Skip to content

Commit bb246c4

Browse files
committed
Update eslint config to new format
1 parent e69e679 commit bb246c4

6 files changed

Lines changed: 80 additions & 29 deletions

File tree

.eslintrc.cjs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const config = {
1+
export default {
22
printWidth: 110,
33
trailingComma: 'es5',
44
semi: false,
@@ -8,5 +8,3 @@ const config = {
88
quoteProps: 'consistent',
99
plugins: ['prettier-plugin-organize-imports'],
1010
}
11-
12-
module.exports = config

eslint.config.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { fixupConfigRules } from "@eslint/compat";
2+
import reactRefresh from "eslint-plugin-react-refresh";
3+
import globals from "globals";
4+
import tsParser from "@typescript-eslint/parser";
5+
import path from "node:path";
6+
import { fileURLToPath } from "node:url";
7+
import js from "@eslint/js";
8+
import { FlatCompat } from "@eslint/eslintrc";
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all
16+
});
17+
18+
export default [{
19+
files: ["**/*.ts", "**/*.tsx"],
20+
ignores: ["**/dist"],
21+
}, ...fixupConfigRules(compat.extends(
22+
"eslint:recommended",
23+
"plugin:@typescript-eslint/recommended",
24+
"plugin:react-hooks/recommended",
25+
)), {
26+
plugins: {
27+
"react-refresh": reactRefresh,
28+
},
29+
30+
languageOptions: {
31+
globals: {
32+
...globals.browser,
33+
},
34+
35+
parser: tsParser,
36+
},
37+
38+
rules: {
39+
"react-refresh/only-export-components": ["warn", {
40+
allowConstantExport: true,
41+
}],
42+
},
43+
}];

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
9-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
9+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview",
11-
"find-unused": "ts-unused-exports ./tsconfig.json --showLineNumber"
11+
"find-unused": "ts-unused-exports ./tsconfig.json --showLineNumber",
12+
"format": "prettier --write ./src"
1213
},
1314
"dependencies": {
1415
"prettier": "^3.5.1",
@@ -18,6 +19,7 @@
1819
"styled-components": "^6.1.15"
1920
},
2021
"devDependencies": {
22+
"@eslint/compat": "^1.2.6",
2123
"@types/react": "^19.0.8",
2224
"@types/react-dom": "^19.0.3",
2325
"@typescript-eslint/eslint-plugin": "^8.24.0",
@@ -26,6 +28,7 @@
2628
"eslint": "^9.20.1",
2729
"eslint-plugin-react-hooks": "^5.1.0",
2830
"eslint-plugin-react-refresh": "^0.4.19",
31+
"globals": "^15.15.0",
2932
"ts-unused-exports": "^11.0.1",
3033
"typescript": "^5.7.3",
3134
"vite": "^6.1.0"

pnpm-lock.yaml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom/client";
3-
import App from "./App.tsx";
4-
import "./index.css";
1+
import React from 'react'
2+
import ReactDOM from 'react-dom/client'
3+
import App from './App.tsx'
4+
import './index.css'
55

6-
ReactDOM.createRoot(document.getElementById("root")!).render(
6+
ReactDOM.createRoot(document.getElementById('root')!).render(
77
<React.StrictMode>
88
<App />
99
</React.StrictMode>
10-
);
10+
)

0 commit comments

Comments
 (0)