From d8525e83a79cfcccdf0aea9ac1aaf88c662d1b54 Mon Sep 17 00:00:00 2001 From: chrisweb Date: Sun, 4 Sep 2022 20:56:33 +0200 Subject: [PATCH 1/3] adds documentation for eslint plugin react --- docs/docs.yaml | 1 + docs/eslint-plugin-react.mdx | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 docs/eslint-plugin-react.mdx diff --git a/docs/docs.yaml b/docs/docs.yaml index 19e11d17e..199c46e15 100644 --- a/docs/docs.yaml +++ b/docs/docs.yaml @@ -33,6 +33,7 @@ - testing - typescript - flow + - eslint-plugin-react # This loads the READMEs instead of files in docs/ - title: Packages diff --git a/docs/eslint-plugin-react.mdx b/docs/eslint-plugin-react.mdx new file mode 100644 index 000000000..6786a9ab6 --- /dev/null +++ b/docs/eslint-plugin-react.mdx @@ -0,0 +1,36 @@ +--- +title: 'ESLint Plugin React' +--- + +The eslint rule react/no-unknown-property from the [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) package, with a version > 7.31.1, got a fix which now triggers an eslint error if the emotion css property is used on an element. + +To fix this linting error one solution is to add the following rule to your eslintrc.* configuration file: + +eslintrc.js example: + +```js + "rules": { + "react/no-unknown-property": ['error', { ignore: ['css'] }] + } +``` + +eslintrc.json example: + +```json + "rules": { + "react/no-unknown-property": ["error", { "ignore": ["css"] }] + }, +``` + +eslintrc.yaml example: + +```yaml +rules: + react/no-unknown-property: + - error + - ignore: ["css"] +``` + +> Note +> +> You might want to fine tune your eslint configuration and only apply this rule to a file or a group of files in which the emotion css property is actually being used, to do so you can use the overrides key in your eslint configuration: [ESLint documentation: How do overrides work?](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work) \ No newline at end of file From 23ea000c3f78696a98ae6e3bf11477b2241e2bb6 Mon Sep 17 00:00:00 2001 From: Sam Magura Date: Sat, 10 Sep 2022 17:49:05 -0400 Subject: [PATCH 2/3] Improve writing in eslint-plugin-react page --- docs/eslint-plugin-react.mdx | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/docs/eslint-plugin-react.mdx b/docs/eslint-plugin-react.mdx index 6786a9ab6..c111c2edf 100644 --- a/docs/eslint-plugin-react.mdx +++ b/docs/eslint-plugin-react.mdx @@ -1,36 +1,13 @@ --- -title: 'ESLint Plugin React' +title: 'eslint-plugin-react' --- -The eslint rule react/no-unknown-property from the [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) package, with a version > 7.31.1, got a fix which now triggers an eslint error if the emotion css property is used on an element. +The [`react/no-unknown-property` rule](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md) from [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) will produce an error if the `css` prop is passed to a DOM element. This violation of the rule can be safely ignored because `@emotion/react` intercepts the `css` prop before it is applied to the DOM element. -To fix this linting error one solution is to add the following rule to your eslintrc.* configuration file: - -eslintrc.js example: - -```js - "rules": { - "react/no-unknown-property": ['error', { ignore: ['css'] }] - } -``` - -eslintrc.json example: +The rule can be configured to ignore the `css` prop like so: ```json - "rules": { - "react/no-unknown-property": ["error", { "ignore": ["css"] }] - }, +"rules": { + "react/no-unknown-property": ["error", { "ignore": ["css"] }] +}, ``` - -eslintrc.yaml example: - -```yaml -rules: - react/no-unknown-property: - - error - - ignore: ["css"] -``` - -> Note -> -> You might want to fine tune your eslint configuration and only apply this rule to a file or a group of files in which the emotion css property is actually being used, to do so you can use the overrides key in your eslint configuration: [ESLint documentation: How do overrides work?](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work) \ No newline at end of file From 7896039481f7f5871c5d6ed43aa513e6fdf4642a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 13 Sep 2022 10:23:33 +0200 Subject: [PATCH 3/3] Update docs/eslint-plugin-react.mdx --- docs/eslint-plugin-react.mdx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/eslint-plugin-react.mdx b/docs/eslint-plugin-react.mdx index c111c2edf..88324bd27 100644 --- a/docs/eslint-plugin-react.mdx +++ b/docs/eslint-plugin-react.mdx @@ -7,7 +7,9 @@ The [`react/no-unknown-property` rule](https://github.com/jsx-eslint/eslint-plug The rule can be configured to ignore the `css` prop like so: ```json -"rules": { - "react/no-unknown-property": ["error", { "ignore": ["css"] }] -}, +{ + "rules": { + "react/no-unknown-property": ["error", { "ignore": ["css"] }] + } +} ```