Content-Length: 836817 | pFad | http://github.com/vuejs/eslint-plugin-vue/pull/2775/files/b11524988caa70f79efcd152928bc7ea200a3bfd

12 chore: Use ESLint v9 in development env by ota-meshi · Pull Request #2775 · vuejs/eslint-plugin-vue · GitHub
Skip to content

chore: Use ESLint v9 in development env #2775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-glasses-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-vue": patch
---

Fixed false negatives when using typescript-eslint v8 in `vue/script-indent` rule
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
yarn.lock
yarn-error.log
/docs/.vitepress/dist
/docs/.vitepress/build-system/shim/eslint.mjs
/docs/.vitepress/build-system/shim/assert.mjs
/docs/.vitepress/build-system/shim/vue-eslint-parser.mjs
/docs/.vitepress/build-system/shim/@typescript-eslint/parser.mjs
/docs/.vitepress/.temp
/docs/.vitepress/cache
typings/eslint/lib/rules
44 changes: 36 additions & 8 deletions docs/.vitepress/build-system/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,42 @@ import { fileURLToPath } from 'url'
const dirname = path.dirname(fileURLToPath(import.meta.url))

build(
path.join(dirname, './src/eslint.mjs'),
path.join(dirname, './shim/eslint.mjs'),
['path', 'assert', 'util', 'esquery']
path.join(
dirname,
'../../../node_modules/@typescript-eslint/parser/dist/index.js'
),
path.join(dirname, './shim/@typescript-eslint/parser.mjs'),
[
'stream',
'node:stream',
'os',
'node:os',
'util',
'node:util',
'path',
'node:path',
'fs',
'node:fs',
'semver',
'fast-glob',
'debug'
]
)

build(
path.join(dirname, '../../../node_modules/assert'),
path.join(dirname, './shim/assert.mjs'),
['path']
path.join(dirname, '../../../node_modules/vue-eslint-parser/index.js'),
path.join(dirname, './shim/vue-eslint-parser.mjs'),
[
'path',
'debug',
'semver',
'assert',
'module',
'events',
'esquery',
'fs',
'eslint'
]
)

