@lunit/eslint-config 0.5.0 → 1.1.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,257 @@
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
+ This ESLint configuration is only available for TypeScript projects.
6
6
 
7
- ```sh
8
- npm install eslint @lunit/eslint-config eslint-config-prettier --save-dev
7
+ ## Installation
8
+
9
+ ```shell
10
+ npm install --save-dev @lunit/eslint-config
9
11
  ```
10
12
 
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
- ]
13
+ ## Usage
14
+
15
+ ### Getting Started
16
+
17
+ `@lunit/eslint-config v2.x` is configured using the ESLint Flat Config approach.
18
+
19
+ For information regarding ESLint Flat Config, please refer to the relevant ESLint Blog post.
20
+ - https://eslint.org/blog/2022/08/new-config-system-part-2/
21
+
22
+
23
+ To use it, add @lunit/eslint-config to your eslint.config.js file as follows.
24
+ If you are using TypeScript ESLint rules, please remove them.
25
+ This is already being used in Rushstack ESLint, causing conflict issues.
26
+
27
+
28
+ #### ESM
29
+
30
+ ```javascript
31
+ // eslint.config.js
32
+ import js from "@eslint/js";
33
+ import globals from "globals";
34
+ import reactHooks from "eslint-plugin-react-hooks";
35
+ import reactRefresh from "eslint-plugin-react-refresh";
36
+ import { defineConfig, globalIgnores } from "eslint/config";
37
+ import eslintConfig from '@lunit/eslint-config';
38
+
39
+ export default defineConfig([
40
+ globalIgnores(["dist"]),
41
+ {
42
+ files: ["**/*.{ts,tsx}"],
43
+ extends: [
44
+ js.configs.recommended,
45
+ reactHooks.configs.flat["recommended-latest"],
46
+ reactRefresh.configs.vite,
47
+ ],
48
+ languageOptions: {
49
+ ecmaVersion: 2020,
50
+ globals: globals.browser,
51
+ },
52
+ },
53
+ lunitEslintConfig,
54
+ ]);
55
+ ```
56
+
57
+ #### CommonJS
58
+
59
+ ```javascript
60
+ // eslint.config.cjs
61
+ const js = require("@eslint/js");
62
+ const globals = require("globals");
63
+ const reactHooks = require("eslint-plugin-react-hooks");
64
+ const reactRefresh = require("eslint-plugin-react-refresh");
65
+ const { defineConfig, globalIgnores } = require("eslint/config");
66
+ const lunitEslintConfig = require('@lunit/eslint-config');
67
+
68
+ module.exports = defineConfig([
69
+ globalIgnores(["dist"]),
70
+ {
71
+ files: ["**/*.{ts,tsx}"],
72
+ extends: [
73
+ js.configs.recommended,
74
+ reactHooks.configs.flat["recommended-latest"],
75
+ reactRefresh.configs.vite,
76
+ ],
77
+ languageOptions: {
78
+ ecmaVersion: 2020,
79
+ globals: globals.browser,
80
+ },
81
+ },
82
+ // You can add the ESLint Config rules as follows.
83
+ lunitEslintConfig,
84
+ ]);
85
+ ```
86
+
87
+ > If you created the app using vite,
88
+ > please refer to the information below.
89
+
90
+ If the tsconfig.json file is separate and the actual rules are applied in `tsconfig.app.json`,
91
+ please configure it as follows.
92
+
93
+ rushstack eslint config internally follows the rules set in tsconfig,
94
+ so you must link the corresponding JSON file.
95
+
96
+ #### ESM
97
+ ```js
98
+ // eslint.config.js
99
+ import js from "@eslint/js";
100
+ import globals from "globals";
101
+ import reactHooks from "eslint-plugin-react-hooks";
102
+ import reactRefresh from "eslint-plugin-react-refresh";
103
+ import { defineConfig, globalIgnores } from "eslint/config";
104
+ import eslintConfig from '@lunit/eslint-config';
105
+
106
+ export default defineConfig([
107
+ globalIgnores(["dist"]),
108
+ {
109
+ files: ["**/*.{ts,tsx}"],
110
+ extends: [
111
+ js.configs.recommended,
112
+ reactHooks.configs.flat["recommended-latest"],
113
+ reactRefresh.configs.vite,
114
+ ],
115
+ languageOptions: {
116
+ ecmaVersion: 2020,
117
+ globals: globals.browser,
118
+ },
119
+ },
120
+ {
121
+ ...eslintConfig,
122
+ // You must integrate the tsconfig.app.json file applied to the actual ts and tsx files as shown below.
123
+ languageOptions: {
124
+ parserOptions: {
125
+ project: ["./tsconfig.app.json"],
126
+ tsconfigRootDir: import.meta.dirname,
127
+ },
128
+ },
129
+ }
130
+ ]);
131
+ ```
132
+
133
+ #### CommonJS
134
+
135
+ ```js
136
+ // eslint.config.cjs
137
+ const js = require("@eslint/js");
138
+ const globals = require("globals");
139
+ const reactHooks = require("eslint-plugin-react-hooks");
140
+ const reactRefresh = require("eslint-plugin-react-refresh");
141
+ const { defineConfig, globalIgnores } = require("eslint/config");
142
+ const lunitEslintConfig = require('@lunit/eslint-config');
143
+
144
+ module.exports = defineConfig([
145
+ globalIgnores(["dist"]),
146
+ {
147
+ files: ["**/*.{ts,tsx}"],
148
+ extends: [
149
+ js.configs.recommended,
150
+ reactHooks.configs.flat["recommended-latest"],
151
+ reactRefresh.configs.vite,
152
+ ],
153
+ languageOptions: {
154
+ ecmaVersion: 2020,
155
+ globals: globals.browser,
156
+ },
157
+ },
158
+ {
159
+ ...lunitEslintConfig,
160
+ // You must integrate the tsconfig.app.json file applied to the actual ts and tsx files as shown below.
161
+ languageOptions: {
162
+ parserOptions: {
163
+ project: ["./tsconfig.app.json"],
164
+ tsconfigRootDir: __dirname,
165
+ },
166
+ },
167
+ }
168
+ ]);
169
+ ```
170
+
171
+ ### Advanced
172
+
173
+ #### Override rushstack eslint rule
174
+
175
+ If you wish to modify the Rushstack ESLint rule, please refer to the code below.
176
+
177
+ #### ESM
178
+ ```js
179
+ // eslint.config.js
180
+ import js from "@eslint/js";
181
+ import globals from "globals";
182
+ import reactHooks from "eslint-plugin-react-hooks";
183
+ import reactRefresh from "eslint-plugin-react-refresh";
184
+ import { defineConfig, globalIgnores } from "eslint/config";
185
+ import eslintConfig from '@lunit/eslint-config';
186
+
187
+ export default defineConfig([
188
+ globalIgnores(["dist"]),
189
+ {
190
+ files: ["**/*.{ts,tsx}"],
191
+ extends: [
192
+ js.configs.recommended,
193
+ reactHooks.configs.flat["recommended-latest"],
194
+ reactRefresh.configs.vite,
195
+ ],
196
+ languageOptions: {
197
+ ecmaVersion: 2020,
198
+ globals: globals.browser,
199
+ },
200
+ },
201
+ {
202
+ // Using Spread Operator lunit Eslint Config
203
+ ...lunitEslintConfig,
204
+ rules: {
205
+ // Using Spread Operator lunit Eslint Config Rules
206
+ ...lunitEslintConfig.rules,
207
+ // And apply the target rule
208
+ '@rushstack/no-new-null': 'error',
209
+ },
22
210
  }
23
- }
211
+ ]);
24
212
  ```
25
213
 
26
- Or add this config into package.json if the project is not a React application. (like a Node.js application)
214
+ #### CommonJS
215
+
216
+ ```js
217
+ // eslint.config.cjs
218
+ const js = require("@eslint/js");
219
+ const globals = require("globals");
220
+ const reactHooks = require("eslint-plugin-react-hooks");
221
+ const reactRefresh = require("eslint-plugin-react-refresh");
222
+ const { defineConfig, globalIgnores } = require("eslint/config");
223
+ const lunitEslintConfig = require('@lunit/eslint-config');
27
224
 
