eslint-plugin-lit 1.8.1 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -91,7 +91,7 @@ const rule = {
|
|
|
91
91
|
'ClassDeclaration:exit': classExit,
|
|
92
92
|
MethodDefinition: (node) => methodEnter(node),
|
|
93
93
|
'MethodDefinition:exit': methodExit,
|
|
94
|
-
'AssignmentExpression:has(
|
|
94
|
+
'AssignmentExpression:has(.left ThisExpression)': (node) => assignmentFound(node)
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
};
|
|
@@ -13,10 +13,12 @@ const rule = {
|
|
|
13
13
|
recommended: false,
|
|
14
14
|
url: 'https://github.com/43081j/eslint-plugin-lit/blob/master/docs/rules/prefer-nothing.md'
|
|
15
15
|
},
|
|
16
|
+
hasSuggestions: true,
|
|
16
17
|
schema: [],
|
|
17
18
|
messages: {
|
|
18
19
|
preferNothing: '`nothing` is preferred over empty templates when you want to render' +
|
|
19
|
-
' nothing'
|
|
20
|
+
' nothing',
|
|
21
|
+
useNothing: 'Replace empty template with `nothing` constant'
|
|
20
22
|
}
|
|
21
23
|
},
|
|
22
24
|
create(context) {
|
|
@@ -30,7 +32,15 @@ const rule = {
|
|
|
30
32
|
node.quasi.quasis[0].value.raw === '') {
|
|
31
33
|
context.report({
|
|
32
34
|
node,
|
|
33
|
-
messageId: 'preferNothing'
|
|
35
|
+
messageId: 'preferNothing',
|
|
36
|
+
suggest: [
|
|
37
|
+
{
|
|
38
|
+
messageId: 'useNothing',
|
|
39
|
+
fix: (fixer) => {
|
|
40
|
+
return fixer.replaceText(node, 'nothing');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
34
44
|
});
|
|
35
45
|
}
|
|
36
46
|
}
|
|
@@ -44,6 +44,11 @@ const rule = {
|
|
|
44
44
|
const expression = node.quasi.expressions[i];
|
|
45
45
|
const previousQuasi = node.quasi.quasis[i];
|
|
46
46
|
const nextQuasi = node.quasi.quasis[i + 1];
|
|
47
|
+
const isAttribute = /=["']?$/.test(previousQuasi.value.raw);
|
|
48
|
+
// don't care about non-attribute bindings
|
|
49
|
+
if (!isAttribute) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
47
52
|
const isQuoted = (previousQuasi.value.raw.endsWith('="') &&
|
|
48
53
|
nextQuasi.value.raw.startsWith('"')) ||
|
|
49
54
|
(previousQuasi.value.raw.endsWith("='") &&
|