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.

Allow defining a template for how paths should be passed to the command

See original GitHub issue

At this moment lint-staged will always pass file paths as arguemnts at the end of the string:

npm run-script command -- path/to/staged/file1 path/to/staged/file2
eslint -- path/to/staged/file1 path/to/staged/file2

In order to support exotic cases like #136 and #18 we might want to redefine this. One way of doing this would be to pass a “template” string to how paths should be interpolated. Something like this:

{
  "*.jpg": "${ path } | imagemin",
  "*.html": "gulp my-task -g ${ paths }",
  "*.js": "eslint" // This is the current way of doing "eslint ${ paths }"
}

lint-staged will try to interpolate those strings when running tasks.

  1. The piping example will require calling filepath | imagemin for each path in paths. Not sure how to do that. Different type of token (path instead of paths?)
  2. Better error handling: since templates may be broken, lint-staged should help users find the mistake

Another use cases: #404

I’m open for a discussion and suggestions on the API of this feature.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:21
  • Comments:40 (20 by maintainers)

github_iconTop GitHub Comments

13reactions
renchapcommented, Jun 27, 2018

Small comment here about usecase: being able to do something like: *.ts: "tsc --noEmit -p tsconfig.json"

would be quite useful to run the Typescript compiler in check mode only if there are staged Typescript files. This is different from running it using Husky, as you only want to check it if you committed TS files, not all the time.

8reactions
okonetcommented, Mar 18, 2018

Another important question if implicit syntax { "*.js": "eslint" } should be deprecated in favor of more explicit one i.e. {"*.js": "eslint <paths>" }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Templates - Azure Pipelines | Microsoft Learn
Templates let you define reusable content, logic, and parameters. ... Template paths should be relative to the file that does the including.
Read more >
Development guide for GitLab CI/CD templates
This document explains how to develop GitLab CI/CD templates. Requirements for CI/CD templates. Before submitting a merge request with a new or updated ......
Read more >
What is the path that Django uses for locating and loading ...
Your project's TEMPLATES setting describes how Django will load and render templates. The default settings file configures a DjangoTemplates ...
Read more >
Use Airflow templates | Astronomer Documentation
Use Airflow templates. Templating allows you to pass dynamic information into task instances at runtime. For example, you can run the following command...
Read more >
Templates - Django documentation
DIRS defines a list of directories where the engine should look for template source files, in search order. APP_DIRS tells whether the engine...
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