Skip to content

Commit 7112627

Browse files
CoveMBericglau
andauthored
Add format command and CI (#509)
Co-authored-by: Eric Lau <[email protected]>
1 parent 1f8e90e commit 7112627

File tree

81 files changed

+1573
-1370
lines changed

Some content is hidden

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

81 files changed

+1573
-1370
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request: {}
77

88
jobs:
9-
lint:
9+
format-lint:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
@@ -16,6 +16,8 @@ jobs:
1616
cache: 'yarn'
1717
- name: Install dependencies
1818
run: yarn install --network-concurrency 1
19+
- name: Check formatting
20+
run: yarn format:check
1921
- name: Run linter
2022
run: yarn lint
2123

.prettierignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.json
2+
*.md
3+
*.map
4+
*.snap
5+
*.lock
6+
*.png
7+
*.sol
8+
*.toml
9+
*tgz
10+
*.tsbuildinfo
11+
**/.*
12+
**/LICENSE
13+
**/NOTICE
14+
build/
15+
public/

.prettierrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
2+
"plugins": [
3+
"prettier-plugin-svelte"
4+
],
25
"singleQuote": true,
36
"arrowParens": "avoid",
47
"trailingComma": "all",
58
"printWidth": 120,
69
"bracketSpacing": true
7-
}
10+
}

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ From the root directory:
4040

4141
If linting errors or warnings occur, run `yarn lint --fix` to attempt to auto-fix issues. If there are remaining issues that cannot be auto-fixed, manually address them and re-run the command to ensure it passes.
4242

43+
### Running formater
44+
From the root directory:
45+
- ```yarn format:{check|write}```
46+
47+
If formatting errors or warnings occurs when running `yarn format:check`, run `yarn format:write` to attempt to auto-fix issues.
48+
It is recommended to use automatic formatter in your code editor or run this command before making your merge request as formatting error will fail CI.
49+
4350
### Running the UI
4451
From the `packages/ui` directory:
4552
- Run `yarn dev` to start a local server for the UI.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"scripts": {
55
"prepare": "wsrun -m prepare",
66
"lint": "eslint",
7+
"format:write": "prettier --write \"**/*\"",
8+
"format:check": "prettier --check \"**/*\"",
79
"dev:ui": "yarn --cwd ./packages/ui dev",
810
"dev:api": "yarn --cwd ./packages/ui dev:api",
911
"dev": "concurrently --kill-others-on-fail --names \"ui,api\" --prefix-colors \"magenta.bold,green.bold\" \"yarn dev:ui\" \"yarn dev:api\"",
@@ -23,12 +25,13 @@
2325
"@eslint/js": "^9.21.0",
2426
"concurrently": "^9.1.2",
2527
"eslint": "^9.21.0",
26-
"eslint-config-prettier": "^10.0.1",
27-
"eslint-plugin-prettier": "^5.2.3",
28+
"eslint-config-prettier": "^10.1.1",
29+
"eslint-plugin-prettier": "^5.2.6",
2830
"eslint-plugin-unicorn": "^58.0.0",
29-
"prettier": "^3.5.1",
31+
"prettier": "^3.5.3",
32+
"prettier-plugin-svelte": "^3.3.3",
3033
"typescript": "^5.7.3",
31-
"typescript-eslint": "^8.24.1",
34+
"typescript-eslint": "^8.29.0",
3235
"wsrun": "^5.2.4"
3336
}
3437
}

