mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
perf: 新包使用更严格的eslint
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['@vben'],
|
||||
extends: ['@vben/eslint-config/strict'],
|
||||
};
|
||||
|
@@ -1,16 +1,55 @@
|
||||
import baseLintConfig from './index';
|
||||
|
||||
export default {
|
||||
extends: [baseLintConfig],
|
||||
extends: ['@vben'],
|
||||
plugins: ['simple-import-sort'],
|
||||
rules: {
|
||||
'simple-import-sort/imports': 'error',
|
||||
'simple-import-sort/exports': 'error',
|
||||
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'@typescript-eslint/ban-ts-ignore': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': [
|
||||
'error',
|
||||
{
|
||||
'ts-expect-error': 'allow-with-description',
|
||||
'ts-ignore': 'allow-with-description',
|
||||
'ts-nocheck': 'allow-with-description',
|
||||
'ts-check': false,
|
||||
},
|
||||
],
|
||||
|
||||
/**
|
||||
* 【强制】关键字前后有一个空格
|
||||
* @link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md
|
||||
*/
|
||||
'keyword-spacing': 'off',
|
||||
'@typescript-eslint/keyword-spacing': [
|
||||
'error',
|
||||
{
|
||||
before: true,
|
||||
after: true,
|
||||
overrides: {
|
||||
return: { after: true },
|
||||
throw: { after: true },
|
||||
case: { after: true },
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
/**
|
||||
* 禁止出现空函数,普通函数(非 async/await/generator)、箭头函数、类上的方法除外
|
||||
* @link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
|
||||
*/
|
||||
'no-empty-function': 'off',
|
||||
'@typescript-eslint/no-empty-function': [
|
||||
'error',
|
||||
{
|
||||
allow: ['arrowFunctions', 'functions', 'methods'],
|
||||
},
|
||||
],
|
||||
|
||||
/**
|
||||
* 优先使用 interface 而不是 type 定义对象类型
|
||||
* @link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md
|
||||
*/
|
||||
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
|
||||
|
||||
'vue/attributes-order': 'error',
|
||||
'vue/require-default-prop': 'error',
|
||||
|
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['@vben'],
|
||||
extends: ['@vben/eslint-config/strict'],
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['@vben'],
|
||||
extends: ['@vben/eslint-config/strict'],
|
||||
};
|
||||
|
@@ -1,14 +1,18 @@
|
||||
import { type UserConfig, defineConfig, mergeConfig, loadEnv } from 'vite';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { readPackageJSON } from 'pkg-types';
|
||||
import { defineConfig, loadEnv, mergeConfig, type UserConfig } from 'vite';
|
||||
|
||||
import { createPlugins } from '../plugins';
|
||||
import { generateModifyVars } from '../utils/modifyVars';
|
||||
import { commonConfig } from './common';
|
||||
import { createPlugins } from '../plugins';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
interface DefineOptions {
|
||||
overrides?: UserConfig;
|
||||
options?: {};
|
||||
options?: {
|
||||
//
|
||||
};
|
||||
}
|
||||
|
||||
function defineApplicationConfig(defineOptions: DefineOptions = {}) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { type UserConfig } from 'vite';
|
||||
import UnoCSS from 'unocss/vite';
|
||||
import { presetTypography, presetUno } from 'unocss';
|
||||
import UnoCSS from 'unocss/vite';
|
||||
import { type UserConfig } from 'vite';
|
||||
|
||||
const commonConfig: UserConfig = {
|
||||
server: {
|
||||
|
@@ -1,11 +1,14 @@
|
||||
import { type UserConfig, defineConfig, mergeConfig } from 'vite';
|
||||
import { readPackageJSON } from 'pkg-types';
|
||||
import { commonConfig } from './common';
|
||||
import { defineConfig, mergeConfig, type UserConfig } from 'vite';
|
||||
import dts from 'vite-plugin-dts';
|
||||
|
||||
import { commonConfig } from './common';
|
||||
|
||||
interface DefineOptions {
|
||||
overrides?: UserConfig;
|
||||
options?: {};
|
||||
options?: {
|
||||
//
|
||||
};
|
||||
}
|
||||
|
||||
function definePackageConfig(defineOptions: DefineOptions = {}) {
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import colors from 'picocolors';
|
||||
import { readPackageJSON } from 'pkg-types';
|
||||
import { type PluginOption } from 'vite';
|
||||
|
||||
import { getEnvConfig } from '../utils/env';
|
||||
import { createContentHash } from '../utils/hash';
|
||||
import { readPackageJSON } from 'pkg-types';
|
||||
import colors from 'picocolors';
|
||||
|
||||
const GLOBAL_CONFIG_FILE_NAME = '_app.config.js';
|
||||
const PLUGIN_NAME = 'app-config';
|
||||
|
@@ -1,15 +1,16 @@
|
||||
import { type PluginOption } from 'vite';
|
||||
import { configHtmlPlugin } from './html';
|
||||
import { configMockPlugin } from './mock';
|
||||
import { configCompressPlugin } from './compress';
|
||||
import { configVisualizerConfig } from './visualizer';
|
||||
import { configSvgIconsPlugin } from './svgSprite';
|
||||
import { createAppConfigPlugin } from './appConfig';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import purgeIcons from 'vite-plugin-purge-icons';
|
||||
// @ts-ignore
|
||||
// @ts-ignore: type unless
|
||||
import DefineOptions from 'unplugin-vue-define-options/vite';
|
||||
import { type PluginOption } from 'vite';
|
||||
import purgeIcons from 'vite-plugin-purge-icons';
|
||||
|
||||
import { createAppConfigPlugin } from './appConfig';
|
||||
import { configCompressPlugin } from './compress';
|
||||
import { configHtmlPlugin } from './html';
|
||||
import { configMockPlugin } from './mock';
|
||||
import { configSvgIconsPlugin } from './svgSprite';
|
||||
import { configVisualizerConfig } from './visualizer';
|
||||
|
||||
interface Options {
|
||||
isBuild: boolean;
|
||||
|
@@ -3,9 +3,10 @@
|
||||
* https://github.com/anncwb/vite-plugin-svg-icons
|
||||
*/
|
||||
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import type { PluginOption } from 'vite';
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
||||
|
||||
export function configSvgIconsPlugin({ isBuild }: { isBuild: boolean }) {
|
||||
const svgIconsPlugin = createSvgIconsPlugin({
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Package file volume analysis
|
||||
*/
|
||||
import { type PluginOption } from 'vite';
|
||||
import visualizer from 'rollup-plugin-visualizer';
|
||||
import { type PluginOption } from 'vite';
|
||||
|
||||
export function configVisualizerConfig() {
|
||||
return visualizer({
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { join } from 'node:path';
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
import { readFile } from 'fs-extra';
|
||||
import { join } from 'node:path';
|
||||
|
||||
/**
|
||||
* 获取当前环境下生效的配置文件名
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { generate } from '@ant-design/colors';
|
||||
import { resolve } from 'node:path';
|
||||
// @ts-ignore
|
||||
|
||||
import { generate } from '@ant-design/colors';
|
||||
// @ts-ignore: typo
|
||||
import { getThemeVariables } from 'ant-design-vue/dist/theme';
|
||||
|
||||
const primaryColor = '#0960bd';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['@vben'],
|
||||
extends: ['@vben/eslint-config/strict'],
|
||||
};
|
||||
|
@@ -1,5 +1,4 @@
|
||||
export * from './onMountedOrActivated';
|
||||
export * from './useAttrs';
|
||||
export * from './useRefs';
|
||||
|
||||
export { useTimeoutFn } from '@vueuse/core';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { type AnyFunction } from '@vben/types';
|
||||
import { nextTick, onMounted, onActivated } from 'vue';
|
||||
import { nextTick, onActivated, onMounted } from 'vue';
|
||||
|
||||
/**
|
||||
* 在 OnMounted 或者 OnActivated 时触发
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { getCurrentInstance, reactive, shallowRef, watchEffect } from 'vue';
|
||||
import { type Recordable } from '@vben/types';
|
||||
import { getCurrentInstance, reactive, shallowRef, watchEffect } from 'vue';
|
||||
|
||||
interface Options {
|
||||
excludeListeners?: boolean;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import type { Ref } from 'vue';
|
||||
import { ref, onBeforeUpdate } from 'vue';
|
||||
import { onBeforeUpdate, ref } from 'vue';
|
||||
|
||||
export function useRefs(): [Ref<HTMLElement[]>, (index: number) => (el: HTMLElement) => void] {
|
||||
const refs = ref([]) as Ref<HTMLElement[]>;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['@vben'],
|
||||
extends: ['@vben/eslint-config/strict'],
|
||||
};
|
||||
|
@@ -31,9 +31,9 @@ type Recordable<T> = Record<string, T>;
|
||||
/**
|
||||
* 字符串类型对象(只读)
|
||||
*/
|
||||
type ReadonlyRecordable<T = any> = {
|
||||
interface ReadonlyRecordable<T = any> {
|
||||
readonly [key: string]: T;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* setTimeout 返回值类型
|
||||
@@ -47,12 +47,12 @@ type IntervalHandle = ReturnType<typeof setInterval>;
|
||||
|
||||
export {
|
||||
type AnyFunction,
|
||||
type AnyPromiseFunction,
|
||||
type AnyNormalFunction,
|
||||
type Nullable,
|
||||
type NonNullable,
|
||||
type Recordable,
|
||||
type ReadonlyRecordable,
|
||||
type TimeoutHandle,
|
||||
type AnyPromiseFunction,
|
||||
type IntervalHandle,
|
||||
type NonNullable,
|
||||
type Nullable,
|
||||
type ReadonlyRecordable,
|
||||
type Recordable,
|
||||
type TimeoutHandle,
|
||||
};
|
||||
|
Reference in New Issue
Block a user