Skip to content

Commit

Permalink
Improve(ESLint): Support object functions like styled.h1
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Oct 25, 2023
1 parent 405c579 commit 89039fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/lib/utils/define-visitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const astUtil = require('./ast')
function defineVisitors({ context, options, settings, config }, visitNode) {
const CallExpression = function (node) {
const calleeStr = astUtil.calleeToString(node.callee)
if (settings.functions.findIndex((name) => calleeStr === name) === -1) {
if (settings.functions.findIndex((name) => calleeStr.startsWith(name)) === -1) {
return
}
node.arguments.forEach((arg) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/eslint-plugin/tests/class-matching/react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@ new RuleTester({
`,
errors: [{ messageId: 'invalidClass' }],
},
{
code: `
import React from 'react'
import { styled } from '@master/css.react'
const H1 = styled.h1('text-align:cente')
export default () => (
<H1>Hello World</H1>
)
`,
errors: [{ messageId: 'invalidClass' }],
},
]
})

0 comments on commit 89039fe

Please sign in to comment.