node.jslint-staged

What purpose does the Asterisk (*) serve in lint-staged config?


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.


Solution

  • As the readme says, those are glob patterns.

    "*": "your-cmd"
    

    will match any file (* matches anything by definition)

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

    will match: