@lunit/eslint-config 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,24 @@
1
- MIT License
1
+ @lunit/eslint-config
2
+
3
+ Copyright (c) Lunit Inc. All rights reserved.
2
4
 
3
- Copyright (c) 2020-present Lunit.inc
5
+ MIT License
4
6
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
11
14
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
14
17
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,38 +1,81 @@
1
- # ESLint config
1
+ # @lunit/eslint-config
2
2
 
3
- ## Basic Usage
3
+ A TypeScript ESLint ruleset designed for lunit projects based on [@rushstack/eslint-config](https://github.com/microsoft/rushstack/tree/main/eslint/eslint-config).
4
4
 
5
- Install dependencies.
5
+ ## Installation
6
6
 
7
- ```sh
8
- npm install eslint @lunit/eslint-config eslint-config-prettier --save-dev
7
+ ```shell
8
+ npm install --save-dev @lunit/eslint-config
9
9
  ```
10
10
 
11
- Add this config into package.json if the project is a React application.
12
-
13
- ```json
14
- {
15
- "eslintConfig": {
16
- "extends": [
17
- "@lunit",
18
- "prettier",
19
- "prettier/react",
20
- "prettier/@typescript-eslint"
21
- ]
22
- }
23
- }
11
+ ## Usage
12
+
13
+ Referring to the [sapmple-project](./sample-project/) folder, create [eslint-config](./sample-project/eslint-config/) folder in the project repository root folder, add [index.js](./sample-project/eslint-config/index.js) file, and then extend the **eslint-config** folder to the [.eslintrc.cjs](./sample-project/.eslintrc.cjs) file.
14
+
15
+ ```shell
16
+ # Project folder structure
17
+ sample-project/
18
+ ├── .eslintrc.cjs
19
+ └── eslint-config
20
+ ├── index.js
21
+ └── mixins
22
+ └── react.js
23
+ ```
24
+
25
+ ```javascript
26
+ // .eslintrc.cjs
27
+ module.exports = {
28
+ ...
29
+ extends: [
30
+ './eslint-config', // Extend common ESLint config
31
+ ],
32
+ settings: {
33
+ react: {
34
+ // Specifies the current React version (e.g. version: '18.2')
35
+ // If not specified (default 'detect'), the entire React library will be loaded,
36
+ // which may slow down the linting process.
37
+ version: 'detect',
38
+ },
39
+ },
40
+ ...
41
+ };
42
+ ```
43
+
44
+ If necessary, add your own mixin to the [eslint-config/mixins](./sample-project/eslint-config/mixins/) folder and use it, or use the mixins in [@rushstack/eslint-config/mixins](https://github.com/microsoft/rushstack/tree/main/eslint/eslint-config/mixins). (Refer to [eslint-config/index.js](./sample-project/eslint-config/index.js))
45
+
46
+ ```javascript
47
+ // eslint-config/index.js
48
+ module.exports = {
49
+ ...
50
+ extends: [
51
+ // (required) Extend the @lunit/eslint-config.
52
+ // (@rushstack/eslint-config/profile/web-app is included by default.)
53
+ '@lunit/eslint-config',
54
+ // React mixin provided by rushstack (requires installation of @rushstack/eslint-config package)
55
+ // '@rushstack/eslint-config/mixins/react',
56
+ // You can create and use your own mixin as follows.
57
+ './mixins/react',
58
+ ],
59
+ ...
60
+ };
61
+ ```
62
+
63
+ <!--
64
+ To use [@rushstack/eslint-config/mixins/react](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-config/mixins/react.js) mixin, you need to install the package as follow.
65
+
66
+ ```shell
67
+ npm install --save-dev @rushstack/eslint-config
24
68
  ```
69
+ -->
70
+
71
+ Refer to the default settings in [@lunit/eslint-config/index.js](./index.js) & [@rushstack/eslint-config/profile/web-app](https://github.com/microsoft/rushstack/blob/main/eslint/eslint-config/profile/_common.js) and add your own rules to the config if necessary.
72
+ Any esconfig rule entries added must have a valid **RATIONALE**.
25
73
 
26
- Or add this config into package.json if the project is not a React application. (like a Node.js application)
27
-
28
- ```json
29
- {
30
- "eslintConfig": {
31
- "extends": [
32
- "@lunit/eslint-config/without-react",
33
- "prettier",
34
- "prettier/@typescript-eslint"
35
- ]
36
- }
37
- }
38
- ```
74
+ ```javascript
75
+ rules: {
76
+ ...
77
+ // RATIONALE : Enforce consistent function types for function components.
78
+ 'react/function-component-definition': 'error',
79
+ ...
80
+ },
81
+ ```
package/index.js CHANGED
@@ -1,299 +1,43 @@
1
- const restrictedGlobals = require('confusing-browser-globals');
2
- const {typescript} = require('./rules');
1
+ /*
2
+ * @rushstack/eslint-patch is used to include plugins as dev
3
+ * dependencies instead of imposing them as peer dependencies
4
+ *
5
+ * https://www.npmjs.com/package/@rushstack/eslint-patch
6
+ */
7
+ require('@rushstack/eslint-patch/modern-module-resolution');
3
8
 
4
9
  module.exports = {
5
- root: true,
6
-
7
- parser: 'babel-eslint',
8
-
9
- plugins: ['import', 'jsx-a11y', 'react', 'react-hooks'],
10
-
11
- env: {
12
- browser: true,
13
- commonjs: true,
14
- es6: true,
15
- jest: true,
16
- node: true,
17
- },
18
-
19
- parserOptions: {
20
- ecmaVersion: 2018,
21
- sourceType: 'module',
22
- ecmaFeatures: {
23
- jsx: true,
24
- },
25
- },
26
-
10
+ extends: ['@rushstack/eslint-config/profile/web-app'],
11
+ plugins: [],
12
+ rules: {},
27
13
  settings: {
28
14
  react: {
29
15
  version: 'detect',
30
16
  },
31
17
  },
32
-
33
18
  overrides: [
34
19
  {
35
- files: ['**/*.ts?(x)'],
36
- parser: '@typescript-eslint/parser',
37
- parserOptions: {
38
- ecmaVersion: 2018,
39
- sourceType: 'module',
40
- ecmaFeatures: {
41
- jsx: true,
42
- },
43
-
44
- // typescript-eslint specific options
45
- warnOnUnsupportedTypeScriptVersion: true,
46
- },
47
- plugins: ['@typescript-eslint'],
48
- // If adding a typescript-eslint version of an existing ESLint rule,
49
- // make sure to disable the ESLint rule here.
20
+ files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
50
21
  rules: {
51
- // TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
52
- 'default-case': 'off',
53
- // 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
54
- 'no-dupe-class-members': 'off',
55
- // 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
56
- 'no-undef': 'off',
57
-
58
- // Add TypeScript specific rules (and turn off ESLint equivalents)
59
- '@typescript-eslint/consistent-type-assertions': 'warn',
60
- 'no-array-constructor': 'off',
61
- '@typescript-eslint/no-array-constructor': 'warn',
62
- 'no-use-before-define': 'off',
63
- '@typescript-eslint/no-use-before-define': [
64
- 'warn',
65
- {
66
- functions: false,
67
- classes: false,
68
- variables: false,
69
- typedefs: false,
70
- },
71
- ],
72
- 'no-unused-expressions': 'off',
73
- '@typescript-eslint/no-unused-expressions': [
74
- 'error',
75
- {
76
- allowShortCircuit: true,
77
- allowTernary: true,
78
- allowTaggedTemplates: true,
79
- },
80
- ],
81
- 'no-unused-vars': 'off',
82
- '@typescript-eslint/no-unused-vars': [
83
- 'warn',
84
- {
85
- args: 'none',
86
- ignoreRestSiblings: true,
87
- },
88
- ],
89
- 'no-useless-constructor': 'off',
90
- '@typescript-eslint/no-useless-constructor': 'warn',
91
-
92
- ...typescript,
22
+ // RATIONALE : Too many parts are initialized to null, so turn it off for now.
23
+ '@rushstack/no-new-null': 'off',
93
24
  },
94
25
  },
95
26
  {
96
- files: ['**/*.stories.{js,jsx,ts,tsx}'],
27
+ files: ['*.ts', '*.tsx'],
97
28
  rules: {
98
- 'react-hooks/rules-of-hooks': 'off',
99
- }
100
- }
101
- ],
102
-
103
- // NOTE: When adding rules here, you need to make sure they are compatible with
104
- // `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.
105
- rules: {
106
- // http://eslint.org/docs/rules/
107
- 'array-callback-return': 'warn',
108
- 'default-case': ['warn', {commentPattern: '^no default$'}],
109
- 'dot-location': ['warn', 'property'],
110
- eqeqeq: ['warn', 'smart'],
111
- 'new-parens': 'warn',
112
- 'no-array-constructor': 'warn',
113
- 'no-caller': 'warn',
114
- 'no-cond-assign': ['warn', 'except-parens'],
115
- 'no-const-assign': 'warn',
116
- 'no-control-regex': 'warn',
117
- 'no-delete-var': 'warn',
118
- 'no-dupe-args': 'warn',
119
- 'no-dupe-class-members': 'warn',
120
- 'no-dupe-keys': 'warn',
121
- 'no-duplicate-case': 'warn',
122
- 'no-empty-character-class': 'warn',
123
- 'no-empty-pattern': 'warn',
124
- 'no-eval': 'warn',
125
- 'no-ex-assign': 'warn',
126
- 'no-extend-native': 'warn',
127
- 'no-extra-bind': 'warn',
128
- 'no-extra-label': 'warn',
129
- 'no-fallthrough': 'warn',
130
- 'no-func-assign': 'warn',
131
- 'no-implied-eval': 'warn',
132
- 'no-invalid-regexp': 'warn',
133
- 'no-iterator': 'warn',
134
- 'no-label-var': 'warn',
135
- 'no-labels': ['warn', {allowLoop: true, allowSwitch: false}],
136
- 'no-lone-blocks': 'warn',
137
- 'no-loop-func': 'warn',
138
- 'no-mixed-operators': [
139
- 'warn',
140
- {
141
- groups: [
142
- ['&', '|', '^', '~', '<<', '>>', '>>>'],
143
- ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
144
- ['&&', '||'],
145
- ['in', 'instanceof'],
146
- ],
147
- allowSamePrecedence: false,
148
- },
149
- ],
150
- 'no-multi-str': 'warn',
151
- 'no-native-reassign': 'warn',
152
- 'no-negated-in-lhs': 'warn',
153
- 'no-new-func': 'warn',
154
- 'no-new-object': 'warn',
155
- 'no-new-symbol': 'warn',
156
- 'no-new-wrappers': 'warn',
157
- 'no-obj-calls': 'warn',
158
- 'no-octal': 'warn',
159
- 'no-octal-escape': 'warn',
160
- // TODO: Remove this option in the next major release of CRA.
161
- // https://eslint.org/docs/user-guide/migrating-to-6.0.0#-the-no-redeclare-rule-is-now-more-strict-by-default
162
- 'no-redeclare': ['warn', {builtinGlobals: false}],
163
- 'no-regex-spaces': 'warn',
164
- 'no-restricted-syntax': ['warn', 'WithStatement'],
165
- 'no-script-url': 'warn',
166
- 'no-self-assign': 'warn',
167
- 'no-self-compare': 'warn',
168
- 'no-sequences': 'warn',
169
- 'no-shadow-restricted-names': 'warn',
170
- 'no-sparse-arrays': 'warn',
171
- 'no-template-curly-in-string': 'warn',
172
- 'no-this-before-super': 'warn',
173
- 'no-throw-literal': 'warn',
174
- 'no-undef': 'error',
175
- 'no-restricted-globals': ['error'].concat(restrictedGlobals),
176
- 'no-unreachable': 'warn',
177
- 'no-unused-expressions': [
178
- 'error',
179
- {
180
- allowShortCircuit: true,
181
- allowTernary: true,
182
- allowTaggedTemplates: true,
183
- },
184
- ],
185
- 'no-unused-labels': 'warn',
186
- 'no-unused-vars': [
187
- 'warn',
188
- {
189
- args: 'none',
190
- ignoreRestSiblings: true,
191
- },
192
- ],
193
- 'no-use-before-define': [
194
- 'warn',
195
- {
196
- functions: false,
197
- classes: false,
198
- variables: false,
199
- },
200
- ],
201
- 'no-useless-computed-key': 'warn',
202
- 'no-useless-concat': 'warn',
203
- 'no-useless-constructor': 'warn',
204
- 'no-useless-escape': 'warn',
205
- 'no-useless-rename': [
206
- 'warn',
207
- {
208
- ignoreDestructuring: false,
209
- ignoreImport: false,
210
- ignoreExport: false,
29
+ // RATIONALE : Enforcing type definitions where type inference is sufficient
30
+ '@rushstack/typedef-var': 'off',
31
+ // RATIONALE : According to the documentation, it can be used in projects that use many classes,
32
+ // but it is unnecessary because the development pattern is functional.
33
+ '@typescript-eslint/explicit-member-accessibility': 'off',
34
+ // RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
35
+ '@typescript-eslint/explicit-function-return-type': 'off',
211
36
  },
212
- ],
213
- 'no-with': 'warn',
214
- 'no-whitespace-before-property': 'warn',
215
- 'react-hooks/exhaustive-deps': 'warn',
216
- 'require-yield': 'warn',
217
- 'rest-spread-spacing': ['warn', 'never'],
218
- strict: ['warn', 'never'],
219
- 'unicode-bom': ['warn', 'never'],
220
- 'use-isnan': 'warn',
221
- 'valid-typeof': 'warn',
222
- 'no-restricted-properties': [
223
- 'error',
224
- {
225
- object: 'require',
226
- property: 'ensure',
227
- message:
228
- 'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
229
- },
230
- {
231
- object: 'System',
232
- property: 'import',
233
- message:
234
- 'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
235
- },
236
- ],
237
- 'getter-return': 'warn',
238
-
239
- // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
240
- 'import/first': 'error',
241
- 'import/no-amd': 'error',
242
- 'import/no-webpack-loader-syntax': 'error',
243
-
244
- // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
245
- 'react/forbid-foreign-prop-types': ['warn', {allowInPropTypes: true}],
246
- 'react/jsx-no-comment-textnodes': 'warn',
247
- 'react/jsx-no-duplicate-props': 'warn',
248
- 'react/jsx-no-target-blank': 'warn',
249
- 'react/jsx-no-undef': 'error',
250
- 'react/jsx-pascal-case': [
251
- 'warn',
252
- {
253
- allowAllCaps: true,
254
- ignore: [],
255
- },
256
- ],
257
- 'react/jsx-uses-react': 'warn',
258
- 'react/jsx-uses-vars': 'warn',
259
- 'react/no-danger-with-children': 'warn',
260
- // Disabled because of undesirable warnings
261
- // See https://github.com/facebook/create-react-app/issues/5204 for
262
- // blockers until its re-enabled
263
- // 'react/no-deprecated': 'warn',
264
- 'react/no-direct-mutation-state': 'warn',
265
- 'react/no-is-mounted': 'warn',
266
- 'react/no-typos': 'error',
267
- 'react/react-in-jsx-scope': 'error',
268
- 'react/require-render-return': 'error',
269
- 'react/style-prop-object': 'warn',
270
-
271
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
272
- 'jsx-a11y/accessible-emoji': 'warn',
273
- 'jsx-a11y/alt-text': 'warn',
274
- 'jsx-a11y/anchor-has-content': 'warn',
275
- 'jsx-a11y/anchor-is-valid': [
276
- 'warn',
277
- {
278
- aspects: ['noHref', 'invalidHref'],
279
- },
280
- ],
281
- 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
282
- 'jsx-a11y/aria-props': 'warn',
283
- 'jsx-a11y/aria-proptypes': 'warn',
284
- 'jsx-a11y/aria-role': ['warn', {ignoreNonDOM: true}],
285
- 'jsx-a11y/aria-unsupported-elements': 'warn',
286
- 'jsx-a11y/heading-has-content': 'warn',
287
- 'jsx-a11y/iframe-has-title': 'warn',
288
- 'jsx-a11y/img-redundant-alt': 'warn',
289
- 'jsx-a11y/no-access-key': 'warn',
290
- 'jsx-a11y/no-distracting-elements': 'warn',
291
- 'jsx-a11y/no-redundant-roles': 'warn',
292
- 'jsx-a11y/role-has-required-aria-props': 'warn',
293
- 'jsx-a11y/role-supports-aria-props': 'warn',
294
- 'jsx-a11y/scope': 'warn',
295
-
296
- // https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
297
- 'react-hooks/rules-of-hooks': 'error',
298
- },
299
- };
37
+ },
38
+ {
39
+ files: ['*.js', '*.jsx'],
40
+ rules: {},
41
+ },
42
+ ],
43
+ };
package/package.json CHANGED
@@ -1,26 +1,27 @@
1
1
  {
2
2
  "name": "@lunit/eslint-config",
3
- "version": "0.4.0",
4
- "description": "Lunit eslint config",
3
+ "version": "1.0.0",
4
+ "description": "Lunit ESLnt Config",
5
5
  "main": "index.js",
6
- "repository": "lunit-io/eslint-config",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/lunit-io/eslint-config.git"
9
+ },
7
10
  "author": {
8
- "name": "Seoyeon Lee",
9
- "email": "i@ssen.name"
11
+ "name": "Larry Kim",
12
+ "email": "larry@lunit.io"
10
13
  },
