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.
Files changed (180) hide show
  1. package/README.md +3 -0
  2. package/lib/.DS_Store +0 -0
  3. package/lib/configs/base.js +10 -5
  4. package/lib/configs/mpx-essential.js +0 -30
  5. package/lib/index.js +1 -150
  6. package/lib/rules/comment-directive.js +2 -2
  7. package/lib/rules/component-tags-order.js +2 -2
  8. package/lib/rules/eqeqeq.js +4 -2
  9. package/lib/rules/html-end-tags.js +1 -1
  10. package/lib/rules/no-arrow-functions-in-watch.js +2 -2
  11. package/lib/rules/no-async-in-computed-properties.js +5 -5
  12. package/lib/rules/no-dupe-keys.js +3 -3
  13. package/lib/rules/no-dupe-wx-elif.js +8 -3
  14. package/lib/rules/no-duplicate-attributes.js +6 -16
  15. package/lib/rules/no-parsing-error.js +2 -2
  16. package/lib/rules/no-reserved-keys.js +3 -3
  17. package/lib/rules/no-side-effects-in-computed-properties.js +8 -9
  18. package/lib/rules/return-in-computed-property.js +3 -3
  19. package/lib/rules/syntaxes/dynamic-directive-arguments.js +2 -1
  20. package/lib/rules/syntaxes/scope-attribute.js +2 -1
  21. package/lib/rules/syntaxes/slot-attribute.js +2 -1
  22. package/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js +2 -1
  23. package/lib/rules/valid-wx-elif.js +1 -1
  24. package/lib/rules/valid-wx-else.js +1 -1
  25. package/lib/rules/valid-wx-for.js +2 -2
  26. package/lib/rules/valid-wx-if.js +1 -1
  27. package/lib/rules/valid-wx-model.js +2 -2
  28. package/lib/utils/index.js +504 -490
  29. package/lib/utils/keycode-to-key.js +60 -60
  30. package/lib/utils/{vue-reserved.json → mpx-reserved.json} +2 -2
  31. package/package.json +18 -15
  32. package/lib/configs/essential.js +0 -51
  33. package/lib/configs/no-layout-rules.js +0 -47
  34. package/lib/configs/recommended.js +0 -17
  35. package/lib/configs/strongly-recommended.js +0 -32
  36. package/lib/configs/vue3-essential.js +0 -71
  37. package/lib/configs/vue3-recommended.js +0 -17
  38. package/lib/configs/vue3-strongly-recommended.js +0 -33
  39. package/lib/rules/array-bracket-spacing.js +0 -12
  40. package/lib/rules/arrow-spacing.js +0 -9
  41. package/lib/rules/attribute-hyphenation.js +0 -121
  42. package/lib/rules/attributes-order.js +0 -281
  43. package/lib/rules/block-spacing.js +0 -11
  44. package/lib/rules/brace-style.js +0 -11
  45. package/lib/rules/camelcase.js +0 -9
  46. package/lib/rules/comma-dangle.js +0 -9
  47. package/lib/rules/comma-spacing.js +0 -12
  48. package/lib/rules/comma-style.js +0 -20
  49. package/lib/rules/component-definition-name-casing.js +0 -108
  50. package/lib/rules/component-name-in-template-casing.js +0 -164
  51. package/lib/rules/custom-event-name-casing.js +0 -214
  52. package/lib/rules/dot-location.js +0 -9
  53. package/lib/rules/dot-notation.js +0 -9
  54. package/lib/rules/func-call-spacing.js +0 -11
  55. package/lib/rules/html-closing-bracket-newline.js +0 -115
  56. package/lib/rules/html-closing-bracket-spacing.js +0 -137
  57. package/lib/rules/html-comment-content-newline.js +0 -215
  58. package/lib/rules/html-comment-content-spacing.js +0 -179
  59. package/lib/rules/html-comment-indent.js +0 -258
  60. package/lib/rules/html-indent.js +0 -81
  61. package/lib/rules/html-quotes.js +0 -107
  62. package/lib/rules/html-self-closing.js +0 -222
  63. package/lib/rules/jsx-uses-vars.js +0 -73
  64. package/lib/rules/key-spacing.js +0 -11
  65. package/lib/rules/keyword-spacing.js +0 -11
  66. package/lib/rules/match-component-file-name.js +0 -151
  67. package/lib/rules/max-attributes-per-line.js +0 -194
  68. package/lib/rules/max-len.js +0 -561
  69. package/lib/rules/multiline-html-element-content-newline.js +0 -246
  70. package/lib/rules/mustache-interpolation-spacing.js +0 -107
  71. package/lib/rules/name-property-casing.js +0 -71
  72. package/lib/rules/no-bare-strings-in-template.js +0 -275
  73. package/lib/rules/no-boolean-default.js +0 -114
  74. package/lib/rules/no-confusing-v-for-v-if.js +0 -69
  75. package/lib/rules/no-custom-modifiers-on-v-model.js +0 -59
  76. package/lib/rules/no-deprecated-data-object-declaration.js +0 -95
  77. package/lib/rules/no-deprecated-destroyed-lifecycle.js +0 -101
  78. package/lib/rules/no-deprecated-dollar-listeners-api.js +0 -72
  79. package/lib/rules/no-deprecated-dollar-scopedslots-api.js +0 -79
  80. package/lib/rules/no-deprecated-events-api.js +0 -69
  81. package/lib/rules/no-deprecated-filter.js +0 -44
  82. package/lib/rules/no-deprecated-functional-template.js +0 -56
  83. package/lib/rules/no-deprecated-html-element-is.js +0 -54
  84. package/lib/rules/no-deprecated-inline-template.js +0 -47
  85. package/lib/rules/no-deprecated-scope-attribute.js +0 -31
  86. package/lib/rules/no-deprecated-slot-attribute.js +0 -29
  87. package/lib/rules/no-deprecated-slot-scope-attribute.js +0 -34
  88. package/lib/rules/no-deprecated-v-bind-sync.js +0 -62
  89. package/lib/rules/no-deprecated-v-on-native-modifier.js +0 -50
  90. package/lib/rules/no-deprecated-v-on-number-modifiers.js +0 -61
  91. package/lib/rules/no-deprecated-vue-config-keycodes.js +0 -53
  92. package/lib/rules/no-duplicate-attr-inheritance.js +0 -67
  93. package/lib/rules/no-empty-component-block.js +0 -109
  94. package/lib/rules/no-empty-pattern.js +0 -9
  95. package/lib/rules/no-extra-parens.js +0 -182
  96. package/lib/rules/no-irregular-whitespace.js +0 -251
  97. package/lib/rules/no-lifecycle-after-await.js +0 -133
  98. package/lib/rules/no-lone-template.js +0 -129
  99. package/lib/rules/no-multi-spaces.js +0 -107
  100. package/lib/rules/no-multiple-objects-in-class.js +0 -59
  101. package/lib/rules/no-multiple-slot-args.js +0 -118
  102. package/lib/rules/no-multiple-template-root.js +0 -101
  103. package/lib/rules/no-mutating-props.js +0 -323
  104. package/lib/rules/no-potential-component-option-typo.js +0 -125
  105. package/lib/rules/no-ref-as-operand.js +0 -189
  106. package/lib/rules/no-reserved-component-names.js +0 -187
  107. package/lib/rules/no-restricted-component-options.js +0 -215
  108. package/lib/rules/no-restricted-static-attribute.js +0 -164
  109. package/lib/rules/no-restricted-syntax.js +0 -9
  110. package/lib/rules/no-restricted-v-bind.js +0 -184
  111. package/lib/rules/no-setup-props-destructure.js +0 -149
  112. package/lib/rules/no-spaces-around-equal-signs-in-attribute.js +0 -57
  113. package/lib/rules/no-sparse-arrays.js +0 -9
  114. package/lib/rules/no-static-inline-styles.js +0 -141
  115. package/lib/rules/no-template-key.js +0 -48
  116. package/lib/rules/no-template-shadow.js +0 -101
  117. package/lib/rules/no-template-target-blank.js +0 -138
  118. package/lib/rules/no-textarea-mustache.js +0 -46
  119. package/lib/rules/no-unregistered-components.js +0 -187
  120. package/lib/rules/no-unsupported-features.js +0 -157
  121. package/lib/rules/no-unused-components.js +0 -143
  122. package/lib/rules/no-unused-properties.js +0 -742
  123. package/lib/rules/no-unused-vars.js +0 -147
  124. package/lib/rules/no-use-v-if-with-v-for.js +0 -119
  125. package/lib/rules/no-useless-concat.js +0 -9
  126. package/lib/rules/no-useless-mustaches.js +0 -154
  127. package/lib/rules/no-useless-v-bind.js +0 -150
  128. package/lib/rules/no-v-html.js +0 -36
  129. package/lib/rules/no-v-model-argument.js +0 -49
  130. package/lib/rules/no-watch-after-await.js +0 -142
  131. package/lib/rules/object-curly-newline.js +0 -12
  132. package/lib/rules/object-curly-spacing.js +0 -12
  133. package/lib/rules/object-property-newline.js +0 -12
  134. package/lib/rules/one-component-per-file.js +0 -50
  135. package/lib/rules/operator-linebreak.js +0 -9
  136. package/lib/rules/order-in-components.js +0 -341
  137. package/lib/rules/padding-line-between-blocks.js +0 -220
  138. package/lib/rules/prefer-template.js +0 -9
  139. package/lib/rules/prop-name-casing.js +0 -66
  140. package/lib/rules/require-component-is.js +0 -45
  141. package/lib/rules/require-default-prop.js +0 -190
  142. package/lib/rules/require-direct-export.js +0 -128
  143. package/lib/rules/require-explicit-emits.js +0 -511
  144. package/lib/rules/require-name-property.js +0 -43
  145. package/lib/rules/require-prop-type-constructor.js +0 -99
  146. package/lib/rules/require-prop-types.js +0 -103
  147. package/lib/rules/require-render-return.js +0 -50
  148. package/lib/rules/require-slots-as-functions.js +0 -120
  149. package/lib/rules/require-toggle-inside-transition.js +0 -89
  150. package/lib/rules/require-v-for-key.js +0 -62
  151. package/lib/rules/require-valid-default-prop.js +0 -338
  152. package/lib/rules/return-in-emits-validator.js +0 -141
  153. package/lib/rules/script-indent.js +0 -56
  154. package/lib/rules/singleline-html-element-content-newline.js +0 -215
  155. package/lib/rules/sort-keys.js +0 -282
  156. package/lib/rules/space-in-parens.js +0 -12
  157. package/lib/rules/space-infix-ops.js +0 -11
  158. package/lib/rules/space-unary-ops.js +0 -11
  159. package/lib/rules/static-class-names-order.js +0 -61
  160. package/lib/rules/template-curly-spacing.js +0 -12
  161. package/lib/rules/this-in-template.js +0 -128
  162. package/lib/rules/use-v-on-exact.js +0 -228
  163. package/lib/rules/v-bind-style.js +0 -76
  164. package/lib/rules/v-for-delimiter-style.js +0 -69
  165. package/lib/rules/v-on-function-call.js +0 -172
  166. package/lib/rules/v-on-style.js +0 -58
  167. package/lib/rules/v-slot-style.js +0 -155
  168. package/lib/rules/valid-template-root.js +0 -69
  169. package/lib/rules/valid-v-bind-sync.js +0 -179
  170. package/lib/rules/valid-v-bind.js +0 -62
  171. package/lib/rules/valid-v-cloak.js +0 -58
  172. package/lib/rules/valid-v-html.js +0 -58
  173. package/lib/rules/valid-v-is.js +0 -95
  174. package/lib/rules/valid-v-on.js +0 -153
  175. package/lib/rules/valid-v-once.js +0 -58
  176. package/lib/rules/valid-v-pre.js +0 -58
  177. package/lib/rules/valid-v-show.js +0 -58
  178. package/lib/rules/valid-v-slot.js +0 -290
  179. package/lib/rules/valid-v-text.js +0 -58
  180. 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
- }