Skip to content

Commit 7cdf3ff

Browse files
authored
Merge branch 'master' into feature/#2465_autofix_in_define-props-declaration
2 parents 2a1c654 + c64bf94 commit 7cdf3ff

File tree

84 files changed

+1175
-1023
lines changed

Some content is hidden

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

84 files changed

+1175
-1023
lines changed

docs/.vitepress/build-system/build.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Pre-build cjs packages that cannot be bundled well.
33
*/
44
import esbuild from 'esbuild'
5-
import path from 'path'
5+
import path from 'pathe'
66
import fs from 'fs'
77
import { fileURLToPath } from 'url'
88

docs/.vitepress/config.mts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DefaultTheme } from 'vitepress'
22
import { defineConfig } from 'vitepress'
3-
import path from 'path'
3+
import path from 'pathe'
44
import { fileURLToPath } from 'url'
55
import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin.mjs'
66

@@ -214,6 +214,10 @@ export default async () => {
214214
]
215215
},
216216

217+
outline: {
218+
level: 'deep'
219+
},
220+
217221
algolia: {
218222
appId: '2L4MGZSULB',
219223
apiKey: 'fdf57932b27a6c230d01a890492ab76d',

docs/.vitepress/vite-plugin.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { UserConfig } from 'vitepress'
2-
import path from 'path'
2+
import path from 'pathe'
33
import { fileURLToPath } from 'url'
44
import esbuild from 'esbuild'
55
type Plugin = Extract<

docs/rules/object-curly-newline.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ This rule was introduced in eslint-plugin-vue v7.0.0
3636
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/object-curly-newline.js)
3737
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/object-curly-newline.js)
3838

39-
<sup>Taken with ❤️ [from ESLint Stylistic](https://eslint.style/rules/js/object-curly-newline)</sup>
39+
<sup>Taken with ❤️ [from ESLint Stylistic](https://eslint.style/rules/ts/object-curly-newline)</sup>

docs/rules/object-property-newline.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ This rule was introduced in eslint-plugin-vue v7.0.0
3636
- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/object-property-newline.js)
3737
- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/object-property-newline.js)
3838

