Skip to content

Commit 7172794

Browse files
authored
fix: the erroneous corrections caused by biome. (elizaOS#3052)
- fix the sample serviceType is undefined - fix erroneous corrections in di plugin caused by biome. - add Parameter Decorators support in biome
1 parent 448c758 commit 7172794

File tree

7 files changed

+101
-94
lines changed

7 files changed

+101
-94
lines changed

biome.json

+85-77
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,96 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
33
"organizeImports": {
4-
"enabled": false
4+
"enabled": false
55
},
66
"linter": {
7-
"enabled": true,
8-
"rules": {
9-
"recommended": true,
10-
"suspicious": {
11-
"noExplicitAny": "warn",
12-
"noArrayIndexKey": "warn",
13-
"noPrototypeBuiltins": "warn",
14-
"noDuplicateObjectKeys": "warn",
15-
"noGlobalIsNan": "warn",
16-
"noDuplicateFontNames": "warn",
17-
"noSelfCompare": "warn",
18-
"noDoubleEquals": "warn",
19-
"noImplicitAnyLet": "warn",
20-
"noAssignInExpressions": "warn",
21-
"noExportsInTest": "warn",
22-
"noConstEnum": "warn",
23-
"noEmptyInterface": "warn"
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true,
10+
"suspicious": {
11+
"noExplicitAny": "warn",
12+
"noArrayIndexKey": "warn",
13+
"noPrototypeBuiltins": "warn",
14+
"noDuplicateObjectKeys": "warn",
15+
"noGlobalIsNan": "warn",
16+
"noDuplicateFontNames": "warn",
17+
"noSelfCompare": "warn",
18+
"noDoubleEquals": "warn",
19+
"noImplicitAnyLet": "warn",
20+
"noAssignInExpressions": "warn",
21+
"noExportsInTest": "warn",
22+
"noConstEnum": "warn",
23+
"noEmptyInterface": "warn"
24+
},
25+
"correctness": {
26+
"noUnusedVariables": "warn",
27+
"noUnreachable": "warn",
28+
"useExhaustiveDependencies": "warn",
29+
"noSwitchDeclarations": "warn",
30+
"noUnnecessaryContinue": "warn",
31+
"noInnerDeclarations": "warn"
32+
},
33+
"style": {
34+
"useConst": "warn",
35+
"useTemplate": "warn",
36+
"useImportType": "warn",
37+
"useNodejsImportProtocol": "warn",
38+
"noUselessElse": "warn",
39+
"useSelfClosingElements": "warn",
40+
"useNumberNamespace": "warn",
41+
"noUnusedTemplateLiteral": "warn",
42+
"noInferrableTypes": "warn",
43+
"noNonNullAssertion": "warn",
44+
"noParameterAssign": "warn",
45+
"useDefaultParameterLast": "warn",
46+
"useExponentiationOperator": "warn",
47+
"noVar": "warn",
48+
"useSingleVarDeclarator": "warn",
49+
"useExportType": "warn"
50+
},
51+
"a11y": {
52+
"useAltText": "warn",
53+
"useFocusableInteractive": "warn",
54+
"useMediaCaption": "warn",
55+
"noSvgWithoutTitle": "warn",
56+
"useKeyWithClickEvents": "warn"
57+
},
58+
"complexity": {
59+
"noForEach": "warn",
60+
"useOptionalChain": "warn",
61+
"useArrowFunction": "warn",
62+
"useFlatMap": "warn",
63+
"useLiteralKeys": "warn",
64+
"noBannedTypes": "warn",
65+
"noStaticOnlyClass": "warn",
66+
"noThisInStatic": "warn",
67+
"noUselessConstructor": "warn",
68+
"noUselessTernary": "warn",
69+
"noUselessSwitchCase": "warn",
70+
"noUselessCatch": "warn"
71+
},
72+
"performance": {
73+
"noDelete": "warn",
74+
"noAccumulatingSpread": "warn"
75+
}
2476
},
25-
"correctness": {
26-
"noUnusedVariables": "warn",
27-
"noUnreachable": "warn",
28-
"useExhaustiveDependencies": "warn",
29-
"noSwitchDeclarations": "warn",
30-
"noUnnecessaryContinue": "warn",
31-
"noInnerDeclarations": "warn"
32-
},
33-
"style": {
34-
"useConst": "warn",
35-
"useTemplate": "warn",
36-
"useImportType": "warn",
37-
"useNodejsImportProtocol": "warn",
38-
"noUselessElse": "warn",
39-
"useSelfClosingElements": "warn",
40-
"useNumberNamespace": "warn",
41-
"noUnusedTemplateLiteral": "warn",
42-
"noInferrableTypes": "warn",
43-
"noNonNullAssertion": "warn",
44-
"noParameterAssign": "warn",
45-
"useDefaultParameterLast": "warn",
46-
"useExponentiationOperator": "warn",
47-
"noVar": "warn",
48-
"useSingleVarDeclarator": "warn",
49-
"useExportType": "warn"
50-
},
51-
"a11y": {
52-
"useAltText": "warn",
53-
"useFocusableInteractive": "warn",
54-
"useMediaCaption": "warn",
55-
"noSvgWithoutTitle": "warn",
56-
"useKeyWithClickEvents": "warn"
57-
},
58-
"complexity": {
59-
"noForEach": "warn",
60-
"useOptionalChain": "warn",
61-
"useArrowFunction": "warn",
62-
"useFlatMap": "warn",
63-
"useLiteralKeys": "warn",
64-
"noBannedTypes": "warn",
65-
"noStaticOnlyClass": "warn",
66-
"noThisInStatic": "warn",
67-
"noUselessConstructor": "warn",
68-
"noUselessTernary": "warn",
69-
"noUselessSwitchCase": "warn",
70-
"noUselessCatch": "warn"
71-
},
72-
"performance": {
73-
"noDelete": "warn",
74-
"noAccumulatingSpread": "warn"
75-
}
76-
},
77-
"ignore": ["**/dist/**", "**/node_modules/**", "**/coverage/**", "**/*.json"]
77+
"ignore": [
78+
"**/dist/**",
79+
"**/node_modules/**",
80+
"**/coverage/**",
81+
"**/*.json"
82+
]
7883
},
7984
"formatter": {
80-
"enabled": false
85+
"enabled": false
8186
},
8287
"javascript": {
83-
"formatter": {
84-
"quoteStyle": "double",
85-
"semicolons": "always"
86-
}
88+
"parser": {
89+
"unsafeParameterDecoratorsEnabled": true
90+
},
91+
"formatter": {
92+
"quoteStyle": "double",
93+
"semicolons": "always"
94+
}
8795
}
88-
}
96+
}

packages/_examples/plugin-with-di/src/actions/sampleAction.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ const options: ActionOptions<CreateResourceContent> = {
9494
*/
9595
@injectable()
9696
export class CreateResourceAction extends BaseInjectableAction<CreateResourceContent> {
97-
private sampleProvider: SampleProvider;
98-
99-
constructor(sampleProvider: SampleProvider) {
97+
constructor(
98+
@inject(SampleProvider)
99+
private readonly sampleProvider: SampleProvider
100+
) {
100101
super(options);
101-
this.sampleProvider = sampleProvider;
102102
}
103103

104104
async validate(

packages/_examples/plugin-with-di/src/providers/sampleProvider.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ export class SampleProvider
2525
{
2626
private _sharedInstance: Record<string, string>;
2727

28-
private dynamicData: Record<string, string>;
29-
30-
constructor(dynamicData: Record<string, string>) {
31-
this.dynamicData = dynamicData;
32-
}
28+
constructor(
29+
@inject("DYNAMIC_DATA")
30+
private readonly dynamicData: Record<string, string>
31+
) {}
3332

3433
// ---- Implementing the InjectableProvider interface ----
3534

packages/_examples/plugin-with-di/src/services/sampleService.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ export class SampleService extends Service {
2626
private intervalId: NodeJS.Timeout | null = null;
2727
private readonly DEFAULT_INTERVAL = 15 * 60 * 1000; // 15 minutes in milliseconds
2828

29-
private sampleProvider: SampleProvider;
30-
31-
constructor(sampleProvider: SampleProvider) {
29+
constructor(
30+
@inject(SampleProvider)
31+
private readonly sampleProvider: SampleProvider
32+
) {
3233
super();
33-
this.sampleProvider = sampleProvider;
3434
}
3535

3636
static get serviceType(): ServiceType {
37-
return ServiceType.SAMPLE;
37+
return "sample" as ServiceType.SAMPLE;
3838
}
3939

4040
private static isInitialized = false;

packages/_examples/plugin/src/services/sampleService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class SampleService extends Service {
2323
private readonly DEFAULT_INTERVAL = 15 * 60 * 1000; // 15 minutes in milliseconds
2424

2525
static get serviceType(): ServiceType {
26-
return ServiceType.SAMPLE;
26+
return "sample" as ServiceType.SAMPLE;
2727
}
2828

2929
private static isInitialized = false;

packages/plugin-di/src/actions/baseInjectableAction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export abstract class BaseInjectableAction<T> implements InjectableAction<T> {
4747
/**
4848
* Constructor for the base injectable action
4949
*/
50-
constructor(opts: ActionOptions<T>) {
50+
constructor(@unmanaged() opts: ActionOptions<T>) {
5151
// Set the action properties
5252
this.name = opts.name;
5353
this.similes = opts.similes;

packages/plugin-di/src/evaluators/baseInjectableEvaluator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class BaseInjectableEvaluator implements InjectableEvaluator {
2323
/**
2424
* Constructor for the base injectable action
2525
*/
26-
constructor(opts: EvaluatorOptions) {
26+
constructor(@unmanaged() opts: EvaluatorOptions) {
2727
// Set the action properties
2828
this.name = opts.name;
2929
this.similes = opts.similes;

0 commit comments

Comments
 (0)