🔧 chore(lint): use new eslint file format

This commit is contained in:
2024-12-04 16:49:42 +00:00
parent 06965a35a5
commit b84d177158
4 changed files with 67 additions and 22 deletions
-1
View File
@@ -1 +0,0 @@
/dist
-20
View File
@@ -1,20 +0,0 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"prettier",
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
"plugin:prettier/recommended"
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
+66
View File
@@ -0,0 +1,66 @@
import { fixupConfigRules } from '@eslint/compat'
import reactRefresh from 'eslint-plugin-react-refresh'
import globals from 'globals'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})
export default [
{
ignores: ['**/dist', '**/.eslintrc.cjs', 'eslint.config.mjs'],
},
...fixupConfigRules(
compat.extends(
'prettier',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended'
)
),
{
plugins: {
'react-refresh': reactRefresh,
},
languageOptions: {
globals: {
...globals.browser,
},
parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
project: ['./tsconfig.json', './tsconfig.base.json'],
tsconfigRootDir: __dirname,
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'react-refresh/only-export-components': [
'warn',
{
allowConstantExport: true,
},
],
},
},
]
+1 -1
View File
@@ -11,7 +11,7 @@
"build": "npm run build:dev", "build": "npm run build:dev",
"build:dev": "tsc && vite build", "build:dev": "tsc && vite build",
"build:prod": "tsc --project tsconfig.prod.json && vite build", "build:prod": "tsc --project tsconfig.prod.json && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"lint:fix": "npm run lint -- --fix", "lint:fix": "npm run lint -- --fix",
"preview": "vite preview", "preview": "vite preview",
"test": "vitest", "test": "vitest",