@open-turo/eslint-config-typescript 18.0.12 → 18.1.0-pr-440.291.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/.nvmrc +1 -1
- package/.pre-commit-config.yaml +1 -1
- package/README.md +13 -2
- package/index.cjs +52 -4
- package/pack/open-turo-eslint-config-typescript-18.1.0-pr-440.291.1.1.tgz +0 -0
- package/package.json +2 -1
- package/test/__snapshots__/test.spec.js.snap +6100 -0
- package/test/test.spec.js +36 -0
- package/pack/open-turo-eslint-config-typescript-18.0.12.tgz +0 -0
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
22.
|
|
1
|
+
22.20.0
|
package/.pre-commit-config.yaml
CHANGED
package/README.md
CHANGED
|
@@ -29,10 +29,21 @@ module.exports = turoConfig();
|
|
|
29
29
|
|
|
30
30
|
The `turoConfig` function accepts an options object with the following properties:
|
|
31
31
|
|
|
32
|
-
- `allowModules` - List of modules to allow in the `n/no-unpublished-import` rule
|
|
33
|
-
- `ignores` - List of patterns to ignore
|
|
32
|
+
- `allowModules` - List of modules to allow in the `n/no-unpublished-import` rule. Defaults to `["@jest/globals", "nock"]` for Jest or `["nock"]` for Vitest
|
|
33
|
+
- `ignores` - List of patterns to ignore
|
|
34
34
|
- `typescript` - Whether to include typescript rules. Defaults to `true`
|
|
35
35
|
- `ecmaVersion` - The ECMAScript version to use. Defaults to `latest`
|
|
36
|
+
- `testFramework` - Test framework to use: `"jest"` (default) or `"vitest"`
|
|
37
|
+
|
|
38
|
+
#### Vitest Configuration Example
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
const turoConfig = require("@open-turo/eslint-config-typescript");
|
|
42
|
+
|
|
43
|
+
module.exports = turoConfig({
|
|
44
|
+
testFramework: "vitest",
|
|
45
|
+
});
|
|
46
|
+
```
|
|
36
47
|
|
|
37
48
|
### **[.eslintrc](https://eslint.org/docs/latest/use/configure/configuration-files)** (legacy example)
|
|
38
49
|
|
package/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const perfectionistPlugin = require("eslint-plugin-perfectionist");
|
|
|
11
11
|
const prettierPluginRecommended = require("eslint-plugin-prettier/recommended");
|
|
12
12
|
const sonarjsPlugin = require("eslint-plugin-sonarjs");
|
|
13
13
|
const unicornPlugin = require("eslint-plugin-unicorn");
|
|
14
|
+
const vitestPlugin = require("@vitest/eslint-plugin");
|
|
14
15
|
const tseslint = require("typescript-eslint");
|
|
15
16
|
|
|
16
17
|
const FILES_JS = "**/*.?([cm])js";
|
|
@@ -183,10 +184,9 @@ const typescriptConfig = () =>
|
|
|
183
184
|
* @param {object} options Configuration options
|
|
184
185
|
* @param {boolean} options.typescript Whether to include typescript rules
|
|
185
186
|
*/
|
|
186
|
-
const
|
|
187
|
+
const jestTestConfig = (options) => {
|
|
187
188
|
const typescriptRules = options.typescript
|
|
188
189
|
? /** @type {const} */ ({
|
|
189
|
-
// this turns the original rule off *only* for test files, for jestPlugin compatibility
|
|
190
190
|
"@typescript-eslint/unbound-method": "off",
|
|
191
191
|
"jest/unbound-method": "error",
|
|
192
192
|
})
|
|
@@ -211,6 +211,42 @@ const testConfig = (options) => {
|
|
|
211
211
|
});
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
+
/**
|
|
215
|
+
*
|
|
216
|
+
* @param {object} options Configuration options
|
|
217
|
+
* @param {boolean} options.typescript Whether to include typescript rules
|
|
218
|
+
*/
|
|
219
|
+
const vitestTestConfig = (options) => {
|
|
220
|
+
return tseslint.config({
|
|
221
|
+
extends: [vitestPlugin.configs.recommended],
|
|
222
|
+
files: FILES_TEST,
|
|
223
|
+
languageOptions: {
|
|
224
|
+
globals: vitestPlugin.environments.env.globals,
|
|
225
|
+
...(options.typescript ? typescriptLanguageOptions() : {}),
|
|
226
|
+
},
|
|
227
|
+
plugins: { vitest: vitestPlugin },
|
|
228
|
+
rules: {
|
|
229
|
+
"import/no-extraneous-dependencies": [
|
|
230
|
+
"error",
|
|
231
|
+
{ devDependencies: FILES_TEST },
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
*
|
|
239
|
+
* @param {object} options Configuration options
|
|
240
|
+
* @param {boolean} options.typescript Whether to include typescript rules
|
|
241
|
+
* @param {"jest" | "vitest"} options.testFramework Test framework to use
|
|
242
|
+
*/
|
|
243
|
+
const testConfig = (options) => {
|
|
244
|
+
if (options.testFramework === "vitest") {
|
|
245
|
+
return vitestTestConfig(options);
|
|
246
|
+
}
|
|
247
|
+
return jestTestConfig(options);
|
|
248
|
+
};
|
|
249
|
+
|
|
214
250
|
/**
|
|
215
251
|
* @param {string[]} ignores
|
|
216
252
|
*/
|
|
@@ -226,22 +262,34 @@ const ignoresConfig = (ignores = []) =>
|
|
|
226
262
|
* @param {string[]} [options.ignores] - List of patterns to ignore
|
|
227
263
|
* @param {boolean} [options.typescript] - Whether to include typescript rules
|
|
228
264
|
* @param {EcmaVersion} [options.ecmaVersion] - The ECMAScript version to use
|
|
265
|
+
* @param {"jest" | "vitest"} [options.testFramework] - Test framework to use (defaults to "jest")
|
|
229
266
|
*/
|
|
230
267
|
module.exports = function config(options = {}) {
|
|
231
268
|
const useTypescript =
|
|
232
269
|
options.typescript === undefined ? true : options.typescript;
|
|
270
|
+
const testFramework = options.testFramework || "jest";
|
|
271
|
+
|
|
272
|
+
if (testFramework !== "jest" && testFramework !== "vitest") {
|
|
273
|
+
throw new Error(
|
|
274
|
+
`Invalid testFramework option: "${testFramework}". Valid values are "jest" or "vitest".`,
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const defaultAllowModules =
|
|
279
|
+
testFramework === "vitest" ? ["nock"] : ["@jest/globals", "nock"];
|
|
280
|
+
const allowModules = options.allowModules || defaultAllowModules;
|
|
233
281
|
|
|
234
282
|
return tseslint.config(
|
|
235
283
|
javascriptConfig(options.ecmaVersion),
|
|
236
284
|
importConfig(),
|
|
237
|
-
nPluginConfig(
|
|
285
|
+
nPluginConfig(allowModules),
|
|
238
286
|
perfectionistPlugin.configs["recommended-alphabetical"],
|
|
239
287
|
sonarJsConfig(),
|
|
240
288
|
unicornPlugin.configs["flat/recommended"],
|
|
241
289
|
prettierPluginRecommended,
|
|
242
290
|
jsonPlugin.configs["recommended"],
|
|
243
291
|
useTypescript ? typescriptConfig() : {},
|
|
244
|
-
testConfig({ typescript: useTypescript }),
|
|
292
|
+
testConfig({ testFramework, typescript: useTypescript }),
|
|
245
293
|
ignoresConfig(options.ignores),
|
|
246
294
|
);
|
|
247
295
|
};
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"@eslint/js": "9.36.0",
|
|
7
7
|
"@typescript-eslint/eslint-plugin": "8.45.0",
|
|
8
8
|
"@typescript-eslint/parser": "8.45.0",
|
|
9
|
+
"@vitest/eslint-plugin": "1.1.23",
|
|
9
10
|
"eslint-config-prettier": "10.1.8",
|
|
10
11
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
11
12
|
"eslint-plugin-import": "2.32.0",
|
|
@@ -55,6 +56,6 @@
|
|
|
55
56
|
"access": "public"
|
|
56
57
|
},
|
|
57
58
|
"repository": "https://github.com/open-turo/eslint-config-typescript",
|
|
58
|
-
"version": "18.0.
|
|
59
|
+
"version": "18.1.0-pr-440.291.1.1",
|
|
59
60
|
"packageManager": "npm@11.6.1"
|
|
60
61
|
}
|