packages/ui/src/cairo/AccessControlSection.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@
3434
defaultValue="ownable"
3535
helpContent="Restrict who can access the functions of a contract or when they can do it."
3636
helpLink="https://docs.openzeppelin.com/contracts-cairo/access"
37-
required={required}
37+
{required}
3838
>
3939
<div class="checkbox-group">
4040
<label class:checked={access === 'ownable'}>
41-
<input type="radio" bind:group={access} value="ownable">
41+
<input type="radio" bind:group={access} value="ownable" />
4242
Ownable
4343
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/access#ownership_and_ownable">
4444
Simple mechanism with a single account authorized for all privileged actions.
4545
</HelpTooltip>
4646
</label>
4747
<label class:checked={access === 'roles'}>
48-
<input type="radio" bind:group={access} value="roles">
48+
<input type="radio" bind:group={access} value="roles" />
4949
Roles
5050
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/access#role_based_accesscontrol">
5151
Flexible mechanism with a separate role for each privileged action. A role can have many authorized accounts.
5252
</HelpTooltip>
5353
</label>
5454
</div>
55-
</ExpandableToggleRadio>
55+
</ExpandableToggleRadio>

packages/ui/src/cairo/AccountControls.svelte

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,28 @@
1616
export let accountType: Account | undefined;
1717
</script>
1818

19-
2019
<section class="controls-section">
2120
<h1>Settings</h1>
2221

2322
<label class="labeled-input">
2423
<span>Name</span>
25-
<input bind:value={opts.name} use:error={errors?.name}>
24+
<input bind:value={opts.name} use:error={errors?.name} />
2625
</label>
2726
</section>
2827

2928
<section class="controls-section">
3029
<h1>Account Type</h1>
3130
<div class="checkbox-group">
3231
<label class:checked={accountType === 'stark'}>
33-
<input type="radio" bind:group={opts.type} value="stark">
32+
<input type="radio" bind:group={opts.type} value="stark" />
3433
Starknet
3534
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/accounts#starknet_account">
3635
Starknet account that uses the STARK curve for signature checking.
3736
</HelpTooltip>
3837
</label>
3938

4039
<label class:checked={accountType === 'eth'}>
41-
<input type="radio" bind:group={opts.type} value="eth">
40+
<input type="radio" bind:group={opts.type} value="eth" />
4241
Ethereum
4342
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/accounts#ethereum_account">
4443
Ethereum-flavored account that uses the Secp256k1 curve for signature checking.
@@ -52,35 +51,33 @@
5251

5352
<div class="checkbox-group">
5453
<label class:checked={opts.outsideExecution}>
55-
<input type="checkbox" bind:checked={opts.outsideExecution}>
54+
<input type="checkbox" bind:checked={opts.outsideExecution} />
5655
Outside Execution
5756
<HelpTooltip link="https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-9.md">
5857
Allows a protocol to submit transactions on behalf of the account, as long as it has the relevant signatures.
5958
</HelpTooltip>
6059
</label>
6160

6261
<label class:checked={opts.declare}>
63-
<input type="checkbox" bind:checked={opts.declare}>
62+
<input type="checkbox" bind:checked={opts.declare} />
6463
Declarer
6564
<HelpTooltip link="https://docs.starknet.io/architecture-and-concepts/smart-contracts/contract-classes/">
6665
Enables the account to declare other contract classes.
6766
</HelpTooltip>
6867
</label>
6968

7069
<label class:checked={opts.deploy}>
71-
<input type="checkbox" bind:checked={opts.deploy}>
70+
<input type="checkbox" bind:checked={opts.deploy} />
7271
Deployable
7372
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/accounts#deploying_an_account">
7473
Enables the account to be counterfactually deployed.
7574
</HelpTooltip>
7675
</label>
7776

7877
<label class:checked={opts.pubkey}>
79-
<input type="checkbox" bind:checked={opts.pubkey}>
78+
<input type="checkbox" bind:checked={opts.pubkey} />
8079
Public Key
81-
<HelpTooltip>
82-
Enables the account to change its own public key.
83-
</HelpTooltip>
80+
<HelpTooltip>Enables the account to change its own public key.</HelpTooltip>
8481
</label>
8582
<UpgradeabilityField bind:upgradeable={opts.upgradeable} />
8683
</div>

0 commit comments

Comments
 (0)