Skip to content

Commit

Permalink
Refactor ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Oct 24, 2023
1 parent eb4f03b commit 258a6aa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/eslint-plugin/lib/rules/class-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,23 @@ module.exports = {

if (originalClassNamesValue !== validatedClassNamesValue) {
validatedClassNamesValue = prefix + validatedClassNamesValue + suffix

const sourceCode = context.getSourceCode()
const sourceCodeLines = sourceCode.lines
const nodeStartLine = node.loc.start.line
const nodeEndLine = node.loc.end.line
context.report({
loc: astUtil.findLoc(originalClassNamesValue, sourceCodeLines, nodeStartLine, nodeEndLine),
const foundLoc = astUtil.findLoc(originalClassNamesValue, sourceCodeLines, nodeStartLine, nodeEndLine)
const descriptor = {
messageId: 'invalidClassOrder',
fix: function (fixer) {
return fixer.replaceTextRange([start, end], validatedClassNamesValue)
},
})
}
}
if (foundLoc) {
descriptor.loc = foundLoc
} else {
descriptor.node = node
}
context.report(descriptor)
}
}
return defineVisitors({ context, options, settings, config }, visitNode)
Expand Down

0 comments on commit 258a6aa

Please sign in to comment.