@open-turo/eslint-config-typescript 16.0.0-pr-373.7.1.1 → 16.0.0-pr-373.9.1.1
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/README.md +1 -1
- package/eslint.config.mjs +2 -1
- package/index.cjs +125 -54
- package/index.mjs +2 -136
- package/pack/open-turo-eslint-config-typescript-16.0.0-pr-373.9.1.1.tgz +0 -0
- package/package.json +1 -1
- package/recommended.cjs +56 -56
- package/test/test.spec.js +2 -4
- package/pack/open-turo-eslint-config-typescript-16.0.0-pr-373.7.1.1.tgz +0 -0
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ npx install-peerdeps --dev @open-turo/eslint-config-typescript
|
|
|
24
24
|
```js
|
|
25
25
|
const turoConfig = require("@open-turo/eslint-config-typescript");
|
|
26
26
|
|
|
27
|
-
module.exports = turoConfig;
|
|
27
|
+
module.exports = turoConfig();
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### **[.eslintrc](https://eslint.org/docs/latest/use/configure/configuration-files)** (legacy example)
|
package/eslint.config.mjs
CHANGED
package/index.cjs
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const eslint = require("@eslint/js");
|
|
2
|
+
const tsParser = require("@typescript-eslint/parser");
|
|
3
3
|
const importPlugin = require("eslint-plugin-import");
|
|
4
|
+
const jestPlugin = require("eslint-plugin-jest");
|
|
4
5
|
const jsonPlugin = require("eslint-plugin-json");
|
|
5
|
-
const
|
|
6
|
+
const nPlugin = require("eslint-plugin-n");
|
|
6
7
|
const perfectionistPlugin = require("eslint-plugin-perfectionist");
|
|
7
8
|
const prettierPluginRecommended = require("eslint-plugin-prettier/recommended");
|
|
8
|
-
const tseslint = require("typescript-eslint");
|
|
9
9
|
const sonarjsPlugin = require("eslint-plugin-sonarjs");
|
|
10
10
|
const unicornPlugin = require("eslint-plugin-unicorn");
|
|
11
|
-
const
|
|
11
|
+
const tseslint = require("typescript-eslint");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
const FILES_SRC_EXTENSION = "?([cm])[jt]s?(x)";
|
|
14
|
+
const FILES_TS = "**/*.?([cm])ts";
|
|
15
|
+
const FILES_TSX = "**/*.?([cm])tsx";
|
|
16
|
+
const FILES_TEST = [
|
|
17
|
+
`**/__tests__/**/*.${FILES_SRC_EXTENSION}`,
|
|
18
|
+
`**/*.spec.${FILES_SRC_EXTENSION}`,
|
|
19
|
+
`**/*.test.${FILES_SRC_EXTENSION}`,
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const typescriptLanguageOptions = () => ({
|
|
23
|
+
parser: tsParser,
|
|
24
|
+
parserOptions: {
|
|
25
|
+
projectService: true,
|
|
26
|
+
tsconfigRootDir: process.cwd(),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const importConfig = () =>
|
|
31
|
+
tseslint.config({
|
|
32
|
+
extends: [importPlugin.flatConfigs.recommended],
|
|
32
33
|
rules: {
|
|
33
34
|
"import/default": "off",
|
|
34
35
|
"import/named": "off",
|
|
@@ -36,17 +37,41 @@ module.exports = tseslint.config(
|
|
|
36
37
|
"import/no-default-export": "error",
|
|
37
38
|
"import/no-extraneous-dependencies": [
|
|
38
39
|
"error",
|
|
39
|
-
{ devDependencies: [
|
|
40
|
+
{ devDependencies: [`eslint.config.${FILES_SRC_EXTENSION}`] },
|
|
40
41
|
],
|
|
41
42
|
"import/prefer-default-export": "off",
|
|
43
|
+
},
|
|
44
|
+
settings: {
|
|
45
|
+
"import/resolver": {
|
|
46
|
+
typescript: {
|
|
47
|
+
alwaysTryTypes: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const nPluginConfig = (allowModules = ["@jest/globals", "nock"]) =>
|
|
54
|
+
tseslint.config({
|
|
55
|
+
extends: [
|
|
56
|
+
nPlugin.configs["flat/recommended"],
|
|
57
|
+
nPlugin.configs["flat/mixed-esm-and-cjs"],
|
|
58
|
+
],
|
|
59
|
+
rules: {
|
|
60
|
+
"n/no-missing-import": "off",
|
|
42
61
|
"n/no-unpublished-import": [
|
|
43
62
|
"error",
|
|
44
63
|
{
|
|
45
|
-
allowModules
|
|
64
|
+
allowModules,
|
|
46
65
|
},
|
|
47
66
|
],
|
|
48
67
|
"n/no-unsupported-features/es-syntax": "off",
|
|
49
|
-
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const sonarJsConfig = () =>
|
|
72
|
+
tseslint.config({
|
|
73
|
+
extends: [sonarjsPlugin.configs.recommended],
|
|
74
|
+
rules: {
|
|
50
75
|
// Noisy rule - we may have helpers/methods that we mark as @deprecated but aren't planning to remove in the near future. This rule also significantly adds to eslint running time, which slows down both local development and CI.
|
|
51
76
|
"sonarjs/deprecation": "off",
|
|
52
77
|
// This rule is not helpful in TypeScript files, and in JavaScript we often return different types from functions, so this is not a strictness level we want to enforce.
|
|
@@ -55,10 +80,10 @@ module.exports = tseslint.config(
|
|
|
55
80
|
"sonarjs/no-ignored-exceptions": "off",
|
|
56
81
|
"sonarjs/no-nested-functions": ["warn", { threshold: 5 }],
|
|
57
82
|
"sonarjs/no-small-switch": "off",
|
|
58
|
-
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
59
|
-
"sonarjs/prefer-nullish-coalescing": "off",
|
|
60
83
|
// Overlaps with @typescript-eslint/no-unused-vars
|
|
61
84
|
"sonarjs/no-unused-vars": "off",
|
|
85
|
+
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
86
|
+
"sonarjs/prefer-nullish-coalescing": "off",
|
|
62
87
|
// Overlaps with @typescript-eslint/prefer-optional-chain
|
|
63
88
|
"sonarjs/prefer-optional-chain": "off",
|
|
64
89
|
// Useful for guarding against prop mutation in React, but too much of a lift as very rarely do we apply readonly/ReadonlyArray<T> to type definitions
|
|
@@ -67,6 +92,18 @@ module.exports = tseslint.config(
|
|
|
67
92
|
"sonarjs/todo-tag": "off",
|
|
68
93
|
// A useful rule to consider for libraries to better document (and export) type definitions, but noisy in app usages (especially around redux type definitions)
|
|
69
94
|
"sonarjs/use-type-alias": "off",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const typescriptConfig = () =>
|
|
99
|
+
tseslint.config({
|
|
100
|
+
extends: [
|
|
101
|
+
tseslint.configs.recommendedTypeChecked,
|
|
102
|
+
importPlugin.flatConfigs.typescript,
|
|
103
|
+
],
|
|
104
|
+
files: [FILES_TS, FILES_TSX],
|
|
105
|
+
languageOptions: typescriptLanguageOptions(),
|
|
106
|
+
rules: {
|
|
70
107
|
/**
|
|
71
108
|
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
|
|
72
109
|
*/
|
|
@@ -102,35 +139,69 @@ module.exports = tseslint.config(
|
|
|
102
139
|
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
103
140
|
"@typescript-eslint/unbound-method": "error",
|
|
104
141
|
},
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @param options Configuration options
|
|
147
|
+
* @param options.typescript Whether to include typescript rules
|
|
148
|
+
* @returns {ConfigArray}
|
|
149
|
+
*/
|
|
150
|
+
const testConfig = (options) => {
|
|
151
|
+
const typescriptRules = options.typescript
|
|
152
|
+
? {
|
|
153
|
+
// this turns the original rule off *only* for test files, for jestPlugin compatibility
|
|
154
|
+
"@typescript-eslint/unbound-method": "off",
|
|
155
|
+
"jest/unbound-method": "error",
|
|
156
|
+
}
|
|
157
|
+
: {};
|
|
158
|
+
return tseslint.config({
|
|
159
|
+
extends: [jestPlugin.configs["flat/recommended"]],
|
|
160
|
+
files: FILES_TEST,
|
|
111
161
|
languageOptions: {
|
|
112
162
|
globals: jestPlugin.environments.globals.globals,
|
|
113
|
-
|
|
114
|
-
parserOptions: {
|
|
115
|
-
projectService: true,
|
|
116
|
-
},
|
|
163
|
+
...(options.typescript ? typescriptLanguageOptions() : {}),
|
|
117
164
|
},
|
|
118
|
-
|
|
165
|
+
plugins: { jest: jestPlugin },
|
|
119
166
|
rules: {
|
|
120
167
|
...jestPlugin.configs["flat/recommended"].rules,
|
|
121
|
-
|
|
122
|
-
"
|
|
168
|
+
...typescriptRules,
|
|
169
|
+
"import/no-extraneous-dependencies": [
|
|
170
|
+
"error",
|
|
171
|
+
{ devDependencies: FILES_TEST },
|
|
172
|
+
],
|
|
123
173
|
"jest/no-jest-import": "off",
|
|
124
|
-
"jest/unbound-method": "error",
|
|
125
174
|
},
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const ignoresConfig = (ignores = []) =>
|
|
179
|
+
tseslint.config({
|
|
180
|
+
ignores: ["**/.yalc", "**/dist", ...ignores],
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Turo eslint configuration for typescript
|
|
185
|
+
* @param [options] - Eslint config options
|
|
186
|
+
* @param [options.allowModules] - List of modules to allow in the n/no-unpublished-import rule
|
|
187
|
+
* @param [options.ignores] - List of patterns to ignore
|
|
188
|
+
* @param [options.typescript] - Whether to include typescript rules
|
|
189
|
+
* @returns {ConfigArray}
|
|
190
|
+
*/
|
|
191
|
+
module.exports = function config(options = {}) {
|
|
192
|
+
const useTypescript =
|
|
193
|
+
options.typescript === undefined ? true : options.typescript;
|
|
194
|
+
return tseslint.config(
|
|
195
|
+
eslint.configs.recommended,
|
|
196
|
+
importConfig(),
|
|
197
|
+
nPluginConfig(options.allowModules),
|
|
198
|
+
perfectionistPlugin.configs["recommended-alphabetical"],
|
|
199
|
+
sonarJsConfig(),
|
|
200
|
+
unicornPlugin.configs["flat/recommended"],
|
|
201
|
+
prettierPluginRecommended,
|
|
202
|
+
jsonPlugin.configs["recommended"],
|
|
203
|
+
useTypescript ? typescriptConfig() : {},
|
|
204
|
+
testConfig({ typescript: useTypescript }),
|
|
205
|
+
ignoresConfig(options.ignores),
|
|
206
|
+
);
|
|
207
|
+
};
|
package/index.mjs
CHANGED
|
@@ -1,136 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import importPlugin from "eslint-plugin-import";
|
|
4
|
-
import jsonPlugin from "eslint-plugin-json";
|
|
5
|
-
import eslint from "@eslint/js";
|
|
6
|
-
import perfectionistPlugin from "eslint-plugin-perfectionist";
|
|
7
|
-
import prettierPluginRecommended from "eslint-plugin-prettier/recommended";
|
|
8
|
-
import tseslint from "typescript-eslint";
|
|
9
|
-
import sonarjsPlugin from "eslint-plugin-sonarjs";
|
|
10
|
-
import unicornPlugin from "eslint-plugin-unicorn";
|
|
11
|
-
import tsParser from "@typescript-eslint/parser";
|
|
12
|
-
|
|
13
|
-
export default tseslint.config(
|
|
14
|
-
{
|
|
15
|
-
files: ["**/*.ts", "**/*.tsx"],
|
|
16
|
-
extends: [
|
|
17
|
-
eslint.configs.recommended,
|
|
18
|
-
tseslint.configs.recommendedTypeChecked,
|
|
19
|
-
importPlugin.flatConfigs.recommended,
|
|
20
|
-
importPlugin.flatConfigs.typescript,
|
|
21
|
-
nPlugin.configs["flat/recommended-script"],
|
|
22
|
-
perfectionistPlugin.configs["recommended-alphabetical"],
|
|
23
|
-
sonarjsPlugin.configs.recommended,
|
|
24
|
-
unicornPlugin.configs["flat/recommended"],
|
|
25
|
-
],
|
|
26
|
-
languageOptions: {
|
|
27
|
-
parser: tsParser,
|
|
28
|
-
parserOptions: {
|
|
29
|
-
projectService: true,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
"import/default": "off",
|
|
34
|
-
"import/named": "off",
|
|
35
|
-
"import/namespace": "off",
|
|
36
|
-
"import/no-default-export": "error",
|
|
37
|
-
"import/no-extraneous-dependencies": [
|
|
38
|
-
"error",
|
|
39
|
-
{ devDependencies: ["test/**"] },
|
|
40
|
-
],
|
|
41
|
-
"import/prefer-default-export": "off",
|
|
42
|
-
"n/no-unpublished-import": [
|
|
43
|
-
"error",
|
|
44
|
-
{
|
|
45
|
-
allowModules: ["@jest/globals", "nock"],
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
"n/no-unsupported-features/es-syntax": "off",
|
|
49
|
-
"n/no-missing-import": "off",
|
|
50
|
-
// Noisy rule - we may have helpers/methods that we mark as @deprecated but aren't planning to remove in the near future. This rule also significantly adds to eslint running time, which slows down both local development and CI.
|
|
51
|
-
"sonarjs/deprecation": "off",
|
|
52
|
-
// This rule is not helpful in TypeScript files, and in JavaScript we often return different types from functions, so this is not a strictness level we want to enforce.
|
|
53
|
-
"sonarjs/function-return-type": "off",
|
|
54
|
-
// We may want to catch errors but not use the error object directly, just trigger error handling fallbacks within the catch block.
|
|
55
|
-
"sonarjs/no-ignored-exceptions": "off",
|
|
56
|
-
"sonarjs/no-nested-functions": ["warn", { threshold: 5 }],
|
|
57
|
-
"sonarjs/no-small-switch": "off",
|
|
58
|
-
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
59
|
-
"sonarjs/prefer-nullish-coalescing": "off",
|
|
60
|
-
// Overlaps with @typescript-eslint/no-unused-vars
|
|
61
|
-
"sonarjs/no-unused-vars": "off",
|
|
62
|
-
// Overlaps with @typescript-eslint/prefer-optional-chain
|
|
63
|
-
"sonarjs/prefer-optional-chain": "off",
|
|
64
|
-
// Useful for guarding against prop mutation in React, but too much of a lift as very rarely do we apply readonly/ReadonlyArray<T> to type definitions
|
|
65
|
-
"sonarjs/prefer-read-only-props": "off",
|
|
66
|
-
// Noisy rule: if we wanted stricter linting of TODOs, we could use unicorn/expiring-todo-comments
|
|
67
|
-
"sonarjs/todo-tag": "off",
|
|
68
|
-
// A useful rule to consider for libraries to better document (and export) type definitions, but noisy in app usages (especially around redux type definitions)
|
|
69
|
-
"sonarjs/use-type-alias": "off",
|
|
70
|
-
/**
|
|
71
|
-
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
|
|
72
|
-
*/
|
|
73
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
74
|
-
"error",
|
|
75
|
-
{
|
|
76
|
-
disallowTypeAnnotations: true,
|
|
77
|
-
fixStyle: "inline-type-imports",
|
|
78
|
-
prefer: "type-imports",
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
/** We do not need to force people to wrap `void`-return implicit arrow returns with braces just for a lint rule. TypeScript alone covers functionality, by the return type being `void`. */
|
|
82
|
-
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
83
|
-
/** Included as part of `strict-type-checked`, but nothing we want to enforce. */
|
|
84
|
-
"@typescript-eslint/no-deprecated": "off",
|
|
85
|
-
/** Prefers `import type {}` syntax over `import { type }` if all imports are type-only */
|
|
86
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
87
|
-
/** A relatively stylistic rule, downgraded to "off" to limit breaking changes in the update that includes `strict-type-checked`. */
|
|
88
|
-
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
89
|
-
/** This rule can help us identify syntax that is more defensive than the types suggest. Unfortunately, it may be protecting us from runtime errors where the type definitions are incorrect. As such, it is turned "off", as even "warn" auto-fixes source code. */
|
|
90
|
-
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
91
|
-
/** There is readability benefit to passing in type arguments that match defaults. If defaults change, we may prefer the manual inspection of all the types changed, too. */
|
|
92
|
-
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
93
|
-
/** Errors on generic type parameters that are only used once, even though that helps with return type inference. */
|
|
94
|
-
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
95
|
-
"@typescript-eslint/no-unused-vars": [
|
|
96
|
-
"error",
|
|
97
|
-
{
|
|
98
|
-
// Allow to name unused vars with _
|
|
99
|
-
argsIgnorePattern: "^_",
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
103
|
-
"@typescript-eslint/unbound-method": "error",
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
prettierPluginRecommended,
|
|
107
|
-
jsonPlugin.configs["recommended"],
|
|
108
|
-
{
|
|
109
|
-
files: ["test/**/*.{ts,tsx}"],
|
|
110
|
-
plugins: { jest: jestPlugin },
|
|
111
|
-
languageOptions: {
|
|
112
|
-
globals: jestPlugin.environments.globals.globals,
|
|
113
|
-
parser: tsParser,
|
|
114
|
-
parserOptions: {
|
|
115
|
-
projectService: true,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
extends: [jestPlugin.configs["flat/recommended"]],
|
|
119
|
-
rules: {
|
|
120
|
-
...jestPlugin.configs["flat/recommended"].rules,
|
|
121
|
-
// this turns the original rule off *only* for test files, for jestPlugin compatibility
|
|
122
|
-
"@typescript-eslint/unbound-method": "off",
|
|
123
|
-
"jest/no-jest-import": "off",
|
|
124
|
-
"jest/unbound-method": "error",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
settings: {
|
|
129
|
-
"import/resolver": {
|
|
130
|
-
typescript: {
|
|
131
|
-
alwaysTryTypes: true,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
);
|
|
1
|
+
// eslint-disable-next-line import/no-default-export
|
|
2
|
+
export { default } from "./index.cjs";
|
|
Binary file
|
package/package.json
CHANGED
package/recommended.cjs
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
root: true,
|
|
3
2
|
env: {
|
|
4
3
|
es2022: true,
|
|
5
4
|
jest: true,
|
|
6
5
|
},
|
|
7
|
-
parser: "@typescript-eslint/parser",
|
|
8
|
-
plugins: [
|
|
9
|
-
"@typescript-eslint",
|
|
10
|
-
"eslint-plugin-jest",
|
|
11
|
-
"import",
|
|
12
|
-
"jest",
|
|
13
|
-
"json",
|
|
14
|
-
"n",
|
|
15
|
-
"perfectionist",
|
|
16
|
-
"prettier",
|
|
17
|
-
"sonarjs",
|
|
18
|
-
"unicorn",
|
|
19
|
-
],
|
|
20
6
|
extends: [
|
|
21
7
|
"eslint:recommended",
|
|
22
8
|
"plugin:@typescript-eslint/recommended-type-checked",
|
|
@@ -31,11 +17,6 @@ module.exports = {
|
|
|
31
17
|
"plugin:sonarjs/recommended-legacy",
|
|
32
18
|
"plugin:unicorn/recommended",
|
|
33
19
|
],
|
|
34
|
-
parserOptions: {
|
|
35
|
-
ecmaVersion: "latest",
|
|
36
|
-
project: "./tsconfig.json",
|
|
37
|
-
sourceType: "module",
|
|
38
|
-
},
|
|
39
20
|
overrides: [
|
|
40
21
|
{
|
|
41
22
|
files: ["test/**"],
|
|
@@ -47,7 +28,60 @@ module.exports = {
|
|
|
47
28
|
},
|
|
48
29
|
},
|
|
49
30
|
],
|
|
31
|
+
parser: "@typescript-eslint/parser",
|
|
32
|
+
parserOptions: {
|
|
33
|
+
ecmaVersion: "latest",
|
|
34
|
+
project: "./tsconfig.json",
|
|
35
|
+
sourceType: "module",
|
|
36
|
+
},
|
|
37
|
+
plugins: [
|
|
38
|
+
"@typescript-eslint",
|
|
39
|
+
"eslint-plugin-jest",
|
|
40
|
+
"import",
|
|
41
|
+
"jest",
|
|
42
|
+
"json",
|
|
43
|
+
"n",
|
|
44
|
+
"perfectionist",
|
|
45
|
+
"prettier",
|
|
46
|
+
"sonarjs",
|
|
47
|
+
"unicorn",
|
|
48
|
+
],
|
|
49
|
+
root: true,
|
|
50
50
|
rules: {
|
|
51
|
+
/**
|
|
52
|
+
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
|
|
53
|
+
*/
|
|
54
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
55
|
+
"error",
|
|
56
|
+
{
|
|
57
|
+
disallowTypeAnnotations: true,
|
|
58
|
+
fixStyle: "inline-type-imports",
|
|
59
|
+
prefer: "type-imports",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
/** We do not need to force people to wrap `void`-return implicit arrow returns with braces just for a lint rule. TypeScript alone covers functionality, by the return type being `void`. */
|
|
63
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
64
|
+
/** Included as part of `strict-type-checked`, but nothing we want to enforce. */
|
|
65
|
+
"@typescript-eslint/no-deprecated": "off",
|
|
66
|
+
/** Prefers `import type {}` syntax over `import { type }` if all imports are type-only */
|
|
67
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
68
|
+
/** A relatively stylistic rule, downgraded to "off" to limit breaking changes in the update that includes `strict-type-checked`. */
|
|
69
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
70
|
+
/** This rule can help us identify syntax that is more defensive than the types suggest. Unfortunately, it may be protecting us from runtime errors where the type definitions are incorrect. As such, it is turned "off", as even "warn" auto-fixes source code. */
|
|
71
|
+
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
72
|
+
/** There is readability benefit to passing in type arguments that match defaults. If defaults change, we may prefer the manual inspection of all the types changed, too. */
|
|
73
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
74
|
+
/** Errors on generic type parameters that are only used once, even though that helps with return type inference. */
|
|
75
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
76
|
+
"@typescript-eslint/no-unused-vars": [
|
|
77
|
+
"error",
|
|
78
|
+
{
|
|
79
|
+
// Allow to name unused vars with _
|
|
80
|
+
argsIgnorePattern: "^_",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
84
|
+
"@typescript-eslint/unbound-method": "error",
|
|
51
85
|
"import/default": "off",
|
|
52
86
|
"import/named": "off",
|
|
53
87
|
"import/namespace": "off",
|
|
@@ -59,6 +93,7 @@ module.exports = {
|
|
|
59
93
|
"import/prefer-default-export": "off",
|
|
60
94
|
"jest/no-jest-import": "off",
|
|
61
95
|
"json/*": "error",
|
|
96
|
+
"n/no-missing-import": "off",
|
|
62
97
|
"n/no-unpublished-import": [
|
|
63
98
|
"error",
|
|
64
99
|
{
|
|
@@ -66,7 +101,6 @@ module.exports = {
|
|
|
66
101
|
},
|
|
67
102
|
],
|
|
68
103
|
"n/no-unsupported-features/es-syntax": "off",
|
|
69
|
-
"n/no-missing-import": "off",
|
|
70
104
|
// Noisy rule - we may have helpers/methods that we mark as @deprecated but aren't planning to remove in the near future. This rule also significantly adds to eslint running time, which slows down both local development and CI.
|
|
71
105
|
"sonarjs/deprecation": "off",
|
|
72
106
|
// This rule is not helpful in TypeScript files, and in JavaScript we often return different types from functions, so this is not a strictness level we want to enforce.
|
|
@@ -75,10 +109,10 @@ module.exports = {
|
|
|
75
109
|
"sonarjs/no-ignored-exceptions": "off",
|
|
76
110
|
"sonarjs/no-nested-functions": ["warn", { threshold: 5 }],
|
|
77
111
|
"sonarjs/no-small-switch": "off",
|
|
78
|
-
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
79
|
-
"sonarjs/prefer-nullish-coalescing": "off",
|
|
80
112
|
// Overlaps with @typescript-eslint/no-unused-vars
|
|
81
113
|
"sonarjs/no-unused-vars": "off",
|
|
114
|
+
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
115
|
+
"sonarjs/prefer-nullish-coalescing": "off",
|
|
82
116
|
// Overlaps with @typescript-eslint/prefer-optional-chain
|
|
83
117
|
"sonarjs/prefer-optional-chain": "off",
|
|
84
118
|
// Useful for guarding against prop mutation in React, but too much of a lift as very rarely do we apply readonly/ReadonlyArray<T> to type definitions
|
|
@@ -87,40 +121,6 @@ module.exports = {
|
|
|
87
121
|
"sonarjs/todo-tag": "off",
|
|
88
122
|
// A useful rule to consider for libraries to better document (and export) type definitions, but noisy in app usages (especially around redux type definitions)
|
|
89
123
|
"sonarjs/use-type-alias": "off",
|
|
90
|
-
/**
|
|
91
|
-
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
|
|
92
|
-
*/
|
|
93
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
94
|
-
"error",
|
|
95
|
-
{
|
|
96
|
-
disallowTypeAnnotations: true,
|
|
97
|
-
fixStyle: "inline-type-imports",
|
|
98
|
-
prefer: "type-imports",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
/** We do not need to force people to wrap `void`-return implicit arrow returns with braces just for a lint rule. TypeScript alone covers functionality, by the return type being `void`. */
|
|
102
|
-
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
103
|
-
/** Included as part of `strict-type-checked`, but nothing we want to enforce. */
|
|
104
|
-
"@typescript-eslint/no-deprecated": "off",
|
|
105
|
-
/** Prefers `import type {}` syntax over `import { type }` if all imports are type-only */
|
|
106
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
107
|
-
/** A relatively stylistic rule, downgraded to "off" to limit breaking changes in the update that includes `strict-type-checked`. */
|
|
108
|
-
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
109
|
-
/** This rule can help us identify syntax that is more defensive than the types suggest. Unfortunately, it may be protecting us from runtime errors where the type definitions are incorrect. As such, it is turned "off", as even "warn" auto-fixes source code. */
|
|
110
|
-
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
111
|
-
/** There is readability benefit to passing in type arguments that match defaults. If defaults change, we may prefer the manual inspection of all the types changed, too. */
|
|
112
|
-
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
113
|
-
/** Errors on generic type parameters that are only used once, even though that helps with return type inference. */
|
|
114
|
-
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
115
|
-
"@typescript-eslint/no-unused-vars": [
|
|
116
|
-
"error",
|
|
117
|
-
{
|
|
118
|
-
// Allow to name unused vars with _
|
|
119
|
-
argsIgnorePattern: "^_",
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
123
|
-
"@typescript-eslint/unbound-method": "error",
|
|
124
124
|
},
|
|
125
125
|
settings: {
|
|
126
126
|
"import/parsers": {
|
package/test/test.spec.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { loadESLint } from "eslint";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import path from "node:path";
|
|
4
2
|
|
|
5
3
|
describe("validate config", () => {
|
|
6
4
|
test.each(["./index.mjs", "./index.cjs", "./recommended.cjs"])(
|
|
@@ -12,8 +10,6 @@ describe("validate config", () => {
|
|
|
12
10
|
useFlatConfig,
|
|
13
11
|
});
|
|
14
12
|
const linter = new ESLint({
|
|
15
|
-
// cwd: cwd,
|
|
16
|
-
overrideConfigFile: config,
|
|
17
13
|
overrideConfig: useFlatConfig
|
|
18
14
|
? [
|
|
19
15
|
{
|
|
@@ -34,6 +30,8 @@ describe("validate config", () => {
|
|
|
34
30
|
},
|
|
35
31
|
},
|
|
36
32
|
},
|
|
33
|
+
// cwd: cwd,
|
|
34
|
+
overrideConfigFile: config,
|
|
37
35
|
});
|
|
38
36
|
const messages = await linter.lintText(
|
|
39
37
|
`const foo = 1;\nconsole.log(foo);\n`,
|
|
Binary file
|