Skip to content

Commit 2c8b08a

Browse files
CopilotMishaKav
andcommitted
Migrate to ESLint 9 flat config format
Co-authored-by: MishaKav <289035+MishaKav@users.noreply.github.com>
1 parent 4cd6b94 commit 2c8b08a

2 files changed

Lines changed: 115 additions & 2 deletions

File tree

eslint.config.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
const eslint = require('@eslint/js')
2+
const tseslint = require('typescript-eslint')
3+
const jestPlugin = require('eslint-plugin-jest')
4+
const githubPlugin = require('eslint-plugin-github')
5+
const prettierPlugin = require('eslint-plugin-prettier')
6+
7+
module.exports = tseslint.config(
8+
// Ignore patterns
9+
{
10+
ignores: [
11+
'**/node_modules/**',
12+
'**/dist/**',
13+
'**/coverage/**',
14+
'**/*.json'
15+
]
16+
},
17+
18+
// Base ESLint recommended rules
19+
eslint.configs.recommended,
20+
21+
// TypeScript recommended configurations
22+
...tseslint.configs.recommended,
23+
24+
// TypeScript type-checked rules
25+
...tseslint.configs.recommendedTypeChecked,
26+
27+
// TypeScript files configuration
28+
{
29+
files: ['**/*.ts'],
30+
languageOptions: {
31+
parserOptions: {
32+
projectService: true,
33+
tsconfigRootDir: __dirname
34+
}
35+
},
36+
plugins: {
37+
jest: jestPlugin,
38+
github: githubPlugin,
39+
prettier: prettierPlugin
40+
},
41+
rules: {
42+
// ESLint core rules
43+
'camelcase': 'off',
44+
'no-console': 'off',
45+
'no-unused-vars': 'off',
46+
'semi': ['error', 'never'],
47+
'func-call-spacing': ['error', 'never'],
48+
49+
// Prettier integration
50+
'prettier/prettier': 'error',
51+
52+
// TypeScript custom rules
53+
'@typescript-eslint/array-type': 'error',
54+
'@typescript-eslint/await-thenable': 'error',
55+
'@typescript-eslint/ban-ts-comment': 'error',
56+
'@typescript-eslint/consistent-type-assertions': 'error',
57+
'@typescript-eslint/explicit-member-accessibility': [
58+
'error',
59+
{ accessibility: 'no-public' }
60+
],
61+
'@typescript-eslint/explicit-function-return-type': [
62+
'error',
63+
{ allowExpressions: true }
64+
],
65+
'@typescript-eslint/no-array-constructor': 'error',
66+
'@typescript-eslint/no-empty-interface': 'error',
67+
'@typescript-eslint/no-explicit-any': 'error',
68+
'@typescript-eslint/no-extraneous-class': 'error',
69+
'@typescript-eslint/no-for-in-array': 'error',
70+
'@typescript-eslint/no-inferrable-types': 'error',
71+
'@typescript-eslint/no-misused-new': 'error',
72+
'@typescript-eslint/no-namespace': 'error',
73+
'@typescript-eslint/no-non-null-assertion': 'warn',
74+
'@typescript-eslint/no-require-imports': 'error',
75+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
76+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
77+
'@typescript-eslint/no-unused-vars': 'error',
78+
'@typescript-eslint/no-useless-constructor': 'error',
79+
'@typescript-eslint/no-var-requires': 'error',
80+
'@typescript-eslint/prefer-for-of': 'warn',
81+
'@typescript-eslint/prefer-function-type': 'warn',
82+
'@typescript-eslint/prefer-includes': 'error',
83+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
84+
'@typescript-eslint/promise-function-async': 'error',
85+
'@typescript-eslint/require-array-sort-compare': 'error',
86+
'@typescript-eslint/restrict-plus-operands': 'error',
87+
'@typescript-eslint/space-before-function-paren': 'off',
88+
'@typescript-eslint/unbound-method': 'error',
89+
90+
// GitHub plugin rules
91+
'eslint-comments/no-use': 'off',
92+
'eslint-comments/no-unused-disable': 'off',
93+
'i18n-text/no-en': 'off',
94+
'import/no-namespace': 'off',
95+
96+
// Jest plugin rules
97+
...jestPlugin.configs.recommended.rules
98+
}
99+
},
100+
101+
// JavaScript files configuration
102+
{
103+
files: ['**/*.js'],
104+
...tseslint.configs.disableTypeChecked,
105+
rules: {
106+
// Disable TypeScript-specific rules for JavaScript files
107+
'@typescript-eslint/explicit-function-return-type': 'off',
108+
'@typescript-eslint/no-explicit-any': 'off',
109+
'@typescript-eslint/explicit-member-accessibility': 'off'
110+
}
111+
}
112+
)

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"bundle": "npm run format:write && npm run package",
2929
"format:write": "prettier --write .",
3030
"format:check": "prettier --check .",
31-
"lint": "eslint . -c ./.github/linters/.eslintrc.yml",
31+
"lint": "eslint .",
3232
"package": "ncc build --minify src/index.ts -o dist --license licenses.txt",
3333
"test": "jest",
3434
"all": "npm run format:write && npm run lint && npm run test && npm run package",
@@ -56,7 +56,8 @@
5656
"prettier": "^3.6.2",
5757
"prettier-eslint": "^16.4.2",
5858
"ts-jest": "^29.4.5",
59-
"typescript": "^5.9.3"
59+
"typescript": "^5.9.3",
60+
"typescript-eslint": "^8.46.3"
6061
},
6162
"jest": {
6263
"preset": "ts-jest",

0 commit comments

Comments
 (0)