1

I want to use lint-staged to run hooks only on staged files in a node.js project. The docs suggest adding the following code to the package.json file;

{ "lint-staged": { "*": "your-cmd" } } 

I have also seen the following code elsewhere in another codebase;

"lint-staged": { "**/*": "prettier --write --ignore-unknown" } 

What purpose does the asterisk(s) serve? I don't suppose it's simply a placeholder. Thanks for the help.

1 Answer 1

2

As the readme says, those are glob patterns.

"*": "your-cmd" 

will match any file (* matches anything by definition)

"**/*": "prettier --write --ignore-unknown" 

will match:

  • ** - "≥ 0 characters crossing directory boundaries", followed by
  • / - A directory boundary, followed by
  • * - Anything
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.