Skip to content

Commit

Permalink
Merge branch 'master-co:dev/beta' into dev/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
0Miles authored Oct 25, 2023
2 parents 7d630f6 + d20a504 commit 18cf929
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/lib/settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const settings = {
functions: ['classnames', 'clsx', 'ctl', 'cva', 'cv', 'classVariant', 'styled'],
functions: ['classnames', 'clsx', 'ctl', 'cva', 'cv', 'classVariant', 'styled(?:\\.\\w+)?'],
ignoredKeys: ['compoundVariants', 'defaultVariants'],
classMatching: '^class(Name)?$',
config: 'master.css.*'
Expand Down
16 changes: 9 additions & 7 deletions packages/eslint-plugin/lib/utils/define-visitors.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const astUtil = require('./ast')

function defineVisitors({ context, options, settings, config }, visitNode) {
function defineVisitors({ context, settings }, visitNode) {

const isFnNode = (node) => {
const calleeStr = astUtil.calleeToString(node.callee || node.tag)
return settings.functions.findIndex((eachFnPattern) => new RegExp('^' + eachFnPattern).test(calleeStr)) !== -1
}

const CallExpression = function (node) {
const calleeStr = astUtil.calleeToString(node.callee)
if (settings.functions.findIndex((name) => calleeStr.startsWith(name)) === -1) {
if (!isFnNode(node)) {
return
}
node.arguments.forEach((arg) => {
Expand Down Expand Up @@ -32,10 +37,7 @@ function defineVisitors({ context, options, settings, config }, visitNode) {
visitNode(node)
},
TaggedTemplateExpression: function (node) {
if (
settings.functions.includes(node.tag.name) ||
settings.functions.includes(node.tag?.object?.name) && node.tag?.type === 'MemberExpression'
) {
if (isFnNode(node)) {
visitNode(node, node.quasi)
return
}
Expand Down

0 comments on commit 18cf929

Please sign in to comment.