eslint-plugin-mpx 0.0.21 → 0.0.22

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 CHANGED
@@ -16,6 +16,9 @@ Next, install `eslint-plugin-mpx`:
16
16
  $ npm install eslint-plugin-mpx --save-dev
17
17
  ```
18
18
 
19
+ ## Docs
20
+
21
+ https://mpx-ecology.github.io/eslint-plugin-mpx/
19
22
 
20
23
  ## Usage
21
24
 
@@ -139,10 +139,15 @@ module.exports = {
139
139
  operandsB.operands.some((operandB) => equal(operandA, operandB))
140
140
  )
141
141
  }
142
-
142
+ const sourceCode = context.getSourceCode()
143
143
  return utils.defineTemplateBodyVisitor(context, {
144
144
  "VAttribute[directive=true][key.name.name='elif']"(node) {
145
- if (!node.value || !node.value.expression) {
145
+ const text = sourceCode.getText(node).slice(-3)
146
+ if (
147
+ !node.value ||
148
+ !node.value.expression ||
149
+ !['}}"', "}}'"].includes(text)
150
+ ) {
146
151
  return
147
152
  }
148
153
  const test = node.value.expression
@@ -24,11 +24,12 @@ function getName(attribute) {
24
24
  if (!attribute.directive) {
25
25
  return attribute.key.name
26
26
  }
27
- if (attribute.key.name.name === 'bind') {
27
+ if (attribute.key.name.name.startsWith('bind')) {
28
28
  return (
29
29
  (attribute.key.argument &&
30
30
  attribute.key.argument.type === 'VIdentifier' &&
31
- attribute.key.argument.name) ||
31
+ attribute.key.name.name + attribute.key.argument.name) ||
32
+ attribute.key.name.name ||
32
33
  null
33
34
  )
34
35
  }
@@ -65,10 +66,6 @@ module.exports = {
65
66
  },
66
67
  /** @param {RuleContext} context */
67
68
  create(context) {
68
- const options = context.options[0] || {}
69
- const allowCoexistStyle = options.allowCoexistStyle !== false
70
- const allowCoexistClass = options.allowCoexistClass !== false
71
-
72
69
  /** @type {Set<string>} */
73
70
  const directiveNames = new Set()
74
71
  /** @type {Set<string>} */
@@ -76,15 +73,8 @@ module.exports = {
76
73
 
77
74
  /**
78
75
  * @param {string} name
79
- * @param {boolean} isDirective
80
76
  */
81
- function isDuplicate(name, isDirective) {
82
- if (
83
- (allowCoexistStyle && name === 'style') ||
84
- (allowCoexistClass && name === 'class')
85
- ) {
86
- return isDirective ? directiveNames.has(name) : attributeNames.has(name)
87
- }
77
+ function isDuplicate(name) {
88
78
  return directiveNames.has(name) || attributeNames.has(name)
89
79
  }
90
80
 
@@ -99,7 +89,7 @@ module.exports = {
99
89
  return
100
90
  }
101
91
 
102
- if (isDuplicate(name, node.directive)) {
92
+ if (isDuplicate(name)) {
103
93
  context.report({
104
94
  node,
105
95
  loc: node.loc,
@@ -16,7 +16,7 @@ const utils = require('../utils')
16
16
 
17
17
  const RESERVED_KEYS = require('../utils/vue-reserved.json')
18
18
  /** @type {GroupName[]} */
19
- const GROUP_NAMES = ['properties', 'computed', 'data', 'methods', 'setup']
19
+ const GROUP_NAMES = ['properties', 'computed', 'data', 'methods']
20
20
 
21
21
  module.exports = {
22
22
  meta: {
@@ -33,7 +33,7 @@ module.exports = {
33
33
  type: 'problem',
34
34
  docs: {
35
35
  description: 'enforce valid `wx:model` directives',
36
- categories: ['mpx-essential'],
36
+ // categories: ['mpx-essential'],
37
37
  url: 'https://eslint.vuejs.org/rules/valid-wx:model.html'
38
38
  },
39
39
  fixable: null,
@@ -1488,11 +1488,7 @@ module.exports = {
1488
1488
  const tokensL = sourceCode.getTokens(left)
1489
1489
  const tokensR = sourceCode.getTokens(right)
1490
1490
 
1491
- if (
1492
- tokensL.length !== tokensR.length ||
1493
- sourceCode.getTokenBefore(left).value !==
1494
- sourceCode.getTokenBefore(right).value
1495
- ) {
1491
+ if (tokensL.length !== tokensR.length) {
1496
1492
  return false
1497
1493
  }
1498
1494
  for (let i = 0; i < tokensL.length; ++i) {
@@ -1,4 +1,4 @@
1
1
  [
2
- "$data", "$props", "$el", "$options", "$parent", "$root", "$children", "$slots", "$scopedSlots", "$refs", "$isServer", "$attrs", "$listeners",
3
- "$watch", "$set", "$delete", "$on", "$once", "$off", "$emit", "$mount", "$forceUpdate", "$nextTick", "$destroy"
2
+ "$data", "$props", "$el", "$options", "$parent", "$root", "$children", "$slots", "$scopedSlots", "$refs", "$isServer", "$attrs", "$listeners", "$i18n", "$hook", "$xfetch",
3
+ "$watch", "$set", "$delete", "$on", "$once", "$off", "$emit", "$mount", "$forceUpdate", "$nextTick", "$destroy" , "$remove"
4
4
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-mpx",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Official ESLint plugin for Mpx.js",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -48,8 +48,8 @@
48
48
  "eslint": "^6.2.0 || ^7.0.0"
49
49
  },
50
50
  "dependencies": {
51
- "mpx-eslint-parser": "0.0.7",
52
51
  "eslint-utils": "^2.1.0",
52
+ "mpx-eslint-parser": "0.0.8",
53
53
  "natural-compare": "^1.4.0",
54
54
  "semver": "^7.3.2",
55
55
  "vue-eslint-parser": "^7.1.0"