Skip to content

Commit

Permalink
Showing 9 changed files with 341 additions and 308 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

260 changes: 0 additions & 260 deletions .eslintrc.cjs

This file was deleted.

9 changes: 5 additions & 4 deletions docs/.vitepress/buildEnd.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import path from 'path'
import { writeFileSync } from 'fs'
import path from 'node:path'
import { writeFileSync } from 'node:fs'
import { Feed } from 'feed'
import { createContentLoader, type SiteConfig } from 'vitepress'
import type { SiteConfig } from 'vitepress'
import { createContentLoader } from 'vitepress'

const siteUrl = 'https://vitejs.dev'
const blogUrl = `${siteUrl}/blog`

export const buildEnd = async (config: SiteConfig) => {
export const buildEnd = async (config: SiteConfig): Promise<void> => {
const feed = new Feed({
title: 'Vite',
description: 'Next Generation Frontend Tooling',
3 changes: 2 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig, DefaultTheme } from 'vitepress'
import type { DefaultTheme } from 'vitepress'
import { defineConfig } from 'vitepress'
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
import { buildEnd } from './buildEnd.config'

2 changes: 1 addition & 1 deletion docs/.vitepress/theme/composables/sponsor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, onMounted, onUnmounted } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'

interface Sponsors {
special: Sponsor[]
289 changes: 289 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
// @ts-check
import { builtinModules, createRequire } from 'node:module'
import eslint from '@eslint/js'
import pluginN from 'eslint-plugin-n'
import * as pluginI from 'eslint-plugin-i'
import pluginRegExp from 'eslint-plugin-regexp'
import tsParser from '@typescript-eslint/parser'
import tseslint from 'typescript-eslint'
import globals from 'globals'

const require = createRequire(import.meta.url)
const pkg = require('./package.json')
const pkgVite = require('./packages/vite/package.json')

export default tseslint.config(
{
ignores: [
'packages/create-vite/template-*',
'**/dist/**',
'**/fixtures/**',
'**/playground-temp/**',
'**/temp/**',
'**/.vitepress/cache/**',
'**/*.snap',
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
/** @type {any} */ (pluginRegExp.configs['flat/recommended']),
{
name: 'main',
languageOptions: {
parser: tsParser,
parserOptions: {
sourceType: 'module',
ecmaVersion: 2022,
},
globals: {
...globals.es2021,
...globals.node,
},
},
plugins: {
n: pluginN,
i: pluginI,
},
rules: {
'n/no-exports-assign': 'error',
'n/no-unpublished-bin': 'error',
'n/no-unsupported-features/es-builtins': 'error',
'n/no-unsupported-features/node-builtins': 'error',
'n/process-exit-as-throw': 'error',
'n/hashbang': 'error',

eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-process-exit': 'off',
'no-useless-escape': 'off',
'prefer-const': [
'warn',
{
destructuring: 'all',
},
],

'n/no-missing-require': [
'error',
{
// for try-catching yarn pnp
allowModules: ['pnpapi', 'vite'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
},
],
'n/no-extraneous-import': [
'error',
{
allowModules: ['vite', 'less', 'sass', 'vitest', 'unbuild'],
},
],
'n/no-extraneous-require': [
'error',
{
allowModules: ['vite'],
},
],

'@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 },
],
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] },
],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
'no-extra-semi': 'off',
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', disallowTypeAnnotations: false },
],
// disable rules set in @typescript-eslint/stylistic v6 that wasn't set in @typescript-eslint/recommended v5 and which conflict with current code
// maybe we should turn them on in a new PR
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-tslint-comment': 'off',
'@typescript-eslint/consistent-generic-constructors': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/prefer-function-type': 'off',

'i/no-nodejs-modules': [
'error',
{ allow: builtinModules.map((mod) => `node:${mod}`) },
],
'i/no-duplicates': 'error',
'i/order': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],

'regexp/no-contradiction-with-assertion': 'error',
// in some cases using explicit letter-casing is more performant than the `i` flag
'regexp/use-ignore-case': 'off',
},
},
{
name: 'vite/globals',
files: ['packages/**/*.?([cm])[jt]s?(x)'],
ignores: ['**/__tests__/**'],
rules: {
'no-restricted-globals': ['error', 'require', '__dirname', '__filename'],
},
},
{
name: 'vite/node',
files: ['packages/vite/src/node/**/*.?([cm])[jt]s?(x)'],
rules: {
'no-console': ['error'],
'n/no-restricted-require': [
'error',
Object.keys(pkgVite.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.`,
})),
],
},
},
{
name: 'playground/enforce-esm',
files: ['playground/**/*.?([cm])[jt]s?(x)'],
ignores: [
'playground/ssr-resolve/**',
'playground/**/*{commonjs,cjs}*/**',
'playground/**/*{commonjs,cjs}*',
'playground/**/*dep*/**',
'playground/resolve/browser-module-field2/index.web.js',
'playground/resolve/browser-field/**',
'playground/tailwind/**', // blocked by https://github.com/postcss/postcss-load-config/issues/239
],
rules: {
'i/no-commonjs': 'error',
},
},
{
name: 'playground/test',
files: ['playground/**/__tests__/**/*.?([cm])[jt]s?(x)'],
rules: {
// engine field doesn't exist in playgrounds
'n/no-unsupported-features/es-builtins': [
'error',
{
version: pkg.engines.node,
},
],
'n/no-unsupported-features/node-builtins': [
'error',
{
version: pkg.engines.node,
// ideally we would like to allow all experimental features
// https://github.com/eslint-community/eslint-plugin-n/issues/199
ignores: ['fetch'],
},
],
},
},

{
name: 'disables/vite/client',
files: ['packages/vite/src/client/**/*.?([cm])[jt]s?(x)'],
ignores: ['**/__tests__/**'],
rules: {
'n/no-unsupported-features/node-builtins': 'off',
},
},
{
name: 'disables/vite/types',
files: [
'packages/vite/src/types/**/*.?([cm])[jt]s?(x)',
'packages/vite/scripts/**/*.?([cm])[jt]s?(x)',
'**/*.spec.ts',
],
rules: {
'n/no-extraneous-import': 'off',
},
},
{
name: 'disables/create-vite/templates',
files: [
'packages/create-vite/template-*/**/*.?([cm])[jt]s?(x)',
'**/build.config.ts',
],
rules: {
'no-undef': 'off',
'n/no-missing-import': 'off',
'n/no-extraneous-import': 'off',
'n/no-extraneous-require': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
name: 'disables/playground',
files: ['playground/**/*.?([cm])[jt]s?(x)', 'docs/**/*.?([cm])[jt]s?(x)'],
rules: {
'n/no-extraneous-import': 'off',
'n/no-extraneous-require': 'off',
'n/no-missing-import': 'off',
'n/no-missing-require': 'off',
'n/no-unsupported-features/es-builtins': 'off',
'n/no-unsupported-features/node-builtins': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'no-undef': 'off',
'no-empty': 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
{
name: 'disables/playground/tsconfig-json',
files: [
'playground/tsconfig-json/**/*.?([cm])[jt]s?(x)',
'playground/tsconfig-json-load-error/**/*.?([cm])[jt]s?(x)',
],
ignores: ['**/__tests__/**'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
},
},
{
name: 'disables/js',
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
name: 'disables/dts',
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off',
},
},
{
name: 'disables/test',
files: ['**/__tests__/**/*.?([cm])[jt]s?(x)'],
rules: {
'no-console': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
},
)
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
},
"devDependencies": {
"@babel/types": "^7.24.6",
"@eslint-types/typescript-eslint": "^7.5.0",
"@eslint/js": "^9.3.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/babel__core": "^7.20.5",
"@types/babel__preset-env": "^7.9.6",
@@ -70,6 +70,7 @@
"execa": "^9.1.0",
"feed": "^4.2.2",
"fs-extra": "^11.2.0",
"globals": "^15.3.0",
"lint-staged": "^15.2.5",
"npm-run-all2": "^6.2.0",
"picocolors": "^1.0.1",
@@ -82,6 +83,7 @@
"tslib": "^2.6.2",
"tsx": "^4.11.0",
"typescript": "^5.2.2",
"typescript-eslint": "^7.10.0",
"unbuild": "^2.0.0",
"vite": "workspace:*",
"vitest": "^1.6.0"
1 change: 1 addition & 0 deletions packages/vite/types/customEvent.d.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ export interface WebSocketConnectionPayload {
* This might be removed in the future if we didn't find reasonable use cases.
* If you find this useful, please open an issue with details so we can discuss and make it stable API.
*/
// eslint-disable-next-line n/no-unsupported-features/node-builtins
webSocket: WebSocket
}

78 changes: 40 additions & 38 deletions pnpm-lock.yaml

0 comments on commit 8f16765

Please sign in to comment.