Skip to content

Commit

Permalink
πŸ“ update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed May 3, 2019
1 parent ab40a47 commit a4fbb9a
Show file tree
Hide file tree
Showing 37 changed files with 329 additions and 62 deletions.
10 changes: 8 additions & 2 deletions docs/rules/exports-style.md
@@ -1,4 +1,5 @@
# enforce either `module.exports` or `exports` (exports-style)
# node/exports-style
> enforce either `module.exports` or `exports`
`module.exports` and `exports` are the same instance by default.
But those come to be different if one of them is modified.
Expand All @@ -13,7 +14,7 @@ exports.bar = 2

In this case, `exports.bar` will be lost since only the instance of `module.exports` will be exported.

## Rule Details
## πŸ“– Rule Details

This rule enforces the export style.

Expand Down Expand Up @@ -104,3 +105,8 @@ module.exports = exports = function foo() {

exports.bar = 1
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/exports-style.js)
- [Test source](../../tests/lib/rules/exports-style.js)
12 changes: 10 additions & 2 deletions docs/rules/file-extension-in-import.md
@@ -1,4 +1,7 @@
# enforce the style of file extensions in `import` declarations (file-extension-in-import)
# node/file-extension-in-import
> enforce the style of file extensions in `import` declarations
- βœ’οΈ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.

We can omit file extensions in `import`/`export` declarations.

Expand All @@ -11,7 +14,7 @@ However, [--experimental-modules](https://medium.com/@nodejs/announcing-a-new-ex

Also, we can import a variety kind of files with bundlers such as Webpack. In the situation, probably explicit file extensions help us to understand code.

## Rule Details
## πŸ“– Rule Details

This rule enforces the style of file extensions in `import`/`export` declarations.

Expand Down Expand Up @@ -108,3 +111,8 @@ module.exports = {
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/file-extension-in-import.js)
- [Test source](../../tests/lib/rules/file-extension-in-import.js)
12 changes: 10 additions & 2 deletions docs/rules/no-deprecated-api.md
@@ -1,9 +1,12 @@
# Disallow deprecated API (no-deprecated-api)
# node/no-deprecated-api
> disallow deprecated APIs
- ⭐️ This rule is included in `plugin:node/recommended` preset.

Node has many deprecated API.
The community is going to remove those API from Node in future, so we should not use those.

## Rule Details
## πŸ“– Rule Details

Examples of :-1: **incorrect** code for this rule:

Expand Down Expand Up @@ -357,3 +360,8 @@ var Buffer = require("buffer").Buffer;
Buffer = require("another-buffer");
new Buffer(); /*ERROR: 'buffer.Buffer' constructor was deprecated.*/
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-deprecated-api.js)
- [Test source](../../tests/lib/rules/no-deprecated-api.js)
10 changes: 8 additions & 2 deletions docs/rules/no-extraneous-import.md
@@ -1,9 +1,10 @@
# Disallow `import` declarations which import extraneous modules (no-extraneous-import)
# node/no-extraneous-import
> disallow `import` declarations which import extraneous modules
If an `import` declaration's source is extraneous (it's not written in `package.json`), the program works in local, but will not work after dependencies are re-installed. It will cause troubles to your team/contributors.
This rule disallows `import` declarations of extraneous modules.

## Rule Details
## πŸ“– Rule Details

This rule warns `import` declarations of extraneous modules.

Expand Down Expand Up @@ -77,3 +78,8 @@ module.exports = {
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-extraneous-import.js)
- [Test source](../../tests/lib/rules/no-extraneous-import.js)
12 changes: 10 additions & 2 deletions docs/rules/no-extraneous-require.md
@@ -1,9 +1,12 @@
# Disallow `require()`s which import extraneous modules (no-extraneous-require)
# node/no-extraneous-require
> disallow `require()` expressions which import extraneous modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.

If a `require()`'s target is extraneous (it's not written in `package.json`), the program works in local, but will not work after dependencies are re-installed. It will cause troubles to your team/contributors.
This rule disallows `require()` of extraneous modules.

## Rule Details
## πŸ“– Rule Details

This rule warns `require()` of extraneous modules.

Expand Down Expand Up @@ -77,3 +80,8 @@ module.exports = {
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-extraneous-require.js)
- [Test source](../../tests/lib/rules/no-extraneous-require.js)
12 changes: 10 additions & 2 deletions docs/rules/no-hide-core-modules.md
@@ -1,4 +1,7 @@
# Disallow third-party modules which are hiding core modules (node/no-hide-core-modules)
# node/no-hide-core-modules
> disallow third-party modules which are hiding core modules
- β›” This rule has been deprecated.

