diff --git a/lib/util/ast.js b/lib/util/ast.js
index 9e942be..a6ed24d 100644
--- a/lib/util/ast.js
+++ b/lib/util/ast.js
@@ -121,7 +121,6 @@ function isVueValidAttributeValue(node) {
case isArrayExpression(node): // ['tw-unknown-class']
case isObjectExpression(node): // {'tw-unknown-class': true}
return true;
- break;
default:
return false;
}
@@ -218,10 +217,8 @@ function extractValueFromNode(node) {
switch (node.value.expression.type) {
case 'ArrayExpression':
return node.value.expression.elements;
- break;
case 'ObjectExpression':
return node.value.expression.properties;
- break;
}
return node.value.expression.value;
default:
@@ -302,7 +299,7 @@ function parseNodeRecursive(rootNode, childNode, cb, skipConditional = false, is
return;
case 'ObjectExpression':
childNode.properties.forEach((prop) => {
- const isUsedByClassNamesPlugin = rootNode.callee && rootNode.callee.name === 'classnames';
+ const isUsedByClassNamesPlugin = (rootNode.callee && rootNode.callee.name === 'classnames') || rootNode.type === 'VAttribute';
if (prop.type === 'SpreadElement') {
// Ignore spread elements
diff --git a/tests/lib/rules/no-custom-classname.js b/tests/lib/rules/no-custom-classname.js
index f2161b0..4259aad 100644
--- a/tests/lib/rules/no-custom-classname.js
+++ b/tests/lib/rules/no-custom-classname.js
@@ -1089,6 +1089,41 @@ ruleTester.run("no-custom-classname", rule, {
filename: "test.vue",
parser: require.resolve("vue-eslint-parser"),
},
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ options: [
+ {
+ config: {
+ prefix: "tw-",
+ theme: {
+ extend: {},
+ },
+ },
+ },
+ ],
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ }
],
invalid: [
@@ -1435,6 +1470,65 @@ ruleTester.run("no-custom-classname", rule, {
filename: "test.vue",
parser: require.resolve("vue-eslint-parser"),
},
+ {
+ code: `
+
+
+
+
+ `,
+ options: [
+ {
+ config: {
+ prefix: "tw-",
+ theme: {
+ extend: {},
+ },
+ },
+ },
+ ],
+ errors: generateErrors(
+ "text-red-200 tw-unknown-class tw-unknown-class-two tw-unknown-class-three"
+ ),
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ errors: generateErrors("baz foo"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ errors: generateErrors("unknown baz foo"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ errors: generateErrors("unknown baz foo tw-unknown-class"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ errors: generateErrors("tw-hidden custom 🧑💻 bg-tw"),
+ },
+ {
+ code: `Issue #319
`,
+ filename: "test.vue",
+ parser: require.resolve("vue-eslint-parser"),
+ errors: generateErrors("baz foo"),
+ },
{
code: `
Custom group name variant with invalid class name
`,
errors: generateErrors("group-hover/edit:unknown-class"),