mirror of
https://github.com/lone-cloud/gerbil
synced 2026-06-03 09:33:10 -07:00
148 lines
3.6 KiB
TypeScript
148 lines
3.6 KiB
TypeScript
import js from '@eslint/js';
|
|
import globals from 'globals';
|
|
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
import tsParser from '@typescript-eslint/parser';
|
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
import react from 'eslint-plugin-react';
|
|
import importPlugin from 'eslint-plugin-import';
|
|
import sonarjs from 'eslint-plugin-sonarjs';
|
|
import noComments from 'eslint-plugin-no-comments';
|
|
|
|
const config = [
|
|
js.configs.recommended,
|
|
{
|
|
ignores: [
|
|
'dist',
|
|
'dist-electron',
|
|
'out',
|
|
'electron',
|
|
'scripts',
|
|
'release',
|
|
'build',
|
|
],
|
|
},
|
|
{
|
|
files: ['**/*.{js,mjs,cjs,ts,tsx}'],
|
|
languageOptions: {
|
|
ecmaVersion: 2020,
|
|
parser: tsParser,
|
|
parserOptions: {
|
|
ecmaVersion: 2020,
|
|
sourceType: 'module',
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
},
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
},
|
|
plugins: {
|
|
'@typescript-eslint': tseslint,
|
|
'react-hooks': reactHooks,
|
|
'react-refresh': reactRefresh,
|
|
react: react,
|
|
import: importPlugin,
|
|
sonarjs: sonarjs,
|
|
'no-comments': noComments,
|
|
},
|
|
settings: {
|
|
react: {
|
|
version: 'detect',
|
|
},
|
|
},
|
|
rules: {
|
|
...reactHooks.configs.recommended.rules,
|
|
...react.configs.recommended.rules,
|
|
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
ignoreRestSiblings: true,
|
|
},
|
|
],
|
|
'no-unused-vars': 'off',
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
|
|
'react-refresh/only-export-components': [
|
|
'warn',
|
|
{ allowConstantExport: true },
|
|
],
|
|
'react/function-component-definition': [
|
|
'error',
|
|
{
|
|
namedComponents: 'arrow-function',
|
|
unnamedComponents: 'arrow-function',
|
|
},
|
|
],
|
|
'react/react-in-jsx-scope': 'off',
|
|
'react/jsx-boolean-value': ['error', 'never'],
|
|
'react/jsx-curly-brace-presence': [
|
|
'error',
|
|
{ props: 'never', children: 'never' },
|
|
],
|
|
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
patterns: [
|
|
{
|
|
group: ['react'],
|
|
importNames: ['default'],
|
|
message:
|
|
'Import specific React hooks/utilities instead of default React import. Use automatic JSX transform.',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
|
|
'import/no-default-export': 'error',
|
|
'import/prefer-default-export': 'off',
|
|
|
|
'arrow-body-style': ['error', 'as-needed'],
|
|
'prefer-arrow-callback': ['error', { allowNamedFunctions: false }],
|
|
|
|
'no-console': 'error',
|
|
|
|
'@typescript-eslint/no-inferrable-types': 'warn',
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
|
|
'sonarjs/cognitive-complexity': ['warn', 25],
|
|
|
|
'no-comments/disallowComments': 'error',
|
|
},
|
|
},
|
|
{
|
|
files: ['**/*.d.ts'],
|
|
rules: {
|
|
'no-unused-vars': 'off',
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
'*.config.*',
|
|
'vite.config.*',
|
|
'eslint.config.*',
|
|
'postcss.config.*',
|
|
],
|
|
rules: {
|
|
'import/no-default-export': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['**/*.d.ts'],
|
|
rules: {
|
|
'no-comments/disallowComments': 'off',
|
|
'import/no-default-export': 'off',
|
|
},
|
|
},
|
|
];
|
|
|
|
export default config;
|