eslint-plugin-mpx 0.2.10 → 0.2.11

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.
@@ -14,6 +14,7 @@ module.exports = {
14
14
  'mpx/valid-wx-elif': 'error',
15
15
  'mpx/valid-wx-model': 'error',
16
16
  // 'mpx/script-setup-uses-vars': 'error',
17
+ 'mpx/valid-initdata': 'error',
17
18
  'mpx/valid-setup-define-expose': 'error',
18
19
  'mpx/no-deprecated-mpx-createfunction': 'error',
19
20
  'mpx/no-deprecated-watch-second-param': 'error',
@@ -15,11 +15,25 @@ function commonFunction(value, list) {
15
15
  if (
16
16
  item.type === 'SpreadElement' &&
17
17
  item.argument &&
18
- item.argument.arguments &&
19
- item.argument.arguments[0] &&
20
- item.argument.arguments[0].elements
18
+ item.argument.arguments
21
19
  ) {
22
- const args = item.argument.arguments[0].elements
20
+ let args = []
21
+ if (item.argument.arguments[0]) {
22
+ if (item.argument.arguments[0].elements) {
23
+ args = item.argument.arguments[0].elements
24
+ }
25
+ } else {
26
+ if (item.argument.arguments.arguments) {
27
+ const elements = item.argument.arguments.arguments.elements
28
+ if (elements) {
29
+ elements.forEach((row) => {
30
+ if (row.type === 'ArrayExpression') {
31
+ args = row.elements
32
+ }
33
+ })
34
+ }
35
+ }
36
+ }
23
37
  args.forEach((item) => {
24
38
  list.add(item.value)
25
39
  })
@@ -261,7 +275,12 @@ module.exports = {
261
275
  commonFunction(node.value, computedSet)
262
276
  }
263
277
  if (node.key.name === 'initData') {
264
- handleInitData(node.value.properties, propsSet)
278
+ if (
279
+ node.parent.parent.callee &&
280
+ node.parent.parent.callee.name === 'createComponent'
281
+ ) {
282
+ handleInitData(node.value.properties, propsSet)
283
+ }
265
284
  }
266
285
  }
267
286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-mpx",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Official ESLint plugin for Mpx.js",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {