-
Notifications
You must be signed in to change notification settings - Fork 63
Fix lint staged to match pnpm:fix order and settings #1761
Conversation
Storybook and Tailwind configuration previews: Ready Storybook: https://wordpress.github.io/openverse-frontend/_preview/1761 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't resist looking more into this situation :)
Since we are already running prettier --write
, we do not need eslint
to check for prettier errors (and un-do the prettier fixes while doing that!). We can actually fix this whole thing if we add "prettier/prettier": "off"
to the rules
in .eslintrc.js
.
Also, I re-arranged the commands in this file locally:
{
"*.{json,yml,yaml,mdx,md}": "prettier --write",
"*.{ts,js,vue}": ["prettier --write", "eslint --ext .js,.vue,.ts --ignore-path .gitignore --ignore-path .eslintignore --max-warnings=0 ."],
}
If two commands are in a bracketed list, they are executed sequentially. The two separate commands in this object are executed at the same time.
And tried committing the VSkipToContainer
file with the wrong order of classes:
class="ms-2 z-50 mt-2 focus:fixed focus:absolute"
.
lintstaged first ran prettier and fixed the class order to the correct class="z-50 mt-2 ms-2 focus:fixed focus:absolute"
, and then eslint did not undo it. So, husky said that it's an empty commit and refused to commit it :)
Co-authored-by: Olga Bulat <obulat@gmail.com>
Fantastic, thanks @obulat! I implemented your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Size Change: -381 B (0%) Total Size: 768 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So glad the root cause was found! 🥳
Fixes
Fixes #1658 by @dhruvkb
Description
Fixes a discrepancy between
pnpm lint:fix
and our precommit linting script. Now they run eslint and prettier formatting in the same order with the same settings.