Skip to content

chore: Add prettier check to CI#1303

Merged
tbwebb22 merged 6 commits intomasterfrom
taylor/prettier-ci
Feb 25, 2026
Merged

chore: Add prettier check to CI#1303
tbwebb22 merged 6 commits intomasterfrom
taylor/prettier-ci

Conversation

@tbwebb22
Copy link
Copy Markdown
Contributor

@tbwebb22 tbwebb22 commented Feb 6, 2026

Add prettier format check for Solidity files (contracts/ and script/) to CI, and add yarn format-contracts convenience command. Also fixes the broken glob in lint-fix.

VSCode / Cursor setup - add this to your workspace or user settings.json:

    "[solidity]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.formatOnSave": true
    },

This ensures VS Code uses the project's node_modules/prettier and .prettierrc to format Solidity files on save, matching what CI enforces. If you don't want format-on-save, you can omit that line and just run yarn format-contracts before committing.

Closes ACP-47

Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
@tbwebb22 tbwebb22 changed the title add prettier to ci chore: Add prettier check to CI Feb 6, 2026
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
@linear
Copy link
Copy Markdown

linear Bot commented Feb 6, 2026

@tbwebb22 tbwebb22 marked this pull request as ready for review February 6, 2026 21:31
Copy link
Copy Markdown
Collaborator

@grasphoper grasphoper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few Qs:

  • Is "editor.defaultFormatter": "esbenp.prettier-vscode", referring to the prettier -- the node module, or prettier -- the vs code extension? If the extension, are there any extra settings to change on the extension for it to use node_modules/prettier and .prettierrc, .prettierignore and something like prettier-plugin-solidity? E.g. can it happen that the extension is overriding the prettierrc config?
  • yarn pretty-quick --staged: what prettier path + version is that using?
  • should we perhaps upgrade versions of prettier-plugin-solidity, pretty-quick as a part of this change?

@tbwebb22
Copy link
Copy Markdown
Contributor Author

tbwebb22 commented Feb 9, 2026

  • Is "editor.defaultFormatter": "esbenp.prettier-vscode", referring to the prettier -- the node module, or prettier -- the vs code extension? If the extension, are there any extra settings to change on the extension for it to use node_modules/prettier and .prettierrc, .prettierignore and something like prettier-plugin-solidity? E.g. can it happen that the extension is overriding the prettierrc config?

"editor.defaultFormatter": "esbenp.prettier-vscode" refers to the VSCode extension. It does automatically use node_modules/prettier. It resolves prettier in this order:

  1. node_modules/prettier in the workspace (local install)
  2. The bundled prettier that ships with the extension itself (fallback)

The extension automatically uses .prettierrc and will use prettier-plugin-solidity as is since its listed in the plugins array.

As far as extension being able to override perttierrc config, this is what Claude’s telling me:

The extension has its own settings (prettier.tabWidth, prettier.printWidth,
prettier.singleQuote, etc.). The priority order is:

  1. .prettierrc (highest — wins)
  2. .editorconfig
  3. VS Code extension settings (lowest — only used as fallback)

So when .prettierrc exists, extension settings cannot override it. The only scenarios where a
dev would get different formatting:

  • They set prettier.prettierPath to a different prettier binary (different version)
  • They set prettier.configPath to a different config file
  • They don't have node_modules installed, so the extension falls back to its bundled prettier
    (possibly a different version)
  • They use a different extension entirely as their Solidity formatter (e.g.,
    JuanBlanco.solidity with its own built-in formatter instead of delegating to prettier)

None of these happen with default settings. And regardless, CI will catch any mismatches.

@tbwebb22
Copy link
Copy Markdown
Contributor Author

tbwebb22 commented Feb 9, 2026

  • yarn pretty-quick --staged: what prettier path + version is that using?

pretty-quick uses prettier as a peer dependency, so it resolves to whatever is in node_modules — same prettier@2.8.8 with the same .prettierrc. The output is identical to running prettier directly.

Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
@tbwebb22
Copy link
Copy Markdown
Contributor Author

tbwebb22 commented Feb 9, 2026

  • should we perhaps upgrade versions of prettier-plugin-solidity, pretty-quick as a part of this change?

Yeah good call ad3eeab

@tbwebb22
Copy link
Copy Markdown
Contributor Author

tbwebb22 commented Feb 9, 2026

prettier v3 has different default rules for breaking long lines, and enforces trailing commas by default - which is why so many files are being changed here

@grasphoper
Copy link
Copy Markdown
Collaborator

@tbwebb22 got it to work only after also adding this to .vscode/settings.json:

...
  "prettier.prettierPath": "./node_modules/prettier",
...

Copy link
Copy Markdown
Collaborator

@grasphoper grasphoper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should just disable the trailing comma option to reduce this diff? The change otherwise looks good. I think we wanna hold off on merging this though and wait for the latest audit to land on master first (better fix conflicts here than in the audit PR)

@tbwebb22
Copy link
Copy Markdown
Contributor Author

@tbwebb22 got it to work only after also adding this to .vscode/settings.json:

...
  "prettier.prettierPath": "./node_modules/prettier",
...

ok interesting. I don't have that in my settings.json

@tbwebb22
Copy link
Copy Markdown
Contributor Author

Do you think we should just disable the trailing comma option to reduce this diff? The change otherwise looks good. I think we wanna hold off on merging this though and wait for the latest audit to land on master first (better fix conflicts here than in the audit PR)

Sounds good, we can always re-enable the trailing comma option later on if we want to.

@tbwebb22
Copy link
Copy Markdown
Contributor Author

Do you think we should just disable the trailing comma option to reduce this diff? The change otherwise looks good. I think we wanna hold off on merging this though and wait for the latest audit to land on master first (better fix conflicts here than in the audit PR)

a09c7b2

Apparently there's no way to configure line-wrapping length in prettier-plugin-solidity v2, so we'll have to live with those changes in the diff if we want to stick with the newer version

@grasphoper grasphoper self-requested a review February 25, 2026 22:14
@tbwebb22 tbwebb22 merged commit 3e53c57 into master Feb 25, 2026
12 checks passed
@tbwebb22 tbwebb22 deleted the taylor/prettier-ci branch February 25, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants