Skip to content

Commit 4fe8bfb

Browse files
committed
Fix issue where @typescript-eslint/recommended rules were not included
1 parent 7dffb39 commit 4fe8bfb

File tree

5 files changed

+45
-49
lines changed

5 files changed

+45
-49
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
> ESLint configuration for services built with Node.js and TypeScript.
66
7-
The configuration extends `@typescript-eslint/recommended`, `eslint-plugin-sonarjs`, `prettier` ESLint configurations.
7+
The configuration exports and extends `@typescript-eslint/recommended`, `eslint-plugin-sonarjs`, `prettier` ESLint configurations.
88

99
It is compatible with ESlint >= v9 configuration format (flat config).
1010

@@ -20,7 +20,7 @@ Note that it requires ESlint v9 and above.
2020

2121
## Usage
2222

23-
Import the package inside of an eslint.config.js file and add it into the exported array, like this:
23+
Import the package inside of an `eslint.config.js` file and add it into the exported array, like this:
2424

2525
```js
2626
// eslint.config.js

index.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import js from "@eslint/js";
2-
import prettierConfig from "eslint-config-prettier";
3-
import * as typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
4-
import tsParser from "@typescript-eslint/parser";
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
53
import sonarjs from "eslint-plugin-sonarjs";
4+
import prettierConfig from "eslint-config-prettier";
65
import globals from "globals";
76

8-
export default [
9-
js.configs.recommended,
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
...tseslint.configs.recommended,
1010
sonarjs.configs.recommended,
1111
prettierConfig,
1212
{
@@ -18,33 +18,30 @@ export default [
1818
Atomics: "readonly",
1919
SharedArrayBuffer: "readonly",
2020
},
21-
parser: tsParser,
2221
parserOptions: {
2322
ecmaVersion: 2018,
2423
sourceType: "module",
2524
},
2625
},
27-
plugins: {
28-
"@typescript-eslint": typescriptEslintPlugin,
29-
// sonarjs,
30-
},
3126
rules: {
32-
"@typescript-eslint/no-use-before-define": "off",
33-
"@typescript-eslint/no-inferrable-types": "off",
27+
// base rule needs to be disabled to prevent errors with the ts version
28+
// see https://typescript-eslint.io/rules/#extension-rules
29+
"no-unused-vars": "off",
3430
"@typescript-eslint/no-unused-vars": "error",
35-
"@typescript-eslint/interface-name-prefix": "off",
31+
"@typescript-eslint/no-explicit-any": "off",
3632
"@typescript-eslint/consistent-type-assertions": [
3733
"error",
3834
{ assertionStyle: "angle-bracket" },
3935
],
40-
"@typescript-eslint/no-explicit-any": "off",
41-
"@typescript-eslint/explicit-function-return-type": "off",
4236
},
4337
},
38+
// overriding rules specifically for test files
4439
{
4540
files: ["**/*(specs|tests)/**", "**/*.spec.ts"],
4641
rules: {
4742
"@typescript-eslint/no-empty-function": "off",
43+
"sonarjs/no-identical-functions": "off",
44+
"sonarjs/no-duplicate-string": "off",
4845
},
49-
},
50-
];
46+
}
47+
);

package-lock.json

Lines changed: 4 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"license": "MIT",
1515
"dependencies": {
1616
"@eslint/js": "^9.14.0",
17-
"@types/eslint__js": "^8.42.3",
1817
"eslint-config-prettier": "^9.1.0",
1918
"eslint-plugin-sonarjs": "^2.0.4",
2019
"globals": "^15.12.0",

test/rules-snapshot.json

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,36 @@
5252
"no-unsafe-optional-chaining": [2],
5353
"no-unused-labels": [2],
5454
"no-unused-private-class-members": [2],
55-
"no-unused-vars": [2],
55+
"no-unused-vars": [0],
5656
"no-useless-backreference": [2],
5757
"no-useless-catch": [2],
5858
"no-useless-escape": [2],
5959
"no-with": [2],
6060
"require-yield": [2],
6161
"use-isnan": [2],
6262
"valid-typeof": [2],
63+
"@typescript-eslint/ban-ts-comment": [2],
64+
"no-array-constructor": [0],
65+
"@typescript-eslint/no-array-constructor": [2],
66+
"@typescript-eslint/no-duplicate-enum-values": [2],
67+
"@typescript-eslint/no-empty-object-type": [2],
68+
"@typescript-eslint/no-explicit-any": [0],
69+
"@typescript-eslint/no-extra-non-null-assertion": [2],
70+
"@typescript-eslint/no-misused-new": [2],
71+
"@typescript-eslint/no-namespace": [2],
72+
"@typescript-eslint/no-non-null-asserted-optional-chain": [2],
73+
"@typescript-eslint/no-require-imports": [2],
74+
"@typescript-eslint/no-this-alias": [2],
75+
"@typescript-eslint/no-unnecessary-type-constraint": [2],
76+
"@typescript-eslint/no-unsafe-declaration-merging": [2],
77+
"@typescript-eslint/no-unsafe-function-type": [2],
78+
"no-unused-expressions": [0],
79+
"@typescript-eslint/no-unused-expressions": [2],
80+
"@typescript-eslint/no-unused-vars": [2],
81+
"@typescript-eslint/no-wrapper-object-types": [2],
82+
"@typescript-eslint/prefer-as-const": [2],
83+
"@typescript-eslint/prefer-namespace-keyword": [2],
84+
"@typescript-eslint/triple-slash-reference": [2],
6385
"sonarjs/anchor-precedence": [2],
6486
"sonarjs/argument-type": [2],
6587
"sonarjs/arguments-order": [2],
@@ -565,16 +587,10 @@
565587
"wrap-regex": [0],
566588
"yield-star-spacing": [0],
567589
"react/jsx-space-before-closing": [0],
568-
"@typescript-eslint/no-use-before-define": [0],
569-
"@typescript-eslint/no-inferrable-types": [0],
570-
"@typescript-eslint/no-unused-vars": [2],
571-
"@typescript-eslint/interface-name-prefix": [0],
572590
"@typescript-eslint/consistent-type-assertions": [
573591
2,
574592
{
575593
"assertionStyle": "angle-bracket"
576594
}
577-
],
578-
"@typescript-eslint/no-explicit-any": [0],
579-
"@typescript-eslint/explicit-function-return-type": [0]
595+
]
580596
}

0 commit comments

Comments
 (0)