diff --git a/.eslintignore b/.eslintignore index 3e795e7a98280b..2974196847e467 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ dist playground-temp temp - diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 7411edbf846b98..f60f3280712ed6 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,4 +1,5 @@ // @ts-check +const { builtinModules } = require('node:module') const { defineConfig } = require('eslint-define-config') module.exports = defineConfig({ @@ -6,13 +7,14 @@ module.exports = defineConfig({ extends: [ 'eslint:recommended', 'plugin:node/recommended', - 'plugin:@typescript-eslint/recommended' + 'plugin:@typescript-eslint/recommended', + 'plugin:regexp/recommended', ], - plugins: ['import'], + plugins: ['import', 'regexp'], parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module', - ecmaVersion: 2021 + ecmaVersion: 2021, }, rules: { eqeqeq: ['warn', 'always', { null: 'never' }], @@ -23,63 +25,51 @@ module.exports = defineConfig({ 'prefer-const': [ 'warn', { - destructuring: 'all' - } + destructuring: 'all', + }, ], 'node/no-missing-import': [ 'error', { allowModules: ['types', 'estree', 'less', 'sass', 'stylus'], - tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'] - } + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], + }, ], 'node/no-missing-require': [ 'error', { // for try-catching yarn pnp allowModules: ['pnpapi', 'vite'], - 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.` - }) - ) + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], + }, ], 'node/no-extraneous-import': [ 'error', { - allowModules: ['vite', 'less', 'sass', 'vitest'] - } + allowModules: ['vite', 'less', 'sass', 'vitest'], + }, ], 'node/no-extraneous-require': [ 'error', { - allowModules: ['vite'] - } + allowModules: ['vite'], + }, ], 'node/no-deprecated-api': 'off', 'node/no-unpublished-import': 'off', 'node/no-unpublished-require': 'off', 'node/no-unsupported-features/es-syntax': 'off', - '@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR + '@typescript-eslint/ban-ts-comment': 'error', '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR '@typescript-eslint/explicit-module-boundary-types': [ 'error', - { allowArgumentsExplicitlyTypedAsAny: true } + { allowArgumentsExplicitlyTypedAsAny: true }, ], '@typescript-eslint/no-empty-function': [ 'error', - { allow: ['arrowFunctions'] } + { allow: ['arrowFunctions'] }, ], '@typescript-eslint/no-empty-interface': 'off', '@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR @@ -90,9 +80,13 @@ module.exports = defineConfig({ '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/consistent-type-imports': [ 'error', - { prefer: 'type-imports' } + { prefer: 'type-imports' }, ], + 'import/no-nodejs-modules': [ + 'error', + { allow: builtinModules.map((mod) => `node:${mod}`) }, + ], 'import/no-duplicates': 'error', 'import/order': 'error', 'sort-imports': [ @@ -102,28 +96,61 @@ module.exports = defineConfig({ ignoreDeclarationSort: true, ignoreMemberSort: false, memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], - allowSeparatedGroups: false - } - ] + allowSeparatedGroups: false, + }, + ], + + 'regexp/no-contradiction-with-assertion': 'error', }, 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: { - 'no-console': ['error'] - } + 'no-console': ['error'], + }, }, { - files: ['packages/vite/types/**', '*.spec.ts'], + files: ['packages/vite/src/types/**', '*.spec.ts'], rules: { - 'node/no-extraneous-import': 'off' - } + 'node/no-extraneous-import': 'off', + }, }, { - 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', + }, }, { files: ['playground/**'], @@ -132,46 +159,54 @@ 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', { - version: '>=14.18.0' - } + version: '^14.18.0 || >=16.0.0', + }, ], 'node/no-unsupported-features/node-builtins': [ 'error', { - version: '>=14.18.0' - } - ] - } + 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: [ + 'playground/tsconfig-json/**', + 'playground/tsconfig-json-load-error/**', + ], + excludedFiles: '**/__tests__/**', rules: { - '@typescript-eslint/explicit-module-boundary-types': 'off' - } + '@typescript-eslint/ban-ts-comment': 'off', + }, }, { - files: ['*.d.ts'], + files: ['*.js', '*.mjs', '*.cjs'], rules: { - '@typescript-eslint/triple-slash-reference': 'off' - } + '@typescript-eslint/explicit-module-boundary-types': 'off', + }, }, { - files: 'packages/vite/**/*.*', + files: ['*.d.ts'], rules: { - 'no-restricted-globals': ['error', 'require', '__dirname', '__filename'] - } - } + '@typescript-eslint/triple-slash-reference': 'off', + }, + }, ], - reportUnusedDisableDirectives: true + reportUnusedDisableDirectives: true, }) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000000..a4c31afed65932 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,4 @@ +# chore: enable prettier trailing commas (#11167) +134ce6817984bad0f5fb043481502531fee9b1db +# chore: rename test packages (#11172) +5170e44920458090b8b43ee9cfe5010c25dfe22b diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 0d84e28034a442..c330f6c2926bf3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -18,10 +18,16 @@ body: id: reproduction attributes: label: Reproduction - description: Please provide a link via [vite.new](https://vite.new/) or a link to a repo that can reproduce the problem you ran into. A [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) is required ([Why?](https://antfu.me/posts/why-reproductions-are-required)). If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided after 3 days, it will be auto-closed. - placeholder: Reproduction URL and steps + description: Please provide a link via [vite.new](https://vite.new/) or a link to a repo that can reproduce the problem you ran into. `npm create vite@latest` and `npm create vite-extra@latest` (for SSR or library repros) can be used as a starter template. A [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) is required ([Why?](https://antfu.me/posts/why-reproductions-are-required)). If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided after 3 days, it will be auto-closed. + placeholder: Reproduction URL validations: required: true + - type: textarea + id: reproduction-steps + attributes: + label: Steps to reproduce + description: Please provide any reproduction steps that may need to be described. E.g. if it happens only when running the dev or build script make sure it's clear which one to use. + placeholder: Run `npm install` followed by `npm run dev` - type: textarea id: system-info attributes: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c504c325f08040..f85f41ebbd3809 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,11 @@ blank_issues_enabled: false contact_links: + - name: Vite Plugin React Issues + url: https://github.com/vitejs/vite-plugin-react/issues/new/choose + about: React related issues should be reported on the vite-plugin-react repository. + - name: Vite Plugin Vue Issues + url: https://github.com/vitejs/vite-plugin-vue/issues/new/choose + about: Vue related issues should be reported on the vite-plugin-vue repository. - name: Discord Chat url: https://chat.vitejs.dev about: Ask questions and discuss with other Vite users in real time. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 946e6aa9bedb9f..c393c93c94e659 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -20,7 +20,7 @@ ### Before submitting the PR, please make sure you do the following - [ ] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md). -- [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [Commit Convention](https://github.com/vitejs/vite/blob/main/.github/commit-convention.md). +- [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [PR Title Convention](https://github.com/vitejs/vite/blob/main/.github/commit-convention.md). - [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate. - [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`). - [ ] Ideally, include relevant tests that fail without this PR but pass with it. diff --git a/.github/commit-convention.md b/.github/commit-convention.md index baa447479e9c39..4971cff4547fce 100644 --- a/.github/commit-convention.md +++ b/.github/commit-convention.md @@ -8,64 +8,21 @@ Messages must be matched by the following regex: ```js -/^(revert: )?(feat|fix|docs|dx|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps)(\(.+\))?: .{1,50}/ +/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?!?: .{1,50}/ ``` #### Examples -Appears under "Features" header, `dev` subheader: - ``` feat(dev): add 'comments' option -``` - -Appears under "Bug Fixes" header, `dev` subheader, with a link to issue #28: - -``` fix(dev): fix dev error - -close #28 -``` - -Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: - -``` -perf(build): remove 'foo' option - -BREAKING CHANGE: The 'foo' option has been removed. -``` - -The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header. - -``` +perf(build)!: remove 'foo' option revert: feat(compiler): add 'comments' option - -This reverts commit 667ecc1654a317a13331b17617d973392f415f02. -``` - -### Full Message Format - -A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: - -``` -(): - - - -