Skip to content

Commit e85c694

Browse files
bmishljharb
authored andcommitted
[Docs] automate docs with eslint-doc-generator
1 parent c3d14cb commit e85c694

File tree

95 files changed

+344
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+344
-141
lines changed

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"eslint-plugin/no-deprecated-report-api": "off",
7272
"eslint-plugin/prefer-replace-text": "error",
7373
"eslint-plugin/report-message-format": "error",
74+
"eslint-plugin/require-meta-docs-description": ["error", { "pattern": "^(Enforce|Ensure|Prefer|Forbid).+\\.$" }],
7475
"eslint-plugin/require-meta-schema": "error",
7576
"eslint-plugin/require-meta-type": "error",
7677

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
4545
- [readme] make json for setting groups multiline ([#2570], thanks [@bertyhell])
4646
- [Tests] [`no-restricted-paths`]: Tests for `import type` statements ([#2459], thanks [@golergka])
4747
- [Tests] [`no-restricted-paths`]: fix one failing `import type` test case, submitted by [@golergka], thanks [@azyzz228]
48+
- [Docs] automate docs with eslint-doc-generator ([#2582], thanks [@bmish])
4849

4950
## [2.26.0] - 2022-04-05
5051

CONTRIBUTING.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ Thanks for your interest in helping out! Here are a **few** _weird_ tricks to ~~
55
## TL;DR: Checklist
66

77
When opening an [issue](#issues):
8+
89
- [ ] search open/closed issues
910
- [ ] discuss bug/enhancement in new or old issue
1011

1112
[PR](#prs) time:
13+
1214
- [ ] write tests
1315
- [ ] implement feature/fix bug
1416
- [ ] update docs
@@ -18,13 +20,13 @@ Remember, you don't need to do it all yourself; any of these are helpful! 😎
1820

1921
## Issues
2022

21-
### Search open + closed issues for similar cases.
23+
### Search open + closed issues for similar cases
2224

2325
You may find an open issue that closely matches what you are thinking. You may also find a closed issue with discussion that either solves your problem or explains why we are unlikely to solve it in the near future.
2426

2527
If you find a matching issue that is open, and marked `accepted` and/or `help wanted`, you might want to [open a PR](#prs).
2628

27-
### Open an issue.
29+
### Open an issue
2830

2931
Let's discuss your issue. Could be as simple as unclear documentation or a wonky config file.
3032
If you're suggesting a feature, it might exist and need better documentation, or it might be in process. Even given those, some discussion might be warranted to ensure the enhancement is clear.
@@ -48,21 +50,19 @@ Here are some things to keep in mind when working on a PR:
4850
If a PR is open, but unfortunately the author is, for any reason, not available to apply code review fixes or rebase the source branch, then please **do not open a new PR**.
4951
Instead, paste a link to your own branch in the PR, and the maintainers can pull in your changes and update the existing PR in-place.
5052

51-
#### Tests
53+
### Tests
5254

5355
A PR that is just failing test cases for an existing issue is very helpful, as this can take as much time (if not more) as it takes to implement a new feature or fix a bug.
5456

5557
If you only have enough time to write tests, fantastic! Submit away. This is a great jumping-off point for a core contributor or even another PR to continue what you've started.
5658

57-
#### Docs
58-
59-
For enhancements to rules, please update the docs in `docs/rules` matching the rule filename from `src/rules`.
59+
### Docs
6060

61-
Also, take a quick look at the rule summary in [README.md] in case it could use tweaking, or add a line if you've implemented a new rule.
61+
For enhancements to rules, please update the docs in `docs/rules` matching the rule filename from `src/rules` or the rule description in `meta.docs.description`. Running `npm run update:eslint-docs` will update the [README.md] and rule doc header.
6262

6363
Bugfixes may not warrant docs changes, though it's worth skimming the existing docs to see if there are any relevant caveats that need to be removed.
6464

65-
#### Changelog
65+
### Changelog
6666

6767
Please add a quick blurb to the [**Unreleased**](./CHANGELOG.md#unreleased) section of the change log. Give yourself some credit, and please link back to the PR for future reference. This is especially helpful for resolver changes, as the resolvers are less frequently modified and published.
6868

@@ -72,4 +72,4 @@ Note also that the change log can't magically link back to Github entities (i.e.
7272

7373
Please familiarize yourself with the [Code of Conduct](https://github.com/import-js/.github/blob/main/CODE_OF_CONDUCT.md).
7474

75-
[README.md]: ./README.md
75+
[README.md]: ./README.md

README.md

+80-107
Large diffs are not rendered by default.

docs/rules/consistent-type-specifier-style.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/consistent-type-specifier-style
22

3+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4+
5+
<!-- end auto-generated rule header -->
6+
37
In both Flow and TypeScript you can mark an import as a type-only import by adding a "kind" marker to the import. Both languages support two positions for marker.
48

59
**At the top-level** which marks all names in the import as type-only and applies to named, default, and namespace (for TypeScript) specifiers:

docs/rules/default.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/default
22

3+
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
If a default import is requested, this rule will report if there is no default
48
export in the imported module.
59

docs/rules/dynamic-import-chunkname.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/dynamic-import-chunkname
22

3+
<!-- end auto-generated rule header -->
4+
35
This rule reports any dynamic imports without a webpackChunkName specified in a leading block comment in the proper format.
46

57
This rule enforces naming of webpack chunks in dynamic imports. When you don't explicitly name chunks, webpack will autogenerate chunk names that are not consistent across builds, which prevents long-term browser caching.

docs/rules/export.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/export
22

3+
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Reports funny business with exports, like repeated exports of names or defaults.
48

59
## Rule Details

docs/rules/exports-last.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/exports-last
22

3+
<!-- end auto-generated rule header -->
4+
35
This rule enforces that all exports are declared at the bottom of the file. This rule will report any export declarations that comes before any non-export statements.
46

57

docs/rules/extensions.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# import/extensions - Ensure consistent use of file extension within the import path
1+
# import/extensions
2+
3+
<!-- end auto-generated rule header -->
24

35
Some file resolve algorithms allow you to omit the file extension within the import source path. For example the `node` resolver can resolve `./foo/bar` to the absolute path `/User/someone/foo/bar.js` because the `.js` extension is resolved automatically by default. Depending on the resolver you can configure more extensions to get resolved automatically.
46

@@ -37,6 +39,7 @@ By providing both a string and an object, the string will set the default settin
3739
For example, `["error", "never", { "svg": "always" }]` would require that all extensions are omitted, except for "svg".
3840

3941
`ignorePackages` can be set as a separate boolean option like this:
42+
4043
```
4144
"import/extensions": [
4245
<severity>,
@@ -49,10 +52,10 @@ For example, `["error", "never", { "svg": "always" }]` would require that all ex
4952
}
5053
]
5154
```
55+
5256
In that case, if you still want to specify extensions, you can do so inside the **pattern** property.
5357
Default value of `ignorePackages` is `false`.
5458

55-
5659
### Exception
5760

5861
When disallowing the use of certain extensions this rule makes an exception and allows the use of extension when the file would not be resolvable without extension.

docs/rules/first.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/first
22

3+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4+
5+
<!-- end auto-generated rule header -->
6+
37
This rule reports any imports that come after non-import
48
statements.
59

docs/rules/group-exports.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/group-exports
22

3+
<!-- end auto-generated rule header -->
4+
35
Reports when named exports are not grouped together in a single `export` declaration or when multiple assignments to CommonJS `module.exports` or `exports` object are present in a single file.
46

57
**Rationale:** An `export` declaration or `module.exports` assignment can appear anywhere in the code. By requiring a single export declaration all your exports will remain at one place, making it easier to see what exports a module provides.

docs/rules/imports-first.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# import/imports-first
22

3+
❌ This rule is deprecated.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
39
This rule was **deprecated** in eslint-plugin-import v2.0.0. Please use the corresponding rule [`first`](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/first.md).

docs/rules/max-dependencies.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/max-dependencies
22

3+
<!-- end auto-generated rule header -->
4+
35
Forbid modules to have too many dependencies (`import` or `require` statements).
46

57
This is a useful rule because a module with too many dependencies is a code smell, and usually indicates the module is doing too much and/or should be broken up into smaller modules.

docs/rules/named.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/named
22

3+
💼🚫 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`. This rule is _disabled_ in the ⌨️ `typescript` config.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Verifies that all named imports are part of the set of named exports in the referenced module.
48

59
For `export`, verifies that all named exports exist in the referenced module.

docs/rules/namespace.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/namespace
22

3+
💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Enforces names exist at the time they are dereferenced, when imported as a full namespace (i.e. `import * as foo from './foo'; foo.bar();` will report if `bar` is not exported by `./foo`.).
48

59
Will report at the import declaration if there are _no_ exported names found.

docs/rules/newline-after-import.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/newline-after-import
22

3+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4+
5+
<!-- end auto-generated rule header -->
6+
37
Enforces having one or more empty lines after the last top-level import statement or require call.
48
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.
59

docs/rules/no-absolute-path.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# import/no-absolute-path: Forbid import of modules using absolute paths
1+
# import/no-absolute-path
2+
3+
<!-- end auto-generated rule header -->
24

35
Node.js allows the import of modules using an absolute path such as `/home/xyz/file.js`. That is a bad practice as it ties the code using it to your computer, and therefore makes it unusable in packages distributed on `npm` for instance.
46

7+
This rule forbids the import of modules using absolute paths.
8+
59
## Rule Details
610

711
### Fail

docs/rules/no-amd.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-amd
22

3+
<!-- end auto-generated rule header -->
4+
35
Reports `require([array], ...)` and `define([array], ...)` function calls at the
46
module scope. Will not report if !=2 arguments, or first argument is not a literal array.
57

docs/rules/no-anonymous-default-export.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-anonymous-default-export
22

3+
<!-- end auto-generated rule header -->
4+
35
Reports if a module's default export is unnamed. This includes several types of unnamed data types; literals, object expressions, arrays, anonymous functions, arrow functions, and anonymous class declarations.
46

57
Ensuring that default exports are named helps improve the grepability of the codebase by encouraging the re-use of the same identifier for the module's default export at its declaration site and at its import sites.

docs/rules/no-commonjs.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-commonjs
22

3+
<!-- end auto-generated rule header -->
4+
35
Reports `require([string])` function calls. Will not report if >1 argument,
46
or single argument is not a literal string.
57

docs/rules/no-cycle.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-cycle
22

3+
<!-- end auto-generated rule header -->
4+
35
Ensures that there is no resolvable path back to this module via its dependencies.
46

57
This includes cycles of depth 1 (imported module imports me) to `"∞"` (or `Infinity`), if the

docs/rules/no-default-export.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# `import/no-default-export`
1+
# import/no-default-export
2+
3+
<!-- end auto-generated rule header -->
24

35
Prohibit default exports. Mostly an inverse of [`prefer-default-export`].
46

docs/rules/no-deprecated.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# `import/no-deprecated`
1+
# import/no-deprecated
2+
3+
<!-- end auto-generated rule header -->
24

35
Reports use of a deprecated name, as indicated by a JSDoc block with a `@deprecated`
46
tag or TomDoc `Deprecated: ` comment.

docs/rules/no-duplicates.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# import/no-duplicates
22

3+
⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
39
Reports if a resolved path is imported more than once.
410
+(fixable) The `--fix` option on the [command line] automatically fixes some problems reported by this rule.
511

docs/rules/no-dynamic-require.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# import/no-dynamic-require: Forbid `require()` calls with expressions
1+
# import/no-dynamic-require
2+
3+
<!-- end auto-generated rule header -->
24

35
The `require` method from CommonJS is used to import modules from different files. Unlike the ES6 `import` syntax, it can be given expressions that will be resolved at runtime. While this is sometimes necessary and useful, in most cases it isn't. Using expressions (for instance, concatenating a path and variable) as the argument makes it harder for tools to do static code analysis, or to find where in the codebase a module is used.
46

5-
This rule checks every call to `require()` that uses expressions for the module name argument.
7+
This rule forbids every call to `require()` that uses expressions for the module name argument.
68

79
## Rule Details
810

docs/rules/no-empty-named-blocks.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/no-empty-named-blocks
22

3+
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
4+
5+
<!-- end auto-generated rule header -->
6+
37
Reports the use of empty named import blocks.
48

59
## Rule Details

docs/rules/no-extraneous-dependencies.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# import/no-extraneous-dependencies: Forbid the use of extraneous packages
1+
# import/no-extraneous-dependencies
2+
3+
<!-- end auto-generated rule header -->
24

35
Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies`, `peerDependencies`, or `bundledDependencies`.
46
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behavior can be changed with the rule option `packageDir`. Normally ignores imports of modules marked internal, but this can be changed with the rule option `includeInternal`. Type imports can be verified by specifying `includeTypes`.

docs/rules/no-import-module-exports.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/no-import-module-exports
22

3+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4+
5+
<!-- end auto-generated rule header -->
6+
37
Reports the use of import declarations with CommonJS exports in any module
48
except for the [main module](https://docs.npmjs.com/files/package.json#main).
59

docs/rules/no-internal-modules.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-internal-modules
22

3+
<!-- end auto-generated rule header -->
4+
35
Use this rule to prevent importing the submodules of other modules.
46

57
## Rule Details

docs/rules/no-mutable-exports.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-mutable-exports
22

3+
<!-- end auto-generated rule header -->
4+
35
Forbids the use of mutable exports with `var` or `let`.
46

57
## Rule Details

docs/rules/no-named-as-default-member.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/no-named-as-default-member
22

3+
⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Reports use of an exported name as a property on the default export.
48

59
Rationale: Accessing a property that has a name that is shared by an exported

docs/rules/no-named-as-default.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/no-named-as-default
22

3+
⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Reports use of an exported name as the locally imported name of a default export.
48

59
Rationale: using an exported name as the name of the default export is likely...

docs/rules/no-named-default.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# import/no-named-default
22

3+
<!-- end auto-generated rule header -->
4+
35
Reports use of a default export as a locally named import.
46

57
Rationale: the syntax exists to import default exports expressively, let's use it.

docs/rules/no-named-export.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# `import/no-named-export`
1+
# import/no-named-export
2+
3+
<!-- end auto-generated rule header -->
24

35
Prohibit named exports. Mostly an inverse of [`no-default-export`].
46

docs/rules/no-namespace.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# import/no-namespace
22

3+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4+
5+
<!-- end auto-generated rule header -->
6+
37
Enforce a convention of not using namespace (a.k.a. "wildcard" `*`) imports.
48

59
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule, provided that the namespace object is only used for direct member access, e.g. `namespace.a`.

0 commit comments

Comments
 (0)