I have a 'script' that runs eslint in my package.json like so:
{
"name": "overthinkingJs",
"scripts": {
"lint": "node lint.js && echo No lint errors"
"lint": "node lint.js --fix && echo No lint errors"
}
}
Where the lint file has this sort of thing, where spawn is from cross-spawn:
const eslint = path.join(__dirname, 'path/to/eslint');
const args = process.argv.slice(2);
spawn(eslint, args, { stdio: 'inherit' })
I'm aware the args = process.argv.slice(2); part means that calling node lint.js --fix passes --fix into eslint.
I'm aware I can make new scripts, but I want a way to pass arbitrary arguments to the first bash process (lint.js) and not the last command (echo) in the ampersand chain?
I've tried:
npm run lint:fix -- --rule 'rule-name: off'
But it runs:
node lint.js --fix && echo No lint errors "--rule" "rule-name: off"
How do I specify which command in the chain to pass arguments to, without changing my lint.js?