Skip to content

Commit

Permalink
Enable recomended rule performance/noDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Oct 11, 2024
1 parent 91f6054 commit 6cc060b
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 14 deletions.
4 changes: 1 addition & 3 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
"useArrayLiterals": "error",
"noUndeclaredVariables": "error"
},
"performance": {
"noDelete": "off"
},
"performance": {},
"style": {
"noCommaOperator": "off",
"noInferrableTypes": "off",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/utils/checkAgainstSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function validateSchema(schema: Parameters<typeof ajv.compile>[0], json: unknown
if (!valid) {
// Remove descriptions, for better clarity in rendering on errors
applyRecursively(schema, (obj) => {
delete obj.description;
obj.description = undefined;
});

throw Error(
Expand Down
4 changes: 2 additions & 2 deletions packages/api/test/utils/parseOpenApiSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ function preprocessSchema(schema: JsonSchema): void {

// Remove nullable
applyRecursively(schema, (obj) => {
delete obj.nullable;
obj.nullable = undefined;
});

// Remove required: false
applyRecursively(schema, (obj) => {
if (typeof obj.required === "boolean") {
delete obj.required;
obj.required = undefined;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("ExecutionEngine / http", () => {
return [];
}
reqJsonRpcPayload = req.body;
delete (reqJsonRpcPayload as {id?: number}).id;
(reqJsonRpcPayload as {id?: number}).id = undefined;
return returnValue;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("ExecutionEngine / http ", () => {
server.post("/", async (req) => {
if (errorResponsesBeforeSuccess === 0) {
reqJsonRpcPayload = req.body;
delete (reqJsonRpcPayload as {id?: number}).id;
(reqJsonRpcPayload as {id?: number}).id = undefined;
return returnValue;
} else {
--errorResponsesBeforeSuccess;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmds/beacon/initPeerIdAndEnr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function overwriteEnrWithCliArgs(
enr.seq = preSeq + BigInt(1);
}
// invalidate cached signature
delete enr["_signature"];
enr["_signature"] = undefined;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/params/test/e2e/overridePreset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Override preset", function () {

it("Should correctly override preset", async () => {
// `LODESTAR_PRESET` must not be set to properly test preset override
if (process.env.LODESTAR_PRESET) delete process.env.LODESTAR_PRESET;
if (process.env.LODESTAR_PRESET) process.env.LODESTAR_PRESET = undefined;

await exec(`node --loader ts-node/esm ${path.join(__dirname, scriptNames.ok)}`);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/params/test/e2e/setPreset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("setPreset", function () {

it("Should correctly set preset", async () => {
// `LODESTAR_PRESET` must not be set to properly test setting preset
if (process.env.LODESTAR_PRESET) delete process.env.LODESTAR_PRESET;
if (process.env.LODESTAR_PRESET) process.env.LODESTAR_PRESET = undefined;

await exec(`node --loader ts-node/esm ${path.join(__dirname, scriptNames.ok)}`);
});
Expand Down
1 change: 1 addition & 0 deletions packages/prover/test/unit/utils/execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const validAccountProof = eoaProof.dependentRequests[0].response.result as unkno
const validStateRoot = hexToBuffer(eoaProof.beacon.executionPayload.state_root);

const invalidAccountProof = deepmerge(validAccountProof, {});
// biome-ignore lint/performance/noDelete: Can not delete index with undefined assignment
delete invalidAccountProof.accountProof[0];

describe("uitls/execution", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe("verified_requests / eth_getBalance", () => {
it("should return the json-rpc response with error for an invalid account", async () => {
const data = cloneTestFixture(testCase);
// Temporarily remove the accountProof to make the request invalid
// biome-ignore lint/performance/noDelete: Can not delete index with undefined assignment
delete data.dependentRequests[0].response.result.accountProof[0];
const config = createForkConfig(networksChainConfig[data.network as NetworkName]);
const options = generateReqHandlerOptionsMock(data, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe("verified_requests / eth_getTransactionCount", () => {

it("should return the json-rpc response with error for an invalid account", async () => {
const testCase = cloneTestFixture(t);
// biome-ignore lint/performance/noDelete: Can not delete index with undefined assignment
delete testCase.dependentRequests[0].response.result.accountProof[0];

const config = createForkConfig(networksChainConfig[testCase.network as NetworkName]);
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/util/blindedBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function signedBlindedBlockToFull(

// state transition can't seem to handle executionPayloadHeader presense in merge block
// so just delete the extra field we don't require
delete (signedBlock.message.body as {executionPayloadHeader?: ExecutionPayloadHeader}).executionPayloadHeader;
(signedBlock.message.body as {executionPayloadHeader?: ExecutionPayloadHeader}).executionPayloadHeader = undefined;
return signedBlock;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/validator/src/services/validatorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class ValidatorStore {
throw Error(`Validator pubkey ${pubkeyHex} not known`);
}
// This should directly modify data in the map
delete validatorData["feeRecipient"];
validatorData["feeRecipient"] = undefined;
}

getGraffiti(pubkeyHex: PubkeyHex): string | undefined {
Expand All @@ -267,7 +267,7 @@ export class ValidatorStore {
if (validatorData === undefined) {
throw Error(`Validator pubkey ${pubkeyHex} not known`);
}
delete validatorData["graffiti"];
validatorData["graffiti"] = undefined;
}

getBuilderSelectionParams(pubkeyHex: PubkeyHex): {selection: routes.validator.BuilderSelection; boostFactor: bigint} {
Expand Down Expand Up @@ -327,6 +327,7 @@ export class ValidatorStore {
if (validatorData === undefined) {
throw Error(`Validator pubkey ${pubkeyHex} not known`);
}
// biome-ignore lint/performance/noDelete: Can not delete property with undefined assignment
delete validatorData.builder?.gasLimit;
}

Expand Down Expand Up @@ -355,6 +356,7 @@ export class ValidatorStore {
if (validatorData === undefined) {
throw Error(`Validator pubkey ${pubkeyHex} not known`);
}
// biome-ignore lint/performance/noDelete: Can not delete property with undefined assignment>
delete validatorData.builder?.boostFactor;
}

Expand Down
1 change: 1 addition & 0 deletions packages/validator/test/unit/utils/params.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe("utils / params / assertEqualParams", () => {

it("should fill missing remote values with default and be equal", () => {
const chainConfigJson = chainConfigToJson(chainConfig);
// biome-ignore lint/performance/noDelete: Can not delete property with undefined assignment
delete chainConfigJson["DEPOSIT_CONTRACT_ADDRESS"];
assertEqualParams(chainConfig, chainConfigJson);
});
Expand Down

0 comments on commit 6cc060b

Please sign in to comment.