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

Lines changed: 6 additions & 9 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 1 addition & 2 deletions
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
}

0 commit comments

Comments
ย (0)