|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const tsRules = { |
| 4 | + '@typescript-eslint/no-deprecated': 'error', |
| 5 | + 'local-rules/no-inject-explicit-type': 'error', |
| 6 | + 'local-rules/no-filter-map': 'error', |
| 7 | + '@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'never' }], |
| 8 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 9 | + 'padding-line-between-statements': ['error', { blankLine: 'always', prev: '*', next: 'if' }], |
| 10 | + 'no-restricted-globals': [ |
| 11 | + 'error', |
| 12 | + { name: 'window', message: 'Используйте inject(DOCUMENT)/inject(WINDOW), а не глобальный window.' }, |
| 13 | + { name: 'document', message: 'Используйте inject(DOCUMENT), а не глобальный document.' }, |
| 14 | + ], |
| 15 | + 'no-restricted-syntax': [ |
| 16 | + 'error', |
| 17 | + { selector: 'MethodDefinition[accessibility="private"]', message: 'Используйте методы с # вместо private' }, |
| 18 | + { selector: 'PropertyDefinition[accessibility="private"]', message: 'Используйте поля с # вместо private' }, |
| 19 | + { |
| 20 | + selector: 'PropertyDefinition[value.callee.name=/^inject/][readonly!=true]', |
| 21 | + message: 'Зависимости из inject*(...) должны быть readonly.', |
| 22 | + }, |
| 23 | + { selector: 'TSAsExpression > TSUnknownKeyword', message: 'Использование "as unknown" запрещено. Найдите правильную типизацию.' }, |
| 24 | + ], |
| 25 | + '@angular-eslint/prefer-inject': ['error'], |
| 26 | + '@typescript-eslint/no-empty-function': ['error', { allow: ['methods'] }], |
| 27 | + 'dot-notation': 'off', |
| 28 | + '@typescript-eslint/dot-notation': ['error', { allowIndexSignaturePropertyAccess: true }], |
| 29 | + '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true, argsIgnorePattern: '^_' }], |
| 30 | + '@typescript-eslint/no-unused-expressions': 'off', |
| 31 | + 'import/no-duplicates': ['error', { considerQueryString: true }], |
| 32 | + '@typescript-eslint/no-explicit-any': ['error'], |
| 33 | + '@typescript-eslint/no-inferrable-types': ['error'], |
| 34 | + '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }], |
| 35 | + '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }], |
| 36 | + '@typescript-eslint/member-ordering': [ |
| 37 | + 'error', |
| 38 | + { |
| 39 | + default: { |
| 40 | + memberTypes: [ |
| 41 | + ['#private-readonly-field'], |
| 42 | + 'static-field', |
| 43 | + 'public-field', |
| 44 | + 'protected-field', |
| 45 | + 'private-static-field', |
| 46 | + 'private-field', |
| 47 | + '#private-field', |
| 48 | + 'abstract-field', |
| 49 | + 'constructor', |
| 50 | + 'public-method', |
| 51 | + 'protected-method', |
| 52 | + 'private-method', |
| 53 | + '#private-method', |
| 54 | + 'abstract-method', |
| 55 | + ], |
| 56 | + }, |
| 57 | + }, |
| 58 | + ], |
| 59 | + '@angular-eslint/use-lifecycle-interface': ['error'], |
| 60 | + 'no-console': ['error', { allow: ['info', 'time', 'timeEnd'] }], |
| 61 | + 'optimize-regex/optimize-regex': 'error', |
| 62 | + 'max-lines': ['error', { max: 500, skipBlankLines: true, skipComments: true }], |
| 63 | + 'max-lines-per-function': ['error', { max: 50, skipBlankLines: true, skipComments: true }], |
| 64 | + 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }], |
| 65 | + 'object-shorthand': 'error', |
| 66 | + '@angular-eslint/no-output-on-prefix': 'error', |
| 67 | + '@angular-eslint/no-output-rename': 'error', |
| 68 | + '@angular-eslint/use-pipe-transform-interface': 'error', |
| 69 | + curly: ['error'], |
| 70 | + '@angular-eslint/directive-selector': ['error', { type: 'attribute', prefix: 'app', style: 'camelCase' }], |
| 71 | + '@angular-eslint/component-selector': ['error', { type: 'element', prefix: 'app', style: 'kebab-case' }], |
| 72 | + '@angular-eslint/prefer-signals': 'error', |
| 73 | + '@angular-eslint/prefer-output-emitter-ref': 'error', |
| 74 | + '@typescript-eslint/prefer-includes': 'error', |
| 75 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 76 | + '@typescript-eslint/prefer-nullish-coalescing': 'error', |
| 77 | + '@typescript-eslint/sort-type-constituents': 'error', |
| 78 | + eqeqeq: ['error', 'always'], |
| 79 | + 'change-detection-strategy/on-push': 'error', |
| 80 | + '@eslint-community/eslint-comments/disable-enable-pair': 'error', |
| 81 | + '@eslint-community/eslint-comments/no-unlimited-disable': 'error', |
| 82 | + '@eslint-community/eslint-comments/no-duplicate-disable': 'error', |
| 83 | + '@eslint-community/eslint-comments/no-unused-disable': 'error', |
| 84 | + '@eslint-community/eslint-comments/require-description': ['error', { ignore: [] }], |
| 85 | +}; |
| 86 | + |
| 87 | +module.exports = { |
| 88 | + root: true, |
| 89 | + parser: '@typescript-eslint/parser', |
| 90 | + parserOptions: { |
| 91 | + project: ['./tsconfig.app.json', './tsconfig.spec.json'], |
| 92 | + tsconfigRootDir: __dirname, |
| 93 | + }, |
| 94 | + plugins: [ |
| 95 | + '@typescript-eslint', |
| 96 | + 'optimize-regex', |
| 97 | + '@angular-eslint', |
| 98 | + 'import', |
| 99 | + 'change-detection-strategy', |
| 100 | + 'local-rules', |
| 101 | + '@eslint-community/eslint-comments', |
| 102 | + ], |
| 103 | + overrides: [ |
| 104 | + { |
| 105 | + files: ['src/**/*.ts'], |
| 106 | + excludedFiles: ['**/*.spec.ts'], |
| 107 | + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], |
| 108 | + rules: tsRules, |
| 109 | + }, |
| 110 | + { |
| 111 | + files: ['src/**/spec-utils/**/*.ts'], |
| 112 | + excludedFiles: ['**/*.spec.ts'], |
| 113 | + rules: { |
| 114 | + '@typescript-eslint/consistent-type-assertions': ['warn', { assertionStyle: 'as' }], |
| 115 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 116 | + '@eslint-community/eslint-comments/require-description': 'off', |
| 117 | + 'max-lines-per-function': 'off', |
| 118 | + }, |
| 119 | + }, |
| 120 | + { |
| 121 | + files: ['src/**/*.spec.ts'], |
| 122 | + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], |
| 123 | + rules: { |
| 124 | + ...tsRules, |
| 125 | + '@typescript-eslint/consistent-type-assertions': ['warn', { assertionStyle: 'never' }], |
| 126 | + 'local-rules/no-provide-auto-spy-directive': 'error', |
| 127 | + 'local-rules/no-compile-components-for-standalone': 'error', |
| 128 | + 'max-lines-per-function': 'off', |
| 129 | + 'no-restricted-properties': [ |
| 130 | + 'error', |
| 131 | + { object: 'describe', property: 'skip', message: 'Do not commit skipped tests (describe.skip)' }, |
| 132 | + { object: 'it', property: 'skip', message: 'Do not commit skipped tests (it.skip)' }, |
| 133 | + { object: 'test', property: 'skip', message: 'Do not commit skipped tests (test.skip)' }, |
| 134 | + ], |
| 135 | + }, |
| 136 | + }, |
| 137 | + { |
| 138 | + files: ['*.html'], |
| 139 | + parser: '@angular-eslint/template-parser', |
| 140 | + plugins: ['@angular-eslint/eslint-plugin-template'], |
| 141 | + rules: { |
| 142 | + '@angular-eslint/template/no-duplicate-attributes': 'error', |
| 143 | + '@angular-eslint/template/alt-text': 'error', |
| 144 | + '@angular-eslint/template/banana-in-box': 'error', |
| 145 | + '@angular-eslint/template/eqeqeq': 'error', |
| 146 | + '@angular-eslint/template/i18n': ['error', { checkId: true, checkText: true, checkAttributes: false, checkDuplicateId: true }], |
| 147 | + '@angular-eslint/template/no-any': 'error', |
| 148 | + '@angular-eslint/template/no-negated-async': 'error', |
| 149 | + }, |
| 150 | + }, |
| 151 | + ], |
| 152 | +}; |
0 commit comments