[PM-24643] Add an easy to use formatting linting command to the sdk#1140
Conversation
Introduce scripts/lint.sh as the single source of truth for the formatting and linting checks the SDK requires. Mirrors the checks in .github/workflows/lint.yml so a local run matches CI. The script supports --fix (auto-fix where supported) and --only <name> (run a single check), and is wired into package.json: - npm run lint - check-only, matches CI - npm run lint:fix - auto-fix what can be auto-fixed - npm run lint:prettier (the previous prettier-only `npm run lint`) The CI workflow is otherwise unchanged in this commit; only the `Node Lint` step is updated to call lint:prettier under its new name. A follow-up commit refactors CI to call scripts/lint.sh directly.
Each check that used to be a sequential step in the `style` job is now its own matrix entry, calling `./scripts/lint.sh --only <name>`. The script remains the single source of truth for what each check does; this workflow only handles toolchain/tool installation gated on the matrix entry's needs. `fail-fast: false` mirrors the previous "let every check finish so you see all the failures" behaviour. Net effect: wall-clock is bounded by the slowest single check (udeps or clippy) rather than their sum. The clippy job still produces SARIF output for the GitHub Security tab; that step runs before `--only clippy` so the script's clippy run hits the warm cache. Also switch the script's `cargo-lock` check from `git diff Cargo.lock` to `cargo metadata --locked`. The diff-based check only catches drift when a prior step in the same job updated Cargo.lock, which no longer holds in matrix isolation. `--locked` checks lockfile-vs-Cargo.toml consistency directly.
Replace the hand-typed checks list in README § Formatting & Linting with a pointer to `npm run lint` / `npm run lint:fix` and the `--only <check>` selector. The list of tools and pinned versions remains in lint.yml; the README no longer re-asserts the exact commands and so cannot drift from CI. Update .claude/CLAUDE.md Format & Lint bullets to point at the same commands.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR introduces a unified The script faithfully mirrors the previous CI steps (same flags, same Code Review DetailsNo actionable findings. |
🔍 SDK Breaking Change DetectionSDK Version:
Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1140 +/- ##
==========================================
+ Coverage 83.85% 84.10% +0.25%
==========================================
Files 437 445 +8
Lines 56704 58746 +2042
==========================================
+ Hits 47547 49410 +1863
- Misses 9157 9336 +179 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The existing entries only covered `*_bg.wasm.js`, missing the companion `bitwarden_wasm_internal.js`, `*_bg.js`, and the `node/` subdirectory variant that wasm-pack also emits. Locally those files made `npm run lint` noisy after a wasm build; CI never saw them because they're git-untracked, but the new unified lint command surfaced the gap. Collapse both lines to a single `**/bitwarden_wasm_internal*.js` glob under `crates/bitwarden-wasm-internal/`. Tracked files in those directories (`index.js`, `package.json`, etc.) keep being checked since the prefix doesn't match them.
withinfocus
left a comment
There was a problem hiding this comment.
The AI changes are fine, but a couple things too.
Also, see bitwarden/template#199 -- you don't have to use NPM as your linting gateway if you don't want to; the latest Git's hooks feature can be used for that and would be my preference for all new work.
There was a problem hiding this comment.
Is that a thing we do?
There was a problem hiding this comment.
Also bash can be available on windows too
There was a problem hiding this comment.
Yes, all other projects runs on both windows and mac. Several of our developers use windows and we want to support external contributors. I don't think bash is generally available on windows unless you use WSL or git bash which I'm not sure we can assume?
What about just using a node script or powershell which is what we use in other places.
There was a problem hiding this comment.
Just a note, we require devs to install powershell on linux/mac for server development, so requiring them to install bash on windows seems reasonable.
There was a problem hiding this comment.
Does git even work without bash? I think it's pretty safe to assume that bash exists on windows since it's a core component of git for windows. There are scaled down versions like MinGit that don't come with bash but MinGit is a lightweight, non-interactive distribution of Git for Windows, designed specifically for third-party applications like IDEs and graph visualizers, so I think we can safely scope that out.
Unless support for Bash and Powershell is a general requirement we have documented somewhere that I've missed?
There was a problem hiding this comment.
Doesn't IDEs imply we break commit flows in IDEs?
Powershell is a documented requirement, used in both server and browser extension, bash is not currently required on windows.
At a minimum we should test to ensure this works on windows.
There was a problem hiding this comment.
Thanks for the call out, we should definitely work to have all SDK tooling work across platforms. Considering bash is the current standard in the SDK I don't think we should block this work over it. I've added this ticket to the top of the Platform backlog for converting this script and others to powershell/ts/something else.
Pairs naturally with `needs_rust`; review nit from withinfocus.
The existing Renovate custom regex manager covered cargo-dylint and dylint-link installs in workflows; cargo-sort and cargo-udeps were not tracked. Extend the matchStrings to pick them up and add both to the platform-team review/commit-prefix list to mirror how cargo-dylint is owned. Answers withinfocus's "how are these versions monitored" question on the lint workflow.
|
@withinfocus |
That's fine, just something to keep in mind as an improvement. |
|
You might need some admin help with merging this since you renamed a required check. |
|
|
@withinfocus Fixed without admin permissions, thanks for pointing me in the right direction! |
… easy to use formatting linting command to the sdk (bitwarden/sdk-internal#1140)



🎟️ Tracking
📔 Objective
🚨 Breaking Changes