chore: format all common files (#431)

This commit is contained in:
tecvan
2025-07-31 21:46:47 +08:00
committed by GitHub
parent 8136ddd82d
commit 40088b0a05
60 changed files with 658 additions and 288 deletions

View File

@@ -18,46 +18,41 @@ import type {
IPlugin,
IHooks,
IPromptsHookParams,
} from "rush-init-project-plugin";
} from 'rush-init-project-plugin';
import { readFileSync } from 'fs';
import path from 'path';
import JSON5 from '../../autoinstallers/plugins/node_modules/json5'
import JSON5 from '../../autoinstallers/plugins/node_modules/json5';
const rushJson = JSON5.parse(
readFileSync(
path.resolve(__dirname, '../../../rush.json')
).toString('utf-8')
readFileSync(path.resolve(__dirname, '../../../rush.json')).toString('utf-8'),
);
export default class SelectTeamPlugin implements IPlugin {
apply(hooks: IHooks): void {
hooks.prompts.tap("SelectTeamPlugin", (prompts: IPromptsHookParams) => {
hooks.prompts.tap('SelectTeamPlugin', (prompts: IPromptsHookParams) => {
// Leave only the prefix team-
const teamNamePrefix = /^team-/;
const choices = rushJson.allowedProjectTags.filter(
teamName => teamNamePrefix.test(teamName)
).map(
teamName => teamName.replace(teamNamePrefix, '')
);
const choices = rushJson.allowedProjectTags
.filter(teamName => teamNamePrefix.test(teamName))
.map(teamName => teamName.replace(teamNamePrefix, ''));
// Unshift an issue, causing the user to display the issue after selecting a template.
prompts.promptQueue.unshift({
type: "list",
name: "team",
message: "Select your team",
type: 'list',
name: 'team',
message: 'Select your team',
choices,
default: 0, // Default choices [0]
});
const projectFolderPrompt = prompts.promptQueue.find(
item => item.name === 'projectFolder'
item => item.name === 'projectFolder',
);
projectFolderPrompt.default = (answers) => {
projectFolderPrompt.default = answers => {
// Remove the scope from the folder name, such as @code-arch/foo - > foo
const folderDir = answers.packageName.split('/').slice(-1)[0];
return `frontend/packages/${answers.team}/${folderDir}`;
}
};
});
}
}

View File

@@ -13,12 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { ILogger } from 'rush-init-project-plugin';
// eslint-disable-next-line @infra/no-deep-relative-import
import { spawnSync } from 'child_process';
const exec = (logger: ILogger, cmd: string, args: string[]): string | undefined => {
const exec = (
logger: ILogger,
cmd: string,
args: string[],
): string | undefined => {
try {
if (!cmd) {
return undefined;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import process from 'process';
// parseArgs.ts

View File

@@ -21,8 +21,8 @@ import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
const config: IConfig = {
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
defaultProjectConfiguration: {
tags:['level-3']
}
tags: ['level-3'],
},
};
export default config;

View File

@@ -40,7 +40,6 @@
"react-dom": "~18.2.0",
"storybook": "^7.6.7",
"stylelint": "^15.11.0",
"vite-plugin-svgr": "~3.3.0",
"vitest": "~3.0.5"
},
@@ -49,3 +48,4 @@
"react-dom": ">=18.2.0"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { useState } from 'react';
import classNames from 'classnames';

View File

@@ -13,5 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { DemoComponent } from './demo';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DemoComponent } from '../src';
export default {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
import SelectTeamPlugin from '../_plugins/SelectTeamPlugin';
import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
@@ -21,8 +21,8 @@ import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
const config: IConfig = {
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
defaultProjectConfiguration: {
tags:['level-3']
}
tags: ['level-3'],
},
};
export default config;

View File

@@ -19,8 +19,8 @@
"@coze-arch/vitest-config": "workspace:*",
"@types/node": "^18",
"@vitest/coverage-v8": "~3.0.5",
"vitest": "~3.0.5",
"sucrase": "^3.32.0"
"sucrase": "^3.32.0",
"vitest": "~3.0.5"
}
}

View File

@@ -13,5 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const foo = 'bar';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -21,8 +21,8 @@ import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
const config: IConfig = {
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
defaultProjectConfiguration: {
tags:['level-4']
}
tags: ['level-4'],
},
};
export default config;

View File

