Skip to content

Commit f02bc9b

Browse files
committed
Docs: improve?
1 parent 0da386a commit f02bc9b

10 files changed

+112
-167
lines changed

docs/rules/exports-style.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ This rule has a string option.
4242
- `"exports"` requires `exports` and disallows `module.exports`.
4343
- `allowBatchAssign` (default is `false`) allows `module.exports = exports = obj` if this is `true`.
4444

45-
Examples of **incorrect** code for the `"module.exports"` option:
45+
### module.exports
46+
47+
Examples of :-1: **incorrect** code for the `"module.exports"` option:
4648

4749
```js
4850
/*eslint exports-style: ["error", "module.exports"]*/
@@ -51,7 +53,7 @@ exports.foo = 1
5153
exports.bar = 2
5254
```
5355

54-
Examples of **correct** code for the `"module.exports"` option:
56+
Examples of :+1: **correct** code for the `"module.exports"` option:
5557

5658
```js
5759
/*eslint exports-style: ["error", "module.exports"]*/
@@ -64,7 +66,9 @@ module.exports = {
6466
module.exports.baz = 3
6567
```
6668

67-
Examples of **incorrect** code for the `"exports"` option:
69+
### exports
70+
71+
Examples of :-1: **incorrect** code for the `"exports"` option:
6872

6973
```js
7074
/*eslint exports-style: ["error", "exports"]*/
@@ -77,7 +81,7 @@ module.exports = {
7781
module.exports.baz = 3
7882
```
7983

80-
Examples of **correct** code for the `"exports"` option:
84+
Examples of :+1: **correct** code for the `"exports"` option:
8185

8286
```js
8387
/*eslint exports-style: ["error", "exports"]*/
@@ -86,7 +90,9 @@ exports.foo = 1
8690
exports.bar = 2
8791
```
8892

89-
Examples of **correct** code for the `"exports"` and `{"allowBatchAssign": true}` option:
93+
### allowBatchAssign
94+
95+
Examples of :+1: **correct** code for the `"exports"` and `{"allowBatchAssign": true}` option:
9096

9197
```js
9298
/*eslint exports-style: ["error", "exports", {"allowBatchAssign": true}]*/

docs/rules/no-deprecated-api.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ The community is going to remove those API from Node in future, so we should not
55

66
## Rule Details
77

8-
The following patterns are considered problems:
8+
Examples of :-1: **incorrect** code for this rule:
99

1010
```js
11-
/*eslint no-deprecated-api: 2*/
11+
/*eslint node/no-deprecated-api: "error" */
1212

1313
var fs = require("fs");
1414
fs.exists("./foo.js", function() {}); /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
1515

1616
// Also, it can report the following patterns.
17-
var exists = require("fs").exists; /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
18-
const {exists} = require("fs"); /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
17+
var exists = require("fs").exists; /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
18+
const {exists} = require("fs"); /*ERROR: 'fs.exists' was deprecated since v4. Use 'fs.stat()' or 'fs.access()' instead.*/
1919

2020

