Skip to content

Commit 535b73a

Browse files
committed
chore: simplify node param
1 parent ba9bd9b commit 535b73a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

lib/rules/no-duplicate-class-names.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,15 @@ module.exports = {
7777
/** @param {RuleContext} context */
7878
create: (context) => {
7979
/**
80-
* @param {VAttribute | VLiteral | Literal | TemplateElement | null} node
80+
* @param {VLiteral | Literal | TemplateElement | null} node
8181
*/
8282
function reportDuplicateClasses(node) {
83-
const fixTarget = node
84-
if (!fixTarget || !fixTarget.value) return
83+
if (!node || !node.value) return
8584

8685
const classList =
87-
typeof fixTarget.value === 'object' && 'raw' in fixTarget.value
88-
? fixTarget.value.raw
89-
: fixTarget.value
86+
typeof node.value === 'object' && 'raw' in node.value
87+
? node.value.raw
88+
: node.value
9089

9190
if (typeof classList !== 'string') return
9291

@@ -116,12 +115,9 @@ module.exports = {
116115
fix: (fixer) => {
117116
const unique = [...seen].join(' ')
118117
const sourceCode = context.getSourceCode()
119-
const raw = sourceCode.text.slice(
120-
fixTarget.range[0],
121-
fixTarget.range[1]
122-
)
118+
const raw = sourceCode.text.slice(node.range[0], node.range[1])
123119
const quote = raw[0]
124-
return fixer.replaceText(fixTarget, `${quote}${unique}${quote}`)
120+
return fixer.replaceText(node, `${quote}${unique}${quote}`)
125121
}
126122
})
127123
}

0 commit comments

Comments
 (0)