diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ba8d46f3c26f97..904873b07043cc 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -42,18 +42,6 @@ module.exports = defineConfig({ tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'] } ], - 'node/no-restricted-require': [ - 'error', - Object.keys(require('./packages/vite/package.json').devDependencies).map( - (d) => ({ - name: d, - message: - `devDependencies can only be imported using ESM syntax so ` + - `that they are included in the rollup bundle. If you are trying to ` + - `lazy load a dependency, use (await import('dependency')).default instead.` - }) - ) - ], 'node/no-extraneous-import': [ 'error', { @@ -107,6 +95,30 @@ module.exports = defineConfig({ ] }, overrides: [ + { + files: ['packages/**'], + excludedFiles: '**/__tests__/**', + rules: { + 'no-restricted-globals': ['error', 'require', '__dirname', '__filename'] + } + }, + { + files: 'packages/vite/**/*.*', + rules: { + 'node/no-restricted-require': [ + 'error', + Object.keys( + require('./packages/vite/package.json').devDependencies + ).map((d) => ({ + name: d, + message: + `devDependencies can only be imported using ESM syntax so ` + + `that they are included in the rollup bundle. If you are trying to ` + + `lazy load a dependency, use (await import('dependency')).default instead.` + })) + ] + } + }, { files: ['packages/vite/src/node/**'], rules: { @@ -120,9 +132,11 @@ module.exports = defineConfig({ } }, { - files: ['packages/plugin-*/**/*'], + files: ['packages/create-vite/template-*/**', '**/build.config.ts'], rules: { - 'no-restricted-globals': ['error', 'require', '__dirname', '__filename'] + 'no-undef': 'off', + 'node/no-missing-import': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off' } }, { @@ -132,7 +146,6 @@ module.exports = defineConfig({ 'node/no-extraneous-require': 'off', 'node/no-missing-import': 'off', 'node/no-missing-require': 'off', - 'no-undef': 'off', // engine field doesn't exist in playgrounds 'node/no-unsupported-features/es-builtins': [ 'error', @@ -145,17 +158,22 @@ module.exports = defineConfig({ { version: '^14.18.0 || >=16.0.0' } - ] + ], + '@typescript-eslint/explicit-module-boundary-types': 'off' } }, { - files: ['packages/create-vite/template-*/**', '**/build.config.ts'], + files: ['playground/**'], + excludedFiles: '**/__tests__/**', rules: { - 'node/no-missing-import': 'off' + 'no-undef': 'off', + 'no-empty': 'off', + 'no-constant-condition': 'off', + '@typescript-eslint/no-empty-function': 'off' } }, { - files: ['playground/**', '*.js'], + files: ['*.js'], rules: { '@typescript-eslint/explicit-module-boundary-types': 'off' } @@ -165,12 +183,6 @@ module.exports = defineConfig({ rules: { '@typescript-eslint/triple-slash-reference': 'off' } - }, - { - files: 'packages/vite/**/*.*', - rules: { - 'no-restricted-globals': ['error', 'require', '__dirname', '__filename'] - } } ], reportUnusedDisableDirectives: true diff --git a/package.json b/package.json index e9a3576f9b4462..3192b00df6b6ae 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "preinstall": "npx only-allow pnpm", "postinstall": "simple-git-hooks", "format": "prettier --write --cache .", - "lint": "eslint --cache packages/*/{src,types,__tests__}/** playground/**/__tests__/**/*.ts scripts/**/*.ts", + "lint": "eslint --cache .", "typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit", "test": "run-s test-unit test-serve test-build", "test-serve": "vitest run -c vitest.config.e2e.ts", @@ -65,7 +65,7 @@ "cross-env": "^7.0.3", "esbuild": "^0.14.47", "eslint": "^8.20.0", - "eslint-define-config": "^1.5.1", + "eslint-define-config": "^1.6.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-node": "^11.1.0", "execa": "^6.1.0", diff --git a/packages/create-vite/template-lit-ts/src/my-element.ts b/packages/create-vite/template-lit-ts/src/my-element.ts index da680eb1d0f19c..dde5d8cd50de89 100644 --- a/packages/create-vite/template-lit-ts/src/my-element.ts +++ b/packages/create-vite/template-lit-ts/src/my-element.ts @@ -1,4 +1,4 @@ -import { html, css, LitElement } from 'lit' +import { LitElement, css, html } from 'lit' import { customElement, property } from 'lit/decorators.js' import litLogo from './assets/lit.svg' diff --git a/packages/create-vite/template-lit/src/my-element.js b/packages/create-vite/template-lit/src/my-element.js index 411701454b89de..7c0c0426e49116 100644 --- a/packages/create-vite/template-lit/src/my-element.js +++ b/packages/create-vite/template-lit/src/my-element.js @@ -1,4 +1,4 @@ -import { html, css, LitElement } from 'lit' +import { LitElement, css, html } from 'lit' import litLogo from './assets/lit.svg' /** diff --git a/packages/vite/rollup.config.ts b/packages/vite/rollup.config.ts index a630c2a813198c..a271d4f3562906 100644 --- a/packages/vite/rollup.config.ts +++ b/packages/vite/rollup.config.ts @@ -11,7 +11,7 @@ import MagicString from 'magic-string' import colors from 'picocolors' import fg from 'fast-glob' import { sync as resolve } from 'resolve' -import type { Plugin } from 'rollup' +import type { Plugin, RollupOptions } from 'rollup' import { defineConfig } from 'rollup' import pkg from './package.json' @@ -185,7 +185,7 @@ function createCjsConfig(isProduction: boolean) { }) } -export default (commandLineArgs: any) => { +export default (commandLineArgs: any): RollupOptions[] => { const isDev = commandLineArgs.watch const isProduction = !isDev diff --git a/playground/css/main.js b/playground/css/main.js index 45e7730b868eb1..f767a3d9b9674d 100644 --- a/playground/css/main.js +++ b/playground/css/main.js @@ -47,6 +47,7 @@ text('.charset-css', charset) import './dep.css' import './glob-dep.css' +// eslint-disable-next-line import/order import { barModuleClasses } from 'css-js-dep' document .querySelector('.css-js-dep-module') diff --git a/playground/css/postcss.config.js b/playground/css/postcss.config.js index b30209bff42097..48d5dd23d5a8f1 100644 --- a/playground/css/postcss.config.js +++ b/playground/css/postcss.config.js @@ -3,8 +3,8 @@ module.exports = { } const fs = require('fs') -const glob = require('fast-glob') const path = require('path') +const glob = require('fast-glob') const { normalizePath } = require('vite') /** diff --git a/playground/json/server.js b/playground/json/server.js index b0c0dd18dc43ae..d78c7f6246d540 100644 --- a/playground/json/server.js +++ b/playground/json/server.js @@ -15,8 +15,7 @@ async function createServer( /** * @type {import('vite').ViteDevServer} */ - let vite - vite = await require('vite').createServer({ + const vite = await require('vite').createServer({ root, logLevel: isTest ? 'error' : 'info', server: { diff --git a/playground/resolve/browser-field/relative.js b/playground/resolve/browser-field/relative.js index bbf6a2c74a10b5..492be3e96738eb 100644 --- a/playground/resolve/browser-field/relative.js +++ b/playground/resolve/browser-field/relative.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-duplicates */ import ra from './no-ext' import rb from './no-ext.js' // no substitution import rc from './ext' diff --git a/playground/tailwind/__test__/tailwind.spec.ts b/playground/tailwind/__test__/tailwind.spec.ts index 4483aabf6f6597..d72680cc522f64 100644 --- a/playground/tailwind/__test__/tailwind.spec.ts +++ b/playground/tailwind/__test__/tailwind.spec.ts @@ -1,11 +1,11 @@ import { - isBuild, + browserLogs, editFile, - untilUpdated, - getColor, getBgColor, - browserLogs, - page + getColor, + isBuild, + page, + untilUpdated } from '~utils' test('should render', async () => { diff --git a/playground/tailwind/src/router.ts b/playground/tailwind/src/router.ts index cfcf2a29b637e2..2a8c3cd0dd966f 100644 --- a/playground/tailwind/src/router.ts +++ b/playground/tailwind/src/router.ts @@ -1,4 +1,4 @@ -import { createWebHistory, createRouter } from 'vue-router' +import { createRouter, createWebHistory } from 'vue-router' import Page from './views/Page.vue' const history = createWebHistory() diff --git a/playground/wasm/worker.js b/playground/wasm/worker.js index dbbc0640226406..7e7ee8c331f917 100644 --- a/playground/wasm/worker.js +++ b/playground/wasm/worker.js @@ -1,5 +1,4 @@ import init from './add.wasm?init' init().then(({ exports }) => { - // eslint-disable-next-line no-undef self.postMessage({ result: exports.add(1, 2) }) }) diff --git a/playground/worker/my-worker.ts b/playground/worker/my-worker.ts index 8c91d49d70ba5c..9a5203711d3375 100644 --- a/playground/worker/my-worker.ts +++ b/playground/worker/my-worker.ts @@ -1,6 +1,6 @@ +import { msg as msgFromDep } from 'dep-to-optimize' import { mode, msg } from './modules/workerImport' import { bundleWithPlugin } from './modules/test-plugin' -import { msg as msgFromDep } from 'dep-to-optimize' self.onmessage = (e) => { if (e.data === 'ping') { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c9742082efe58..a5bcb9c7edaaa1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,7 +39,7 @@ importers: cross-env: ^7.0.3 esbuild: ^0.14.47 eslint: ^8.20.0 - eslint-define-config: ^1.5.1 + eslint-define-config: ^1.6.0 eslint-plugin-import: ^2.26.0 eslint-plugin-node: ^11.1.0 execa: ^6.1.0 @@ -97,7 +97,7 @@ importers: cross-env: 7.0.3 esbuild: 0.14.47 eslint: 8.20.0 - eslint-define-config: 1.5.1 + eslint-define-config: 1.6.0 eslint-plugin-import: 2.26.0_xconv27bia2733zao6ipggqv2i eslint-plugin-node: 11.1.0_eslint@8.20.0 execa: 6.1.0 @@ -4766,8 +4766,8 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - /eslint-define-config/1.5.1: - resolution: {integrity: sha512-6gxrmN7aKGffaO8dCtMMKyo3IxbWymMQ248p4lf8GbaFRcLsqOXHFdUhhM0Hcy1NudvnpwHcfbDf7Nh9pIm1TA==} + /eslint-define-config/1.6.0: + resolution: {integrity: sha512-3qulYnwDRGYQHXHGdXBSRcfpI7m37ilBoERzTUYI8fBUoK/46yfUVNkGwM9cF/aoBrGgIDcBSz/HyPQJTHI/+w==} engines: {node: '>= 14.6.0', npm: '>= 6.0.0', pnpm: '>= 7.0.0'} dev: true