Skip to content

Commit b925331

Browse files
authored
Remove useless spread and fallbacks (#249)
* Add `unicorn/no-useless-fallback-in-spread` * Apply fix * Enable `unicorn/no-useless-spread` * Apply fix
1 parent bb58633 commit b925331

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

eslint.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import typescriptEslint from "@typescript-eslint/eslint-plugin"
33
import eslintComments from "eslint-plugin-eslint-comments"
44
import node from "eslint-plugin-n"
55
import nodeDeps from "eslint-plugin-node-dependencies"
6+
import unicorn from "eslint-plugin-unicorn"
67
import tsParser from "@typescript-eslint/parser"
78
import jsonParser from "jsonc-eslint-parser"
89
import path from "node:path"
@@ -114,6 +115,7 @@ export default [
114115
"@typescript-eslint": typescriptEslint,
115116
"eslint-comments": eslintComments,
116117
node,
118+
unicorn,
117119
},
118120

119121
languageOptions: {
@@ -779,6 +781,9 @@ export default [
779781
],
780782
},
781783
],
784+
785+
"unicorn/no-useless-fallback-in-spread": ["error"],
786+
"unicorn/no-useless-spread": ["error"],
782787
},
783788
},
784789
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"eslint-plugin-n": "^17.15.1",
4848
"eslint-plugin-node-dependencies": "^0.12.0",
4949
"eslint-plugin-prettier": "^5.2.3",
50+
"eslint-plugin-unicorn": "^57.0.0",
5051
"fs-extra": "^10.0.0",
5152
"jsonc-eslint-parser": "^2.0.3",
5253
"mocha": "^9.1.3",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function parseForESLint(
5454
loc: true,
5555
range: true,
5656
tokens: true,
57-
...(parserOptions ?? {}),
57+
...parserOptions,
5858
}
5959

6060
let result: AST.ESLintExtendedProgram
@@ -69,7 +69,7 @@ export function parseForESLint(
6969
}
7070

7171
result.services = {
72-
...(result.services || {}),
72+
...result.services,
7373
...services.define(code, result.ast, document, locationCalculator, {
7474
parserOptions: options,
7575
}),

src/script/generic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
9595
typeDefScope: Scope,
9696
isRemoveTarget: (nodeOrToken: HasLocation) => boolean,
9797
) {
98-
for (const variable of [...typeDefScope.variables]) {
98+
for (const variable of typeDefScope.variables) {
9999
let def = variable.defs.find((d) =>
100100
isRemoveTarget(d.name as HasLocation),
101101
)
@@ -106,13 +106,13 @@ export function extractGeneric(element: VElement): GenericProcessInfo | null {
106106
)
107107
}
108108
}
109-
for (const reference of [...typeDefScope.references]) {
109+
for (const reference of typeDefScope.references) {
110110
if (isRemoveTarget(reference.identifier as HasLocation)) {
111111
removeReference(reference, typeDefScope)
112112
}
113113
}
114114

115-
for (const scope of [...scopeManager.scopes]) {
115+
for (const scope of scopeManager.scopes) {
116116
if (isRemoveTarget(scope.block as HasLocation)) {
117117
removeScope(scopeManager, scope)
118118
}

src/sfc/custom-block/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export function createCustomBlockSharedContext({
263263
{ ...parserOptions, ...options },
264264
)
265265
},
266-
...(parsedResult.services ?? {}),
266+
...parsedResult.services,
267267
...(parsedResult.error
268268
? { parseError: parsedResult.error }
269269
: {}),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy