Skip to content

Commit 5802fa3

Browse files
authored
Merge pull request #482 from sir-gon/develop
[CONFIG] ESlint old .eslintrc migrated to eslint.config.mjs
2 parents 2bac8c2 + d351638 commit 5802fa3

File tree

7 files changed

+306
-116
lines changed

7 files changed

+306
-116
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 77 deletions
This file was deleted.

.github/workflows/eslint.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ jobs:
6060
- name: Run ESLint
6161
run: >
6262
npx eslint .
63-
--config .eslintrc
63+
--color
6464
--max-warnings=0
65-
--ext .js,.jsx,.ts,.tsx
6665
--format @microsoft/eslint-formatter-sarif
6766
--output-file eslint-results.sarif
6867
continue-on-error: true

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ COPY ./Makefile ${WORKDIR}/
4040
# code linting conf
4141
COPY ./.prettierrc ${WORKDIR}/
4242
COPY ./.prettierignore ${WORKDIR}/
43-
COPY ./.eslintrc ${WORKDIR}/
44-
COPY ./.eslintignore ${WORKDIR}/
43+
COPY ./eslint.config.mjs ${WORKDIR}/
44+
4545

4646
# markdownlint conf
4747
COPY ./.markdownlint.yaml ${WORKDIR}/

eslint.config.mjs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
2+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
3+
import _import from 'eslint-plugin-import';
4+
import jest from 'eslint-plugin-jest';
5+
import prettier from 'eslint-plugin-prettier';
6+
import tsParser from '@typescript-eslint/parser';
7+
import path from 'node:path';
8+
import { fileURLToPath } from 'node:url';
9+
import js from '@eslint/js';
10+
import { FlatCompat } from '@eslint/eslintrc';
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
const compat = new FlatCompat({
15+
baseDirectory: __dirname,
16+
recommendedConfig: js.configs.recommended,
17+
allConfig: js.configs.all
18+
});
19+
20+
export default [
21+
{
22+
ignores: ['**/coverage', '**/dist', '**/node_modules', '**/*.js']
23+
},
24+
...fixupConfigRules(
25+
compat.extends(
26+
'eslint:recommended',
27+
'plugin:@typescript-eslint/eslint-recommended',
28+
'plugin:@typescript-eslint/recommended',
29+
'plugin:@typescript-eslint/recommended-type-checked',
30+
'plugin:@typescript-eslint/stylistic-type-checked',
31+
'airbnb-base',
32+
'prettier',
33+
'plugin:import/recommended',
34+
'plugin:import/errors',
35+
'plugin:import/warnings',
36+
'plugin:jest/all'
37+
)
38+
),
39+
{
40+
plugins: {
41+
'@typescript-eslint': fixupPluginRules(typescriptEslint),
42+
import: fixupPluginRules(_import),
43+
jest: fixupPluginRules(jest),
44+
prettier
45+
},
46+
47+
languageOptions: {
48+
parser: tsParser,
49+
ecmaVersion: 5,
50+
sourceType: 'script',
51+
52+
parserOptions: {
53+
project: true
54+
}
55+
},
56+
57+
settings: {
58+
'import/parsers': {
59+
'@typescript-eslint/parser': ['.ts', '.tsx']
60+
},
61+
62+
'import/resolver': {
63+
typescript: {
64+
alwaysTryTypes: true,
65+
project: '.'
66+
}
67+
}
68+
},
69+
70+
rules: {
71+
'prettier/prettier': ['error'],
72+
73+
'import/extensions': [
74+
'error',
75+
'always',
76+
{
77+
pattern: {
78+
ts: 'never'
79+
}
80+
}
81+
],
82+
83+
'no-restricted-syntax': 0,
84+
'no-console': 'off',
85+
'no-underscore-dangle': 0,
86+
87+
'no-plusplus': [
88+
'error',
89+
{
90+
allowForLoopAfterthoughts: true
91+
}
92+
],
93+
94+
'no-shadow': 'off',
95+
'@typescript-eslint/no-shadow': 'error',
96+
'no-unused-vars': 'off',
97+
'@typescript-eslint/no-unused-vars': 'error',
98+
'no-use-before-define': 'off',
99+
'@typescript-eslint/no-use-before-define': 'error'
100+
}
101+
},
102+
{
103+
files: ['**/*.ts', '**/*.mts', '**/*.cts', '**/*.tsx'],
104+
105+
rules: {
106+
'@typescript-eslint/explicit-function-return-type': 'error'
107+
}
108+
},
109+
{
110+
ignores: ["dist/*", "coverage/*", "node_modules/*", "eslint.config.mjs"]
111+
}
112+
];

0 commit comments

Comments
 (0)