eslint-plugin-mpx 0.2.26 → 0.2.28

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.
@@ -11,6 +11,7 @@
11
11
  const utils = require('../utils')
12
12
  function commonFunction(value, list) {
13
13
  const props = value.properties
14
+ if (!props) return false
14
15
  for (const item of props) {
15
16
  if (
16
17
  item.type === 'SpreadElement' &&
@@ -74,7 +75,7 @@ function checkInInitData(
74
75
  // 属性值存在 || 说明有兜底,跳过检测
75
76
  if (nodeName.includes('||')) return
76
77
  // 检测当前属性值在initData 和 computedSet 导出情况,computedSet 返回不会解构出来,做一个兼容
77
- if (!propsSet.has(nodeName) && computedSet.has(nodeName.split('.')[0])) {
78
+ if (!propsSet.has(nodeName) && computedSet.has(nodeName.split('.')?.[0])) {
78
79
  context.report({
79
80
  node,
80
81
  messageId: 'unexpected',
@@ -191,7 +192,7 @@ module.exports = {
191
192
  propsSet,
192
193
  context,
193
194
  node,
194
- node.value.value.match(reg)[0],
195
+ node.value.value.match(reg)?.[0],
195
196
  hasInitData
196
197
  )
197
198
  checkInitData(
@@ -200,7 +201,7 @@ module.exports = {
200
201
  hasInitData,
201
202
  context,
202
203
  node,
203
- node.value.value.match(reg)[0]
204
+ node.value.value.match(reg)?.[0]
204
205
  )
205
206
  }
206
207
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "eslint-plugin-mpx",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "Official ESLint plugin for Mpx.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "scripts": {
8
8
  "start": "npm run test:base -- --watch --growl",
9
9
  "test": "mocha \"tests/lib/**/*.js\" --reporter dot",
10
- "test:only": "mocha \"tests/lib/rules/valid-setup-define-expose.js\" --reporter dot",
10
+ "test:only": "mocha \"tests/lib/rules/valid-initdata.js\" --reporter dot",
11
11
  "debug": "mocha --inspect \"tests/lib/**/*.js\" --reporter dot --timeout 60000",
12
12
  "cover": "npm run cover:test && npm run cover:report",
13
13
  "cover:test": "nyc npm run test -- --timeout 60000",