mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Refactor ESLint config
This commit is contained in:
@@ -1,92 +1,107 @@
|
|||||||
import { defineConfig, globalIgnores } from "eslint/config";
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
||||||
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
|
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
|
||||||
import react from "eslint-plugin-react";
|
import react from 'eslint-plugin-react';
|
||||||
import reactHooks from "eslint-plugin-react-hooks";
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
import typescriptEslint from '@typescript-eslint/eslint-plugin';
|
||||||
import tsParser from "@typescript-eslint/parser";
|
import tsParser from '@typescript-eslint/parser';
|
||||||
import path from "node:path";
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from 'node:url';
|
||||||
import js from "@eslint/js";
|
import js from '@eslint/js';
|
||||||
import { FlatCompat } from "@eslint/eslintrc";
|
import { FlatCompat } from '@eslint/eslintrc';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
const compat = new FlatCompat({
|
const compat = new FlatCompat({
|
||||||
baseDirectory: __dirname,
|
baseDirectory: __dirname,
|
||||||
recommendedConfig: js.configs.recommended,
|
recommendedConfig: js.configs.recommended,
|
||||||
allConfig: js.configs.all
|
allConfig: js.configs.all,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default defineConfig([globalIgnores([
|
export default defineConfig([
|
||||||
"**/node_modules",
|
globalIgnores([
|
||||||
"**/dist",
|
'**/node_modules',
|
||||||
"**/build",
|
'**/dist',
|
||||||
"**/coverage",
|
'**/build',
|
||||||
"**/public",
|
'**/coverage',
|
||||||
"**/*.js",
|
'**/public',
|
||||||
"**/vite.config.ts",
|
'**/*.js',
|
||||||
]), {
|
'**/vite.config.ts',
|
||||||
extends: fixupConfigRules(compat.extends(
|
'**/eslint.config.mjs',
|
||||||
"eslint:recommended",
|
]),
|
||||||
"plugin:react/recommended",
|
{
|
||||||
"plugin:react-hooks/recommended",
|
extends: fixupConfigRules(
|
||||||
"plugin:@typescript-eslint/recommended",
|
compat.extends(
|
||||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
'eslint:recommended',
|
||||||
)),
|
'plugin:react/recommended',
|
||||||
|
'plugin:react-hooks/recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended-requiring-type-checking'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
plugins: {
|
plugins: {
|
||||||
react: fixupPluginRules(react),
|
react: fixupPluginRules(react),
|
||||||
"react-hooks": fixupPluginRules(reactHooks),
|
'react-hooks': fixupPluginRules(reactHooks),
|
||||||
"@typescript-eslint": fixupPluginRules(typescriptEslint),
|
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
||||||
},
|
},
|
||||||
|
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
parser: tsParser,
|
parser: tsParser,
|
||||||
ecmaVersion: 2022,
|
ecmaVersion: 2022,
|
||||||
sourceType: "module",
|
sourceType: 'module',
|
||||||
|
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaFeatures: {
|
ecmaFeatures: {
|
||||||
jsx: true,
|
jsx: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
project: "./tsconfig.json",
|
project: './tsconfig.json',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
settings: {
|
settings: {
|
||||||
react: {
|
react: {
|
||||||
version: "detect",
|
version: 'detect',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
"no-console": ["warn", {
|
'no-console': [
|
||||||
allow: ["warn", "error", "debug"],
|
'warn',
|
||||||
}],
|
{
|
||||||
|
allow: ['warn', 'error', 'debug'],
|
||||||
"no-duplicate-imports": "error",
|
|
||||||
"no-unused-vars": "off",
|
|
||||||
"react/prop-types": "off",
|
|
||||||
"react/react-in-jsx-scope": "off",
|
|
||||||
"react-hooks/rules-of-hooks": "error",
|
|
||||||
"react-hooks/exhaustive-deps": "warn",
|
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
||||||
"@typescript-eslint/no-explicit-any": "warn",
|
|
||||||
|
|
||||||
"@typescript-eslint/no-unused-vars": ["warn", {
|
|
||||||
argsIgnorePattern: "^_",
|
|
||||||
varsIgnorePattern: "^_",
|
|
||||||
caughtErrorsIgnorePattern: "^_",
|
|
||||||
}],
|
|
||||||
|
|
||||||
"@typescript-eslint/consistent-type-imports": ["warn", {
|
|
||||||
prefer: "type-imports",
|
|
||||||
}],
|
|
||||||
|
|
||||||
"@typescript-eslint/no-misused-promises": "warn",
|
|
||||||
"@typescript-eslint/no-floating-promises": "warn",
|
|
||||||
"@typescript-eslint/unbound-method": "off",
|
|
||||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
||||||
},
|
},
|
||||||
}]);
|
],
|
||||||
|
|
||||||
|
'no-duplicate-imports': 'error',
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'react/prop-types': 'off',
|
||||||
|
'react/react-in-jsx-scope': 'off',
|
||||||
|
'react-hooks/rules-of-hooks': 'error',
|
||||||
|
'react-hooks/exhaustive-deps': 'warn',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'warn',
|
||||||
|
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
argsIgnorePattern: '^_',
|
||||||
|
varsIgnorePattern: '^_',
|
||||||
|
caughtErrorsIgnorePattern: '^_',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/consistent-type-imports': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
prefer: 'type-imports',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/no-misused-promises': 'warn',
|
||||||
|
'@typescript-eslint/no-floating-promises': 'warn',
|
||||||
|
'@typescript-eslint/unbound-method': 'off',
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user