In package.json
I have this script name with two words lint
and fix
. How should I make a right name?
There are options:
lintFix
LintFix
lint_fix
lint-fix
lint:fix
What option is right? And why?
json file: To execute your Script, use the 'npm run <NAME-OF-YOUR-SCRIPT>' command. Some predefined aliases convert to npm run, like npm test or npm start, you can use them interchangeably.
A package. json file must contain "name" and "version" fields. The "name" field contains your package's name, and must be lowercase and one word, and may contain hyphens and underscores. The "version" field must be in the form x.x.x and follow the semantic versioning guidelines.
Scripts are stored in a project's package. json file, which means they're shared amongst everyone using the codebase. They help automate repetitive tasks, and mean having to learn fewer tools. Node npm scripts also ensure that everyone is using the same command with the same flags.
Please always use kebab case. The colon is a throwback to gulp, and it looks terrible. I hate it.
Disclaimer: My opinions are often wrong and I had a dysfunctional family.
There is no official naming convention. Before npm@v4 standard scripts had only one word, for example test
, start
, prestart
. npm@v4 introduced a new script prepublishOnly
*.
So now, the best practice is use lowerCamelCase.
*Reference: https://iamakulov.com/notes/npm-4-prepublish/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With