Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/modkit plugin #42

Merged
merged 37 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cc60be0
feat: Module class
VirgilClyne Oct 18, 2024
078786f
feat: 更新模版实现
baranwang Oct 19, 2024
d744582
feat(modkit/share): types
VirgilClyne Oct 19, 2024
36fd153
feat: 修改模版渲染逻辑
baranwang Oct 19, 2024
0d0f8b2
ci: biome
baranwang Oct 19, 2024
c6c7dab
style: format
baranwang Oct 19, 2024
675a75b
feat: template 抽象化
baranwang Oct 19, 2024
b1f8ff4
feat: 禁用热模块替换(HMR)和实时重新加载(live reload)功能
baranwang Oct 19, 2024
2ce0082
feat: rule 逻辑实现
baranwang Oct 20, 2024
8fd10ee
feat: 完善surge模版渲染
baranwang Oct 20, 2024
edfb5e9
feat: 补充类型
baranwang Oct 20, 2024
9150f6e
feat: 替换为js标注私有标记
baranwang Oct 20, 2024
6563bfa
refactor: template class
baranwang Oct 20, 2024
cfc560a
feat: loon plugin
baranwang Oct 20, 2024
9727480
feat: update
baranwang Oct 20, 2024
ae8a232
feat: 更新模版渲染
baranwang Oct 20, 2024
8b6f484
feat: rule type
VirgilClyne Oct 20, 2024
2a39aae
chore: npmrc
baranwang Oct 21, 2024
e59205c
feat: quantumultx plugin
VirgilClyne Oct 21, 2024
3733b42
faet: update
baranwang Oct 21, 2024
dc98257
chore: 同步 biome 规则
baranwang Oct 21, 2024
c47c8fb
ci: biome
baranwang Oct 21, 2024
3f7dd2c
style: biome
baranwang Oct 21, 2024
68cfb8a
feat: update
baranwang Oct 21, 2024
391f3d2
feat: stash plugin
baranwang Oct 21, 2024
2059847
feat: stash plugin
baranwang Oct 21, 2024
9b595d0
feat: update
baranwang Oct 21, 2024
3d484d4
feat: 修改配置文件自动重启
baranwang Oct 21, 2024
1628a5a
fix: modkit-plugin-surge
VirgilClyne Oct 22, 2024
48ce772
refactor(modkit-plugin-surge): 统一代码样式
VirgilClyne Oct 22, 2024
18387b6
feat(modkit-shared)!: 允许额外配置
VirgilClyne Oct 22, 2024
b3514d9
feat(modkit-plugin)!: 允许额外配置
VirgilClyne Oct 22, 2024
8250e39
feat(modkit-plugin-quantumultx)
VirgilClyne Oct 22, 2024
ed523d0
fix(modkit-shared): 参数与分割符均含逗号时
VirgilClyne Oct 22, 2024
ef09c0e
feat(modkit-plugin-quantumultx)
VirgilClyne Oct 23, 2024
0012a9c
test: 新增单元测试
baranwang Oct 25, 2024
ec66484
chore: update config
baranwang Nov 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Code quality

