Skip to content

Commit b72e4a5

Browse files
committed
Fix: 'biome check' now passes. Fix all lint errors.
- Biome is the existing TS formatter / linter, however it was failing. - Upgrade to Biome V2, run biome on GitHub Actions (it's already used in a precommit hook) - Add a biome config file to match what most of the existing code uses, plus Anchor defaults - Add missing Tailwind options to check CSS files with Tailwind directives - Skip some of the 'any' tests in Anchor TS files - these will be moved to LiteSVM
1 parent 646891b commit b72e4a5

410 files changed

Lines changed: 9139 additions & 8855 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/anchor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
branches:
88
- main
99
- anchor-1.0
10+
- fix-biome-errors
1011
pull_request:
1112
types: [opened, synchronize, reopened]
1213
branches:

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
branches:
1111
- main
1212
- anchor-1.0
13+
- fix-biome-errors
1314
pull_request:
1415
types: [opened, synchronize, reopened]
1516
branches:

.github/workflows/solana-native.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
- fix-biome-errors
910
pull_request:
1011
types: [opened, synchronize, reopened]
1112
branches:

.github/workflows/solana-pinocchio.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
- fix-biome-errors
910
pull_request:
1011
types: [opened, synchronize, reopened]
1112
branches:

.github/workflows/typescript.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: TypeScript
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- fix-biome-errors
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
branches:
11+
- main
12+
13+
env:
14+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
15+
16+
jobs:
17+
biome:
18+
name: Biome check
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
- uses: pnpm/action-setup@v4
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: pnpm
27+
# --frozen-lockfile: fail if pnpm-lock.yaml is out of date
28+
# --ignore-workspace: only install root deps, not all 94 subprojects
29+
- run: pnpm install --frozen-lockfile --ignore-workspace
30+
- run: pnpm run check

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"editor.defaultFormatter": "biomejs.biome",
3-
"editor.formatOnSave": true
2+
"editor.defaultFormatter": "biomejs.biome",
3+
"editor.formatOnSave": true
44
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"dependencies": {
3-
"@anchor-lang/core": "1.0.0-rc.5",
4-
"@solana/web3.js": "^1.98.4"
5-
},
6-
"devDependencies": {
7-
"@types/bn.js": "^5.1.0",
8-
"@types/chai": "^4.3.0",
9-
"@types/mocha": "^9.0.0",
10-
"chai": "^4.3.4",
11-
"litesvm": "^0.3.3",
12-
"mocha": "^9.0.3",
13-
"ts-mocha": "^10.0.0",
14-
"typescript": "^5.3.3"
15-
},
16-
"type": "module"
2+
"dependencies": {
3+
"@anchor-lang/core": "1.0.0-rc.5",
4+
"@solana/web3.js": "^1.98.4"
5+
},
6+
"devDependencies": {
7+
"@types/bn.js": "^5.1.0",
8+
"@types/chai": "^4.3.0",
9+
"@types/mocha": "^9.0.0",
10+
"chai": "^4.3.4",
11+
"litesvm": "^0.3.3",
12+
"mocha": "^9.0.3",
13+
"ts-mocha": "^10.0.0",
14+
"typescript": "^5.3.3"
15+
},
16+
"type": "module"
1717
}
Lines changed: 79 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,96 @@
11
import { BorshCoder } from "@anchor-lang/core";
2-
import {
3-
Keypair,
4-
PublicKey,
5-
SystemProgram,
6-
Transaction,
7-
TransactionInstruction,
8-
} from "@solana/web3.js";
2+
import { Keypair, PublicKey, SystemProgram, Transaction, TransactionInstruction } from "@solana/web3.js";
93
import { LiteSVM } from "litesvm";
104

11-
import IDL from "../target/idl/account_data_anchor_program.json" with {
12-
type: "json",
13-
};
5+
import IDL from "../target/idl/account_data_anchor_program.json" with { type: "json" };
146

