Skip to content

Commit 7d855e6

Browse files
authored
docs: Create a shared settings document (#115)
1 parent 150b34f commit 7d855e6

11 files changed

+298
-621
lines changed

.eslint-doc-generatorrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const config = {
1010
["flat/recommended", "☑️"],
1111
["flat/mixed-esm-and-cjs", "🟠"],
1212
],
13+
ruleDocSectionOptions: false,
1314
}
1415

1516
module.exports = config

docs/rules/file-extension-in-import.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,39 +92,15 @@ import logo from "./logo.png"
9292

9393
### Shared Settings
9494

95-
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
96-
Several rules have the same option, but we can set this option at once.
95+
#### tsconfigPath
9796

98-
#### typescriptExtensionMap
99-
100-
Adds the ability to change the extension mapping when converting between typescript and javascript
101-
102-
You can also use the [typescript compiler jsx options](https://www.typescriptlang.org/tsconfig#jsx) to automatically use the correct mapping.
97+
This can be configured in the shared settings [`settings.tsconfigPath`](../shared-settings.md#tsconfigpath).
98+
Please see the shared settings documentation for more information.
10399

104-
If this option is left undefined we:
105-
106-
1. Check your `tsconfig.json` `compilerOptions.jsx`
107-
2. Return the default mapping (jsx = `preserve`)
100+
#### typescriptExtensionMap
108101

109-
```js
110-
// .eslintrc.js
111-
module.exports = {
112-
"settings": {
113-
"node": {
114-
"typescriptExtensionMap": [
115-
[ "", ".js" ],
116-
[ ".ts", ".js" ],
117-
[ ".cts", ".cjs" ],
118-
[ ".mts", ".mjs" ],
119-
[ ".tsx", ".jsx" ],
120-
]
121-
}
122-
},
123-
"rules": {
124-
"n/file-extension-in-import": "error"
125-
}
126-
}
127-
```
102+
This can be configured in the shared settings [`settings.typescriptExtensionMap`](../shared-settings.md#typescriptextensionmap).
103+
Please see the shared settings documentation for more information.
128104

129105
## 🔎 Implementation
130106

docs/rules/no-extraneous-import.md

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,57 +26,18 @@ This rule warns `import` declarations of extraneous modules.
2626

2727
#### allowModules
2828

29-
Some platforms have additional embedded modules.
30-
For example, Electron has `electron` module.
31-
32-
We can specify additional embedded modules with this option.
33-
This option is an array of strings as module names.
34-
35-
```json
36-
{
37-
"rules": {
38-
"n/no-extraneous-import": ["error", {
39-
"allowModules": ["electron"]
40-
}]
41-
}
42-
}
43-
```
29+
This can be configured in the rule options or as a shared setting [`settings.allowModules`](../shared-settings.md#allowmodules).
30+
Please see the shared settings documentation for more information.
4431

4532
#### resolvePaths
4633

47-
Adds additional paths to try for when resolving imports.
48-
If a path is relative, it will be resolved from CWD.
49-
50-
Default is `[]`
34+
This can be configured in the rule options or as a shared setting [`settings.resolvePaths`](../shared-settings.md#resolvepaths).
35+
Please see the shared settings documentation for more information.
5136

5237
#### convertPath
5338

54-
- `exclude`: TODO
55-
- `include`: TODO
56-
- `replace`: TODO
57-
58-
### Shared Settings
59-
60-
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
61-
Several rules have the same option, but we can set this option at once.
62-
63-
- `allowModules`
64-
- `resolvePaths`
65-
66-
```js
67-
// .eslintrc.js
68-
module.exports = {
69-
"settings": {
70-
"node": {
71-
"allowModules": ["electron"],
72-
"resolvePaths": [__dirname],
73-
}
74-
},
75-
"rules": {
76-
"n/no-extraneous-import": "error"
77-
}
78-
}
79-
```
39+
This can be configured in the rule options or as a shared setting [`settings.convertPath`](../shared-settings.md#convertpath).
40+
Please see the shared settings documentation for more information.
8041

8142
## 🔎 Implementation
8243

docs/rules/no-extraneous-require.md

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,66 +27,23 @@ This rule warns `require()` of extraneous modules.
2727

2828
#### allowModules
2929

30-
Some platforms have additional embedded modules.
31-
For example, Electron has `electron` module.
32-
33-
We can specify additional embedded modules with this option.
34-
This option is an array of strings as module names.
35-
36-
```json
37-
{
38-
"rules": {
39-
"n/no-extraneous-require": ["error", {
40-
"allowModules": ["electron"]
41-
}]
42-
}
43-
}
44-
```
30+
This can be configured in the rule options or as a shared setting [`settings.allowModules`](../shared-settings.md#allowmodules).
31+
Please see the shared settings documentation for more information.
4532

4633
#### resolvePaths
4734

48-
Adds additional paths to try for when resolving imports.
49-
If a path is relative, it will be resolved from CWD.
35+
This can be configured in the rule options or as a shared setting [`settings.resolvePaths`](../shared-settings.md#resolvepaths).
36+
Please see the shared settings documentation for more information.
5037

51-
Default is `[]`
52-
53-
#### tryExtensions
54-
55-
When an import path does not exist, this rule checks whether or not any of `path.js`, `path.json`, and `path.node` exists.
56-
`tryExtensions` option is the extension list this rule uses at the time.
38+
#### convertPath
5739

58-
Default is `[".js", ".json", ".node"]`.
40+
This can be configured in the rule options or as a shared setting [`settings.convertPath`](../shared-settings.md#convertpath).
41+
Please see the shared settings documentation for more information.
5942

60-
#### convertPath
43+
#### tryExtensions
6144

62-
- `exclude`: TODO
63-
- `include`: TODO
64-
- `replace`: TODO
65-
66-
### Shared Settings
67-
68-
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
69-
Several rules have the same option, but we can set this option at once.
70-
71-
- `allowModules`
72-
- `resolvePaths`
73-
- `tryExtensions`
74-
75-
```js
76-
// .eslintrc.js
77-
module.exports = {
78-
"settings": {
79-
"node": {
80-
"allowModules": ["electron"],
81-
"resolvePaths": [__dirname],
82-
"tryExtensions": [".js", ".json", ".node"]
83-
}
84-
},
85-
"rules": {
86-
"n/no-extraneous-require": "error"
87-
}
88-
}
89-
```
45+
This can be configured in the rule options or as a shared setting [`settings.tryExtensions`](../shared-settings.md#tryextensions).
46+
Please see the shared settings documentation for more information.
9047

9148
## 🔎 Implementation
9249

docs/rules/no-missing-import.md

Lines changed: 9 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -46,87 +46,23 @@ import existingModule from "existing-module";
4646

4747
#### allowModules
4848

49-
Some platforms have additional embedded modules.
50-
For example, Electron has `electron` module.
51-
52-
We can specify additional embedded modules with this option.
53-
This option is an array of strings as module names.
54-
55-
```json
56-
{
57-
"rules": {
58-
"n/no-missing-import": ["error", {
59-
"allowModules": ["electron"]
60-
}]
61-
}
62-
}
63-
```
49+
This can be configured in the rule options or as a shared setting [`settings.allowModules`](../shared-settings.md#allowmodules).
50+
Please see the shared settings documentation for more information.
6451

6552
#### resolvePaths
6653

67-
Adds additional paths to try for when resolving imports.
68-
If a path is relative, it will be resolved from CWD.
69-
70-
Default is `[]`
71-
72-
#### typescriptExtensionMap
73-
74-
Adds the ability to change the extension mapping when converting between typescript and javascript
75-
76-
You can also use the [typescript compiler jsx options](https://www.typescriptlang.org/tsconfig#jsx) to automatically use the correct mapping.
77-
78-
If this option is left undefined we:
79-
80-
1. Check the Shared Settings
81-
2. Check your `tsconfig.json` `compilerOptions.jsx`
82-
3. Return the default mapping (jsx = `preserve`)
83-
84-
Default is:
85-
86-
```json
87-
[
88-
[ "", ".js" ],
89-
[ ".ts", ".js" ],
90-
[ ".cts", ".cjs" ],
91-
[ ".mts", ".mjs" ],
92-
[ ".tsx", ".jsx" ],
93-
]
94-
```
54+
This can be configured in the rule options or as a shared setting [`settings.resolvePaths`](../shared-settings.md#resolvepaths).
55+
Please see the shared settings documentation for more information.
9556

9657
#### tsconfigPath
9758

98-
Adds the ability to specify the tsconfig used by the typescriptExtensionMap tool.
99-
100-
### Shared Settings
59+
This can be configured in the rule options or as a shared setting [`settings.tsconfigPath`](../shared-settings.md#tsconfigpath).
60+
Please see the shared settings documentation for more information.
10161

102-
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
103-
Several rules have the same option, but we can set this option at once.
104-
105-
- `allowModules`
106-
- `resolvePaths`
107-
- `typescriptExtensionMap`
62+
#### typescriptExtensionMap
10863

109-
```js
110-
// .eslintrc.js
111-
module.exports = {
112-
"settings": {
113-
"node": {
114-
"allowModules": ["electron"],
115-
"resolvePaths": [__dirname],
116-
"typescriptExtensionMap": [
117-
[ "", ".js" ],
118-
[ ".ts", ".js" ],
119-
[ ".cts", ".cjs" ],
120-
[ ".mts", ".mjs" ],
121-
[ ".tsx", ".js" ],
122-
]
123-
}
124-
},
125-
"rules": {
126-
"n/no-missing-import": "error"
127-
}
128-
}
129-
```
64+
This can be configured in the rule options or as a shared setting [`settings.typescriptExtensionMap`](../shared-settings.md#typescriptextensionmap).
65+
Please see the shared settings documentation for more information.
13066

13167
## 🔎 Implementation
13268

docs/rules/no-missing-require.md

Lines changed: 11 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -52,96 +52,28 @@ var foo = require(FOO_NAME);
5252

5353
#### allowModules
5454

55-
Some platforms have additional embedded modules.
56-
For example, Electron has `electron` module.
57-
58-
We can specify additional embedded modules with this option.
59-
This option is an array of strings as module names.
60-
61-
```json
62-
{
63-
"rules": {
64-
"n/no-missing-require": ["error", {
65-
"allowModules": ["electron"]
66-
}]
67-
}
68-
}
69-
```
55+
This can be configured in the rule options or as a shared setting [`settings.allowModules`](../shared-settings.md#allowmodules).
56+
Please see the shared settings documentation for more information.
7057

7158
#### resolvePaths
7259

73-
Adds additional paths to try for when resolving a require.
74-
If a path is relative, it will be resolved from CWD.
75-
76-
Default is `[]`
60+
This can be configured in the rule options or as a shared setting [`settings.resolvePaths`](../shared-settings.md#resolvepaths).
61+
Please see the shared settings documentation for more information.
7762

7863
#### tryExtensions
7964

80-
When an import path does not exist, this rule checks whether or not any of `path.js`, `path.json`, and `path.node` exists.
81-
`tryExtensions` option is the extension list this rule uses at the time.
82-
83-
Default is `[".js", ".json", ".node"]`.
84-
85-
#### typescriptExtensionMap
86-
87-
Adds the ability to change the extension mapping when converting between typescript and javascript
88-
89-
You can also use the [typescript compiler jsx options](https://www.typescriptlang.org/tsconfig#jsx) to automatically use the correct mapping.
90-
91-
If this option is left undefined we:
92-
93-
1. Check the Shared Settings
94-
2. Check your `tsconfig.json` `compilerOptions.jsx`
95-
3. Return the default mapping (jsx = `preserve`)
96-
97-
Default is:
98-
99-
```json
100-
[
101-
[ "", ".js" ],
102-
[ ".ts", ".js" ],
103-
[ ".cts", ".cjs" ],
104-
[ ".mts", ".mjs" ],
105-
[ ".tsx", ".jsx" ],
106-
]
107-
```
65+
This can be configured in the rule options or as a shared setting [`settings.tryExtensions`](../shared-settings.md#tryextensions).
66+
Please see the shared settings documentation for more information.
10867

10968
#### tsconfigPath
11069

111-
Adds the ability to specify the tsconfig used by the typescriptExtensionMap tool.
112-
113-
### Shared Settings
70+
This can be configured in the rule options or as a shared setting [`settings.tsconfigPath`](../shared-settings.md#tsconfigpath).
71+
Please see the shared settings documentation for more information.
11472

115-
The following options can be set by [shared settings](http://eslint.org/docs/user-guide/configuring.html#adding-shared-settings).
116-
Several rules have the same option, but we can set this option at once.
117-
118-
- `allowModules`
119-
- `resolvePaths`
120-
- `tryExtensions`
121-
- `typescriptExtensionMap`
73+
#### typescriptExtensionMap
12274

123-
```js
124-
// .eslintrc.js
125-
module.exports = {
126-
"settings": {
127-
"node": {
128-
"allowModules": ["electron"],
129-
"resolvePaths": [__dirname],
130-
"tryExtensions": [".js", ".json", ".node"],
131-
"typescriptExtensionMap": [
132-
[ "", ".js" ],
133-
[ ".ts", ".js" ],
134-
[ ".cts", ".cjs" ],
135-
[ ".mts", ".mjs" ],
136-
[ ".tsx", ".js" ],
137-
]
138-
}
139-
},
140-
"rules": {
141-
"n/no-missing-require": "error"
142-
}
143-
}
144-
```
75+
This can be configured in the rule options or as a shared setting [`settings.typescriptExtensionMap`](../shared-settings.md#typescriptextensionmap).
76+
Please see the shared settings documentation for more information.
14577

14678
## 🔎 Implementation
14779

0 commit comments

Comments
 (0)