eslint-plugin-vue-scoped-css 1.2.2 → 2.2.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 +4 -3
- 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 +165 -140
- 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 +6 -6
- 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 +31 -31
|
@@ -7,7 +7,7 @@ function getVueComponentObject(node) {
|
|
|
7
7
|
if (node.type !== "ExportDefaultDeclaration") {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
const declaration = nodes_1.unwrapTypesExpression(node.declaration);
|
|
10
|
+
const declaration = (0, nodes_1.unwrapTypesExpression)(node.declaration);
|
|
11
11
|
if (declaration.type === "ObjectExpression") {
|
|
12
12
|
return declaration;
|
|
13
13
|
}
|
|
@@ -15,12 +15,12 @@ function getVueComponentObject(node) {
|
|
|
15
15
|
declaration.arguments.length >= 1) {
|
|
16
16
|
const callee = declaration.callee;
|
|
17
17
|
if (callee.type === "MemberExpression") {
|
|
18
|
-
const calleeObject = nodes_1.unwrapTypesExpression(callee.object);
|
|
18
|
+
const calleeObject = (0, nodes_1.unwrapTypesExpression)(callee.object);
|
|
19
19
|
if (calleeObject.type === "Identifier" &&
|
|
20
20
|
calleeObject.name === "Vue" &&
|
|
21
21
|
callee.property.type === "Identifier" &&
|
|
22
22
|
callee.property.name === "extend") {
|
|
23
|
-
const object = nodes_1.unwrapTypesExpression(declaration.arguments[0]);
|
|
23
|
+
const object = (0, nodes_1.unwrapTypesExpression)(declaration.arguments[0]);
|
|
24
24
|
if (object.type === "ObjectExpression") {
|
|
25
25
|
return object;
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ function getVueComponentObject(node) {
|
|
|
28
28
|
}
|
|
29
29
|
if (callee.type === "Identifier") {
|
|
30
30
|
if (callee.name === "defineComponent") {
|
|
31
|
-
const object = nodes_1.unwrapTypesExpression(declaration.arguments[0]);
|
|
31
|
+
const object = (0, nodes_1.unwrapTypesExpression)(declaration.arguments[0]);
|
|
32
32
|
if (object.type === "ObjectExpression") {
|
|
33
33
|
return object;
|
|
34
34
|
}
|
|
@@ -41,7 +41,7 @@ function findVueComponent(context) {
|
|
|
41
41
|
const sourceCode = context.getSourceCode();
|
|
42
42
|
const componentComments = sourceCode
|
|
43
43
|
.getAllComments()
|
|
44
|
-
.filter((comment) =>
|
|
44
|
+
.filter((comment) => comment.value.includes("@vue/component"));
|
|
45
45
|
const foundNodes = [];
|
|
46
46
|
function isDuplicateNode(node) {
|
|
47
47
|
if (foundNodes.some((el) => el.loc.start.line === node.loc.start.line)) {
|
|
@@ -41,7 +41,7 @@ class VueComponentContext {
|
|
|
41
41
|
}
|
|
42
42
|
exports.VueComponentContext = VueComponentContext;
|
|
43
43
|
function createVueComponentContext(context) {
|
|
44
|
-
const node = find_vue_1.default(context);
|
|
44
|
+
const node = (0, find_vue_1.default)(context);
|
|
45
45
|
if (!node) {
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
@@ -110,7 +110,7 @@ class CSSParser {
|
|
|
110
110
|
if (astNode == null) {
|
|
111
111
|
return null;
|
|
112
112
|
}
|
|
113
|
-
if (utils_1.isPostCSSContainer(node) && css_nodes_1.isVCSSContainerNode(astNode)) {
|
|
113
|
+
if ((0, utils_1.isPostCSSContainer)(node) && (0, css_nodes_1.isVCSSContainerNode)(astNode)) {
|
|
114
114
|
astNode.nodes = node.nodes
|
|
115
115
|
.map((n) => this._postcssNodeToASTNode(offsetLocation, n, astNode))
|
|
116
116
|
.filter(utils_2.isDefined);
|
|
@@ -123,7 +123,7 @@ class CSSParser {
|
|
|
123
123
|
}
|
|
124
124
|
catch (e) {
|
|
125
125
|
this.addError(e);
|
|
126
|
-
return postcss_safe_parser_1.default(css);
|
|
126
|
+
return (0, postcss_safe_parser_1.default)(css);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
createSelectorParser() {
|
|
@@ -11,7 +11,7 @@ const PARSERS = {
|
|
|
11
11
|
stylus: stylus_parser_1.StylusParser,
|
|
12
12
|
};
|
|
13
13
|
function parse(sourceCode, offsetLocation, css, lang) {
|
|
14
|
-
const Parser = utils_1.isSupportedStyleLang(lang) ? PARSERS[lang] : css_parser_1.CSSParser;
|
|
14
|
+
const Parser = (0, utils_1.isSupportedStyleLang)(lang) ? PARSERS[lang] : css_parser_1.CSSParser;
|
|
15
15
|
const parser = new Parser(sourceCode, lang);
|
|
16
16
|
return parser.parse(css, offsetLocation);
|
|
17
17
|
}
|
|
@@ -20,10 +20,10 @@ class CSSSelectorParser {
|
|
|
20
20
|
return this._postcssSelectorParserNodeChiildrenToASTNodes(offsetLocation, selectorParserRoot, parent);
|
|
21
21
|
}
|
|
22
22
|
parseInternal(selector) {
|
|
23
|
-
return postcss_selector_parser_1.default().astSync(selector);
|
|
23
|
+
return (0, postcss_selector_parser_1.default)().astSync(selector);
|
|
24
24
|
}
|
|
25
25
|
parseCommentsInternal(selector) {
|
|
26
|
-
return postcss_selector_parser_1.default().astSync(selector);
|
|
26
|
+
return (0, postcss_selector_parser_1.default)().astSync(selector);
|
|
27
27
|
}
|
|
28
28
|
_postcssSelectorParserNodeChiildrenToASTNodes(offsetLocation, node, parent) {
|
|
29
29
|
const astNodes = removeInvalidDescendantCombinator(node.nodes
|
|
@@ -58,12 +58,13 @@ class CSSSelectorParser {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
this.parseRawsSpaces(astNode, node, parent);
|
|
61
|
-
if (utils_1.isPostCSSSPContainer(node)) {
|
|
61
|
+
if ((0, utils_1.isPostCSSSPContainer)(node)) {
|
|
62
62
|
if (astNode.type === "VCSSSelectorPseudo") {
|
|
63
|
-
astNode.nodes = selectors_1.normalizePseudoParams(astNode, this._postcssSelectorParserNodeChiildrenToASTNodes(offsetLocation, node, astNode));
|
|
63
|
+
astNode.nodes = (0, selectors_1.normalizePseudoParams)(astNode, this._postcssSelectorParserNodeChiildrenToASTNodes(offsetLocation, node, astNode));
|
|
64
64
|
}
|
|
65
65
|
else if (astNode.type === "VCSSSelector") {
|
|
66
|
-
astNode.nodes =
|
|
66
|
+
astNode.nodes =
|
|
67
|
+
this._postcssSelectorParserNodeChiildrenToASTNodes(offsetLocation, node, astNode);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
return astNode;
|
|
@@ -218,20 +219,20 @@ function removeInvalidDescendantCombinator(nodes) {
|
|
|
218
219
|
let prev = null;
|
|
219
220
|
for (let index = 0; index < nodes.length; index++) {
|
|
220
221
|
const node = nodes[index];
|
|
221
|
-
if (selectors_1.isDescendantCombinator(node)) {
|
|
222
|
+
if ((0, selectors_1.isDescendantCombinator)(node)) {
|
|
222
223
|
if (results.length === 0) {
|
|
223
224
|
continue;
|
|
224
225
|
}
|
|
225
|
-
if (selectors_1.isSelectorCombinator(prev) || selectors_1.isVDeepPseudoV2(prev)) {
|
|
226
|
+
if ((0, selectors_1.isSelectorCombinator)(prev) || (0, selectors_1.isVDeepPseudoV2)(prev)) {
|
|
226
227
|
continue;
|
|
227
228
|
}
|
|
228
229
|
const next = nodes[index + 1];
|
|
229
|
-
if (selectors_1.isSelectorCombinator(next)) {
|
|
230
|
+
if ((0, selectors_1.isSelectorCombinator)(next)) {
|
|
230
231
|
continue;
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
else if (selectors_1.isVueSpecialPseudo(node)) {
|
|
234
|
-
if (prev && !selectors_1.isSelectorCombinator(prev)) {
|
|
234
|
+
else if ((0, selectors_1.isVueSpecialPseudo)(node)) {
|
|
235
|
+
if (prev && !(0, selectors_1.isSelectorCombinator)(prev)) {
|
|
235
236
|
results.push(new ast_1.VCSSSelectorCombinator(node.node, node.loc, node.start, node.end, { parent: node.parent, value: " " }));
|
|
236
237
|
}
|
|
237
238
|
}
|
|
@@ -274,7 +274,7 @@ function restoreReplacedSelector(orgNode, replaceSelectorContext) {
|
|
|
274
274
|
while (restoreComments(node, comments, cssText)) {
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
if (utils_1.isPostCSSSPContainer(node)) {
|
|
277
|
+
if ((0, utils_1.isPostCSSSPContainer)(node)) {
|
|
278
278
|
for (let index = 0; index < node.nodes.length; index++) {
|
|
279
279
|
node.nodes[index] = restoreReplacedSelector(node.nodes[index], replaceSelectorContext);
|
|
280
280
|
}
|
|
@@ -10,7 +10,7 @@ const ast_1 = require("../../ast");
|
|
|
10
10
|
const replace_utils_1 = require("./replace-utils");
|
|
11
11
|
class SCSSSelectorParser extends css_selector_parser_1.CSSSelectorParser {
|
|
12
12
|
parseInternal(selector) {
|
|
13
|
-
const replaceSelectorContext = replace_utils_1.replaceSelector(selector, [
|
|
13
|
+
const replaceSelectorContext = (0, replace_utils_1.replaceSelector)(selector, [
|
|
14
14
|
{
|
|
15
15
|
regexp: /#\{[\s\S]+?\}/gu,
|
|
16
16
|
replace: (_res, random) => `_${random}_`,
|
|
@@ -21,11 +21,11 @@ class SCSSSelectorParser extends css_selector_parser_1.CSSSelectorParser {
|
|
|
21
21
|
replace: (_res, random) => `/*${random}*/`,
|
|
22
22
|
},
|
|
23
23
|
]);
|
|
24
|
-
const result = postcss_selector_parser_1.default().astSync(replaceSelectorContext.cssSelector);
|
|
24
|
+
const result = (0, postcss_selector_parser_1.default)().astSync(replaceSelectorContext.cssSelector);
|
|
25
25
|
if (!replaceSelectorContext.hasReplace()) {
|
|
26
26
|
return result;
|
|
27
27
|
}
|
|
28
|
-
return replace_utils_1.restoreReplacedSelector(result, replaceSelectorContext);
|
|
28
|
+
return (0, replace_utils_1.restoreReplacedSelector)(result, replaceSelectorContext);
|
|
29
29
|
}
|
|
30
30
|
parseCommentsInternal(selector) {
|
|
31
31
|
return this.parseInternal(selector);
|
|
@@ -24,7 +24,7 @@ function restoreStylusNesting(attribute, random, original) {
|
|
|
24
24
|
}
|
|
25
25
|
class StylusSelectorParser extends css_selector_parser_1.CSSSelectorParser {
|
|
26
26
|
parseInternal(selector) {
|
|
27
|
-
const replaceSelectorContext = replace_utils_1.replaceSelector(selector, [
|
|
27
|
+
const replaceSelectorContext = (0, replace_utils_1.replaceSelector)(selector, [
|
|
28
28
|
{
|
|
29
29
|
regexp: /\{[\s\S]+?\}/gu,
|
|
30
30
|
replace: (_res, random) => `_${random}_`,
|
|
@@ -83,11 +83,11 @@ class StylusSelectorParser extends css_selector_parser_1.CSSSelectorParser {
|
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
]);
|
|
86
|
-
const result = postcss_selector_parser_1.default().astSync(replaceSelectorContext.cssSelector);
|
|
86
|
+
const result = (0, postcss_selector_parser_1.default)().astSync(replaceSelectorContext.cssSelector);
|
|
87
87
|
if (!replaceSelectorContext.hasReplace()) {
|
|
88
88
|
return result;
|
|
89
89
|
}
|
|
90
|
-
return replace_utils_1.restoreReplacedSelector(result, replaceSelectorContext);
|
|
90
|
+
return (0, replace_utils_1.restoreReplacedSelector)(result, replaceSelectorContext);
|
|
91
91
|
}
|
|
92
92
|
parseCommentsInternal(selector) {
|
|
93
93
|
return this.parseInternal(selector);
|
|
@@ -13,7 +13,7 @@ const RESOLVERS = {
|
|
|
13
13
|
};
|
|
14
14
|
function getResolvedSelectors(style) {
|
|
15
15
|
const lang = style.lang;
|
|
16
|
-
const Resolver = utils_1.isSupportedStyleLang(lang)
|
|
16
|
+
const Resolver = (0, utils_1.isSupportedStyleLang)(lang)
|
|
17
17
|
? RESOLVERS[lang]
|
|
18
18
|
: css_selector_resolver_1.CSSSelectorResolver;
|
|
19
19
|
return extractSelectors(new Resolver().resolveSelectors(style.cssNode));
|
|
@@ -7,7 +7,7 @@ function getAttributeValueNodes(element, name, context) {
|
|
|
7
7
|
const results = [];
|
|
8
8
|
const { startTag } = element;
|
|
9
9
|
for (const attr of startTag.attributes) {
|
|
10
|
-
if (!templates_1.isVDirective(attr)) {
|
|
10
|
+
if (!(0, templates_1.isVDirective)(attr)) {
|
|
11
11
|
const { key, value } = attr;
|
|
12
12
|
if (value == null) {
|
|
13
13
|
continue;
|
|
@@ -21,10 +21,10 @@ function getAttributeValueNodes(element, name, context) {
|
|
|
21
21
|
if (value == null) {
|
|
22
22
|
continue;
|
|
23
23
|
}
|
|
24
|
-
if (!templates_1.isVBind(key)) {
|
|
24
|
+
if (!(0, templates_1.isVBind)(key)) {
|
|
25
25
|
continue;
|
|
26
26
|
}
|
|
27
|
-
const bindArg = templates_1.getArgument(key);
|
|
27
|
+
const bindArg = (0, templates_1.getArgument)(key);
|
|
28
28
|
if (bindArg == null) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
@@ -51,7 +51,7 @@ function getReferenceExpressions(expression, context) {
|
|
|
51
51
|
if (expression.type !== "Identifier") {
|
|
52
52
|
return [expression];
|
|
53
53
|
}
|
|
54
|
-
const vueComponent = context_1.getVueComponentContext(context);
|
|
54
|
+
const vueComponent = (0, context_1.getVueComponentContext)(context);
|
|
55
55
|
if (!vueComponent) {
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
@@ -13,7 +13,7 @@ function isRootTemplate(element) {
|
|
|
13
13
|
}
|
|
14
14
|
function isSkipElement(element) {
|
|
15
15
|
return (element.type === "VElement" &&
|
|
16
|
-
(element.name === "template" || templates_1.isTransitionElement(element)));
|
|
16
|
+
(element.name === "template" || (0, templates_1.isTransitionElement)(element)));
|
|
17
17
|
}
|
|
18
18
|
exports.isSkipElement = isSkipElement;
|
|
19
19
|
function isSlotElement(element) {
|
|
@@ -23,7 +23,7 @@ exports.isSlotElement = isSlotElement;
|
|
|
23
23
|
function getWrapperTransition(element) {
|
|
24
24
|
let parent = element.parent;
|
|
25
25
|
while (parent.type === "VElement") {
|
|
26
|
-
if (templates_1.isTransitionElement(parent) || templates_1.isTransitionGroupElement(parent)) {
|
|
26
|
+
if ((0, templates_1.isTransitionElement)(parent) || (0, templates_1.isTransitionGroupElement)(parent)) {
|
|
27
27
|
return parent;
|
|
28
28
|
}
|
|
29
29
|
if (!isSlotElement(parent) && !isSkipElement(parent)) {
|