**:warning: This is deprecated since v4.2.0.** This rule was based on an invalid assumption. See also [#69](https://github.com/mysticatea/eslint-plugin-node/issues/69).

Expand All @@ -8,7 +11,7 @@ This might cause unintentional behaviors.

This rule warns `require()` expressions and `import` declarations if those import a third-party module which has the same name as core modules.

## Rule Details
## πŸ“– Rule Details

:-1: Examples of **incorrect** code for this rule:

Expand Down Expand Up @@ -58,3 +61,8 @@ This option would allow all explicit dependencies which are hiding core modules.
If `ignoreIndirectDependencies: true`, if the third-party module which has the same name as a core module does not exist in your `package.json`, this rule ignores it.

This option would allow all implicit dependencies which are hiding core modules.

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-hide-core-modules.js)
- [Test source](../../tests/lib/rules/no-hide-core-modules.js)
10 changes: 8 additions & 2 deletions docs/rules/no-missing-import.md
@@ -1,10 +1,11 @@
# Disallow `import` and `export` declarations for files that don't exist (no-missing-import)
# node/no-missing-import
> disallow `import` declarations which import non-existence modules
This is similar to [no-missing-require](no-missing-require.md), but this rule handles `import` and `export` declarations.

:warning: 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.

## Rule Details
## πŸ“– Rule Details

This rule checks the file paths of `import` and `export` declarations.
If the file paths don't exist, this reports these.
Expand Down Expand Up @@ -97,3 +98,8 @@ module.exports = {
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-missing-import.js)
- [Test source](../../tests/lib/rules/no-missing-import.js)
12 changes: 10 additions & 2 deletions docs/rules/no-missing-require.md
@@ -1,4 +1,7 @@
# Disallow `require()`s for files that don't exist (no-missing-require)
# node/no-missing-require
> disallow `require()` expressions which import non-existence modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.

Maybe we cannot find typo of import paths until run it, so this rule checks import paths.

Expand All @@ -7,7 +10,7 @@ Maybe we cannot find typo of import paths until run it, so this rule checks impo
const foo = require("./foo");
```

## Rule Details
## πŸ“– Rule Details

This rule checks the file paths of `require()`s, then reports the path of files which don't exist.

Expand Down Expand Up @@ -102,3 +105,8 @@ module.exports = {
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-missing-require.js)
- [Test source](../../tests/lib/rules/no-missing-require.js)
12 changes: 10 additions & 2 deletions docs/rules/no-unpublished-bin.md
@@ -1,4 +1,7 @@
# disallow 'bin' files that npm ignores (no-unpublished-bin)
# node/no-unpublished-bin
> disallow `bin` files that npm ignores
- ⭐️ This rule is included in `plugin:node/recommended` preset.

We can publish CLI commands by `npm`. It uses `bin` field of `package.json`.

Expand All @@ -11,7 +14,7 @@ We can publish CLI commands by `npm`. It uses `bin` field of `package.json`.

At this time, if `npm` ignores the file, your package will fail to install.

## Rule Details
## πŸ“– Rule Details

If `npm` ignores the files in `bin` field, this rule warns the files.

Expand Down Expand Up @@ -107,3 +110,8 @@ For Example:
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-unpublished-bin.js)
- [Test source](../../tests/lib/rules/no-unpublished-bin.js)
10 changes: 8 additions & 2 deletions docs/rules/no-unpublished-import.md
@@ -1,10 +1,11 @@
# Disallow `import` declarations which import unpublished files/modules (no-unpublished-import)
# node/no-unpublished-import
> disallow `import` declarations which import private modules
This is similar to [no-unpublished-require](no-unpublished-require.md), but this rule handles `import` declarations.

:warning: 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.

## Rule Details
## πŸ“– Rule Details

If a source code file satisfies all of the following conditions, the file is \*published\*.

Expand Down Expand Up @@ -136,3 +137,8 @@ For Example:
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-unpublished-import.js)
- [Test source](../../tests/lib/rules/no-unpublished-import.js)
12 changes: 10 additions & 2 deletions docs/rules/no-unpublished-require.md
@@ -1,9 +1,12 @@
# Disallow `require()` expressions which import unpublished files/modules (no-unpublished-require)
# node/no-unpublished-require
> disallow `require()` expressions which import private modules
- ⭐️ This rule is included in `plugin:node/recommended` preset.

If a `require()` expression's target is not published, the program works in local, but will not work after published to npm.
This rule disallows `require()` expressions of unpublished files/modules.

## Rule Details
## πŸ“– Rule Details

If a source code file satisfies all of the following conditions, the file is \*published\*.

Expand Down Expand Up @@ -135,3 +138,8 @@ For Example:
}
}
```

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-unpublished-require.js)
- [Test source](../../tests/lib/rules/no-unpublished-require.js)
12 changes: 10 additions & 2 deletions docs/rules/no-unsupported-features.md
@@ -1,4 +1,7 @@
# Disallow unsupported ECMAScript features on the specified version (no-unsupported-features)
# node/no-unsupported-features
> disallow unsupported ECMAScript features on the specified version
- β›” This rule has been deprecated. Use [node/no-unsupported-features/es-syntax](./node/no-unsupported-features/es-syntax.md) and [node/no-unsupported-features/es-builtins](./node/no-unsupported-features/es-builtins.md) instead.

