@open-turo/eslint-config-typescript 15.0.1 → 16.0.0-pr-373.4.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/.github/workflows/prerelease.yaml +24 -0
- package/README.md +9 -21
- package/docs/breaking-changes/v16.md +63 -0
- package/eslint.config.mjs +23 -0
- package/index.cjs +133 -0
- package/index.mjs +133 -0
- package/pack/open-turo-eslint-config-typescript-16.0.0-pr-373.4.1.1.tgz +0 -0
- package/package.json +24 -12
- package/{index.js → recommended.cjs} +2 -7
- package/test/test.spec.js +45 -27
- package/legacy.js +0 -128
- package/pack/open-turo-eslint-config-typescript-15.0.1.tgz +0 -0
- package/test/__snapshots__/test.spec.js.snap +0 -3031
- package/test/sample.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Prerelease
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- labeled
|
|
8
|
+
- synchronize
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
jobs:
|
|
13
|
+
prerelease:
|
|
14
|
+
name: Prerelease
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
if: contains(github.event.pull_request.labels.*.name, 'prerelease')
|
|
17
|
+
steps:
|
|
18
|
+
- name: Prerelease
|
|
19
|
+
id: prerelease
|
|
20
|
+
uses: open-turo/actions-node/prerelease@v6
|
|
21
|
+
with:
|
|
22
|
+
github-token: ${{ secrets.OPEN_TURO_GITHUB_TOKEN }}
|
|
23
|
+
npm-token: ${{ secrets.OPEN_TURO_NPM_TOKEN }}
|
|
24
|
+
create-prerelease: true
|
package/README.md
CHANGED
|
@@ -19,33 +19,21 @@ Install the package and all of its peer dependencies:
|
|
|
19
19
|
npx install-peerdeps --dev @open-turo/eslint-config-typescript
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
### [`eslint.config.js`](https://eslint.org/docs/latest/use/configure/configuration-files-new) (requires eslint>=v8.23.0)
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
```js
|
|
25
|
+
const turoConfig = require("@open-turo/eslint-config-typescript");
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
The default config of this repo is the recommended version for new Typescript projects.
|
|
30
|
-
|
|
31
|
-
To use this config, just add to your `.eslintrc` the following:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
"extends": "@open-turo/eslint-config-typescript"
|
|
27
|
+
module.exports = turoConfig;
|
|
35
28
|
```
|
|
36
29
|
|
|
37
|
-
###
|
|
38
|
-
|
|
39
|
-
We also provide an alternative `legacy` preset, which is used by `eslint-config-react`, for compatibility with our
|
|
40
|
-
existing front-end projects.
|
|
41
|
-
|
|
42
|
-
If you want to use this `legacy` configuration, you can import it by instead adding the following to your `.eslintrc`:
|
|
30
|
+
### **[.eslintrc](https://eslint.org/docs/latest/use/configure/configuration-files)** (legacy example)
|
|
43
31
|
|
|
32
|
+
```jsonc
|
|
33
|
+
{
|
|
34
|
+
"extends": "@open-turo/eslint-config-typescript/recommended"],
|
|
35
|
+
}
|
|
44
36
|
```
|
|
45
|
-
"extends": "@open-turo/eslint-config-typescript/legacy"
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Simply notice the `/legacy` suffix, which points to the `legacy.js` file in this repository.
|
|
49
37
|
|
|
50
38
|
## Development
|
|
51
39
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Breaking changes in v16
|
|
2
|
+
|
|
3
|
+
## Minimum Node.js version
|
|
4
|
+
|
|
5
|
+
The minimum Node.js supported version is now `^20`.
|
|
6
|
+
|
|
7
|
+
## Removed plugins
|
|
8
|
+
|
|
9
|
+
The following plugins are getting replaced by [eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist):
|
|
10
|
+
|
|
11
|
+
- [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort)
|
|
12
|
+
- [eslint-plugin-sort-destructure-keys](https://github.com/mthadley/eslint-plugin-sort-destructure-keys)
|
|
13
|
+
- [eslint-plugin-typescript-sort-keys](https://github.com/infctr/eslint-plugin-typescript-sort-keys/tree/master)
|
|
14
|
+
|
|
15
|
+
If you were reconfiguring some of the rules from these plugins in your eslint config you will have to update them and reference
|
|
16
|
+
the equivalent rule from https://perfectionist.dev/rules.
|
|
17
|
+
|
|
18
|
+
## Removed legacy preset
|
|
19
|
+
|
|
20
|
+
The legacy preset is removed, as it only existed for some internal turo projects. Maintaining it to support eslint v9
|
|
21
|
+
was not worth the effort.
|
|
22
|
+
|
|
23
|
+
## Default flat configuration
|
|
24
|
+
|
|
25
|
+
The default configuration for this package is now a flat eslint configuration. Read the
|
|
26
|
+
eslint [guide](https://eslint.org/docs/latest/use/configure/migration-guide) for how to update legacy configurations
|
|
27
|
+
to flat configs.
|
|
28
|
+
|
|
29
|
+
The legacy configuration is still supported. To keep using it, you just have to update the `.eslintrc` file to:
|
|
30
|
+
|
|
31
|
+
```diff
|
|
32
|
+
{
|
|
33
|
+
-- "extends": "@open-turo/eslint-config-typescript"
|
|
34
|
+
++ "extends": "@open-turo/eslint-config-typescript/recommended"
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Updating to flat configuration
|
|
39
|
+
|
|
40
|
+
If you wish to update to a flat configuration, you will have to make the following changes (please refer to the above guide
|
|
41
|
+
for all the details).
|
|
42
|
+
|
|
43
|
+
- Move from `.eslintrc` (or equivalent file) into `eslint.config.js` (or equivalent file).
|
|
44
|
+
- If you have a `.eslintignore` file, replace that into the `ignores` section of the `eslint.config.js` file
|
|
45
|
+
|
|
46
|
+
A `.eslintignore` file like this:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
/lib
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Will become a `eslint.config.js` file like this:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const turoConfig = require("@open-turo/eslint-config-typescript");
|
|
56
|
+
|
|
57
|
+
module.exports = [
|
|
58
|
+
...turoConfig,
|
|
59
|
+
{
|
|
60
|
+
ignores: ["/lib"],
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import openTuroTypescriptConfig from "./index.mjs";
|
|
2
|
+
import jestPlugin from "eslint-plugin-jest";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
...openTuroTypescriptConfig,
|
|
6
|
+
{
|
|
7
|
+
files: ["*.cjs", "*.mjs", "test/**/*.js"],
|
|
8
|
+
languageOptions: {
|
|
9
|
+
parserOptions: {
|
|
10
|
+
projectService: {
|
|
11
|
+
// This project doesn't use Typescript and a lot of our rules require type checking
|
|
12
|
+
allowDefaultProject: [
|
|
13
|
+
"index.mjs",
|
|
14
|
+
"index.cjs",
|
|
15
|
+
"eslint.config.mjs",
|
|
16
|
+
"recommended.cjs",
|
|
17
|
+
"test/test.spec.js",
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
];
|
package/index.cjs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const jestPlugin = require("eslint-plugin-jest");
|
|
2
|
+
const nPlugin = require("eslint-plugin-n");
|
|
3
|
+
const importPlugin = require("eslint-plugin-import");
|
|
4
|
+
const jsonPlugin = require("eslint-plugin-json");
|
|
5
|
+
const eslint = require("@eslint/js");
|
|
6
|
+
const perfectionistPlugin = require("eslint-plugin-perfectionist");
|
|
7
|
+
const prettierPluginRecommended = require("eslint-plugin-prettier/recommended");
|
|
8
|
+
const tseslint = require("typescript-eslint");
|
|
9
|
+
const sonarjsPlugin = require("eslint-plugin-sonarjs");
|
|
10
|
+
const unicornPlugin = require("eslint-plugin-unicorn");
|
|
11
|
+
const tsParser = require("@typescript-eslint/parser");
|
|
12
|
+
|
|
13
|
+
module.exports = 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
|
+
rules: {
|
|
27
|
+
"import/default": "off",
|
|
28
|
+
"import/named": "off",
|
|
29
|
+
"import/namespace": "off",
|
|
30
|
+
"import/no-default-export": "error",
|
|
31
|
+
"import/no-extraneous-dependencies": [
|
|
32
|
+
"error",
|
|
33
|
+
{ devDependencies: ["test/**"] },
|
|
34
|
+
],
|
|
35
|
+
"import/prefer-default-export": "off",
|
|
36
|
+
"n/no-unpublished-import": [
|
|
37
|
+
"error",
|
|
38
|
+
{
|
|
39
|
+
allowModules: ["@jest/globals", "nock"],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
"n/no-unsupported-features/es-syntax": "off",
|
|
43
|
+
"n/no-missing-import": "off",
|
|
44
|
+
// 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.
|
|
45
|
+
"sonarjs/deprecation": "off",
|
|
46
|
+
// 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.
|
|
47
|
+
"sonarjs/function-return-type": "off",
|
|
48
|
+
// We may want to catch errors but not use the error object directly, just trigger error handling fallbacks within the catch block.
|
|
49
|
+
"sonarjs/no-ignored-exceptions": "off",
|
|
50
|
+
"sonarjs/no-nested-functions": ["warn", { threshold: 5 }],
|
|
51
|
+
"sonarjs/no-small-switch": "off",
|
|
52
|
+
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
53
|
+
"sonarjs/prefer-nullish-coalescing": "off",
|
|
54
|
+
// Overlaps with @typescript-eslint/no-unused-vars
|
|
55
|
+
"sonarjs/no-unused-vars": "off",
|
|
56
|
+
// Overlaps with @typescript-eslint/prefer-optional-chain
|
|
57
|
+
"sonarjs/prefer-optional-chain": "off",
|
|
58
|
+
// 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
|
|
59
|
+
"sonarjs/prefer-read-only-props": "off",
|
|
60
|
+
// Noisy rule: if we wanted stricter linting of TODOs, we could use unicorn/expiring-todo-comments
|
|
61
|
+
"sonarjs/todo-tag": "off",
|
|
62
|
+
// A useful rule to consider for libraries to better document (and export) type definitions, but noisy in app usages (especially around redux type definitions)
|
|
63
|
+
"sonarjs/use-type-alias": "off",
|
|
64
|
+
/**
|
|
65
|
+
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
|
|
66
|
+
*/
|
|
67
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
68
|
+
"error",
|
|
69
|
+
{
|
|
70
|
+
disallowTypeAnnotations: true,
|
|
71
|
+
fixStyle: "inline-type-imports",
|
|
72
|
+
prefer: "type-imports",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
/** 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`. */
|
|
76
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
77
|
+
/** Included as part of `strict-type-checked`, but nothing we want to enforce. */
|
|
78
|
+
"@typescript-eslint/no-deprecated": "off",
|
|
79
|
+
/** Prefers `import type {}` syntax over `import { type }` if all imports are type-only */
|
|
80
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
81
|
+
/** A relatively stylistic rule, downgraded to "off" to limit breaking changes in the update that includes `strict-type-checked`. */
|
|
82
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
83
|
+
/** 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. */
|
|
84
|
+
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
85
|
+
/** 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. */
|
|
86
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
87
|
+
/** Errors on generic type parameters that are only used once, even though that helps with return type inference. */
|
|
88
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
89
|
+
"@typescript-eslint/no-unused-vars": [
|
|
90
|
+
"error",
|
|
91
|
+
{
|
|
92
|
+
// Allow to name unused vars with _
|
|
93
|
+
argsIgnorePattern: "^_",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
97
|
+
"@typescript-eslint/unbound-method": "error",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
prettierPluginRecommended,
|
|
101
|
+
jsonPlugin.configs["recommended"],
|
|
102
|
+
{
|
|
103
|
+
files: ["test/**"],
|
|
104
|
+
plugins: { jest: jestPlugin },
|
|
105
|
+
languageOptions: {
|
|
106
|
+
globals: jestPlugin.environments.globals.globals,
|
|
107
|
+
},
|
|
108
|
+
extends: [jestPlugin.configs["flat/recommended"]],
|
|
109
|
+
rules: {
|
|
110
|
+
...jestPlugin.configs["flat/recommended"].rules,
|
|
111
|
+
// this turns the original rule off *only* for test files, for jestPlugin compatibility
|
|
112
|
+
"@typescript-eslint/unbound-method": "off",
|
|
113
|
+
"jest/no-jest-import": "off",
|
|
114
|
+
"jest/unbound-method": "error",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
languageOptions: {
|
|
119
|
+
parser: tsParser,
|
|
120
|
+
parserOptions: {
|
|
121
|
+
projectService: true,
|
|
122
|
+
tsconfigRootDir: __dirname,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
settings: {
|
|
126
|
+
"import/resolver": {
|
|
127
|
+
typescript: {
|
|
128
|
+
alwaysTryTypes: true,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
);
|
package/index.mjs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import jestPlugin from "eslint-plugin-jest";
|
|
2
|
+
import nPlugin from "eslint-plugin-n";
|
|
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
|
+
rules: {
|
|
27
|
+
"import/default": "off",
|
|
28
|
+
"import/named": "off",
|
|
29
|
+
"import/namespace": "off",
|
|
30
|
+
"import/no-default-export": "error",
|
|
31
|
+
"import/no-extraneous-dependencies": [
|
|
32
|
+
"error",
|
|
33
|
+
{ devDependencies: ["test/**"] },
|
|
34
|
+
],
|
|
35
|
+
"import/prefer-default-export": "off",
|
|
36
|
+
"n/no-unpublished-import": [
|
|
37
|
+
"error",
|
|
38
|
+
{
|
|
39
|
+
allowModules: ["@jest/globals", "nock"],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
"n/no-unsupported-features/es-syntax": "off",
|
|
43
|
+
"n/no-missing-import": "off",
|
|
44
|
+
// 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.
|
|
45
|
+
"sonarjs/deprecation": "off",
|
|
46
|
+
// 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.
|
|
47
|
+
"sonarjs/function-return-type": "off",
|
|
48
|
+
// We may want to catch errors but not use the error object directly, just trigger error handling fallbacks within the catch block.
|
|
49
|
+
"sonarjs/no-ignored-exceptions": "off",
|
|
50
|
+
"sonarjs/no-nested-functions": ["warn", { threshold: 5 }],
|
|
51
|
+
"sonarjs/no-small-switch": "off",
|
|
52
|
+
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
|
|
53
|
+
"sonarjs/prefer-nullish-coalescing": "off",
|
|
54
|
+
// Overlaps with @typescript-eslint/no-unused-vars
|
|
55
|
+
"sonarjs/no-unused-vars": "off",
|
|
56
|
+
// Overlaps with @typescript-eslint/prefer-optional-chain
|
|
57
|
+
"sonarjs/prefer-optional-chain": "off",
|
|
58
|
+
// 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
|
|
59
|
+
"sonarjs/prefer-read-only-props": "off",
|
|
60
|
+
// Noisy rule: if we wanted stricter linting of TODOs, we could use unicorn/expiring-todo-comments
|
|
61
|
+
"sonarjs/todo-tag": "off",
|
|
62
|
+
// A useful rule to consider for libraries to better document (and export) type definitions, but noisy in app usages (especially around redux type definitions)
|
|
63
|
+
"sonarjs/use-type-alias": "off",
|
|
64
|
+
/**
|
|
65
|
+
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
|
|
66
|
+
*/
|
|
67
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
68
|
+
"error",
|
|
69
|
+
{
|
|
70
|
+
disallowTypeAnnotations: true,
|
|
71
|
+
fixStyle: "inline-type-imports",
|
|
72
|
+
prefer: "type-imports",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
/** 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`. */
|
|
76
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
77
|
+
/** Included as part of `strict-type-checked`, but nothing we want to enforce. */
|
|
78
|
+
"@typescript-eslint/no-deprecated": "off",
|
|
79
|
+
/** Prefers `import type {}` syntax over `import { type }` if all imports are type-only */
|
|
80
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
81
|
+
/** A relatively stylistic rule, downgraded to "off" to limit breaking changes in the update that includes `strict-type-checked`. */
|
|
82
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
83
|
+
/** 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. */
|
|
84
|
+
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
85
|
+
/** 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. */
|
|
86
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
87
|
+
/** Errors on generic type parameters that are only used once, even though that helps with return type inference. */
|
|
88
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
89
|
+
"@typescript-eslint/no-unused-vars": [
|
|
90
|
+
"error",
|
|
91
|
+
{
|
|
92
|
+
// Allow to name unused vars with _
|
|
93
|
+
argsIgnorePattern: "^_",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
97
|
+
"@typescript-eslint/unbound-method": "error",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
prettierPluginRecommended,
|
|
101
|
+
jsonPlugin.configs["recommended"],
|
|
102
|
+
{
|
|
103
|
+
files: ["test/**"],
|
|
104
|
+
plugins: { jest: jestPlugin },
|
|
105
|
+
languageOptions: {
|
|
106
|
+
globals: jestPlugin.environments.globals.globals,
|
|
107
|
+
},
|
|
108
|
+
extends: [jestPlugin.configs["flat/recommended"]],
|
|
109
|
+
rules: {
|
|
110
|
+
...jestPlugin.configs["flat/recommended"].rules,
|
|
111
|
+
// this turns the original rule off *only* for test files, for jestPlugin compatibility
|
|
112
|
+
"@typescript-eslint/unbound-method": "off",
|
|
113
|
+
"jest/no-jest-import": "off",
|
|
114
|
+
"jest/unbound-method": "error",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
languageOptions: {
|
|
119
|
+
parser: tsParser,
|
|
120
|
+
parserOptions: {
|
|
121
|
+
projectService: true,
|
|
122
|
+
tsconfigRootDir: import.meta.dirname,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
settings: {
|
|
126
|
+
"import/resolver": {
|
|
127
|
+
typescript: {
|
|
128
|
+
alwaysTryTypes: true,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,46 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Turo engineering",
|
|
3
3
|
"description": "Turo eslint configuration for typescript",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"dependencies": {
|
|
5
|
-
"@
|
|
6
|
-
"
|
|
6
|
+
"@eslint/js": "9.19.0",
|
|
7
|
+
"typescript-eslint": "8.22.0",
|
|
8
|
+
"@typescript-eslint/eslint-plugin": "8.22.0",
|
|
9
|
+
"@typescript-eslint/parser": "8.22.0",
|
|
7
10
|
"eslint-config-prettier": "10.0.1",
|
|
8
11
|
"eslint-import-resolver-typescript": "3.7.0",
|
|
9
12
|
"eslint-plugin-import": "2.31.0",
|
|
10
13
|
"eslint-plugin-jest": "28.11.0",
|
|
11
14
|
"eslint-plugin-json": "4.0.1",
|
|
12
15
|
"eslint-plugin-n": "17.15.1",
|
|
16
|
+
"eslint-plugin-perfectionist": "4.7.0",
|
|
13
17
|
"eslint-plugin-prettier": "5.2.3",
|
|
14
|
-
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
15
18
|
"eslint-plugin-sonarjs": "3.0.1",
|
|
16
|
-
"eslint-plugin-sort-destructure-keys": "2.0.0",
|
|
17
|
-
"eslint-plugin-typescript-sort-keys": "3.3.0",
|
|
18
19
|
"eslint-plugin-unicorn": "56.0.1"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"eslint": "
|
|
22
|
+
"eslint": "9.19.0",
|
|
22
23
|
"jest": "29.7.0",
|
|
23
24
|
"prettier": "3.4.2"
|
|
24
25
|
},
|
|
25
26
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
27
|
+
"node": ">= 20"
|
|
27
28
|
},
|
|
28
29
|
"homepage": "https://github.com/open-turo/eslint-config-typescript#readme",
|
|
29
30
|
"license": "MIT",
|
|
30
|
-
"main": "index.
|
|
31
|
+
"main": "index.cjs",
|
|
32
|
+
"module": "index.mjs",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./index.mjs",
|
|
36
|
+
"require": "./index.cjs",
|
|
37
|
+
"default": "./index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./legacy": {
|
|
40
|
+
"require": "./legacy.cjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
31
43
|
"name": "@open-turo/eslint-config-typescript",
|
|
32
44
|
"scripts": {
|
|
33
45
|
"build": "echo noop",
|
|
34
|
-
"lint": "
|
|
35
|
-
"test": "
|
|
46
|
+
"lint": "eslint './*.{cjs,mjs}' test/test.spec.js",
|
|
47
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
36
48
|
},
|
|
37
49
|
"peerDependencies": {
|
|
38
|
-
"eslint": "^8.18.0",
|
|
50
|
+
"eslint": "^8.18.0 || ^9.0.0",
|
|
39
51
|
"prettier": "^3.0.0"
|
|
40
52
|
},
|
|
41
53
|
"publishConfig": {
|
|
42
54
|
"access": "public"
|
|
43
55
|
},
|
|
44
56
|
"repository": "https://github.com/open-turo/eslint-config-typescript",
|
|
45
|
-
"version": "
|
|
57
|
+
"version": "16.0.0-pr-373.4.1.1"
|
|
46
58
|
}
|
|
@@ -12,11 +12,9 @@ module.exports = {
|
|
|
12
12
|
"jest",
|
|
13
13
|
"json",
|
|
14
14
|
"n",
|
|
15
|
+
"perfectionist",
|
|
15
16
|
"prettier",
|
|
16
|
-
"simple-import-sort",
|
|
17
17
|
"sonarjs",
|
|
18
|
-
"sort-destructure-keys",
|
|
19
|
-
"typescript-sort-keys",
|
|
20
18
|
"unicorn",
|
|
21
19
|
],
|
|
22
20
|
extends: [
|
|
@@ -28,9 +26,9 @@ module.exports = {
|
|
|
28
26
|
"plugin:jest/recommended",
|
|
29
27
|
"plugin:json/recommended-legacy",
|
|
30
28
|
"plugin:n/recommended",
|
|
29
|
+
"plugin:perfectionist/recommended-alphabetical-legacy",
|
|
31
30
|
"plugin:prettier/recommended",
|
|
32
31
|
"plugin:sonarjs/recommended-legacy",
|
|
33
|
-
"plugin:typescript-sort-keys/recommended",
|
|
34
32
|
"plugin:unicorn/recommended",
|
|
35
33
|
],
|
|
36
34
|
parserOptions: {
|
|
@@ -69,9 +67,6 @@ module.exports = {
|
|
|
69
67
|
],
|
|
70
68
|
"n/no-unsupported-features/es-syntax": "off",
|
|
71
69
|
"n/no-missing-import": "off",
|
|
72
|
-
"simple-import-sort/imports": "error",
|
|
73
|
-
"simple-import-sort/exports": "error",
|
|
74
|
-
"sort-destructure-keys/sort-destructure-keys": "error",
|
|
75
70
|
// 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.
|
|
76
71
|
"sonarjs/deprecation": "off",
|
|
77
72
|
// 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.
|
package/test/test.spec.js
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { loadESLint } from "eslint";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
3
4
|
|
|
4
5
|
describe("validate config", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
test.each(["./index.mjs", "./index.cjs", "./recommended.cjs"])(
|
|
7
|
+
`load config file in ESLint to validate all rules are correct for %s`,
|
|
8
|
+
async (config) => {
|
|
9
|
+
const testFileName = "test.js";
|
|
10
|
+
const useFlatConfig = !config.includes("recommended");
|
|
11
|
+
const ESLint = await loadESLint({
|
|
12
|
+
useFlatConfig,
|
|
13
|
+
});
|
|
14
|
+
const linter = new ESLint({
|
|
15
|
+
// cwd: cwd,
|
|
16
|
+
overrideConfigFile: config,
|
|
17
|
+
overrideConfig: useFlatConfig
|
|
18
|
+
? [
|
|
19
|
+
{
|
|
20
|
+
files: [testFileName],
|
|
21
|
+
languageOptions: {
|
|
22
|
+
parserOptions: {
|
|
23
|
+
projectService: {
|
|
24
|
+
allowDefaultProject: [testFileName],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
: {
|
|
31
|
+
parserOptions: {
|
|
32
|
+
projectService: {
|
|
33
|
+
allowDefaultProject: [testFileName],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const messages = await linter.lintText(
|
|
39
|
+
`const foo = 1;\nconsole.log(foo);\n`,
|
|
40
|
+
{
|
|
41
|
+
filePath: testFileName,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
expect(messages[0].messages).toEqual([]);
|
|
45
|
+
expect(messages[0].errorCount).toEqual(0);
|
|
46
|
+
},
|
|
47
|
+
);
|
|
30
48
|
});
|