Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] before:content with variant breaks autofix in vue #328

Open
illeb opened this issue Mar 17, 2024 · 0 comments
Open

[BUG] before:content with variant breaks autofix in vue #328

illeb opened this issue Mar 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@illeb
Copy link

illeb commented Mar 17, 2024

Describe the bug
It seems that having a before:content with an arbitrary variant (for example, before:content-[\'\']) breaks the autofixer (launched via eslint --ext .js,.vue,.ts . --fix) with the following error:

TypeError: Cannot read properties of null (reading 'type')
Occurred while linting /home/projects/nuxt-starter-t1gumu/app.vue:1
Rule: "tailwindcss/classnames-order"
    at isArrayExpression (file:///home/projects/nuxt-starter-t1gumu/node_modules/eslint-plugin-tailwindcss/lib/util/ast.js:91:92)
    at isVueValidAttributeValue (file:///home/projects/nuxt-starter-t1gumu/node_modules/eslint-plugin-tailwindcss/lib/util/ast.js:113:10)
    at Object.isValidVueAttribute (file:///home/projects/nuxt-starter-t1gumu/node_modules/eslint-plugin-tailwindcss/lib/util/ast.js:176:8)
    at EventEmitter.VAttribute (file:///home/projects/nuxt-starter-t1gumu/node_modules/eslint-plugin-tailwindcss/lib/rules/classnames-order.js:253:25)

The issue seems to be present only if a :class is used in a SFC vue file with a condition, for example:
<h1 :class="{ 'before:content-[\'\'] before:absolute': true }">
In fact,
<h1 class="before:content-[\'\'] before:absolute">
does not cause errors

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/autofix-broken
  2. run a yarn lint --fix in console

Expected behavior
The autofixer should work with no errors

Screenshots
N/A

Environment (please complete the following information):

  • OS: macOS
  • Softwares + version used:
    • "nuxt": "3.11.0"
    • "eslint-plugin-tailwindcss": "3.15.1"
    • "tailwindcss": "3.4.1"
    • "@nuxt/eslint-config": "0.2.0",
    • "@nuxtjs/eslint-module": "4.1.0",

eslint config file or live demo
I managed to ricreate the issue with
https://stackblitz.com/edit/autofix-broken

@illeb illeb added the bug Something isn't working label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant