eslint-plugin-mpx 0.0.20 → 0.0.21

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
@@ -23,8 +23,8 @@ Add `mpx` to the plugins section of your `.eslintrc` configuration file. You can
23
23
 
24
24
  ```json
25
25
  {
26
- "plugins": [
27
- "mpx"
26
+ "extends": [
27
+ "plugin:mpx/mpx-essential"
28
28
  ]
29
29
  }
30
30
  ```
@@ -13,9 +13,18 @@ module.exports = {
13
13
  browser: true,
14
14
  es6: true
15
15
  },
16
+ globals: {
17
+ wx: 'readonly',
18
+ getApp: 'readonly',
19
+ App: 'readonly',
20
+ __mpx_mode__: 'readonly',
21
+ __mpx_env__: 'readonly',
22
+ requirePlugin: 'readonly'
23
+ },
16
24
  plugins: ['mpx'],
17
25
  rules: {
18
26
  'mpx/comment-directive': 'error',
19
- 'mpx/jsx-uses-vars': 'error'
27
+ // 'mpx/jsx-uses-vars': 'error',
28
+ camelcase: ['error', { allow: ['__mpx_mode__', '__mpx_env__'] }]
20
29
  }
21
30
  }
@@ -20,7 +20,7 @@ module.exports = {
20
20
  type: 'suggestion',
21
21
  docs: {
22
22
  description: 'enforce end tag style',
23
- categories: ['vue3-strongly-recommended', 'strongly-recommended'],
23
+ categories: ['mpx-essential'],
24
24
  url: 'https://eslint.vuejs.org/rules/html-end-tags.html'
25
25
  },
26
26
  fixable: 'code',
@@ -39,7 +39,7 @@ module.exports = {
39
39
  type: 'problem',
40
40
  docs: {
41
41
  description: 'prevent variables used in JSX to be marked as unused', // eslint-disable-line consistent-docs-description
42
- categories: ['base'],
42
+ // categories: ['base'],
43
43
  url: 'https://eslint.vuejs.org/rules/jsx-uses-vars.html'
44
44
  },
45
45
  schema: []
@@ -10,7 +10,7 @@ module.exports = {
10
10
  type: 'problem',
11
11
  docs: {
12
12
  description: 'disallow using arrow functions to define watcher',
13
- categories: ['vue3-essential', 'essential'],
13
+ categories: ['mpx-essential'],
14
14
  url: 'https://eslint.vuejs.org/rules/no-arrow-functions-in-watch.html'
15
15
  },
16
16
  fixable: null,
@@ -69,7 +69,7 @@ module.exports = {
69
69
  type: 'problem',
70
70
  docs: {
71
71
  description: 'disallow asynchronous actions in computed properties',
72
- categories: ['vue3-essential', 'essential'],
72
+ categories: ['mpx-essential'],
73
73
  url: 'https://eslint.vuejs.org/rules/no-async-in-computed-properties.html'
74
74
  },
75
75
  fixable: null,
@@ -14,14 +14,14 @@ const utils = require('../utils')
14
14
  // Rule Definition
15
15
  // ------------------------------------------------------------------------------
16
16
  /** @type {GroupName[]} */
17
- const GROUP_NAMES = ['props', 'computed', 'data', 'methods', 'setup']
17
+ const GROUP_NAMES = ['properties', 'computed', 'data', 'methods']
18
18
 
19
19
  module.exports = {
20
20
  meta: {
21
21
  type: 'problem',
22
22
  docs: {
23
23
  description: 'disallow duplication of field names',
24
- categories: ['vue3-essential', 'essential'],
24
+ categories: ['mpx-essential'],
25
25
  url: 'https://eslint.vuejs.org/rules/no-dupe-keys.html'
26
26
  },
27
27
  fixable: null, // or "code" or "whitespace"
@@ -44,7 +44,7 @@ module.exports = {
44
44
  type: 'problem',
45
45
  docs: {
46
46
  description: 'disallow duplication of attributes',
47
- categories: ['vue3-essential', 'essential'],
47
+ categories: ['mpx-essential'],
48
48
  url: 'https://eslint.vuejs.org/rules/no-duplicate-attributes.html'
49
49
  },
50
50
  fixable: null,
@@ -23,7 +23,7 @@ module.exports = {
23
23
  type: 'suggestion',
24
24
  docs: {
25
25
  description: 'disallow overwriting reserved keys',
26
- categories: ['vue3-essential', 'essential'],
26
+ categories: ['mpx-essential'],
27
27
  url: 'https://eslint.vuejs.org/rules/no-reserved-keys.html'
28
28
  },
29
29
  fixable: null,
@@ -20,7 +20,7 @@ module.exports = {
20
20
  type: 'problem',
21
21
  docs: {
22
22
  description: 'disallow side effects in computed properties',
23
- categories: ['vue3-essential', 'essential'],
23
+ categories: ['mpx-essential'],
24
24
  url:
25
25
  'https://eslint.vuejs.org/rules/no-side-effects-in-computed-properties.html'
26
26
  },
@@ -19,7 +19,7 @@ const utils = require('../utils')
19
19
  // ------------------------------------------------------------------------------
20
20
 
21
21
  /** @type {GroupName[]} */
22
- const GROUP_NAMES = ['props', 'computed', 'data', 'methods']
22
+ const GROUP_NAMES = ['properties', 'computed', 'data', 'methods']
23
23
 
24
24
  module.exports = {
25
25
  meta: {
@@ -63,7 +63,7 @@ module.exports = {
63
63
  docs: {
64
64
  description:
65
65
  'disallow unused variable definitions of v-for directives or scope attributes',
66
- categories: ['vue3-essential', 'essential'],
66
+ categories: ['essential'],
67
67
  url: 'https://eslint.vuejs.org/rules/no-unused-vars.html'
68
68
  },
69
69
  fixable: null,
@@ -20,7 +20,7 @@ module.exports = {
20
20
  docs: {
21
21
  description:
22
22
  'enforce that a return statement is present in computed property',
23
- categories: ['vue3-essential', 'essential'],
23
+ categories: ['mpx-essential'],
24
24
  url: 'https://eslint.vuejs.org/rules/return-in-computed-property.html'
25
25
  },
26
26
  fixable: null, // or "code" or "whitespace"
@@ -20,7 +20,7 @@ module.exports = {
20
20
  type: 'problem',
21
21
  docs: {
22
22
  description: 'enforce valid `v-text` directives',
23
- categories: ['vue3-essential', 'essential'],
23
+ categories: ['essential'],
24
24
  url: 'https://eslint.vuejs.org/rules/valid-v-text.html'
25
25
  },
26
26
  fixable: null,
@@ -20,7 +20,7 @@ module.exports = {
20
20
  type: 'problem',
21
21
  docs: {
22
22
  description: 'enforce valid `wx:elif` directives',
23
- categories: ['vue3-essential', 'essential'],
23
+ categories: ['mpx-essential'],
24
24
  url: 'https://eslint.vuejs.org/rules/valid-wx:elif.html'
25
25
  },
26
26
  fixable: null,
@@ -20,7 +20,7 @@ module.exports = {
20
20
  type: 'problem',
21
21
  docs: {
22
22
  description: 'enforce valid `wx:else` directives',
23
- categories: ['vue3-essential', 'essential'],
23
+ categories: ['mpx-essential'],
24
24
  url: 'https://eslint.vuejs.org/rules/valid-wx:else.html'
25
25
  },
26
26
  fixable: null,
@@ -103,7 +103,7 @@ module.exports = {
103
103
  type: 'problem',
104
104
  docs: {
105
105
  description: 'enforce valid `wx:for` directives',
106
- categories: ['vue3-essential', 'essential'],
106
+ categories: [],
107
107
  url: 'https://eslint.vuejs.org/rules/valid-wx:for.html'
108
108
  },
109
109
  fixable: null,
@@ -20,7 +20,7 @@ module.exports = {
20
20
  type: 'problem',
21
21
  docs: {
22
22
  description: 'enforce valid `wx:if` directives',
23
- categories: ['vue3-essential', 'essential'],
23
+ categories: ['mpx-essential'],
24
24
  url: 'https://eslint.vuejs.org/rules/valid-v-if.html'
25
25
  },
26
26
  fixable: null,
@@ -38,7 +38,7 @@ module.exports = {
38
38
  node,
39
39
  loc: node.loc,
40
40
  message:
41
- "'wx:if' and 'wx:elif' directives can't exist on the same element. You may want 'wx:elif' directives."
41
+ "'wx:if' and 'wx:else' directives can't exist on the same element. You may want 'wx:elif' directives."
42
42
  })
43
43
  }
44
44
  if (utils.hasDirective(element, 'elif')) {
@@ -33,7 +33,7 @@ module.exports = {
33
33
  type: 'problem',
34
34
  docs: {
35
35
  description: 'enforce valid `wx:model` directives',
36
- categories: ['vue3-essential', 'essential'],
36
+ categories: ['mpx-essential'],
37
37
  url: 'https://eslint.vuejs.org/rules/valid-wx:model.html'
38
38
  },
39
39
  fixable: null,
@@ -81,15 +81,15 @@
81
81
  * @typedef { {key: string | null, value: BlockStatement | null} } ComponentComputedProperty
82
82
  */
83
83
  /**
84
- * @typedef { 'props' | 'data' | 'computed' | 'setup' | 'watch' | 'methods' } GroupName
84
+ * @typedef { 'properties' | 'data' | 'computed' | 'watch' | 'methods' } GroupName
85
85
  * @typedef { { type: 'array', name: string, groupName: GroupName, node: Literal | TemplateLiteral } } ComponentArrayPropertyData
86
86
  * @typedef { { type: 'object', name: string, groupName: GroupName, node: Identifier | Literal | TemplateLiteral, property: Property } } ComponentObjectPropertyData
87
87
  * @typedef { ComponentArrayPropertyData | ComponentObjectPropertyData } ComponentPropertyData
88
88
  */
89
89
  /**
90
- * @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').VueObjectType} VueObjectType
91
- * @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').VueObjectData} VueObjectData
92
- * @typedef {import('../../typings/eslint-plugin-vue/util-types/utils').VueVisitor} VueVisitor
90
+ * @typedef {import('../../typings/eslint-plugin-mpx/util-types/utils').VueObjectType} VueObjectType
91
+ * @typedef {import('../../typings/eslint-plugin-mpx/util-types/utils').VueObjectData} VueObjectData
92
+ * @typedef {import('../../typings/eslint-plugin-mpx/util-types/utils').VueVisitor} VueVisitor
93
93
  */
94
94
 
95
95
  // ------------------------------------------------------------------------------
@@ -670,8 +670,7 @@ module.exports = {
670
670
  return (
671
671
  p.type === 'Property' &&
672
672
  p.key.type === 'Identifier' &&
673
- (p.key.name === 'props' ||
674
- p.key.name === 'properties' ) &&
673
+ (p.key.name === 'props' || p.key.name === 'properties') &&
675
674
  (p.value.type === 'ObjectExpression' ||
676
675
  p.value.type === 'ArrayExpression')
677
676
  )
@@ -1489,7 +1488,11 @@ module.exports = {
1489
1488
  const tokensL = sourceCode.getTokens(left)
1490
1489
  const tokensR = sourceCode.getTokens(right)
1491
1490
 
1492
- if (tokensL.length !== tokensR.length) {
1491
+ if (
1492
+ tokensL.length !== tokensR.length ||
1493
+ sourceCode.getTokenBefore(left).value !==
1494
+ sourceCode.getTokenBefore(right).value
1495
+ ) {
1493
1496
  return false
1494
1497
  }
1495
1498
  for (let i = 0; i < tokensL.length; ++i) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-mpx",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
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",
51
52
  "eslint-utils": "^2.1.0",
52
- "mpx-eslint-parser": "0.0.5",
53
53
  "natural-compare": "^1.4.0",
54
54
  "semver": "^7.3.2",
55
55
  "vue-eslint-parser": "^7.1.0"