francoismassart / eslint-plugin-tailwindcss

ESLint plugin for Tailwind CSS usage
https://www.npmjs.com/package/eslint-plugin-tailwindcss
MIT License
1.5k stars 71 forks source link

[BUG] no-contradicting-classname breaks eslint #177

Open tbo opened 1 year ago

tbo commented 1 year ago

Describe the bug Using the no-contradicting-classname with nested arrays in JSX breaks ESLint:

Oops! Something went wrong! :(

ESLint: 8.27.0

AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided

To Reproduce This will throw the error if used with the ESLint CLI:

<a href="#" class={['inline inline-flex']}>
  bug
</a>

Environment:

Additional context

My editor manages to show the linter warning, but executing the ESLint CLI throws the error message mentioned above.

TheMythologist commented 1 year ago

Facing this issue as well.

Environment:

francoismassart commented 1 year ago

@tbo & @TheMythologist please take the latest beta for a test run on your project(s):

npm i eslint-plugin-tailwindcss@3.12.2-beta.0

How is it working for you both ?

TheMythologist commented 1 year ago

Nope, the error still occurs for me:

AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided
    at assertValidNodeInfo (<truncated>\node_modules\.pnpm\eslint@8.41.0\node_modules\eslint\lib\linter\report-translator.js:83:9)
    at <truncated>\node_modules\.pnpm\eslint@8.41.0\node_modules\eslint\lib\linter\report-translator.js:317:9        
    at Object.report (<truncated>\node_modules\.pnpm\eslint@8.41.0\node_modules\eslint\lib\linter\linter.js:1021:41) 
    at <truncated>\node_modules\.pnpm\eslint-plugin-tailwindcss@3.12.2-beta.0_tailwindcss@3.3.2\node_modules\eslint-plugin-tailwindcss\lib\rules\no-contradicting-classname.js:146:21
    at Array.forEach (<anonymous>)
    at <truncated>\node_modules\.pnpm\eslint-plugin-tailwindcss@3.12.2-beta.0_tailwindcss@3.3.2\node_modules\eslint-plugin-tailwindcss\lib\rules\no-contradicting-classname.js:143:29
    at Array.forEach (<anonymous>)
    at parseForContradictingClassNames (<truncated>\node_modules\.pnpm\eslint-plugin-tailwindcss@3.12.2-beta.0_tailwindcss@3.3.2\node_modules\eslint-plugin-tailwindcss\lib\rules\no-contradicting-classname.js:107:20)
    at parseNodeRecursive (<truncated>\node_modules\.pnpm\eslint-plugin-tailwindcss@3.12.2-beta.0_tailwindcss@3.3.2\node_modules\eslint-plugin-tailwindcss\lib\util\ast.js:326:5)
    at parseNodeRecursive (<truncated>\node_modules\.pnpm\eslint-plugin-tailwindcss@3.12.2-beta.0_tailwindcss@3.3.2\node_modules\eslint-plugin-tailwindcss\lib\util\ast.js:278:9)
 ELIFECYCLE  Command failed with exit code 2.

Environment:

OS: Windows ESLint 8.41.0 eslint-plugin-tailwindcss 3.12.2-beta.0 pnpm@8.6.0 Monorepo setup

Let me know if there is any other information you need, I'll be glad to help :)

TheMythologist commented 1 year ago

Note: I took a look at the attempted fix and the location that caused the error, seems like it occurred in a different switch block (childNode.type was ConditionalExpression instead of ArrayExpression). Perhaps this error will occur for more than just these 2 switch blocks?

djoume commented 4 weeks ago

Using eslint-plugin-tailwindcss 3.17.4, this still breaks eslint:

export const Test = () => {
  return <div className={`${"block inline"}`}></div>;
};
Oops! Something went wrong! :(

ESLint: 9.10.0

AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided
    at assertValidNodeInfo (/Users/djoume/src/fata-app/node_modules/eslint/lib/linter/report-translator.js:83:9)
    at /Users/djoume/src/fata-app/node_modules/eslint/lib/linter/report-translator.js:339:9
    at FileContext.report (/Users/djoume/src/fata-app/node_modules/eslint/lib/linter/linter.js:1047:41)
    at /Users/djoume/src/fata-app/node_modules/eslint-plugin-tailwindcss/lib/rules/no-contradicting-classname.js:146:21
    at Array.forEach (<anonymous>)
    at /Users/djoume/src/fata-app/node_modules/eslint-plugin-tailwindcss/lib/rules/no-contradicting-classname.js:143:29
    at Array.forEach (<anonymous>)
    at parseForContradictingClassNames (/Users/djoume/src/fata-app/node_modules/eslint-plugin-tailwindcss/lib/rules/no-contra
dicting-classname.js:107:20)
    at parseNodeRecursive (/Users/djoume/src/fata-app/node_modules/eslint-plugin-tailwindcss/lib/util/ast.js:345:5)
    at /Users/djoume/src/fata-app/node_modules/eslint-plugin-tailwindcss/lib/util/ast.js:285:11