Skip to content

Commit

Permalink
Eslint config: fix support for the latest react/no-unknown-property
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnzlml committed Sep 7, 2022
1 parent 310f96f commit ada90c3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,15 @@ exports[`rules snapshot: all stable rules 1`] = `
"react/no-this-in-sfc": 2,
"react/no-typos": 0,
"react/no-unescaped-entities": 2,
"react/no-unknown-property": 2,
"react/no-unknown-property": [
2,
{
"ignore": [
"jsx",
"global",
],
},
],
"react/no-unsafe": 0,
"react/no-unstable-nested-components": [
2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,15 @@ exports[`React preset: React preset 1`] = `
"react/no-this-in-sfc": 2,
"react/no-typos": 0,
"react/no-unescaped-entities": 2,
"react/no-unknown-property": 2,
"react/no-unknown-property": [
2,
{
"ignore": [
"jsx",
"global",
],
},
],
"react/no-unsafe": 0,
"react/no-unstable-nested-components": [
2,
Expand Down
12 changes: 11 additions & 1 deletion src/eslint-config-adeira/src/presets/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,17 @@ module.exports = ({
'react/no-this-in-sfc': ERROR,
'react/no-typos': OFF,
'react/no-unescaped-entities': ERROR,
'react/no-unknown-property': ERROR,
'react/no-unknown-property': [
ERROR,
{
ignore: [
// To support `<style global jsx>` from Next.js
// See: https://nextjs.org/docs/basic-features/built-in-css-support#css-in-js
'jsx',
'global',
],
},
],
'react/no-unsafe': OFF,
'react/no-unstable-nested-components': [ERROR, { allowAsProps: true }],
'react/no-unused-class-component-methods': ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import sx from '@adeira/sx';

export default function MyCustomComponent(): Node {
// $FlowExpectedError[incompatible-use] yadada
return <div xstyle={styles.yadada} />;
return <div xstyle={styles.yadada} />; // eslint-disable-line react/no-unknown-property
}

const styles = sx.create({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import sx from '@adeira/sx';
const unrelatedCallExpression = (fake: string) => fake;

export default function MyComponent(): Node {
// eslint-disable-next-line react/no-unknown-property -- (should be "className" instead of "styles")
return <div styles={unrelatedCallExpression('aaa')} />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Node } from 'react';
import sx from '@adeira/sx';

export default function MyCustomComponent(): Node {
return <div xstyle={styles.spacing} />;
return <div xstyle={styles.spacing} />; // eslint-disable-line react/no-unknown-property
}

const styles = sx.create({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Node } from 'react';
import sx from '@adeira/sx';

export default function MyCustomComponent(): Node {
// eslint-disable-next-line dot-notation
// eslint-disable-next-line dot-notation, react/no-unknown-property
return <div xstyle={styles['spacing']} />;
}

Expand Down

0 comments on commit ada90c3

Please sign in to comment.