123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- module.exports = {
- extends: ['eslint:recommended'],
- env: {
- browser: true,
- node: true,
- es6: true,
- },
- parserOptions: {
- ecmaVersion: 2022,
- sourceType: 'module',
- },
- rules: {
- // 错误级别规则
- 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
- 'no-debugger': 'warn',
- 'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
-
- // 代码风格规则
- 'arrow-body-style': ['error', 'as-needed'],
- 'prefer-const': 'error',
- 'no-var': 'error',
- 'eqeqeq': ['error', 'always', { null: 'ignore' }],
- 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],
- 'no-trailing-spaces': 'error',
-
- // 其他规则
- 'no-restricted-syntax': [
- 'error',
- {
- selector: 'ForInStatement',
- message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
- },
- ],
- },
- overrides: [
- {
- files: ['*.ts', '*.tsx'],
- parser: '@typescript-eslint/parser',
- extends: [
- 'plugin:@typescript-eslint/recommended',
- ],
- rules: {
- '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
- 'no-unused-vars': 'off',
- },
- },
- ],
- };
|