2121
// And other deprecated API below.
@@ -24,7 +24,7 @@ const {exists} = require("fs"); /*ERROR: 'fs.exists' was deprecated since v4. Us
2424
This rule reports the following deprecated API.
2525

2626
- buffer
27-
- [Buffer constructors](https://nodejs.org/dist/v6.0.0/docs/api/buffer.html#buffer_class_buffer)
27+
- [Buffer constructors](https://nodejs.org/dist/v6.0.0/docs/api/buffer.html#buffer_class_buffer) (You can use [safe-buffer](https://www.npmjs.com/package/safe-buffer) module for `Node@<6.0.0`)
2828
- [SlowBuffer class](https://nodejs.org/dist/v6.0.0/docs/api/buffer.html#buffer_class_slowbuffer)
2929
- crypto
3030
- [createCredentials](https://nodejs.org/dist/v0.12.0/docs/api/crypto.html#crypto_crypto_createcredentials_details)
@@ -33,7 +33,6 @@ This rule reports the following deprecated API.
3333
- [EventEmitter.listenerCount](https://nodejs.org/dist/v4.0.0/docs/api/events.html#events_class_method_eventemitter_listenercount_emitter_event)
3434
- fs
3535
- [exists](https://nodejs.org/dist/v4.0.0/docs/api/fs.html#fs_fs_exists_path_callback)
36-
- [existsSync](https://nodejs.org/dist/v4.0.0/docs/api/fs.html#fs_fs_existssync_path)
3736
- globals
3837
- [require.extensions](https://nodejs.org/dist/v0.12.0/docs/api/globals.html#globals_require_extensions)
3938
- http
@@ -74,7 +73,9 @@ This rule reports the following deprecated API.
7473

7574
## Known Limitations
7675

77-
### Cannot report non-static properties:
76+
This rule cannot report the following cases:
77+
78+
### non-static properties
7879

7980
- cluster
8081
- [worker.suicide](https://nodejs.org/dist/v6.0.0/docs/api/cluster.html#cluster_worker_suicide)
@@ -83,14 +84,14 @@ This rule reports the following deprecated API.
8384
- net
8485
- [server.connections](https://nodejs.org/dist/v0.10.0/docs/api/net.html#net_server_connections)
8586

86-
### Cannot report dynamic things:
87+
### dynamic things
8788

8889
```js
8990
require(foo).aDeprecatedProperty;
9091
require("http")[A_DEPRECATED_PROPERTY]();
9192
```
9293

93-
### Cannot understand assignments to properties:
94+
### assignments
9495

9596
```js
9697
var obj = {
@@ -105,22 +106,16 @@ obj.Buffer = require("buffer").Buffer
105106
new obj.Buffer(); /* missing. */
106107
```
107108

108-
### Cannot understand assignments to arguments:
109-
110109
```js
111110
(function(Buffer) {
112111
new Buffer(); /* missing. */
113112
})(require("buffer").Buffer);
114113
```
115114

116-
### Cannot understand reassignments:
115+
### reassignments
117116

118117
```js
119118
var Buffer = require("buffer").Buffer;
120119
Buffer = require("another-buffer");
121120
new Buffer(); /*ERROR: 'buffer.Buffer' constructor was deprecated.*/
122121
```
123-
124-
## When Not To Use It
125-
126-
If you don't want to be warned on deprecated API, then it's safe to disable this rule.

docs/rules/no-missing-import.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@
22

33
This is similar to [no-missing-require](no-missing-require.md), but this rule handles `import` and `export` declarations.
44

5-
**⚠ NOTE:** ECMAScript 2015 (ES6) does not define the lookup logic and Node does not support modules yet. So this rule spec might be changed in future.
5+
:warning: ECMAScript "error"015 (ES6) does not define the lookup logic and Node does not support modules yet. So this rule spec might be changed in future.
66

77
## Rule Details
88

99
This rule checks the file paths of `import` and `export` declarations.
1010
If the file paths don't exist, this reports these.
1111

12-
The following patterns are considered problems:
12+
Examples of :-1: **incorrect** code for this rule:
1313

1414
```js
15-
/*eslint node/no-missing-import: 2*/
15+
/*eslint node/no-missing-import: "error" */
1616

17-
import typoFile from "./typo-file"; /*error "./typo-file" is not found.*/
18-
import typoModule from "typo-module"; /*error "typo-module" is not found.*/
17+
import typoFile from "./typo-file"; /*ERROR: "./typo-file" is not found.*/
18+
import typoModule from "typo-module"; /*ERROR: "typo-module" is not found.*/
1919
```
2020

21-
The following patterns are not considered problems:
21+
Examples of :+1: **correct** code for this rule:
2222

2323
```js
24-
/*eslint node/no-missing-import: 2*/
24+
/*eslint node/no-missing-import: "error" */
2525

