Skip to content

Commit 1341745

Browse files
committed
chore: migrate to Flat Config
1 parent 667bce8 commit 1341745

File tree

4 files changed

+1280
-985
lines changed

4 files changed

+1280
-985
lines changed

.eslintrc

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

eslint.config.mjs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { fixupPluginRules } from '@eslint/compat';
2+
import reactPlugin from 'eslint-plugin-react';
3+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import testingLibraryPlugin from 'eslint-plugin-testing-library';
6+
import vitestPlugin from '@vitest/eslint-plugin';
7+
import globals from 'globals';
8+
import { config } from '@markuplint-dev/eslint-config';
9+
10+
/** @type {import('eslint').Linter.Config[]} */
11+
export default [
12+
...config,
13+
reactPlugin.configs.flat.recommended,
14+
testingLibraryPlugin.configs['flat/react'],
15+
{
16+
plugins: {
17+
'react-hooks': fixupPluginRules(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+
rules: {
29+
// https://github.com/facebook/react/issues/28313
30+
...reactHooksPlugin.configs.recommended.rules,
31+
'react/display-name': 0,
32+
'react/prop-types': 0,
33+
'react-refresh/only-export-components': 'warn',
34+
},
35+
},
36+
{
37+
files: ['*.{ts,tsx}'],
38+
languageOptions: {
39+
parserOptions: {
40+
// https://typescript-eslint.io/getting-started/typed-linting/
41+
projectService: true,
42+
tsconfigRootDir: import.meta.dirname,
43+
},
44+
},
45+
rules: {
46+
'@typescript-eslint/no-unused-vars': [2, { argsIgnorePattern: '^_', ignoreRestSiblings: true }],
47+
'@typescript-eslint/prefer-readonly-parameter-types': [
48+
1,
49+
{
50+
allow: [
51+
{ from: 'lib', name: 'URL' },
52+
{ from: 'package', package: 'json-schema', name: 'JSONSchema7' },
53+
{ from: 'package', package: 'json-schema', name: 'JSONSchema7Definition' },
54+
],
55+
checkParameterProperties: false,
56+
ignoreInferredTypes: true,
57+
},
58+
],
59+
},
60+
},
61+
{
62+
files: ['./*.js'],
63+
rules: {
64+
'@typescript-eslint/no-var-requires': 0,
65+
},
66+
},
67+
{
68+
files: ['./*.mjs'],
69+
rules: {
70+
'import/no-named-as-default-member': 0,
71+
},
72+
},
73+
{
74+
files: ['./**/*.tsx'],
75+
rules: {
76+
'unicorn/filename-case': 0,
77+
},
78+
},
79+
{
80+
files: ['./**/*.spec.ts', './**/*.spec.tsx'],
81+
rules: {
82+
'testing-library/prefer-user-event': 2,
83+
'testing-library/no-manual-cleanup': 0,
84+
},
85+
},
86+
{
87+
files: ['./vitest.config.ts'],
88+
rules: {
89+
'import/no-default-export': 0,
90+
},
91+
},
92+
];

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
"@commitlint/cli": "^19.4.0",
3737
"@commitlint/config-conventional": "^19.2.2",
3838
"@egoist/tailwindcss-icons": "1.8.1",
39+
"@eslint/compat": "^1.2.6",
40+
"@eslint/js": "^9.20.0",
3941
"@iconify-json/heroicons-solid": "1.1.12",
4042
"@iconify-json/majesticons": "1.1.12",
41-
"@markuplint-dev/eslint-config": "^1.0.1",
43+
"@markuplint-dev/eslint-config": "^1.0.11",
4244
"@markuplint-dev/prettier-config": "^1.0.1",
4345
"@markuplint/jsx-parser": "4.7.5",
4446
"@markuplint/react-spec": "4.5.5",
@@ -52,16 +54,16 @@
5254
"@types/react": "18.3.3",
5355
"@types/react-dom": "18.3.0",
5456
"@types/semver": "7.5.8",
55-
"@typescript-eslint/eslint-plugin": "7",
5657
"@vitejs/plugin-react": "4.3.1",
58+
"@vitest/eslint-plugin": "^1.1.26",
5759
"autoprefixer": "10.4.20",
5860
"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",
61+
"eslint": "^9.20.0",
62+
"eslint-plugin-react": "^7.37.4",
63+
"eslint-plugin-react-hooks": "^5.1.0",
64+
"eslint-plugin-react-refresh": "^0.4.18",
65+
"eslint-plugin-testing-library": "^7.1.1",
66+
"globals": "^15.14.0",
6567
"husky": "^9.1.5",
6668
"jsdom": "24.1.1",
6769
"lint-staged": "^15.2.9",

0 commit comments

Comments
 (0)