Skip to content

Commit

Permalink
docs: autogenerate many rule options list with eslint-doc-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Nov 4, 2023
1 parent 6d34c88 commit 70f909c
Show file tree
Hide file tree
Showing 34 changed files with 209 additions and 89 deletions.
9 changes: 9 additions & 0 deletions docs/rules/dynamic-import-chunkname.md
Expand Up @@ -11,6 +11,15 @@ This rule enforces naming of webpack chunks in dynamic imports. When you don't e
This rule runs against `import()` by default, but can be configured to also run against an alternative dynamic-import function, e.g. 'dynamicImport.'
You can also configure the regex format you'd like to accept for the webpackChunkName - for example, if we don't want the number 6 to show up in our chunk names:

<!-- begin auto-generated rule options list -->

| Name | Type |
| :----------------------- | :------- |
| `importFunctions` | String[] |
| `webpackChunknameFormat` | String |

<!-- end auto-generated rule options list -->

```javascript
{
"dynamic-import-chunkname": [2, {
Expand Down
14 changes: 7 additions & 7 deletions docs/rules/max-dependencies.md
Expand Up @@ -10,14 +10,14 @@ Importing multiple named exports from a single module will only count once (e.g.

## Options

This rule has the following options, with these defaults:
<!-- begin auto-generated rule options list -->

```js
"import/max-dependencies": ["error", {
"max": 10,
"ignoreTypeImports": false,
}]
```
| Name | Type | Default |
| :------------------ | :------ | :------ |
| `ignoreTypeImports` | Boolean | `false` |
| `max` | Number | `10` |

<!-- end auto-generated rule options list -->

### `max`

Expand Down
10 changes: 10 additions & 0 deletions docs/rules/named.md
Expand Up @@ -86,6 +86,16 @@ then the following is not reported:
import { notWhatever } from './whatever'
```

## Options

<!-- begin auto-generated rule options list -->

| Name | Type | Default |
| :--------- | :------ | :------ |
| `commonjs` | Boolean | `false` |

<!-- end auto-generated rule options list -->

## When Not To Use It

