eslint-plugin-mpx 0.2.20-3 → 0.2.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
@@ -24,12 +24,11 @@ https://mpx-ecology.github.io/eslint-plugin-mpx/
24
24
 
25
25
  Add `mpx` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
26
26
 
27
- ```json
28
- {
29
- "extends": [
30
- "plugin:mpx/mpx-essential"
31
- ]
32
- }
27
+ ```js
28
+ const eslintPluginMpx = require('eslint-plugin-mpx')
29
+ module.exports = [
30
+ ...eslintPluginMpx.configs['flat/composition-api-essential']
31
+ ]
33
32
  ```
34
33
 
35
34
 
@@ -14,10 +14,28 @@ module.exports = [
14
14
  files: ['*.mpx', '**/*.mpx'],
15
15
  languageOptions: {
16
16
  parser: require('mpx-eslint-parser'),
17
- sourceType: 'module'
18
- },
19
- rules: {
20
- 'mpx/comment-directive': 'error'
17
+ sourceType: 'module',
18
+ globals: {
19
+ wx: 'readonly',
20
+ my: 'readonly',
21
+ swan: 'readonly',
22
+ qq: 'readonly',
23
+ tt: 'readonly',
24
+ jd: 'readonly',
25
+ qa: 'readonly',
26
+ dd: 'readonly',
27
+ getCurrentPages: 'readonly',
28
+ getRegExp: 'readonly',
29
+ getApp: 'readonly',
30
+ App: 'readonly',
31
+ Page: 'readonly',
32
+ Component: 'readonly',
33
+ Behavior: 'readonly',
34
+ requirePlugin: 'readonly',
35
+ requireMiniProgram: 'readonly',
36
+ __mpx_mode__: 'readonly',
37
+ __mpx_env__: 'readonly'
38
+ }
21
39
  },
22
40
  processor: 'mpx/mpx'
23
41
  }
@@ -2,10 +2,11 @@
2
2
  const config = require('./base.js')
3
3
 
4
4
  module.exports = [
5
- ...config,
6
5
  {
6
+ ...config[0],
7
7
  name: 'mpx/composition-api-essential/rules',
8
8
  rules: {
9
+ 'mpx/comment-directive': 'error',
9
10
  'mpx/html-end-tags': 'error',
10
11
  'mpx/no-dupe-wx-elif': 'error',
11
12
  'mpx/no-duplicate-attributes': 'error',
@@ -2,10 +2,11 @@
2
2
  const config = require('./base.js')
3
3
 
4
4
  module.exports = [
5
- ...config,
6
5
  {
6
+ ...config[0],
7
7
  name: 'mpx/mpx-essential/rules',
8
8
  rules: {
9
+ 'mpx/comment-directive': 'error',
9
10
  'mpx/html-end-tags': 'error',
10
11
  'mpx/no-arrow-functions-in-watch': 'error',
11
12
  'mpx/no-async-in-computed-properties': 'error',
package/lib/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { Linter } from 'eslint'
2
+
3
+ declare const mpx: {
4
+ meta: any
5
+ configs: {
6
+ base: Linter.LegacyConfig
7
+ 'mpx-essential': Linter.LegacyConfig
8
+ 'composition-api-essential': Linter.LegacyConfig
9
+ 'flat/base': Linter.FlatConfig[]
10
+ 'flat/mpx-essential': Linter.FlatConfig[]
11
+ 'flat/composition-api-essential': Linter.FlatConfig[]
12
+ }
13
+ rules: Record<string, any>
14
+ processors: {
15
+ '.vue': any
16
+ vue: any
17
+ }
18
+ }
19
+
20
+ export = mpx
@@ -1235,10 +1235,10 @@ module.exports = {
1235
1235
  }
1236
1236
  },
1237
1237
  onCodePathSegmentStart(segment) {
1238
- funcInfo?.currentSegments.push(segment)
1238
+ funcInfo && funcInfo.currentSegments.push(segment)
1239
1239
  },
1240
1240
  onCodePathSegmentEnd() {
1241
- funcInfo?.currentSegments.pop()
1241
+ funcInfo && funcInfo.currentSegments.pop()
1242
1242
  },
1243
1243
  onCodePathEnd() {
1244
1244
  funcInfo = funcInfo && funcInfo.funcInfo
@@ -1566,7 +1566,7 @@ function createRequire(filename) {
1566
1566
 
1567
1567
  /**
1568
1568
  * Register the given visitor to parser services.
1569
- * If the parser service of `vue-eslint-parser` was not found,
1569
+ * If the parser service of `mpx-eslint-parser` was not found,
1570
1570
  * this generates a warning.
1571
1571
  *
1572
1572
  * @param {RuleContext} context The rule context to use parser services.
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "eslint-plugin-mpx",
3
- "version": "0.2.20-3",
3
+ "version": "0.2.21",
4
4
  "description": "Official ESLint plugin for Mpx.js",
5
5
  "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "scripts": {
7
8
  "start": "npm run test:base -- --watch --growl",
8
9
  "test": "mocha \"tests/lib/**/*.js\" --reporter dot",
@@ -49,10 +50,9 @@
49
50
  },
50
51
  "dependencies": {
51
52
  "eslint-utils": "^2.1.0",
52
- "mpx-eslint-parser": "0.0.9",
53
+ "mpx-eslint-parser": "^0.0.13",
53
54
  "natural-compare": "^1.4.0",
54
- "semver": "^7.3.2",
55
- "vue-eslint-parser": "^7.1.0"
55
+ "semver": "^7.3.2"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/eslint": "^8.4.2",