Skip to content

Commit 793112d

Browse files
feat: ๐ŸŽธ #1492 (#1493)
* feat: ๐ŸŽธ #1492 * docs: โœ๏ธ update doc * fix: ๐Ÿ› fix eslint
1 parent 8a0a0ed commit 793112d

File tree

88 files changed

+575
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+575
-888
lines changed

โ€Ždocs/.vuepress/components/eslint-code-block.vue

+6-9
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,12 @@ export default {
122122
123123
async mounted() {
124124
// Load linter.
125-
const [
126-
{ default: Linter },
127-
{ default: coreRules },
128-
{ parseForESLint }
129-
] = await Promise.all([
130-
import('eslint4b/dist/linter'),
131-
import('eslint4b/dist/core-rules'),
132-
import('espree').then(() => import('vue-eslint-parser'))
133-
])
125+
const [{ default: Linter }, { default: coreRules }, { parseForESLint }] =
126+
await Promise.all([
127+
import('eslint4b/dist/linter'),
128+
import('eslint4b/dist/core-rules'),
129+
import('espree').then(() => import('vue-eslint-parser'))
130+
])
134131
135132
const linter = (this.linter = new Linter())
136133

โ€Ždocs/rules/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
157157
| [vue/no-multiple-slot-args](./no-multiple-slot-args.md) | disallow to pass multiple arguments to scoped slots | |
158158
| [vue/no-v-html](./no-v-html.md) | disallow use of v-html to prevent XSS attack | |
159159
| [vue/order-in-components](./order-in-components.md) | enforce order of properties in components | :wrench: |
160-
| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | |
160+
| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | :wrench: |
161161

162162
## Priority A: Essential (Error Prevention) <badge text="for Vue.js 2.x" vertical="middle" type="warn">for Vue.js 2.x</badge>
163163

@@ -267,7 +267,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
267267
| [vue/no-multiple-slot-args](./no-multiple-slot-args.md) | disallow to pass multiple arguments to scoped slots | |
268268
| [vue/no-v-html](./no-v-html.md) | disallow use of v-html to prevent XSS attack | |
269269
| [vue/order-in-components](./order-in-components.md) | enforce order of properties in components | :wrench: |
270-
| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | |
270+
| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | :wrench: |
271271

272272
## Uncategorized
273273

โ€Ždocs/rules/this-in-template.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ since: v3.13.0
1010
> disallow usage of `this` in template
1111
1212
- :gear: This rule is included in `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`.
13+
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1314

1415
## :book: Rule Details
1516

1617
This rule aims at preventing usage of `this` in Vue templates.
1718

18-
<eslint-code-block :rules="{'vue/this-in-template': ['error']}">
19+
<eslint-code-block fix :rules="{'vue/this-in-template': ['error']}">
1920

2021
```vue
2122
<template>
@@ -45,7 +46,7 @@ This rule aims at preventing usage of `this` in Vue templates.
4546

4647
### `"always"`
4748

48-
<eslint-code-block :rules="{'vue/this-in-template': ['error', 'always']}">
49+
<eslint-code-block fix :rules="{'vue/this-in-template': ['error', 'always']}">
4950

5051
```vue
5152
<template>

โ€Žlib/rules/attributes-order.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,8 @@ function create(context) {
271271
return
272272
}
273273

274-
let {
275-
attr: previousNode,
276-
position: previousPosition
277-
} = attributeAndPositions[0]
274+
let { attr: previousNode, position: previousPosition } =
275+
attributeAndPositions[0]
278276
for (let index = 1; index < attributeAndPositions.length; index++) {
279277
const { attr, position } = attributeAndPositions[index]
280278

โ€Žlib/rules/component-definition-name-casing.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ module.exports = {
1818
docs: {
1919
description: 'enforce specific casing for component definition name',
2020
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
21-
url:
22-
'https://eslint.vuejs.org/rules/component-definition-name-casing.html'
21+
url: 'https://eslint.vuejs.org/rules/component-definition-name-casing.html'
2322
},
2423
fixable: 'code', // or "code" or "whitespace"
2524
schema: [

โ€Žlib/rules/component-name-in-template-casing.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ module.exports = {
3030
description:
3131
'enforce specific casing for the component naming style in template',
3232
categories: undefined,
33-
url:
34-
'https://eslint.vuejs.org/rules/component-name-in-template-casing.html'
33+
url: 'https://eslint.vuejs.org/rules/component-name-in-template-casing.html'
3534
},
3635
fixable: 'code',
3736
schema: [

โ€Žlib/rules/experimental-script-setup-vars.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ function parseSetup(code, espree, eslintScope) {
161161
fallback: AST.getFallbackKeys
162162
})
163163

164-
const variables = /** @type {Variable[]} */ (result.globalScope.childScopes[0]
165-
.variables)
164+
const variables = /** @type {Variable[]} */ (
165+
result.globalScope.childScopes[0].variables
166+
)
166167

167168
return variables.map((v) => v.name)
168169
}

โ€Žlib/rules/html-self-closing.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ module.exports = {
164164
name: node.rawName
165165
},
166166
fix(fixer) {
167-
const tokens = context.parserServices.getTemplateBodyTokenStore()
167+
const tokens =
168+
context.parserServices.getTemplateBodyTokenStore()
168169
const close = tokens.getLastToken(node.startTag)
169170
if (close.type !== 'HTMLTagClose') {
170171
return null
@@ -188,7 +189,8 @@ module.exports = {
188189
name: node.rawName
189190
},
190191
fix(fixer) {
191-
const tokens = context.parserServices.getTemplateBodyTokenStore()
192+
const tokens =
193+
context.parserServices.getTemplateBodyTokenStore()
192194
const close = tokens.getLastToken(node.startTag)
193195
if (close.type !== 'HTMLSelfClosingTagClose') {
194196
return null

โ€Žlib/rules/max-attributes-per-line.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,11 @@ module.exports = {
177177

178178
// Find the closest token before the current prop
179179
// that is not a white space
180-
const prevToken = /** @type {Token} */ (template.getTokenBefore(
181-
prop,
182-
{
180+
const prevToken = /** @type {Token} */ (
181+
template.getTokenBefore(prop, {
183182
filter: (token) => token.type !== 'HTMLWhitespace'
184-
}
185-
))
183+
})
184+
)
186185

187186
/** @type {Range} */
188187
const range = [prevToken.range[1], prop.range[0]]

โ€Žlib/rules/max-len.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ module.exports = {
209209
OPTIONS_SCHEMA
210210
],
211211
messages: {
212-
max:
213-
'This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.',
212+
max: 'This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.',
214213
maxComment:
215214
'This line has a comment length of {{lineLength}}. Maximum allowed is {{maxCommentLength}}.'
216215
}

โ€Žlib/rules/multiline-html-element-content-newline.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ module.exports = {
7272
description:
7373
'require a line break before and after the contents of a multiline element',
7474
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
75-
url:
76-
'https://eslint.vuejs.org/rules/multiline-html-element-content-newline.html'
75+
url: 'https://eslint.vuejs.org/rules/multiline-html-element-content-newline.html'
7776
},
7877
fixable: 'whitespace',
7978
schema: [
@@ -179,14 +178,12 @@ module.exports = {
179178
return
180179
}
181180

182-
const contentFirst = /** @type {Token} */ (template.getTokenAfter(
183-
element.startTag,
184-
getTokenOption
185-
))
186-
const contentLast = /** @type {Token} */ (template.getTokenBefore(
187-
element.endTag,
188-
getTokenOption
189-
))
181+
const contentFirst = /** @type {Token} */ (
182+
template.getTokenAfter(element.startTag, getTokenOption)
183+
)
184+
const contentLast = /** @type {Token} */ (
185+
template.getTokenBefore(element.endTag, getTokenOption)
186+
)
190187

191188
const beforeLineBreaks =
192189
contentFirst.loc.start.line - element.startTag.loc.end.line

โ€Žlib/rules/new-line-between-multi-line-property.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ module.exports = {
5555
description:
5656
'enforce new lines between multi-line properties in Vue components',
5757
categories: undefined,
58-
url:
59-
'https://eslint.vuejs.org/rules/new-line-between-multi-line-property.html'
58+
url: 'https://eslint.vuejs.org/rules/new-line-between-multi-line-property.html'
6059
},
6160
fixable: 'whitespace', // or "code" or "whitespace"
6261
schema: [

โ€Žlib/rules/no-deprecated-data-object-declaration.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ module.exports = {
5252
description:
5353
'disallow using deprecated object declaration on data (in Vue.js 3.0.0+)',
5454
categories: ['vue3-essential'],
55-
url:
56-
'https://eslint.vuejs.org/rules/no-deprecated-data-object-declaration.html'
55+
url: 'https://eslint.vuejs.org/rules/no-deprecated-data-object-declaration.html'
5756
},
5857
fixable: 'code',
5958
schema: [],

โ€Žlib/rules/no-deprecated-destroyed-lifecycle.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ module.exports = {
2121
description:
2222
'disallow using deprecated `destroyed` and `beforeDestroy` lifecycle hooks (in Vue.js 3.0.0+)',
2323
categories: ['vue3-essential'],
24-
url:
25-
'https://eslint.vuejs.org/rules/no-deprecated-destroyed-lifecycle.html'
24+
url: 'https://eslint.vuejs.org/rules/no-deprecated-destroyed-lifecycle.html'
2625
},
2726
fixable: null,
2827
schema: [],

โ€Žlib/rules/no-deprecated-dollar-listeners-api.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ module.exports = {
2020
docs: {
2121
description: 'disallow using deprecated `$listeners` (in Vue.js 3.0.0+)',
2222
categories: ['vue3-essential'],
23-
url:
24-
'https://eslint.vuejs.org/rules/no-deprecated-dollar-listeners-api.html'
23+
url: 'https://eslint.vuejs.org/rules/no-deprecated-dollar-listeners-api.html'
2524
},
2625
fixable: null,
2726
schema: [],

โ€Žlib/rules/no-deprecated-dollar-scopedslots-api.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ module.exports = {
2121
description:
2222
'disallow using deprecated `$scopedSlots` (in Vue.js 3.0.0+)',
2323
categories: ['vue3-essential'],
24-
url:
25-
'https://eslint.vuejs.org/rules/no-deprecated-dollar-scopedslots-api.html'
24+
url: 'https://eslint.vuejs.org/rules/no-deprecated-dollar-scopedslots-api.html'
2625
},
2726
fixable: 'code',
2827
schema: [],

โ€Žlib/rules/no-deprecated-functional-template.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ module.exports = {
2121
description:
2222
'disallow using deprecated the `functional` template (in Vue.js 3.0.0+)',
2323
categories: ['vue3-essential'],
24-
url:
25-
'https://eslint.vuejs.org/rules/no-deprecated-functional-template.html'
24+
url: 'https://eslint.vuejs.org/rules/no-deprecated-functional-template.html'
2625
},
2726
fixable: null,
2827
schema: [],

โ€Žlib/rules/no-deprecated-props-default-this.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ module.exports = {
2020
docs: {
2121
description: 'disallow props default function `this` access',
2222
categories: ['vue3-essential'],
23-
url:
24-
'https://eslint.vuejs.org/rules/no-deprecated-props-default-this.html'
23+
url: 'https://eslint.vuejs.org/rules/no-deprecated-props-default-this.html'
2524
},
2625
fixable: null,
2726
schema: [],

โ€Žlib/rules/no-deprecated-scope-attribute.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ module.exports = {
2323
},
2424
/** @param {RuleContext} context */
2525
create(context) {
26-
const templateBodyVisitor = scopeAttribute.createTemplateBodyVisitor(
27-
context
28-
)
26+
const templateBodyVisitor =
27+
scopeAttribute.createTemplateBodyVisitor(context)
2928
return utils.defineTemplateBodyVisitor(context, templateBodyVisitor)
3029
}
3130
}

โ€Žlib/rules/no-deprecated-slot-scope-attribute.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ module.exports = {
1414
description:
1515
'disallow deprecated `slot-scope` attribute (in Vue.js 2.6.0+)',
1616
categories: ['vue3-essential'],
17-
url:
18-
'https://eslint.vuejs.org/rules/no-deprecated-slot-scope-attribute.html'
17+
url: 'https://eslint.vuejs.org/rules/no-deprecated-slot-scope-attribute.html'
1918
},
2019
fixable: 'code',
2120
schema: [],

โ€Žlib/rules/no-deprecated-v-on-native-modifier.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ module.exports = {
2121
description:
2222
'disallow using deprecated `.native` modifiers (in Vue.js 3.0.0+)',
2323
categories: ['vue3-essential'],
24-
url:
25-
'https://eslint.vuejs.org/rules/no-deprecated-v-on-native-modifier.html'
24+
url: 'https://eslint.vuejs.org/rules/no-deprecated-v-on-native-modifier.html'
2625
},
2726
fixable: null,
2827
schema: [],

โ€Žlib/rules/no-deprecated-v-on-number-modifiers.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ module.exports = {
2222
description:
2323
'disallow using deprecated number (keycode) modifiers (in Vue.js 3.0.0+)',
2424
categories: ['vue3-essential'],
25-
url:
26-
'https://eslint.vuejs.org/rules/no-deprecated-v-on-number-modifiers.html'
25+
url: 'https://eslint.vuejs.org/rules/no-deprecated-v-on-number-modifiers.html'
2726
},
2827
fixable: 'code',
2928
schema: [],

โ€Žlib/rules/no-deprecated-vue-config-keycodes.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module.exports = {
1717
description:
1818
'disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+)',
1919
categories: ['vue3-essential'],
20-
url:
21-
'https://eslint.vuejs.org/rules/no-deprecated-vue-config-keycodes.html'
20+
url: 'https://eslint.vuejs.org/rules/no-deprecated-vue-config-keycodes.html'
2221
},
2322
fixable: null,
2423
schema: [],

โ€Žlib/rules/no-extra-parens.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ function createForVueSyntax(context) {
176176
}
177177

178178
return {
179-
"VAttribute[directive=true][key.name.name='bind'] > VExpressionContainer": verify,
179+
"VAttribute[directive=true][key.name.name='bind'] > VExpressionContainer":
180+
verify,
180181
'VElement > VExpressionContainer': verify
181182
}
182183
}

โ€Žlib/rules/no-irregular-whitespace.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ const utils = require('../utils')
1515
// Constants
1616
// ------------------------------------------------------------------------------
1717

18-
const ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u
19-
const IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/gmu
18+
const ALL_IRREGULARS =
19+
/[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u
20+
const IRREGULAR_WHITESPACE =
21+
/[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/gmu
2022
const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/gmu
2123

2224
// ------------------------------------------------------------------------------
@@ -195,7 +197,8 @@ module.exports = {
195197
const bodyVisitor = utils.defineTemplateBodyVisitor(context, {
196198
...(skipHTMLAttributeValues
197199
? {
198-
'VAttribute[directive=false] > VLiteral': removeInvalidNodeErrorsInHTMLAttributeValue
200+
'VAttribute[directive=false] > VLiteral':
201+
removeInvalidNodeErrorsInHTMLAttributeValue
199202
}
200203
: {}),
201204
...(skipHTMLTextContents

โ€Žlib/rules/no-potential-component-option-typo.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module.exports = {
1717
description: 'disallow a potential typo in your component property',
1818
categories: undefined,
1919
recommended: false,
20-
url:
21-
'https://eslint.vuejs.org/rules/no-potential-component-option-typo.html'
20+
url: 'https://eslint.vuejs.org/rules/no-potential-component-option-typo.html'
2221
},
2322
fixable: null,
2423
schema: [

โ€Žlib/rules/no-restricted-v-bind.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ module.exports = {
137137
/** @param {RuleContext} context */
138138
create(context) {
139139
/** @type {ParsedOption[]} */
140-
const options = (context.options.length === 0
141-
? DEFAULT_OPTIONS
142-
: context.options
140+
const options = (
141+
context.options.length === 0 ? DEFAULT_OPTIONS : context.options
143142
).map(parseOption)
144143

145144
return utils.defineTemplateBodyVisitor(context, {

โ€Žlib/rules/no-side-effects-in-computed-properties.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ module.exports = {
2121
docs: {
2222
description: 'disallow side effects in computed properties',
2323
categories: ['vue3-essential', 'essential'],
24-
url:
25-
'https://eslint.vuejs.org/rules/no-side-effects-in-computed-properties.html'
24+
url: 'https://eslint.vuejs.org/rules/no-side-effects-in-computed-properties.html'
2625
},
2726
fixable: null,
2827
schema: []
@@ -104,9 +103,9 @@ module.exports = {
104103
}
105104
const targetBody = scopeStack.body
106105

107-
const computedProperty = /** @type {ComponentComputedProperty[]} */ (computedPropertiesMap.get(
108-
vueNode
109-
)).find((cp) => {
106+
const computedProperty = /** @type {ComponentComputedProperty[]} */ (
107+
computedPropertiesMap.get(vueNode)
108+
).find((cp) => {
110109
return (
111110
cp.value &&
112111
node.loc.start.line >= cp.value.loc.start.line &&

โ€Žlib/rules/no-spaces-around-equal-signs-in-attribute.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ module.exports = {
2020
docs: {
2121
description: 'disallow spaces around equal signs in attribute',
2222
categories: ['vue3-strongly-recommended', 'strongly-recommended'],
23-
url:
24-
'https://eslint.vuejs.org/rules/no-spaces-around-equal-signs-in-attribute.html'
23+
url: 'https://eslint.vuejs.org/rules/no-spaces-around-equal-signs-in-attribute.html'
2524
},
2625
fixable: 'whitespace',
2726
schema: []

0 commit comments

Comments
ย (0)