If you are using CommonJS and/or modifying the exported namespace of any module at
Expand Down
8 changes: 8 additions & 0 deletions docs/rules/namespace.md
Expand Up @@ -79,6 +79,14 @@ function deepTrouble() {

### Options

<!-- begin auto-generated rule options list -->

| Name | Description | Type | Default |
| :-------------- | :---------------------------------------------------------------------------------------- | :------ | :------ |
| `allowComputed` | If `false`, will report computed (and thus, un-lintable) references to namespace members. | Boolean | `false` |

<!-- end auto-generated rule options list -->

#### `allowComputed`

Defaults to `false`. When false, will report the following:
Expand Down
12 changes: 7 additions & 5 deletions docs/rules/newline-after-import.md
Expand Up @@ -8,13 +8,15 @@ Enforces having one or more empty lines after the last top-level import statemen

## Rule Details

This rule supports the following options:
<!-- begin auto-generated rule options list -->

- `count` which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to `1`.
| Name | Description | Type | Default |
| :----------------- | :------------------------------------------------------------------------------------------------------- | :------ | :------ |
| `considerComments` | enforces the rule on comments after the last import-statement as well when set to true | Boolean | `false` |
| `count` | Sets the number of newlines that are enforced after the last top-level import statement or require call. | Integer | |
| `exactCount` | enforce the exact numbers of newlines that is mentioned in `count` | Boolean | `false` |

- `exactCount` which enforce the exact numbers of newlines that is mentioned in `count`. This option defaults to `false`.

- `considerComments` which enforces the rule on comments after the last import-statement as well when set to true. This option defaults to `false`.
<!-- end auto-generated rule options list -->

Valid:

Expand Down
13 changes: 10 additions & 3 deletions docs/rules/no-absolute-path.md
Expand Up @@ -38,9 +38,16 @@ By default, only ES6 imports and CommonJS `require` calls will have this rule en

You may provide an options object providing true/false for any of

- `esmodule`: defaults to `true`
- `commonjs`: defaults to `true`
- `amd`: defaults to `false`
<!-- begin auto-generated rule options list -->

| Name | Type |
| :--------- | :------- |
| `amd` | Boolean |
| `commonjs` | Boolean |
| `esmodule` | Boolean |
| `ignore` | String[] |

<!-- end auto-generated rule options list -->

If `{ amd: true }` is provided, dependency paths for AMD-style `define` and `require`
calls will be resolved:
Expand Down
14 changes: 14 additions & 0 deletions docs/rules/no-cycle.md
Expand Up @@ -28,6 +28,20 @@ This rule ignores type-only imports in Flow and TypeScript syntax (`import type`

### Options

<!-- begin auto-generated rule options list -->

| Name | Description | Type | Default |
| :----------------------------------- | :--------------------------------------------------------------------------- | :------- | :------ |
| `allowUnsafeDynamicCyclicDependency` | Allow cyclic dependency if there is at least one dynamic import in the chain | Boolean | `false` |
| `amd` | | Boolean | |
| `commonjs` | | Boolean | |
| `esmodule` | | Boolean | |
| `ignore` | | String[] | |
| `ignoreExternal` | ignore external modules | Boolean | `false` |
| `maxDepth` | | | |

<!-- end auto-generated rule options list -->

By default, this rule only detects cycles for ES6 imports, but see the [`no-unresolved` options](./no-unresolved.md#options) as this rule also supports the same `commonjs` and `amd` flags. However, these flags only impact which import types are _linted_; the
import/export infrastructure only registers `import` statements in dependencies, so
cycles created by `require` within imported modules may not be detected.
Expand Down
11 changes: 11 additions & 0 deletions docs/rules/no-duplicates.md
Expand Up @@ -42,6 +42,17 @@ The motivation is that this is likely a result of two developers importing diffe
names from the same module at different times (and potentially largely different
locations in the file.) This rule brings both (or n-many) to attention.

## Options

<!-- begin auto-generated rule options list -->

| Name | Type | Default |
| :-------------------- | :------ | :------ |
| `considerQueryString` | Boolean | `false` |
| `prefer-inline` | Boolean | `false` |

<!-- end auto-generated rule options list -->

### Query Strings

By default, this rule ignores query strings (i.e. paths followed by a question mark), and thus imports from `./mod?a` and `./mod?b` will be considered as duplicates. However you can use the option `considerQueryString` to handle them as different (primarily because browsers will resolve those imports differently).
Expand Down
10 changes: 10 additions & 0 deletions docs/rules/no-dynamic-require.md
Expand Up @@ -23,3 +23,13 @@ require(name());
require('../name');
require(`../name`);
```

## Options

<!-- begin auto-generated rule options list -->

| Name | Type | Default |
| :--------- | :------ | :------ |
| `esmodule` | Boolean | `false` |

<!-- end auto-generated rule options list -->
2 changes: 0 additions & 2 deletions docs/rules/no-extraneous-dependencies.md
Expand Up @@ -9,8 +9,6 @@ Modules have to be installed for this rule to work.

## Options

This rule supports the following options:

`devDependencies`: If set to `false`, then the rule will show an error when `devDependencies` are imported. Defaults to `true`.
Type imports are ignored by default.

Expand Down
14 changes: 5 additions & 9 deletions docs/rules/no-import-module-exports.md
Expand Up @@ -12,17 +12,13 @@ If you have multiple entry points or are using `js:next` this rule includes an

## Options

### `exceptions`
<!-- begin auto-generated rule options list -->

- An array of globs. The rule will be omitted from any file that matches a glob
in the options array. For example, the following setting will omit the rule
in the `some-file.js` file.
| Name | Description | Type |
| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---- |
| `exceptions` | An array of globs. The rule will be omitted from any file that matches a glob in the options array. For example, `"**/*/some-file.js"` will omit the rule in the `some-file.js` file. | Array |

```json
"import/no-import-module-exports": ["error", {
"exceptions": ["**/*/some-file.js"]
}]
```
<!-- end auto-generated rule options list -->

## Rule Details

Expand Down
10 changes: 8 additions & 2 deletions docs/rules/no-internal-modules.md
Expand Up @@ -8,8 +8,14 @@ Use this rule to prevent importing the submodules of other modules.

This rule has two mutally exclusive options that are arrays of [minimatch/glob patterns](https://github.com/isaacs/node-glob#glob-primer) patterns:

- `allow` that include paths and import statements that can be imported with reaching.
- `forbid` that exclude paths and import statements that can be imported with reaching.
<!-- begin auto-generated rule options list -->

| Name | Description | Type |
| :------- | :---------------------------------------------------------------------- | :------- |
| `allow` | Include paths and import statements that can be imported with reaching. | String[] |
| `forbid` | Exclude paths and import statements that can be imported with reaching. | String[] |

<!-- end auto-generated rule options list -->

### Examples

Expand Down
8 changes: 6 additions & 2 deletions docs/rules/no-namespace.md
Expand Up @@ -10,9 +10,13 @@ The rule is auto-fixable when the namespace object is only used for direct membe

## Options

This rule supports the following options:
<!-- begin auto-generated rule options list -->

- `ignore`: array of glob strings for modules that should be ignored by the rule.
| Name | Description | Type |
| :------- | :----------------------------------------------------------- | :------- |
| `ignore` | Glob strings for modules that should be ignored by the rule. | String[] |

<!-- end auto-generated rule options list -->

## Rule Details

Expand Down
8 changes: 6 additions & 2 deletions docs/rules/no-nodejs-modules.md
Expand Up @@ -6,9 +6,13 @@ Forbid the use of Node.js builtin modules. Can be useful for client-side web pro

## Options

This rule supports the following options:
<!-- begin auto-generated rule options list -->

- `allow`: Array of names of allowed modules. Defaults to an empty array.
| Name | Description | Type |
| :------ | :------------------------ | :------- |
| `allow` | Names of allowed modules. | String[] |

<!-- end auto-generated rule options list -->

## Rule Details

Expand Down
13 changes: 13 additions & 0 deletions docs/rules/no-relative-packages.md
Expand Up @@ -68,3 +68,16 @@ import bar from 'bar'; // Import sibling package using package name

import bar from 'bar'; // Import sibling package using package name
```

## Options

<!-- begin auto-generated rule options list -->

| Name | Type |
| :--------- | :------- |
| `amd` | Boolean |
| `commonjs` | Boolean |
| `esmodule` | Boolean |
| `ignore` | String[] |

<!-- end auto-generated rule options list -->
13 changes: 13 additions & 0 deletions docs/rules/no-relative-parent-imports.md
Expand Up @@ -121,3 +121,16 @@ import a from './lib/a'; // Import child file using relative path

import b from './b'; // Import sibling file using relative path
```

## Options

<!-- begin auto-generated rule options list -->

| Name | Type |
| :--------- | :------- |
| `amd` | Boolean |
| `commonjs` | Boolean |
| `esmodule` | Boolean |
| `ignore` | String[] |

<!-- end auto-generated rule options list -->
11 changes: 8 additions & 3 deletions docs/rules/no-unassigned-import.md
Expand Up @@ -11,11 +11,16 @@ This rule aims to remove modules with side-effects by reporting when a module is

## Options

This rule supports the following option:
<!-- begin auto-generated rule options list -->

`allow`: An Array of globs. The files that match any of these patterns would be ignored/allowed by the linter. This can be useful for some build environments (e.g. css-loader in webpack).
| Name | Description | Type |
| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ |
| `allow` | An Array of globs. The files that match any of these patterns would be ignored/allowed by the linter. This can be useful for some build environments (e.g. css-loader in webpack). Note that the globs start from the where the linter is executed (usually project root), but not from each file that includes the source. Learn more in both the pass and fail examples below. | String[] |
| `devDependencies` | | Boolean,array |
| `optionalDependencies` | | Boolean,array |
| `peerDependencies` | | Boolean,array |

Note that the globs start from the where the linter is executed (usually project root), but not from each file that includes the source. Learn more in both the pass and fail examples below.
<!-- end auto-generated rule options list -->

## Fail

Expand Down
13 changes: 13 additions & 0 deletions docs/rules/no-unresolved.md
Expand Up @@ -21,6 +21,19 @@ If you are using Webpack, see the section on [resolvers](../../README.md#resolve

### Options

<!-- begin auto-generated rule options list -->

| Name | Type | Default |
| :-------------------- | :------- | :------ |
| `amd` | Boolean | |
| `caseSensitive` | Boolean | `true` |
| `caseSensitiveStrict` | Boolean | `false` |
| `commonjs` | Boolean | |
| `esmodule` | Boolean | |
| `ignore` | String[] | |

<!-- end auto-generated rule options list -->

By default, only ES6 imports will be resolved:

```js
Expand Down
19 changes: 13 additions & 6 deletions docs/rules/no-unused-modules.md
Expand Up @@ -25,12 +25,19 @@ Example:

### Options

This rule takes the following option:

- **`missingExports`**: if `true`, files without any exports are reported (defaults to `false`)
- **`unusedExports`**: if `true`, exports without any static usage within other modules are reported (defaults to `false`)
- `src`: an array with files/paths to be analyzed. It only applies to unused exports. Defaults to `process.cwd()`, if not provided
- `ignoreExports`: an array with files/paths for which unused exports will not be reported (e.g module entry points in a published package)
<!-- begin auto-generated rule options list -->

| Name | Description | Type | Choices | Default | Required |
| :--------------- | :--------------------------------------------------------------------------------------------------------- | :------- | :------ | :-------------- | :------- |
| `ignoreExports` | files/paths for which unused exports will not be reported (e.g module entry points in a published package) | String[] | | | |
| `missingExports` | report modules without any exports | Boolean | | `false` | |
| `missingExports` | | | `true` | | Yes |
| `src` | files/paths to be analyzed (only for unused exports) | String[] | | `process.cwd()` | |
| `src` | | | | | |
| `unusedExports` | report exports without any usage | Boolean | | `false` | |
| `unusedExports` | | | `true` | | Yes |

<!-- end auto-generated rule options list -->

### Example for missing exports

Expand Down
9 changes: 9 additions & 0 deletions docs/rules/no-useless-path-segments.md
Expand Up @@ -59,6 +59,15 @@ import fs from "fs";

## Options

<!-- begin auto-generated rule options list -->

| Name | Type |
| :--------------- | :------ |
| `commonjs` | Boolean |
| `noUselessIndex` | Boolean |

<!-- end auto-generated rule options list -->

### noUselessIndex

If you want to detect unnecessary `/index` or `/index.js` (depending on the specified file extensions, see below) imports in your paths, you can enable the option `noUselessIndex`. By default it is set to `false`:
Expand Down

0 comments on commit 70f909c

Please sign in to comment.