Merge branch 'eslint-plugin-import'
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
|
import pluginImport from 'eslint-plugin-import';
|
||||||
import { globalIgnores } from 'eslint/config';
|
import { globalIgnores } from 'eslint/config';
|
||||||
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
|
import {
|
||||||
|
defineConfigWithVueTs,
|
||||||
|
vueTsConfigs,
|
||||||
|
configureVueProject,
|
||||||
|
} from '@vue/eslint-config-typescript';
|
||||||
import pluginVue from 'eslint-plugin-vue';
|
import pluginVue from 'eslint-plugin-vue';
|
||||||
import pluginVitest from '@vitest/eslint-plugin';
|
import pluginVitest from '@vitest/eslint-plugin';
|
||||||
import pluginPlaywright from 'eslint-plugin-playwright';
|
import pluginPlaywright from 'eslint-plugin-playwright';
|
||||||
import pluginOxlint from 'eslint-plugin-oxlint';
|
import pluginOxlint from 'eslint-plugin-oxlint';
|
||||||
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';
|
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';
|
||||||
|
|
||||||
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
|
||||||
import { configureVueProject } from '@vue/eslint-config-typescript';
|
|
||||||
configureVueProject({ scriptLangs: ['ts', 'tsx'] });
|
configureVueProject({ scriptLangs: ['ts', 'tsx'] });
|
||||||
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
||||||
|
|
||||||
@@ -32,7 +35,22 @@ export default defineConfigWithVueTs(
|
|||||||
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
||||||
},
|
},
|
||||||
...pluginOxlint.configs['flat/recommended'],
|
...pluginOxlint.configs['flat/recommended'],
|
||||||
skipFormatting,
|
{
|
||||||
|
plugins: {
|
||||||
|
import: pluginImport,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'import/first': 'error',
|
||||||
|
'import/no-duplicates': 'error',
|
||||||
|
'import/newline-after-import': 'error',
|
||||||
|
'import/no-mutable-exports': 'error',
|
||||||
|
'import/no-named-default': 'error',
|
||||||
|
'import/no-self-import': 'error',
|
||||||
|
'import/no-unresolved': 'off',
|
||||||
|
'import/no-webpack-loader-syntax': 'error',
|
||||||
|
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
rules: {
|
rules: {
|
||||||
@@ -50,4 +68,6 @@ export default defineConfigWithVueTs(
|
|||||||
'vue/multi-word-component-names': 'off',
|
'vue/multi-word-component-names': 'off',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
skipFormatting,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"_all": "run-p build-only format:prettier type-check lint test:unit:DisableWatch",
|
"_all": "run-p build-only type-check lint format:prettier test:unit:DisableWatch",
|
||||||
"dev": "vite --port 4730 --host --strictPort",
|
"dev": "vite --port 4730 --host --strictPort",
|
||||||
"build": "run-p type-check \"build-only {@}\" --",
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
@@ -97,6 +97,7 @@
|
|||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
"consola": "^3.4.2",
|
"consola": "^3.4.2",
|
||||||
"eslint": "^9.35.0",
|
"eslint": "^9.35.0",
|
||||||
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-oxlint": "~1.23.0",
|
"eslint-plugin-oxlint": "~1.23.0",
|
||||||
"eslint-plugin-playwright": "^2.2.2",
|
"eslint-plugin-playwright": "^2.2.2",
|
||||||
"eslint-plugin-vue": "~10.5.0",
|
"eslint-plugin-vue": "~10.5.0",
|
||||||
|
|||||||
1043
pnpm-lock.yaml
generated
1043
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,10 @@
|
|||||||
* https://pinia.vuejs.org/zh/cookbook/testing.html#unit-testing-components
|
* https://pinia.vuejs.org/zh/cookbook/testing.html#unit-testing-components
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { mount } from '@vue/test-utils';
|
||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { createMemoryHistory, createRouter } from 'vue-router';
|
||||||
|
import App from './App.vue';
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createMemoryHistory(),
|
history: createMemoryHistory(),
|
||||||
@@ -20,10 +23,6 @@ const router = createRouter({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
import { mount } from '@vue/test-utils';
|
|
||||||
import { createMemoryHistory, createRouter } from 'vue-router';
|
|
||||||
import App from './App.vue';
|
|
||||||
|
|
||||||
describe('App', () => {
|
describe('App', () => {
|
||||||
it('renders RouterView', async () => {
|
it('renders RouterView', async () => {
|
||||||
router.push('/');
|
router.push('/');
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { GlobalThemeOverrides } from 'naive-ui';
|
||||||
|
import { darkTheme } from 'naive-ui';
|
||||||
import { RouterView } from 'vue-router';
|
import { RouterView } from 'vue-router';
|
||||||
import { darkTheme, type GlobalThemeOverrides } from 'naive-ui';
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
// https://www.naiveui.com/zh-CN/light/docs/customize-theme
|
// https://www.naiveui.com/zh-CN/light/docs/customize-theme
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import type { Ref } from 'vue';
|
|
||||||
import type { MenuInst, MenuOption } from 'naive-ui';
|
import type { MenuInst, MenuOption } from 'naive-ui';
|
||||||
import { createGetRoutes } from 'virtual:meta-layouts';
|
import { createGetRoutes } from 'virtual:meta-layouts';
|
||||||
import { RouterLink, type RouteRecordRaw } from 'vue-router';
|
import type { Ref } from 'vue';
|
||||||
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
import { RouterLink } from 'vue-router';
|
||||||
import IconMenuRounded from '~icons/material-symbols/menu-rounded';
|
import IconMenuRounded from '~icons/material-symbols/menu-rounded';
|
||||||
|
|
||||||
export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<MenuInst | null> }) {
|
export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<MenuInst | null> }) {
|
||||||
|
|||||||
10
src/main.ts
10
src/main.ts
@@ -1,13 +1,11 @@
|
|||||||
import './styles/index.ts';
|
import './styles/index.ts';
|
||||||
|
import { LogLevels } from 'consola';
|
||||||
// import { LogLevels } from 'consola';
|
|
||||||
// consola.level = LogLevels.verbose;
|
|
||||||
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
import { setupPlugins } from './plugins';
|
||||||
|
|
||||||
|
consola.level = LogLevels.verbose;
|
||||||
|
|
||||||
/* `import.meta.glob(${g}, { eager: ${isSync} })`; */
|
/* `import.meta.glob(${g}, { eager: ${isSync} })`; */
|
||||||
const autoInstallModules = import.meta.glob('./plugins/!(index).ts', { eager: true });
|
const autoInstallModules = import.meta.glob('./plugins/!(index).ts', { eager: true });
|
||||||
|
|
||||||
import { setupPlugins } from './plugins';
|
|
||||||
|
|
||||||
setupPlugins(createApp(App), autoInstallModules).mount('#app');
|
setupPlugins(createApp(App), autoInstallModules).mount('#app');
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import type { FunctionalComponent } from 'vue';
|
|
||||||
|
|
||||||
import hljs from 'highlight.js/lib/core';
|
import hljs from 'highlight.js/lib/core';
|
||||||
import json from 'highlight.js/lib/languages/json';
|
import json from 'highlight.js/lib/languages/json';
|
||||||
|
import type { FunctionalComponent } from 'vue';
|
||||||
|
|
||||||
hljs.registerLanguage('json', json);
|
hljs.registerLanguage('json', json);
|
||||||
|
|
||||||
definePage({ meta: { link: true } });
|
definePage({ meta: { link: true } });
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
import type { ConfigEnv, PluginOption } from 'vite';
|
import consola from 'consola';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
import AutoImport from 'unplugin-auto-import/vite';
|
import AutoImport from 'unplugin-auto-import/vite';
|
||||||
|
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
|
||||||
import Icons from 'unplugin-icons/vite';
|
import Icons from 'unplugin-icons/vite';
|
||||||
import Components from 'unplugin-vue-components/vite';
|
import Components from 'unplugin-vue-components/vite';
|
||||||
|
|
||||||
import { VueRouterAutoImports } from 'unplugin-vue-router';
|
import { VueRouterAutoImports } from 'unplugin-vue-router';
|
||||||
import { createUtils4uAutoImports } from 'utils4u/auto-imports';
|
import { createUtils4uAutoImports } from 'utils4u/auto-imports';
|
||||||
|
import type { ConfigEnv, PluginOption } from 'vite';
|
||||||
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
|
|
||||||
|
|
||||||
// >>>>>
|
// >>>>>
|
||||||
|
// eslint-disable-next-line import/no-duplicates
|
||||||
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-duplicates
|
||||||
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
|
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-duplicates
|
||||||
import { TDesignResolver } from 'unplugin-vue-components/resolvers';
|
import { TDesignResolver } from 'unplugin-vue-components/resolvers';
|
||||||
|
|
||||||
import { PrimeVueResolver } from '@primevue/auto-import-resolver';
|
import { PrimeVueResolver } from '@primevue/auto-import-resolver';
|
||||||
@@ -23,10 +27,6 @@ import IconsResolver from 'unplugin-icons/resolver';
|
|||||||
import { VantResolver } from '@vant/auto-import-resolver';
|
import { VantResolver } from '@vant/auto-import-resolver';
|
||||||
// <<<<<
|
// <<<<<
|
||||||
|
|
||||||
import consola from 'consola';
|
|
||||||
import fs from 'node:fs';
|
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
function _getNaiveUiComponentNames() {
|
function _getNaiveUiComponentNames() {
|
||||||
// 方法1: 从 web-types.json 读取(推荐)
|
// 方法1: 从 web-types.json 读取(推荐)
|
||||||
const webTypesPath = path.resolve('node_modules/naive-ui/web-types.json');
|
const webTypesPath = path.resolve('node_modules/naive-ui/web-types.json');
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import consola from 'consola';
|
import consola from 'consola';
|
||||||
import { loadEnv, type ConfigEnv, type PluginOption } from 'vite';
|
import type { ConfigEnv, PluginOption } from 'vite';
|
||||||
|
import { loadEnv } from 'vite';
|
||||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||||
|
|
||||||
export function loadPlugin(configEnv: ConfigEnv): PluginOption {
|
export function loadPlugin(configEnv: ConfigEnv): PluginOption {
|
||||||
|
|||||||
Reference in New Issue
Block a user