**:warning: This is deprecated since v7.0.0.** Use [node/no-unsupported-features/es-syntax](./no-unsupported-features/es-syntax.md) and [node/no-unsupported-features/es-builtins](./no-unsupported-features/es-builtins.md) instead.

Expand All @@ -8,7 +11,7 @@ This rule reports when you used unsupported ECMAScript 2015-2018 features on the
> β€» About ECMAScript 2018, this rule reports only features which have arrived at stage 4 until 2018-02-01.
> It needs a major version bump in order to cover newer features.
## Rule Details
## πŸ“– Rule Details

:warning: This rule expects to be used with the following configuration:

Expand Down Expand Up @@ -299,3 +302,8 @@ E.g., a use of instance methods.
- http://node.green/

[engines]: https://docs.npmjs.com/files/package.json#engines

## πŸ”Ž Implementation

- [Rule source](../../lib/rules/no-unsupported-features.js)
- [Test source](../../tests/lib/rules/no-unsupported-features.js)
12 changes: 10 additions & 2 deletions docs/rules/no-unsupported-features/es-builtins.md
@@ -1,12 +1,15 @@
# Disallow unsupported ECMAScript features on the specified version (no-unsupported-features/es-builtins)
# node/no-unsupported-features/es-builtins
> disallow unsupported ECMAScript built-ins on the specified version
- ⭐️ This rule is included in `plugin:node/recommended` preset.

ECMAScript standard is updating every two months.
You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature.

This rule reports unsupported ECMAScript built-in variables on the configured Node.js version as lint errors.
Editor integrations of ESLint would be useful to know it in real-time.

## Rule Details
## πŸ“– Rule Details

### Supported ECMAScript features

Expand Down Expand Up @@ -139,3 +142,8 @@ For example:
- New events.

[engines]: https://docs.npmjs.com/files/package.json#engines

## πŸ”Ž Implementation

- [Rule source](../../../lib/rules/no-unsupported-features/es-builtins.js)
- [Test source](../../../tests/lib/rules/no-unsupported-features/es-builtins.js)
12 changes: 10 additions & 2 deletions docs/rules/no-unsupported-features/es-syntax.md
@@ -1,12 +1,15 @@
# Disallow unsupported ECMAScript syntax on the specified version (no-unsupported-features/es-syntax)
# node/no-unsupported-features/es-syntax
> disallow unsupported ECMAScript syntax on the specified version
- ⭐️ This rule is included in `plugin:node/recommended` preset.

ECMAScript standard is updating every two months.
You can check [node.green](https://node.green/) to know which Node.js version supports each ECMAScript feature.

This rule reports unsupported ECMAScript syntax on the configured Node.js version as lint errors.
Editor integrations of ESLint would be useful to know it in real-time.

## Rule Details
## πŸ“– Rule Details

### Supported ECMAScript features

Expand Down Expand Up @@ -113,3 +116,8 @@ The `"ignores"` option accepts an array of the following strings.
</details>

[engines]: https://docs.npmjs.com/files/package.json#engines

## πŸ”Ž Implementation

- [Rule source](../../../lib/rules/no-unsupported-features/es-syntax.js)
- [Test source](../../../tests/lib/rules/no-unsupported-features/es-syntax.js)
12 changes: 10 additions & 2 deletions docs/rules/no-unsupported-features/node-builtins.md
@@ -1,12 +1,15 @@
# Disallow unsupported Node.js built-in APIs on the specified version (no-unsupported-features/node-builtins)
# node/no-unsupported-features/node-builtins
> disallow unsupported Node.js built-in APIs on the specified version
- ⭐️ This rule is included in `plugin:node/recommended` preset.

Node.js community is improving built-in APIs continuously.
You can check [Node.js Documentation](https://nodejs.org/api/) to know which Node.js version supports each Node.js API.

This rule reports unsupported Node.js built-in APIs on the configured Node.js version as lint errors.
Editor integrations of ESLint would be useful to know it in real-time.

## Rule Details
## πŸ“– Rule Details

This rule reports APIs of Node.js built-in APIs on the basis of [Node.js v12.0.0 Documentation](https://nodejs.org/docs/v12.0.0/api/).

Expand Down Expand Up @@ -319,3 +322,8 @@ For example:
- New events.

[engines]: https://docs.npmjs.com/files/package.json#engines

## πŸ”Ž Implementation

- [Rule source](../../../lib/rules/no-unsupported-features/node-builtins.js)
- [Test source](../../../tests/lib/rules/no-unsupported-features/node-builtins.js)

0 comments on commit a4fbb9a

Please sign in to comment.