eslint-plugin-mpx 0.0.21 → 0.2.0
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 +3 -0
- package/lib/.DS_Store +0 -0
- package/lib/configs/base.js +10 -5
- package/lib/configs/mpx-essential.js +0 -30
- package/lib/index.js +1 -150
- package/lib/rules/comment-directive.js +2 -2
- package/lib/rules/component-tags-order.js +2 -2
- package/lib/rules/eqeqeq.js +4 -2
- package/lib/rules/html-end-tags.js +1 -1
- package/lib/rules/no-arrow-functions-in-watch.js +2 -2
- package/lib/rules/no-async-in-computed-properties.js +5 -5
- package/lib/rules/no-dupe-keys.js +3 -3
- package/lib/rules/no-dupe-wx-elif.js +8 -3
- package/lib/rules/no-duplicate-attributes.js +6 -16
- package/lib/rules/no-parsing-error.js +2 -2
- package/lib/rules/no-reserved-keys.js +3 -3
- package/lib/rules/no-side-effects-in-computed-properties.js +8 -9
- package/lib/rules/return-in-computed-property.js +3 -3
- package/lib/rules/syntaxes/dynamic-directive-arguments.js +2 -1
- package/lib/rules/syntaxes/scope-attribute.js +2 -1
- package/lib/rules/syntaxes/slot-attribute.js +2 -1
- package/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js +2 -1
- package/lib/rules/valid-wx-elif.js +1 -1
- package/lib/rules/valid-wx-else.js +1 -1
- package/lib/rules/valid-wx-for.js +2 -2
- package/lib/rules/valid-wx-if.js +1 -1
- package/lib/rules/valid-wx-model.js +2 -2
- package/lib/utils/index.js +504 -490
- package/lib/utils/keycode-to-key.js +60 -60
- package/lib/utils/{vue-reserved.json → mpx-reserved.json} +2 -2
- package/package.json +18 -15
- package/lib/configs/essential.js +0 -51
- package/lib/configs/no-layout-rules.js +0 -47
- package/lib/configs/recommended.js +0 -17
- package/lib/configs/strongly-recommended.js +0 -32
- package/lib/configs/vue3-essential.js +0 -71
- package/lib/configs/vue3-recommended.js +0 -17
- package/lib/configs/vue3-strongly-recommended.js +0 -33
- package/lib/rules/array-bracket-spacing.js +0 -12
- package/lib/rules/arrow-spacing.js +0 -9
- package/lib/rules/attribute-hyphenation.js +0 -121
- package/lib/rules/attributes-order.js +0 -281
- package/lib/rules/block-spacing.js +0 -11
- package/lib/rules/brace-style.js +0 -11
- package/lib/rules/camelcase.js +0 -9
- package/lib/rules/comma-dangle.js +0 -9
- package/lib/rules/comma-spacing.js +0 -12
- package/lib/rules/comma-style.js +0 -20
- package/lib/rules/component-definition-name-casing.js +0 -108
- package/lib/rules/component-name-in-template-casing.js +0 -164
- package/lib/rules/custom-event-name-casing.js +0 -214
- package/lib/rules/dot-location.js +0 -9
- package/lib/rules/dot-notation.js +0 -9
- package/lib/rules/func-call-spacing.js +0 -11
- package/lib/rules/html-closing-bracket-newline.js +0 -115
- package/lib/rules/html-closing-bracket-spacing.js +0 -137
- package/lib/rules/html-comment-content-newline.js +0 -215
- package/lib/rules/html-comment-content-spacing.js +0 -179
- package/lib/rules/html-comment-indent.js +0 -258
- package/lib/rules/html-indent.js +0 -81
- package/lib/rules/html-quotes.js +0 -107
- package/lib/rules/html-self-closing.js +0 -222
- package/lib/rules/jsx-uses-vars.js +0 -73
- package/lib/rules/key-spacing.js +0 -11
- package/lib/rules/keyword-spacing.js +0 -11
- package/lib/rules/match-component-file-name.js +0 -151
- package/lib/rules/max-attributes-per-line.js +0 -194
- package/lib/rules/max-len.js +0 -561
- package/lib/rules/multiline-html-element-content-newline.js +0 -246
- package/lib/rules/mustache-interpolation-spacing.js +0 -107
- package/lib/rules/name-property-casing.js +0 -71
- package/lib/rules/no-bare-strings-in-template.js +0 -275
- package/lib/rules/no-boolean-default.js +0 -114
- package/lib/rules/no-confusing-v-for-v-if.js +0 -69
- package/lib/rules/no-custom-modifiers-on-v-model.js +0 -59
- package/lib/rules/no-deprecated-data-object-declaration.js +0 -95
- package/lib/rules/no-deprecated-destroyed-lifecycle.js +0 -101
- package/lib/rules/no-deprecated-dollar-listeners-api.js +0 -72
- package/lib/rules/no-deprecated-dollar-scopedslots-api.js +0 -79
- package/lib/rules/no-deprecated-events-api.js +0 -69
- package/lib/rules/no-deprecated-filter.js +0 -44
- package/lib/rules/no-deprecated-functional-template.js +0 -56
- package/lib/rules/no-deprecated-html-element-is.js +0 -54
- package/lib/rules/no-deprecated-inline-template.js +0 -47
- package/lib/rules/no-deprecated-scope-attribute.js +0 -31
- package/lib/rules/no-deprecated-slot-attribute.js +0 -29
- package/lib/rules/no-deprecated-slot-scope-attribute.js +0 -34
- package/lib/rules/no-deprecated-v-bind-sync.js +0 -62
- package/lib/rules/no-deprecated-v-on-native-modifier.js +0 -50
- package/lib/rules/no-deprecated-v-on-number-modifiers.js +0 -61
- package/lib/rules/no-deprecated-vue-config-keycodes.js +0 -53
- package/lib/rules/no-duplicate-attr-inheritance.js +0 -67
- package/lib/rules/no-empty-component-block.js +0 -109
- package/lib/rules/no-empty-pattern.js +0 -9
- package/lib/rules/no-extra-parens.js +0 -182
- package/lib/rules/no-irregular-whitespace.js +0 -251
- package/lib/rules/no-lifecycle-after-await.js +0 -133
- package/lib/rules/no-lone-template.js +0 -129
- package/lib/rules/no-multi-spaces.js +0 -107
- package/lib/rules/no-multiple-objects-in-class.js +0 -59
- package/lib/rules/no-multiple-slot-args.js +0 -118
- package/lib/rules/no-multiple-template-root.js +0 -101
- package/lib/rules/no-mutating-props.js +0 -323
- package/lib/rules/no-potential-component-option-typo.js +0 -125
- package/lib/rules/no-ref-as-operand.js +0 -189
- package/lib/rules/no-reserved-component-names.js +0 -187
- package/lib/rules/no-restricted-component-options.js +0 -215
- package/lib/rules/no-restricted-static-attribute.js +0 -164
- package/lib/rules/no-restricted-syntax.js +0 -9
- package/lib/rules/no-restricted-v-bind.js +0 -184
- package/lib/rules/no-setup-props-destructure.js +0 -149
- package/lib/rules/no-spaces-around-equal-signs-in-attribute.js +0 -57
- package/lib/rules/no-sparse-arrays.js +0 -9
- package/lib/rules/no-static-inline-styles.js +0 -141
- package/lib/rules/no-template-key.js +0 -48
- package/lib/rules/no-template-shadow.js +0 -101
- package/lib/rules/no-template-target-blank.js +0 -138
- package/lib/rules/no-textarea-mustache.js +0 -46
- package/lib/rules/no-unregistered-components.js +0 -187
- package/lib/rules/no-unsupported-features.js +0 -157
- package/lib/rules/no-unused-components.js +0 -143
- package/lib/rules/no-unused-properties.js +0 -742
- package/lib/rules/no-unused-vars.js +0 -147
- package/lib/rules/no-use-v-if-with-v-for.js +0 -119
- package/lib/rules/no-useless-concat.js +0 -9
- package/lib/rules/no-useless-mustaches.js +0 -154
- package/lib/rules/no-useless-v-bind.js +0 -150
- package/lib/rules/no-v-html.js +0 -36
- package/lib/rules/no-v-model-argument.js +0 -49
- package/lib/rules/no-watch-after-await.js +0 -142
- package/lib/rules/object-curly-newline.js +0 -12
- package/lib/rules/object-curly-spacing.js +0 -12
- package/lib/rules/object-property-newline.js +0 -12
- package/lib/rules/one-component-per-file.js +0 -50
- package/lib/rules/operator-linebreak.js +0 -9
- package/lib/rules/order-in-components.js +0 -341
- package/lib/rules/padding-line-between-blocks.js +0 -220
- package/lib/rules/prefer-template.js +0 -9
- package/lib/rules/prop-name-casing.js +0 -66
- package/lib/rules/require-component-is.js +0 -45
- package/lib/rules/require-default-prop.js +0 -190
- package/lib/rules/require-direct-export.js +0 -128
- package/lib/rules/require-explicit-emits.js +0 -511
- package/lib/rules/require-name-property.js +0 -43
- package/lib/rules/require-prop-type-constructor.js +0 -99
- package/lib/rules/require-prop-types.js +0 -103
- package/lib/rules/require-render-return.js +0 -50
- package/lib/rules/require-slots-as-functions.js +0 -120
- package/lib/rules/require-toggle-inside-transition.js +0 -89
- package/lib/rules/require-v-for-key.js +0 -62
- package/lib/rules/require-valid-default-prop.js +0 -338
- package/lib/rules/return-in-emits-validator.js +0 -141
- package/lib/rules/script-indent.js +0 -56
- package/lib/rules/singleline-html-element-content-newline.js +0 -215
- package/lib/rules/sort-keys.js +0 -282
- package/lib/rules/space-in-parens.js +0 -12
- package/lib/rules/space-infix-ops.js +0 -11
- package/lib/rules/space-unary-ops.js +0 -11
- package/lib/rules/static-class-names-order.js +0 -61
- package/lib/rules/template-curly-spacing.js +0 -12
- package/lib/rules/this-in-template.js +0 -128
- package/lib/rules/use-v-on-exact.js +0 -228
- package/lib/rules/v-bind-style.js +0 -76
- package/lib/rules/v-for-delimiter-style.js +0 -69
- package/lib/rules/v-on-function-call.js +0 -172
- package/lib/rules/v-on-style.js +0 -58
- package/lib/rules/v-slot-style.js +0 -155
- package/lib/rules/valid-template-root.js +0 -69
- package/lib/rules/valid-v-bind-sync.js +0 -179
- package/lib/rules/valid-v-bind.js +0 -62
- package/lib/rules/valid-v-cloak.js +0 -58
- package/lib/rules/valid-v-html.js +0 -58
- package/lib/rules/valid-v-is.js +0 -95
- package/lib/rules/valid-v-on.js +0 -153
- package/lib/rules/valid-v-once.js +0 -58
- package/lib/rules/valid-v-pre.js +0 -58
- package/lib/rules/valid-v-show.js +0 -58
- package/lib/rules/valid-v-slot.js +0 -290
- package/lib/rules/valid-v-text.js +0 -58
- package/lib/utils/indent-common.js +0 -2085
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Define the number of attributes allows per line
|
|
3
|
-
* @author Filipa Lacerda
|
|
4
|
-
*/
|
|
5
|
-
'use strict'
|
|
6
|
-
|
|
7
|
-
// ------------------------------------------------------------------------------
|
|
8
|
-
// Rule Definition
|
|
9
|
-
// ------------------------------------------------------------------------------
|
|
10
|
-
const utils = require('../utils')
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
meta: {
|
|
14
|
-
type: 'layout',
|
|
15
|
-
docs: {
|
|
16
|
-
description: 'enforce the maximum number of attributes per line',
|
|
17
|
-
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
|
|
18
|
-
url: 'https://eslint.vuejs.org/rules/max-attributes-per-line.html'
|
|
19
|
-
},
|
|
20
|
-
fixable: 'whitespace', // or "code" or "whitespace"
|
|
21
|
-
schema: [
|
|
22
|
-
{
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
singleline: {
|
|
26
|
-
anyOf: [
|
|
27
|
-
{
|
|
28
|
-
type: 'number',
|
|
29
|
-
minimum: 1
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'object',
|
|
33
|
-
properties: {
|
|
34
|
-
max: {
|
|
35
|
-
type: 'number',
|
|
36
|
-
minimum: 1
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
additionalProperties: false
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
multiline: {
|
|
44
|
-
anyOf: [
|
|
45
|
-
{
|
|
46
|
-
type: 'number',
|
|
47
|
-
minimum: 1
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
type: 'object',
|
|
51
|
-
properties: {
|
|
52
|
-
max: {
|
|
53
|
-
type: 'number',
|
|
54
|
-
minimum: 1
|
|
55
|
-
},
|
|
56
|
-
allowFirstLine: {
|
|
57
|
-
type: 'boolean'
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
additionalProperties: false
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
/** @param {RuleContext} context */
|
|
69
|
-
create(context) {
|
|
70
|
-
const sourceCode = context.getSourceCode()
|
|
71
|
-
const configuration = parseOptions(context.options[0])
|
|
72
|
-
const multilineMaximum = configuration.multiline
|
|
73
|
-
const singlelinemMaximum = configuration.singleline
|
|
74
|
-
const canHaveFirstLine = configuration.allowFirstLine
|
|
75
|
-
const template =
|
|
76
|
-
context.parserServices.getTemplateBodyTokenStore &&
|
|
77
|
-
context.parserServices.getTemplateBodyTokenStore()
|
|
78
|
-
|
|
79
|
-
return utils.defineTemplateBodyVisitor(context, {
|
|
80
|
-
VStartTag(node) {
|
|
81
|
-
const numberOfAttributes = node.attributes.length
|
|
82
|
-
|
|
83
|
-
if (!numberOfAttributes) return
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
utils.isSingleLine(node) &&
|
|
87
|
-
numberOfAttributes > singlelinemMaximum
|
|
88
|
-
) {
|
|
89
|
-
showErrors(node.attributes.slice(singlelinemMaximum))
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (!utils.isSingleLine(node)) {
|
|
93
|
-
if (
|
|
94
|
-
!canHaveFirstLine &&
|
|
95
|
-
node.attributes[0].loc.start.line === node.loc.start.line
|
|
96
|
-
) {
|
|
97
|
-
showErrors([node.attributes[0]])
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
groupAttrsByLine(node.attributes)
|
|
101
|
-
.filter((attrs) => attrs.length > multilineMaximum)
|
|
102
|
-
.forEach((attrs) => showErrors(attrs.splice(multilineMaximum)))
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
// ----------------------------------------------------------------------
|
|
108
|
-
// Helpers
|
|
109
|
-
// ----------------------------------------------------------------------
|
|
110
|
-
/**
|
|
111
|
-
* @param {any} options
|
|
112
|
-
*/
|
|
113
|
-
function parseOptions(options) {
|
|
114
|
-
const defaults = {
|
|
115
|
-
singleline: 1,
|
|
116
|
-
multiline: 1,
|
|
117
|
-
allowFirstLine: false
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (options) {
|
|
121
|
-
if (typeof options.singleline === 'number') {
|
|
122
|
-
defaults.singleline = options.singleline
|
|
123
|
-
} else if (options.singleline && options.singleline.max) {
|
|
124
|
-
defaults.singleline = options.singleline.max
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (options.multiline) {
|
|
128
|
-
if (typeof options.multiline === 'number') {
|
|
129
|
-
defaults.multiline = options.multiline
|
|
130
|
-
} else if (typeof options.multiline === 'object') {
|
|
131
|
-
if (options.multiline.max) {
|
|
132
|
-
defaults.multiline = options.multiline.max
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (options.multiline.allowFirstLine) {
|
|
136
|
-
defaults.allowFirstLine = options.multiline.allowFirstLine
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return defaults
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @param {(VDirective | VAttribute)[]} attributes
|
|
147
|
-
*/
|
|
148
|
-
function showErrors(attributes) {
|
|
149
|
-
attributes.forEach((prop, i) => {
|
|
150
|
-
context.report({
|
|
151
|
-
node: prop,
|
|
152
|
-
loc: prop.loc,
|
|
153
|
-
message: "'{{name}}' should be on a new line.",
|
|
154
|
-
data: { name: sourceCode.getText(prop.key) },
|
|
155
|
-
fix(fixer) {
|
|
156
|
-
if (i !== 0) return null
|
|
157
|
-
|
|
158
|
-
// Find the closest token before the current prop
|
|
159
|
-
// that is not a white space
|
|
160
|
-
const prevToken = /** @type {Token} */ (template.getTokenBefore(
|
|
161
|
-
prop,
|
|
162
|
-
{
|
|
163
|
-
filter: (token) => token.type !== 'HTMLWhitespace'
|
|
164
|
-
}
|
|
165
|
-
))
|
|
166
|
-
|
|
167
|
-
/** @type {Range} */
|
|
168
|
-
const range = [prevToken.range[1], prop.range[0]]
|
|
169
|
-
|
|
170
|
-
return fixer.replaceTextRange(range, '\n')
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
})
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* @param {(VDirective | VAttribute)[]} attributes
|
|
178
|
-
*/
|
|
179
|
-
function groupAttrsByLine(attributes) {
|
|
180
|
-
const propsPerLine = [[attributes[0]]]
|
|
181
|
-
|
|
182
|
-
attributes.reduce((previous, current) => {
|
|
183
|
-
if (previous.loc.end.line === current.loc.start.line) {
|
|
184
|
-
propsPerLine[propsPerLine.length - 1].push(current)
|
|
185
|
-
} else {
|
|
186
|
-
propsPerLine.push([current])
|
|
187
|
-
}
|
|
188
|
-
return current
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
return propsPerLine
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|