Skip to content

Commit 1058844

Browse files
committed
feat(eslint-config): harden eslint config
1 parent 7157c5a commit 1058844

File tree

5 files changed

+215
-143
lines changed

5 files changed

+215
-143
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@types/react-dom": "18.0.10",
3434
"builtin-modules": "3.3.0",
3535
"cross-env": "7.0.3",
36-
"eslint": "8.31.0",
36+
"eslint": "8.32.0",
3737
"husky": "8.0.3",
3838
"jest": "29.3.1",
3939
"jest-environment-jsdom": "29.3.1",

packages/eslint-config-react/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
"eslint-config-prettier": "8.6.0",
2626
"eslint-plugin-deprecation": "1.3.3",
2727
"eslint-plugin-eslint-comments": "3.2.0",
28-
"eslint-plugin-import": "2.26.0",
29-
"eslint-plugin-jsx-a11y": "6.7.0",
30-
"eslint-plugin-react": "7.31.11",
28+
"eslint-plugin-import": "2.27.4",
29+
"eslint-plugin-jsx-a11y": "6.7.1",
30+
"eslint-plugin-react": "7.32.0",
3131
"eslint-plugin-react-hooks": "4.6.0"
3232
},
3333
"peerDependencies": {
3434
"eslint": ">= 8.5"
3535
},
3636
"devDependencies": {
37-
"eslint": "8.31.0",
37+
"eslint": "8.32.0",
3838
"typescript": "4.9.4"
3939
}
4040
}

packages/eslint-config-react/shared.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ module.exports = {
9898
'react/no-adjacent-inline-elements': 'error', // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
9999
'prefer-object-has-own': 'error', // https://eslint.org/docs/rules/prefer-object-has-own
100100

101+
// Prevent uneeded rerender with object as default props
102+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c8f2813758dea1759ba5ab8caf1920cae9417a43/docs/rules/no-object-type-as-default-prop.md
103+
'react/no-object-type-as-default-prop': 'error',
104+
101105
// We don't use babel-preset-airbnb so we can make those changes
102106
'react/static-property-placement': ['error', 'static public field'],
103107
'react/state-in-constructor': ['error', 'never'],

packages/eslint-config-react/typescript.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ module.exports = {
99
plugins: ['deprecation', '@typescript-eslint'],
1010
rules: {
1111
'deprecation/deprecation': 'warn',
12+
// Enforce T[] instead of Array<T>
13+
'@typescript-eslint/array-type': [
14+
'error',
15+
{
16+
default: 'array',
17+
},
18+
],
19+
// Avoid toString which are going to generate [object Object]
20+
'@typescript-eslint/no-base-to-string': 'error',
21+
// (someCondition === true) => (someCondition)
22+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
23+
'@typescript-eslint/no-unnecessary-condition': 'error',
24+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
25+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
26+
'@typescript-eslint/prefer-for-of': 'error',
27+
'@typescript-eslint/prefer-includes': 'error',
28+
'@typescript-eslint/prefer-optional-chain': 'error',
29+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
30+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
31+
'@typescript-eslint/prefer-ts-expect-error': 'error',
1232
// https://github.com/typescript-eslint/typescript-eslint/issues/4619
1333
'@typescript-eslint/no-misused-promises': [
1434
'error',

0 commit comments

Comments
 (0)