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.

Trigger a linter once without passing files?

See original GitHub issue

Hello, and thanks for a great project!

I’d like to use lint-staged to run the flow typechecker if a commit would contain .js files. flow does not expect to be passed individual files, and does not need to run once per file; instead, no matter how many .js files are in the commit, flow only needs to run once.

I saw #174 - the reason I would like to use lint-staged is because I have other linters (stylelint, eslint) that should also run. Currently, I’m getting this to work with the following config:

{
  "scripts": {
    "precommit": "lint-staged && flow"
  },
  "lint-staged": {
    "*.css": "stylelint",
    "*.scss": "stylelint --syntax=scss",
    "*.js": "eslint"
  }
}

but this makes flow run after all linters, instead of potentially letting it run in parallel. It also feels cleaner to have “precommit” just be “lint-staged”, instead of a shell-chained list of commands.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
okonetcommented, Jun 8, 2017

BTW when #138 is done it should be possible to run commands without arguments.

0reactions
sebastiandedeynecommented, Dec 5, 2019

For people landing here, this is now possible with functions as linter commands: https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-commands

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line Interface
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
lint-staged: Lint Your Staged Files | Karuppiah's Blog
lint -staged will take care of passing the file path of the staged files as it's the one that knows which files are...
Read more >
lint-staged
Linter commands work on a subset of all staged files, defined by a glob pattern. lint-staged uses micromatch for matching files with the ......
Read more >
Configuration
Linter (s) to run when a triggered file is modified. Targets(s) to pass to the linters (can be files or directories). An example...
Read more >
A Complete Guide to Linting Go Programs - freshman.tech
You can also choose which directories and files to analyse by passing one or more directories or paths to files. $ golangci-lint run...
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