28
- ```json
29
- {
30
- "eslintConfig": {
31
- "extends": [
32
- "@lunit/eslint-config/without-react",
33
- "prettier",
34
- "prettier/@typescript-eslint"
35
- ]
225
+ module.exports = defineConfig([
226
+ globalIgnores(["dist"]),
227
+ {
228
+ files: ["**/*.{ts,tsx}"],
229
+ extends: [
230
+ js.configs.recommended,
231
+ reactHooks.configs.flat["recommended-latest"],
232
+ reactRefresh.configs.vite,
233
+ ],
234
+ languageOptions: {
235
+ ecmaVersion: 2020,
236
+ globals: globals.browser,
237
+ },
238
+ },
239
+ {
240
+ // Using Spread Operator lunit Eslint Config
241
+ ...lunitEslintConfig,
242
+ rules: {
243
+ // Using Spread Operator lunit Eslint Config Rules
244
+ ...lunitEslintConfig.rules,
245
+ // And apply the target rule
246
+ '@rushstack/no-new-null': 'error',
247
+ },
36
248
  }
37
- }
38
- ```
249
+ ]);
250
+ ```
251
+
252
+ #### Migrate 1.x to 2.x
253
+
254
+ Since migration to the ESLint flat config is required,
255
+ please refer to the official ESLint documentation guide below.
256
+
257
+ - https://eslint.org/docs/latest/use/configure/migration-guide
package/dist/index.js ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ const react = require("@rushstack/eslint-config/flat/mixins/react.js");
3
+ const webApp = require("@rushstack/eslint-config/flat/profile/web-app.js");
4
+ function _interopNamespaceDefault(e) {
5
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
+ if (e) {
7
+ for (const k in e) {
8
+ if (k !== "default") {
9
+ const d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ n.default = e;
18
+ return Object.freeze(n);
19
+ }
20
+ const react__namespace = /* @__PURE__ */ _interopNamespaceDefault(react);
21
+ const webApp__namespace = /* @__PURE__ */ _interopNamespaceDefault(webApp);
22
+ function getDefaultExportFromCjs(x) {
23
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
24
+ }
25
+ function getAugmentedNamespace(n) {
26
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
27
+ var f = n.default;
28
+ if (typeof f == "function") {
29
+ var a = function a2() {
30
+ var isInstance = false;
31
+ try {
32
+ isInstance = this instanceof a2;
33
+ } catch {
34
+ }
35
+ if (isInstance) {
36
+ return Reflect.construct(f, arguments, this.constructor);
37
+ }
38
+ return f.apply(this, arguments);
39
+ };
40
+ a.prototype = f.prototype;
41
+ } else a = {};
42
+ Object.defineProperty(a, "__esModule", { value: true });
43
+ Object.keys(n).forEach(function(k) {
44
+ var d = Object.getOwnPropertyDescriptor(n, k);
45
+ Object.defineProperty(a, k, d.get ? d : {
46
+ enumerable: true,
47
+ get: function() {
48
+ return n[k];
49
+ }
50
+ });
51
+ });
52
+ return a;
53
+ }
54
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(react__namespace);
55
+ const require$$1 = /* @__PURE__ */ getAugmentedNamespace(webApp__namespace);
56
+ var eslintConfig;
57
+ var hasRequiredEslintConfig;
58
+ function requireEslintConfig() {
59
+ if (hasRequiredEslintConfig) return eslintConfig;
60
+ hasRequiredEslintConfig = 1;
61
+ const rushStackReactConfig = require$$0;
62
+ const rushStackWebAppConfig = require$$1;
63
+ function cleanConfig(config) {
64
+ if (Array.isArray(config)) {
65
+ return config.map(cleanConfig);
66
+ }
67
+ if (config && typeof config === "object" && config.default) {
68
+ return cleanConfig(config.default);
69
+ }
70
+ return config;
71
+ }
72
+ const cleanedExtends = [rushStackWebAppConfig, rushStackReactConfig].map(cleanConfig);
73
+ eslintConfig = {
74
+ files: ["**/*.ts", "**/*.tsx"],
75
+ extends: cleanedExtends,
76
+ rules: {
77
+ /**
78
+ * RATIONALE : The null type is universally used, so it is excluded.
79
+ * docs: https://www.npmjs.com/package/@rushstack/eslint-plugin
80
+ */
81
+ "@rushstack/no-new-null": "off",
82
+ /**
83
+ * RATIONALE : Rushstack's policy enforces explicit types for top-level variables for readability,
84
+ * but our project prefers to leverage TypeScript's type inference.
85
+ * docs: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-plugin#rushstacktypedef-var
86
+ */
87
+ "@rushstack/typedef-var": "off",
88
+ /**
89
+ * RATIONALE : According to the documentation, it can be used in projects that use many classes,
90
+ * but it is unnecessary because the development pattern is functional.
91
+ * docs: https://typescript-eslint.io/rules/explicit-member-accessibility/
92
+ */
93
+ "@typescript-eslint/explicit-member-accessibility": "off",
94
+ /**
95
+ * RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
96
+ * docs: https://typescript-eslint.io/rules/explicit-function-return-type/
97
+ */
98
+ "@typescript-eslint/explicit-function-return-type": "off"
99
+ },
100
+ settings: {
101
+ react: {
102
+ version: "detect"
103
+ }
104
+ }
105
+ };
106
+ return eslintConfig;
107
+ }
108
+ var eslintConfigExports = requireEslintConfig();
109
+ const index = /* @__PURE__ */ getDefaultExportFromCjs(eslintConfigExports);
110
+ module.exports = index;
package/dist/index.mjs ADDED
@@ -0,0 +1,91 @@
1
+ import * as react from "@rushstack/eslint-config/flat/mixins/react.js";
2
+ import * as webApp from "@rushstack/eslint-config/flat/profile/web-app.js";
3
+ function getDefaultExportFromCjs(x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
5
+ }
6
+ function getAugmentedNamespace(n) {
7
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
8
+ var f = n.default;
9
+ if (typeof f == "function") {
10
+ var a = function a2() {
11
+ var isInstance = false;
12
+ try {
13
+ isInstance = this instanceof a2;
14
+ } catch {
15
+ }
16
+ if (isInstance) {
17
+ return Reflect.construct(f, arguments, this.constructor);
18
+ }
19
+ return f.apply(this, arguments);
20
+ };
21
+ a.prototype = f.prototype;
22
+ } else a = {};
23
+ Object.defineProperty(a, "__esModule", { value: true });
24
+ Object.keys(n).forEach(function(k) {
25
+ var d = Object.getOwnPropertyDescriptor(n, k);
26
+ Object.defineProperty(a, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function() {
29
+ return n[k];
30
+ }
31
+ });
32
+ });
33
+ return a;
34
+ }
35
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(react);
36
+ const require$$1 = /* @__PURE__ */ getAugmentedNamespace(webApp);
37
+ var eslintConfig;
38
+ var hasRequiredEslintConfig;
39
+ function requireEslintConfig() {
40
+ if (hasRequiredEslintConfig) return eslintConfig;
41
+ hasRequiredEslintConfig = 1;
42
+ const rushStackReactConfig = require$$0;
43
+ const rushStackWebAppConfig = require$$1;
44
+ function cleanConfig(config) {
45
+ if (Array.isArray(config)) {
46
+ return config.map(cleanConfig);
47
+ }
48
+ if (config && typeof config === "object" && config.default) {
49
+ return cleanConfig(config.default);
50
+ }
51
+ return config;
52
+ }
53
+ const cleanedExtends = [rushStackWebAppConfig, rushStackReactConfig].map(cleanConfig);
54
+ eslintConfig = {
55
+ files: ["**/*.ts", "**/*.tsx"],
56
+ extends: cleanedExtends,
57
+ rules: {
58
+ /**
59
+ * RATIONALE : The null type is universally used, so it is excluded.
60
+ * docs: https://www.npmjs.com/package/@rushstack/eslint-plugin
61
+ */
62
+ "@rushstack/no-new-null": "off",
63
+ /**
64
+ * RATIONALE : Rushstack's policy enforces explicit types for top-level variables for readability,
65
+ * but our project prefers to leverage TypeScript's type inference.
66
+ * docs: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-plugin#rushstacktypedef-var
67
+ */
68
+ "@rushstack/typedef-var": "off",
69
+ /**
70
+ * RATIONALE : According to the documentation, it can be used in projects that use many classes,
71
+ * but it is unnecessary because the development pattern is functional.
72
+ * docs: https://typescript-eslint.io/rules/explicit-member-accessibility/
73
+ */
74
+ "@typescript-eslint/explicit-member-accessibility": "off",
75
+ /**
76
+ * RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
77
+ * docs: https://typescript-eslint.io/rules/explicit-function-return-type/
78
+ */
79
+ "@typescript-eslint/explicit-function-return-type": "off"
80
+ },
81
+ settings: {
82
+ react: {
83
+ version: "detect"
84
+ }
85
+ }
86
+ };
87
+ return eslintConfig;
88
+ }
89
+ var eslintConfigExports = requireEslintConfig();
90
+ const index = /* @__PURE__ */ getDefaultExportFromCjs(eslintConfigExports);
91
+ export default index;
package/package.json CHANGED
@@ -1,26 +1,40 @@
1
1
  {
2
2
  "name": "@lunit/eslint-config",
3
- "version": "0.5.0",
4
- "description": "Lunit eslint config",
5
- "main": "index.js",
3
+ "version": "1.1.0",
4
+ "description": "Lunit ESLint Config",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "files": ["dist"],
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ }
13
+ },
6
14
  "repository": "lunit-io/eslint-config",
7
15
  "author": {
8
- "name": "Seoyeon Lee",
9
- "email": "i@ssen.name"
16
+ "name": "Larry Kim",
17
+ "email": "larry@lunit.io"
10
18
  },
11
19
  "publishConfig": {
12
20
  "access": "public"
13
21
  },
22
+ "scripts": {
23
+ "build": "vite build"
24
+ },
14
25
  "license": "MIT",
26
+ "peerDependencies": {
27
+ "eslint": ">= 8",
28
+ "prettier": ">= 3",
29
+ "typescript": ">= 5"
30
+ },
15
31
  "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.3.0"
32
+ "@rushstack/eslint-config": "^4.4.0"
33
+ },
34
+ "devDependencies": {
35
+ "@rollup/plugin-commonjs": "^28.0.6",
36
+ "eslint": "^9.36.0",
37
+ "typescript": "^5.8.3",
38
+ "vite": "^7.1.7"
25
39
  }
26
40
  }
package/index.js DELETED
@@ -1,299 +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', '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
-
27
- settings: {
28
- react: {
29
- version: 'detect',
30
- },
31
- },
32
-
33
- overrides: [
34
- {
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.
50
- 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,
93
- },
94
- },
95
- {
96
- files: ['**/*.stories.{js,jsx,ts,tsx}'],
97
- 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,
211
- },
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
- };
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
- };