File where you store all "meta" data about your package
// init package.json
npm init
// init with default settings
npm init --yesAdd package to your project:
npm install [PACKAGE_NAME]
// alias
npm i [PACKAGE_NAME]Add package to your project:
npm install --save [PACKAGE_NAME]npm install --save-dev [PACKAGE_NAME]
npm install --global [PACKAGE_NAME]Save to dependencies:
Save to dev dependencies:
Save to global dependencies:
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
The difference between these two is that devDependencies are modules that are only required during development, while dependencies are modules which are also required at runtime.
Install
npm install eslint --save-dev
# or
yarn add eslint --devInit
$ npx eslint --init
# or
$ yarn run eslint --initRun
$ npx eslint yourfile.js
# or
$ yarn run eslint yourfile.jsPopular style guieds:
Change rule
{
"rules": {
"semi": ["error", "always"],
"quotes": ["error", "double"]
}
}The names "semi" and "quotes" are the names of rules in ESLint. The first value is the error level of the rule and can be one of these values:
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the configuration docs).
You can use it to lint your commit messages, run tests, lint code, etc... when you commit or push (or some other hook).