39-
<sup>Taken with ❤️ [from ESLint Stylistic](https://eslint.style/rules/js/object-property-newline)</sup>
39+
<sup>Taken with ❤️ [from ESLint Stylistic](https://eslint.style/rules/ts/object-property-newline)</sup>

docs/user-guide/index.md

+44-4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,48 @@ If you want to use custom parsers such as [@babel/eslint-parser](https://www.npm
146146
}
147147
```
148148

149+
Full example:
150+
151+
::: code-group
152+
153+
```json [.eslintrc]
154+
{
155+
"root": true,
156+
"plugins": ["@typescript-eslint"],
157+
"extends": [
158+
"eslint:recommended",
159+
"plugin:@typescript-eslint/recommended",
160+
"plugin:vue/vue3-recommended"
161+
],
162+
"parser": "vue-eslint-parser",
163+
"parserOptions": {
164+
"parser": "@typescript-eslint/parser"
165+
}
166+
}
167+
```
168+
169+
```js [eslint.config.js]
170+
import js from '@eslint/js'
171+
import eslintPluginVue from 'eslint-plugin-vue'
172+
import ts from 'typescript-eslint'
173+
174+
export default ts.config(
175+
js.configs.recommended,
176+
...ts.configs.recommended,
177+
...eslintPluginVue.configs['flat/recommended'],
178+
{
179+
files: ['*.vue', '**/*.vue'],
180+
languageOptions: {
181+
parserOptions: {
182+
parser: '@typescript-eslint/parser'
183+
}
184+
}
185+
}
186+
)
187+
```
188+
189+
:::
190+
149191
The `parserOptions.parser` option can also specify an object to specify multiple parsers. See [vue-eslint-parser README](https://github.com/vuejs/vue-eslint-parser#readme) for more details.
150192

151193
### How does ESLint detect components?
@@ -441,8 +483,7 @@ In [Nuxt 3](https://nuxt.com/) or with [`unplugin-auto-import`](https://github.c
441483

442484
::: code-group
443485

444-
```json [Legacy Config]
445-
// .eslintrc
486+
```json [.eslintrc]
446487
{
447488
"globals": {
448489
"ref": "readonly",
@@ -454,8 +495,7 @@ In [Nuxt 3](https://nuxt.com/) or with [`unplugin-auto-import`](https://github.c
454495
}
455496
```
456497

457-
```js [Flat Config]
458-
// eslint.config.js
498+
```js [eslint.config.js]
459499
export default [
460500
{
461501
languageOptions: {

eslint.config.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
'use strict'
22

33
const globals = require('globals')
4-
const { FlatCompat } = require('@eslint/eslintrc')
54
const eslintPluginEslintPlugin = require('eslint-plugin-eslint-plugin/configs/all')
5+
const eslintPluginJsonc = require('eslint-plugin-jsonc')
6+
const eslintPluginNodeDependencies = require('eslint-plugin-node-dependencies')
67
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended')
78
const eslintPluginUnicorn = require('eslint-plugin-unicorn')
89

9-
const eslintrc = new FlatCompat({
10-
baseDirectory: __dirname
11-
})
12-
1310
module.exports = [
1411
{
1512
ignores: [
@@ -30,10 +27,8 @@ module.exports = [
3027
},
3128
eslintPluginEslintPlugin,
3229
eslintPluginUnicorn.configs['flat/recommended'],
33-
...eslintrc.extends(
34-
'plugin:node-dependencies/recommended',
35-
'plugin:jsonc/recommended-with-jsonc'
36-
),
30+
...eslintPluginNodeDependencies.configs['flat/recommended'],
31+
...eslintPluginJsonc.configs['flat/recommended-with-jsonc'],
3732
eslintPluginPrettierRecommended,
3833
{
3934
plugins: {
@@ -144,6 +139,7 @@ module.exports = [
144139
'prefer-const': 2,
145140

146141
'prettier/prettier': 'error',
142+
'eslint-plugin/require-meta-docs-recommended': 'off', // use `categories` instead
147143
'eslint-plugin/require-meta-fixable': [
148144
'error',
149145
{ catchNoFixerButFixableProperty: true }

lib/configs/flat/base.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const globals = require('globals')
77
module.exports = [
88
{
9+
name: 'vue:base:setup',
910
plugins: {
1011
get vue() {
1112
return require('../../index')
@@ -17,6 +18,7 @@ module.exports = [
1718
}
1819
},
1920
{
21+
name: 'vue:base:setup-for-vue',
2022
files: ['*.vue', '**/*.vue'],
2123
plugins: {
2224
get vue() {

lib/configs/flat/vue2-essential.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = require('./base.js')
99
module.exports = [
1010
...config,
1111
{
12+
name: 'vue:vue2-essential:rules',
1213
rules: {
1314
'vue/multi-word-component-names': 'error',
1415
'vue/no-arrow-functions-in-watch': 'error',

lib/configs/flat/vue2-recommended.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = require('./vue2-strongly-recommended.js')
99
module.exports = [
1010
...config,
1111
{
12+
name: 'vue:vue2-recommended:rules',
1213
rules: {
1314
'vue/attributes-order': 'warn',
1415
'vue/component-tags-order': 'warn',

lib/configs/flat/vue2-strongly-recommended.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = require('./vue2-essential.js')
99
module.exports = [
1010
...config,
1111
{
12+
name: 'vue:vue2-strongly-recommended:rules',
1213
rules: {
1314
'vue/attribute-hyphenation': 'warn',
1415
'vue/component-definition-name-casing': 'warn',

lib/configs/flat/vue3-essential.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = require('./base.js')
99
module.exports = [
1010
...config,
1111
{
12+
name: 'vue:essential:rules',
1213
rules: {
1314
'vue/multi-word-component-names': 'error',
1415
'vue/no-arrow-functions-in-watch': 'error',

lib/configs/flat/vue3-recommended.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = require('./vue3-strongly-recommended.js')
99
module.exports = [
1010
...config,
1111
{
12+
name: 'vue:recommended:rules',
1213
rules: {
1314
'vue/attributes-order': 'warn',
1415
'vue/component-tags-order': 'warn',

lib/configs/flat/vue3-strongly-recommended.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = require('./vue3-essential.js')
99
module.exports = [
1010
...config,
1111
{
12+
name: 'vue:strongly-recommended:rules',
1213
rules: {
1314
'vue/attribute-hyphenation': 'warn',
1415
'vue/component-definition-name-casing': 'warn',

lib/rules/attribute-hyphenation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = {
5151
allOf: [
5252
{ type: 'string' },
5353
{ not: { type: 'string', pattern: ':exit$' } },
54-
{ not: { type: 'string', pattern: '^\\s*$' } }
54+
{ not: { type: 'string', pattern: String.raw`^\s*$` } }
5555
]
5656
},
5757
uniqueItems: true,

lib/rules/html-indent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
allOf: [
6363
{ type: 'string' },
6464
{ not: { type: 'string', pattern: ':exit$' } },
65-
{ not: { type: 'string', pattern: '^\\s*$' } }
65+
{ not: { type: 'string', pattern: String.raw`^\s*$` } }
6666
]
6767
},
6868
uniqueItems: true,

lib/rules/no-invalid-model-keys.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ module.exports = {
1313
categories: undefined,
1414
url: 'https://eslint.vuejs.org/rules/no-invalid-model-keys.html'
1515
},
16-
schema: [],
1716
deprecated: true,
18-
replacedBy: ['valid-model-definition']
17+
replacedBy: ['valid-model-definition'],
18+
schema: []
1919
},
2020
/** @param {RuleContext} context */
2121
create(context) {

lib/rules/no-restricted-custom-event.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ module.exports = {
155155
sourceCode.text[nameWithLoc.range[0]]
156156
}${JSON.stringify(option.suggest)
157157
.slice(1, -1)
158-
.replace(/'/gu, "\\'")}${
158+
.replace(/'/gu, String.raw`\'`)}${
159159
sourceCode.text[nameWithLoc.range[1] - 1]
160160
}`
161161
)

lib/rules/no-setup-props-reactivity-loss.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,35 @@ module.exports = {
7979
left.type !== 'ArrayPattern' &&
8080
left.type !== 'ObjectPattern' &&
8181
rightNode.type !== 'MemberExpression' &&
82-
rightNode.type !== 'ConditionalExpression'
82+
rightNode.type !== 'ConditionalExpression' &&
83+
rightNode.type !== 'TemplateLiteral'
8384
) {
8485
return
8586
}
8687

87-
/** @type {Expression | Super} */
88-
let rightId = rightNode
88+
if (rightNode.type === 'TemplateLiteral') {
89+
rightNode.expressions.some((expression) =>
90+
checkMemberAccess(expression, propsReferences, left, right)
91+
)
92+
} else {
93+
checkMemberAccess(rightNode, propsReferences, left, right)
94+
}
95+
}
96+
97+
/**
98+
* @param {Expression | Super} rightId
99+
* @param {ScopePropsReferences} propsReferences
100+
* @param {Pattern} left
101+
* @param {Expression} right
102+
* @return {boolean}
103+
*/
104+
function checkMemberAccess(rightId, propsReferences, left, right) {
89105
while (rightId.type === 'MemberExpression') {
90106
rightId = utils.skipChainExpression(rightId.object)
91107
}
92108
if (rightId.type === 'Identifier' && propsReferences.refs.has(rightId)) {
93109
report(left, 'getProperty', propsReferences.scopeName)
110+
return true
94111
}
95112
if (
96113
rightId.type === 'ConditionalExpression' &&
@@ -99,7 +116,9 @@ module.exports = {
99116
isPropsMemberAccessed(rightId.alternate, propsReferences))
100117
) {
101118
report(right, 'getProperty', propsReferences.scopeName)
119+
return true
102120
}
121+
return false
103122
}
104123

105124
/**

lib/rules/no-undef-properties.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ module.exports = {
106106
/** @param {RuleContext} context */
107107
create(context) {
108108
const options = context.options[0] || {}
109-
const ignores = /** @type {string[]} */ (options.ignores || ['/^\\$/']).map(
110-
toRegExp
111-
)
109+
const ignores = /** @type {string[]} */ (
110+
options.ignores || [String.raw`/^\$/`]
111+
).map(toRegExp)
112112
const propertyReferenceExtractor = definePropertyReferenceExtractor(context)
113113
const programNode = context.getSourceCode().ast
114114

lib/rules/order-in-components.js

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ module.exports = {
259259
}
260260

261261
/**
262+
* @param {RuleFixer} fixer
262263
* @param {Property} propertyNode
263264
* @param {Property} unorderedPropertyNode
264265
*/

lib/rules/require-toggle-inside-transition.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
const utils = require('../utils')
88

9+
/**
10+
* @param {VDirective} vBindAppear
11+
*/
12+
function isValidBindAppear(vBindAppear) {
13+
if (
14+
vBindAppear.value?.expression &&
15+
vBindAppear.value.expression.type === 'Literal'
16+
) {
17+
return vBindAppear.value.expression?.value !== false
18+
}
19+
20+
return true
21+
}
22+
923
module.exports = {
1024
meta: {
1125
type: 'problem',
@@ -35,7 +49,11 @@ module.exports = {
3549

3650
/** @type VElement */ // @ts-expect-error
3751
const parent = element.parent
38-
if (utils.hasAttribute(parent, 'appear')) {
52+
const vBindAppear = utils.getDirective(parent, 'bind', 'appear')
53+
if (
54+
utils.hasAttribute(parent, 'appear') ||
55+
(vBindAppear && isValidBindAppear(vBindAppear))
56+
) {
3957
return
4058
}
4159

lib/rules/script-indent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
allOf: [
3333
{ type: 'string' },
3434
{ not: { type: 'string', pattern: ':exit$' } },
35-
{ not: { type: 'string', pattern: '^\\s*$' } }
35+
{ not: { type: 'string', pattern: String.raw`^\s*$` } }
3636
]
3737
},
3838
uniqueItems: true,

lib/rules/script-setup-uses-vars.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ module.exports = {
2828
categories: undefined,
2929
url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html'
3030
},
31-
schema: [],
32-
deprecated: true
31+
deprecated: true,
32+
schema: []
3333
},
3434
/**
3535
* @param {RuleContext} context - The rule context.

lib/rules/v-on-event-hyphenation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
allOf: [
3131
{ type: 'string' },
3232
{ not: { type: 'string', pattern: ':exit$' } },
33-
{ not: { type: 'string', pattern: '^\\s*$' } }
33+
{ not: { type: 'string', pattern: String.raw`^\s*$` } }
3434
]
3535
},
3636
uniqueItems: true,

0 commit comments

Comments
 (0)