\ No newline at end of file
diff --git a/examples/eslint/order.html b/examples/eslint/order.html
index 187aa376b..57e95dec0 100644
--- a/examples/eslint/order.html
+++ b/examples/eslint/order.html
@@ -1,2 +1 @@
-
...
-
+
...
\ No newline at end of file
diff --git a/examples/eslint/unknow.html b/examples/eslint/unknow.html
index 2f385c147..92766668e 100644
--- a/examples/eslint/unknow.html
+++ b/examples/eslint/unknow.html
@@ -1 +1 @@
-
+
\ No newline at end of file
diff --git a/examples/eslint/validation.html b/examples/eslint/validation.html
index 6fae1ef72..7c9baa7b2 100644
--- a/examples/eslint/validation.html
+++ b/examples/eslint/validation.html
@@ -1 +1 @@
-
...
+
...
\ No newline at end of file
diff --git a/packages/eslint-plugin/src/utils/are-declarations-equal.ts b/packages/eslint-plugin/src/utils/are-declarations-equal.ts
index ce2b02e1a..04241a1a0 100644
--- a/packages/eslint-plugin/src/utils/are-declarations-equal.ts
+++ b/packages/eslint-plugin/src/utils/are-declarations-equal.ts
@@ -1,20 +1,23 @@
export default function areDeclarationsEqual(aDeclarations, bDeclarations) {
// 获取对象A和B的所有属性名
- const aKeys = Object.keys(aDeclarations);
- const bKeys = Object.keys(bDeclarations);
+ const aKeys = Object.keys(aDeclarations)
+ const bKeys = Object.keys(bDeclarations)
// 如果属性数量不相等,返回false
if (aKeys.length !== bKeys.length) {
- return false;
+ return false
}
// 检查对象A的属性是否都存在于对象B中
for (const key of aKeys) {
- if (!bDeclarations.hasOwnProperty(key)) {
- return false;
+ if (!Object.prototype.hasOwnProperty.call(bDeclarations, key)) {
+ return false
+ }
+ if (aDeclarations[key] !== bDeclarations[key]) {
+ return false
}
}
// 如果所有属性都匹配,返回true
- return true;
+ return true
}
\ No newline at end of file
diff --git a/packages/eslint-plugin/src/utils/ast.ts b/packages/eslint-plugin/src/utils/ast.ts
index 73ec10716..21d08173f 100644
--- a/packages/eslint-plugin/src/utils/ast.ts
+++ b/packages/eslint-plugin/src/utils/ast.ts
@@ -1,3 +1,6 @@
+/* eslint-disable no-case-declarations */
+import { Rule } from 'eslint'
+
const separatorRegEx = /([\t\n\f\r ]+)/
export function extractRangeFromNode(node) {
@@ -36,19 +39,19 @@ export function extractClassnamesFromValue(classStr) {
if (typeof classStr !== 'string') {
return { classNames: [], whitespaces: [], headSpace: false, tailSpace: false }
}
- let parts = classStr.split(separatorRegEx)
+ const parts = classStr.split(separatorRegEx)
if (parts[0] === '') {
parts.shift()
}
if (parts[parts.length - 1] === '') {
parts.pop()
}
- let headSpace = separatorRegEx.test(parts[0])
- let tailSpace = separatorRegEx.test(parts[parts.length - 1])
+ const headSpace = separatorRegEx.test(parts[0])
+ const tailSpace = separatorRegEx.test(parts[parts.length - 1])
const isClass = (_, i) => (headSpace ? i % 2 !== 0 : i % 2 === 0)
const isNotClass = (_, i) => (headSpace ? i % 2 === 0 : i % 2 !== 0)
- let classNames = parts.filter(isClass)
- let whitespaces = parts.filter(isNotClass)
+ const classNames = parts.filter(isClass)
+ const whitespaces = parts.filter(isNotClass)
return { classNames: classNames, whitespaces: whitespaces, headSpace: headSpace, tailSpace: tailSpace }
}
@@ -64,7 +67,7 @@ export function extractClassnamesFromValue(classStr) {
* @param {Array} ignoredKeys Optional, set object keys which should not be parsed e.g. for `cva`
* @returns {void}
*/
-export function parseNodeRecursive(rootNode, childNode, cb, skipConditional = false, isolate = false, ignoredKeys = [], context = null) {
+export function parseNodeRecursive(rootNode, childNode, cb, skipConditional = false, isolate = false, ignoredKeys = [], context: Rule.RuleContext = null) {
// TODO allow vue non litteral
let originalClassNamesValue
let classNames
@@ -161,7 +164,7 @@ export function parseNodeRecursive(rootNode, childNode, cb, skipConditional = fa
originalClassNamesValue = childNode.value.raw
start = childNode.range[0]
end = childNode.range[1]
- const txt = context?.getSourceCode()?.getText(childNode) ?? ''
+ const txt = context?.sourceCode.getText(childNode) ?? ''
prefix = getTemplateElementPrefix(txt, originalClassNamesValue)
suffix = getTemplateElementSuffix(txt, originalClassNamesValue)
break
@@ -195,7 +198,7 @@ export function getTemplateElementSuffix(text, raw) {
export function getTemplateElementBody(text, prefix, suffix) {
let arr = text.split(prefix)
arr.shift()
- let body = arr.join(prefix)
+ const body = arr.join(prefix)
arr = body.split(suffix)
arr.pop()
return arr.join(suffix)