Skip to content

Commit 60e84ca

Browse files
committed
chore(no-unused-class-name): removed unneeded type assertions
1 parent 8c63f78 commit 60e84ca

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/rules/no-unused-class-name.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ import type {
99
SvelteSpreadAttribute,
1010
SvelteStyleDirective,
1111
} from "svelte-eslint-parser/lib/ast"
12-
import {
13-
default as selectorParser,
14-
type Node,
15-
type Root as SelectorRoot,
16-
} from "postcss-selector-parser"
17-
import type { AnyNode, AtRule, Root } from "postcss"
12+
import { default as selectorParser, type Node } from "postcss-selector-parser"
13+
import type { AnyNode } from "postcss"
1814

1915
export default createRule("no-unused-class-name", {
2016
meta: {
@@ -106,8 +102,8 @@ function findClassesInPostCSSNode(node: AnyNode): string[] {
106102
)
107103
return classes
108104
}
109-
if (["root", "atrule"].includes(node.type)) {
110-
return (node as Root | AtRule).nodes.flatMap(findClassesInPostCSSNode)
105+
if (node.type === "root" || node.type === "atrule") {
106+
return node.nodes.flatMap(findClassesInPostCSSNode)
111107
}
112108
return []
113109
}
@@ -119,8 +115,8 @@ function findClassesInSelector(node: Node): string[] {
119115
if (node.type === "class") {
120116
return [node.value]
121117
}
122-
if (["root", "selector"].includes(node.type)) {
123-
return (node as SelectorRoot).nodes.flatMap(findClassesInSelector)
118+
if (node.type === "root" || node.type === "selector") {
119+
return node.nodes.flatMap(findClassesInSelector)
124120
}
125121
return []
126122
}

0 commit comments

Comments
 (0)