on:
push:
pull_request:

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci . --reporter=github
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": ["biome check --write --no-errors-on-unmatched"]
}
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
registry=https://registry.npmjs.org/
link-workspace-packages=true
link-workspace-packages=true
enable-pre-post-scripts=true
6 changes: 2 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"recommendations": [
"biomejs.biome"
]
}
"recommendations": ["biomejs.biome"]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"source.organizeImports.biome": "explicit"
},
"conventionalCommits.scopes": ["arguments-builder", "sgmoudle-tools"],
"cSpell.words": ["iringo", "modkit", "rsbuild"]
"cSpell.words": ["iringo", "MITM", "modkit", "rsbuild"]
}
200 changes: 189 additions & 11 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"files": { "ignoreUnknown": false, "ignore": [] },
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"defaultBranch": "main",
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"ignore": ["packages/modkit/tests/src/arguments.d.ts"]
},
"formatter": {
"enabled": true,
"useEditorconfig": true,
Expand All @@ -13,19 +21,90 @@
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": { "enabled": true },
"organizeImports": {
"enabled": true,
"include": ["./**/*.js", "./**/*.jsx", "./**/*.ts", "./**/*.tsx", "./**/*.mjs", "./**/*.cjs"]
},
"css": {
"parser": {
"cssModules": true
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn"
},
"recommended": false,
"complexity": {
"noForEach": "off"
"noForEach": "off",
"noExtraBooleanCast": "error",
"noStaticOnlyClass": "error",
"noUselessCatch": "error",
"noUselessConstructor": "error",
"noWith": "error",
"useLiteralKeys": "error"
},
"correctness": {
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "error",
"useIsNan": "error",
"useValidForDirection": "error"
},
"security": { "noGlobalEval": "error" },
"style": {
"noNonNullAssertion": "warn"
"noArguments": "error",
"noVar": "error",
"useBlockStatements": "error",
"useConsistentBuiltinInstantiation": "error",
"useConst": "error",
"useDefaultParameterLast": "error",
"useDefaultSwitchClause": "error",
"useFilenamingConvention": {
"level": "warn",
"options": { "requireAscii": true, "filenameCases": ["kebab-case", "snake_case"] }
},
"useTemplate": "warn",
"useThrowOnlyError": "error",
"useImportType": "error"
},
"suspicious": {
"noAssignInExpressions": "error",
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDoubleEquals": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noEmptyBlockStatements": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noPrototypeBuiltins": "error",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useAwait": "error",
"useDefaultSwitchClauseLast": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
}
},
Expand All @@ -41,5 +120,104 @@
"attributePosition": "auto",
"bracketSpacing": true
}
}
},
"overrides": [
{
"include": ["*.ts", "*.tsx"],
"linter": {
"rules": {
"complexity": {
"noBannedTypes": "error",
"noStaticOnlyClass": "error",
"noUselessConstructor": "off",
"noUselessThisAlias": "error",
"noUselessTypeConstraint": "error",
"useLiteralKeys": "off",
"useOptionalChain": "warn"
},
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noPrecisionLoss": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off",
"noUnusedVariables": "off",
"useArrayLiterals": "off"
},
"style": {
"noInferrableTypes": "error",
"noNamespace": "error",
"noNonNullAssertion": "warn",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "off",
"useForOf": "warn",
"useLiteralEnumMembers": "error",
"useNamingConvention": {
"level": "error",
"options": {
"strictCase": false,
"conventions": [
{ "selector": { "kind": "class" }, "formats": ["PascalCase"] },
{ "selector": { "kind": "interface" }, "formats": ["PascalCase"] },
{ "selector": { "kind": "typeLike" }, "formats": ["PascalCase"] },
{ "selector": { "kind": "enumMember" }, "formats": ["PascalCase", "CONSTANT_CASE"] },
{ "selector": { "kind": "function" }, "match": "([^_]*)", "formats": ["camelCase"] },
{
"selector": { "kind": "importNamespace" },
"formats": ["camelCase", "PascalCase", "CONSTANT_CASE"]
},
{ "selector": { "kind": "importAlias" }, "formats": ["camelCase", "PascalCase", "CONSTANT_CASE"] },
{ "selector": { "kind": "objectLiteralProperty" }, "match": ".*" },
{ "selector": { "kind": "functionParameter" }, "match": "_?([^_]*)", "formats": ["camelCase"] },
{ "selector": { "kind": "typeProperty" }, "formats": ["camelCase", "snake_case"] },
{
"selector": { "kind": "variable", "scope": "global" },
"formats": ["camelCase", "PascalCase", "CONSTANT_CASE"]
},
{
"selector": { "kind": "variable" },
"formats": ["camelCase", "snake_case", "PascalCase", "CONSTANT_CASE"]
},
{ "formats": ["camelCase", "CONSTANT_CASE", "PascalCase"] },
{ "selector": { "kind": "variable" }, "formats": ["camelCase", "CONSTANT_CASE"] },
{
"selector": { "kind": "function" },
"formats": ["camelCase", "CONSTANT_CASE"]
},
{
"selector": { "kind": "functionParameter" },
"formats": ["camelCase", "CONSTANT_CASE"]
}
]
}
},
"useThrowOnlyError": "off"
},
"suspicious": {
"noConfusingVoidType": "error",
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noEmptyBlockStatements": "off",
"noEmptyInterface": "error",
"noExplicitAny": "warn",
"noExtraNonNullAssertion": "error",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noMisleadingInstantiator": "error",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useAwait": "off",
"useGetterReturn": "off",
"useNamespaceKeyword": "off",
"useValidTypeof": "off"
}
}
}
}
]
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"prepare": "husky",
"build": "cross-env NX_DAEMON=false nx run-many -t build --exclude @examples/* @e2e/* --parallel=10",
"mk:dev": "nx run-many -t dev --projects=@iringo/utils,@iringo/modkit* --parallel=10",
"mk:build": "nx run-many -t build --projects=@iringo/utils,@iringo/modkit* --parallel=10",
"mk:test": "nx run-many -t test --projects=@iringo/utils,@iringo/modkit* --parallel=10",
"change": "changeset"
},
"author": "",
Expand All @@ -17,6 +19,8 @@
"@changesets/cli": "^2.27.8",
"@nx/js": "^20.0.0",
"cross-env": "^7.0.3",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"nx": "^20.0.0"
}
}
5 changes: 1 addition & 4 deletions packages/arguments-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
"ts-jest": "^29.2.5",
"typescript": "^5.6.2"
},
"files": [
"dist",
"CHANGELOG.md"
],
"files": ["dist", "CHANGELOG.md"],
"repository": {
"type": "git",
"url": "https://github.com/NSRingo/engineering-solutions",
Expand Down
5 changes: 1 addition & 4 deletions packages/doc-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
"build:watch": "modern build -w",
"build": "modern build"
},
"files": [
"dist",
"CHANGELOG.md"
],
"files": ["dist", "CHANGELOG.md"],
"dependencies": {
"@rc-component/qrcode": "^1.0.0",
"rc-tooltip": "^6.2.1"
Expand Down
2 changes: 2 additions & 0 deletions packages/doc-ui/src/module-install/module-install-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import type { SupportedApp } from './constants';

export const ModuleInstallItem: React.FC<
{
// biome-ignore lint/style/useNamingConvention: <explanation>
__appType: SupportedApp;
// biome-ignore lint/style/useNamingConvention: <explanation>
__urlPrefix?: string;
} & Omit<AppTabContentProps, 'appType'>
> = ({ __appType, __urlPrefix = '', url, ...rest }) => {
Expand Down
1 change: 1 addition & 0 deletions packages/doc-ui/src/module-install/module-install-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

export interface ModuleInstallTabProps {
type: SupportedApp;
// biome-ignore lint/style/useNamingConvention: <explanation>
__urlPrefix?: string;
children?: React.ReactNode;
}
Expand All @@ -20,7 +21,7 @@
'displayName' in childType &&
childType.displayName === 'ModuleInstallItem'
) {
return cloneElement(child, { __appType: appType, __urlPrefix } as any);

Check warning on line 24 in packages/doc-ui/src/module-install/module-install-tab.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/suspicious/noExplicitAny

Unexpected any. Specify a different type.

Check warning on line 24 in packages/doc-ui/src/module-install/module-install-tab.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/suspicious/noExplicitAny

Unexpected any. Specify a different type.
}
return createElement(
'div',
Expand Down
7 changes: 5 additions & 2 deletions packages/doc-ui/src/module-install/module-install.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
export interface ModuleInstallProps {
urlPrefix?: string;
urls?: {
[key in SupportedApp]?: string;
[Key in SupportedApp]?: string;
};
children?: React.ReactNode;
}

// biome-ignore lint/style/useNamingConvention: React Component
export function ModuleInstall({ urlPrefix = '', urls, children }: ModuleInstallProps) {
const renderTabLabel = useCallback((appType: SupportedApp) => {
return (
Expand Down Expand Up @@ -49,7 +50,7 @@
if (children) {
return Children.map(children, (child) => {
if (isValidElement(child)) {
return cloneElement(child, { __urlPrefix: urlPrefix } as any);

Check warning on line 53 in packages/doc-ui/src/module-install/module-install.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/suspicious/noExplicitAny

Unexpected any. Specify a different type.

Check warning on line 53 in packages/doc-ui/src/module-install/module-install.tsx

View workflow job for this annotation

GitHub Actions / quality

lint/suspicious/noExplicitAny

Unexpected any. Specify a different type.
}
return null;
});
Expand All @@ -57,7 +58,9 @@
const result: React.ReactNode[] = [];
SUPPORTED_APPS.forEach((appType) => {
const url = urls?.[appType];
if (!url) return;
if (!url) {
return;
}
result.push(
<Tab key={appType}>
<AppTabContent key={url} appType={appType} url={`${urlPrefix}${url}`} />
Expand Down
2 changes: 1 addition & 1 deletion packages/doc-ui/src/nav-icon/nav-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PopoverContent } from './popover-content';

export const NavIcon: React.FC = () => {
return (
<Popover overlay={<PopoverContent />} placement='bottomLeft'>
<Popover overlay={<PopoverContent />} placement="bottomLeft">
<span className={styles.icon}>
<IconNav />
</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/doc-ui/src/nav-icon/popover-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const PROJECTS = [
export const PopoverContent: React.FC = () => {
const renderLink = ({ icon, url, title, description }: (typeof PROJECTS)[number]) => {
return (
<a key={title} className={styles.item} href={url} target='_blank' rel='noopener noreferrer'>
<a key={title} className={styles.item} href={url} target="_blank" rel="noopener noreferrer">
<img className={styles.icon} src={icon} alt={title} />
<div>
<span className={styles.title}>{title}</span>
Expand Down
6 changes: 4 additions & 2 deletions packages/modkit/core/bin/modkit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env node
const { initCommand } = require('../dist/index.js');
const { ModKitCli } = require('../dist/index.js');

initCommand();
const cli = new ModKitCli();

cli.run();
Loading
Loading