Skip to content

Commit 09b9dd0

Browse files
committed
[Docs] no-unknown-property add a mention about using ignores properties with libraries that add props
1 parent 3f29e77 commit 09b9dd0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/rules/no-unknown-property.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var AnotherComponent = <Foo.bar for="bar" />;
4343
// Custom web components are ignored
4444
var MyElem = <div class="foo" is="my-elem"></div>;
4545
var AtomPanel = <atom-panel class="foo"></atom-panel>;
46-
4746
```
4847

4948
## Rule Options
@@ -57,6 +56,24 @@ var AtomPanel = <atom-panel class="foo"></atom-panel>;
5756
- `enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
5857
- `ignore`: optional array of property and attribute names to ignore during validation.
5958

59+
60+
If you are using a library that passes something as a prop to JSX elements, it is recommended to add those props to the ignored properties.
61+
62+
For example, if you use [emotion](https://emotion.sh/docs/introduction) and its [`css` prop](https://emotion.sh/docs/css-prop)),
63+
add the following to your `.eslintrc` config file:
64+
```js
65+
...
66+
"react/no-unknown-property": ['error', { ignore: ['css'] }]
67+
...
68+
69+
```
70+
71+
Now, the following code passes:
72+
```js
73+
var StyledDiv = <div css={{color: 'pink'}}></div>
74+
```
75+
76+
6077
## When Not To Use It
6178

6279
If you are not using JSX you can disable this rule.

tests/lib/rules/no-unknown-property.js

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ ruleTester.run('no-unknown-property', rule, {
9292
code: '<div someProp="bar"></div>;',
9393
options: [{ ignore: ['someProp'] }],
9494
},
95+
{
96+
code: '<div css={{flex: 1}}></div>;',
97+
options: [{ ignore: ['css'] }],
98+
},
9599

96100
// aria-* attributes should work
97101
{ code: '<button aria-haspopup="true">Click me to open pop up</button>;' },

0 commit comments

Comments
 (0)