mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-08-26 03:10:51 +08:00
140 lines
4.1 KiB
JavaScript
140 lines
4.1 KiB
JavaScript
module.exports = {
|
|
// https://eslint.org/docs/latest/use/configure/configuration-files
|
|
env: {
|
|
browser: true,
|
|
es6: true,
|
|
node: true,
|
|
},
|
|
extends: [
|
|
'eslint:recommended',
|
|
'plugin:@typescript-eslint/recommended',
|
|
'plugin:import/recommended',
|
|
'plugin:import/typescript'
|
|
],
|
|
parser: '@typescript-eslint/parser',
|
|
parserOptions: {
|
|
project: 'tsconfig.json',
|
|
sourceType: 'module',
|
|
tsconfigRootDir: __dirname,
|
|
extraFileExtensions: ['.json'],
|
|
},
|
|
plugins: ['@typescript-eslint', 'react-hooks', 'import', 'unused-imports'],
|
|
settings: {
|
|
'import/resolver': {
|
|
typescript: {
|
|
alwaysTryTypes: true,
|
|
project: 'tsconfig.json',
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
'react-hooks/rules-of-hooks': 'error',
|
|
'react-hooks/exhaustive-deps': 'error',
|
|
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
'@typescript-eslint/no-empty-function': 'error',
|
|
'@typescript-eslint/no-empty-interface': 'error',
|
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
'@typescript-eslint/await-thenable': 'error',
|
|
'@typescript-eslint/no-namespace': 'error',
|
|
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
'@typescript-eslint/no-redeclare': 'error',
|
|
'@typescript-eslint/prefer-for-of': 'error',
|
|
'@typescript-eslint/triple-slash-reference': 'error',
|
|
'@typescript-eslint/unified-signatures': 'error',
|
|
'no-shadow': 'off',
|
|
'@typescript-eslint/no-shadow': 'off',
|
|
'constructor-super': 'error',
|
|
eqeqeq: ['error', 'always'],
|
|
'no-cond-assign': 'error',
|
|
'no-duplicate-case': 'error',
|
|
// replaced by import/no-duplicates
|
|
'no-duplicate-imports': 'off',
|
|
'no-empty': [
|
|
'error',
|
|
{
|
|
allowEmptyCatch: true,
|
|
},
|
|
],
|
|
'no-invalid-this': 'error',
|
|
'no-new-wrappers': 'error',
|
|
'no-param-reassign': 'error',
|
|
'no-sequences': 'error',
|
|
'no-throw-literal': 'error',
|
|
'no-unsafe-finally': 'error',
|
|
'no-unused-labels': 'error',
|
|
'no-var': 'error',
|
|
'no-void': 'off',
|
|
'prefer-const': 'error',
|
|
'prefer-spread': 'off',
|
|
|
|
// 禁用标准的未使用变量规则,使用 unused-imports 插件的规则代替
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
|
|
'padding-line-between-statements': [
|
|
'error',
|
|
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
|
|
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
|
|
{ blankLine: 'always', prev: 'import', next: '*' },
|
|
{ blankLine: 'any', prev: 'import', next: 'import' },
|
|
{ blankLine: 'always', prev: 'block-like', next: '*' },
|
|
{ blankLine: 'always', prev: 'block', next: '*' },
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'import/no-named-as-default': 'off',
|
|
'import/no-named-as-default-member': 'off',
|
|
|
|
'import/no-unresolved': 'warn',
|
|
'import/named': 'warn',
|
|
'import/namespace': 'warn',
|
|
'import/default': 'warn',
|
|
'import/export': 'warn',
|
|
'import/no-unused-modules': 'warn',
|
|
'import/no-duplicates': 'warn',
|
|
|
|
// unused-imports should be error level so eslint can auto fix it
|
|
'unused-imports/no-unused-imports': 'error',
|
|
'unused-imports/no-unused-vars': [
|
|
'warn',
|
|
{
|
|
vars: 'all',
|
|
varsIgnorePattern: '^_',
|
|
args: 'after-used',
|
|
argsIgnorePattern: '^_'
|
|
}
|
|
],
|
|
|
|
// 导入顺序规则
|
|
'import/order': ['warn', {
|
|
'groups': [
|
|
'builtin',
|
|
'external',
|
|
'internal',
|
|
'parent',
|
|
'sibling',
|
|
'index',
|
|
'object',
|
|
'type'
|
|
],
|
|
'newlines-between': 'always',
|
|
'alphabetize': {
|
|
'order': 'asc',
|
|
'caseInsensitive': true
|
|
},
|
|
'pathGroups': [
|
|
{
|
|
'pattern': '@/**',
|
|
'group': 'internal',
|
|
'position': 'after'
|
|
},
|
|
{
|
|
'pattern': 'src/**',
|
|
'group': 'internal',
|
|
'position': 'after'
|
|
}
|
|
],
|
|
'pathGroupsExcludedImportTypes': ['builtin']
|
|
}]
|
|
},
|
|
ignorePatterns: ['src/**/*.test.ts', '**/__tests__/**/*.json', 'package.json', '__mocks__/*.ts'],
|
|
};
|