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 217a90c
Show file tree
Hide file tree
Showing 27 changed files with 187 additions and 80 deletions.
6 changes: 3 additions & 3 deletions basics/account-data/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ 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 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.
26 changes: 13 additions & 13 deletions scripts/lib/get-recursive-file-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ export function getRecursiveFileList(path: string): string[] {
const files: string[] = [];

const items = readdirSync(path);
items.forEach((item) => {
if (ignore.includes(item)) {
return;
}
// Check out if it's a directory or a file
const isDir = statSync(`${path}/${item}`).isDirectory();
if (isDir) {
// If it's a directory, recursively call the method
files.push(...getRecursiveFileList(`${path}/${item}`));
} else {
// If it's a file, add it to the array of files
files.push(`${path}/${item}`);

for (const item of items) {
if (!ignore.includes(item)) {
// Check out if it's a directory or a file
const isDir = statSync(`${path}/${item}`).isDirectory();
if (isDir) {
// If it's a directory, recursively call the method
files.push(...getRecursiveFileList(`${path}/${item}`));
} else {
// If it's a file, add it to the array of files
files.push(`${path}/${item}`);
}
}
});
}

return files.filter((file) => {
// Remove package.json from the root directory
Expand Down
6 changes: 3 additions & 3 deletions tokens/create-token/native/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function createKeypairFromFile(path: string): Keypair {

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 tokens/nft-minter/native/tests/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as borsh from 'borsh';

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 tokens/pda-mint-authority/native/tests/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as borsh from 'borsh';

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 tokens/spl-token-minter/native/tests/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as borsh from 'borsh';

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
Loading

0 comments on commit 217a90c

Please sign in to comment.