diff --git a/.eslintrc.cjs b/.eslintrc.cjs index f60f3280712ed6..6f10675c2f33ce 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -6,7 +6,7 @@ module.exports = defineConfig({ root: true, extends: [ 'eslint:recommended', - 'plugin:node/recommended', + 'plugin:n/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:regexp/recommended', ], @@ -29,14 +29,9 @@ module.exports = defineConfig({ }, ], - 'node/no-missing-import': [ - 'error', - { - allowModules: ['types', 'estree', 'less', 'sass', 'stylus'], - tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], - }, - ], - 'node/no-missing-require': [ + 'n/no-process-exit': 'off', + 'n/no-missing-import': 'off', + 'n/no-missing-require': [ 'error', { // for try-catching yarn pnp @@ -44,22 +39,22 @@ module.exports = defineConfig({ tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], }, ], - 'node/no-extraneous-import': [ + 'n/no-extraneous-import': [ 'error', { - allowModules: ['vite', 'less', 'sass', 'vitest'], + allowModules: ['vite', 'less', 'sass', 'vitest', 'unbuild'], }, ], - 'node/no-extraneous-require': [ + 'n/no-extraneous-require': [ 'error', { allowModules: ['vite'], }, ], - 'node/no-deprecated-api': 'off', - 'node/no-unpublished-import': 'off', - 'node/no-unpublished-require': 'off', - 'node/no-unsupported-features/es-syntax': 'off', + 'n/no-deprecated-api': 'off', + 'n/no-unpublished-import': 'off', + 'n/no-unpublished-require': 'off', + 'n/no-unsupported-features/es-syntax': 'off', '@typescript-eslint/ban-ts-comment': 'error', '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR @@ -118,7 +113,7 @@ module.exports = defineConfig({ { files: 'packages/vite/**/*.*', rules: { - 'node/no-restricted-require': [ + 'n/no-restricted-require': [ 'error', Object.keys( require('./packages/vite/package.json').devDependencies, @@ -141,32 +136,32 @@ module.exports = defineConfig({ { files: ['packages/vite/src/types/**', '*.spec.ts'], rules: { - 'node/no-extraneous-import': 'off', + 'n/no-extraneous-import': 'off', }, }, { files: ['packages/create-vite/template-*/**', '**/build.config.ts'], rules: { 'no-undef': 'off', - 'node/no-missing-import': 'off', + 'n/no-missing-import': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', }, }, { files: ['playground/**'], rules: { - 'node/no-extraneous-import': 'off', - 'node/no-extraneous-require': 'off', - 'node/no-missing-import': 'off', - 'node/no-missing-require': 'off', + 'n/no-extraneous-import': 'off', + 'n/no-extraneous-require': 'off', + 'n/no-missing-import': 'off', + 'n/no-missing-require': 'off', // engine field doesn't exist in playgrounds - 'node/no-unsupported-features/es-builtins': [ + 'n/no-unsupported-features/es-builtins': [ 'error', { version: '^14.18.0 || >=16.0.0', }, ], - 'node/no-unsupported-features/node-builtins': [ + 'n/no-unsupported-features/node-builtins': [ 'error', { version: '^14.18.0 || >=16.0.0', diff --git a/package.json b/package.json index 8413d44a97d563..9b915cc513878d 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "eslint": "^8.36.0", "eslint-define-config": "^1.17.0", "eslint-plugin-import": "^2.27.5", - "eslint-plugin-node": "^11.1.0", + "eslint-plugin-n": "^15.7.0", "eslint-plugin-regexp": "^1.13.0", "execa": "^7.1.1", "fast-glob": "^3.2.12", diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index 84453271e65736..29dfb4f754a128 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -1,4 +1,4 @@ -/* eslint-disable node/no-extraneous-import */ +/* eslint-disable n/no-extraneous-import */ import path from 'node:path' import { createHash } from 'node:crypto' import { createRequire } from 'node:module' diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index cb668832aa6f53..0c3163adfb1c06 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -2,7 +2,6 @@ import type { ErrorPayload, HMRPayload, Update } from 'types/hmrPayload' import type { ModuleNamespace, ViteHotContext } from 'types/hot' import type { InferCustomEventPayload } from 'types/customEvent' import { ErrorOverlay, overlayId } from './overlay' -// eslint-disable-next-line node/no-missing-import import '@vite/env' // injected by the hmr plugin when served diff --git a/packages/vite/src/node/ssr/__tests__/fixtures/modules/has-invalid-import.js b/packages/vite/src/node/ssr/__tests__/fixtures/modules/has-invalid-import.js index 81ab2b0fab83c9..1cddd78e2da615 100644 --- a/packages/vite/src/node/ssr/__tests__/fixtures/modules/has-invalid-import.js +++ b/packages/vite/src/node/ssr/__tests__/fixtures/modules/has-invalid-import.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line node/no-missing-import import { foo } from './non-existent.js' export const hello = 'world' diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts index b7d050f6479dd4..96ee465e2a0ebe 100644 --- a/packages/vite/src/node/ssr/ssrTransform.ts +++ b/packages/vite/src/node/ssr/ssrTransform.ts @@ -9,8 +9,6 @@ import type { Node as _Node, } from 'estree' import { extract_names as extractNames } from 'periscopic' -// `eslint-plugin-node` doesn't support package without main -// eslint-disable-next-line node/no-missing-import import { walk as eswalk } from 'estree-walker' import type { RawSourceMap } from '@ampproject/remapping' import type { TransformResult } from '../server/transformRequest' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d40a007470e383..59dee360a0f7bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,9 +101,9 @@ importers: eslint-plugin-import: specifier: ^2.27.5 version: 2.27.5(@typescript-eslint/parser@5.56.0)(eslint@8.36.0) - eslint-plugin-node: - specifier: ^11.1.0 - version: 11.1.0(eslint@8.36.0) + eslint-plugin-n: + specifier: ^15.7.0 + version: 15.7.0(eslint@8.36.0) eslint-plugin-regexp: specifier: ^1.13.0 version: 1.13.0(eslint@8.36.0) @@ -4438,6 +4438,12 @@ packages: engines: {node: '>=6'} dev: true + /builtins@5.0.1: + resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} + dependencies: + semver: 7.3.8 + dev: true + /busboy@0.3.1: resolution: {integrity: sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==} engines: {node: '>=4.5.0'} @@ -5679,8 +5685,8 @@ packages: - supports-color dev: true - /eslint-plugin-es@3.0.1(eslint@8.36.0): - resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} + /eslint-plugin-es@4.1.0(eslint@8.36.0): + resolution: {integrity: sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=4.19.1' @@ -5723,19 +5729,21 @@ packages: - supports-color dev: true - /eslint-plugin-node@11.1.0(eslint@8.36.0): - resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} - engines: {node: '>=8.10.0'} + /eslint-plugin-n@15.7.0(eslint@8.36.0): + resolution: {integrity: sha512-jDex9s7D/Qial8AGVIHq4W7NswpUD5DPDL2RH8Lzd9EloWUuvUkHfv4FRLMipH5q2UtyurorBkPeNi1wVWNh3Q==} + engines: {node: '>=12.22.0'} peerDependencies: - eslint: '>=5.16.0' + eslint: '>=7.0.0' dependencies: + builtins: 5.0.1 eslint: 8.36.0 - eslint-plugin-es: 3.0.1(eslint@8.36.0) - eslint-utils: 2.1.0 + eslint-plugin-es: 4.1.0(eslint@8.36.0) + eslint-utils: 3.0.0(eslint@8.36.0) ignore: 5.2.0 + is-core-module: 2.11.0 minimatch: 3.1.2 resolve: 1.22.1 - semver: 6.3.0 + semver: 7.3.8 dev: true /eslint-plugin-regexp@1.13.0(eslint@8.36.0): @@ -5778,11 +5786,26 @@ packages: eslint-visitor-keys: 1.3.0 dev: true + /eslint-utils@3.0.0(eslint@8.36.0): + resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} + engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} + peerDependencies: + eslint: '>=5' + dependencies: + eslint: 8.36.0 + eslint-visitor-keys: 2.1.0 + dev: true + /eslint-visitor-keys@1.3.0: resolution: {integrity: sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==} engines: {node: '>=4'} dev: true + /eslint-visitor-keys@2.1.0: + resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==} + engines: {node: '>=10'} + dev: true + /eslint-visitor-keys@3.3.0: resolution: {integrity: sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}