1+ // TODO remove these once the full set of rules can be turned on for the repo
2+ // extensions that should be ran against the entire repo
3+ const sharedExtensions = [
4+ 'plugin:react-hooks/recommended' ,
5+
6+ // always extend last to override previous extensions
7+ 'prettier' ,
8+ ] ;
9+
10+ // rules that should be ran against the entire repo
11+ const sharedRules = {
12+ // react hook rules
13+ 'react-hooks/rules-of-hooks' : 'error' ,
14+ 'react-hooks/exhaustive-deps' : 'error' ,
15+ } ;
16+
117module . exports = {
218 env : { node : true } ,
319 root : true ,
420 ignorePatterns : [
21+ // top level directories
522 '__tests__' ,
23+ 'dist' ,
24+ 'node_modules' ,
25+ 'scripts' ,
26+
27+ // config files
628 '.eslintrc.js' ,
729 'jest.config.js' ,
30+ 'jest.setup.ts' ,
31+ 'rollup.config.js' ,
832 'tsup.config.ts' ,
9- 'scripts' ,
10- 'dist' ,
11- 'node_modules' ,
1233
13- // TODO Delete this file once the above directories are no longer ignored
34+ // TODO remove once the full set of rules can be turned on for the repo
1435 'src/react-shim.js' ,
1536
1637 // TODO remove once the icons have been deprecated for v3
1738 'src/primitives/Icon/icons' ,
1839 ] ,
19- extends : [ 'plugin:react-hooks/recommended' ] ,
40+ extends : sharedExtensions ,
2041 plugins : [ 'react-hooks' ] ,
2142 parser : '@typescript-eslint/parser' ,
2243 parserOptions : {
@@ -40,7 +61,7 @@ module.exports = {
4061 'jest/unbound-method' : 'error' ,
4162 } ,
4263 } ,
43- // TODO remove once the larger set of rules is applied to the whole repo.
64+ // TODO remove once the full set of rules can be turned on for the repo
4465 // To keep the rules-of-hooks on for the entire ui-react package while
4566 // we add the larger set of rules incrementally, use an overrides object
4667 // to incrementally apply the new rules
@@ -54,70 +75,75 @@ module.exports = {
5475 // 'src/primitives/**/*',
5576 ] ,
5677 extends : [
57- 'airbnb' ,
58- 'airbnb-typescript' ,
78+ 'eslint:recommended' ,
5979 'plugin:jest/recommended' ,
6080 'plugin:react/recommended' ,
61- 'plugin:react-hooks/recommended' ,
6281 'plugin:@typescript-eslint/recommended-requiring-type-checking' ,
63- 'plugin:prettier/recommended' ,
64- ] ,
65- plugins : [
66- 'react' ,
67- '@typescript-eslint' ,
68- 'react-hooks' ,
69- 'jest' ,
70- 'prettier' ,
82+
83+ // extend last to override previous extensions
84+ ...sharedExtensions ,
7185 ] ,
86+ plugins : [ '@typescript-eslint' , 'jest' , 'react' , 'react-hooks' ] ,
87+ settings : {
88+ react : {
89+ version : 'detect' ,
90+ } ,
91+ } ,
7292 rules : {
93+ ...sharedRules ,
94+
95+ // typescript eslint rules either not in recommended rule set or overridden
7396 '@typescript-eslint/explicit-module-boundary-types' : 2 ,
7497 '@typescript-eslint/member-ordering' : 'error' ,
7598 '@typescript-eslint/no-extra-semi' : 'error' ,
99+ '@typescript-eslint/no-floating-promises' : [ 'off' ] ,
76100 '@typescript-eslint/no-unused-expressions' : [
77101 'error' ,
78102 { allowTernary : true } ,
79103 ] ,
80- '@typescript-eslint/no-floating-promises ' : [ 'off ' ] ,
104+ '@typescript-eslint/no-use-before-define ' : [ 'error ' ] ,
81105 '@typescript-eslint/no-unused-vars' : [
82106 'error' ,
83107 { argsIgnorePattern : '_' , varsIgnorePattern : '_' } ,
84108 ] ,
85109 '@typescript-eslint/prefer-nullish-coalescing' : 'error' ,
86110 '@typescript-eslint/restrict-template-expressions' : [ 'off' ] ,
87111 '@typescript-eslint/unbound-method' : 'error' ,
112+
113+ // eslint rules either not in recommended rule set or overridden
88114 'comma-dangle' : [ 'error' , 'only-multiline' ] ,
89115 'function-paren-newline' : 'off' ,
90116 'generator-star-spacing' : 'off' ,
91117 'global-require' : 'off' ,
92118 'implicit-arrow-linebreak' : 'off' ,
93- 'import/no-cycle' : 'off' ,
94- 'import/no-extraneous-dependencies' : [ 'off' ] ,
95- 'import/prefer-default-export' : 'off' ,
96- 'jest/expect-expect' : [ 'error' , { assertFunctionNames : [ 'expect*' ] } ] ,
97- 'jest/no-mocks-import' : 'off' ,
98119 'max-params' : 2 ,
99120 'no-alert' : 'error' ,
100121 'no-console' : 'error' ,
122+ 'no-eval' : 'error' ,
101123 'no-tabs' : [ 'error' , { allowIndentationTabs : true } ] ,
124+ 'no-unused-vars' : 'off' , // prefer @typescript -eslint version
125+ 'prefer-const' : 'error' ,
102126 'prefer-destructuring' : [ 'error' , { array : false , object : true } ] ,
103- 'prettier/prettier' : [ 'error' ] ,
127+
128+ // jest rules either not in recommended rule set or overridden
129+ 'jest/expect-expect' : [ 'error' , { assertFunctionNames : [ 'expect*' ] } ] ,
130+ 'jest/no-mocks-import' : 'off' ,
131+
132+ // react rules either not in recommended rule set or overridden
133+ 'react/destructuring-assignment' : [ 'error' , 'always' ] ,
134+ 'react/jsx-boolean-value' : 'error' ,
135+ 'react/jsx-no-constructed-context-values' : [ 'error' ] ,
136+ 'react/jsx-no-useless-fragment' : [ 'error' , { allowExpressions : true } ] ,
104137 'react/jsx-props-no-spreading' : 'off' ,
105138 'react/jsx-wrap-multilines' : [ 'error' , { declaration : 'ignore' } ] ,
106139 'react/no-array-index-key' : 'off' ,
140+ 'react/no-danger' : [ 'error' ] ,
141+ 'react/no-unused-prop-types' : [ 'error' ] ,
107142 'react/prop-types' : 'off' ,
108- 'react/require-default-props' : [
109- 2 ,
110- { ignoreFunctionalComponents : true } ,
111- ] ,
112143 'react/static-property-placement' : [ 'error' , 'static public field' ] ,
113- 'react-hooks/rules-of-hooks' : 'error' ,
114- 'react-hooks/exhaustive-deps' : 'error' ,
115144 } ,
116145 } ,
117146 ] ,
118147
119- rules : {
120- 'react-hooks/rules-of-hooks' : 'error' ,
121- 'react-hooks/exhaustive-deps' : 'error' ,
122- } ,
148+ rules : sharedRules ,
123149} ;
0 commit comments