eslint-plugin-vue-scoped-css 1.2.0 → 2.0.0
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.
- package/README.md +5 -4
- package/dist/configs/all.js +1 -1
- package/dist/configs/recommended.js +1 -1
- package/dist/configs/vue3-recommended.js +1 -1
- package/dist/options.js +1 -1
- package/dist/rules/enforce-style-type.js +8 -5
- package/dist/rules/no-deprecated-deep-combinator.js +3 -3
- package/dist/rules/no-deprecated-v-enter-v-leave-class.js +12 -12
- package/dist/rules/no-parent-of-v-global.js +3 -3
- package/dist/rules/no-parsing-error.js +2 -2
- package/dist/rules/no-unused-keyframes.js +2 -2
- package/dist/rules/no-unused-selector.js +25 -22
- package/dist/rules/require-scoped.js +3 -2
- package/dist/rules/require-selector-used-inside.js +18 -17
- package/dist/rules/require-v-deep-argument.js +10 -10
- package/dist/rules/require-v-global-argument.js +3 -3
- package/dist/rules/require-v-slotted-argument.js +4 -4
- package/dist/styles/context/index.js +4 -4
- package/dist/styles/context/style/index.js +3 -3
- package/dist/styles/context/vue-components/find-vue.js +5 -5
- package/dist/styles/context/vue-components/index.js +1 -1
- package/dist/styles/parser/css-parser.js +2 -2
- package/dist/styles/parser/index.js +1 -1
- package/dist/styles/parser/selector/css-selector-parser.js +11 -10
- package/dist/styles/parser/selector/replace-utils.js +1 -1
- package/dist/styles/parser/selector/scss-selector-parser.js +3 -3
- package/dist/styles/parser/selector/stylus-selector-parser.js +3 -3
- package/dist/styles/selectors/index.js +1 -1
- package/dist/styles/selectors/query/attribute-tracker.js +4 -4
- package/dist/styles/selectors/query/elements.js +2 -2
- package/dist/styles/selectors/query/index.js +51 -51
- package/dist/styles/selectors/resolver/css-selector-resolver.js +22 -22
- package/dist/styles/selectors/resolver/scss-selector-resolver.js +5 -5
- package/dist/styles/selectors/resolver/stylus-selector-resolver.js +6 -6
- package/dist/styles/template/at-rule-params/index.js +1 -1
- package/dist/styles/template/at-rule-params/scss.js +1 -1
- package/dist/styles/template/at-rule-params/stylus.js +1 -1
- package/dist/styles/template/decl-value/index.js +1 -1
- package/dist/styles/template/decl-value/scss.js +1 -1
- package/dist/styles/template/decl-value/stylus.js +1 -1
- package/dist/styles/template/index.js +5 -5
- package/dist/styles/template/selector/index.js +1 -1
- package/dist/styles/template/selector/scss.js +1 -1
- package/dist/styles/template/selector/stylus.js +1 -1
- package/dist/styles/utils/css-nodes.js +1 -1
- package/dist/styles/utils/nodes.js +1 -3
- package/dist/styles/utils/selectors.js +1 -1
- package/dist/utils/regexp.js +1 -1
- package/package.json +26 -27
package/README.md
CHANGED
|
@@ -41,8 +41,8 @@ npm install --save-dev eslint eslint-plugin-vue-scoped-css
|
|
|
41
41
|
|
|
42
42
|
> **Requirements**
|
|
43
43
|
>
|
|
44
|
-
> - ESLint
|
|
45
|
-
> - Node.js
|
|
44
|
+
> - ESLint v6.0.0 and above
|
|
45
|
+
> - Node.js v12.22.x, v14.17.x, v16.x and above
|
|
46
46
|
|
|
47
47
|
<!--DOCS_IGNORE_END-->
|
|
48
48
|
|
|
@@ -99,6 +99,7 @@ Enforce all the rules in this category with:
|
|
|
99
99
|
|
|
100
100
|
| Rule ID | Description | |
|
|
101
101
|
|:--------|:------------|:---|
|
|
102
|
+
| [vue-scoped-css/enforce-style-type](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/enforce-style-type.html) | enforce the `<style>` tags to be plain or have the `scoped` or `module` attribute | |
|
|
102
103
|
| [vue-scoped-css/no-deprecated-deep-combinator](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-deprecated-deep-combinator.html) | disallow using deprecated deep combinators | :wrench: |
|
|
103
104
|
| [vue-scoped-css/no-parent-of-v-global](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-parent-of-v-global.html) | disallow parent selector for `::v-global` pseudo-element | |
|
|
104
105
|
| [vue-scoped-css/no-parsing-error](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-parsing-error.html) | disallow parsing errors in `<style>` | |
|
|
@@ -120,6 +121,7 @@ Enforce all the rules in this category with:
|
|
|
120
121
|
|
|
121
122
|
| Rule ID | Description | |
|
|
122
123
|
|:--------|:------------|:---|
|
|
124
|
+
| [vue-scoped-css/enforce-style-type](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/enforce-style-type.html) | enforce the `<style>` tags to be plain or have the `scoped` or `module` attribute | |
|
|
123
125
|
| [vue-scoped-css/no-parsing-error](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-parsing-error.html) | disallow parsing errors in `<style>` | |
|
|
124
126
|
| [vue-scoped-css/no-unused-keyframes](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-unused-keyframes.html) | disallow `@keyframes` which don't use in Scoped CSS | |
|
|
125
127
|
| [vue-scoped-css/no-unused-selector](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-unused-selector.html) | disallow selectors defined in Scoped CSS that don't use in `<template>` | |
|
|
@@ -134,14 +136,13 @@ For example:
|
|
|
134
136
|
```json
|
|
135
137
|
{
|
|
136
138
|
"rules": {
|
|
137
|
-
"vue-scoped-css/
|
|
139
|
+
"vue-scoped-css/no-deprecated-v-enter-v-leave-class": "error"
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
```
|
|
141
143
|
|
|
142
144
|
| Rule ID | Description | |
|
|
143
145
|
|:--------|:------------|:---|
|
|
144
|
-
| [vue-scoped-css/enforce-style-type](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/enforce-style-type.html) | enforce the `<style>` tags to be plain or have the `scoped` or `module` attribute | |
|
|
145
146
|
| [vue-scoped-css/no-deprecated-v-enter-v-leave-class](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/no-deprecated-v-enter-v-leave-class.html) | disallow v-enter and v-leave classes. | |
|
|
146
147
|
| [vue-scoped-css/require-selector-used-inside](https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/require-selector-used-inside.html) | disallow selectors defined that is not used inside `<template>` | |
|
|
147
148
|
|
package/dist/configs/all.js
CHANGED
package/dist/options.js
CHANGED
|
@@ -7,7 +7,7 @@ function parseQueryOptions(options) {
|
|
|
7
7
|
const { ignoreBEMModifier, captureClassesFromDoc } = options || {};
|
|
8
8
|
return {
|
|
9
9
|
ignoreBEMModifier: ignoreBEMModifier !== null && ignoreBEMModifier !== void 0 ? ignoreBEMModifier : false,
|
|
10
|
-
captureClassesFromDoc: (_a = captureClassesFromDoc === null || captureClassesFromDoc === void 0 ? void 0 : captureClassesFromDoc.map((s) => regexp_1.toRegExp(s, "g"))) !== null && _a !== void 0 ? _a : [],
|
|
10
|
+
captureClassesFromDoc: (_a = captureClassesFromDoc === null || captureClassesFromDoc === void 0 ? void 0 : captureClassesFromDoc.map((s) => (0, regexp_1.toRegExp)(s, "g"))) !== null && _a !== void 0 ? _a : [],
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
exports.parseQueryOptions = parseQueryOptions;
|
|
@@ -10,7 +10,7 @@ module.exports = {
|
|
|
10
10
|
meta: {
|
|
11
11
|
docs: {
|
|
12
12
|
description: "enforce the `<style>` tags to be plain or have the `scoped` or `module` attribute",
|
|
13
|
-
categories: [],
|
|
13
|
+
categories: ["recommended", "vue3-recommended"],
|
|
14
14
|
default: "warn",
|
|
15
15
|
url: "https://future-architect.github.io/eslint-plugin-vue-scoped-css/rules/enforce-style-type.html",
|
|
16
16
|
suggestion: true,
|
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
|
22
22
|
removeMultiple: "Remove attributes {{ attributes }}.",
|
|
23
23
|
change: "Change `{{ fromAttribute }}` to `{{ toAttribute }}` attribute.",
|
|
24
24
|
forbiddenStyle: "`{{ attribute }}` attribute is forbidden.",
|
|
25
|
-
forbiddenPlain: "Missing
|
|
25
|
+
forbiddenPlain: "Missing attribute {{ attributes }}.",
|
|
26
26
|
forbiddenScopedModule: "Cannot use both `scoped` and `module` attributes.",
|
|
27
27
|
},
|
|
28
28
|
schema: [
|
|
@@ -43,14 +43,15 @@ module.exports = {
|
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
45
|
type: "suggestion",
|
|
46
|
+
hasSuggestions: true,
|
|
46
47
|
},
|
|
47
48
|
create(context) {
|
|
48
49
|
var _a, _b, _c, _d;
|
|
49
|
-
const styles = context_1.getStyleContexts(context).filter(context_1.isValidStyleContext);
|
|
50
|
+
const styles = (0, context_1.getStyleContexts)(context).filter(context_1.isValidStyleContext);
|
|
50
51
|
if (!styles.length) {
|
|
51
52
|
return {};
|
|
52
53
|
}
|
|
53
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
54
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
54
55
|
const tokenStore = (_b = (_a = context.parserServices).getTemplateBodyTokenStore) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
55
56
|
const { options } = context;
|
|
56
57
|
const allows = (_d = (_c = options[0]) === null || _c === void 0 ? void 0 : _c.allows) !== null && _d !== void 0 ? _d : ["scoped"];
|
|
@@ -106,7 +107,9 @@ module.exports = {
|
|
|
106
107
|
node: node.startTag,
|
|
107
108
|
messageId: "forbiddenPlain",
|
|
108
109
|
data: {
|
|
109
|
-
|
|
110
|
+
attributes: allows
|
|
111
|
+
.map((allow) => `\`${allow}\``)
|
|
112
|
+
.join(" or "),
|
|
110
113
|
},
|
|
111
114
|
suggest: singleAllow
|
|
112
115
|
? [
|
|
@@ -18,13 +18,13 @@ module.exports = {
|
|
|
18
18
|
type: "suggestion",
|
|
19
19
|
},
|
|
20
20
|
create(context) {
|
|
21
|
-
const styles = context_1.getStyleContexts(context)
|
|
21
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
22
22
|
.filter(context_1.isValidStyleContext)
|
|
23
23
|
.filter((style) => style.scoped);
|
|
24
24
|
if (!styles.length) {
|
|
25
25
|
return {};
|
|
26
26
|
}
|
|
27
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
27
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
28
28
|
function report(node) {
|
|
29
29
|
reporter.report({
|
|
30
30
|
node,
|
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
|
51
51
|
function verify(style) {
|
|
52
52
|
style.traverseSelectorNodes({
|
|
53
53
|
enterNode(node) {
|
|
54
|
-
if (selectors_1.isDeepCombinator(node)) {
|
|
54
|
+
if ((0, selectors_1.isDeepCombinator)(node)) {
|
|
55
55
|
report(node);
|
|
56
56
|
}
|
|
57
57
|
},
|
|
@@ -23,10 +23,10 @@ module.exports = {
|
|
|
23
23
|
type: "suggestion",
|
|
24
24
|
},
|
|
25
25
|
create(context) {
|
|
26
|
-
const styles = context_1.getStyleContexts(context)
|
|
26
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
27
27
|
.filter(context_1.isValidStyleContext)
|
|
28
28
|
.filter((style) => style.scoped);
|
|
29
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
29
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
30
30
|
const deprecatedClassNames = new Map();
|
|
31
31
|
const renamedClassNames = new Map();
|
|
32
32
|
function report(node, messageId, kind) {
|
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
|
61
61
|
return !skipChild;
|
|
62
62
|
function verifyInternal(nodes) {
|
|
63
63
|
for (const node of nodes) {
|
|
64
|
-
if (selectors_1.isDeepCombinator(node) || selectors_1.isVueSpecialPseudo(node)) {
|
|
64
|
+
if ((0, selectors_1.isDeepCombinator)(node) || (0, selectors_1.isVueSpecialPseudo)(node)) {
|
|
65
65
|
skipChild = true;
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
@@ -88,7 +88,7 @@ module.exports = {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
function isIgnoreNode(node) {
|
|
91
|
-
return (css_nodes_1.isVCSSAtRule(node) &&
|
|
91
|
+
return ((0, css_nodes_1.isVCSSAtRule)(node) &&
|
|
92
92
|
node.name === "keyframes" &&
|
|
93
93
|
node.identifier === "@");
|
|
94
94
|
}
|
|
@@ -116,13 +116,13 @@ module.exports = {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
function verifyTransitionElementNode(node) {
|
|
119
|
-
const enterAttr = templates_1.findAttribute(node, "enter-class");
|
|
120
|
-
const enterFromAttr = templates_1.findAttribute(node, "enter-from-class");
|
|
119
|
+
const enterAttr = (0, templates_1.findAttribute)(node, "enter-class");
|
|
120
|
+
const enterFromAttr = (0, templates_1.findAttribute)(node, "enter-from-class");
|
|
121
121
|
if (enterAttr && !enterFromAttr) {
|
|
122
122
|
report(enterAttr.key, "deprecatedProps", "enter");
|
|
123
123
|
}
|
|
124
|
-
const leaveAttr = templates_1.findAttribute(node, "leave-class");
|
|
125
|
-
const leaveFromAttr = templates_1.findAttribute(node, "leave-from-class");
|
|
124
|
+
const leaveAttr = (0, templates_1.findAttribute)(node, "leave-class");
|
|
125
|
+
const leaveFromAttr = (0, templates_1.findAttribute)(node, "leave-from-class");
|
|
126
126
|
if (leaveAttr && !leaveFromAttr) {
|
|
127
127
|
report(leaveAttr.key, "deprecatedProps", "leave");
|
|
128
128
|
}
|
|
@@ -133,13 +133,13 @@ module.exports = {
|
|
|
133
133
|
}
|
|
134
134
|
return {
|
|
135
135
|
"Program:exit"() {
|
|
136
|
-
for (const transition of templates_1.getElements(context, (element) => templates_1.isTransitionElement(element) ||
|
|
137
|
-
templates_1.isTransitionGroupElement(element))) {
|
|
138
|
-
const { hasEnterClass, hasLeaveClass
|
|
136
|
+
for (const transition of (0, templates_1.getElements)(context, (element) => (0, templates_1.isTransitionElement)(element) ||
|
|
137
|
+
(0, templates_1.isTransitionGroupElement)(element))) {
|
|
138
|
+
const { hasEnterClass, hasLeaveClass } = verifyTransitionElementNode(transition);
|
|
139
139
|
if (hasEnterClass && hasLeaveClass) {
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
|
-
const nodes = attribute_tracker_1.getAttributeValueNodes(transition, "name", context);
|
|
142
|
+
const nodes = (0, attribute_tracker_1.getAttributeValueNodes)(transition, "name", context);
|
|
143
143
|
if (!nodes) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
@@ -18,13 +18,13 @@ module.exports = {
|
|
|
18
18
|
type: "suggestion",
|
|
19
19
|
},
|
|
20
20
|
create(context) {
|
|
21
|
-
const styles = context_1.getStyleContexts(context)
|
|
21
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
22
22
|
.filter(context_1.isValidStyleContext)
|
|
23
23
|
.filter((style) => style.scoped);
|
|
24
24
|
if (!styles.length) {
|
|
25
25
|
return {};
|
|
26
26
|
}
|
|
27
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
27
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
28
28
|
function report(node) {
|
|
29
29
|
reporter.report({
|
|
30
30
|
node,
|
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
function verify(style) {
|
|
36
36
|
style.traverseSelectorNodes({
|
|
37
37
|
enterNode(node) {
|
|
38
|
-
if (!selectors_1.isVGlobalPseudo(node)) {
|
|
38
|
+
if (!(0, selectors_1.isVGlobalPseudo)(node)) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
const nodes = node.parent.nodes;
|
|
@@ -15,11 +15,11 @@ module.exports = {
|
|
|
15
15
|
type: "problem",
|
|
16
16
|
},
|
|
17
17
|
create(context) {
|
|
18
|
-
const styles = context_1.getStyleContexts(context);
|
|
18
|
+
const styles = (0, context_1.getStyleContexts)(context);
|
|
19
19
|
if (!styles.length) {
|
|
20
20
|
return {};
|
|
21
21
|
}
|
|
22
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
22
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
23
23
|
function report(node) {
|
|
24
24
|
reporter.report({
|
|
25
25
|
node,
|
|
@@ -19,13 +19,13 @@ module.exports = {
|
|
|
19
19
|
type: "suggestion",
|
|
20
20
|
},
|
|
21
21
|
create(context) {
|
|
22
|
-
const styles = context_1.getStyleContexts(context)
|
|
22
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
23
23
|
.filter(style_1.isValidStyleContext)
|
|
24
24
|
.filter((style) => style.scoped);
|
|
25
25
|
if (!styles.length) {
|
|
26
26
|
return {};
|
|
27
27
|
}
|
|
28
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
28
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
29
29
|
const sourceCode = context.getSourceCode();
|
|
30
30
|
function report(node) {
|
|
31
31
|
const paramsStartIndex = node.range[0] +
|
|
@@ -9,26 +9,26 @@ const context_1 = require("../styles/context");
|
|
|
9
9
|
const utils_1 = require("../utils/utils");
|
|
10
10
|
const style_1 = require("../styles/context/style");
|
|
11
11
|
function getScopedSelectors(style) {
|
|
12
|
-
const resolvedSelectors = selectors_1.getResolvedSelectors(style);
|
|
12
|
+
const resolvedSelectors = (0, selectors_1.getResolvedSelectors)(style);
|
|
13
13
|
return resolvedSelectors.map(getScopedSelector).filter(utils_1.isDefined);
|
|
14
14
|
}
|
|
15
15
|
function getScopedSelector(resolvedSelector) {
|
|
16
16
|
const { selector } = resolvedSelector;
|
|
17
|
-
const specialNodeIndex = selector.findIndex((s) => selectors_2.isDeepCombinator(s) || selectors_2.isVueSpecialPseudo(s));
|
|
17
|
+
const specialNodeIndex = selector.findIndex((s) => (0, selectors_2.isDeepCombinator)(s) || (0, selectors_2.isVueSpecialPseudo)(s));
|
|
18
18
|
let scopedCandidateSelector;
|
|
19
19
|
if (specialNodeIndex >= 0) {
|
|
20
20
|
const specialNode = selector[specialNodeIndex];
|
|
21
|
-
if (selectors_2.isDeepCombinator(specialNode) || selectors_2.isVDeepPseudo(specialNode)) {
|
|
21
|
+
if ((0, selectors_2.isDeepCombinator)(specialNode) || (0, selectors_2.isVDeepPseudo)(specialNode)) {
|
|
22
22
|
scopedCandidateSelector = selector.slice(0, specialNodeIndex);
|
|
23
23
|
const last = scopedCandidateSelector.pop();
|
|
24
|
-
if (last && !selectors_2.isDescendantCombinator(last)) {
|
|
24
|
+
if (last && !(0, selectors_2.isDescendantCombinator)(last)) {
|
|
25
25
|
scopedCandidateSelector.push(last);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
else if (selectors_2.isVSlottedPseudo(specialNode)) {
|
|
28
|
+
else if ((0, selectors_2.isVSlottedPseudo)(specialNode)) {
|
|
29
29
|
scopedCandidateSelector = selector.slice(0, specialNodeIndex + 1);
|
|
30
30
|
}
|
|
31
|
-
else if (selectors_2.isVGlobalPseudo(specialNode)) {
|
|
31
|
+
else if ((0, selectors_2.isVGlobalPseudo)(specialNode)) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
@@ -40,10 +40,10 @@ function getScopedSelector(resolvedSelector) {
|
|
|
40
40
|
}
|
|
41
41
|
const results = [];
|
|
42
42
|
for (const sel of scopedCandidateSelector.reverse()) {
|
|
43
|
-
if (selectors_2.isSelectorCombinator(sel)) {
|
|
44
|
-
if (!selectors_2.isChildCombinator(sel) &&
|
|
45
|
-
!selectors_2.isAdjacentSiblingCombinator(sel) &&
|
|
46
|
-
!selectors_2.isGeneralSiblingCombinator(sel)) {
|
|
43
|
+
if ((0, selectors_2.isSelectorCombinator)(sel)) {
|
|
44
|
+
if (!(0, selectors_2.isChildCombinator)(sel) &&
|
|
45
|
+
!(0, selectors_2.isAdjacentSiblingCombinator)(sel) &&
|
|
46
|
+
!(0, selectors_2.isGeneralSiblingCombinator)(sel)) {
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -87,16 +87,16 @@ module.exports = {
|
|
|
87
87
|
type: "suggestion",
|
|
88
88
|
},
|
|
89
89
|
create(context) {
|
|
90
|
-
if (!utils_1.hasTemplateBlock(context)) {
|
|
90
|
+
if (!(0, utils_1.hasTemplateBlock)(context)) {
|
|
91
91
|
return {};
|
|
92
92
|
}
|
|
93
|
-
const styles = context_1.getStyleContexts(context)
|
|
93
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
94
94
|
.filter(style_1.isValidStyleContext)
|
|
95
95
|
.filter((style) => style.scoped);
|
|
96
96
|
if (!styles.length) {
|
|
97
97
|
return {};
|
|
98
98
|
}
|
|
99
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
99
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
100
100
|
const reportedSet = new Set();
|
|
101
101
|
function report(nodes) {
|
|
102
102
|
if (!reportedSet.has(nodes[0])) {
|
|
@@ -131,13 +131,14 @@ module.exports = {
|
|
|
131
131
|
reverseVerifySelector = [];
|
|
132
132
|
}
|
|
133
133
|
const classSelectors = selectorBlock.filter(selectors_2.isClassSelector);
|
|
134
|
-
const notClassSelectors = selectorBlock.filter((s) => selectors_2.isSelectorCombinator(s) ||
|
|
135
|
-
selectors_2.isTypeSelector(s) ||
|
|
136
|
-
selectors_2.isIDSelector(s) ||
|
|
137
|
-
selectors_2.isUniversalSelector(s) ||
|
|
138
|
-
selectors_2.isVueSpecialPseudo(s));
|
|
134
|
+
const notClassSelectors = selectorBlock.filter((s) => (0, selectors_2.isSelectorCombinator)(s) ||
|
|
135
|
+
(0, selectors_2.isTypeSelector)(s) ||
|
|
136
|
+
(0, selectors_2.isIDSelector)(s) ||
|
|
137
|
+
(0, selectors_2.isUniversalSelector)(s) ||
|
|
138
|
+
(0, selectors_2.isVueSpecialPseudo)(s));
|
|
139
139
|
for (const selectorNode of notClassSelectors) {
|
|
140
|
-
targetsQueryContext =
|
|
140
|
+
targetsQueryContext =
|
|
141
|
+
targetsQueryContext.reverseQueryStep(selectorNode);
|
|
141
142
|
}
|
|
142
143
|
const roots = targetsQueryContext.filter(elements_1.isRootElement);
|
|
143
144
|
if (roots.elements.length) {
|
|
@@ -148,7 +149,8 @@ module.exports = {
|
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
for (const selectorNode of classSelectors) {
|
|
151
|
-
targetsQueryContext =
|
|
152
|
+
targetsQueryContext =
|
|
153
|
+
targetsQueryContext.reverseQueryStep(selectorNode);
|
|
152
154
|
}
|
|
153
155
|
reportSelectorNodes.push(...selectorBlock);
|
|
154
156
|
if (comb) {
|
|
@@ -158,7 +160,8 @@ module.exports = {
|
|
|
158
160
|
if (targetsQueryContext.elements.some(elements_1.isRootElement)) {
|
|
159
161
|
return;
|
|
160
162
|
}
|
|
161
|
-
targetsQueryContext =
|
|
163
|
+
targetsQueryContext =
|
|
164
|
+
targetsQueryContext.reverseQueryStep(comb);
|
|
162
165
|
reportSelectorNodes.push(comb);
|
|
163
166
|
}
|
|
164
167
|
}
|
|
@@ -168,7 +171,7 @@ module.exports = {
|
|
|
168
171
|
}
|
|
169
172
|
return {
|
|
170
173
|
"Program:exit"() {
|
|
171
|
-
const queryContext = query_1.createQueryContext(context, options_1.parseQueryOptions(context.options[0]));
|
|
174
|
+
const queryContext = (0, query_1.createQueryContext)(context, (0, options_1.parseQueryOptions)(context.options[0]));
|
|
172
175
|
for (const style of styles) {
|
|
173
176
|
for (const scopedSelector of getScopedSelectors(style)) {
|
|
174
177
|
verifySelector(queryContext, scopedSelector);
|
|
@@ -21,15 +21,16 @@ module.exports = {
|
|
|
21
21
|
},
|
|
22
22
|
schema: [{ enum: ["always", "never"] }],
|
|
23
23
|
type: "suggestion",
|
|
24
|
+
hasSuggestions: true,
|
|
24
25
|
},
|
|
25
26
|
create(context) {
|
|
26
27
|
var _a, _b;
|
|
27
28
|
const always = context.options[0] !== "never";
|
|
28
|
-
const styles = context_1.getStyleContexts(context).filter(context_1.isValidStyleContext);
|
|
29
|
+
const styles = (0, context_1.getStyleContexts)(context).filter(context_1.isValidStyleContext);
|
|
29
30
|
if (!styles.length) {
|
|
30
31
|
return {};
|
|
31
32
|
}
|
|
32
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
33
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
33
34
|
const tokenStore = (_b = (_a = context.parserServices).getTemplateBodyTokenStore) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
34
35
|
function reportAlways(node) {
|
|
35
36
|
reporter.report({
|
|
@@ -8,26 +8,26 @@ const utils_1 = require("../utils/utils");
|
|
|
8
8
|
const options_1 = require("../options");
|
|
9
9
|
const style_1 = require("../styles/context/style");
|
|
10
10
|
function getScopedSelectors(style) {
|
|
11
|
-
const resolvedSelectors = selectors_1.getResolvedSelectors(style);
|
|
11
|
+
const resolvedSelectors = (0, selectors_1.getResolvedSelectors)(style);
|
|
12
12
|
return resolvedSelectors.map(getScopedSelector).filter(utils_1.isDefined);
|
|
13
13
|
}
|
|
14
14
|
function getScopedSelector(resolvedSelector) {
|
|
15
15
|
const { selector } = resolvedSelector;
|
|
16
|
-
const specialNodeIndex = selector.findIndex((s) => selectors_2.isDeepCombinator(s) || selectors_2.isVueSpecialPseudo(s));
|
|
16
|
+
const specialNodeIndex = selector.findIndex((s) => (0, selectors_2.isDeepCombinator)(s) || (0, selectors_2.isVueSpecialPseudo)(s));
|
|
17
17
|
if (specialNodeIndex >= 0) {
|
|
18
18
|
const specialNode = selector[specialNodeIndex];
|
|
19
|
-
if (selectors_2.isDeepCombinator(specialNode) || selectors_2.isVDeepPseudo(specialNode)) {
|
|
19
|
+
if ((0, selectors_2.isDeepCombinator)(specialNode) || (0, selectors_2.isVDeepPseudo)(specialNode)) {
|
|
20
20
|
const scopedCandidateSelector = selector.slice(0, specialNodeIndex);
|
|
21
21
|
const last = scopedCandidateSelector.pop();
|
|
22
|
-
if (last && !selectors_2.isDescendantCombinator(last)) {
|
|
22
|
+
if (last && !(0, selectors_2.isDescendantCombinator)(last)) {
|
|
23
23
|
scopedCandidateSelector.push(last);
|
|
24
24
|
}
|
|
25
25
|
return scopedCandidateSelector;
|
|
26
26
|
}
|
|
27
|
-
else if (selectors_2.isVSlottedPseudo(specialNode)) {
|
|
27
|
+
else if ((0, selectors_2.isVSlottedPseudo)(specialNode)) {
|
|
28
28
|
return selector.slice(0, specialNodeIndex + 1);
|
|
29
29
|
}
|
|
30
|
-
else if (selectors_2.isVGlobalPseudo(specialNode)) {
|
|
30
|
+
else if ((0, selectors_2.isVGlobalPseudo)(specialNode)) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
return [...selector];
|
|
@@ -70,16 +70,16 @@ module.exports = {
|
|
|
70
70
|
type: "suggestion",
|
|
71
71
|
},
|
|
72
72
|
create(context) {
|
|
73
|
-
if (!utils_1.hasTemplateBlock(context)) {
|
|
73
|
+
if (!(0, utils_1.hasTemplateBlock)(context)) {
|
|
74
74
|
return {};
|
|
75
75
|
}
|
|
76
|
-
const styles = context_1.getStyleContexts(context)
|
|
76
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
77
77
|
.filter(style_1.isValidStyleContext)
|
|
78
78
|
.filter((style) => style.scoped);
|
|
79
79
|
if (!styles.length) {
|
|
80
80
|
return {};
|
|
81
81
|
}
|
|
82
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
82
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
83
83
|
const reportedSet = new Set();
|
|
84
84
|
function report(nodes) {
|
|
85
85
|
const last = nodes[nodes.length - 1];
|
|
@@ -100,15 +100,16 @@ module.exports = {
|
|
|
100
100
|
function verifySelector(queryContext, scopedSelector) {
|
|
101
101
|
let targetsQueryContext = queryContext;
|
|
102
102
|
const selectorNodes = scopedSelector
|
|
103
|
-
.filter((s) => selectors_2.isSelectorCombinator(s) ||
|
|
104
|
-
selectors_2.isTypeSelector(s) ||
|
|
105
|
-
selectors_2.isIDSelector(s) ||
|
|
106
|
-
selectors_2.isClassSelector(s) ||
|
|
107
|
-
selectors_2.isUniversalSelector(s) ||
|
|
108
|
-
selectors_2.isVueSpecialPseudo(s));
|
|
103
|
+
.filter((s) => (0, selectors_2.isSelectorCombinator)(s) ||
|
|
104
|
+
(0, selectors_2.isTypeSelector)(s) ||
|
|
105
|
+
(0, selectors_2.isIDSelector)(s) ||
|
|
106
|
+
(0, selectors_2.isClassSelector)(s) ||
|
|
107
|
+
(0, selectors_2.isUniversalSelector)(s) ||
|
|
108
|
+
(0, selectors_2.isVueSpecialPseudo)(s));
|
|
109
109
|
for (let index = 0; index < selectorNodes.length; index++) {
|
|
110
110
|
const selectorNode = selectorNodes[index];
|
|
111
|
-
targetsQueryContext =
|
|
111
|
+
targetsQueryContext =
|
|
112
|
+
targetsQueryContext.queryStep(selectorNode);
|
|
112
113
|
if (!targetsQueryContext.elements.length) {
|
|
113
114
|
report(selectorNodes.slice(0, index + 1));
|
|
114
115
|
break;
|
|
@@ -117,7 +118,7 @@ module.exports = {
|
|
|
117
118
|
}
|
|
118
119
|
return {
|
|
119
120
|
"Program:exit"() {
|
|
120
|
-
const queryContext = query_1.createQueryContext(context, options_1.parseQueryOptions(context.options[0]));
|
|
121
|
+
const queryContext = (0, query_1.createQueryContext)(context, (0, options_1.parseQueryOptions)(context.options[0]));
|
|
121
122
|
for (const style of styles) {
|
|
122
123
|
for (const scopedSelector of getScopedSelectors(style)) {
|
|
123
124
|
verifySelector(queryContext, scopedSelector);
|
|
@@ -19,18 +19,18 @@ module.exports = {
|
|
|
19
19
|
type: "suggestion",
|
|
20
20
|
},
|
|
21
21
|
create(context) {
|
|
22
|
-
const styles = context_1.getStyleContexts(context)
|
|
22
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
23
23
|
.filter(context_1.isValidStyleContext)
|
|
24
24
|
.filter((style) => style.scoped);
|
|
25
25
|
if (!styles.length) {
|
|
26
26
|
return {};
|
|
27
27
|
}
|
|
28
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
28
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
29
29
|
function findHasSelectorsNode(node) {
|
|
30
|
-
if (css_nodes_1.hasSelectorNodes(node.parent)) {
|
|
30
|
+
if ((0, css_nodes_1.hasSelectorNodes)(node.parent)) {
|
|
31
31
|
return node.parent;
|
|
32
32
|
}
|
|
33
|
-
if (css_nodes_1.isVCSSAtRule(node.parent)) {
|
|
33
|
+
if ((0, css_nodes_1.isVCSSAtRule)(node.parent)) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
return findHasSelectorsNode(node.parent);
|
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
loc: node.loc,
|
|
42
42
|
messageId: "missingArguments",
|
|
43
43
|
fix(fixer) {
|
|
44
|
-
if (!selectors_1.isVDeepPseudoV2(node)) {
|
|
44
|
+
if (!(0, selectors_1.isVDeepPseudoV2)(node)) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
const nodes = node.parent.nodes;
|
|
@@ -61,8 +61,8 @@ module.exports = {
|
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
63
|
const ruleNode = findHasSelectorsNode(node);
|
|
64
|
-
if (!(ruleNode === null || ruleNode === void 0 ? void 0 : ruleNode.nodes.every((n) => css_nodes_1.isVCSSDeclarationProperty(n) ||
|
|
65
|
-
css_nodes_1.isVCSSComment(n)))) {
|
|
64
|
+
if (!(ruleNode === null || ruleNode === void 0 ? void 0 : ruleNode.nodes.every((n) => (0, css_nodes_1.isVCSSDeclarationProperty)(n) ||
|
|
65
|
+
(0, css_nodes_1.isVCSSComment)(n)))) {
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
68
|
const last = nodes[nodes.length - 1];
|
|
@@ -77,11 +77,11 @@ module.exports = {
|
|
|
77
77
|
function verify(style) {
|
|
78
78
|
style.traverseSelectorNodes({
|
|
79
79
|
enterNode(node) {
|
|
80
|
-
if (selectors_1.isVDeepPseudoV2(node)) {
|
|
80
|
+
if ((0, selectors_1.isVDeepPseudoV2)(node)) {
|
|
81
81
|
report(node);
|
|
82
82
|
}
|
|
83
|
-
else if (selectors_1.isVDeepPseudo(node) &&
|
|
84
|
-
selectors_1.isPseudoEmptyArguments(node)) {
|
|
83
|
+
else if ((0, selectors_1.isVDeepPseudo)(node) &&
|
|
84
|
+
(0, selectors_1.isPseudoEmptyArguments)(node)) {
|
|
85
85
|
report(node);
|
|
86
86
|
}
|
|
87
87
|
},
|
|
@@ -18,13 +18,13 @@ module.exports = {
|
|
|
18
18
|
type: "suggestion",
|
|
19
19
|
},
|
|
20
20
|
create(context) {
|
|
21
|
-
const styles = context_1.getStyleContexts(context)
|
|
21
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
22
22
|
.filter(context_1.isValidStyleContext)
|
|
23
23
|
.filter((style) => style.scoped);
|
|
24
24
|
if (!styles.length) {
|
|
25
25
|
return {};
|
|
26
26
|
}
|
|
27
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
27
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
28
28
|
function report(node) {
|
|
29
29
|
reporter.report({
|
|
30
30
|
node,
|
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
function verify(style) {
|
|
36
36
|
style.traverseSelectorNodes({
|
|
37
37
|
enterNode(node) {
|
|
38
|
-
if (selectors_1.isVGlobalPseudo(node) && selectors_1.isPseudoEmptyArguments(node)) {
|
|
38
|
+
if ((0, selectors_1.isVGlobalPseudo)(node) && (0, selectors_1.isPseudoEmptyArguments)(node)) {
|
|
39
39
|
report(node);
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -18,13 +18,13 @@ module.exports = {
|
|
|
18
18
|
type: "suggestion",
|
|
19
19
|
},
|
|
20
20
|
create(context) {
|
|
21
|
-
const styles = context_1.getStyleContexts(context)
|
|
21
|
+
const styles = (0, context_1.getStyleContexts)(context)
|
|
22
22
|
.filter(context_1.isValidStyleContext)
|
|
23
23
|
.filter((style) => style.scoped);
|
|
24
24
|
if (!styles.length) {
|
|
25
25
|
return {};
|
|
26
26
|
}
|
|
27
|
-
const reporter = context_1.getCommentDirectivesReporter(context);
|
|
27
|
+
const reporter = (0, context_1.getCommentDirectivesReporter)(context);
|
|
28
28
|
function report(node) {
|
|
29
29
|
reporter.report({
|
|
30
30
|
node,
|
|
@@ -35,8 +35,8 @@ module.exports = {
|
|
|
35
35
|
function verify(style) {
|
|
36
36
|
style.traverseSelectorNodes({
|
|
37
37
|
enterNode(node) {
|
|
38
|
-
if (selectors_1.isVSlottedPseudo(node) &&
|
|
39
|
-
selectors_1.isPseudoEmptyArguments(node)) {
|
|
38
|
+
if ((0, selectors_1.isVSlottedPseudo)(node) &&
|
|
39
|
+
(0, selectors_1.isPseudoEmptyArguments)(node)) {
|
|
40
40
|
report(node);
|
|
41
41
|
}
|
|
42
42
|
},
|
|
@@ -23,11 +23,11 @@ function getStyleContexts(context) {
|
|
|
23
23
|
if (cache.styles) {
|
|
24
24
|
return cache.styles;
|
|
25
25
|
}
|
|
26
|
-
return (cache.styles = style_1.createStyleContexts(context));
|
|
26
|
+
return (cache.styles = (0, style_1.createStyleContexts)(context));
|
|
27
27
|
}
|
|
28
28
|
exports.getStyleContexts = getStyleContexts;
|
|
29
29
|
function getCommentDirectivesReporter(context) {
|
|
30
|
-
return comment_directive_1.createCommentDirectivesReporter(context, getCommentDirectives(context));
|
|
30
|
+
return (0, comment_directive_1.createCommentDirectivesReporter)(context, getCommentDirectives(context));
|
|
31
31
|
}
|
|
32
32
|
exports.getCommentDirectivesReporter = getCommentDirectivesReporter;
|
|
33
33
|
function getVueComponentContext(context) {
|
|
@@ -35,7 +35,7 @@ function getVueComponentContext(context) {
|
|
|
35
35
|
if (cache.vueComponent) {
|
|
36
36
|
return cache.vueComponent;
|
|
37
37
|
}
|
|
38
|
-
return (cache.vueComponent = vue_components_1.createVueComponentContext(context));
|
|
38
|
+
return (cache.vueComponent = (0, vue_components_1.createVueComponentContext)(context));
|
|
39
39
|
}
|
|
40
40
|
exports.getVueComponentContext = getVueComponentContext;
|
|
41
41
|
function getCommentDirectives(context) {
|
|
@@ -43,5 +43,5 @@ function getCommentDirectives(context) {
|
|
|
43
43
|
if (cache.comment) {
|
|
44
44
|
return cache.comment;
|
|
45
45
|
}
|
|
46
|
-
return (cache.comment = comment_directive_1.createCommentDirectives(getStyleContexts(context)));
|
|
46
|
+
return (cache.comment = (0, comment_directive_1.createCommentDirectives)(getStyleContexts(context)));
|
|
47
47
|
}
|