Skip to content

Commit 62ebe28

Browse files
authored
refactor(eslint): migrate to eslint-plugin-n (#12895)
1 parent 93e095c commit 62ebe28

File tree

7 files changed

+57
-43
lines changed

7 files changed

+57
-43
lines changed

.eslintrc.cjs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = defineConfig({
66
root: true,
77
extends: [
88
'eslint:recommended',
9-
'plugin:node/recommended',
9+
'plugin:n/recommended',
1010
'plugin:@typescript-eslint/recommended',
1111
'plugin:regexp/recommended',
1212
],
@@ -29,37 +29,32 @@ module.exports = defineConfig({
2929
},
3030
],
3131

32-
'node/no-missing-import': [
33-
'error',
34-
{
35-
allowModules: ['types', 'estree', 'less', 'sass', 'stylus'],
36-
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
37-
},
38-
],
39-
'node/no-missing-require': [
32+
'n/no-process-exit': 'off',
33+
'n/no-missing-import': 'off',
34+
'n/no-missing-require': [
4035
'error',
4136
{
4237
// for try-catching yarn pnp
4338
allowModules: ['pnpapi', 'vite'],
4439
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
4540
},
4641
],
47-
'node/no-extraneous-import': [
42+
'n/no-extraneous-import': [
4843
'error',
4944
{
50-
allowModules: ['vite', 'less', 'sass', 'vitest'],
45+
allowModules: ['vite', 'less', 'sass', 'vitest', 'unbuild'],
5146
},
5247
],
53-
'node/no-extraneous-require': [
48+
'n/no-extraneous-require': [
5449
'error',
5550
{
5651
allowModules: ['vite'],
5752
},
5853
],
59-
'node/no-deprecated-api': 'off',
60-
'node/no-unpublished-import': 'off',
61-
'node/no-unpublished-require': 'off',
62-
'node/no-unsupported-features/es-syntax': 'off',
54+
'n/no-deprecated-api': 'off',
55+
'n/no-unpublished-import': 'off',
56+
'n/no-unpublished-require': 'off',
57+
'n/no-unsupported-features/es-syntax': 'off',
6358

6459
'@typescript-eslint/ban-ts-comment': 'error',
6560
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
@@ -118,7 +113,7 @@ module.exports = defineConfig({
118113
{
119114
files: 'packages/vite/**/*.*',
120115
rules: {
121-
'node/no-restricted-require': [
116+
'n/no-restricted-require': [
122117
'error',
123118
Object.keys(
124119
require('./packages/vite/package.json').devDependencies,
@@ -141,32 +136,32 @@ module.exports = defineConfig({
141136
{
142137
files: ['packages/vite/src/types/**', '*.spec.ts'],
143138
rules: {
144-
'node/no-extraneous-import': 'off',
139+
'n/no-extraneous-import': 'off',
145140
},
146141
},
147142
{
148143
files: ['packages/create-vite/template-*/**', '**/build.config.ts'],
149144
rules: {
150145
'no-undef': 'off',
151-
'node/no-missing-import': 'off',
146+
'n/no-missing-import': 'off',
152147
'@typescript-eslint/explicit-module-boundary-types': 'off',
153148
},
154149
},
155150
{
156151
files: ['playground/**'],
157152
rules: {
158-
'node/no-extraneous-import': 'off',
159-
'node/no-extraneous-require': 'off',
160-
'node/no-missing-import': 'off',
161-
'node/no-missing-require': 'off',
153+
'n/no-extraneous-import': 'off',
154+
'n/no-extraneous-require': 'off',
155+
'n/no-missing-import': 'off',
156+
'n/no-missing-require': 'off',
162157
// engine field doesn't exist in playgrounds
163-
'node/no-unsupported-features/es-builtins': [
158+
'n/no-unsupported-features/es-builtins': [
164159
'error',
165160
{
166161
version: '^14.18.0 || >=16.0.0',
167162
},
168163
],
169-
'node/no-unsupported-features/node-builtins': [
164+
'n/no-unsupported-features/node-builtins': [
170165
'error',
171166
{
172167
version: '^14.18.0 || >=16.0.0',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"eslint": "^8.36.0",
6565
"eslint-define-config": "^1.17.0",
6666
"eslint-plugin-import": "^2.27.5",
67-
"eslint-plugin-node": "^11.1.0",
67+
"eslint-plugin-n": "^15.7.0",
6868
"eslint-plugin-regexp": "^1.13.0",
6969
"execa": "^7.1.1",
7070
"fast-glob": "^3.2.12",

packages/plugin-legacy/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable node/no-extraneous-import */
1+
/* eslint-disable n/no-extraneous-import */
22
import path from 'node:path'
33
import { createHash } from 'node:crypto'
44
import { createRequire } from 'node:module'

packages/vite/src/client/client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { ErrorPayload, HMRPayload, Update } from 'types/hmrPayload'
22
import type { ModuleNamespace, ViteHotContext } from 'types/hot'
33
import type { InferCustomEventPayload } from 'types/customEvent'
44
import { ErrorOverlay, overlayId } from './overlay'
5-
// eslint-disable-next-line node/no-missing-import
65
import '@vite/env'
76

87
// injected by the hmr plugin when served
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line node/no-missing-import
21
import { foo } from './non-existent.js'
32

43
export const hello = 'world'

packages/vite/src/node/ssr/ssrTransform.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import type {
99
Node as _Node,
1010
} from 'estree'
1111
import { extract_names as extractNames } from 'periscopic'
12-
// `eslint-plugin-node` doesn't support package without main
13-
// eslint-disable-next-line node/no-missing-import
1412
import { walk as eswalk } from 'estree-walker'
1513
import type { RawSourceMap } from '@ampproject/remapping'
1614
import type { TransformResult } from '../server/transformRequest'

pnpm-lock.yaml

Lines changed: 35 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)