eslint-plugin-mpx 0.2.19 → 0.2.20-1
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/lib/configs/flat/base.js +22 -0
- package/lib/configs/flat/composition-api-essential.js +24 -0
- package/lib/configs/flat/mpx-essential.js +30 -0
- package/lib/index.js +7 -2
- package/lib/meta.js +3 -0
- package/lib/processor.js +24 -14
- package/lib/rules/comment-directive.js +16 -15
- package/lib/rules/component-tags-order.js +8 -7
- package/lib/rules/eqeqeq.js +2 -1
- package/lib/rules/html-end-tags.js +5 -2
- package/lib/rules/no-arrow-functions-in-watch.js +5 -2
- package/lib/rules/no-async-in-computed-properties.js +17 -14
- package/lib/rules/no-deprecated-lifecycle.js +2 -2
- package/lib/rules/no-deprecated-mpx-createfunction.js +9 -6
- package/lib/rules/no-deprecated-watch-second-param.js +9 -6
- package/lib/rules/no-dupe-keys.js +10 -4
- package/lib/rules/no-dupe-wx-elif.js +10 -7
- package/lib/rules/no-duplicate-attributes.js +5 -3
- package/lib/rules/no-parsing-error.js +6 -2
- package/lib/rules/no-reserved-keys.js +12 -6
- package/lib/rules/no-side-effects-in-computed-properties.js +8 -6
- package/lib/rules/return-in-computed-property.js +7 -5
- package/lib/rules/script-indent.js +6 -3
- package/lib/rules/script-setup-uses-vars.js +4 -2
- package/lib/rules/syntaxes/slot-attribute.js +1 -0
- package/lib/rules/syntaxes/slot-scope-attribute.js +1 -0
- package/lib/rules/syntaxes/v-slot.js +3 -2
- package/lib/rules/valid-attribute-value.js +10 -5
- package/lib/rules/valid-component-range.js +21 -15
- package/lib/rules/valid-initdata.js +39 -36
- package/lib/rules/valid-properties.js +8 -5
- package/lib/rules/valid-setup-define-expose.js +35 -13
- package/lib/rules/valid-swiper-item-style.js +7 -4
- package/lib/rules/valid-template-quote.js +6 -3
- package/lib/rules/valid-wx-elif.js +18 -10
- package/lib/rules/valid-wx-else.js +18 -10
- package/lib/rules/valid-wx-if.js +14 -8
- package/lib/rules/valid-wx-key.js +27 -14
- package/lib/utils/casing.js +7 -7
- package/lib/utils/indent-common.js +32 -32
- package/lib/utils/index.js +92 -84
- package/lib/utils/regexp.js +2 -2
- package/lib/utils/scope.js +30 -0
- package/package.json +15 -14
- package/lib/.DS_Store +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTANT!
|
|
3
|
+
* This file has been automatically generated,
|
|
4
|
+
* in order to update its content execute "npm run update"
|
|
5
|
+
*/
|
|
6
|
+
module.exports = [
|
|
7
|
+
{
|
|
8
|
+
name: 'mpx/base',
|
|
9
|
+
plugins: {
|
|
10
|
+
get mpx() {
|
|
11
|
+
return require('../../index')
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: require('mpx-eslint-parser'),
|
|
16
|
+
sourceType: 'module'
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
'vue/comment-directive': 'error'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const config = require('./base.js')
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
...config,
|
|
6
|
+
{
|
|
7
|
+
name: 'mpx/composition-api-essential/rules',
|
|
8
|
+
rules: {
|
|
9
|
+
'mpx/html-end-tags': 'error',
|
|
10
|
+
'mpx/no-dupe-wx-elif': 'error',
|
|
11
|
+
'mpx/no-duplicate-attributes': 'error',
|
|
12
|
+
'mpx/valid-wx-if': 'error',
|
|
13
|
+
'mpx/valid-wx-else': 'error',
|
|
14
|
+
'mpx/valid-wx-elif': 'error',
|
|
15
|
+
'mpx/valid-wx-model': 'error',
|
|
16
|
+
// 'mpx/script-setup-uses-vars': 'error',
|
|
17
|
+
'mpx/valid-initdata': 'warn',
|
|
18
|
+
'mpx/valid-setup-define-expose': 'error',
|
|
19
|
+
'mpx/no-deprecated-mpx-createfunction': 'error',
|
|
20
|
+
'mpx/no-deprecated-watch-second-param': 'error',
|
|
21
|
+
'mpx/no-deprecated-lifecycle': 'error'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const config = require('./base.js')
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
...config,
|
|
6
|
+
{
|
|
7
|
+
name: 'mpx/mpx-essential/rules',
|
|
8
|
+
rules: {
|
|
9
|
+
'mpx/html-end-tags': 'error',
|
|
10
|
+
'mpx/no-arrow-functions-in-watch': 'error',
|
|
11
|
+
'mpx/no-async-in-computed-properties': 'error',
|
|
12
|
+
'mpx/no-dupe-keys': 'error',
|
|
13
|
+
'mpx/no-dupe-wx-elif': 'error',
|
|
14
|
+
'mpx/no-duplicate-attributes': 'error',
|
|
15
|
+
'mpx/no-reserved-keys': 'error',
|
|
16
|
+
'mpx/no-side-effects-in-computed-properties': 'error',
|
|
17
|
+
'mpx/return-in-computed-property': 'error',
|
|
18
|
+
'mpx/valid-wx-if': 'error',
|
|
19
|
+
'mpx/valid-wx-else': 'error',
|
|
20
|
+
'mpx/valid-wx-elif': 'error',
|
|
21
|
+
'mpx/valid-wx-model': 'error',
|
|
22
|
+
'mpx/valid-swiper-item-style': 'error',
|
|
23
|
+
'mpx/valid-wx-key': 'error',
|
|
24
|
+
'mpx/valid-attribute-value': 'error',
|
|
25
|
+
'mpx/valid-template-quote': 'error',
|
|
26
|
+
'mpx/valid-component-range': 'error',
|
|
27
|
+
'mpx/valid-properties': 'error'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
9
|
+
meta: require('./meta'),
|
|
9
10
|
rules: {
|
|
10
11
|
'comment-directive': require('./rules/comment-directive'),
|
|
11
12
|
'component-tags-order': require('./rules/component-tags-order'),
|
|
@@ -41,9 +42,13 @@ module.exports = {
|
|
|
41
42
|
configs: {
|
|
42
43
|
base: require('./configs/base'),
|
|
43
44
|
'mpx-essential': require('./configs/mpx-essential'),
|
|
44
|
-
'composition-api-essential': require('./configs/composition-api-essential')
|
|
45
|
+
'composition-api-essential': require('./configs/composition-api-essential'),
|
|
46
|
+
'flat/base': require('./configs/base'),
|
|
47
|
+
'flat/mpx-essential': require('./configs/mpx-essential'),
|
|
48
|
+
'flat/composition-api-essential': require('./configs/composition-api-essential')
|
|
45
49
|
},
|
|
46
50
|
processors: {
|
|
47
|
-
'.mpx': require('./processor')
|
|
51
|
+
'.mpx': require('./processor'),
|
|
52
|
+
mpx: require('./processor')
|
|
48
53
|
}
|
|
49
54
|
}
|
package/lib/meta.js
ADDED
package/lib/processor.js
CHANGED
|
@@ -46,48 +46,58 @@ module.exports = {
|
|
|
46
46
|
const directiveType = message.messageId
|
|
47
47
|
const data = message.message.split(' ')
|
|
48
48
|
switch (directiveType) {
|
|
49
|
-
case 'disableBlock':
|
|
49
|
+
case 'disableBlock': {
|
|
50
50
|
state.block.disableAllKeys.add(data[1])
|
|
51
51
|
break
|
|
52
|
-
|
|
52
|
+
}
|
|
53
|
+
case 'disableLine': {
|
|
53
54
|
state.line.disableAllKeys.add(data[1])
|
|
54
55
|
break
|
|
55
|
-
|
|
56
|
+
}
|
|
57
|
+
case 'enableBlock': {
|
|
56
58
|
state.block.disableAllKeys.clear()
|
|
57
59
|
break
|
|
58
|
-
|
|
60
|
+
}
|
|
61
|
+
case 'enableLine': {
|
|
59
62
|
state.line.disableAllKeys.clear()
|
|
60
63
|
break
|
|
61
|
-
|
|
64
|
+
}
|
|
65
|
+
case 'disableBlockRule': {
|
|
62
66
|
addDisableRule(state.block.disableRuleKeys, data[1], data[2])
|
|
63
67
|
break
|
|
64
|
-
|
|
68
|
+
}
|
|
69
|
+
case 'disableLineRule': {
|
|
65
70
|
addDisableRule(state.line.disableRuleKeys, data[1], data[2])
|
|
66
71
|
break
|
|
67
|
-
|
|
72
|
+
}
|
|
73
|
+
case 'enableBlockRule': {
|
|
68
74
|
state.block.disableRuleKeys.delete(data[1])
|
|
69
75
|
break
|
|
70
|
-
|
|
76
|
+
}
|
|
77
|
+
case 'enableLineRule': {
|
|
71
78
|
state.line.disableRuleKeys.delete(data[1])
|
|
72
79
|
break
|
|
73
|
-
|
|
80
|
+
}
|
|
81
|
+
case 'clear': {
|
|
74
82
|
state.block.disableAllKeys.clear()
|
|
75
83
|
state.block.disableRuleKeys.clear()
|
|
76
84
|
state.line.disableAllKeys.clear()
|
|
77
85
|
state.line.disableRuleKeys.clear()
|
|
78
86
|
break
|
|
79
|
-
|
|
87
|
+
}
|
|
88
|
+
default: {
|
|
80
89
|
// unused eslint-disable comments report
|
|
81
90
|
unusedDisableDirectiveReports.set(messageToKey(message), message)
|
|
82
91
|
break
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
94
|
return false
|
|
85
95
|
} else {
|
|
86
96
|
const disableDirectiveKeys = []
|
|
87
|
-
if (state.block.disableAllKeys.size) {
|
|
97
|
+
if (state.block.disableAllKeys.size > 0) {
|
|
88
98
|
disableDirectiveKeys.push(...state.block.disableAllKeys)
|
|
89
99
|
}
|
|
90
|
-
if (state.line.disableAllKeys.size) {
|
|
100
|
+
if (state.line.disableAllKeys.size > 0) {
|
|
91
101
|
disableDirectiveKeys.push(...state.line.disableAllKeys)
|
|
92
102
|
}
|
|
93
103
|
if (message.ruleId) {
|
|
@@ -101,7 +111,7 @@ module.exports = {
|
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
if (disableDirectiveKeys.length) {
|
|
114
|
+
if (disableDirectiveKeys.length > 0) {
|
|
105
115
|
// Store used eslint-disable comment key
|
|
106
116
|
usedDisableDirectiveKeys.push(...disableDirectiveKeys)
|
|
107
117
|
return false
|
|
@@ -111,7 +121,7 @@ module.exports = {
|
|
|
111
121
|
}
|
|
112
122
|
})
|
|
113
123
|
|
|
114
|
-
if (unusedDisableDirectiveReports.size) {
|
|
124
|
+
if (unusedDisableDirectiveReports.size > 0) {
|
|
115
125
|
for (const key of usedDisableDirectiveKeys) {
|
|
116
126
|
// Remove used eslint-disable comments
|
|
117
127
|
unusedDisableDirectiveReports.delete(key)
|
|
@@ -77,16 +77,16 @@ function parse(pattern, comment) {
|
|
|
77
77
|
* @returns {void}
|
|
78
78
|
*/
|
|
79
79
|
function enable(context, loc, group, rule) {
|
|
80
|
-
if (
|
|
80
|
+
if (rule) {
|
|
81
81
|
context.report({
|
|
82
82
|
loc,
|
|
83
|
-
messageId: group === 'block' ? '
|
|
83
|
+
messageId: group === 'block' ? 'enableBlockRule' : 'enableLineRule',
|
|
84
|
+
data: { rule }
|
|
84
85
|
})
|
|
85
86
|
} else {
|
|
86
87
|
context.report({
|
|
87
88
|
loc,
|
|
88
|
-
messageId: group === 'block' ? '
|
|
89
|
-
data: { rule }
|
|
89
|
+
messageId: group === 'block' ? 'enableBlock' : 'enableLine'
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -101,17 +101,17 @@ function enable(context, loc, group, rule) {
|
|
|
101
101
|
* @returns {void}
|
|
102
102
|
*/
|
|
103
103
|
function disable(context, loc, group, rule, key) {
|
|
104
|
-
if (
|
|
104
|
+
if (rule) {
|
|
105
105
|
context.report({
|
|
106
106
|
loc,
|
|
107
|
-
messageId: group === 'block' ? '
|
|
108
|
-
data: { key }
|
|
107
|
+
messageId: group === 'block' ? 'disableBlockRule' : 'disableLineRule',
|
|
108
|
+
data: { rule, key }
|
|
109
109
|
})
|
|
110
110
|
} else {
|
|
111
111
|
context.report({
|
|
112
112
|
loc,
|
|
113
|
-
messageId: group === 'block' ? '
|
|
114
|
-
data: {
|
|
113
|
+
messageId: group === 'block' ? 'disableBlock' : 'disableLine',
|
|
114
|
+
data: { key }
|
|
115
115
|
})
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -128,7 +128,7 @@ function processBlock(context, comment, reportUnusedDisableDirectives) {
|
|
|
128
128
|
const parsed = parse(COMMENT_DIRECTIVE_B, comment.value)
|
|
129
129
|
if (parsed != null) {
|
|
130
130
|
if (parsed.type === 'eslint-disable') {
|
|
131
|
-
if (parsed.rules.length) {
|
|
131
|
+
if (parsed.rules.length > 0) {
|
|
132
132
|
const rules = reportUnusedDisableDirectives
|
|
133
133
|
? reportUnusedRules(context, comment, parsed.type, parsed.rules)
|
|
134
134
|
: parsed.rules
|
|
@@ -148,7 +148,7 @@ function processBlock(context, comment, reportUnusedDisableDirectives) {
|
|
|
148
148
|
disable(context, comment.loc.start, 'block', null, key)
|
|
149
149
|
}
|
|
150
150
|
} else {
|
|
151
|
-
if (parsed.rules.length) {
|
|
151
|
+
if (parsed.rules.length > 0) {
|
|
152
152
|
for (const rule of parsed.rules) {
|
|
153
153
|
enable(context, comment.loc.start, 'block', rule.ruleId)
|
|
154
154
|
}
|
|
@@ -173,7 +173,7 @@ function processLine(context, comment, reportUnusedDisableDirectives) {
|
|
|
173
173
|
const line =
|
|
174
174
|
comment.loc.start.line + (parsed.type === 'eslint-disable-line' ? 0 : 1)
|
|
175
175
|
const column = -1
|
|
176
|
-
if (parsed.rules.length) {
|
|
176
|
+
if (parsed.rules.length > 0) {
|
|
177
177
|
const rules = reportUnusedDisableDirectives
|
|
178
178
|
? reportUnusedRules(context, comment, parsed.type, parsed.rules)
|
|
179
179
|
: parsed.rules
|
|
@@ -285,7 +285,7 @@ module.exports = {
|
|
|
285
285
|
meta: {
|
|
286
286
|
type: 'problem',
|
|
287
287
|
docs: {
|
|
288
|
-
description: 'support comment-directives in `<template>`',
|
|
288
|
+
description: 'require support comment-directives in `<template>`',
|
|
289
289
|
categories: ['base'],
|
|
290
290
|
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/comment-directive.html'
|
|
291
291
|
},
|
|
@@ -322,11 +322,12 @@ module.exports = {
|
|
|
322
322
|
*/
|
|
323
323
|
create(context) {
|
|
324
324
|
const options = context.options[0] || {}
|
|
325
|
+
const sourceCode = context.getSourceCode()
|
|
325
326
|
/** @type {boolean} */
|
|
326
327
|
const reportUnusedDisableDirectives = options.reportUnusedDisableDirectives
|
|
327
328
|
const documentFragment =
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
sourceCode.parserServices.getDocumentFragment &&
|
|
330
|
+
sourceCode.parserServices.getDocumentFragment()
|
|
330
331
|
|
|
331
332
|
return {
|
|
332
333
|
Program(node) {
|
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
|
58
58
|
/** @type {(string|string[])[]} */
|
|
59
59
|
const orderOptions =
|
|
60
60
|
(context.options[0] && context.options[0].order) || DEFAULT_ORDER
|
|
61
|
-
orderOptions.
|
|
61
|
+
for (const [index, nameOrNames] of orderOptions.entries()) {
|
|
62
62
|
if (Array.isArray(nameOrNames)) {
|
|
63
63
|
for (const name of nameOrNames) {
|
|
64
64
|
orderMap.set(name, index)
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
} else {
|
|
67
67
|
orderMap.set(nameOrNames, index)
|
|
68
68
|
}
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @param {string} name
|
|
@@ -75,9 +75,10 @@ module.exports = {
|
|
|
75
75
|
const num = orderMap.get(name)
|
|
76
76
|
return num == null ? -1 : num
|
|
77
77
|
}
|
|
78
|
+
const sourceCode = context.getSourceCode()
|
|
78
79
|
const documentFragment =
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
sourceCode.parserServices.getDocumentFragment &&
|
|
81
|
+
sourceCode.parserServices.getDocumentFragment()
|
|
81
82
|
|
|
82
83
|
function getTopLevelHTMLElements() {
|
|
83
84
|
if (documentFragment) {
|
|
@@ -110,10 +111,10 @@ module.exports = {
|
|
|
110
111
|
}
|
|
111
112
|
const elements = getTopLevelHTMLElements()
|
|
112
113
|
|
|
113
|
-
elements.
|
|
114
|
+
for (const [index, element] of elements.entries()) {
|
|
114
115
|
const expectedIndex = getOrderPosition(element.name)
|
|
115
116
|
if (expectedIndex < 0) {
|
|
116
|
-
|
|
117
|
+
continue
|
|
117
118
|
}
|
|
118
119
|
const firstUnordered = elements
|
|
119
120
|
.slice(0, index)
|
|
@@ -124,7 +125,7 @@ module.exports = {
|
|
|
124
125
|
if (firstUnordered) {
|
|
125
126
|
report(element, firstUnordered)
|
|
126
127
|
}
|
|
127
|
-
}
|
|
128
|
+
}
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
}
|
package/lib/rules/eqeqeq.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable internal/no-invalid-meta-docs-categories */
|
|
1
2
|
/**
|
|
2
3
|
* @author Toru Nagashima
|
|
3
4
|
*/
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
|
|
6
7
|
const { wrapCoreRule } = require('../utils')
|
|
7
8
|
|
|
8
|
-
// eslint-disable-next-line
|
|
9
|
+
// eslint-disable-next-line internal/no-invalid-meta
|
|
9
10
|
module.exports = wrapCoreRule('eqeqeq', {
|
|
10
11
|
applyDocument: true
|
|
11
12
|
})
|
|
@@ -24,7 +24,10 @@ module.exports = {
|
|
|
24
24
|
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/html-end-tags.html'
|
|
25
25
|
},
|
|
26
26
|
fixable: 'code',
|
|
27
|
-
schema: []
|
|
27
|
+
schema: [],
|
|
28
|
+
messages: {
|
|
29
|
+
endTag: "'<{{name}}>' should have end tag."
|
|
30
|
+
}
|
|
28
31
|
},
|
|
29
32
|
/** @param {RuleContext} context */
|
|
30
33
|
create(context) {
|
|
@@ -48,7 +51,7 @@ module.exports = {
|
|
|
48
51
|
context.report({
|
|
49
52
|
node: node.startTag,
|
|
50
53
|
loc: node.startTag.loc,
|
|
51
|
-
|
|
54
|
+
messageId: 'endTag',
|
|
52
55
|
data: { name },
|
|
53
56
|
fix: (fixer) => fixer.insertTextAfter(node, `</${name}>`)
|
|
54
57
|
})
|
|
@@ -14,7 +14,10 @@ module.exports = {
|
|
|
14
14
|
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-arrow-functions-in-watch.html'
|
|
15
15
|
},
|
|
16
16
|
fixable: null,
|
|
17
|
-
schema: []
|
|
17
|
+
schema: [],
|
|
18
|
+
messages: {
|
|
19
|
+
watcher: 'You should not use an arrow function to define a watcher.'
|
|
20
|
+
}
|
|
18
21
|
},
|
|
19
22
|
/** @param {RuleContext} context */
|
|
20
23
|
create(context) {
|
|
@@ -34,7 +37,7 @@ module.exports = {
|
|
|
34
37
|
) {
|
|
35
38
|
context.report({
|
|
36
39
|
node: property,
|
|
37
|
-
|
|
40
|
+
messageId: 'watcher'
|
|
38
41
|
})
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -11,16 +11,16 @@ const utils = require('../utils')
|
|
|
11
11
|
* @typedef {import('../utils').ComponentComputedProperty} ComponentComputedProperty
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const PROMISE_FUNCTIONS = ['then', 'catch', 'finally']
|
|
14
|
+
const PROMISE_FUNCTIONS = new Set(['then', 'catch', 'finally'])
|
|
15
15
|
|
|
16
|
-
const PROMISE_METHODS = ['all', 'race', 'reject', 'resolve']
|
|
16
|
+
const PROMISE_METHODS = new Set(['all', 'race', 'reject', 'resolve'])
|
|
17
17
|
|
|
18
|
-
const TIMED_FUNCTIONS = [
|
|
18
|
+
const TIMED_FUNCTIONS = new Set([
|
|
19
19
|
'setTimeout',
|
|
20
20
|
'setInterval',
|
|
21
21
|
'setImmediate',
|
|
22
22
|
'requestAnimationFrame'
|
|
23
|
-
]
|
|
23
|
+
])
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @param {CallExpression} node
|
|
@@ -30,14 +30,14 @@ function isTimedFunction(node) {
|
|
|
30
30
|
return (
|
|
31
31
|
((node.type === 'CallExpression' &&
|
|
32
32
|
callee.type === 'Identifier' &&
|
|
33
|
-
TIMED_FUNCTIONS.
|
|
33
|
+
TIMED_FUNCTIONS.has(callee.name)) ||
|
|
34
34
|
(node.type === 'CallExpression' &&
|
|
35
35
|
callee.type === 'MemberExpression' &&
|
|
36
36
|
callee.object.type === 'Identifier' &&
|
|
37
37
|
callee.object.name === 'window' &&
|
|
38
38
|
callee.property.type === 'Identifier' &&
|
|
39
|
-
TIMED_FUNCTIONS.
|
|
40
|
-
node.arguments.length
|
|
39
|
+
TIMED_FUNCTIONS.has(callee.property.name))) &&
|
|
40
|
+
node.arguments.length > 0
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -50,11 +50,11 @@ function isPromise(node) {
|
|
|
50
50
|
return (
|
|
51
51
|
// hello.PROMISE_FUNCTION()
|
|
52
52
|
(callee.property.type === 'Identifier' &&
|
|
53
|
-
PROMISE_FUNCTIONS.
|
|
53
|
+
PROMISE_FUNCTIONS.has(callee.property.name)) || // Promise.PROMISE_METHOD()
|
|
54
54
|
(callee.object.type === 'Identifier' &&
|
|
55
55
|
callee.object.name === 'Promise' &&
|
|
56
56
|
callee.property.type === 'Identifier' &&
|
|
57
|
-
PROMISE_METHODS.
|
|
57
|
+
PROMISE_METHODS.has(callee.property.name))
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
60
|
return false
|
|
@@ -73,7 +73,11 @@ module.exports = {
|
|
|
73
73
|
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-async-in-computed-properties.html'
|
|
74
74
|
},
|
|
75
75
|
fixable: null,
|
|
76
|
-
schema: []
|
|
76
|
+
schema: [],
|
|
77
|
+
messages: {
|
|
78
|
+
computed:
|
|
79
|
+
'Unexpected {{expressionName}} in "{{propertyName}}" computed property.'
|
|
80
|
+
}
|
|
77
81
|
},
|
|
78
82
|
/** @param {RuleContext} context */
|
|
79
83
|
create(context) {
|
|
@@ -121,7 +125,7 @@ module.exports = {
|
|
|
121
125
|
* @param {ComponentComputedProperty[]} computedProperties
|
|
122
126
|
*/
|
|
123
127
|
function verify(node, targetBody, type, computedProperties = []) {
|
|
124
|
-
|
|
128
|
+
for (const cp of computedProperties) {
|
|
125
129
|
if (
|
|
126
130
|
cp.value &&
|
|
127
131
|
node.loc.start.line >= cp.value.loc.start.line &&
|
|
@@ -130,15 +134,14 @@ module.exports = {
|
|
|
130
134
|
) {
|
|
131
135
|
context.report({
|
|
132
136
|
node,
|
|
133
|
-
|
|
134
|
-
'Unexpected {{expressionName}} in "{{propertyName}}" computed property.',
|
|
137
|
+
messageId: 'computed',
|
|
135
138
|
data: {
|
|
136
139
|
expressionName: expressionTypes[type],
|
|
137
140
|
propertyName: cp.key || 'unknown'
|
|
138
141
|
}
|
|
139
142
|
})
|
|
140
143
|
}
|
|
141
|
-
}
|
|
144
|
+
}
|
|
142
145
|
}
|
|
143
146
|
return utils.defineMpxVisitor(context, {
|
|
144
147
|
onMpxObjectEnter(node) {
|
|
@@ -10,11 +10,11 @@ module.exports = {
|
|
|
10
10
|
meta: {
|
|
11
11
|
type: 'problem',
|
|
12
12
|
docs: {
|
|
13
|
-
description: 'pageShow/pageHide废弃的生命周期',
|
|
13
|
+
description: 'disallow pageShow/pageHide废弃的生命周期',
|
|
14
14
|
categories: ['composition-api-essential'],
|
|
15
15
|
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-deprecated-lifecycle.html'
|
|
16
16
|
},
|
|
17
|
-
fixable:
|
|
17
|
+
fixable: null,
|
|
18
18
|
schema: [],
|
|
19
19
|
messages: {
|
|
20
20
|
deprecatedPageShow:
|
|
@@ -9,12 +9,16 @@ module.exports = {
|
|
|
9
9
|
meta: {
|
|
10
10
|
type: 'problem',
|
|
11
11
|
docs: {
|
|
12
|
-
description: 'mpx.create*调用方式已经被废弃',
|
|
12
|
+
description: 'disallow mpx.create*调用方式已经被废弃',
|
|
13
13
|
categories: ['composition-api-essential'],
|
|
14
|
-
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-deprecated-mpx-createfunction'
|
|
14
|
+
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-deprecated-mpx-createfunction.html'
|
|
15
15
|
},
|
|
16
|
-
fixable:
|
|
17
|
-
schema: []
|
|
16
|
+
fixable: null,
|
|
17
|
+
schema: [],
|
|
18
|
+
messages: {
|
|
19
|
+
method:
|
|
20
|
+
'The Mpx object of default export is no longer attached to the {{name}} runtime method.'
|
|
21
|
+
}
|
|
18
22
|
},
|
|
19
23
|
/** @param {RuleContext} context */
|
|
20
24
|
create(context) {
|
|
@@ -35,8 +39,7 @@ module.exports = {
|
|
|
35
39
|
) {
|
|
36
40
|
context.report({
|
|
37
41
|
node,
|
|
38
|
-
|
|
39
|
-
'The Mpx object of default export is no longer attached to the {{name}} runtime method.',
|
|
42
|
+
messageId: 'method',
|
|
40
43
|
data: { name: node.expression.callee.property.name }
|
|
41
44
|
})
|
|
42
45
|
}
|
|
@@ -9,12 +9,16 @@ module.exports = {
|
|
|
9
9
|
meta: {
|
|
10
10
|
type: 'problem',
|
|
11
11
|
docs: {
|
|
12
|
-
description: 'watch第二个参数统一为函数,不再提供对象',
|
|
12
|
+
description: 'require watch第二个参数统一为函数,不再提供对象',
|
|
13
13
|
categories: ['composition-api-essential'],
|
|
14
|
-
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-deprecated-watch-second-param'
|
|
14
|
+
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-deprecated-watch-second-param.html'
|
|
15
15
|
},
|
|
16
|
-
fixable:
|
|
17
|
-
schema: []
|
|
16
|
+
fixable: null,
|
|
17
|
+
schema: [],
|
|
18
|
+
messages: {
|
|
19
|
+
attribute:
|
|
20
|
+
'The watch API no longer accepts the second parameter as an object with the handler attribute.'
|
|
21
|
+
}
|
|
18
22
|
},
|
|
19
23
|
/** @param {RuleContext} context */
|
|
20
24
|
create(context) {
|
|
@@ -30,8 +34,7 @@ module.exports = {
|
|
|
30
34
|
) {
|
|
31
35
|
context.report({
|
|
32
36
|
node,
|
|
33
|
-
|
|
34
|
-
'The watch API no longer accepts the second parameter as an object with the handler attribute.'
|
|
37
|
+
messageId: 'attribute'
|
|
35
38
|
})
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -35,26 +35,32 @@ module.exports = {
|
|
|
35
35
|
},
|
|
36
36
|
additionalProperties: false
|
|
37
37
|
}
|
|
38
|
-
]
|
|
38
|
+
],
|
|
39
|
+
messages: {
|
|
40
|
+
name: "Duplicated key '{{name}}'."
|
|
41
|
+
}
|
|
39
42
|
},
|
|
40
43
|
/** @param {RuleContext} context */
|
|
41
44
|
create(context) {
|
|
42
45
|
const options = context.options[0] || {}
|
|
43
|
-
const groups = new Set(GROUP_NAMES
|
|
46
|
+
const groups = new Set([...GROUP_NAMES, ...(options.groups || [])])
|
|
44
47
|
|
|
45
48
|
// ----------------------------------------------------------------------
|
|
46
49
|
// Public
|
|
47
50
|
// ----------------------------------------------------------------------
|
|
48
51
|
|
|
49
52
|
return utils.executeOnMpx(context, (obj) => {
|
|
53
|
+
/**
|
|
54
|
+
* @type {string[]}
|
|
55
|
+
*/
|
|
50
56
|
const usedNames = []
|
|
51
57
|
const properties = utils.iterateProperties(obj, groups)
|
|
52
58
|
|
|
53
59
|
for (const o of properties) {
|
|
54
|
-
if (usedNames.
|
|
60
|
+
if (usedNames.includes(o.name)) {
|
|
55
61
|
context.report({
|
|
56
62
|
node: o.node,
|
|
57
|
-
|
|
63
|
+
messageId: 'name',
|
|
58
64
|
data: {
|
|
59
65
|
name: o.name
|
|
60
66
|
}
|
|
@@ -95,9 +95,10 @@ module.exports = {
|
|
|
95
95
|
},
|
|
96
96
|
/** @param {RuleContext} context */
|
|
97
97
|
create(context) {
|
|
98
|
+
const sourceCode = context.getSourceCode()
|
|
98
99
|
const tokenStore =
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
sourceCode.parserServices.getTemplateBodyTokenStore &&
|
|
101
|
+
sourceCode.parserServices.getTemplateBodyTokenStore()
|
|
101
102
|
/**
|
|
102
103
|
* Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
|
|
103
104
|
* represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
|
|
@@ -139,17 +140,19 @@ module.exports = {
|
|
|
139
140
|
operandsB.operands.some((operandB) => equal(operandA, operandB))
|
|
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
145
|
const text = sourceCode.getText(node).slice(-3)
|
|
146
146
|
if (
|
|
147
|
+
// @ts-ignore
|
|
147
148
|
!node.value ||
|
|
149
|
+
// @ts-ignore
|
|
148
150
|
!node.value.expression ||
|
|
149
151
|
!['}}"', "}}'"].includes(text)
|
|
150
152
|
) {
|
|
151
153
|
return
|
|
152
154
|
}
|
|
155
|
+
// @ts-ignore
|
|
153
156
|
const test = node.value.expression
|
|
154
157
|
const conditionsToCheck =
|
|
155
158
|
test.type === 'LogicalExpression' && test.operator === '&&'
|
|
@@ -158,6 +161,7 @@ module.exports = {
|
|
|
158
161
|
const listToCheck = conditionsToCheck.map(buildOrOperands)
|
|
159
162
|
|
|
160
163
|
/** @type {VElement | null} */
|
|
164
|
+
// @ts-ignore
|
|
161
165
|
let current = node.parent.parent
|
|
162
166
|
while (current && (current = utils.prevSibling(current))) {
|
|
163
167
|
const vIf = utils.getDirective(current, 'if')
|
|
@@ -172,13 +176,12 @@ module.exports = {
|
|
|
172
176
|
|
|
173
177
|
for (const condition of listToCheck) {
|
|
174
178
|
const operands = (condition.operands = condition.operands.filter(
|
|
175
|
-
(orOperand) =>
|
|
176
|
-
|
|
179
|
+
(orOperand) =>
|
|
180
|
+
!currentOrOperands.operands.some((currentOrOperand) =>
|
|
177
181
|
isSubset(currentOrOperand, orOperand)
|
|
178
182
|
)
|
|
179
|
-
}
|
|
180
183
|
))
|
|
181
|
-
if (
|
|
184
|
+
if (operands.length === 0) {
|
|
182
185
|
context.report({
|
|
183
186
|
node: condition.node,
|
|
184
187
|
messageId: 'unexpected'
|