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

lint-staged installs husky 5 but sets up husky 4 config #145

Closed
Pezmc opened this issue Feb 18, 2021 · 1 comment
Closed

lint-staged installs husky 5 but sets up husky 4 config #145

Pezmc opened this issue Feb 18, 2021 · 1 comment

Comments

@Pezmc
Copy link
Contributor

Pezmc commented Feb 18, 2021

Right now, if you run the following on an empty project:

$ npm init
$ npm install --save-dev prettier # or eslint or stylelint
$ npx mrm lint-staged

npx: installed 240 in 7.785s
Running lint-staged...
Update package.json
Installing lint-staged and husky...

+ husky@5.0.9
+ lint-staged@10.5.4

Note that husky 5.0.9 was installed, but our package.json looks like:

# cat package.json
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {},
  "devDependencies": {
    "husky": "^5.0.9",
    "lint-staged": "^10.5.4",
    "prettier": "^2.2.1"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{js,css,md}": "prettier --write"
  }
}

Husky 5 no longer uses that config style format (see https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v5), instead you need to run the commands like:

npx husky add .husky/pre-commit "npm run lint-staged"

The short term fix would be to update the task to only install Husky <5, which may be the preferred default since there are license complications right now.

Longer term, mrm should perhaps ask if the user prefers 4/5 and use the appropriate config format.

@okonet
Copy link
Collaborator

okonet commented Feb 18, 2021

Thanks for submitting it! I agree we could quickly pin the version to 4 or migrate to the new format. Can you create a PR please?

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

No branches or pull requests

2 participants