-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lint): run lint-staged on pre-commit again #594
Conversation
@@ -1,11 +1,9 @@ | |||
{ | |||
"extends": [ | |||
"airbnb-typescript/base", |
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.
prettier does pretty much all that airbnb-typescript does, so there's no real need for both of them
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.
you probably need the parser
etc? line 10 and down https://www.npmjs.com/package/eslint-config-airbnb-typescript?activeTab=code
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.
you're absolutely right. I tested locally with a file with no typescript-specific keywords… I just added eslint-config-airbnb-typescript back in now
"plugin:import/recommended", | ||
"plugin:import/typescript" | ||
"plugin:import/typescript", | ||
"plugin:prettier/recommended" |
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.
From https://github.com/prettier/eslint-plugin-prettier#configuration-legacy-eslintrc:
This will:
- Enable the prettier/prettier rule.
- Disable the arrow-body-style and prefer-arrow-callback rules which are problematic with this plugin - see the below for why.
- Enable the eslint-config-prettier config which will turn off ESLint rules that conflict with Prettier.
], | ||
"plugins": ["prettier"], |
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.
extending plugin:prettier/recommended
does this
@@ -116,18 +115,13 @@ | |||
] | |||
}, | |||
"lint-staged": { | |||
"*.js": [ | |||
"*.{js,ts}": [ |
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.
ESLint didn't support TypeScript when this was first added in 2018, but it does now!
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, |
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.
this configuration style was dropped in Husky v5, which is why it stopped working. The hooks are now configured as separate files in .husky/
@@ -0,0 +1 @@ | |||
yarn run pre-commit |
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.
This is the configuration style Husky has used since v5, so this file replaces the hooks.pre-commit
property in package.json
package.json
Outdated
"prebuild": "del-cli --force lib", | ||
"build": "tsc -p .", | ||
"prepare": "yarn run build", | ||
"prepare": "husky && yarn run build", |
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.
This installs the hooks in .husky/…
into .git/hooks/…
package.json
Outdated
"eslint-config-prettier": "^8.8.0", | ||
"eslint-import-resolver-typescript": "^3.5.5", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"esm": "^3.2.25", | ||
"husky": "^8.0.3", | ||
"husky": "^9.0.11", |
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 figured I'd bump Husky to the latest v9 since I was touching it anyway – but the changes in this PR should work fine with v8 too Husky v9 dropped support for Node 16, so I kept it at v8
… stuff
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.
This looks great @theneva! In Unleash we switched to biome which is faster, but we believe this is great anyway and don't have a strong attachment to biome. I'd say we go ahead with this one! Thanks for the contribution!
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [unleash-client](https://togithub.com/Unleash/unleash-client-node) | [`5.5.1` -> `5.5.2`](https://renovatebot.com/diffs/npm/unleash-client/5.5.1/5.5.2) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>Unleash/unleash-client-node (unleash-client)</summary> ### [`v5.5.2`](https://togithub.com/Unleash/unleash-client-node/releases/tag/v5.5.2) [Compare Source](https://togithub.com/Unleash/unleash-client-node/compare/v5.5.1...v5.5.2) #### What's Changed - chore(deps): update dependency nock to v13.5.3 by [@​renovate](https://togithub.com/renovate) in [https://github.com/Unleash/unleash-client-node/pull/588](https://togithub.com/Unleash/unleash-client-node/pull/588) - fix(lint): run lint-staged on pre-commit again by [@​theneva](https://togithub.com/theneva) in [https://github.com/Unleash/unleash-client-node/pull/594](https://togithub.com/Unleash/unleash-client-node/pull/594) - fix: add ip to resolutions by [@​gastonfournier](https://togithub.com/gastonfournier) in [https://github.com/Unleash/unleash-client-node/pull/601](https://togithub.com/Unleash/unleash-client-node/pull/601) #### New Contributors - [@​theneva](https://togithub.com/theneva) made their first contribution in [https://github.com/Unleash/unleash-client-node/pull/594](https://togithub.com/Unleash/unleash-client-node/pull/594) **Full Changelog**: Unleash/unleash-client-node@v5.5.1...v5.5.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 7pm every weekday,before 5am every weekday" in timezone Europe/Madrid, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Unleash/unleash). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Hi! 👋
This PR is based on #593, so please ignore the first commit.
Husky dropped support for the
hooks
field inpackage.json
in v5, so the pre-commit hook (and, by extensionlint-staged
) has not been run since Husky was upgraded from v4 to v7 in 2021 (fcf3c18).I also made ESLint actually run Prettier by extending the
prettier/recommended
config.