ConceptPortal-public/rsconcept/frontend/eslint.config.js

125 lines
3.7 KiB
JavaScript
Raw Normal View History

2024-08-06 14:39:00 +03:00
import globals from 'globals';
import typescriptPlugin from 'typescript-eslint';
import typescriptParser from '@typescript-eslint/parser';
import reactPlugin from 'eslint-plugin-react';
import reactCompilerPlugin from 'eslint-plugin-react-compiler';
2024-10-23 16:21:08 +03:00
import reactHooksPlugin from 'eslint-plugin-react-hooks';
2025-02-12 21:36:25 +03:00
import importPlugin from 'eslint-plugin-import';
2024-08-06 14:39:00 +03:00
import simpleImportSort from 'eslint-plugin-simple-import-sort';
2025-03-03 12:44:29 +03:00
import playwright from 'eslint-plugin-playwright';
2024-08-06 14:39:00 +03:00
2025-03-14 20:44:23 +03:00
const basicRules = {
'no-console': 'off',
'require-jsdoc': 'off',
'@typescript-eslint/consistent-type-imports': [
'warn',
{
fixStyle: 'inline-type-imports'
}
],
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
],
'simple-import-sort/exports': 'error',
'import/no-duplicates': 'warn'
};
2024-08-06 14:39:00 +03:00
export default [
...typescriptPlugin.configs.recommendedTypeChecked,
...typescriptPlugin.configs.stylisticTypeChecked,
{
2025-03-02 19:42:19 +03:00
ignores: [
'**/parser.ts',
'**/node_modules/**',
'**/public/**',
'**/dist/**',
2025-03-03 12:44:29 +03:00
'vite.config.ts',
2025-03-02 19:42:19 +03:00
'eslint.config.js',
2025-03-03 12:44:29 +03:00
'playwright.config.ts'
2025-03-02 19:42:19 +03:00
]
2024-08-06 14:39:00 +03:00
},
{
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...globals.browser, ...globals.es2020, ...globals.jest },
2025-03-03 12:44:29 +03:00
project: ['./tsconfig.json', './tsconfig.vite.json', './tsconfig.playwright.json']
2024-08-06 14:39:00 +03:00
}
}
},
{
2025-03-03 12:44:29 +03:00
files: ['src/**/*.ts', 'src/**/*.tsx'],
2024-08-06 14:39:00 +03:00
plugins: {
'react': reactPlugin,
'react-compiler': reactCompilerPlugin,
2024-10-23 16:21:08 +03:00
'react-hooks': reactHooksPlugin,
2025-02-12 21:36:25 +03:00
'simple-import-sort': simpleImportSort,
'import': importPlugin
2024-08-06 14:39:00 +03:00
},
settings: { react: { version: 'detect' } },
rules: {
2025-03-14 20:44:23 +03:00
...basicRules,
'react-compiler/react-compiler': 'error',
2025-03-02 19:42:19 +03:00
'react-refresh/only-export-components': ['off', { allowConstantExport: true }],
2025-02-12 21:36:25 +03:00
'simple-import-sort/imports': [
'warn',
{
groups: [
// Node.js builtins.
[
'^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)'
],
// Packages. `react` related packages come first.
['^react', '^@?\\w'],
// Global app and features
['^(@/app|@/features)(/.*|$)'],
// Internal packages.
['^(@)(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports.
['^.+\\.s?css$']
]
}
],
2024-10-23 16:21:08 +03:00
...reactHooksPlugin.configs.recommended.rules
2024-08-06 14:39:00 +03:00
}
},
2025-03-03 12:44:29 +03:00
{
...playwright.configs['flat/recommended'],
files: ['tests/**/*.ts'],
plugins: {
'playwright': playwright,
'simple-import-sort': simpleImportSort,
'import': importPlugin
},
rules: {
2025-03-14 20:44:23 +03:00
...basicRules,
2025-03-03 12:44:29 +03:00
...playwright.configs['flat/recommended'].rules,
'simple-import-sort/imports': 'warn'
}
2024-08-06 14:39:00 +03:00
}
];