question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to establish multiple lint-staged 'scripts'?

See original GitHub issue

Description

I am using lint-staged to lint JS and SCSS files in our project, but I also have multiple ESLint configs depending on the context. One that runs as part of a build process that is less strict and allows things like console.logs. Then a more strict config that gets run on pre-commit hooks.

As it stands right now I can call lint-staged for the pre-commit hooks but have to lint all files on my build process.

I’m wondering if there is a way to have something like:

"lint-staged": {
    "src/main/webpack/**/*.js": "eslint --fix",
    "src/main/webpack/**/*.scss": "stylelint --fix"
},
"lint-staged-build": {
    "src/main/webpack/**/*.js": "eslint --fix -c .eslintconfig-build.json",
    "src/main/webpack/**/*.scss": "stylelint --fix"
}

OR

"lint-staged": {
    "pre-commit": {
        "src/main/webpack/**/*.js": "eslint --fix",
        "src/main/webpack/**/*.scss": "stylelint --fix"
    },
    "build": {
        "src/main/webpack/**/*.js": "eslint --fix -c .eslintconfig-build.json",
        "src/main/webpack/**/*.scss": "stylelint --fix"
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
iirojcommented, Feb 27, 2020

Alternatively, pass a different config: lint-staged -c lint-staged.build.json

1reaction
okonetcommented, Mar 11, 2020

Sorry but I don’t think we want go this route. The provided solution solves the problem and to me addition CLI flags isn’t worth the complexity considering same can be achieved with a different syntax ATM. I’ll close this since I consider it’s resolved. Feel free to re-open if I’m mistaken.

Read more comments on GitHub >

github_iconTop Results From Across the Web

okonet/lint-staged: — Run linters on git staged files - GitHub
Ignoring files. The concept of lint-staged is to run configured linter tasks (or other tasks) on files that are staged in git.
Read more >
Is this a right way to use husky + lint-staged? - Stack Overflow
Run npm install --save-dev husky lint-staged and create a .lintstagedrc and as well as an .huskyrc at root. Example setup for some scripts...
Read more >
Diving into Husky and Lint-staged | Laurie on Tech
The first tool to talk about is lint-staged. ... In many cases, you'll want more than one command, which lint-staged supports.
Read more >
Getting started with Husky and Lint-staged for pre-commit hooks
The next step is to install lint-staged. Lint-staged has been created with the purpose of linting only staged files. Lint-staged has very well-defined...
Read more >
Automate and Keep Your Code Consistent Using ESLint ...
Lint-Staged — is used to run linter to staged git files and prevent from committing the buggy code. Husky — is a tool...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found