Skip to content

Conversation

@stefanv
Copy link
Collaborator

@stefanv stefanv commented Jun 28, 2025

This adds the (optional) ability to run a pre-commit hook to lint changes.

I find it quite helpful, in that it prevents me from having to go back and run eslint or prettier on my commits. We've had it for a while on the mystmd repo without complaints.

@changeset-bot
Copy link

changeset-bot bot commented Jun 28, 2025

⚠️ No Changeset found

Latest commit: 5ea53d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Jun 28, 2025

Deploy Preview for myst-theme ready!

Name Link
🔨 Latest commit 5ea53d0
🔍 Latest deploy log https://app.netlify.com/projects/myst-theme/deploys/68605386e8efe2000880339f
😎 Deploy Preview https://deploy-preview-622--myst-theme.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Collaborator

@agoose77 agoose77 left a comment

Choose a reason for hiding this comment

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

LGTM! it's opt in, so we can easily merge and iterate. One question - our built-in lint tasks have implementions (definitions) per-subpackage, I.e you can define a different lint rule in each package. Is there a way that we should be defining this to match?

@stefanv
Copy link
Collaborator Author

stefanv commented Jun 29, 2025

This seems to only be the case for the themes/ subdirectory.

So, if you want, we can do prefix detection and run different commands for files coming from those directories.

"dependencies": {}
"lint-staged": {
"*.ts": "eslint --config ./.eslintrc.cjs --fix",
"*.{js,jsx,ts,tsx,md,html,css,json}": "prettier --write"
Copy link
Collaborator

@stevejpurves stevejpurves Jul 1, 2025

Choose a reason for hiding this comment

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

Hi @stefanv, @agoose77,

How does this align with the separate turborepo powered linting (which uses the eslint config from each respective package dir) that we have in place in scripts already? can the lint-staged call the respective npm scripts above? (just wanting to avoid two different sets of linting config)

Also will opening the pattern here beyond ts, tsx, md especially to include js, css mean that we are running prettier on the contents of dist/ and other build output folders?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the same question I ask above, although I'm not sure if my meaning came through as clearly as it does here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The lint-staged package lets us only lint files that were touched during the commit.

I am not sure how to use the existing scripts, since afaik they don't take file arguments.

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