Skip to content

Commit

Permalink
style: migrate to new ESLint config format
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Nov 6, 2023
1 parent 8e28933 commit 3886cdf
Show file tree
Hide file tree
Showing 47 changed files with 165 additions and 220 deletions.
12 changes: 0 additions & 12 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion apps/admin/src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const vueQueryOptions: VueQueryPluginOptions = {
queryClientConfig: {
defaultOptions: {
queries: {
cacheTime: 1000 * 60 * 60 * 24,
staleTime: 1000 * 60 * 60 * 24,
},
},
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/composables/setting/useGlobSetting.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GlobConfig, GlobEnvConfig } from "@celeris/types";
import { getAppGlobalConfig } from "@celeris/utils";

export const useGlobSetting = (): Readonly<GlobConfig> => {
export function useGlobSetting(): Readonly<GlobConfig> {
const glob = getAppGlobalConfig(<GlobEnvConfig>import.meta.env);
return glob as Readonly<GlobConfig>;
};
}
4 changes: 2 additions & 2 deletions apps/admin/src/directives/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function isAuth(el: Element, binding: any) {
}
}

const mounted = (el: Element, binding: DirectiveBinding<any>) => {
function mounted(el: Element, binding: DirectiveBinding<any>) {
isAuth(el, binding);
};
}

const authDirective: Directive = {
mounted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import ToolTipper from "~/layouts/header/components/ToolTipper.vue";
withDefaults(
defineProps<{ tooltipText?: string;icon: string;color: string }>(), {
defineProps<{ tooltipText?: string;icon: string;color: string }>(),
{
tooltipText: "icon Button",
icon: "i-mdi-alert ",
color: "gray",
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/layouts/header/components/LocaleSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const options = computed(
key: item,
})),
);
const handleSelect = (key: string) => {
function handleSelect(key: string) {
setProjectSetting({ locale: key });
locale.value = key;
LocalesEngine.setLocale(key);
};
}
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/layouts/header/components/UserInfoButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const userStore = useUserStore();
const userInfo = toRef<UserInfo | null>(userStore.getUserInfo);
const dialog = useDialog();
const message = useMessage();
const handleLogout = () => {
function handleLogout() {
dialog.warning({
title: t("layouts.logoutConfirmation.title"),
content: t("layouts.logoutConfirmation.content"),
Expand All @@ -22,7 +22,7 @@ const handleLogout = () => {
message.info(t("layouts.logoutConfirmation.onNegativeClickMessage"));
},
});
};
}
</script>

<template>
Expand Down
12 changes: 6 additions & 6 deletions apps/admin/src/layouts/menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ async function handleMenuChange(route?: RouteLocationNormalizedLoaded) {
const menu = route || unref(currentRoute);
activeMenu.value = menu.path;
}
const i18nRender = (key: string) => {
function i18nRender(key: string) {
return te(key) ? t(key) : key;
};
}
const transformProjectMenuToNaiveUIMenu = (menu: Menu) => {
function transformProjectMenuToNaiveUIMenu(menu: Menu) {
const { path, meta, icon, children } = menu;
const renderIcon = (icon?: string) => {
if (!icon) {
Expand All @@ -66,12 +66,12 @@ const transformProjectMenuToNaiveUIMenu = (menu: Menu) => {
icon: renderIcon(icon || meta?.icon as string),
collapseTitle: i18nRender(meta?.title as string),
};
};
}
// Generate menu
const generateMenu = () => {
function generateMenu() {
const menus = getMenus();
menuList.value = mapTreeStructure(menus, menu => transformProjectMenuToNaiveUIMenu(menu));
};
}
// Menu changes
watch(
[() => permissionStore.getLastMenuBuildTime, () => permissionStore.getBackendMenuList],
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/pages/internal/exception/Exception.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ onMounted(() => {
try {
statusType.value = getStatusType(props.status);
checkStatus(props.status);
} catch (error) {
} catch (error: any) {
title.value = `${props.status} ${getErrorMessage(error)}`;
}
});
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/pages/login/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const loginFormRef = ref<HTMLElement & FormInst>();
/**
* This function handles the login process
*/
const login = async () => {
async function login() {
try {
// Validate the login form
const errors = await loginFormRef.value?.validate();
Expand Down Expand Up @@ -55,7 +55,7 @@ const login = async () => {
} finally {
loading.value = false;
}
};
}
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { basicRoutes } from "./routes";

// Create a whitelist of route names
const WHITE_NAME_LIST: RouteRecordName[] = [];
const generateRouteNames = (routes: RouteRecordRaw[]) => {
function generateRouteNames(routes: RouteRecordRaw[]) {
routes.forEach((route) => {
WHITE_NAME_LIST.push(route.name ?? "");
if (route.children) {
generateRouteNames(route.children);
}
});
};
}

export const router = createRouter({
history: createWebHashHistory(),
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/router/menus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ function filterMenusByPermissionMode(menus: Menu[]): Menu[] {
}

// Get all menus, filtered by permission mode and role
export const getMenus = (): Menu[] => {
export function getMenus(): Menu[] {
const menus = filterMenusByPermissionMode(staticMenus);
if (toValue(isRolePermissionMode)) {
const routes = router.getRoutes();
return filterTree(menus, basicFilter(routes));
}
return menus;
};
}

// Get the path of the closest parent menu
export function getCurrentParentPath(currentPath: string) {
Expand Down
3 changes: 2 additions & 1 deletion apps/admin/src/router/routes/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { RouteRecordRaw } from "vue-router";
import {
EXCEPTION_COMPONENT,
LAYOUT,
PAGE_NOT_FOUND_NAME, REDIRECT_NAME,
PAGE_NOT_FOUND_NAME,
REDIRECT_NAME,
} from "~/router/constant";

// 404 on a page
Expand Down
6 changes: 2 additions & 4 deletions apps/admin/src/router/routes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ function dynamicImport(dynamicPagesModules: DynamicPagesModules, component: stri
field("请不要在pages目录下的同一层级目录中创建同名的.vue和.tsx文件,否则会导致动态引入失败", ""),
);
} else {
logger.warn(`Could not find \`${component}.vue\` or \`${component}.tsx\` in src/pages/, please create it yourself!`
, field(`在src/pages/中找不到\`${component}.vue\`或\`${component}.tsx\`,请自行创建!`, ""));
logger.warn(`Could not find \`${component}.vue\` or \`${component}.tsx\` in src/pages/, please create it yourself!`, field(`在src/pages/中找不到\`${component}.vue\`或\`${component}.tsx\`,请自行创建!`, ""));
return EXCEPTION_COMPONENT;
}
}
Expand All @@ -102,8 +101,7 @@ export function transformBackendDataToRoutes(routeList: RouteRecordRaw[]): Route
route.meta = meta;
}
} else {
logger.warn(`Please configure the component property of the ${String(route.name)} route correctly.`
, field(`请正确配置${String(route.name)}路由的component属性。`, ""));
logger.warn(`Please configure the component property of the ${String(route.name)} route correctly.`, field(`请正确配置${String(route.name)}路由的component属性。`, ""));
}

route.children && asyncImportRoute(route.children, undefined);
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/store/modules/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const useUserStore = defineStore({
if (this.getToken) {
try {
await logoutApi();
} catch (error) {
} catch (error: any) {
logger.error("logout error", field("error", getErrorMessage(error)));
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/store/plugin/persist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const PERSIST_KEY_PREFIX = createStorageName(<GlobEnvConfig>import.meta.e
* @param shouldEnableEncryption whether to enable encryption for storage data 是否启用存储数据加密
* @returns serializer
*/
const customSerializer = (shouldEnableEncryption: boolean): Serializer => {
function customSerializer(shouldEnableEncryption: boolean): Serializer {
if (shouldEnableEncryption) {
return {
deserialize: (value) => {
Expand All @@ -50,7 +50,7 @@ const customSerializer = (shouldEnableEncryption: boolean): Serializer => {
},
};
}
};
}

/**
* Register Pinia Persist Plugin
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "esnext"],
"module": "esnext",
"baseUrl": ".",
"module": "esnext",
"paths": {
"~/*": ["src/*"]
},
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/types/shims-vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
declare module "*.vue" {
import type { DefineComponent } from "vue";

const component: DefineComponent<{}, {}, any>;
const component: DefineComponent<object, object, any>;
export default component;
}
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import kirklin from "@kirklin/eslint-config";

export default kirklin();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@changesets/cli": "^2.26.2",
"@commitlint/cli": "^18.2.0",
"@commitlint/config-conventional": "^18.1.0",
"@kirklin/eslint-config": "^1.0.0",
"@kirklin/eslint-config": "^1.0.1",
"@types/fs-extra": "^11.0.3",
"@types/node": "^20.8.10",
"@types/nprogress": "^0.2.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/node/tsconfig/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"allowJs": true,
"strict": true,
"strictFunctionTypes": false,
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"declaration": true,
"declarationMap": true,
"removeComments": true,
"inlineSources": false,
"isolatedModules": true,
"removeComments": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": false,
"strictFunctionTypes": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"isolatedModules": true,
"preserveWatchOutput": true,
"skipLibCheck": true
},
Expand Down
3 changes: 2 additions & 1 deletion packages/web/components/Icon/src/UnoCSSIcon.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
withDefaults(
defineProps<{ icon: string;size?: string }>(), {
defineProps<{ icon: string;size?: string }>(),
{
icon: "i-mdi-alert",
size: "5",
},
Expand Down
5 changes: 2 additions & 3 deletions packages/web/constants/src/commonConstants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// A constant function that does nothing and returns undefined
// 一个什么都不做并返回 undefined 的常量函数
export const NOOP = (): undefined => {
// eslint-disable-next-line no-void
export function NOOP(): undefined {
return void 0;
};
}
4 changes: 2 additions & 2 deletions packages/web/hooks/src/useComponentRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isComponentInstance } from "@celeris/utils";
import type { ComponentPublicInstance } from "vue";
import { onMounted, ref, watch } from "vue";

export const useComponentRef = (name: string) => {
export function useComponentRef(name: string) {
const componentRef = ref<HTMLElement | ComponentPublicInstance>();

const getElement = () => {
Expand All @@ -26,4 +26,4 @@ export const useComponentRef = (name: string) => {
componentRef,
elementRef,
};
};
}
4 changes: 2 additions & 2 deletions packages/web/locale/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { LocalesConfiguration } from "./config";
// eslint-disable-next-line import/no-mutable-exports
export let i18n: ReturnType<typeof createI18n>;

const createI18nOptions = async (): Promise<I18nOptions> => {
async function createI18nOptions(): Promise<I18nOptions> {
return deepMerge({
legacy: false,
locale: LocalesConfiguration.locale,
fallbackLocale: LocalesConfiguration.fallbackLocale,
messages: await LocalesConfiguration.messagesHandler(),
}, LocalesConfiguration.otherOptions);
};
}
export async function setupI18n(app: App) {
const options = await createI18nOptions();
i18n = createI18n(options);
Expand Down
4 changes: 2 additions & 2 deletions packages/web/request/src/axiosCancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { AxiosRequestConfig } from "axios";
// 用于存储每个请求的标识和取消函数
const pendingMap = new Map<string, AbortController>();

const getPendingUrl = (config: AxiosRequestConfig): string => {
function getPendingUrl(config: AxiosRequestConfig): string {
return [config.method, config.url].join("&");
};
}

export class AxiosCanceler {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export const defaultTransform: AxiosTransform = {
*/
onRequestError(error: Error, options: RequestOptions): any {
return {
error, options,
error,
options,
};
},

Expand Down
4 changes: 2 additions & 2 deletions packages/web/request/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function joinTimestamp(join: boolean, restful = false): string | object {
/**
* @description: Format request parameter time
*/
export const formatRequestDate = (params: Record<string, any>) => {
export function formatRequestDate(params: Record<string, any>) {
if (!isObject(params)) {
return;
}
Expand All @@ -44,7 +44,7 @@ export const formatRequestDate = (params: Record<string, any>) => {
formatRequestDate(params[key]);
}
});
};
}
/**
* Add the object as a parameter to the URL
* @param baseUrl url
Expand Down
2 changes: 1 addition & 1 deletion packages/web/types/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
declare module "*.vue" {
import type { DefineComponent } from "vue";

const component: DefineComponent<{}, {}, any>;
const component: DefineComponent<object, object, any>;
export default component;
}
Loading

2 comments on commit 3886cdf

@vercel
Copy link

@vercel vercel bot commented on 3886cdf Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

celeris-web – ./apps/admin

celeris-web-git-master-kirklin.vercel.app
celeris-web-kirklin.vercel.app
celeris-web.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 3886cdf Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

celeris-web-api – ./services/admin

celeris-web-api-git-master-kirklin.vercel.app
celeris-web-api.vercel.app
celeris-web-api-kirklin.vercel.app

Please sign in to comment.