1 | # eslint-plugin-node
|
2 |
|
3 | [![npm version](https://img.shields.io/npm/v/eslint-plugin-node.svg)](https://www.npmjs.com/package/eslint-plugin-node)
|
4 | [![Downloads/month](https://img.shields.io/npm/dm/eslint-plugin-node.svg)](http://www.npmtrends.com/eslint-plugin-node)
|
5 | [![Build Status](https://travis-ci.org/mysticatea/eslint-plugin-node.svg?branch=master)](https://travis-ci.org/mysticatea/eslint-plugin-node)
|
6 | [![Coverage Status](https://codecov.io/gh/mysticatea/eslint-plugin-node/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/eslint-plugin-node)
|
7 | [![Dependency Status](https://david-dm.org/mysticatea/eslint-plugin-node.svg)](https://david-dm.org/mysticatea/eslint-plugin-node)
|
8 |
|
9 | Additional ESLint's rules for Node.js
|
10 |
|
11 | ## :cd: Install & Usage
|
12 |
|
13 | ```
|
14 | > npm install --save-dev eslint eslint-plugin-node
|
15 | ```
|
16 |
|
17 | - Requires Node.js `^0.10.0 || ^0.12.0 || ^4.0.0 || >=6.0.0`
|
18 | - Requires ESLint `>=2.0.0`
|
19 |
|
20 | **Note:** It recommends a use of [the "engines" field of package.json](https://docs.npmjs.com/files/package.json#engines). The "engines" field is used by [no-unsupported-features](docs/rules/no-unsupported-features.md) rule.
|
21 |
|
22 | **.eslintrc.json** (An example)
|
23 |
|
24 | ```json
|
25 | {
|
26 | "plugins": ["node"],
|
27 | "extends": ["eslint:recommended", "plugin:node/recommended"],
|
28 | "rules": {
|
29 | "node/exports-style": ["error", "module.exports"],
|
30 | }
|
31 | }
|
32 | ```
|
33 |
|
34 | **package.json** (An example)
|
35 |
|
36 | ```json
|
37 | {
|
38 | "name": "your-module",
|
39 | "version": "1.0.0",
|
40 | "engines": {
|
41 | "node": ">=4.0.0"
|
42 | }
|
43 | }
|
44 | ```
|
45 |
|
46 | ## :bulb: Rules
|
47 |
|
48 | | | | Rule ID | Description |
|
49 | |:------:|:--------:|:-----------------------------------------------------------------|:------------|
|
50 | | | | [exports-style](docs/rules/exports-style.md) | Enforce either `module.exports` or `exports`.
|
51 | | :star: | | [no-deprecated-api](docs/rules/no-deprecated-api.md) | Disallow deprecated API.
|
52 | | | | [no-missing-import](docs/rules/no-missing-import.md) | Disallow `import` declarations for files that don't exist. :warning:
|
53 | | :star: | | [no-missing-require](docs/rules/no-missing-require.md) | Disallow `require()`s for files that don't exist.
|
54 | | :star: | | [no-unpublished-bin](docs/rules/no-unpublished-bin.md) | Disallow `bin` files that npm ignores.
|
55 | | | | [no-unpublished-import](docs/rules/no-unpublished-import.md) | Disallow `import` declarations for files that npm ignores. :warning:
|
56 | | :star: | | [no-unpublished-require](docs/rules/no-unpublished-require.md) | Disallow `require()`s for files that npm ignores.
|
57 | | :star: | | [no-unsupported-features](docs/rules/no-unsupported-features.md) | Disallow unsupported ECMAScript features on the specified version.
|
58 | | :star: | | [process-exit-as-throw](docs/rules/process-exit-as-throw.md) | Make the same code path as throw at `process.exit()`.
|
59 | | :star: | :pencil: | [shebang](docs/rules/shebang.md) | Suggest correct usage of shebang.
|
60 |
|
61 | - :star: - the mark of a recommended rule.
|
62 | - :pencil: - the mark of a fixable rule.
|
63 |
|
64 | ## :wrench: Configs
|
65 |
|
66 | This plugin provides `plugin:node/recommended` preset config.
|
67 | This preset config:
|
68 |
|
69 | - enables the environment of ES2015 (ES6) and Node.js.
|
70 | - enables rules which are given :star: in the above table.
|
71 | - enables [no-process-exit](http://eslint.org/docs/rules/no-process-exit) rule because [the official document](https://nodejs.org/api/process.html#process_process_exit_code) does not recommend a use of `process.exit()`.
|
72 | - adds `{ecmaVersion: 8}` into `parserOptions`.
|
73 |
|
74 | ## :couple: FAQ
|
75 |
|
76 | - Q: The `no-missing-import` / `no-missing-require` rules don't work with nested folders in SublimeLinter-eslint
|
77 | - A: See [context.getFilename() in rule returns relative path](https://github.com/roadhump/SublimeLinter-eslint#contextgetfilename-in-rule-returns-relative-path) in the SublimeLinter-eslint FAQ.
|
78 |
|
79 | ## :anchor: Semantic Versioning Policy
|
80 |
|
81 | `eslint-plugin-node` follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
|
82 |
|
83 | - Patch release (intended to not break your lint build)
|
84 | - A bug fix in a rule that results in it reporting fewer errors.
|
85 | - Improvements to documentation.
|
86 | - Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
|
87 | - Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
|
88 | - Minor release (might break your lint build)
|
89 | - A bug fix in a rule that results in it reporting more errors.
|
90 | - A new rule is created.
|
91 | - A new option to an existing rule is created.
|
92 | - An existing rule is deprecated.
|
93 | - Major release (likely to break your lint build)
|
94 | - A support for old Node version is dropped.
|
95 | - A support for old ESLint version is dropped.
|
96 | - An existing rule is changed in it reporting more errors.
|
97 | - An existing rule is removed.
|
98 | - An existing option of a rule is removed.
|
99 | - An existing config is updated.
|
100 |
|
101 | ## :newspaper: Changelog
|
102 |
|
103 | - [GitHub Releases](https://github.com/mysticatea/eslint-plugin-node/releases)
|
104 |
|
105 | ## :muscle: Contributing
|
106 |
|
107 | Welcome contributing!
|
108 |
|
109 | Please use GitHub's Issues/PRs.
|
110 |
|
111 | ### Development Tools
|
112 |
|
113 | - `npm test` runs tests and measures coverage.
|
114 | - `npm run coverage` shows the coverage result of `npm test` command.
|
115 | - `npm run clean` removes the coverage result of `npm test` command.
|