Skip to content

Commit 399abd5

Browse files
authored
Merge pull request #24 from kagankan/feature/eslint-flat-config
upgrade ESLint to v9 & migrate to Flat Config
2 parents 667bce8 + 3dd2b4b commit 399abd5

File tree

6 files changed

+1266
-987
lines changed

6 files changed

+1266
-987
lines changed

.eslintrc

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

eslint.config.mjs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import reactPlugin from 'eslint-plugin-react';
2+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
3+
import reactRefresh from 'eslint-plugin-react-refresh';
4+
import testingLibraryPlugin from 'eslint-plugin-testing-library';
5+
import vitestPlugin from '@vitest/eslint-plugin';
6+
import globals from 'globals';
7+
import { config } from '@markuplint-dev/eslint-config';
8+
9+
/** @type {import('eslint').Linter.Config[]} */
10+
export default [
11+
...config,
12+
reactPlugin.configs.flat.recommended,
13+
testingLibraryPlugin.configs['flat/react'],
14+
{
15+
// global settings
16+
plugins: {
17+
'react-hooks': reactHooksPlugin,
18+
'react-refresh': reactRefresh,
19+
vitest: vitestPlugin,
20+
},
21+
languageOptions: {
22+
globals: { ...globals.browser, React: true, JSX: true },
23+
parserOptions: {
24+
ecmaFeatures: { jsx: true },
25+
},
26+
},
27+
settings: { react: { version: 'detect' }, 'import/resolver': { typescript: [] } },
28+
},
29+
{
30+
// TypeScript
31+
files: ['**/*.{ts,tsx}'],
32+
languageOptions: {
33+
parserOptions: {
34+
// https://typescript-eslint.io/getting-started/typed-linting/
35+
projectService: true,
36+
tsconfigRootDir: import.meta.dirname,
37+
},
38+
},
39+
rules: {
40+
'@typescript-eslint/no-unused-vars': [2, { argsIgnorePattern: '^_', ignoreRestSiblings: true }],
41+
'@typescript-eslint/prefer-readonly-parameter-types': [
42+
1,
43+
{
44+
allow: [
45+
{ from: 'lib', name: 'URL' },
46+
{ from: 'package', package: 'json-schema', name: 'JSONSchema7' },
47+
{ from: 'package', package: 'json-schema', name: 'JSONSchema7Definition' },
48+
],
49+
checkParameterProperties: false,
50+
ignoreInferredTypes: true,
51+
},
52+
],
53+
},
54+
},
55+
{
56+
// React
57+
files: ['**/*.tsx'],
58+
rules: {
59+
// https://github.com/facebook/react/issues/28313
60+
...reactHooksPlugin.configs.recommended.rules,
61+
'react/display-name': 0,
62+
'react/prop-types': 0,
63+
'react-refresh/only-export-components': 'warn',
64+
'unicorn/filename-case': 0,
65+
},
66+
},
67+
{
68+
files: ['**/*.spec.ts', '**/*.spec.tsx'],
69+
rules: {
70+
'testing-library/prefer-user-event': 2,
71+
'testing-library/no-manual-cleanup': 0,
72+
},
73+
},
74+
{
75+
files: ['vitest.config.ts'],
76+
rules: {
77+
'import/no-default-export': 0,
78+
},
79+
},
80+
];

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite",
88
"build": "tsc && vite build",
99
"lint": "run-s lint:eslint lint:markuplint lint:prettier lint:cspell",
10-
"lint:eslint": "eslint src --ext ts,tsx",
10+
"lint:eslint": "eslint src",
1111
"lint:markuplint": "markuplint src/**/*.tsx",
1212
"lint:prettier": "prettier --check 'src/**/*.{js,ts,tsx}'",
1313
"lint:cspell": "cspell src/**/* --no-progress",
@@ -36,9 +36,10 @@
3636
"@commitlint/cli": "^19.4.0",
3737
"@commitlint/config-conventional": "^19.2.2",
3838
"@egoist/tailwindcss-icons": "1.8.1",
39+
"@eslint/js": "^9.20.0",
3940
"@iconify-json/heroicons-solid": "1.1.12",
4041
"@iconify-json/majesticons": "1.1.12",
41-
"@markuplint-dev/eslint-config": "^1.0.1",
42+
"@markuplint-dev/eslint-config": "^1.0.11",
4243
"@markuplint-dev/prettier-config": "^1.0.1",
4344
"@markuplint/jsx-parser": "4.7.5",
4445
"@markuplint/react-spec": "4.5.5",
@@ -52,16 +53,16 @@
5253
"@types/react": "18.3.3",
5354
"@types/react-dom": "18.3.0",
5455
"@types/semver": "7.5.8",
55-
"@typescript-eslint/eslint-plugin": "7",
5656
"@vitejs/plugin-react": "4.3.1",
57+
"@vitest/eslint-plugin": "^1.1.26",
5758
"autoprefixer": "10.4.20",
5859
"cspell": "8.13.3",
59-
"eslint": "8",
60-
"eslint-plugin-react": "7.35.0",
61-
"eslint-plugin-react-hooks": "4.6.2",
62-
"eslint-plugin-react-refresh": "0.4.9",
63-
"eslint-plugin-testing-library": "6.3.0",
64-
"eslint-plugin-vitest": "0.5.4",
60+
"eslint": "^9.20.0",
61+
"eslint-plugin-react": "^7.37.4",
62+
"eslint-plugin-react-hooks": "^5.1.0",
63+
"eslint-plugin-react-refresh": "^0.4.18",
64+
"eslint-plugin-testing-library": "^7.1.1",
65+
"globals": "^15.14.0",
6566
"husky": "^9.1.5",
6667
"jsdom": "24.1.1",
6768
"lint-staged": "^15.2.9",

src/components/ConsoleOutput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const ConsoleOutput = forwardRef<ConsoleOutputRef, Props>((_, ref) => {
1616

1717
useEffect(() => {
1818
if (wrapperRef.current) {
19+
// eslint-disable-next-line unicorn/prefer-global-this -- fix it later
1920
const elementStyle = window.getComputedStyle(wrapperRef.current);
2021
const terminal = new Terminal({
2122
theme: {

src/server/linter/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import path from 'node:path';
88
import { fileURLToPath } from 'node:url';
99

1010
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
// eslint-disable-next-line unicorn/text-encoding-identifier-case -- fix it later
1112
const content = fs.readFileSync(path.resolve(__dirname, './constants.json'), { encoding: 'utf-8' });
1213
const constants = JSON.parse(content);
1314

0 commit comments

Comments
 (0)