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 array calling pre-configured scripts #20

Closed
alallier opened this issue Jun 27, 2016 · 1 comment
Closed

Lint staged array calling pre-configured scripts #20

alallier opened this issue Jun 27, 2016 · 1 comment
Labels

Comments

@alallier
Copy link

Is it possible to do this (simply just run lint-staged on a script already pre-configured in the scripts section?)

"scripts": {
    "eslint": "./node_modules/.bin/eslint .",
    "stylelint": "./node_modules/.bin/stylelint statics/css/**/*.less --syntax less",
    "htmlhint": "./node_modules/.bin/htmlhint mvc/views",
    "lint": "npm run htmlhint && npm run stylelint && npm run eslint",
    "lint-staged": "lint-staged"
  },
  "lint-staged" [
    "htmlhint",
    "lesshint",
    "eslint"
  ]
  "pre-commit": [
    "lint-staged"
  ]
@okonet
Copy link
Collaborator

okonet commented Jun 27, 2016

Yes, although because of #17 it won't work in this case. It will after it is fixed.

Important note: you shouldn't pass path to these scripts.

Also, you don't need to specify path to your bins. See https://docs.npmjs.com/cli/run-script

So, to sum it up. In this case your config could look like this:

"scripts": {
    "eslint": "eslint .",
    "eslint:staged": "eslint",
    "stylelint": "stylelint statics/css/**/*.less --syntax less",
    "stylelint:staged": "stylelint --syntax less",
    "htmlhint": "htmlhint mvc/views",
    "htmlhint:staged": "htmlhint",
    "lint": "npm run htmlhint && npm run stylelint && npm run eslint",
    "lint-staged": "lint-staged"
  },
  "lint-staged" [
    "htmlhint:staged": "*.html",
    "stylelint:staged": "*.less",
    "eslint:staged": "*.js"
  ]
  "pre-commit": [
    "lint-staged"
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants