Skip to content

Commit

Permalink
Fix all the biome errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemaccana committed Jun 12, 2024
1 parent dc25914 commit 333260c
Show file tree
Hide file tree
Showing 27 changed files with 215 additions and 97 deletions.
51 changes: 31 additions & 20 deletions basics/account-data/native/tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { Buffer } from 'node:buffer';
import { describe, test } from 'node:test';
import { Keypair, PublicKey, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js';
import * as borsh from 'borsh';
import { start } from 'solana-bankrun';
import { Buffer } from "node:buffer";
import { describe, test } from "node:test";
import {
Keypair,
PublicKey,
SystemProgram,
Transaction,
TransactionInstruction,
} from "@solana/web3.js";
import * as borsh from "borsh";
import { start } from "solana-bankrun";

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand All @@ -29,24 +35,27 @@ const AddressInfoSchema = new Map([
[
AddressInfo,
{
kind: 'struct',
kind: "struct",
fields: [
['name', 'string'],
['house_number', 'u8'],
['street', 'string'],
['city', 'string'],
["name", "string"],
["house_number", "u8"],
["street", "string"],
["city", "string"],
],
},
],
]);

describe('Account Data!', async () => {
describe("Account Data!", async () => {
const addressInfoAccount = Keypair.generate();
const PROGRAM_ID = PublicKey.unique();
const context = await start([{ name: 'account_data_program', programId: PROGRAM_ID }], []);
const context = await start(
[{ name: "account_data_program", programId: PROGRAM_ID }],
[]
);
const client = context.banksClient;

test('Create the address info account', async () => {
test("Create the address info account", async () => {
const payer = context.payer;

console.log(`Program Address : ${PROGRAM_ID}`);
Expand All @@ -65,10 +74,10 @@ describe('Account Data!', async () => {
],
programId: PROGRAM_ID,
data: new AddressInfo({
name: 'Joe C',
name: "Joe C",
house_number: 136,
street: 'Mile High Dr.',
city: 'Solana Beach',
street: "Mile High Dr.",
city: "Solana Beach",
}).toBuffer(),
});

Expand All @@ -83,7 +92,9 @@ describe('Account Data!', async () => {
test("Read the new account's data", async () => {
const accountInfo = await client.getAccount(addressInfoAccount.publicKey);

const readAddressInfo = AddressInfo.fromBuffer(Buffer.from(accountInfo.data));
const readAddressInfo = AddressInfo.fromBuffer(
Buffer.from(accountInfo.data)
);
console.log(`Name : ${readAddressInfo.name}`);
console.log(`House Num: ${readAddressInfo.house_number}`);
console.log(`Street : ${readAddressInfo.street}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { PROGRAM_ID } from '../';
export type IncrementInstructionAccounts = {
counter: PublicKey;
};
export type IncrementInstructionArgs = {};

export function createIncrementInstruction(accounts: IncrementInstructionAccounts, args: IncrementInstructionArgs): TransactionInstruction {
export function createIncrementInstruction(
accounts: IncrementInstructionAccounts
): TransactionInstruction {
return new TransactionInstruction({
programId: PROGRAM_ID,
keys: [
Expand Down
2 changes: 1 addition & 1 deletion basics/create-account/anchor/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Create a system account', () => {

// Check that the account was created
const accountInfo = await connection.getAccountInfo(newKeypair.publicKey);
assert((accountInfo.owner = SystemProgram.programId));
assert(accountInfo.owner === SystemProgram.programId);
assert(accountInfo.lamports === lamports);
});
});
6 changes: 3 additions & 3 deletions basics/cross-program-invocation/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('CPI Example', () => {

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions basics/favorites/anchor/favorites/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SECRET_KEY="[
128, 166, 168, 193, 245, 44, 59, 104, 191, 31,
234, 44, 94, 240, 73, 226, 167, 218, 120, 123,
100, 217, 143, 131, 240, 117, 3, 133, 104, 97,
221, 192, 63, 247, 49, 204, 178, 219, 103, 184,
240, 179, 100, 205, 229, 87, 193, 135, 159, 117,
114, 238, 250, 53, 147, 116, 130, 199, 143, 120,
62, 15, 23, 15
]"
MINT_ACCOUNT=[12,30,154,17,31,70,145,100,167,126,88,76,254,107,186,122,219,36,215,214,217,160,183,84,215,35,56,161,192,39,160,112,243,82,181,22,133,180,38,99,209,98,105,87,51,115,31,180,29,64,36,237,175,202,124,200,38,110,27,63,103,215,1,189]
6 changes: 3 additions & 3 deletions basics/pda-rent-payer/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('PDA Rent-Payer', async () => {

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions basics/processing-instructions/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('custom-instruction-data', async () => {

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions basics/program-derived-addresses/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('PDAs', async () => {

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions basics/rent/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('Create a system account', async () => {

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions basics/repository-layout/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('Carnival', async () => {

class Assignable {
constructor(properties) {
Object.keys(properties).map((key) => {
return (this[key] = properties[key]);
});
for (const [key, value] of Object.entries(properties)) {
this[key] = value;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
Expand Down
2 changes: 1 addition & 1 deletion compression/cnft-burn/anchor/tests/cnft-burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getAsset, getAssetProof } from './readApi';
import { decode, mapProof } from './utils';

// Replace this with your custom RPC endpoint that supports cNFT indexing
export const RPC_PATH = 'https://api.devnet.solana.com';
const RPC_PATH = 'https://api.devnet.solana.com';

describe('cnft-burn', () => {
// Configure the client to use the local cluster.
Expand Down
12 changes: 7 additions & 5 deletions compression/cnft-burn/anchor/tests/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const DEFAULT_DEMO_DATA_FILE = 'demo.json';

/*
Load locally stored PublicKey addresses
TODO: use the helpers library and delete this function
*/
export function loadPublicKeysFromFile(absPath = `${DEFAULT_KEY_DIR_NAME}/${DEFAULT_PUBLIC_KEY_FILE}`) {
try {
Expand All @@ -25,7 +26,7 @@ export function loadPublicKeysFromFile(absPath = `${DEFAULT_KEY_DIR_NAME}/${DEFA

return data;
} catch (err) {
// console.warn("Unable to load local file");
console.warn("Unable to load local file");
}
// always return an object
return {};
Expand All @@ -51,7 +52,7 @@ export function saveDemoDataToFile(name: string, newData: any, absPath = `${DEFA
return data;
} catch (err) {
console.warn('Unable to save to file');
// console.warn(err);
console.warn(err);
}

// always return an object
Expand Down Expand Up @@ -105,16 +106,17 @@ export function loadKeypairFromFile(absPath: string) {
const keypair = Keypair.fromSecretKey(new Uint8Array(keyfileBytes));
return keypair;
} catch (err) {
// return false;
console.error('loadKeypairFromFile:', err);
throw err;
}
}

/*
Save a locally stored JSON keypair file for later importing
TODO: delete this function and use the helpers library
*/
export function saveKeypairToFile(keypair: Keypair, fileName: string, dirName: string = DEFAULT_KEY_DIR_NAME) {
fileName = path.join(dirName, `${fileName}.json`);
export function saveKeypairToFile(keypair: Keypair, relativeFileName: string, dirName: string = DEFAULT_KEY_DIR_NAME) {
const fileName = path.join(dirName, `${relativeFileName}.json`);

// create the `dirName` directory, if it does not exists
if (!fs.existsSync(`./${dirName}/`)) fs.mkdirSync(`./${dirName}/`);
Expand Down
7 changes: 4 additions & 3 deletions compression/cutils/anchor/tests/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,17 @@ export function loadKeypairFromFile(absPath: string) {
const keypair = Keypair.fromSecretKey(new Uint8Array(keyfileBytes));
return keypair;
} catch (err) {
// return false;
console.error('loadKeypairFromFile:', err);
throw err;
}
}

/*
Save a locally stored JSON keypair file for later importing
TODO: delete this function and use the helpers library
*/
export function saveKeypairToFile(keypair: Keypair, fileName: string, dirName: string = DEFAULT_KEY_DIR_NAME) {
fileName = path.join(dirName, `${fileName}.json`);
export function saveKeypairToFile(keypair: Keypair, relativeFileName: string, dirName: string = DEFAULT_KEY_DIR_NAME) {
const fileName = path.join(dirName, `${relativeFileName}.json`);

// create the `dirName` directory, if it does not exists
if (!fs.existsSync(`./${dirName}/`)) fs.mkdirSync(`./${dirName}/`);
Expand Down
92 changes: 92 additions & 0 deletions deleteme.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

> [email protected] lint
> pnpx @biomejs/biome lint ./

Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +2
++
Progress: resolved 9, reused 2, downloaded 0, added 2, done
./basics/rent/native/tests/test.ts:16:17 lint/suspicious/noAssignInExpressions ━━━━━━━━━━━━━━━━━━━━━

! The assignment should not be in an expression.

14 │ constructor(properties) {
15 │ Object.keys(properties).map((key) => {
> 16 │ return (this[key] = properties[key]);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
17 │ });
18 │ }

i The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.


./basics/program-derived-addresses/native/tests/test.ts:17:17 lint/suspicious/noAssignInExpressions ━━━━━━━━━━

! The assignment should not be in an expression.

15 │ constructor(properties) {
16 │ Object.keys(properties).map((key) => {
> 17 │ return (this[key] = properties[key]);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 │ });
19 │ }

i The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.


./basics/repository-layout/native/tests/test.ts:16:17 lint/suspicious/noAssignInExpressions ━━━━━━━━━━

! The assignment should not be in an expression.

14 │ constructor(properties) {
15 │ Object.keys(properties).map((key) => {
> 16 │ return (this[key] = properties[key]);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
17 │ });
18 │ }

i The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.


./basics/counter/native/ts/instructions/createIncrementInstruction.ts:7:40 lint/complexity/noBannedTypes ━━━━━━━━━━

! Don't use '{}' as a type.

5 │ counter: PublicKey;
6 │ };
> 7 │ export type IncrementInstructionArgs = {};
│ ^^
8 │
9 │ export function createIncrementInstruction(accounts: IncrementInstructionAccounts, args: IncrementInstructionArgs): TransactionInstruction {

i Prefer explicitly define the object shape. '{}' means "any non-nullable value".


./tokens/token-2022/nft-meta-data-pointer/anchor-example/app/utils/wrappedConnection.ts:128:9 lint/style/noParameterAssign ━━━━━━━━━━

! Reassigning a function parameter is confusing.

126 │ console.log(`Requested page${page}`);
127 │
> 128 │ page += 1;
│ ^^^^
129 │ response = await axios.post(process.env.NEXT_PUBLIC_RPC ? process.env.NEXT_PUBLIC_RPC : METAPLEX_READAPI, {
130 │ jsonrpc: '2.0',

i The parameter is declared here:

108 │ sortBy: any,
109 │ limit: number,
> 110 │ page: number,
│ ^^^^^^^^^^^^
111 │ before: string,
112 │ after: string,

i Use a local variable instead.


Checked 7251 files in 409ms. No fixes needed.
Found 5 warnings.
Loading

0 comments on commit 333260c

Please sign in to comment.