157
describe("Account Data!", () => {
16-
let litesvm: LiteSVM;
17-
let programId: PublicKey;
18-
let payer: Keypair;
19-
let addressInfoAccount: Keypair;
20-
const coder = new BorshCoder(IDL);
8+
let litesvm: LiteSVM;
9+
let programId: PublicKey;
10+
let payer: Keypair;
11+
let addressInfoAccount: Keypair;
12+
const coder = new BorshCoder(IDL);
2113

22-
before(() => {
23-
litesvm = new LiteSVM();
24-
programId = new PublicKey(IDL.address);
25-
payer = Keypair.generate();
26-
addressInfoAccount = Keypair.generate();
14+
before(() => {
15+
litesvm = new LiteSVM();
16+
programId = new PublicKey(IDL.address);
17+
payer = Keypair.generate();
18+
addressInfoAccount = Keypair.generate();
2719

28-
const programPath = new URL(
29-
"../target/deploy/account_data_anchor_program.so",
30-
// @ts-ignore
31-
import.meta.url,
32-
).pathname;
33-
litesvm.addProgramFromFile(programId, programPath);
20+
const programPath = new URL(
21+
"../target/deploy/account_data_anchor_program.so",
22+
// @ts-expect-error
23+
import.meta.url,
24+
).pathname;
25+
litesvm.addProgramFromFile(programId, programPath);
3426

35-
litesvm.airdrop(payer.publicKey, BigInt(100000000000));
36-
});
27+
litesvm.airdrop(payer.publicKey, BigInt(100000000000));
28+
});
3729

38-
it("Create the address info account", () => {
39-
console.log(`Payer Address : ${payer.publicKey}`);
40-
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
30+
it("Create the address info account", () => {
31+
console.log(`Payer Address : ${payer.publicKey}`);
32+
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
4133

42-
// Instruction Ix data
43-
const addressInfoIns = {
44-
name: "Joe C",
45-
house_number: 136,
46-
street: "Mile High Dr.",
47-
city: "Solana Beach",
48-
};
34+
// Instruction Ix data
35+
const addressInfoIns = {
36+
name: "Joe C",
37+
house_number: 136,
38+
street: "Mile High Dr.",
39+
city: "Solana Beach",
40+
};
4941

50-
/**
51-
* Convert into buffer and encode of instruction and arguments
52-
*/
53-
const data = coder.instruction.encode(
54-
"create_address_info",
55-
addressInfoIns,
56-
);
42+
/**
43+
* Convert into buffer and encode of instruction and arguments
44+
*/
45+
const data = coder.instruction.encode("create_address_info", addressInfoIns);
5746

58-
/**
59-
* Create Transactions
60-
*/
47+
/**
48+
* Create Transactions
49+
*/
6150

62-
const ix = new TransactionInstruction({
63-
keys: [
64-
{
65-
pubkey: payer.publicKey,
66-
isSigner: true,
67-
isWritable: true,
68-
},
69-
{
70-
pubkey: addressInfoAccount.publicKey,
71-
isSigner: true,
72-
isWritable: true,
73-
},
74-
{
75-
pubkey: SystemProgram.programId,
76-
isSigner: false,
77-
isWritable: false,
78-
},
79-
],
80-
programId,
81-
data,
82-
});
51+
const ix = new TransactionInstruction({
52+
keys: [
53+
{
54+
pubkey: payer.publicKey,
55+
isSigner: true,
56+
isWritable: true,
57+
},
58+
{
59+
pubkey: addressInfoAccount.publicKey,
60+
isSigner: true,
61+
isWritable: true,
62+
},
63+
{
64+
pubkey: SystemProgram.programId,
65+
isSigner: false,
66+
isWritable: false,
67+
},
68+
],
69+
programId,
70+
data,
71+
});
8372

84-
const tx = new Transaction().add(ix);
85-
tx.feePayer = payer.publicKey;
86-
tx.recentBlockhash = litesvm.latestBlockhash();
87-
tx.sign(payer, addressInfoAccount);
88-
const res = litesvm.sendTransaction(tx);
89-
// console.log(res.toString());
90-
});
91-
it("Read the new account's data", () => {
92-
const accountInfoAcc = litesvm.getAccount(addressInfoAccount.publicKey);
93-
if (!accountInfoAcc) {
94-
throw new Error("Failed to fetch account info");
95-
}
73+
const tx = new Transaction().add(ix);
74+
tx.feePayer = payer.publicKey;
75+
tx.recentBlockhash = litesvm.latestBlockhash();
76+
tx.sign(payer, addressInfoAccount);
77+
const _res = litesvm.sendTransaction(tx);
78+
// console.log(res.toString());
79+
});
80+
it("Read the new account's data", () => {
81+
const accountInfoAcc = litesvm.getAccount(addressInfoAccount.publicKey);
82+
if (!accountInfoAcc) {
83+
throw new Error("Failed to fetch account info");
84+
}
9685

97-
/**
98-
* Decode the accounts' data
99-
*/
100-
const addressInfo = coder.accounts.decode(
101-
"AddressInfo",
102-
Buffer.from(accountInfoAcc.data),
103-
);
86+
/**
87+
* Decode the accounts' data
88+
*/
89+
const addressInfo = coder.accounts.decode("AddressInfo", Buffer.from(accountInfoAcc.data));
10490

105-
console.log(`Name : ${addressInfo.name}`);
106-
console.log(`House Num: ${addressInfo.house_number}`);
107-
console.log(`Street : ${addressInfo.street}`);
108-
console.log(`City : ${addressInfo.city}`);
109-
});
91+
console.log(`Name : ${addressInfo.name}`);
92+
console.log(`House Num: ${addressInfo.house_number}`);
93+
console.log(`Street : ${addressInfo.street}`);
94+
console.log(`City : ${addressInfo.city}`);
95+
});
11096
});

