mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
115 lines
2.9 KiB
JavaScript
115 lines
2.9 KiB
JavaScript
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
|
|
import react from 'eslint-plugin-react';
|
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
import typescriptEslint from '@typescript-eslint/eslint-plugin';
|
|
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 defineConfig([
|
|
globalIgnores([
|
|
'**/node_modules',
|
|
'**/dist',
|
|
'**/build',
|
|
'**/coverage',
|
|
'**/public',
|
|
'**/*.js',
|
|
'**/vite.config.ts',
|
|
'**/eslint.config.mjs',
|
|
]),
|
|
{
|
|
extends: fixupConfigRules(
|
|
compat.extends(
|
|
'eslint:recommended',
|
|
'plugin:react/recommended',
|
|
'plugin:react-hooks/recommended',
|
|
'plugin:@typescript-eslint/recommended',
|
|
'plugin:@typescript-eslint/recommended-requiring-type-checking'
|
|
)
|
|
),
|
|
|
|
plugins: {
|
|
react: fixupPluginRules(react),
|
|
'react-hooks': fixupPluginRules(reactHooks),
|
|
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
|
},
|
|
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
|
|
project: './tsconfig.json',
|
|
},
|
|
},
|
|
|
|
settings: {
|
|
react: {
|
|
version: 'detect',
|
|
},
|
|
},
|
|
|
|
rules: {
|
|
'no-console': [
|
|
'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',
|
|
},
|
|
},
|
|
// Override configuration for test files
|
|
{
|
|
files: ['**/*.test.ts', '**/*.test.tsx'],
|
|
rules: {
|
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
},
|
|
},
|
|
]);
|