@@ -26,9 +26,9 @@
},
"devDependencies": {
"@coze-arch/eslint-config": "workspace:*",
"@coze-arch/stylelint-config": "workspace:*",
"@coze-arch/ts-config": "workspace:*",
"@coze-arch/vitest-config": "workspace:*",
"@coze-arch/stylelint-config": "workspace:*",
"@rsbuild/core": "^0.2.18",
"@rsbuild/plugin-react": "^0.2.18",
"@slardar/web": "1.7.0",
@@ -39,7 +39,7 @@
"postcss": "^8.4.32",
"postcss-loader": "^7.3.3",
"tailwindcss": "~3.3.3",
"vitest": "~3.0.5"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import { useEffect } from 'react';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createRoot } from 'react-dom/client';
import { App } from './app';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Link } from 'react-router-dom';
import { useState } from 'react';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function Page1() {
return <div>page1</div>;
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { NODE_ENV } = process.env;
const IS_DEV_MODE = NODE_ENV === 'development'; // local environment

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
Project,
SyntaxKind,

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
import SelectTeamPlugin from '../_plugins/SelectTeamPlugin';
import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
@@ -21,8 +21,8 @@ import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
const config: IConfig = {
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
defaultProjectConfiguration: {
tags:['level-4']
}
tags: ['level-4'],
},
};
export default config;

View File

@@ -16,6 +16,9 @@
"test:cov": "npm run test -- --coverage"
},
"dependencies": {
"@coze-arch/bot-api": "workspace:*",
"@coze-arch/i18n": "workspace:*",
"@coze-arch/logger": "workspace:*",
"@douyinfe/semi-icons": "^2.36.0",
"@douyinfe/semi-ui": "2.61.0",
"immer": "^10.0.3",
@@ -23,18 +26,15 @@
"react-dom": "~18.2.0",
"react-error-boundary": "^4.0.9",
"react-router-dom": "^6.11.1",
"zustand": "^4.4.7",
"@coze-arch/logger": "workspace:*",
"@coze-arch/i18n": "workspace:*",
"@coze-arch/bot-api": "workspace:*"
"zustand": "^4.4.7"
},
"devDependencies": {
"@douyinfe/semi-rspack-plugin": "~2.48.0",
"@edenx/plugin-tailwind": "1.51.0",
"@coze-arch/eslint-config": "workspace:*",
"@coze-arch/stylelint-config": "workspace:*",
"@coze-arch/ts-config": "workspace:*",
"@coze-arch/vitest-config": "workspace:*",
"@coze-arch/stylelint-config": "workspace:*",
"@douyinfe/semi-rspack-plugin": "~2.48.0",
"@edenx/plugin-tailwind": "1.51.0",
"@rspack/cli": "0.4.0",
"@rspack/core": "0.4.0",
"@rspack/plugin-react-refresh": "0.4.0",
@@ -52,7 +52,7 @@
"tailwindcss": "~3.3.3",
"ts-morph": "^20.0.0",
"ts-node": "^10.9.1",
"vitest": "~3.0.5"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import refreshPlugin from '@rspack/plugin-react-refresh';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RouterProvider } from 'react-router-dom';
import { createRoot } from 'react-dom/client';
@@ -27,7 +27,7 @@ browserClient('init', {
bid: '',
});
browserClient('start');
reporter.init(browserClient)
reporter.init(browserClient);
const root = createRoot(document.getElementById('root'));
root.render(<RouterProvider router={router} />);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import './index.less';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { Button } from '@douyinfe/semi-ui';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { immer } from 'zustand/middleware/immer';
import { devtools } from 'zustand/middleware';
import { create } from 'zustand';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createBrowserRouter } from 'react-router-dom';
import { Page2 } from '@/pages/page2';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { devtools } from 'zustand/middleware';
import { create } from 'zustand';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type StateCreator } from 'zustand';
export interface UserInfoSlice {

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Automatically generated based on env/index.ts, do not modify manually
declare const IS_CI: boolean;
declare const IS_DEV_MODE: boolean;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare module '*.svg';
declare module '*.png';
declare module '*.less';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({

View File

@@ -21,8 +21,8 @@ import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
const config: IConfig = {
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
defaultProjectConfiguration: {
tags:['level-3']
}
tags: ['level-3'],
},
};
export default config;

View File

@@ -4,8 +4,7 @@
"description": "{{ description }}",
"license": "Apache-2.0",
"author": "{{ authorName }}",
"maintainers": [
],
"maintainers": [],
"main": "src/index.ts",
"unpkg": "./dist/umd/index.js",
"module": "./dist/esm/index.js",
@@ -63,7 +62,6 @@
"storybook": "^7.6.7",
"stylelint": "^15.11.0",
"tailwindcss": "~3.3.3",
"vite-plugin-svgr": "~3.3.0",
"vitest": "~3.0.5"
},
@@ -72,3 +70,4 @@
"react-dom": ">=18.2.0"
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { useState } from 'react';
import classNames from 'classnames';

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DemoComponent } from '../src';
export default {