Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Suggestion
Following up on#9523, I was looking through theeslint-plugin-unicorn
rules that we do not have turned on internally, and I found these rules that might be beneficial to enable. Thoughts?
better-regex (26 occurrences)
/([`$``])/g can be optimized to /([$```])/g.
eslint-plugin/src/rules/no-unnecessary-template-expression.ts:150
eslint-plugin/src/rules/no-useless-template-literals.ts:151
/(^|[^\`\`])"(?:``.|[^\`\`"\`r\`n])`"(?!`s`:)/ can be optimized to /(^|[^\`\`])"(?:``.|[^\`n\`r"\`\`])`"(?!`s`:)/.
website/src/prism/language/jsonc.js:11
/(^|[^\`\`])"(?:``.|[^\`\`"\`r\`n])`"(?=`s`:)/ can be optimized to /(^|[^\`\`])"(?:``.|[^\`n\`r"\`\`])`"(?=`s`:)/.
website/src/prism/language/jsonc.js:6
/[{}[`],]/ can be optimized to /[,[`]{}]/.
website/src/prism/language/jsonc.js:20
/[``/]`error`[``/]/ can be optimized to /[/``]`error`[/``]/.
ast-spec/tests/fixtures.test.ts:75
/[``^$.`+?()[`]{}|]/g can be optimized to /[$()`+.?[```]^{|}]/g.
eslint-plugin/src/util/escapeRegExp.ts:5
/`/`/.`|`/``[`s`S]`?(?:```/|$)/ can be optimized to /`/`/.`|`/``[`S`s]`?(?:```/|$)/.
website/src/prism/language/jsonc.js:16
/``(?!["])/gm can be optimized to /``(?!")/gm.
typescript-estree/tests/lib/parse.test.ts:60
/`$`{/g can be optimized to /`${/g.
eslint-plugin-internal/src/rules/plugin-test-formatting.ts:51
/`r`n|[`r`n`u2028`u2029]/ can be optimized to /`r`n|[`n`r`u2028`u2029]/.
utils/src/ast-utils/misc.ts:3
/&(?:#`d+|#x[`da-fA-F]+|[0-9a-zA-Z]+);/g can be optimized to /&(?:#`d+|#x[`dA-Fa-f]+|[`dA-Za-z]+);/g.
typescript-estree/src/node-utils.ts:450
/^([ ]`)/ can be optimized to /^( `)/.
eslint-plugin-internal/src/rules/plugin-test-formatting.ts:49
/^(`/?|)([`s`S]`?)((?:`.{1,2}|[^/]+?|)(`.[^./]`|))(?:[/]`)$/ can be optimized to /^(`/?|)([`S`s]`?)((?:`.{1,2}|[^/]+?|)(`.[^./]`|))`/`$/.
website-eslint/src/mock/path.js:55
/^"'['"]$/ can be optimized to /^"'["']$/.
scope-manager/tests/fixtures.test.ts:39
/^[(`w+:)``/]/ can be optimized to /^[`w()+/:``]/.
typescript-estree/src/create-program/describeFilePath.ts:18
/^[`([]/ can be optimized to /^[([`]/.
eslint-plugin/src/util/getWrappingFixer.ts:70
/^[=!]=/ can be optimized to /^[!=]=/.
eslint-plugin/src/rules/prefer-string-starts-ends-with.ts:16
/^[=?:]$/ can be optimized to /^[:=?]$/.
eslint-plugin/src/rules/space-infix-ops.ts:74
/^`/`/`/`/[ ]+@(`w+)[ ]`=[ ]`(.+)$/ can be optimized to /^`/{4} +@(`w+) `= `(.+)$/.
scope-manager/tests/fixtures.test.ts:38
/^`/`s`<reference`s`(types|path|lib)`s`=`s`"|'["|']/ can be optimized to /^`/`s`<reference`s`(types|path|lib)`s`=`s`"'|["'|]/.
eslint-plugin/src/rules/triple-slash-reference.ts:98
/^`s`(?:`/|``)``s`@ts-(?expect-error|ignore)(?.`)/ can be optimized to /^`s`[`/]``s`@ts-(?expect-er{2}or|ignore)(?.`)/.
eslint-plugin/src/rules/ban-ts-comment.ts:117
/^`s`(?:`/|``)``s`@ts-ignore/ can be optimized to /^`s`[`/]``s`@ts-ignore/.
eslint-plugin/src/rules/prefer-ts-expect-error.ts:28
/Cannot read file .+semanticInfo'/i can be optimized to /cannot read file .+semanticinfo'/i.
typescript-estree/tests/lib/semanticInfo.test.ts:286
/getParserServices(`(`s`[^,\`s)]+)`s`(,`s`false`s`)?`)/ can be optimized to /getParserServices(`(`s`[^\`s),]+)`s`(,`s`false`s`)?`)/.
eslint-plugin/tests/docs.test.ts:512
/import`s``{`s`TypeScriptWorker`s`}`s`from`s`['"].`/tsWorker['"];/ can be optimized to /import`s`{`s`TypeScriptWorker`s`}`s`from`s`["'].`/tsWorker["'];/.
website/tools/generate-website-dts.ts:75
catch-error-name (29 occurrences)
The catch parametere
should be namederror
.
ast-spec/tests/fixtures.test.ts:140
parser/tests/lib/tsx.test.ts:15
repo-tools/src/generate-lib.mts:310
rule-schema-to-typescript-types/src/index.ts:51
scope-manager/tests/fixtures.test.ts:146
scope-manager/tests/fixtures.test.ts:160
typescript-estree/src/semantic-or-syntactic-errors.ts:42
website-eslint/build.ts:166
website/src/components/ESQueryFilter.tsx:25
website/src/components/ast/ASTViewer.tsx:31
website/src/components/hooks/useHashState.ts:43
website/src/components/hooks/useHashState.ts:102
website/src/components/hooks/useHashState.ts:132
website/src/components/hooks/useHashState.ts:172
website/src/components/lib/json.ts:19
website/src/components/lib/parseConfig.ts:23
website/src/components/lib/parseConfig.ts:47
website/src/components/lib/parseConfig.ts:77
website/src/components/linter/createLinter.ts:82
website/src/components/linter/createLinter.ts:149
website/src/components/linter/createLinter.ts:161
website/src/components/typeDetails/TypeInfo.tsx:86
The catch parametererr
should be namederror
.
rule-tester/src/RuleTester.ts:622
rule-tester/src/utils/config-validator.ts:116
rule-tester/src/utils/config-validator.ts:197
website/plugins/generated-rule-docs/addESLintHashToCodeBlocksMeta.ts:57
website/src/components/editor/useSandboxServices.ts:137
The catch parameterex
should be namederror
.
eslint-plugin-internal/src/rules/plugin-test-formatting.ts:171
integration-tests/tools/integration-test-base.ts:155
custom-error-definition (4 occurrences)
Thename
property should be set toAssertionError
.
website-eslint/src/mock/assert.js:27
Thename
property should be set toNotSupportedError
.
rule-schema-to-typescript-types/src/errors.ts:2
Thename
property should be set toTSError
.
typescript-estree/src/node-utils.ts:702
Thename
property should be set toUnexpectedError
.
rule-schema-to-typescript-types/src/errors.ts:14
error-message (1 occurrence)
Pass a message to theError
constructor.
website-eslint/src/mock/assert.js:45
no-array-for-each (118 occurrences)
Usefor…of
instead of.forEach(…)
.
ast-spec/tests/fixtures.test.ts:336
eslint-plugin/src/rules/adjacent-overload-signatures.ts:135
eslint-plugin/src/rules/ban-ts-comment.ts:186
eslint-plugin/src/rules/ban-tslint-comment.ts:37
eslint-plugin/src/rules/class-literal-property-style.ts:99
eslint-plugin/src/rules/comma-spacing.ts:180
eslint-plugin/src/rules/consistent-generic-constructors.ts:123
eslint-plugin/src/rules/consistent-type-definitions.ts:104
eslint-plugin/src/rules/lines-around-comment.ts:41
eslint-plugin/src/rules/lines-around-comment.ts:438
eslint-plugin/src/rules/member-delimiter-style.ts:340
eslint-plugin/src/rules/member-ordering.ts:320
eslint-plugin/src/rules/member-ordering.ts:354
eslint-plugin/src/rules/member-ordering.ts:359
eslint-plugin/src/rules/member-ordering.ts:657
eslint-plugin/src/rules/member-ordering.ts:700
eslint-plugin/src/rules/member-ordering.ts:872
eslint-plugin/src/rules/member-ordering.ts:1001
eslint-plugin/src/rules/naming-convention-utils/parse-options.ts:21
eslint-plugin/src/rules/naming-convention-utils/parse-options.ts:24
eslint-plugin/src/rules/naming-convention.ts:289
eslint-plugin/src/rules/naming-convention.ts:370
eslint-plugin/src/rules/naming-convention.ts:377
eslint-plugin/src/rules/naming-convention.ts:405
eslint-plugin/src/rules/no-duplicate-enum-values.ts:43
eslint-plugin/src/rules/no-inferrable-types.ts:253
eslint-plugin/src/rules/no-mixed-enums.ts:62
eslint-plugin/src/rules/no-type-alias.ts:344
eslint-plugin/src/rules/no-unnecessary-parameter-property-assignment.ts:147
eslint-plugin/src/rules/no-unnecessary-template-expression.ts:125
eslint-plugin/src/rules/no-unnecessary-type-parameters.ts:293
eslint-plugin/src/rules/no-unnecessary-type-parameters.ts:298
eslint-plugin/src/rules/no-use-before-define.ts:328
eslint-plugin/src/rules/no-use-before-define.ts:376
eslint-plugin/src/rules/no-useless-template-literals.ts:126
eslint-plugin/src/rules/prefer-enum-initializers.ts:29
eslint-plugin/src/rules/prefer-function-type.ts:157
eslint-plugin/src/rules/prefer-promise-reject-errors.ts:140
eslint-plugin/src/rules/prefer-readonly.ts:452
eslint-plugin/src/rules/prefer-readonly.ts:456
eslint-plugin/src/rules/prefer-ts-expect-error.ts:54
eslint-plugin/src/rules/return-await.ts:378
eslint-plugin/src/rules/return-await.ts:389
eslint-plugin/src/rules/space-infix-ops.ts:135
eslint-plugin/src/rules/triple-slash-reference.ts:65
eslint-plugin/src/rules/triple-slash-reference.ts:102
eslint-plugin/src/rules/unbound-method.ts:191
eslint-plugin/src/util/collectUnusedVariables.ts:460
eslint-plugin/src/util/collectUnusedVariables.ts:483
eslint-plugin/src/util/collectUnusedVariables.ts:500
eslint-plugin/tests/configs.test.ts:98
eslint-plugin/tests/docs.test.ts:223
eslint-plugin/tests/rules/indent/indent.test.ts:611
eslint-plugin/tests/rules/naming-convention/cases/createTestCases.ts:276
eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts:39
eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts:55
eslint-plugin/tests/util.test.ts:23
eslint-plugin/tests/util.test.ts:33
parser/tests/lib/services.test.ts:36
rule-tester/src/RuleTester.ts:378
rule-tester/src/RuleTester.ts:437
rule-tester/src/RuleTester.ts:458
rule-tester/src/RuleTester.ts:847
rule-tester/src/RuleTester.ts:1001
rule-tester/src/RuleTester.ts:1008
rule-tester/src/utils/SourceCodeFixer.ts:83
rule-tester/src/utils/config-validator.ts:143
rule-tester/src/utils/config-validator.ts:169
rule-tester/src/utils/config-validator.ts:193
rule-tester/src/utils/freezeDeeply.ts:7
rule-tester/src/utils/validationHelpers.ts:117
rule-tester/src/utils/validationHelpers.ts:118
scope-manager/src/ScopeManager.ts:55
scope-manager/src/ScopeManager.ts:56
scope-manager/src/ScopeManager.ts:58
scope-manager/src/referencer/ClassVisitor.ts:52
scope-manager/src/referencer/ClassVisitor.ts:70
scope-manager/src/referencer/ClassVisitor.ts:209
scope-manager/src/referencer/ClassVisitor.ts:251
scope-manager/src/referencer/ClassVisitor.ts:265
scope-manager/src/referencer/ClassVisitor.ts:330
scope-manager/src/referencer/PatternVisitor.ts:59
scope-manager/src/referencer/PatternVisitor.ts:84
scope-manager/src/referencer/Referencer.ts:74
scope-manager/src/referencer/Referencer.ts:270
scope-manager/src/referencer/TypeVisitor.ts:191
scope-manager/src/referencer/Visitor.ts:40
scope-manager/src/scope/ScopeBase.ts:364
scope-manager/src/scope/WithScope.ts:26
scope-manager/tests/eslint-scope/es6-default-parameters.test.ts:7
scope-manager/tests/eslint-scope/references.test.ts:450
scope-manager/tests/eslint-scope/references.test.ts:462
scope-manager/tests/eslint-scope/references.test.ts:484
scope-manager/tests/eslint-scope/references.test.ts:496
scope-manager/tests/eslint-scope/references.test.ts:520
scope-manager/tests/eslint-scope/references.test.ts:536
scope-manager/tests/fixtures.test.ts:174
typescript-eslint/tests/configs.test.ts:103
typescript-estree/src/convert.ts:553
typescript-estree/src/convert.ts:1047
typescript-estree/src/convert.ts:1083
typescript-estree/src/convert.ts:1647
typescript-estree/src/convert.ts:3206
typescript-estree/src/create-program/createProjectProgram.ts:65
typescript-estree/src/create-program/getWatchProgramsForProjects.ts:149
typescript-estree/src/create-program/getWatchProgramsForProjects.ts:410
typescript-estree/src/create-program/getWatchProgramsForProjects.ts:495
typescript-estree/src/node-utils.ts:679
typescript-estree/tests/lib/persistentParse.test.ts:32
typescript-estree/tests/lib/semanticInfo.test.ts:44
utils/src/eslint-utils/applyDefault.ts:25
website/src/components/editor/LoadedEditor.tsx:249
website/src/components/lib/createEventsBinder.ts:10
website/src/components/linter/bridge.ts:47
website/src/components/linter/bridge.ts:49
website/src/components/linter/createLinter.ts:67
website/src/components/linter/createLinter.ts:167
website/src/theme/prism-include-languages.js:10
no-array-method-this-argument (4 occurrences)
Do not use thethis
argument inArray#findIndex()
.
website/plugins/generated-rule-docs/insertions/insertWhenNotToUseIt.ts:18
Do not use thethis
argument inArray#forEach()
.
scope-manager/src/referencer/PatternVisitor.ts:59
scope-manager/src/referencer/TypeVisitor.ts:191
scope-manager/src/referencer/Visitor.ts:40
no-array-push-push (22 occurrences)
Do not callArray#push()
multiple times.
ast-spec/tests/util/serializers/Node.ts:64
ast-spec/tests/util/serializers/Node.ts:76
ast-spec/tests/util/serializers/Node.ts:77
ast-spec/tests/util/serializers/Node.ts:87
eslint-plugin/src/rules/consistent-type-definitions.ts:61
eslint-plugin/src/rules/consistent-type-definitions.ts:96
eslint-plugin/src/rules/member-ordering.ts:578
eslint-plugin/src/rules/member-ordering.ts:582
eslint-plugin/src/rules/member-ordering.ts:594
eslint-plugin/src/rules/member-ordering.ts:598
eslint-plugin/src/rules/prefer-optional-chain-utils/gatherLogicalOperands.ts:341
eslint-plugin/tests/rules/no-unsafe-assignment.test.ts:33
eslint-plugin/tests/rules/semi.test.ts:274
eslint-plugin/tests/rules/semi.test.ts:1092
repo-tools/src/generate-contributors.mts:129
repo-tools/src/generate-contributors.mts:130
repo-tools/src/generate-contributors.mts:131
repo-tools/src/generate-contributors.mts:132
repo-tools/src/generate-contributors.mts:133
repo-tools/src/generate-contributors.mts:134
repo-tools/src/generate-contributors.mts:137
repo-tools/src/generate-lib.mts:281
no-array-reduce (29 occurrences)
Array#reduce()
is not allowed
eslint-plugin/src/rules/member-ordering.ts:317
eslint-plugin/src/rules/naming-convention-utils/parse-options.ts:85
eslint-plugin/src/rules/no-duplicate-type-constituents.ts:112
eslint-plugin/src/rules/no-type-alias.ts:328
eslint-plugin/src/rules/semi.ts:60
eslint-plugin/tests/configs.test.ts:20
eslint-plugin/tests/rules/func-call-spacing.test.ts:330
eslint-plugin/tests/rules/indent/indent.test.ts:596
eslint-plugin/tests/rules/no-base-to-string.test.ts:49
eslint-plugin/tests/rules/no-explicit-any.test.ts:1200
eslint-plugin/tests/rules/no-inferrable-types.test.ts:14
eslint-plugin/tests/rules/no-unsafe-assignment.test.ts:18
eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts:37
eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts:53
eslint-plugin/tests/rules/semi.test.ts:269
eslint-plugin/tests/rules/semi.test.ts:1082
eslint-plugin/tests/rules/type-annotation-spacing.test.ts:6567
eslint-plugin/tests/rules/type-annotation-spacing.test.ts:6609
parser/src/parser.ts:45
repo-tools/src/generate-configs.mts:75
repo-tools/src/generate-configs.mts:278
repo-tools/src/generate-configs.mts:396
repo-tools/src/generate-sponsors.mts:121
repo-tools/src/generate-sponsors.mts:132
typescript-eslint/tests/configs.test.ts:23
typescript-estree/src/parseSettings/resolveProjectList.ts:60
utils/src/eslint-utils/deepMerge.ts:25
website/src/components/config/ConfigTypeScript.tsx:35
website/src/components/lib/jsonSchema.ts:179
no-console-spaces (1 occurrence)
Do not use trailing space betweenconsole.log
parameters.
repo-tools/src/apply-canary-version.mts:35
no-for-loop (21 occurrences)
Use afor-of
loop instead of thisfor
loop.
eslint-plugin/src/rules/no-unsafe-argument.ts:59
eslint-plugin/src/rules/prefer-includes.ts:82
eslint-plugin/src/rules/prefer-string-starts-ends-with.ts:139
eslint-plugin/tests/docs.test.ts:66
rule-schema-to-typescript-types/src/index.ts:33
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:536
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:543
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:642
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:656
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:814
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:950
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1099
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1127
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1140
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1169
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1183
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1212
scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts:1229
type-utils/src/isUnsafeAssignment.ts:98
typescript-estree/src/node-utils.ts:780
website/src/components/ast/selectedRange.ts:53
no-hex-escape (10 occurrences)
Use Unicode escapes instead of hexadecimal escapes.
repo-tools/src/generate-configs.mts:22
repo-tools/src/generate-configs.mts:22
repo-tools/src/generate-configs.mts:23
repo-tools/src/generate-configs.mts:23
repo-tools/src/generate-configs.mts:24
repo-tools/src/generate-configs.mts:24
repo-tools/src/generate-configs.mts:25
repo-tools/src/generate-configs.mts:25
repo-tools/src/generate-configs.mts:26
repo-tools/src/generate-configs.mts:26
no-lonely-if (24 occurrences)
Unexpectedif
as the only statement in aif
block withoutelse
.
eslint-plugin/src/rules/consistent-type-imports.ts:229
eslint-plugin/src/rules/consistent-type-imports.ts:559
eslint-plugin/src/rules/lines-around-comment.ts:403
eslint-plugin/src/rules/lines-around-comment.ts:407
eslint-plugin/src/rules/no-confusing-void-expression.ts:261
eslint-plugin/src/rules/no-confusing-void-expression.ts:273
eslint-plugin/src/rules/no-confusing-void-expression.ts:281
eslint-plugin/src/rules/no-confusing-void-expression.ts:291
eslint-plugin/src/rules/no-confusing-void-expression.ts:297
eslint-plugin/src/rules/no-confusing-void-expression.ts:300
eslint-plugin/src/rules/no-empty-interface.ts:62
eslint-plugin/src/rules/no-magic-numbers.ts:167
eslint-plugin/src/rules/no-misused-new.ts:102
eslint-plugin/src/rules/no-misused-promises.ts:513
eslint-plugin/src/rules/no-type-alias.ts:218
eslint-plugin/src/rules/no-unnecessary-parameter-property-assignment.ts:168
eslint-plugin/src/rules/prefer-optional-chain-utils/gatherLogicalOperands.ts:83
eslint-plugin/src/util/collectUnusedVariables.ts:284
eslint-plugin/src/util/getWrappingFixer.ts:64
rule-tester/src/utils/serialization.ts:34
typescript-estree/src/convert.ts:232
typescript-estree/src/convert.ts:3564
website/src/components/ast/selectedRange.ts:57
website/src/components/ast/tsUtils.ts:27
no-object-as-default-parameter (1 occurrence)
Do not use an object literal as default for parameteroptions
.
scope-manager/src/referencer/Visitor.ts:31
no-unused-properties (2 occurrences)
PropertyemitDecoratorMetadata
is defined but never used.
scope-manager/src/analyze.ts:75
Propertylib
is defined but never used.
scope-manager/src/analyze.ts:73
no-useless-spread (3 occurrences)
Spread an object literal in object literal is unnecessary.
eslint-plugin/src/rules/naming-convention-utils/schema.ts:149
eslint-plugin/src/rules/type-annotation-spacing.ts:49
eslint-plugin/src/rules/type-annotation-spacing.ts:54
no-useless-switch-case (6 occurrences)
Useless case in switch statement.
typescript-estree/src/convert.ts:651
typescript-estree/src/convert.ts:652
typescript-estree/src/node-utils.ts:591
typescript-estree/src/node-utils.ts:592
typescript-estree/src/node-utils.ts:593
typescript-estree/src/node-utils.ts:594
no-useless-undefined (17 occurrences)
Do not use uselessundefined
.
eslint-plugin/src/rules/no-restricted-imports.ts:101
eslint-plugin/src/rules/no-restricted-imports.ts:109
eslint-plugin/src/rules/no-restricted-imports.ts:136
parser/tests/test-utils/test-utils.ts:25
typescript-estree/src/create-program/createIsolatedProgram.ts:54
typescript-estree/src/simple-traverse.ts:91
typescript-estree/tests/lib/createProjectService.test.ts:26
typescript-estree/tests/lib/createProjectService.test.ts:35
typescript-estree/tests/lib/createProjectService.test.ts:60
typescript-estree/tests/lib/createProjectService.test.ts:78
typescript-estree/tests/lib/createProjectService.test.ts:92
typescript-estree/tests/lib/createProjectService.test.ts:105
typescript-estree/tests/lib/useProgramFromProjectService.test.ts:211
website/src/components/ESQueryFilter.tsx:24
website/src/components/ast/DataRenderer.tsx:68
website/src/components/ast/DataRenderer.tsx:200
website/src/components/typeDetails/TypeInfo.tsx:71
number-literal-case (5 occurrences)
Invalid number literal casing.
eslint-plugin/tests/rules/no-magic-numbers.test.ts:146
eslint-plugin/tests/rules/no-magic-numbers.test.ts:150
eslint-plugin/tests/rules/no-magic-numbers.test.ts:807
eslint-plugin/tests/rules/no-magic-numbers.test.ts:821
typescript-estree/src/node-utils.ts:457
prefer-add-event-listener (1 occurrence)
PreferaddEventListener
overonload
.
website/src/components/editor/loadSandbox.ts:20