Skip to content

Commit 77924a7

Browse files
author
Gonzalo Diaz
committed
[CONFIG] ESlint old .eslintrc migrated to eslint.config.mjs flat configuration files
https://eslint.org/docs/latest/use/configure/migration-guide
1 parent f7416fa commit 77924a7

File tree

7 files changed

+333
-135
lines changed

7 files changed

+333
-135
lines changed

.eslintignore

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

.eslintrc

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

.github/workflows/eslint.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,20 @@ jobs:
5454
run: |
5555
npm install --include=dev [email protected]
5656
npm install --include=dev @microsoft/[email protected]
57+
5758
- name: Test ESLint
5859
run: |
5960
npx --yes eslint --env-info
61+
6062
- name: Run ESLint
6163
run: >
6264
npx eslint .
63-
--config .eslintrc
65+
--color
6466
--max-warnings=0
65-
--ext .js,.jsx,.ts,.tsx
6667
--format @microsoft/eslint-formatter-sarif
6768
--output-file eslint-results.sarif
6869
continue-on-error: true
70+
6971
- name: Upload analysis results to GitHub
7072
uses: github/codeql-action/upload-sarif@v3
7173
with:

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ COPY ./Makefile ${WORKDIR}/
3939
# code linting conf
4040
COPY ./.prettierrc ${WORKDIR}/
4141
COPY ./.prettierignore ${WORKDIR}/
42-
COPY ./.eslintrc ${WORKDIR}/
43-
COPY ./.eslintignore ${WORKDIR}/
42+
COPY ./eslint.config.js ${WORKDIR}/
4443
COPY ./.babelrc ${WORKDIR}/
4544

4645
# markdownlint conf

eslint.config.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
2+
import _import from 'eslint-plugin-import';
3+
import jest from 'eslint-plugin-jest';
4+
import prettier from 'eslint-plugin-prettier';
5+
import globals from 'globals';
6+
import babelParser from '@babel/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+
js.configs.recommended,
22+
{
23+
ignores: ['**/coverage', '**/dist', '**/node_modules', 'eslint.config.js']
24+
},
25+
...fixupConfigRules(
26+
compat.extends(
27+
'eslint:recommended',
28+
'airbnb-base',
29+
'prettier',
30+
// 'plugin:import/errors',
31+
// 'plugin:import/warnings',
32+
'plugin:jest/all'
33+
)
34+
),
35+
{
36+
plugins: {
37+
import: fixupPluginRules(_import),
38+
jest: fixupPluginRules(jest),
39+
prettier
40+
},
41+
42+
languageOptions: {
43+
globals: {
44+
...globals.node,
45+
...jest.environments.globals.globals
46+
},
47+
48+
parser: babelParser,
49+
ecmaVersion: 2022,
50+
sourceType: 'module',
51+
52+
parserOptions: {
53+
requireConfigFile: false,
54+
55+
babelOptions: {
56+
parserOpts: {
57+
plugins: ['importAssertions']
58+
}
59+
}
60+
}
61+
},
62+
63+
rules: {
64+
'prettier/prettier': ['error'],
65+
'no-restricted-syntax': 0,
66+
'no-console': 'off',
67+
'no-underscore-dangle': 0,
68+
69+
'no-plusplus': [
70+
'error',
71+
{
72+
allowForLoopAfterthoughts: true
73+
}
74+
],
75+
76+
'import/no-unresolved': [
77+
2,
78+
{
79+
commonjs: true,
80+
amd: true
81+
}
82+
],
83+
84+
'import/extensions': [
85+
'error',
86+
{
87+
js: 'always',
88+
json: 'always'
89+
}
90+
],
91+
92+
'import/no-extraneous-dependencies': [
93+
'error',
94+
{
95+
devDependencies: [
96+
'**/*.test.js',
97+
'**/*.bruteforce-test.js',
98+
'**/*.spec.js'
99+
]
100+
}
101+
]
102+
}
103+
}
104+
];

0 commit comments

Comments
 (0)