From 7172794965f6d79a01e9eedd0e6ac334675f08a6 Mon Sep 17 00:00:00 2001 From: "BT.Wood(Tang Bo Hao)" Date: Fri, 31 Jan 2025 13:29:13 +0800 Subject: [PATCH] fix: the erroneous corrections caused by biome. (#3052) - fix the sample serviceType is undefined - fix erroneous corrections in di plugin caused by biome. - add Parameter Decorators support in biome --- biome.json | 162 +++++++++--------- .../src/actions/sampleAction.ts | 8 +- .../src/providers/sampleProvider.ts | 9 +- .../src/services/sampleService.ts | 10 +- .../plugin/src/services/sampleService.ts | 2 +- .../src/actions/baseInjectableAction.ts | 2 +- .../src/evaluators/baseInjectableEvaluator.ts | 2 +- 7 files changed, 101 insertions(+), 94 deletions(-) diff --git a/biome.json b/biome.json index d84744d33b7..7772669d21d 100644 --- a/biome.json +++ b/biome.json @@ -1,88 +1,96 @@ { "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", "organizeImports": { - "enabled": false + "enabled": false }, "linter": { - "enabled": true, - "rules": { - "recommended": true, - "suspicious": { - "noExplicitAny": "warn", - "noArrayIndexKey": "warn", - "noPrototypeBuiltins": "warn", - "noDuplicateObjectKeys": "warn", - "noGlobalIsNan": "warn", - "noDuplicateFontNames": "warn", - "noSelfCompare": "warn", - "noDoubleEquals": "warn", - "noImplicitAnyLet": "warn", - "noAssignInExpressions": "warn", - "noExportsInTest": "warn", - "noConstEnum": "warn", - "noEmptyInterface": "warn" + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "warn", + "noArrayIndexKey": "warn", + "noPrototypeBuiltins": "warn", + "noDuplicateObjectKeys": "warn", + "noGlobalIsNan": "warn", + "noDuplicateFontNames": "warn", + "noSelfCompare": "warn", + "noDoubleEquals": "warn", + "noImplicitAnyLet": "warn", + "noAssignInExpressions": "warn", + "noExportsInTest": "warn", + "noConstEnum": "warn", + "noEmptyInterface": "warn" + }, + "correctness": { + "noUnusedVariables": "warn", + "noUnreachable": "warn", + "useExhaustiveDependencies": "warn", + "noSwitchDeclarations": "warn", + "noUnnecessaryContinue": "warn", + "noInnerDeclarations": "warn" + }, + "style": { + "useConst": "warn", + "useTemplate": "warn", + "useImportType": "warn", + "useNodejsImportProtocol": "warn", + "noUselessElse": "warn", + "useSelfClosingElements": "warn", + "useNumberNamespace": "warn", + "noUnusedTemplateLiteral": "warn", + "noInferrableTypes": "warn", + "noNonNullAssertion": "warn", + "noParameterAssign": "warn", + "useDefaultParameterLast": "warn", + "useExponentiationOperator": "warn", + "noVar": "warn", + "useSingleVarDeclarator": "warn", + "useExportType": "warn" + }, + "a11y": { + "useAltText": "warn", + "useFocusableInteractive": "warn", + "useMediaCaption": "warn", + "noSvgWithoutTitle": "warn", + "useKeyWithClickEvents": "warn" + }, + "complexity": { + "noForEach": "warn", + "useOptionalChain": "warn", + "useArrowFunction": "warn", + "useFlatMap": "warn", + "useLiteralKeys": "warn", + "noBannedTypes": "warn", + "noStaticOnlyClass": "warn", + "noThisInStatic": "warn", + "noUselessConstructor": "warn", + "noUselessTernary": "warn", + "noUselessSwitchCase": "warn", + "noUselessCatch": "warn" + }, + "performance": { + "noDelete": "warn", + "noAccumulatingSpread": "warn" + } }, - "correctness": { - "noUnusedVariables": "warn", - "noUnreachable": "warn", - "useExhaustiveDependencies": "warn", - "noSwitchDeclarations": "warn", - "noUnnecessaryContinue": "warn", - "noInnerDeclarations": "warn" - }, - "style": { - "useConst": "warn", - "useTemplate": "warn", - "useImportType": "warn", - "useNodejsImportProtocol": "warn", - "noUselessElse": "warn", - "useSelfClosingElements": "warn", - "useNumberNamespace": "warn", - "noUnusedTemplateLiteral": "warn", - "noInferrableTypes": "warn", - "noNonNullAssertion": "warn", - "noParameterAssign": "warn", - "useDefaultParameterLast": "warn", - "useExponentiationOperator": "warn", - "noVar": "warn", - "useSingleVarDeclarator": "warn", - "useExportType": "warn" - }, - "a11y": { - "useAltText": "warn", - "useFocusableInteractive": "warn", - "useMediaCaption": "warn", - "noSvgWithoutTitle": "warn", - "useKeyWithClickEvents": "warn" - }, - "complexity": { - "noForEach": "warn", - "useOptionalChain": "warn", - "useArrowFunction": "warn", - "useFlatMap": "warn", - "useLiteralKeys": "warn", - "noBannedTypes": "warn", - "noStaticOnlyClass": "warn", - "noThisInStatic": "warn", - "noUselessConstructor": "warn", - "noUselessTernary": "warn", - "noUselessSwitchCase": "warn", - "noUselessCatch": "warn" - }, - "performance": { - "noDelete": "warn", - "noAccumulatingSpread": "warn" - } - }, - "ignore": ["**/dist/**", "**/node_modules/**", "**/coverage/**", "**/*.json"] + "ignore": [ + "**/dist/**", + "**/node_modules/**", + "**/coverage/**", + "**/*.json" + ] }, "formatter": { - "enabled": false + "enabled": false }, "javascript": { - "formatter": { - "quoteStyle": "double", - "semicolons": "always" - } + "parser": { + "unsafeParameterDecoratorsEnabled": true + }, + "formatter": { + "quoteStyle": "double", + "semicolons": "always" + } } - } \ No newline at end of file +} diff --git a/packages/_examples/plugin-with-di/src/actions/sampleAction.ts b/packages/_examples/plugin-with-di/src/actions/sampleAction.ts index 11012464526..a5505b226ed 100644 --- a/packages/_examples/plugin-with-di/src/actions/sampleAction.ts +++ b/packages/_examples/plugin-with-di/src/actions/sampleAction.ts @@ -94,11 +94,11 @@ const options: ActionOptions = { */ @injectable() export class CreateResourceAction extends BaseInjectableAction { - private sampleProvider: SampleProvider; - - constructor(sampleProvider: SampleProvider) { + constructor( + @inject(SampleProvider) + private readonly sampleProvider: SampleProvider + ) { super(options); - this.sampleProvider = sampleProvider; } async validate( diff --git a/packages/_examples/plugin-with-di/src/providers/sampleProvider.ts b/packages/_examples/plugin-with-di/src/providers/sampleProvider.ts index 984312663e8..e126ba818fe 100644 --- a/packages/_examples/plugin-with-di/src/providers/sampleProvider.ts +++ b/packages/_examples/plugin-with-di/src/providers/sampleProvider.ts @@ -25,11 +25,10 @@ export class SampleProvider { private _sharedInstance: Record; - private dynamicData: Record; - - constructor(dynamicData: Record) { - this.dynamicData = dynamicData; - } + constructor( + @inject("DYNAMIC_DATA") + private readonly dynamicData: Record + ) {} // ---- Implementing the InjectableProvider interface ---- diff --git a/packages/_examples/plugin-with-di/src/services/sampleService.ts b/packages/_examples/plugin-with-di/src/services/sampleService.ts index 925a5fa04a5..9a8f0408bde 100644 --- a/packages/_examples/plugin-with-di/src/services/sampleService.ts +++ b/packages/_examples/plugin-with-di/src/services/sampleService.ts @@ -26,15 +26,15 @@ export class SampleService extends Service { private intervalId: NodeJS.Timeout | null = null; private readonly DEFAULT_INTERVAL = 15 * 60 * 1000; // 15 minutes in milliseconds - private sampleProvider: SampleProvider; - - constructor(sampleProvider: SampleProvider) { + constructor( + @inject(SampleProvider) + private readonly sampleProvider: SampleProvider + ) { super(); - this.sampleProvider = sampleProvider; } static get serviceType(): ServiceType { - return ServiceType.SAMPLE; + return "sample" as ServiceType.SAMPLE; } private static isInitialized = false; diff --git a/packages/_examples/plugin/src/services/sampleService.ts b/packages/_examples/plugin/src/services/sampleService.ts index be86c41c84e..07b65cef831 100644 --- a/packages/_examples/plugin/src/services/sampleService.ts +++ b/packages/_examples/plugin/src/services/sampleService.ts @@ -23,7 +23,7 @@ export class SampleService extends Service { private readonly DEFAULT_INTERVAL = 15 * 60 * 1000; // 15 minutes in milliseconds static get serviceType(): ServiceType { - return ServiceType.SAMPLE; + return "sample" as ServiceType.SAMPLE; } private static isInitialized = false; diff --git a/packages/plugin-di/src/actions/baseInjectableAction.ts b/packages/plugin-di/src/actions/baseInjectableAction.ts index 73ff24c1f8c..9ef5ced718a 100644 --- a/packages/plugin-di/src/actions/baseInjectableAction.ts +++ b/packages/plugin-di/src/actions/baseInjectableAction.ts @@ -47,7 +47,7 @@ export abstract class BaseInjectableAction implements InjectableAction { /** * Constructor for the base injectable action */ - constructor(opts: ActionOptions) { + constructor(@unmanaged() opts: ActionOptions) { // Set the action properties this.name = opts.name; this.similes = opts.similes; diff --git a/packages/plugin-di/src/evaluators/baseInjectableEvaluator.ts b/packages/plugin-di/src/evaluators/baseInjectableEvaluator.ts index 2bc24af6bed..2a1a83e0e4e 100644 --- a/packages/plugin-di/src/evaluators/baseInjectableEvaluator.ts +++ b/packages/plugin-di/src/evaluators/baseInjectableEvaluator.ts @@ -23,7 +23,7 @@ export abstract class BaseInjectableEvaluator implements InjectableEvaluator { /** * Constructor for the base injectable action */ - constructor(opts: EvaluatorOptions) { + constructor(@unmanaged() opts: EvaluatorOptions) { // Set the action properties this.name = opts.name; this.similes = opts.similes;