Skip to content

Commit 8b5af49

Browse files
committed
✨ add react conf
1 parent e1817ec commit 8b5af49

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

eslint-config-react/base.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
extends:
22
- '@dudeofawesome/browser'
33
- 'plugin:react/recommended'
4+
- 'plugin:react-hooks/recommended'
5+
- 'plugin:jsx-a11y/recommended'
6+
7+
rules:
8+
# limit max element nesting to reduce component complexity
9+
react/jsx-max-depth: 'error'
10+
11+
# prefer ES6 classes
12+
react/prefer-es6-class: 'error'
13+
14+
# prefer functional components
15+
react/prefer-stateless-function: 'error'
16+
17+
react/no-children-prop: 'off'
18+
19+
react/jsx-key: 'error'

eslint-config-react/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
"test": "node --require ts-node/register --test test/index.ts"
2121
},
2222
"dependencies": {
23-
"eslint-plugin-react": "^7.33.2"
23+
"eslint-plugin-jsx-a11y": "^6.7.1",
24+
"eslint-plugin-react": "^7.33.2",
25+
"eslint-plugin-react-hooks": "^4.6.0"
2426
},
2527
"peerDependencies": {
2628
"@dudeofawesome/eslint-config": "^1.3.0",
2729
"eslint": "^8.49.0"
30+
},
31+
"devDependencies": {
32+
"@types/react": "^18.2.23",
33+
"react": "^18.2.0"
2834
}
2935
}

eslint-config-react/test/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ describe('eslint-config-react', () => {
1212
defaultTestSet(linter);
1313

1414
describe('passes', () => {
15-
it(`should pass radix`, async () =>
15+
it(`should parse jsx`, async () =>
1616
testNoFail({
1717
linter,
18-
code: `parseInt('10');\n`,
18+
code: `import React from 'react';\n\nexport const A = () => <div></div>;\n`,
1919
file_path: 'index.jsx',
2020
}));
2121
});
@@ -36,5 +36,17 @@ describe('eslint-config-react', () => {
3636
ruleId: 'no-console',
3737
file_path: 'index.jsx',
3838
}));
39+
40+
it(`should fail react/jsx-key`, () =>
41+
testRuleFail({
42+
linter,
43+
code: `import React from 'react';
44+
45+
export const Foo = (props) => <div>{props}</div>;
46+
export const Bar = (props) => props.list.map((l) => <Foo text={l}></Foo>);
47+
`,
48+
ruleId: 'react/jsx-key',
49+
file_path: 'index.jsx',
50+
}));
3951
});
4052
});

package-lock.json

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)