Skip to content

fix: linting and formatting - #23

Closed
andyjakubowski wants to merge 2 commits into
mainfrom
fix-linting-and-formatting
Closed

andyjakubowski wants to merge 2 commits into
mainfrom
fix-linting-and-formatting

Conversation

@andyjakubowski

@andyjakubowski andyjakubowski commented Oct 2, 2025 •

Copy link
Copy Markdown
Contributor

Addresses #8

This PR tightens up our repo hygiene by fixing lint-staged coverage and ensuring Prettier formatting is enforced in CI.

Changes
1. Pre-commit (lint-staged)
• Updated lint-staged config to run Biome (lint + format) on code files.
• Stopped excluding package.json from Biome, it will format the file and then lint-staged will run sort-package-json.
• Prettier continues to run only on Markdown and YAML files.
2. CI (format job)
• Updated package.json scripts so format:check runs both Biome and Prettier checks.
• Updated CI workflow step label to reflect that format:check now validates MD/YAML as well.

Why
• Previously, lint-staged skipped JS/TS files and tried to pass package.json to Biome (ignored by config), causing failed commits.
• CI only checked Biome formatting, so pushes could bypass Prettier rules on MD/YAML.

With these changes:
• Pre-commit hooks cover all relevant staged files correctly.
• CI enforces both Biome and Prettier formatting consistently.

Summary by CodeRabbit

  • New Features
    • None
  • Style
    • Expanded automatic formatting coverage to include more files for consistent code and docs formatting.
  • Chores
    • Clarified CI formatter step name for better visibility.
    • Added and updated formatter and Prettier scripts to simplify formatting and checks.
    • Improved pre-commit setup to run combined formatters across common file types.
    • Minor metadata formatting cleanup for package information.

@coderabbitai

coderabbitai Bot commented Oct 2, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

  • .github/workflows/ci.yml: Renamed the formatter step to "Run the formatter (Biome for code + Prettier for YAML/MD)"; no logic changes.
  • biome.json: Removed the "!**/package.json" pattern from the includes array, altering which files are targeted by the formatter.
  • package.json: Added scripts biome:check/biome:fix and prettier:check/prettier:fix; updated format and format:check to run Biome then Prettier; consolidated and updated lint-staged globs/commands; reformatted keywords to a single-line array.

Possibly related PRs

Suggested reviewers

  • saltenasl
  • jamesbhobbs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “fix: linting and formatting” directly reflects the PR’s main focus of correcting lint-staged behavior and enforcing formatting rules via Biome and Prettier, matching the changes across CI and package.json without unnecessary detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Oct 2, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5500201) to head (d02fa39).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #23   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines            3         3           
  Branches         1         1           
=========================================
  Hits             3         3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andyjakubowski

Copy link
Copy Markdown
Contributor Author

There is a conflict between Biome formatting all JSON files, and then sort-package-json sorting fields (good), but also reformatting the JSON file in a different way (bad). We will need to resolve this conflict. But when you exclude package.json from Biome, then lint-staged complains that “no files were processed”.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f11b52e and d02fa39.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • biome.json (1 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T12:53:28.421Z
Learning: Run `npm run format-fix` before committing any changes
📚 Learning: 2025-09-03T13:01:49.096Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: Use `npm run format` to check code style

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2025-09-03T13:01:49.096Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: Use `npm run format-fix` to auto-fix formatting issues

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2025-09-03T12:53:28.421Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T12:53:28.421Z
Learning: Run `npm run format-fix` before committing any changes

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2025-09-03T13:01:49.096Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: ALWAYS run `npm run format-fix` before committing changes

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2025-09-03T12:53:28.421Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T12:53:28.421Z
Learning: Use lint/format tools as part of development

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2025-09-03T13:01:49.096Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: Pre-commit: run `npm run format-fix`, `npm run lint`, and `npm run test:unittests` before committing

Applied to files:

  • .github/workflows/ci.yml
🪛 GitHub Actions: CI
package.json

[error] 9-15: Biome formatting check failed. The 'files' field would be reformatted to include proper brackets and spacing. Run 'pnpm run format' or 'biome format .' to fix.

🔇 Additional comments (2)
biome.json (1)

17-17: Keep package.json in Biome’s scope.

Bringing package.json under Biome is necessary now that lint-staged runs Biome on JSON; this keeps the workflow consistent. Looks good.

package.json (1)

9-14: Use Biome’s --write=false (or --check) flag for format checks.

biome format . without flags streams formatted code to stdout but exits 0 even when fixes are needed, so format:check won’t fail for dirty files. Add an explicit check mode, e.g. biome format --write=false . (Biome 2.2+) or biome check --write=false ., so CI actually enforces formatting.

⛔ Skipped due to learnings
Learnt from: jamesbhobbs
PR: deepnote/deepnote#18163
File: .husky/pre-push:2-2
Timestamp: 2025-08-14T18:24:01.956Z
Learning: The `biome format` command runs in check mode by default and does not modify files. It only writes changes when the `--write` or `--fix` flag is provided.
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: Use `npm run format` to check code style
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: Use `npm run format-fix` to auto-fix formatting issues
Learnt from: CR
PR: deepnote/deepnote#0
File: CONVENTIONS.md:0-0
Timestamp: 2025-08-18T23:41:22.727Z
Learning: Use provided build/lint/test commands (pnpm build, lint, typecheck, test) and Nx invocations
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T12:53:28.421Z
Learning: Run `npm run format-fix` before committing any changes
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/typescript.instructions.md:0-0
Timestamp: 2025-09-03T13:01:49.096Z
Learning: ALWAYS run `npm run format-fix` before committing changes

Comment thread package.json
Comment on lines +27 to 31
"**/*.{ts,tsx,json,html}": ["pnpm exec biome lint --write", "pnpm exec biome format --write"],
"**/*.{md,yml,yaml}": "pnpm exec prettier --write",
".gitignore": "sort -o .gitignore .gitignore",
"**/package.json": "sort-package-json"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid fighting Biome with sort-package-json.

With package.json now formatted by Biome, sort-package-json rewrites arrays (e.g., keywords, files) into multi-line JSON.stringify output, after which biome format fails in CI. Drop sort-package-json or switch to Biome’s built-in sort action to keep the tools aligned.

🤖 Prompt for AI Agents
package.json lines 27-31: the lint-staged entry runs sort-package-json against
package.json which conflicts with Biome formatting and causes CI failures;
remove the "**/package.json": "sort-package-json" entry (or replace it with a
Biome-based step such as running Biome format on package.json, e.g.
"**/package.json": "pnpm exec biome format --write") so package.json sorting is
handled by Biome and the two tools no longer fight.

@jamesbhobbs jamesbhobbs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest closing this for https://github.com/deepnote/deepnote/pull/20/files

`biome check runs more than just biome lint and biome format combined.
biome check includes:
Linting (like biome lint)
Formatting (like biome format)
Organize imports (not included in lint or format separately)
Assists (code actions/refactoring suggestions)

So the hierarchy is:
biome lint = linting only
biome format = formatting only
biome check = lint + format + organize imports + assists

That's why biome check is generally the recommended command to use - it's the most comprehensive. When you run biome check --write, it will:
Fix linting issues
Format code
Organize/remove unused imports
Apply safe code transformations
`

@andyjakubowski

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #20

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.

2 participants