Skip to content

Commit

Permalink
fix: Upgrade unbuild to resolve console warning issues and also deal …
Browse files Browse the repository at this point in the history
…with post-upgrade compatibility issues (#4009)
  • Loading branch information
anncwb authored Aug 2, 2024
1 parent e544119 commit 5301591
Show file tree
Hide file tree
Showing 48 changed files with 376 additions and 737 deletions.
14 changes: 10 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# default onwer
* anncwb@126.com
* anncwb vince292007

# vben core onwer
/packages/@core/ anncwb@126.com
/internal/ anncwb@126.com
/scripts/ anncwb@126.com
/.github/ anncwb vince292007
/.vscode/ anncwb vince292007
/packages/@core/ anncwb vince292007
/internal/ anncwb vince292007
/scripts/ anncwb vince292007

# vben team onwer
apps/ vbenjs/team-v5
docs/ vbenjs/team-v5
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ body:
label: Version
description: What version of our software are you running?
options:
- Vben Admin Pro
- Vben Admin
- Vben Admin V5
- Vben Admin V2
default: 0
validations:
required: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
shell: bash
run: |
sed -i "s#VITE_COMPRESS\s*=.*#VITE_COMPRESS = gzip#g" ./apps/web-antd/.env.production
sed -i "s#VITE_PWA\s*=.*#VITE_PWA = true#g" ./apps/web-antd/.env.production
cat ./apps/web-antd/.env.production
- name: Install pnpm
Expand Down
21 changes: 20 additions & 1 deletion .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
export { default } from '@vben/lint-staged-config';
export default {
'*.{js,jsx,ts,tsx}': [
'prettier --cache --ignore-unknown --write',
'eslint --cache --fix',
],
'*.{scss,less,styl,html,vue,css}': [
'prettier --cache --ignore-unknown --write',
'stylelint --fix --allow-empty-input',
],
'*.md': ['prettier --cache --ignore-unknown --write'],
'*.vue': [
'prettier --write',
'eslint --cache --fix',
'stylelint --fix --allow-empty-input',
],
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [
'prettier --cache --write--parser json',
],
'package.json': ['prettier --cache --write'],
};
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ public-hoist-pattern[]=husky
public-hoist-pattern[]=eslint
public-hoist-pattern[]=prettier
public-hoist-pattern[]=prettier-plugin-tailwindcss
public-hoist-pattern[]=lint-staged
public-hoist-pattern[]=stylelint
public-hoist-pattern[]=*postcss*
public-hoist-pattern[]=@commitlint/*
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN echo "Builder Success 🎉"
FROM nginx:stable-alpine as production

RUN echo "types { application/javascript js mjs; }" > /etc/nginx/conf.d/mjs.conf
COPY --from=builder /app/apps/antd-view/dist /usr/share/nginx/html
COPY --from=builder /app/apps/web-antd/dist /usr/share/nginx/html

COPY ./deploy/nginx.conf /etc/nginx/nginx.conf

Expand Down
2 changes: 1 addition & 1 deletion apps/web-ele/src/views/demos/element/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function warning() {
}
function success() {
ElMessage.success(
"'Cause you walked hand in hand With another man in my place",
'Cause you walked hand in hand With another man in my place',
);
}
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"nocheck",
"prefixs",
"vitepress",
"antdv",
"ependencies",
"vite",
"echarts",
Expand Down
7 changes: 0 additions & 7 deletions internal/lint-configs/commitlint-config/build.config.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { UserConfig } from 'cz-git';

import { execSync } from 'node:child_process';

import { getPackagesSync } from '@vben/node-utils';
Expand Down Expand Up @@ -27,7 +25,10 @@ const scopeComplete = execSync('git status --porcelain || true')
?.match(/src%%((\w|-)*)/)?.[1]
?.replace(/s$/, '');

const userConfig: UserConfig = {
/**
* @type {import('cz-git').UserConfig}
*/
const userConfig = {
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
prompt: {
Expand Down Expand Up @@ -106,7 +107,7 @@ const userConfig: UserConfig = {
'function-rules/scope-enum': [
2, // level: error
'always',
(parsed: { scope: string }) => {
(parsed) => {
if (!parsed.scope || allowedScopes.includes(parsed.scope)) {
return [true];
}
Expand Down
13 changes: 4 additions & 9 deletions internal/lint-configs/commitlint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@
},
"license": "MIT",
"type": "module",
"scripts": {
"stub": "pnpm unbuild --stub"
},
"files": [
"dist"
],
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"main": "./index.mjs",
"module": "./index.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
"import": "./index.mjs",
"default": "./index.mjs"
}
},
"dependencies": {
Expand Down
6 changes: 0 additions & 6 deletions internal/lint-configs/commitlint-config/tsconfig.json

This file was deleted.

6 changes: 4 additions & 2 deletions internal/lint-configs/eslint-config/src/configs/comments.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Linter } from 'eslint';

export async function comments(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function comments(): Promise<Linter.Config[]> {
const [pluginComments] = await Promise.all([
// @ts-expect-error - no types
import('eslint-plugin-eslint-comments'),
interopDefault(import('eslint-plugin-eslint-comments')),
] as const);

return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Linter } from 'eslint';

export async function disableds(): Promise<Linter.FlatConfig[]> {
export async function disableds(): Promise<Linter.Config[]> {
return [
{
files: ['**/__tests__/**/*.?([cm])[jt]s?(x)'],
Expand Down
2 changes: 1 addition & 1 deletion internal/lint-configs/eslint-config/src/configs/ignores.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Linter } from 'eslint';

export async function ignores(): Promise<Linter.FlatConfig[]> {
export async function ignores(): Promise<Linter.Config[]> {
return [
{
ignores: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import js from '@eslint/js';
import pluginUnusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';

export async function javascript(): Promise<Linter.FlatConfig[]> {
export async function javascript(): Promise<Linter.Config[]> {
return [
{
languageOptions: {
Expand Down
7 changes: 4 additions & 3 deletions internal/lint-configs/eslint-config/src/configs/jsdoc.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { Linter } from 'eslint';

export async function jsdoc(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function jsdoc(): Promise<Linter.Config[]> {
const [pluginJsdoc] = await Promise.all([
import('eslint-plugin-jsdoc'),
interopDefault(import('eslint-plugin-jsdoc')),
] as const);

return [
{
plugins: {
// @ts-expect-error - no types
jsdoc: pluginJsdoc,
},
rules: {
Expand Down
8 changes: 5 additions & 3 deletions internal/lint-configs/eslint-config/src/configs/jsonc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Linter } from 'eslint';

export async function jsonc(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function jsonc(): Promise<Linter.Config[]> {
const [pluginJsonc, parserJsonc] = await Promise.all([
import('eslint-plugin-jsonc'),
import('jsonc-eslint-parser'),
interopDefault(import('eslint-plugin-jsonc')),
interopDefault(import('jsonc-eslint-parser')),
] as const);

return [
Expand Down
6 changes: 4 additions & 2 deletions internal/lint-configs/eslint-config/src/configs/node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { Linter } from 'eslint';

export async function node(): Promise<Linter.FlatConfig[]> {
const [pluginNode] = await Promise.all([import('eslint-plugin-n')] as const);
import { interopDefault } from '../util';

export async function node(): Promise<Linter.Config[]> {
const pluginNode = await interopDefault(import('eslint-plugin-n'));

return [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Linter } from 'eslint';

import perfectionistPlugin from 'eslint-plugin-perfectionist';

export async function perfectionist(): Promise<Linter.FlatConfig[]> {
export async function perfectionist(): Promise<Linter.Config[]> {
return [
perfectionistPlugin.configs['recommended-natural'],
{
Expand Down
6 changes: 4 additions & 2 deletions internal/lint-configs/eslint-config/src/configs/prettier.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Linter } from 'eslint';

export async function prettier(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function prettier(): Promise<Linter.Config[]> {
const [pluginPrettier] = await Promise.all([
import('eslint-plugin-prettier'),
interopDefault(import('eslint-plugin-prettier')),
] as const);
return [
{
Expand Down
6 changes: 4 additions & 2 deletions internal/lint-configs/eslint-config/src/configs/regexp.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Linter } from 'eslint';

export async function regexp(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function regexp(): Promise<Linter.Config[]> {
const [pluginRegexp] = await Promise.all([
import('eslint-plugin-regexp'),
interopDefault(import('eslint-plugin-regexp')),
] as const);

return [
Expand Down
8 changes: 5 additions & 3 deletions internal/lint-configs/eslint-config/src/configs/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { Linter } from 'eslint';

export async function test(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function test(): Promise<Linter.Config[]> {
const [pluginTest, pluginNoOnlyTests] = await Promise.all([
import('eslint-plugin-vitest'),
interopDefault(import('eslint-plugin-vitest')),
// @ts-expect-error - no types
import('eslint-plugin-no-only-tests'),
interopDefault(import('eslint-plugin-no-only-tests')),
] as const);

return [
Expand Down
6 changes: 4 additions & 2 deletions internal/lint-configs/eslint-config/src/configs/turbo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Linter } from 'eslint';

export async function turbo(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function turbo(): Promise<Linter.Config[]> {
const [pluginTurbo] = await Promise.all([
// @ts-expect-error - no types
import('eslint-config-turbo'),
interopDefault(import('eslint-config-turbo')),
] as const);

return [
Expand Down
8 changes: 5 additions & 3 deletions internal/lint-configs/eslint-config/src/configs/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { Linter } from 'eslint';

export async function typescript(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function typescript(): Promise<Linter.Config[]> {
const [pluginTs, parserTs] = await Promise.all([
import('@typescript-eslint/eslint-plugin'),
interopDefault(import('@typescript-eslint/eslint-plugin')),
// @ts-expect-error missing types
import('@typescript-eslint/parser'),
interopDefault(import('@typescript-eslint/parser')),
] as const);

return [
Expand Down
7 changes: 4 additions & 3 deletions internal/lint-configs/eslint-config/src/configs/unicorn.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { Linter } from 'eslint';

export async function unicorn(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function unicorn(): Promise<Linter.Config[]> {
const [pluginUnicorn] = await Promise.all([
// @ts-expect-error - missing types
import('eslint-plugin-unicorn'),
interopDefault(import('eslint-plugin-unicorn')),
] as const);

return [
Expand Down
10 changes: 6 additions & 4 deletions internal/lint-configs/eslint-config/src/configs/vue.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { Linter } from 'eslint';

export async function vue(): Promise<Linter.FlatConfig[]> {
import { interopDefault } from '../util';

export async function vue(): Promise<Linter.Config[]> {
const [pluginVue, parserVue, parserTs] = await Promise.all([
// @ts-expect-error missing types
import('eslint-plugin-vue'),
import('vue-eslint-parser'),
interopDefault(import('eslint-plugin-vue')),
interopDefault(import('vue-eslint-parser')),
// @ts-expect-error missing types
import('@typescript-eslint/parser'),
interopDefault(import('@typescript-eslint/parser')),
] as const);

return [
Expand Down
8 changes: 8 additions & 0 deletions internal/lint-configs/eslint-config/src/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type Awaitable<T> = Promise<T> | T;

export async function interopDefault<T>(
m: Awaitable<T>,
): Promise<T extends { default: infer U } ? U : T> {
const resolved = await m;
return (resolved as any).default || resolved;
}
7 changes: 0 additions & 7 deletions internal/lint-configs/lint-staged-config/build.config.ts

This file was deleted.

Loading

0 comments on commit 5301591

Please sign in to comment.