11
14
  "publishConfig": {
12
15
  "access": "public"
13
16
  },
14
17
  "license": "MIT",
18
+ "peerDependencies": {
19
+ "eslint": ">= 8",
20
+ "prettier": ">= 3",
21
+ "typescript": ">= 5"
22
+ },
15
23
  "dependencies": {
16
- "@typescript-eslint/eslint-plugin": "2.x",
17
- "@typescript-eslint/parser": "2.x",
18
- "babel-eslint": "10.x",
19
- "confusing-browser-globals": "^1.0.9",
20
- "eslint": "6.x",
21
- "eslint-plugin-import": "2.x",
22
- "eslint-plugin-jsx-a11y": "6.x",
23
- "eslint-plugin-react": "7.x",
24
- "eslint-plugin-react-hooks": "2.x"
24
+ "@rushstack/eslint-config": "^4.0.2",
25
+ "@rushstack/eslint-patch": "^1.10.4"
25
26
  }
26
27
  }
@@ -0,0 +1 @@
1
+ node_modules
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: { browser: true, es2020: true },
4
+ ignorePatterns: ['**/*'],
5
+ extends: [
6
+ './eslint-config', // Extend common ESLint config
7
+ ],
8
+ settings: {
9
+ react: {
10
+ // Specifies the current React version (e.g. version: '18.2')
11
+ // If not specified (default 'detect'), the entire React library will be loaded,
12
+ // which may slow down the linting process.
13
+ version: '18.2',
14
+ },
15
+ },
16
+ };
@@ -0,0 +1,4 @@
1
+ # Add files here to ignore them from prettier formatting
2
+
3
+ /dist
4
+ /coverage
@@ -0,0 +1,12 @@
1
+ const config = {
2
+ printWidth: 100,
3
+ trailingComma: 'all', // Default
4
+ tabWidth: 2, // Default
5
+ semi: true, // Adding a semicolon to the beginning of a line in some code
6
+ singleQuote: true,
7
+ bracketSpacing: true, // Default. If true, {foo:bar} is converted to { foo: bar }
8
+ arrowParens: 'always', // Default
9
+ useTabs: false, // Default
10
+ };
11
+
12
+ export default config;
@@ -0,0 +1,34 @@
1
+ module.exports = {
2
+ // Define the required plugins here.
3
+ plugins: ['prettier'],
4
+ extends: [
5
+ // (required) Extend the @lunit/eslint-config.
6
+ // (@rushstack/eslint-config/profile/web-app is included by default.)
7
+ '@lunit/eslint-config',
8
+ // React mixin provided by rushstack (requires installation of @rushstack/eslint-config package)
9
+ '@rushstack/eslint-config/mixins/react',
10
+ // You can create and use your own mixin as follows.
11
+ // './mixins/react',
12
+ ],
13
+ rules: {},
14
+ settings: {
15
+ // If there are any common settings you would like to add, please add them.
16
+ },
17
+ overrides: [
18
+ {
19
+ files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
20
+ rules: {
21
+ // RATIONALE : Maintain code consistency using prettier settings
22
+ 'prettier/prettier': ['error', {}, { usePrettierrc: true }],
23
+ },
24
+ },
25
+ {
26
+ files: ['*.ts', '*.tsx'],
27
+ rules: {},
28
+ },
29
+ {
30
+ files: ['*.js', '*.jsx'],
31
+ rules: {},
32
+ },
33
+ ],
34
+ };
@@ -0,0 +1,30 @@
1
+ module.exports = {
2
+ // https://www.npmjs.com/package/eslint-plugin-react
3
+ // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
4
+ // https://www.npmjs.com/package/eslint-plugin-jsx-a11y
5
+ plugins: ['react', 'react-refresh', 'jsx-a11y'],
6
+ extends: [
7
+ 'plugin:react/recommended',
8
+ 'plugin:react-hooks/recommended',
9
+ 'plugin:react/jsx-runtime',
10
+ ],
11
+ settings: {
12
+ react: {
13
+ // Specifies the current React version (e.g. version: '18.2')
14
+ // If not specified (default 'detect'), the entire React library will be loaded,
15
+ // which may slow down the linting process.
16
+ version: 'detect',
17
+ },
18
+ },
19
+ overrides: [],
20
+ rules: {
21
+ // RATIONALE : Recommend exporting only React components to use the stable Fast Refresh
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ {
25
+ allowConstantExport: true,
26
+ allowExportNames: ['getServerSideProps'],
27
+ },
28
+ ],
29
+ },
30
+ };
package/rules.js DELETED
@@ -1,15 +0,0 @@
1
- exports.typescript = {
2
- '@typescript-eslint/no-explicit-any': 'error',
3
- '@typescript-eslint/typedef': [
4
- 'error',
5
- {
6
- 'arrayDestructuring': false,
7
- 'arrowParameter': false,
8
- 'objectDestructuring': false,
9
- 'parameter': true,
10
- 'propertyDeclaration': true,
11
- 'memberVariableDeclaration': false,
12
- 'variableDeclaration': false,
13
- },
14
- ],
15
- };
package/without-react.js DELETED
@@ -1,231 +0,0 @@
1
- const restrictedGlobals = require('confusing-browser-globals');
2
- const {typescript} = require('./rules');
3
-
4
- module.exports = {
5
- root: true,
6
-
7
- parser: 'babel-eslint',
8
-
9
- plugins: ['import'],
10
-
11
- env: {
12
- browser: true,
13
- commonjs: true,
14
- es6: true,
15
- jest: true,
16
- node: true,
17
- },
18
-
19
- parserOptions: {
20
- ecmaVersion: 2018,
21
- sourceType: 'module',
22
- ecmaFeatures: {
23
- jsx: false,
24
- },
25
- },
26
-
27
- overrides: [
28
- {
29
- files: ['**/*.ts?(x)'],
30
- parser: '@typescript-eslint/parser',
31
- parserOptions: {
32
- ecmaVersion: 2018,
33
- sourceType: 'module',
34
- ecmaFeatures: {
35
- jsx: false,
36
- },
37
-
38
- // typescript-eslint specific options
39
- warnOnUnsupportedTypeScriptVersion: true,
40
- },
41
- plugins: ['@typescript-eslint'],
42
- // If adding a typescript-eslint version of an existing ESLint rule,
43
- // make sure to disable the ESLint rule here.
44
- rules: {
45
- // TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
46
- 'default-case': 'off',
47
- // 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
48
- 'no-dupe-class-members': 'off',
49
- // 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
50
- 'no-undef': 'off',
51
-
52
- // Add TypeScript specific rules (and turn off ESLint equivalents)
53
- '@typescript-eslint/consistent-type-assertions': 'warn',
54
- 'no-array-constructor': 'off',
55
- '@typescript-eslint/no-array-constructor': 'warn',
56
- 'no-use-before-define': 'off',
57
- '@typescript-eslint/no-use-before-define': [
58
- 'warn',
59
- {
60
- functions: false,
61
- classes: false,
62
- variables: false,
63
- typedefs: false,
64
- },
65
- ],
66
- 'no-unused-expressions': 'off',
67
- '@typescript-eslint/no-unused-expressions': [
68
- 'error',
69
- {
70
- allowShortCircuit: true,
71
- allowTernary: true,
72
- allowTaggedTemplates: true,
73
- },
74
- ],
75
- 'no-unused-vars': 'off',
76
- '@typescript-eslint/no-unused-vars': [
77
- 'warn',
78
- {
79
- args: 'none',
80
- ignoreRestSiblings: true,
81
- },
82
- ],
83
- 'no-useless-constructor': 'off',
84
- '@typescript-eslint/no-useless-constructor': 'warn',
85
-
86
- ...typescript,
87
- },
88
- },
89
- ],
90
-
91
- // NOTE: When adding rules here, you need to make sure they are compatible with
92
- // `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.
93
- rules: {
94
- // http://eslint.org/docs/rules/
95
- 'array-callback-return': 'warn',
96
- 'default-case': ['warn', {commentPattern: '^no default$'}],
97
- 'dot-location': ['warn', 'property'],
98
- eqeqeq: ['warn', 'smart'],
99
- 'new-parens': 'warn',
100
- 'no-array-constructor': 'warn',
101
- 'no-caller': 'warn',
102
- 'no-cond-assign': ['warn', 'except-parens'],
103
- 'no-const-assign': 'warn',
104
- 'no-control-regex': 'warn',
105
- 'no-delete-var': 'warn',
106
- 'no-dupe-args': 'warn',
107
- 'no-dupe-class-members': 'warn',
108
- 'no-dupe-keys': 'warn',
109
- 'no-duplicate-case': 'warn',
110
- 'no-empty-character-class': 'warn',
111
- 'no-empty-pattern': 'warn',
112
- 'no-eval': 'warn',
113
- 'no-ex-assign': 'warn',
114
- 'no-extend-native': 'warn',
115
- 'no-extra-bind': 'warn',
116
- 'no-extra-label': 'warn',
117
- 'no-fallthrough': 'warn',
118
- 'no-func-assign': 'warn',
119
- 'no-implied-eval': 'warn',
120
- 'no-invalid-regexp': 'warn',
121
- 'no-iterator': 'warn',
122
- 'no-label-var': 'warn',
123
- 'no-labels': ['warn', {allowLoop: true, allowSwitch: false}],
124
- 'no-lone-blocks': 'warn',
125
- 'no-loop-func': 'warn',
126
- 'no-mixed-operators': [
127
- 'warn',
128
- {
129
- groups: [
130
- ['&', '|', '^', '~', '<<', '>>', '>>>'],
131
- ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
132
- ['&&', '||'],
133
- ['in', 'instanceof'],
134
- ],
135
- allowSamePrecedence: false,
136
- },
137
- ],
138
- 'no-multi-str': 'warn',
139
- 'no-native-reassign': 'warn',
140
- 'no-negated-in-lhs': 'warn',
141
- 'no-new-func': 'warn',
142
- 'no-new-object': 'warn',
143
- 'no-new-symbol': 'warn',
144
- 'no-new-wrappers': 'warn',
145
- 'no-obj-calls': 'warn',
146
- 'no-octal': 'warn',
147
- 'no-octal-escape': 'warn',
148
- // TODO: Remove this option in the next major release of CRA.
149
- // https://eslint.org/docs/user-guide/migrating-to-6.0.0#-the-no-redeclare-rule-is-now-more-strict-by-default
150
- 'no-redeclare': ['warn', {builtinGlobals: false}],
151
- 'no-regex-spaces': 'warn',
152
- 'no-restricted-syntax': ['warn', 'WithStatement'],
153
- 'no-script-url': 'warn',
154
- 'no-self-assign': 'warn',
155
- 'no-self-compare': 'warn',
156
- 'no-sequences': 'warn',
157
- 'no-shadow-restricted-names': 'warn',
158
- 'no-sparse-arrays': 'warn',
159
- 'no-template-curly-in-string': 'warn',
160
- 'no-this-before-super': 'warn',
161
- 'no-throw-literal': 'warn',
162
- 'no-undef': 'error',
163
- 'no-restricted-globals': ['error'].concat(restrictedGlobals),
164
- 'no-unreachable': 'warn',
165
- 'no-unused-expressions': [
166
- 'error',
167
- {
168
- allowShortCircuit: true,
169
- allowTernary: true,
170
- allowTaggedTemplates: true,
171
- },
172
- ],
173
- 'no-unused-labels': 'warn',
174
- 'no-unused-vars': [
175
- 'warn',
176
- {
177
- args: 'none',
178
- ignoreRestSiblings: true,
179
- },
180
- ],
181
- 'no-use-before-define': [
182
- 'warn',
183
- {
184
- functions: false,
185
- classes: false,
186
- variables: false,
187
- },
188
- ],
189
- 'no-useless-computed-key': 'warn',
190
- 'no-useless-concat': 'warn',
191
- 'no-useless-constructor': 'warn',
192
- 'no-useless-escape': 'warn',
193
- 'no-useless-rename': [
194
- 'warn',
195
- {
196
- ignoreDestructuring: false,
197
- ignoreImport: false,
198
- ignoreExport: false,
199
- },
200
- ],
201
- 'no-with': 'warn',
202
- 'no-whitespace-before-property': 'warn',
203
- 'require-yield': 'warn',
204
- 'rest-spread-spacing': ['warn', 'never'],
205
- strict: ['warn', 'never'],
206
- 'unicode-bom': ['warn', 'never'],
207
- 'use-isnan': 'warn',
208
- 'valid-typeof': 'warn',
209
- 'no-restricted-properties': [
210
- 'error',
211
- {
212
- object: 'require',
213
- property: 'ensure',
214
- message:
215
- 'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
216
- },
217
- {
218
- object: 'System',
219
- property: 'import',
220
- message:
221
- 'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
222
- },
223
- ],
224
- 'getter-return': 'warn',
225
-
226
- // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
227
- 'import/first': 'error',
228
- 'import/no-amd': 'error',
229
- 'import/no-webpack-loader-syntax': 'error',
230
- },
231
- };