function build(input: string, out: string, injects: string[] = []) {
Expand Down Expand Up @@ -47,11 +75,11 @@ function transform(code: string, injects: string[]) {
${injects
.map(
(inject) =>
`import $inject_${inject.replace(/-/gu, '_')}$ from '${inject}';`
`import $inject_${inject.replace(/[\-:]/gu, '_')}$ from '${inject}';`
)
.join('\n')}
const $_injects_$ = {${injects
.map((inject) => `${inject.replace(/-/gu, '_')}:$inject_${inject}$`)
.map((inject) => `"${inject}":$inject_${inject.replace(/[\-:]/gu, '_')}$`)
.join(',\n')}};
function require(module, ...args) {
return $_injects_$[module] || {}
Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions docs/.vitepress/build-system/shim/esquery.mjs

This file was deleted.

38 changes: 0 additions & 38 deletions docs/.vitepress/build-system/shim/path.mjs

This file was deleted.

8 changes: 0 additions & 8 deletions docs/.vitepress/build-system/src/eslint.mjs

This file was deleted.

27 changes: 18 additions & 9 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'vitepress'
import path from 'pathe'
import { fileURLToPath } from 'url'
import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin.mjs'
import eslint4b, { requireESLintUseAtYourOwnRisk4b } from 'vite-plugin-eslint4b'

// Pre-build cjs packages that cannot be bundled well.
import './build-system/build.mjs'
Expand Down Expand Up @@ -142,24 +143,32 @@ export default async () => {

vite: {
publicDir: path.resolve(dirname, './public'),
plugins: [vitePluginRequireResolve(), viteCommonjs()],
plugins: [
vitePluginRequireResolve(),
viteCommonjs(),
eslint4b() as any,
requireESLintUseAtYourOwnRisk4b()
],
resolve: {
alias: {
'eslint/use-at-your-own-risk': path.join(
'vue-eslint-parser': path.join(
dirname,
'./build-system/shim/vue-eslint-parser.mjs'
),
'@typescript-eslint/parser': path.join(
dirname,
'./build-system/shim/eslint/use-at-your-own-risk.mjs'
'./build-system/shim/@typescript-eslint/parser.mjs'
),
eslint: path.join(dirname, './build-system/shim/eslint.mjs'),
assert: path.join(dirname, './build-system/shim/assert.mjs'),
path: path.join(dirname, './build-system/shim/path.mjs'),

tslib: path.join(dirname, '../../node_modules/tslib/tslib.es6.js'),
esquery: path.join(dirname, './build-system/shim/esquery.mjs'),
globby: path.join(dirname, './build-system/shim/globby.mjs')
globby: path.join(dirname, './build-system/shim/empty.mjs'),
'fast-glob': path.join(dirname, './build-system/shim/empty.mjs'),
'node:fs': 'fs',
'node:path': 'path',
'node:util': 'util'
}
},
define: {
'process.env.NODE_DEBUG': 'false',
'require.cache': '{}'
}
},
Expand Down
83 changes: 33 additions & 50 deletions docs/.vitepress/theme/components/eslint-code-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
class="eslint-code-block"
:filename="filename"
:language="language"
:preprocess="preprocess"
:postprocess="postprocess"
dark
:format="format"
:fix="fix"
Expand All @@ -20,8 +18,6 @@
<script>
import EslintEditor from '@ota-meshi/site-kit-eslint-editor-vue'
import { markRaw } from 'vue'
import * as plugin from '../../../..'
const { rules, processors } = plugin.default || plugin

export default {
name: 'ESLintCodeBlock',
Expand Down Expand Up @@ -61,13 +57,23 @@ export default {
code: '',
height: '100px',
linter: null,
preprocess: processors['.vue'].preprocess,
postprocess: processors['.vue'].postprocess,
format: {
insertSpaces: true,
tabSize: 2
},
tsEslintParser: null
tsEslintParser: null,
baseConfig: {
files: ['**'],
plugins: {},
processor: 'vue/vue',
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: { jsx: true }
}
}
}
}
},

Expand All @@ -85,40 +91,13 @@ export default {
}
}
return {
globals: {
console: false,
// ES2015 globals
ArrayBuffer: false,
DataView: false,
Float32Array: false,
Float64Array: false,
Int16Array: false,
Int32Array: false,
Int8Array: false,
Map: false,
Promise: false,
Proxy: false,
Reflect: false,
Set: false,
Symbol: false,
Uint16Array: false,
Uint32Array: false,
Uint8Array: false,
Uint8ClampedArray: false,
WeakMap: false,
WeakSet: false,
// ES2017 globals
Atomics: false,
SharedArrayBuffer: false
},
...this.baseConfig,
rules: this.rules,
parser: 'vue-eslint-parser',
parserOptions: {
parser,
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true
languageOptions: {
...this.baseConfig?.languageOptions,
parserOptions: {
...this.baseConfig?.languageOptions?.parserOptions,
parser
}
}
}
Expand Down Expand Up @@ -150,7 +129,8 @@ export default {

methods: {
async loadTypescriptESLint() {
this.tsEslintParser = await import('@typescript-eslint/parser')
const tsEslintParser = await import('@typescript-eslint/parser')
this.tsEslintParser = tsEslintParser.default || tsEslintParser
}
},

Expand All @@ -161,21 +141,24 @@ export default {
const lines = this.code.split('\n').length
this.height = `${Math.max(120, 20 * (1 + lines))}px`
// Load linter.
const [{ Linter }, { parseForESLint }] = await Promise.all([
const [plugin, { Linter }, vueEslintParser, globals] = await Promise.all([
import('../../../..'),
import('eslint'),
import('espree').then(() => import('vue-eslint-parser'))
import('vue-eslint-parser'),
import('globals')
])
if (this.langTs || this.typescript) {
await this.loadTypescriptESLint()
}

const linter = (this.linter = markRaw(new Linter()))

for (const ruleId of Object.keys(rules)) {
linter.defineRule(`vue/${ruleId}`, rules[ruleId])
}

linter.defineParser('vue-eslint-parser', { parseForESLint })
this.linter = markRaw(new Linter())
this.baseConfig.plugins.vue = markRaw(plugin.default || plugin)
this.baseConfig.languageOptions.parser = markRaw(
vueEslintParser.default || vueEslintParser
)
this.baseConfig.languageOptions.globals = markRaw({
...globals.browser
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions docs/rules/comment-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ This rule sends all `eslint-disable`-like comments as errors to the post-process

The `eslint-disable`-like comments can be used in the `<template>` and in the block level.

<eslint-code-block :rules="{'vue/comment-directive': ['error'], 'vue/max-attributes-per-line': ['error'], 'vue/component-tags-order': ['error'] }">
<eslint-code-block :rules="{'vue/comment-directive': ['error'], 'vue/max-attributes-per-line': ['error'], 'vue/block-order': ['error'] }">

```vue
<template>
<!-- eslint-disable-next-line vue/max-attributes-per-line -->
<div a="1" b="2" c="3" d="4" />
</template>

<!-- eslint-disable-next-line vue/component-tags-order -->
<!-- eslint-disable-next-line vue/block-order -->
<style>
</style>
```
Expand All @@ -60,7 +60,7 @@ The `eslint-disable`-like comments can be used in the `<template>` and in the bl

The `eslint-disable` comments has no effect after one block.

<eslint-code-block :rules="{'vue/comment-directive': ['error'], 'vue/max-attributes-per-line': ['error'], 'vue/component-tags-order': ['error'] }">
<eslint-code-block :rules="{'vue/comment-directive': ['error'], 'vue/max-attributes-per-line': ['error'], 'vue/block-order': ['error'] }">

```vue
<style>
Expand Down
1 change: 1 addition & 0 deletions docs/rules/eqeqeq.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ since: v5.2.0
> Require the use of `===` and `!==` in `<template>`

- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix-problems) can automatically fix some of the problems reported by this rule.
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

This rule is the same rule as core [eqeqeq] rule but it applies to the expressions in `<template>`.

Expand Down
4 changes: 2 additions & 2 deletions docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ The following rules extend the rules provided by ESLint itself and apply them to
| [vue/comma-style] | Enforce consistent comma style in `<template>` | :wrench: | :lipstick: |
| [vue/dot-location] | Enforce consistent newlines before and after dots in `<template>` | :wrench: | :lipstick: |
| [vue/dot-notation] | Enforce dot notation whenever possible in `<template>` | :wrench: | :hammer: |
| [vue/eqeqeq] | Require the use of `===` and `!==` in `<template>` | :wrench: | :hammer: |
| [vue/eqeqeq] | Require the use of `===` and `!==` in `<template>` | :wrench::bulb: | :hammer: |
| [vue/func-call-spacing] | Require or disallow spacing between function identifiers and their invocations in `<template>` | :wrench: | :lipstick: |
| [vue/key-spacing] | Enforce consistent spacing between property names and type annotations in types and interfaces in `<template>` | :wrench: | :lipstick: |
| [vue/keyword-spacing] | Enforce consistent spacing before and after keywords in `<template>` | :wrench: | :lipstick: |
Expand All @@ -324,7 +324,7 @@ The following rules extend the rules provided by ESLint itself and apply them to
| [vue/no-constant-condition] | Disallow constant expressions in conditions in `<template>` | | :warning: |
| [vue/no-empty-pattern] | Disallow empty destructuring patterns in `<template>` | | :warning: |
| [vue/no-extra-parens] | Disallow unnecessary parentheses in `<template>` | :wrench: | :lipstick: |
| [vue/no-implicit-coercion] | Disallow shorthand type conversions in `<template>` | :wrench: | :hammer: |
| [vue/no-implicit-coercion] | Disallow shorthand type conversions in `<template>` | :wrench::bulb: | :hammer: |
| [vue/no-irregular-whitespace] | disallow irregular whitespace in `.vue` files | | :warning: |
| [vue/no-loss-of-precision] | Disallow literal numbers that lose precision in `<template>` | | :warning: |
| [vue/no-restricted-syntax] | Disallow specified syntax in `<template>` | | :hammer: |
Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-implicit-coercion.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ since: v9.33.0
> Disallow shorthand type conversions in `<template>`

- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix-problems) can automatically fix some of the problems reported by this rule.
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

This rule is the same rule as core [no-implicit-coercion] rule but it applies to the expressions in `<template>`.

Expand Down
5 changes: 2 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

'!.vitepress',
'docs/.vitepress/dist',
'docs/.vitepress/build-system/shim/eslint.mjs',
'docs/.vitepress/build-system/shim/assert.mjs',
'docs/.vitepress/build-system/shim/path.mjs',
'docs/.vitepress/build-system/shim/vue-eslint-parser.mjs',
'docs/.vitepress/build-system/shim/@typescript-eslint/parser.mjs',
'docs/.vitepress/.temp',
'docs/.vitepress/cache'
]
Expand All @@ -45,7 +44,7 @@
// turn off some rules from shared configs in all files
{
rules: {
'eslint-plugin/require-meta-default-options': 'off', // TODO: enable when all rules have defaultOptions

Check warning on line 47 in eslint.config.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected 'todo' comment: 'TODO: enable when all rules have...'
'eslint-plugin/require-meta-docs-recommended': 'off', // use `categories` instead
'eslint-plugin/require-meta-schema-description': 'off',

Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/vuejs/eslint-plugin-vue/pull/2775/files/b11524988caa70f79efcd152928bc7ea200a3bfd

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy