Skip to content

Commit 92ffe8e

Browse files
committed
feat: update typescript config
- switch to eslint flat config - migrate from old @typescript-eslint/* to the new typescript-eslint - migrate from old @angular-eslint/* to the new angular-eslint - bump minimum eslint version to 9.20 - add extensions to @typescript-eslint/no-unused-vars starting with _ - move from cmj to esm - add index.d.ts file
1 parent d75e165 commit 92ffe8e

File tree

3 files changed

+48
-41
lines changed

3 files changed

+48
-41
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ConfigArray } from "typescript-eslint";
2+
3+
declare const _default: ConfigArray;
4+
5+
export default _default;

eslint-config-typescript/index.js

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
module.exports = {
2-
root: true,
3-
overrides: [
1+
// @ts-check
2+
import pluginTs from "typescript-eslint";
3+
import pluginJs from "@eslint/js";
4+
import pluginJest from "eslint-plugin-jest";
5+
import pluginPrettier from "eslint-config-prettier";
6+
7+
export default pluginTs.config(
8+
// config to all javascript and typescript files
49
{
5-
files: ["*.ts"],
6-
parserOptions: {
7-
project: ["tsconfig.json"],
8-
createDefaultProgram: true,
9-
},
10-
extends: [
11-
"eslint:recommended",
12-
"plugin:@typescript-eslint/recommended",
13-
"plugin:@typescript-eslint/recommended-requiring-type-checking",
14-
"plugin:prettier/recommended",
15-
"prettier",
16-
],
10+
files: ["**/*.ts", "**/*.js"],
11+
extends: [pluginJs.configs.recommended, pluginPrettier],
12+
rules: {
13+
"no-duplicate-imports": "error",
14+
}
1715
},
1816
{
19-
files: ["*.spec.ts"],
20-
plugins: ["jest"],
17+
// config to all typescript files only
18+
files: ["**/*.ts"],
19+
extends: [pluginTs.configs.recommended, pluginTs.configs.stylistic],
20+
rules: {
21+
"@typescript-eslint/no-unused-vars": [
22+
"error",
23+
{
24+
argsIgnorePattern: '^_',
25+
caughtErrorsIgnorePattern: '^_',
26+
ignoreRestSiblings: true,
27+
},
28+
],
29+
}
30+
},
31+
{
32+
// config to test files only
33+
files: ['**/*.spec.ts'],
34+
...pluginJest.configs['flat/recommended'],
2135
rules: {
22-
// See also https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md
23-
"@typescript-eslint/unbound-method": "off",
24-
"jest/unbound-method": "error",
25-
},
36+
...pluginJest.configs['flat/recommended'].rules,
37+
}
2638
},
27-
],
28-
};
39+
);

eslint-config-typescript/package.json

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Repository which contains ESLint Configuration for projects that use TypeScript",
55
"main": "index.js",
66
"files": [
7-
"index.js"
7+
"index.js",
8+
"index.d.ts"
89
],
910
"scripts": {
1011
"build": "echo 'No build required'",
@@ -14,22 +15,12 @@
1415
"node": ">=18.0.0",
1516
"npm": ">=9.0.0"
1617
},
17-
"devDependencies": {
18-
"@typescript-eslint/eslint-plugin": "8.24.1",
19-
"@typescript-eslint/parser": "8.24.1",
20-
"eslint": "9.20.1",
21-
"eslint-config-prettier": "10.0.1",
22-
"eslint-plugin-jest": "28.11.0",
23-
"eslint-plugin-prettier": "5.2.3",
24-
"prettier": "3.5.1"
25-
},
2618
"peerDependencies": {
27-
"@typescript-eslint/eslint-plugin": ">=8.0.0",
28-
"@typescript-eslint/parser": ">=8.0.0",
29-
"eslint": ">=9.0.0",
30-
"eslint-config-prettier": ">=9.0.0",
31-
"eslint-plugin-jest": ">=25.2.2",
32-
"eslint-plugin-prettier": ">=4.2.1",
33-
"prettier": ">=2.4.1"
34-
}
19+
"eslint": "^9.20.0",
20+
"eslint-config-prettier": "^10.0.1",
21+
"eslint-plugin-jest": "^28.11.0",
22+
"@eslint/js": "^9.20.0",
23+
"typescript-eslint": "^8.24.0"
24+
},
25+
"type": "module"
3526
}

0 commit comments

Comments
 (0)