Skip to content

Commit

Permalink
fix: the erroneous corrections caused by biome. (elizaOS#3052)
Browse files Browse the repository at this point in the history
- fix the sample serviceType is undefined
- fix erroneous corrections in di plugin caused by biome.
- add Parameter Decorators support in biome
  • Loading branch information
btspoony authored Jan 31, 2025
1 parent 448c758 commit 7172794
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 94 deletions.
162 changes: 85 additions & 77 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
8 changes: 4 additions & 4 deletions packages/_examples/plugin-with-di/src/actions/sampleAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ const options: ActionOptions<CreateResourceContent> = {
*/
@injectable()
export class CreateResourceAction extends BaseInjectableAction<CreateResourceContent> {
private sampleProvider: SampleProvider;

constructor(sampleProvider: SampleProvider) {
constructor(
@inject(SampleProvider)
private readonly sampleProvider: SampleProvider
) {
super(options);
this.sampleProvider = sampleProvider;
}

async validate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ export class SampleProvider
{
private _sharedInstance: Record<string, string>;

private dynamicData: Record<string, string>;

constructor(dynamicData: Record<string, string>) {
this.dynamicData = dynamicData;
}
constructor(
@inject("DYNAMIC_DATA")
private readonly dynamicData: Record<string, string>
) {}

// ---- Implementing the InjectableProvider interface ----

Expand Down
10 changes: 5 additions & 5 deletions packages/_examples/plugin-with-di/src/services/sampleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/_examples/plugin/src/services/sampleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-di/src/actions/baseInjectableAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export abstract class BaseInjectableAction<T> implements InjectableAction<T> {
/**
* Constructor for the base injectable action
*/
constructor(opts: ActionOptions<T>) {
constructor(@unmanaged() opts: ActionOptions<T>) {
// Set the action properties
this.name = opts.name;
this.similes = opts.similes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7172794

Please sign in to comment.