@open-turo/eslint-config-typescript 16.0.7 → 16.0.8
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/index.cjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @import { ConfigWithExtends } from "typescript-eslint" */
|
|
1
4
|
const eslint = require("@eslint/js");
|
|
2
5
|
const tsParser = require("@typescript-eslint/parser");
|
|
3
6
|
const importPlugin = require("eslint-plugin-import");
|
|
@@ -28,6 +31,13 @@ const typescriptLanguageOptions = () => ({
|
|
|
28
31
|
},
|
|
29
32
|
});
|
|
30
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {NonNullable<NonNullable<ConfigWithExtends['languageOptions']>['parserOptions']>['ecmaVersion']} EcmaVersion
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {EcmaVersion} [ecmaVersion]
|
|
40
|
+
*/
|
|
31
41
|
const javascriptConfig = (ecmaVersion = "latest") =>
|
|
32
42
|
tseslint.config(eslint.configs.recommended, {
|
|
33
43
|
files: [FILES_JS],
|
|
@@ -38,9 +48,19 @@ const javascriptConfig = (ecmaVersion = "latest") =>
|
|
|
38
48
|
},
|
|
39
49
|
});
|
|
40
50
|
|
|
51
|
+
const getImportPluginFlatConfigs = () => {
|
|
52
|
+
if (!importPlugin.flatConfigs) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"Unexpected value from eslint-plugin-import. You will need to upgrade the plugin.",
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return importPlugin.flatConfigs;
|
|
59
|
+
};
|
|
60
|
+
|
|
41
61
|
const importConfig = () =>
|
|
42
62
|
tseslint.config({
|
|
43
|
-
extends: [
|
|
63
|
+
extends: [getImportPluginFlatConfigs().recommended],
|
|
44
64
|
rules: {
|
|
45
65
|
"import/default": "off",
|
|
46
66
|
"import/named": "off",
|
|
@@ -110,7 +130,8 @@ const typescriptConfig = () =>
|
|
|
110
130
|
tseslint.config({
|
|
111
131
|
extends: [
|
|
112
132
|
tseslint.configs.recommendedTypeChecked,
|
|
113
|
-
|
|
133
|
+
// @ts-expect-error -- We are inferring the types of this import from runtime, but the rule values are inferred as `string` instead of `RuleEntry` ("off" | "warn" | "error")
|
|
134
|
+
getImportPluginFlatConfigs().typescript,
|
|
114
135
|
],
|
|
115
136
|
files: [FILES_TS, FILES_TSX],
|
|
116
137
|
languageOptions: typescriptLanguageOptions(),
|
|
@@ -154,17 +175,16 @@ const typescriptConfig = () =>
|
|
|
154
175
|
|
|
155
176
|
/**
|
|
156
177
|
*
|
|
157
|
-
* @param options Configuration options
|
|
158
|
-
* @param options.typescript Whether to include typescript rules
|
|
159
|
-
* @returns {ConfigArray}
|
|
178
|
+
* @param {object} options Configuration options
|
|
179
|
+
* @param {boolean} options.typescript Whether to include typescript rules
|
|
160
180
|
*/
|
|
161
181
|
const testConfig = (options) => {
|
|
162
182
|
const typescriptRules = options.typescript
|
|
163
|
-
? {
|
|
183
|
+
? /** @type {const} */ ({
|
|
164
184
|
// this turns the original rule off *only* for test files, for jestPlugin compatibility
|
|
165
185
|
"@typescript-eslint/unbound-method": "off",
|
|
166
186
|
"jest/unbound-method": "error",
|
|
167
|
-
}
|
|
187
|
+
})
|
|
168
188
|
: {};
|
|
169
189
|
return tseslint.config({
|
|
170
190
|
extends: [jestPlugin.configs["flat/recommended"]],
|
|
@@ -186,6 +206,9 @@ const testConfig = (options) => {
|
|
|
186
206
|
});
|
|
187
207
|
};
|
|
188
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @param {string[]} ignores
|
|
211
|
+
*/
|
|
189
212
|
const ignoresConfig = (ignores = []) =>
|
|
190
213
|
tseslint.config({
|
|
191
214
|
ignores: ["**/.yalc", "**/dist", ...ignores],
|
|
@@ -193,16 +216,16 @@ const ignoresConfig = (ignores = []) =>
|
|
|
193
216
|
|
|
194
217
|
/**
|
|
195
218
|
* Turo eslint configuration for typescript
|
|
196
|
-
* @param [options] - Eslint config options
|
|
197
|
-
* @param [options.allowModules] - List of modules to allow in the n/no-unpublished-import rule
|
|
198
|
-
* @param [options.ignores] - List of patterns to ignore
|
|
199
|
-
* @param [options.typescript] - Whether to include typescript rules
|
|
200
|
-
* @param [options.ecmaVersion] - The ECMAScript version to use
|
|
201
|
-
* @returns {ConfigArray}
|
|
219
|
+
* @param {object} [options] - Eslint config options
|
|
220
|
+
* @param {string[]} [options.allowModules] - List of modules to allow in the n/no-unpublished-import rule
|
|
221
|
+
* @param {string[]} [options.ignores] - List of patterns to ignore
|
|
222
|
+
* @param {boolean} [options.typescript] - Whether to include typescript rules
|
|
223
|
+
* @param {EcmaVersion} [options.ecmaVersion] - The ECMAScript version to use
|
|
202
224
|
*/
|
|
203
225
|
module.exports = function config(options = {}) {
|
|
204
226
|
const useTypescript =
|
|
205
227
|
options.typescript === undefined ? true : options.typescript;
|
|
228
|
+
|
|
206
229
|
return tseslint.config(
|
|
207
230
|
javascriptConfig(options.ecmaVersion),
|
|
208
231
|
importConfig(),
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@eslint/js": "9.29.0",
|
|
7
|
-
"typescript-eslint": "8.34.1",
|
|
8
7
|
"@typescript-eslint/eslint-plugin": "8.34.1",
|
|
9
8
|
"@typescript-eslint/parser": "8.34.1",
|
|
10
9
|
"eslint-config-prettier": "10.1.5",
|
|
@@ -16,7 +15,8 @@
|
|
|
16
15
|
"eslint-plugin-perfectionist": "4.14.0",
|
|
17
16
|
"eslint-plugin-prettier": "5.4.1",
|
|
18
17
|
"eslint-plugin-sonarjs": "3.0.2",
|
|
19
|
-
"eslint-plugin-unicorn": "56.0.1"
|
|
18
|
+
"eslint-plugin-unicorn": "56.0.1",
|
|
19
|
+
"typescript-eslint": "8.34.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"eslint": "9.29.0",
|
|
@@ -54,5 +54,6 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"repository": "https://github.com/open-turo/eslint-config-typescript",
|
|
57
|
-
"version": "16.0.
|
|
57
|
+
"version": "16.0.8",
|
|
58
|
+
"packageManager": "npm@11.4.2+sha512.f90c1ec8b207b625d6edb6693aef23dacb39c38e4217fe8c46a973f119cab392ac0de23fe3f07e583188dae9fd9108b3845ad6f525b598742bd060ebad60bff3"
|
|
58
59
|
}
|
|
Binary file
|