Skip to content

Commit 236a40f

Browse files
committedAug 14, 2024··
chore: upgrade to eslint 9
1 parent ab2516a commit 236a40f

11 files changed

+492
-1015
lines changed
 

‎.eslintignore

-3
This file was deleted.

‎.eslintrc.cjs

-179
This file was deleted.

‎eslint.config.js

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// @ts-check
2+
import { builtinModules } from 'node:module'
3+
import eslint from '@eslint/js'
4+
import tseslint from 'typescript-eslint'
5+
import nodePlugin from 'eslint-plugin-n'
6+
import * as regexpPlugin from 'eslint-plugin-regexp'
7+
import importPlugin from 'eslint-plugin-import-x'
8+
9+
export default tseslint.config(
10+
eslint.configs.recommended,
11+
...tseslint.configs.recommended,
12+
nodePlugin.configs['flat/recommended'],
13+
regexpPlugin.configs['flat/recommended'],
14+
{ ignores: ['**/dist', '**/playground-temp', '**/temp'] },
15+
{
16+
plugins: {
17+
import: importPlugin,
18+
},
19+
rules: {
20+
eqeqeq: ['warn', 'always', { null: 'never' }],
21+
'no-empty': ['warn', { allowEmptyCatch: true }],
22+
'no-useless-escape': 'off',
23+
'prefer-const': ['warn', { destructuring: 'all' }],
24+
25+
'n/no-process-exit': 'off',
26+
'n/no-missing-import': [
27+
'error',
28+
{
29+
allowModules: ['types', 'estree', 'less', 'sass', 'stylus'],
30+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
31+
},
32+
],
33+
'n/no-missing-require': [
34+
'error',
35+
{
36+
// for try-catching yarn pnp
37+
allowModules: ['pnpapi', 'vite'],
38+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
39+
},
40+
],
41+
'n/no-extraneous-import': [
42+
'error',
43+
{ allowModules: ['vite', 'less', 'sass', 'vitest', 'unbuild'] },
44+
],
45+
'n/no-extraneous-require': ['error', { allowModules: ['vite'] }],
46+
'n/no-deprecated-api': 'off',
47+
'n/no-unpublished-import': 'off',
48+
'n/no-unpublished-require': 'off',
49+
'n/no-unsupported-features/es-syntax': 'off',
50+
51+
'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
52+
'@typescript-eslint/explicit-module-boundary-types': [
53+
'error',
54+
{ allowArgumentsExplicitlyTypedAsAny: true },
55+
],
56+
'@typescript-eslint/no-empty-function': [
57+
'error',
58+
{ allow: ['arrowFunctions'] },
59+
],
60+
'@typescript-eslint/no-empty-object-type': 'off',
61+
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
62+
'@typescript-eslint/no-inferrable-types': 'off',
63+
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
64+
'@typescript-eslint/no-require-imports': 'off',
65+
'@typescript-eslint/consistent-type-imports': [
66+
'error',
67+
{ prefer: 'type-imports' },
68+
],
69+
70+
'import/no-nodejs-modules': [
71+
'error',
72+
{ allow: builtinModules.map((mod) => `node:${mod}`) },
73+
],
74+
'import/no-duplicates': 'error',
75+
'import/order': 'error',
76+
'sort-imports': [
77+
'error',
78+
{
79+
ignoreCase: false,
80+
ignoreDeclarationSort: true,
81+
ignoreMemberSort: false,
82+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
83+
allowSeparatedGroups: false,
84+
},
85+
],
86+
87+
'regexp/no-contradiction-with-assertion': 'error',
88+
},
89+
},
90+
{
91+
files: ['packages/**'],
92+
ignores: ['**/__tests__/**'],
93+
rules: {
94+
'no-restricted-globals': ['error', 'require', '__dirname', '__filename'],
95+
},
96+
},
97+
{
98+
files: ['*.spec.ts'],
99+
rules: {
100+
'n/no-extraneous-import': 'off',
101+
},
102+
},
103+
{
104+
files: ['**/build.config.ts'],
105+
rules: {
106+
'no-undef': 'off',
107+
'n/no-missing-import': 'off',
108+
'@typescript-eslint/explicit-module-boundary-types': 'off',
109+
},
110+
},
111+
{
112+
files: ['playground/**'],
113+
rules: {
114+
'n/no-extraneous-import': 'off',
115+
'n/no-extraneous-require': 'off',
116+
'n/no-missing-import': 'off',
117+
'n/no-missing-require': 'off',
118+
// engine field doesn't exist in playgrounds
119+
'n/no-unsupported-features/es-builtins': [
120+
'error',
121+
{
122+
version: '^18.0.0 || >=20.0.0',
123+
},
124+
],
125+
'n/no-unsupported-features/node-builtins': [
126+
'error',
127+
{
128+
version: '^18.0.0 || >=20.0.0',
129+
},
130+
],
131+
'@typescript-eslint/explicit-module-boundary-types': 'off',
132+
},
133+
},
134+
{
135+
files: ['playground/**'],
136+
ignores: ['**/__tests__/**'],
137+
rules: {
138+
'no-undef': 'off',
139+
'no-empty': 'off',
140+
'no-constant-condition': 'off',
141+
'@typescript-eslint/no-empty-function': 'off',
142+
},
143+
},
144+
{
145+
files: ['*.js', '*.mjs', '*.cjs'],
146+
rules: {
147+
'@typescript-eslint/explicit-module-boundary-types': 'off',
148+
},
149+
},
150+
{
151+
files: ['*.d.ts'],
152+
rules: {
153+
'@typescript-eslint/triple-slash-reference': 'off',
154+
},
155+
},
156+
)

