Skip to content

Commit ee6da7e

Browse files
committed
Tweak rules to fix false positives in Angular code
1 parent 8737331 commit ee6da7e

File tree

12 files changed

+78
-36
lines changed

12 files changed

+78
-36
lines changed

β€Žangular.jsβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const {
33
TYPESCRIPT_FILE_PATTERNS,
44
HTML_FILE_PATTERNS,
55
} = require('./lib/patterns');
6+
const { NAMING_CONVENTION_OPTIONS_ANGULAR } = require('./lib/rule-options');
67

78
/** @type {import('eslint').ESLint.ConfigData} */
89
module.exports = {
@@ -35,10 +36,18 @@ module.exports = {
3536
'rxjs/no-async-subscribe': 'warn',
3637
'rxjs/no-create': 'warn',
3738
'rxjs/no-nested-subscribe': 'warn',
39+
'@typescript-eslint/naming-convention': [
40+
'warn',
41+
...NAMING_CONVENTION_OPTIONS_ANGULAR,
42+
],
3843

3944
// DISABLED RULES FROM EXTENDED CONFIGS
4045

46+
'@typescript-eslint/no-extraneous-class': 'off',
47+
'@typescript-eslint/no-floating-promises': 'off', // because of router.navigate
48+
'promise/catch-or-return': 'off',
4149
'unicorn/prefer-top-level-await': 'off',
50+
'unicorn/prefer-event-target': 'off',
4251

4352
// ADDITIONAL RULES
4453

β€Ždocs/angular-ngrx.mdβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Add to `extends` in your .eslintrc file:
1212
}
1313
```
1414

15-
## πŸ“ Rules (374)
15+
## πŸ“ Rules (369)
1616

17-
**344** rules are included from `@code-pushup/eslint-config/angular`. For brevity, only the **30** additional rules are listed in this document.
17+
**339** rules are included from `@code-pushup/eslint-config/angular`. For brevity, only the **30** additional rules are listed in this document.
1818

1919
Refer to the extended config's docs:
2020

21-
- [`@code-pushup/eslint-config/angular` rules](./angular.md#πŸ“-rules-344)
21+
- [`@code-pushup/eslint-config/angular` rules](./angular.md#πŸ“-rules-339)
2222

2323

2424
> πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>πŸ§ͺ🚫 Disabled for [test files](../README.md#πŸ§ͺ-test-overrides).<br>πŸ§ͺ⚠️ Severity lessened to warning for [test files](../README.md#πŸ§ͺ-test-overrides).

β€Ždocs/angular.mdβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Add to `extends` in your .eslintrc file:
1212
}
1313
```
1414

15-
## πŸ“ Rules (368)
15+
## πŸ“ Rules (367)
1616

17-
**292** rules are included from `@code-pushup/eslint-config/typescript`. For brevity, only the **76** additional rules are listed in this document.
17+
**291** rules are included from `@code-pushup/eslint-config/typescript`. For brevity, only the **76** additional rules are listed in this document.
1818

1919
Refer to the extended config's docs:
2020

21-
- [`@code-pushup/eslint-config/typescript` rules](./typescript.md#πŸ“-rules-292)
21+
- [`@code-pushup/eslint-config/typescript` rules](./typescript.md#πŸ“-rules-291)
2222

2323

2424
> πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>πŸ§ͺ🚫 Disabled for [test files](../README.md#πŸ§ͺ-test-overrides).<br>πŸ§ͺ⚠️ Severity lessened to warning for [test files](../README.md#πŸ§ͺ-test-overrides).

β€Ždocs/graphql.mdβ€Ž

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Add to `extends` in your .eslintrc file:
1212
}
1313
```
1414

15-
## πŸ“ Rules (297)
15+
## πŸ“ Rules (295)
1616

17-
**270** rules are included from `@code-pushup/eslint-config/node`. For brevity, only the **27** additional rules are listed in this document.
17+
**268** rules are included from `@code-pushup/eslint-config/node`. For brevity, only the **27** additional rules are listed in this document.
1818

1919
Refer to the extended config's docs:
2020

21-
- [`@code-pushup/eslint-config/node` rules](./node.md#πŸ“-rules-270)
21+
- [`@code-pushup/eslint-config/node` rules](./node.md#πŸ“-rules-268)
2222

2323

2424
> πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>πŸ§ͺ🚫 Disabled for [test files](../README.md#πŸ§ͺ-test-overrides).<br>πŸ§ͺ⚠️ Severity lessened to warning for [test files](../README.md#πŸ§ͺ-test-overrides).
@@ -48,10 +48,9 @@ Refer to the extended config's docs:
4848
| [![@graphql-eslint](./icons/material/graphql.png)](https://the-guild.dev/graphql/eslint/docs) | [unique-operation-types](https://the-guild.dev/graphql/eslint/rules/unique-operation-types)<br>A GraphQL document is only valid if it has only one type per operation.> This rule is a wrapper around a `graphql-js` validation function. | | | |
4949
| [![@graphql-eslint](./icons/material/graphql.png)](https://the-guild.dev/graphql/eslint/docs) | [unique-type-names](https://the-guild.dev/graphql/eslint/rules/unique-type-names)<br>A GraphQL document is only valid if all defined types have unique names.> This rule is a wrapper around a `graphql-js` validation function. | | | |
5050

51-
### ⚠️ Warnings (3)
51+
### ⚠️ Warnings (2)
5252

5353
| Plugin | Rule | Options | Autofix | Overrides |
5454
| :-: | :-- | :-- | :-: | :-: |
5555
| [![@graphql-eslint](./icons/material/graphql.png)](https://the-guild.dev/graphql/eslint/docs) | [description-style](https://the-guild.dev/graphql/eslint/rules/description-style)<br>Require all comments to follow the same style (either block or inline). | <details><summary>style: inline</summary><pre>{<br> "style": "inline"<br>}</pre></details> | πŸ’‘ | |
56-
| [![@graphql-eslint](./icons/material/graphql.png)](https://the-guild.dev/graphql/eslint/docs) | [no-hashtag-description](https://the-guild.dev/graphql/eslint/rules/no-hashtag-description)<br>Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.Allows to use hashtag for comments, as long as it's not attached to an AST definition. | | πŸ’‘ | |
57-
| [![@typescript-eslint](./icons/material/typescript.png)](https://typescript-eslint.io/) | [naming-convention](https://typescript-eslint.io/rules/naming-convention)<br>Enforce naming conventions for everything across a codebase | <details><summary>selector: variableLike, met...</summary><pre>[<br> {<br> "selector": [<br> "variableLike",<br> "method",<br> "typeProperty",<br> "parameterProperty",<br> "classProperty"<br> ],<br> "format": [<br> "camelCase"<br> ],<br> "filter": {<br> "regex": "^(_id\|__typename|__resolveType)$",<br> "match": false<br> }<br> },<br> {<br> "selector": "variable",<br> "format": [<br> "camelCase",<br> "UPPER_CASE"<br> ]<br> },<br> {<br> "selector": "typeLike",<br> "format": [<br> "PascalCase"<br> ]<br> },<br> {<br> "selector": "enumMember",<br> "format": [<br> "PascalCase"<br> ]<br> },<br> {<br> "selector": "parameter",<br> "modifiers": [<br> "unused"<br> ],<br> "format": null,<br> "custom": {<br> "regex": "^(_+|[a-z][a-zA-Z0-9]\*)$",<br> "match": true<br> }<br> },<br> {<br> "selector": "objectLiteralProperty",<br> "modifiers": [<br> "requiresQuotes"<br> ],<br> "format": null<br> },<br> {<br> "selector": [<br> "variable",<br> "parameter"<br> ],<br> "modifiers": [<br> "destructured"<br> ],<br> "format": null<br> }<br>]</pre></details> | | |
56+
| [![@graphql-eslint](./icons/material/graphql.png)](https://the-guild.dev/graphql/eslint/docs) | [no-hashtag-description](https://the-guild.dev/graphql/eslint/rules/no-hashtag-description)<br>Requires to use `"""` or `"` for adding a GraphQL description instead of `#`.Allows to use hashtag for comments, as long as it's not attached to an AST definition. | | πŸ’‘ | |

β€Ždocs/index.mdβ€Ž

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@ Add to `extends` in your .eslintrc file:
1212
}
1313
```
1414

15-
## πŸ“ Rules (254)
15+
## πŸ“ Rules (252)
1616

1717
> πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>πŸ§ͺ🚫 Disabled for [test files](../README.md#πŸ§ͺ-test-overrides).<br>πŸ§ͺ⚠️ Severity lessened to warning for [test files](../README.md#πŸ§ͺ-test-overrides).
1818
19-
### 🚨 Errors (117)
19+
### 🚨 Errors (116)
2020

2121
| Plugin | Rule | Options | Autofix | Overrides |
2222
| :-: | :-- | :-- | :-: | :-: |
2323
| | [eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq)<br>Require the use of `===` and `!==` | <details><summary>always, null: never</summary><pre>[<br> "always",<br> {<br> "null": "never"<br> }<br>]</pre></details> | πŸ”§ | |
2424
| | [for-direction](https://eslint.org/docs/latest/rules/for-direction)<br>Enforce "for" loop update clause moving the counter in the right direction | | | |
2525
| | [guard-for-in](https://eslint.org/docs/latest/rules/guard-for-in)<br>Require `for-in` loops to include an `if` statement | | | |
2626
| | [no-async-promise-executor](https://eslint.org/docs/latest/rules/no-async-promise-executor)<br>Disallow using an async function as a Promise executor | | | |
27-
| | [no-case-declarations](https://eslint.org/docs/latest/rules/no-case-declarations)<br>Disallow lexical declarations in case clauses | | | |
2827
| | [no-class-assign](https://eslint.org/docs/latest/rules/no-class-assign)<br>Disallow reassigning class members | | | |
2928
| | [no-compare-neg-zero](https://eslint.org/docs/latest/rules/no-compare-neg-zero)<br>Disallow comparing against -0 | | | |
3029
| | [no-cond-assign](https://eslint.org/docs/latest/rules/no-cond-assign)<br>Disallow assignment operators in conditional expressions | | | |
@@ -92,7 +91,7 @@ Add to `extends` in your .eslintrc file:
9291
| [![@typescript-eslint](./icons/material/typescript.png)](https://typescript-eslint.io/) | [no-var-requires](https://typescript-eslint.io/rules/no-var-requires)<br>Disallow `require` statements except in import statements | | | |
9392
| [![@typescript-eslint](./icons/material/typescript.png)](https://typescript-eslint.io/) | [prefer-as-const](https://typescript-eslint.io/rules/prefer-as-const)<br>Enforce the use of `as const` over literal type | | πŸ”§, πŸ’‘ | |
9493
| [![@typescript-eslint](./icons/material/typescript.png)](https://typescript-eslint.io/) | [triple-slash-reference](https://typescript-eslint.io/rules/triple-slash-reference)<br>Disallow certain triple slash directives in favor of ES6-style import declarations | | | |
95-
| [![functional](./icons/icons8/lambda.png)](https://github.com/eslint-functional/eslint-plugin-functional#readme) | [immutable-data](https://github.com/eslint-functional/eslint-plugin-functional/blob/v6.0.0/docs/rules/immutable-data.md)<br>Enforce treating data as immutable. | <details><summary>ignoreImmediateMutation: true</summary><pre>{<br> "ignoreImmediateMutation": true<br>}</pre></details> | | πŸ§ͺ⚠️ |
94+
| [![functional](./icons/icons8/lambda.png)](https://github.com/eslint-functional/eslint-plugin-functional#readme) | [immutable-data](https://github.com/eslint-functional/eslint-plugin-functional/blob/v6.0.0/docs/rules/immutable-data.md)<br>Enforce treating data as immutable. | <details><summary>ignoreImmediateMutation: tr...</summary><pre>{<br> "ignoreImmediateMutation": true,<br> "ignoreClasses": true<br>}</pre></details> | | πŸ§ͺ⚠️ |
9695
| [![import](./icons/icons8/import.png)](https://github.com/import-js/eslint-plugin-import#readme) | [default](https://github.com/import-js/eslint-plugin-import/blob/v2.29.0/docs/rules/default.md)<br>Ensure a default export is present, given a default import. | | | |
9796
| [![import](./icons/icons8/import.png)](https://github.com/import-js/eslint-plugin-import#readme) | [export](https://github.com/import-js/eslint-plugin-import/blob/v2.29.0/docs/rules/export.md)<br>Forbid any invalid exports, i.e. re-export of the same name. | | | |
9897
| [![import](./icons/icons8/import.png)](https://github.com/import-js/eslint-plugin-import#readme) | [named](https://github.com/import-js/eslint-plugin-import/blob/v2.29.0/docs/rules/named.md)<br>Ensure named imports correspond to a named export in the remote file. | | | |
@@ -138,7 +137,7 @@ Add to `extends` in your .eslintrc file:
138137
| [![sonarjs](./icons/other/sonar.png)](https://github.com/SonarSource/eslint-plugin-sonarjs#readme) | [prefer-single-boolean-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-single-boolean-return.md)<br>Return of boolean expressions should not be wrapped into an "if-then-else" statement | | πŸ’‘ | |
139138
| [![sonarjs](./icons/other/sonar.png)](https://github.com/SonarSource/eslint-plugin-sonarjs#readme) | [prefer-while](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-while.md)<br>A "while" loop should be used instead of a "for" loop | | πŸ”§ | |
140139

141-
### ⚠️ Warnings (137)
140+
### ⚠️ Warnings (136)
142141

143142
| Plugin | Rule | Options | Autofix | Overrides |
144143
| :-: | :-- | :-- | :-: | :-: |
@@ -152,7 +151,7 @@ Add to `extends` in your .eslintrc file:
152151
| | [no-bitwise](https://eslint.org/docs/latest/rules/no-bitwise)<br>Disallow bitwise operators | | | |
153152
| | [no-console](https://eslint.org/docs/latest/rules/no-console)<br>Disallow the use of `console` | <details><summary>allow: error, warn, info</summary><pre>{<br> "allow": [<br> "error",<br> "warn",<br> "info"<br> ]<br>}</pre></details> | | |
154153
| | [no-duplicate-imports](https://eslint.org/docs/latest/rules/no-duplicate-imports)<br>Disallow duplicate module imports | | | |
155-
| | [no-magic-numbers](https://eslint.org/docs/latest/rules/no-magic-numbers)<br>Disallow magic numbers | <details><summary>ignore: -1, 0, 1, 2, 7, 10,...</summary><pre>{<br> "ignore": [<br> -1,<br> 0,<br> 1,<br> 2,<br> 7,<br> 10,<br> 24,<br> 60,<br> 100,<br> 1000,<br> 3600<br> ],<br> "ignoreDefaultValues": true,<br> "enforceConst": true,<br> "detectObjects": true,<br> "ignoreArrayIndexes": false,<br> "ignoreClassFieldInitialValues": false<br>}</pre></details> | | πŸ§ͺ🚫 |
154+
| | [no-magic-numbers](https://eslint.org/docs/latest/rules/no-magic-numbers)<br>Disallow magic numbers | <details><summary>ignore: -1, 0, 1, 2, 7, 10,...</summary><pre>{<br> "ignore": [<br> -1,<br> 0,<br> 1,<br> 2,<br> 7,<br> 10,<br> 24,<br> 60,<br> 100,<br> 1000,<br> 3600<br> ],<br> "ignoreDefaultValues": true,<br> "ignoreClassFieldInitialValues": true,<br> "enforceConst": true,<br> "detectObjects": true,<br> "ignoreArrayIndexes": false<br>}</pre></details> | | πŸ§ͺ🚫 |
156155
| | [no-undef-init](https://eslint.org/docs/latest/rules/no-undef-init)<br>Disallow initializing variables to `undefined` | | πŸ”§ | |
157156
| | [prefer-template](https://eslint.org/docs/latest/rules/prefer-template)<br>Require template literals instead of string concatenation | | πŸ”§ | |
158157
| | [radix](https://eslint.org/docs/latest/rules/radix)<br>Enforce the consistent use of the radix argument when using `parseInt()` | | πŸ’‘ | |
@@ -188,7 +187,7 @@ Add to `extends` in your .eslintrc file:
188187
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [better-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/better-regex.md)<br>Improve regexes by making them shorter, consistent, and safer. | <details><summary>sortCharacterClasses: false</summary><pre>{<br> "sortCharacterClasses": false<br>}</pre></details> | πŸ”§ | |
189188
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [catch-error-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/catch-error-name.md)<br>Enforce a specific parameter name in catch clauses. | | πŸ”§ | |
190189
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [consistent-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/consistent-destructuring.md)<br>Use destructured variables over properties. | | πŸ”§, πŸ’‘ | |
191-
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [consistent-function-scoping](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/consistent-function-scoping.md)<br>Move function definitions to the highest possible scope. | | | πŸ§ͺ🚫 |
190+
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [consistent-function-scoping](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/consistent-function-scoping.md)<br>Move function definitions to the highest possible scope. | <details><summary>checkArrowFunctions: false</summary><pre>{<br> "checkArrowFunctions": false<br>}</pre></details> | | πŸ§ͺ🚫 |
192191
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [empty-brace-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/empty-brace-spaces.md)<br>Enforce no spaces between braces. | | πŸ”§ | |
193192
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [error-message](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/error-message.md)<br>Enforce passing a `message` value when creating a built-in error. | | | |
194193
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [escape-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/escape-case.md)<br>Require escape sequences to use uppercase values. | | πŸ”§ | |
@@ -264,7 +263,6 @@ Add to `extends` in your .eslintrc file:
264263
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-set-has](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-set-has.md)<br>Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. | | πŸ”§, πŸ’‘ | |
265264
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-set-size](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-set-size.md)<br>Prefer using `Set#size` instead of `Array#length`. | | πŸ”§ | |
266265
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-spread.md)<br>Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()` and `String#split('')`. | | πŸ”§, πŸ’‘ | |
267-
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-string-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-string-replace-all.md)<br>Prefer `String#replaceAll()` over regex searches with the global flag. | | πŸ”§ | |
268266
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-string-slice](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-string-slice.md)<br>Prefer `String#slice()` over `String#substr()` and `String#substring()`. | | πŸ”§ | |
269267
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-string-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-string-starts-ends-with.md)<br>Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`. | | πŸ”§, πŸ’‘ | |
270268
| [![unicorn](./icons/icons8/unicorn.png)](https://github.com/sindresorhus/eslint-plugin-unicorn#readme) | [prefer-string-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/prefer-string-trim-start-end.md)<br>Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`. | | πŸ”§ | |

0 commit comments

Comments
Β (0)