-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
eslint: Unknown property 'css' found react/no-unknown-property #2878
Comments
Namely, that emotion should at least support, and ideally require, the attribute name to have a data- prefix, instead of just “css”. |
You should configure that ESLint rule to ignore the
Allowing/requiring users to write |
It’s already misleading, because DOM elements can’t have a css attribute. |
ljharb suggested some solutions to the problem in his follow up comment jsx-eslint/eslint-plugin-react#3384 (comment) and then sjarva gave an example of a simple solution in her comment jsx-eslint/eslint-plugin-react#3384 (comment) (based on suggestion in the edited comment jsx-eslint/eslint-plugin-react#3384 (comment) from diegohaz, to use ignore). The solution is to use
eslintrc.js version: "rules": {
"react/no-unknown-property": ['error', { ignore: ['css'] }]
} eslintrc.json version "rules": {
"react/no-unknown-property": ["error", { "ignore": ["css"] }]
}, Also worth mentioning is probably that if you want to apply this extra rule only to a file or a group of files you can use the overrides key: eslint overrides configuration I used this suggestion using "eslint-plugin-react": "7.31.5" and it fixed my linting @srmagura: so this ticket probably more a "documentation update" issue than a "bug" issue, having an emotion documentation page, that explains how to add the extra configuration if using the "eslint react" plugin, would help users that use emotion for the first time, similar to that emotion documentation page that is also there to explain how to configure tsconfig for typescript users |
Current behavior:
eslint react plugin (eslint-plugin-react) emits error that the "css" property is unknown
the rule documentation is here: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
the error appears if you use a version of eslint-plugin-react > 7.31.1
To reproduce:
https://codesandbox.io/s/interesting-raman-2ko96i?file=/src/App.tsx
I did not use the emotion codesandbox template but created a new codesandbox with nodejs as environment, to have a terminal and to be able to run the "npm run lint" command in that terminal (I think you need to be logged in codesanbox to run commands in the terminal)
In the App.tsx I listed the steps I did to create this example
Expected behavior:
no linting error "Unknown property 'css' found react/no-unknown-property"
Environment information:
As suggested by ljharb, in the issue 3384 over at eslint-plugin-react, here is a ticket for emotion js
The text was updated successfully, but these errors were encountered: