Skip to content

Commit 11b70c1

Browse files
[chore] update eslint & pass to flat config & sanitize config
1 parent 88b01e7 commit 11b70c1

File tree

5 files changed

+240
-2407
lines changed

5 files changed

+240
-2407
lines changed

openex-front/.eslintignore

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

openex-front/.eslintrc.cjs

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

openex-front/eslint.config.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import path from 'path';
2+
import { fileURLToPath } from 'url';
3+
import stylistic from '@stylistic/eslint-plugin';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import globals from 'globals';
6+
import js from '@eslint/js';
7+
// import tsParser from '@typescript-eslint/parser';
8+
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
9+
import customRules from 'eslint-plugin-custom-rules';
10+
11+
// import eslint-plugin-react-hooks & @typescript-eslint/eslint-plugin & customRules to not let tools report them as unused
12+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
13+
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
14+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
15+
import tsEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
16+
17+
import { FlatCompat } from '@eslint/eslintrc';
18+
19+
// mimic CommonJS variables -- not needed if using CommonJS
20+
const __filename = fileURLToPath(import.meta.url);
21+
const __dirname = path.dirname(__filename);
22+
23+
const compat = new FlatCompat({
24+
baseDirectory: __dirname,
25+
});
26+
27+
// TODO add eslint-plugin-import when https://github.com/import-js/eslint-plugin-import/issues/2556 is done
28+
29+
export default [
30+
// rules recommended by @eslint/js
31+
js.configs.recommended,
32+
33+
// rules recommended by eslint-plugin-react
34+
{
35+
...reactRecommended,
36+
settings: {
37+
react: {
38+
version: 'detect',
39+
},
40+
},
41+
},
42+
43+
// rules recommended by @stylistic/eslint-plugin
44+
stylistic.configs.customize({
45+
semi: true,
46+
}),
47+
48+
// rules recommended by @typescript-eslint/eslint-plugin
49+
...compat.extends('plugin:@typescript-eslint/recommended'),
50+
51+
// rules recommended by eslint-plugin-react-hooks
52+
...compat.extends('plugin:react-hooks/recommended'),
53+
54+
// eslint-plugin-custom-rules config
55+
{
56+
plugins: {
57+
'custom-rules': customRules,
58+
},
59+
rules: {
60+
'custom-rules/classes-rule': 1,
61+
},
62+
},
63+
64+
// other config
65+
{
66+
languageOptions: {
67+
globals: {
68+
...globals.browser,
69+
...globals.commonjs,
70+
...globals.es2020,
71+
process: true,
72+
},
73+
},
74+
plugins: {
75+
'react-refresh': reactRefresh,
76+
},
77+
rules: {
78+
// react-refresh rules
79+
'react-refresh/only-export-components': [
80+
'warn',
81+
{ allowConstantExport: true },
82+
],
83+
84+
// react rules
85+
'react/no-unused-prop-types': 0,
86+
'react/prop-types': 0,
87+
88+
// @typescript-eslint rules
89+
'@typescript-eslint/naming-convention': ['error', {
90+
selector: 'variable',
91+
format: ['camelCase', 'UPPER_CASE'],
92+
leadingUnderscore: 'allow',
93+
trailingUnderscore: 'allow',
94+
filter: {
95+
regex: '/([^_]*)/',
96+
match: true,
97+
},
98+
}],
99+
'@typescript-eslint/no-unused-vars': [
100+
'error',
101+
{
102+
argsIgnorePattern: '^_',
103+
varsIgnorePattern: '^_',
104+
caughtErrorsIgnorePattern: '^_',
105+
},
106+
],
107+
108+
// @stylistic rules
109+
'@stylistic/arrow-parens': 'off',
110+
'@stylistic/quote-props': ['error', 'as-needed'],
111+
'@stylistic/brace-style': ['error', '1tbs'],
112+
},
113+
},
114+
115+
// ignores patterns
116+
{
117+
ignores: ['src/static/ext', 'packages', 'builder/prod/build', 'builder/dev/build'],
118+
},
119+
];

openex-front/package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"@mui/lab": "5.0.0-alpha.155",
1515
"@mui/material": "5.14.20",
1616
"@mui/styles": "5.14.20",
17-
"@mui/utils": "5.14.20",
1817
"@mui/x-date-pickers": "6.18.3",
1918
"@redux-devtools/extension": "3.2.6",
2019
"@uiw/react-md-editor": "4.0.1",
@@ -64,7 +63,6 @@
6463
"zod": "3.22.4"
6564
},
6665
"devDependencies": {
67-
"@babel/plugin-transform-modules-commonjs": "7.23.3",
6866
"@eslint/eslintrc": "2.1.4",
6967
"@eslint/js": "8.55.0",
7068
"@stylistic/eslint-plugin": "1.5.0",
@@ -82,15 +80,12 @@
8280
"cross-env": "7.0.3",
8381
"esbuild": "0.19.8",
8482
"eslint": "8.54.0",
85-
"eslint-config-airbnb": "19.0.4",
86-
"eslint-config-airbnb-base": "15.0.0",
87-
"eslint-config-airbnb-typescript": "17.1.0",
88-
"eslint-config-prettier": "9.0.0",
89-
"eslint-config-react-app": "7.0.1",
83+
"eslint-import-resolver-typescript": "3.6.1",
9084
"eslint-plugin-custom-rules": "link:packages/eslint-plugin-custom-rules",
91-
"eslint-plugin-import": "2.28.1",
92-
"eslint-plugin-prettier": "5.0.1",
85+
"eslint-plugin-import": "2.29.0",
9386
"eslint-plugin-react": "7.33.2",
87+
"eslint-plugin-react-hooks": "4.6.0",
88+
"eslint-plugin-react-refresh": "0.4.5",
9489
"express": "4.18.2",
9590
"fs-extra": "11.2.0",
9691
"globals": "13.23.0",
@@ -107,7 +102,7 @@
107102
"start": "node builder/dev/dev.js",
108103
"dev": "vite",
109104
"build": "node builder/prod/prod.js",
110-
"lint": "cross-env DEBUG=eslint:cli-engine TIMING=1 eslint --max-warnings 0 --cache -c .eslintrc.cjs src",
105+
"lint": "cross-env DEBUG=eslint:cli-engine TIMING=1 eslint --max-warnings 0 --cache -c eslint.config.js src",
111106
"control": "yarn audit --groups dependencies --summary",
112107
"test": "vitest run",
113108
"check-ts": "tsc --noEmit",

0 commit comments

Comments
 (0)