‎package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,18 @@
3737
},
3838
"devDependencies": {
3939
"@babel/types": "^7.24.7",
40+
"@eslint/js": "^9.9.0",
4041
"@types/babel__core": "^7.20.5",
4142
"@types/convert-source-map": "^2.0.3",
4243
"@types/debug": "^4.1.12",
4344
"@types/fs-extra": "^11.0.4",
4445
"@types/node": "^20.14.2",
4546
"@types/resolve": "^1.20.6",
46-
"@typescript-eslint/eslint-plugin": "^8.0.0",
47-
"@typescript-eslint/parser": "^8.0.0",
4847
"@vitejs/release-scripts": "^1.3.2",
4948
"conventional-changelog-cli": "^5.0.0",
50-
"eslint": "^8.57.0",
51-
"eslint-define-config": "^2.1.0",
52-
"eslint-plugin-import": "^2.29.1",
53-
"eslint-plugin-n": "^14.0.0",
49+
"eslint": "^9.9.0",
50+
"eslint-plugin-import-x": "^3.1.0",
51+
"eslint-plugin-n": "^17.10.2",
5452
"eslint-plugin-regexp": "^2.6.0",
5553
"execa": "^9.2.0",
5654
"fast-glob": "^3.3.2",
@@ -66,6 +64,7 @@
6664
"simple-git-hooks": "^2.11.1",
6765
"tsx": "^4.15.5",
6866
"typescript": "^5.4.5",
67+
"typescript-eslint": "^8.1.0",
6968
"unbuild": "2.0.0",
7069
"vite": "catalog:",
7170
"vitest": "^2.0.0",

‎packages/plugin-vue/src/handleHotUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
resolveScript,
1919
setResolvedScript,
2020
} from './script'
21-
import type { ResolvedOptions } from '.'
21+
import type { ResolvedOptions } from './index'
2222

2323
const debug = _debug('vite:hmr')
2424

‎packages/plugin-vue/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { transformTemplateInMain } from './template'
2424
import { isEqualBlock, isOnlyTemplateChanged } from './handleHotUpdate'
2525
import { createRollupError } from './utils/error'
2626
import { EXPORT_HELPER_ID } from './helper'
27-
import type { ResolvedOptions } from '.'
27+
import type { ResolvedOptions } from './index'
2828

2929
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
3030
export async function transformMain(

‎packages/plugin-vue/src/script.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SFCDescriptor, SFCScriptBlock } from 'vue/compiler-sfc'
22
import { resolveTemplateCompilerOptions } from './template'
33
import { cache as descriptorCache } from './utils/descriptorCache'
4-
import type { ResolvedOptions } from '.'
4+
import type { ResolvedOptions } from './index'
55

66
// ssr and non ssr builds would output different script content
77
let clientCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()

‎packages/plugin-vue/src/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { SFCDescriptor } from 'vue/compiler-sfc'
22
import type { ExistingRawSourceMap, TransformPluginContext } from 'rollup'
33
import type { RawSourceMap } from 'source-map-js'
44
import { formatPostcssSourceMap } from 'vite'
5-
import type { ResolvedOptions } from '.'
5+
import type { ResolvedOptions } from './index'
66

77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
88
export async function transformStyle(

‎packages/plugin-vue/src/template.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
import type { PluginContext, TransformPluginContext } from 'rollup'
1010
import { getResolvedScript, resolveScript } from './script'
1111
import { createRollupError } from './utils/error'
12-
import type { ResolvedOptions } from '.'
12+
import type { ResolvedOptions } from './index'
1313

1414
export async function transformTemplateAsModule(
1515
code: string,

‎packages/plugin-vue/src/utils/descriptorCache.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path'
33
import { createHash } from 'node:crypto'
44
import type { CompilerError, SFCDescriptor } from 'vue/compiler-sfc'
55
import { normalizePath } from 'vite'
6-
import type { ResolvedOptions, VueQuery } from '..'
6+
import type { ResolvedOptions, VueQuery } from '../index'
77

88
// compiler-sfc should be exported so it can be re-used
99
export interface SFCParseResult {

‎pnpm-lock.yaml

+325-821
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.