basics/account-data/anchor/tests/test.ts

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,41 @@ import { Keypair } from "@solana/web3.js";
33
import type { AccountDataAnchorProgram } from "../target/types/account_data_anchor_program";
44

55
describe("Account Data!", () => {
6-
const provider = anchor.AnchorProvider.env();
7-
anchor.setProvider(provider);
8-
const payer = provider.wallet as anchor.Wallet;
9-
const program = anchor.workspace
10-
.AccountDataAnchorProgram as anchor.Program<AccountDataAnchorProgram>;
6+
const provider = anchor.AnchorProvider.env();
7+
anchor.setProvider(provider);
8+
const payer = provider.wallet as anchor.Wallet;
9+
const program = anchor.workspace.AccountDataAnchorProgram as anchor.Program<AccountDataAnchorProgram>;
1110

12-
// Generate a new keypair for the addressInfo account
13-
const addressInfoAccount = new Keypair();
11+
// Generate a new keypair for the addressInfo account
12+
const addressInfoAccount = new Keypair();
1413

15-
it("Create the address info account", async () => {
16-
console.log(`Payer Address : ${payer.publicKey}`);
17-
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
14+
it("Create the address info account", async () => {
15+
console.log(`Payer Address : ${payer.publicKey}`);
16+
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
1817

19-
// Instruction Ix data
20-
const addressInfo = {
21-
name: "Joe C",
22-
houseNumber: 136,
23-
street: "Mile High Dr.",
24-
city: "Solana Beach",
25-
};
18+
// Instruction Ix data
19+
const addressInfo = {
20+
name: "Joe C",
21+
houseNumber: 136,
22+
street: "Mile High Dr.",
23+
city: "Solana Beach",
24+
};
2625

27-
await program.methods
28-
.createAddressInfo(
29-
addressInfo.name,
30-
addressInfo.houseNumber,
31-
addressInfo.street,
32-
addressInfo.city,
33-
)
34-
.accounts({
35-
addressInfo: addressInfoAccount.publicKey,
36-
payer: payer.publicKey,
37-
})
38-
.signers([addressInfoAccount])
39-
.rpc();
40-
});
26+
await program.methods
27+
.createAddressInfo(addressInfo.name, addressInfo.houseNumber, addressInfo.street, addressInfo.city)
28+
.accounts({
29+
addressInfo: addressInfoAccount.publicKey,
30+
payer: payer.publicKey,
31+
})
32+
.signers([addressInfoAccount])
33+
.rpc();
34+
});
4135

42-
it("Read the new account's data", async () => {
43-
const addressInfo = await program.account.addressInfo.fetch(
44-
addressInfoAccount.publicKey,
45-
);
46-
console.log(`Name : ${addressInfo.name}`);
47-
console.log(`House Num: ${addressInfo.houseNumber}`);
48-
console.log(`Street : ${addressInfo.street}`);
49-
console.log(`City : ${addressInfo.city}`);
50-
});
36+
it("Read the new account's data", async () => {
37+
const addressInfo = await program.account.addressInfo.fetch(addressInfoAccount.publicKey);
38+
console.log(`Name : ${addressInfo.name}`);
39+
console.log(`House Num: ${addressInfo.houseNumber}`);
40+
console.log(`Street : ${addressInfo.street}`);
41+
console.log(`City : ${addressInfo.city}`);
42+
});
5143
});

0 commit comments

Comments
 (0)