Skip to content
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

Merged
merged 5 commits into from
Mar 5, 2024

Conversation

theneva
Copy link
Contributor

@theneva theneva commented Feb 22, 2024

Hi! 👋

This PR is based on #593, so please ignore the first commit.

Husky dropped support for the hooks field in package.json in v5, so the pre-commit hook (and, by extension lint-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.

@theneva theneva changed the title chore: run lint:fix fix(eslint): run lint-staged on pre-commit again Feb 22, 2024
@theneva theneva changed the title fix(eslint): run lint-staged on pre-commit again fix(lint): run lint-staged on pre-commit again Feb 22, 2024
@@ -1,11 +1,9 @@
{
"extends": [
"airbnb-typescript/base",
Copy link
Contributor Author

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

Copy link
Collaborator

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

Copy link
Contributor Author

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"
Copy link
Contributor Author

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"],
Copy link
Contributor Author

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}": [
Copy link
Contributor Author

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!

Comment on lines -126 to -130
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
Copy link
Contributor Author

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
Copy link
Contributor Author

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",
Copy link
Contributor Author

@theneva theneva Feb 22, 2024

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",
Copy link
Contributor Author

@theneva theneva Feb 22, 2024

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

@theneva theneva mentioned this pull request Feb 22, 2024
@coveralls
Copy link

coveralls commented Feb 22, 2024

Coverage Status

coverage: 90.863%. remained the same
when pulling 1418940 on theneva:fix-lint-staged
into 59b82c5 on Unleash:main.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
… stuff

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Contributor

@gastonfournier gastonfournier left a 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!

@thomasheartman thomasheartman merged commit 17de2d6 into Unleash:main Mar 5, 2024
4 checks passed
@theneva theneva deleted the fix-lint-staged branch March 6, 2024 09:48
renovate bot referenced this pull request in Unleash/unleash Mar 19, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](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) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/unleash-client/5.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/unleash-client/5.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/unleash-client/5.5.1/5.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/unleash-client/5.5.1/5.5.2?slim=true)](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
[@&#8203;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
[@&#8203;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
[@&#8203;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

- [@&#8203;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>
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.

None yet

5 participants