eslint-plugin-vue-scoped-css 2.3.0 → 2.4.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.
@@ -17,7 +17,7 @@ class VueComponentContext {
17
17
  }
18
18
  findVueComponentProperty(name) {
19
19
  const properties = this.properties ||
20
- (this.properties = extractVueComponentPropertes(this.node, this.context));
20
+ (this.properties = extractVueComponentProperties(this.node, this.context));
21
21
  if (properties[UNKNOWN]) {
22
22
  return null;
23
23
  }
@@ -48,7 +48,7 @@ function createVueComponentContext(context) {
48
48
  return new VueComponentContext(node, context);
49
49
  }
50
50
  exports.createVueComponentContext = createVueComponentContext;
51
- function extractVueComponentPropertes(vueNode, context) {
51
+ function extractVueComponentProperties(vueNode, context) {
52
52
  const result = {
53
53
  data: {},
54
54
  computed: {},
@@ -129,7 +129,7 @@ function extractVueComponentComputed(computedNode, context) {
129
129
  continue;
130
130
  }
131
131
  const values = computed[keyName] || (computed[keyName] = []);
132
- const { value } = p;
132
+ const value = p.value;
133
133
  let func = value;
134
134
  if (value.type === "ObjectExpression") {
135
135
  const get = value.properties
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getReferenceExpressions = exports.getAttributeValueNodes = void 0;
4
- const context_1 = require("../../context");
3
+ exports.getAttributeValueNodes = void 0;
5
4
  const templates_1 = require("../../../utils/templates");
5
+ const reference_expression_1 = require("./reference-expression");
6
6
  function getAttributeValueNodes(element, name, context) {
7
7
  const results = [];
8
8
  const { startTag } = element;
@@ -35,7 +35,7 @@ function getAttributeValueNodes(element, name, context) {
35
35
  if (expression == null) {
36
36
  continue;
37
37
  }
38
- const expressions = getReferenceExpressions(expression, context);
38
+ const expressions = (0, reference_expression_1.getReferenceExpressions)(expression, context);
39
39
  if (!expressions) {
40
40
  return null;
41
41
  }
@@ -47,18 +47,3 @@ function getAttributeValueNodes(element, name, context) {
47
47
  return results;
48
48
  }
49
49
  exports.getAttributeValueNodes = getAttributeValueNodes;
50
- function getReferenceExpressions(expression, context) {
51
- if (expression.type !== "Identifier") {
52
- return [expression];
53
- }
54
- const vueComponent = (0, context_1.getVueComponentContext)(context);
55
- if (!vueComponent) {
56
- return null;
57
- }
58
- const props = vueComponent.findVueComponentProperty(expression.name);
59
- if (props == null) {
60
- return null;
61
- }
62
- return props;
63
- }
64
- exports.getReferenceExpressions = getReferenceExpressions;
@@ -9,6 +9,7 @@ const nodes_1 = require("../../utils/nodes");
9
9
  const template_1 = require("../../template");
10
10
  const templates_1 = require("../../../utils/templates");
11
11
  const style_1 = require("../../context/style");
12
+ const reference_expression_1 = require("./reference-expression");
12
13
  const TRANSITION_CLASS_BASES = [
13
14
  "enter",
14
15
  "enter-from",
@@ -562,30 +563,20 @@ function matchClassNameExpression(expression, className, document) {
562
563
  }
563
564
  function matchClassNameForArrayExpression(expression, className, document) {
564
565
  for (const e of expression.elements) {
565
- if (e.type === "Identifier") {
566
- if (withinTemplate(e, document)) {
567
- const expressions = (0, attribute_tracker_1.getReferenceExpressions)(e, document.context);
568
- if (expressions) {
569
- for (const e2 of expressions) {
570
- if (matchClassNameExpression(e2, className, document)) {
571
- return true;
572
- }
573
- }
574
- }
575
- }
576
- else {
577
- if (matchClassNameExpression(e, className, document)) {
578
- return true;
579
- }
580
- }
581
- }
582
- else if (e.type === "SpreadElement") {
566
+ if (e.type === "SpreadElement") {
583
567
  if (matchClassNameExpression(e.argument, className, document)) {
584
568
  return true;
585
569
  }
586
570
  }
587
- else if (matchClassNameExpression(e, className, document)) {
588
- return true;
571
+ else {
572
+ const expressions = (0, reference_expression_1.getReferenceExpressions)(e, document.context);
573
+ if (expressions) {
574
+ for (const e2 of expressions) {
575
+ if (matchClassNameExpression(e2, className, document)) {
576
+ return true;
577
+ }
578
+ }
579
+ }
589
580
  }
590
581
  }
591
582
  return false;
@@ -629,12 +620,6 @@ function includesClassName(value, className) {
629
620
  }
630
621
  return value.divide(/\s+/u).some((s) => className.match(s));
631
622
  }
632
- function withinTemplate(expr, document) {
633
- var _a;
634
- const templateBody = document.context.getSourceCode().ast.templateBody;
635
- const templateRange = (_a = templateBody === null || templateBody === void 0 ? void 0 : templateBody.range) !== null && _a !== void 0 ? _a : [0, 0];
636
- return templateRange[0] <= expr.range[0] && expr.range[1] <= templateRange[1];
637
- }
638
623
  function* iterateUnique(gen) {
639
624
  const found = new Set();
640
625
  for (const e of gen()) {
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReferenceExpressions = void 0;
4
+ const context_1 = require("../../context");
5
+ function getReferenceExpressions(expression, context) {
6
+ var _a, _b, _c, _d;
7
+ if (expression.type === "ConditionalExpression") {
8
+ const { consequent, alternate } = expression;
9
+ return [
10
+ ...((_a = getReferenceExpressions(consequent, context)) !== null && _a !== void 0 ? _a : [consequent]),
11
+ ...((_b = getReferenceExpressions(alternate, context)) !== null && _b !== void 0 ? _b : [alternate]),
12
+ ];
13
+ }
14
+ if (expression.type === "LogicalExpression") {
15
+ const { left, right } = expression;
16
+ return [
17
+ ...((_c = getReferenceExpressions(left, context)) !== null && _c !== void 0 ? _c : [left]),
18
+ ...((_d = getReferenceExpressions(right, context)) !== null && _d !== void 0 ? _d : [right]),
19
+ ];
20
+ }
21
+ if (expression.type !== "Identifier") {
22
+ return [expression];
23
+ }
24
+ if (!withinTemplate(expression, context)) {
25
+ return [expression];
26
+ }
27
+ const vueComponent = (0, context_1.getVueComponentContext)(context);
28
+ if (!vueComponent) {
29
+ return null;
30
+ }
31
+ const props = vueComponent.findVueComponentProperty(expression.name);
32
+ if (props == null) {
33
+ return null;
34
+ }
35
+ return props;
36
+ }
37
+ exports.getReferenceExpressions = getReferenceExpressions;
38
+ function withinTemplate(expr, context) {
39
+ var _a;
40
+ const templateBody = context.getSourceCode().ast.templateBody;
41
+ const templateRange = (_a = templateBody === null || templateBody === void 0 ? void 0 : templateBody.range) !== null && _a !== void 0 ? _a : [0, 0];
42
+ return templateRange[0] <= expr.range[0] && expr.range[1] <= templateRange[1];
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-vue-scoped-css",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "ESLint plugin for Scoped CSS in Vue.js",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {