Skip to content

Commit

Permalink
chore(deps): add simple-git-hooks lint-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeng889 committed Aug 31, 2024
1 parent 0eded8d commit 9c977fd
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 142 deletions.
2 changes: 1 addition & 1 deletion build/plugins/auto-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function setupAutoImport(viteEnv: Env.ImportMeta) {

function autoImportAntd(componentName: string) {
const pattern = /^A[A-Z]/;
if (!pattern.test(componentName)) {
if (pattern.test(componentName)) {
return { name: componentName.slice(1), from: 'antd' };
}
return null;
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"dev:prod": "vite --mode prod",
"gen-route": "sa gen-route",
"lint": "eslint . --fix",
"prepare": "simple-git-hooks",
"preview": "vite preview",
"release": "sa release",
"typecheck": "tsc --noEmit --skipLibCheck",
Expand Down Expand Up @@ -103,7 +104,9 @@
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.11",
"lint-staged": "^15.2.9",
"sass": "1.77.8",
"simple-git-hooks": "^2.11.1",
"tsx": "4.18.0",
"typescript": "5.5.4",
"unplugin-auto-import": "0.18.2",
Expand All @@ -113,5 +116,12 @@
"vite-plugin-remove-console": "2.2.0",
"vite-plugin-svg-icons": "2.0.1"
},
"simple-git-hooks": {
"commit-msg": "pnpm sa git-commit-verify",
"pre-commit": "pnpm typecheck && pnpm lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
},
"website": "https://react-soybean.ohh-889.com/"
}
2 changes: 1 addition & 1 deletion packages/scripts/src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import type { Options } from 'execa';
export async function execCommand(cmd: string, args: string[], options?: Options) {
const { execa } = await import('execa');
const res = await execa(cmd, args, options);
return res?.stdout?.trim() || '';
return (res?.stdout as string)?.trim() || '';
}
9 changes: 3 additions & 6 deletions packages/simple-router/src/matcher/shared.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import type { ElegantConstRoute } from '@ohh-889/react-auto-route';
import { warn } from '../warning';
import type { LocationQuery } from '../types';
Expand Down Expand Up @@ -34,17 +36,12 @@ export function generatePath(pathTemplate: string, params: { [key: string]: stri
return path;
}

/**
* Normalizes a RouteRecordRaw. Creates a copy
*
* @param record
* @returns the normalized version
*/
export function normalizeRouteRecord(record: ElegantConstRoute): RouteRecordNormalized {
return {
redirect: record.redirect || (record.children && record.children[0].path),
path: record.path || '',
name: record.name,

meta: record.meta || {},
children:
record.children?.map(child => {
Expand Down
2 changes: 2 additions & 0 deletions packages/simple-router/src/matcher/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ElegantConstRoute } from '@ohh-889/react-auto-route';
import type { _RouteRecordBase } from '../types';

export interface RouteRecordNormalized {
/** {@inheritDoc _RouteRecordBase.path} */
path: _RouteRecordBase['path'];
Expand All @@ -12,6 +13,7 @@ export interface RouteRecordNormalized {
/** Nested route records. */
children: ElegantConstRoute[];
/** {@inheritDoc _RouteRecordBase.meta} */

meta: Exclude<_RouteRecordBase['meta'], void>;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/simple-router/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import type { Location, RouteObject } from 'react-router-dom';
import { RouterProvider, createBrowserRouter, createHashRouter, createMemoryRouter } from 'react-router-dom';
import type { BlockerFunction, Router as RemixRouter, RouterState } from '@remix-run/router';
Expand Down
2 changes: 2 additions & 0 deletions packages/simple-router/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import type { ElegantConstRoute, RouteMeta } from '@ohh-889/react-auto-route';
import type { Router as RemixRouter } from '@remix-run/router';
import type { RouteObject } from 'react-router-dom';
Expand Down
Loading

0 comments on commit 9c977fd

Please sign in to comment.