Skip to content

Commit

Permalink
chore: upgrade to eslint 9
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Aug 14, 2024
1 parent ab2516a commit 236a40f
Show file tree
Hide file tree
Showing 11 changed files with 492 additions and 1,015 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

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

This file was deleted.

156 changes: 156 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// @ts-check
import { builtinModules } from 'node:module'
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import nodePlugin from 'eslint-plugin-n'
import * as regexpPlugin from 'eslint-plugin-regexp'
import importPlugin from 'eslint-plugin-import-x'

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
nodePlugin.configs['flat/recommended'],
regexpPlugin.configs['flat/recommended'],
{ ignores: ['**/dist', '**/playground-temp', '**/temp'] },
{
plugins: {
import: importPlugin,
},
rules: {
eqeqeq: ['warn', 'always', { null: 'never' }],
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-useless-escape': 'off',
'prefer-const': ['warn', { destructuring: 'all' }],

'n/no-process-exit': 'off',
'n/no-missing-import': [
'error',
{
allowModules: ['types', 'estree', 'less', 'sass', 'stylus'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
},
],
'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'] }],
'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': '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-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
'@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-require-imports': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],

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

'regexp/no-contradiction-with-assertion': 'error',
},
},
{
files: ['packages/**'],
ignores: ['**/__tests__/**'],
rules: {
'no-restricted-globals': ['error', 'require', '__dirname', '__filename'],
},
},
{
files: ['*.spec.ts'],
rules: {
'n/no-extraneous-import': 'off',
},
},
{
files: ['**/build.config.ts'],
rules: {
'no-undef': 'off',
'n/no-missing-import': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['playground/**'],
rules: {
'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
'n/no-unsupported-features/es-builtins': [
'error',
{
version: '^18.0.0 || >=20.0.0',
},
],
'n/no-unsupported-features/node-builtins': [
'error',
{
version: '^18.0.0 || >=20.0.0',
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['playground/**'],
ignores: ['**/__tests__/**'],
rules: {
'no-undef': 'off',
'no-empty': 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: ['*.js', '*.mjs', '*.cjs'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off',
},
},
)
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,18 @@
},
"devDependencies": {
"@babel/types": "^7.24.7",
"@eslint/js": "^9.9.0",
"@types/babel__core": "^7.20.5",
"@types/convert-source-map": "^2.0.3",
"@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.14.2",
"@types/resolve": "^1.20.6",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@vitejs/release-scripts": "^1.3.2",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^8.57.0",
"eslint-define-config": "^2.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^14.0.0",
"eslint": "^9.9.0",
"eslint-plugin-import-x": "^3.1.0",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-regexp": "^2.6.0",
"execa": "^9.2.0",
"fast-glob": "^3.3.2",
Expand All @@ -66,6 +64,7 @@
"simple-git-hooks": "^2.11.1",
"tsx": "^4.15.5",
"typescript": "^5.4.5",
"typescript-eslint": "^8.1.0",
"unbuild": "2.0.0",
"vite": "catalog:",
"vitest": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
resolveScript,
setResolvedScript,
} from './script'
import type { ResolvedOptions } from '.'
import type { ResolvedOptions } from './index'

const debug = _debug('vite:hmr')

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { transformTemplateInMain } from './template'
import { isEqualBlock, isOnlyTemplateChanged } from './handleHotUpdate'
import { createRollupError } from './utils/error'
import { EXPORT_HELPER_ID } from './helper'
import type { ResolvedOptions } from '.'
import type { ResolvedOptions } from './index'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformMain(
Expand Down
Loading

0 comments on commit 236a40f

Please sign in to comment.