2626
import existingFile from "./existing-file";
2727
import existingModule from "existing-module";
2828
```
2929

30-
### Options
30+
## Options
3131

3232
```json
3333
{
3434
"rules": {
35-
"node/no-missing-import": [2, {
35+
"node/no-missing-import": ["error", {
3636
"allowModules": [],
3737
"tryExtensions": [".js", ".json", ".node"]
3838
}]
3939
}
4040
}
4141
```
4242

43-
#### `allowModules`
43+
### allowModules
4444

4545
Some platforms have additional embedded modules.
4646
For example, Electron has `electron` module.
@@ -51,21 +51,21 @@ This option is an array of strings as module names.
5151
```json
5252
{
5353
"rules": {
54-
"node/no-missing-import": [2, {
54+
"node/no-missing-import": ["error", {
5555
"allowModules": ["electron"]
5656
}]
5757
}
5858
}
5959
```
6060

61-
#### `tryExtensions`
61+
### tryExtensions
6262

6363
When an import path does not exist, this rule checks whether or not any of `path.js`, `path.json`, and `path.node` exists.
6464
`tryExtensions` option is the extension list this rule uses at the time.
6565

6666
Default is `[".js", ".json", ".node"]`.
6767

68-
### Shared Settings
68+
## Shared Settings
6969

7070
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
7171
Several rules have the same option, but we can set this option at once.
@@ -82,13 +82,7 @@ Several rules have the same option, but we can set this option at once.
8282
}
8383
},
8484
"rules": {
85-
"node/no-missing-import": 2
85+
"node/no-missing-import": "error"
8686
}
8787
}
8888
```
89-
90-
## When Not To Use It
91-
92-
This rule should not be used in ES3/5 environments.
93-
94-
If you don't want to be notified about usage of `import` and `export` declarations, then it's safe to disable this rule.

docs/rules/no-missing-require.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@ const foo = require("./foo");
99

1010
## Rule Details
1111

12-
This rule checks the file paths of `require()`s.
13-
If the file paths don't exist, this reports these.
12+
This rule checks the file paths of `require()`s, then reports the path of files which don't exist.
1413

15-
The following patterns are considered problems:
14+
Examples of :-1: **incorrect** code for this rule:
1615

1716
```js
18-
/*eslint node/no-missing-require: 2*/
17+
/*eslint node/no-missing-require: "error" */
1918

2019
var typoFile = require("./typo-file"); /*error "./typo-file" is not found.*/
2120
var typoModule = require("typo-module"); /*error "typo-module" is not found.*/
2221
```
2322

24-
The following patterns are not considered problems:
23+
Examples of :+1: **correct** code for this rule:
2524

2625
```js
27-
/*eslint node/no-missing-require: 2*/
26+
/*eslint node/no-missing-require: "error" */
2827

2928
var existingFile = require("./existing-file");
3029
var existingModule = require("existing-module");
@@ -33,20 +32,20 @@ var existingModule = require("existing-module");
3332
var foo = require(FOO_NAME);
3433
```
3534

36-
### Options
35+
## Options
3736

3837
```json
3938
{
4039
"rules": {
41-
"node/no-missing-require": [2, {
40+
"node/no-missing-require": ["error", {
4241
"allowModules": [],
4342
"tryExtensions": [".js", ".json", ".node"]
4443
}]
4544
}
4645
}
4746
```
4847

49-
#### `allowModules`
48+
### allowModules
5049

5150
Some platforms have additional embedded modules.
5251
For example, Electron has `electron` module.
@@ -57,21 +56,21 @@ This option is an array of strings as module names.
5756
```json
5857
{
5958
"rules": {
60-
"node/no-missing-require": [2, {
59+
"node/no-missing-require": ["error", {
6160
"allowModules": ["electron"]
6261
}]
6362
}
6463
}
6564
```
6665

67-
#### `tryExtensions`
66+
### tryExtensions
6867

6968
When an import path does not exist, this rule checks whether or not any of `path.js`, `path.json`, and `path.node` exists.
7069
`tryExtensions` option is the extension list this rule uses at the time.
7170

7271
Default is `[".js", ".json", ".node"]`.
7372

74-
### Shared Settings
73+
## Shared Settings
7574

7675
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
7776
Several rules have the same option, but we can set this option at once.
@@ -88,11 +87,7 @@ Several rules have the same option, but we can set this option at once.
8887
}
8988
},
9089
"rules": {
91-
"node/no-missing-require": 2
90+
"node/no-missing-require": "error"
9291
}
9392
}
9493
```
95-
96-
## When Not To Use It
97-
98-
If you don't want to be notified about usage of `require()`, then it's safe to disable this rule.

docs/rules/no-unpublished-bin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If `npm` ignores the files in `bin` field, this rule warns the files.
3030
}
3131
```
3232

33-
### `convertPath`
33+
### convertPath
3434

3535
If we use transpilers (e.g. Babel), perhaps the file path to a source code is never published.
3636
`convertPath` option tells to the rule, it needs to convert file paths.

0 commit comments

Comments
 (0)