You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(linter): Add configuration option docs for 5 rules. (#15199)
Part of #14743.
- typescript/no-namespace
- react/exhaustive-deps
- typescript/array-type
- promise/always-return
- eslint/curly
Generated docs:
```md
## Configuration
This rule accepts a configuration object with the following properties:
### consistent
type: `boolean`
default: `false`
Whether to enforce consistent use of curly braces in if-else chains.
### curlyType
type: `"all" | "multi" | "multi-line" | "multi-or-nest"`
default: `"all"`
Which type of curly brace enforcement to use.
- `"all"`: require braces in all cases
- `"multi"`: require braces only for multi-statement blocks
- `"multi-line"`: require braces only for multi-line blocks
- `"multi-or-nest"`: require braces for multi-line blocks or when nested
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### default
type: `"array" | "array-simple" | "generic"`
default: `"array"`
The array type expected for mutable cases.
### readonly
type: `"array" | "array-simple" | "generic"`
default: `null`
The array type expected for readonly cases. If omitted, the value for `default` will be used.
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### ignoreAssignmentVariable
type: `string[]`
default: `["globalThis"]`
You can pass an `{ ignoreAssignmentVariable: [] }` as an option to this rule
with a list of variable names so that the last `then()` callback in a promise
chain does not warn if it does an assignment to a global variable. Default is
`["globalThis"]`.
\```javascript
/* eslint promise/always-return: ["error", { ignoreAssignmentVariable: ["globalThis"] }] */
// OK
promise.then((x) => {
globalThis = x
})
promise.then((x) => {
globalThis.x = x
})
// OK
promise.then((x) => {
globalThis.x.y = x
})
// NG
promise.then((x) => {
anyOtherVariable = x
})
// NG
promise.then((x) => {
anyOtherVariable.x = x
})
// NG
promise.then((x) => {
x()
})
\```
### ignoreLastCallback
type: `boolean`
default: `false`
You can pass an `{ ignoreLastCallback: true }` as an option to this rule so that
the last `then()` callback in a promise chain does not warn if it does not have
a `return`. Default is `false`.
\```javascript
// OK
promise.then((x) => {
console.log(x)
})
// OK
void promise.then((x) => {
console.log(x)
})
// OK
await promise.then((x) => {
console.log(x)
})
promise
// NG
.then((x) => {
console.log(x)
})
// OK
.then((x) => {
console.log(x)
})
// NG
const v = promise.then((x) => {
console.log(x)
})
// NG
const v = await promise.then((x) => {
console.log(x)
})
function foo() {
// NG
return promise.then((x) => {
console.log(x)
})
}
\```
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### additionalHooks
type: `[
string,
null
]`
default: `null`
Optionally provide a regex of additional hooks to check.
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### allowDeclarations
type: `boolean`
default: `false`
Whether to allow declare with custom TypeScript namespaces.
Examples of **incorrect** code for this rule when `{ "allowDeclarations": true }`
\```typescript
module foo {}
namespace foo {}
\```
Examples of **correct** code for this rule when `{ "allowDeclarations": true }`
\```typescript
declare module 'foo' {}
declare module foo {}
declare namespace foo {}
declare global {
namespace foo {}
}
declare module foo {
namespace foo {}
}
\```
Examples of **incorrect** code for this rule when `{ "allowDeclarations": false }`
\```typescript
module foo {}
namespace foo {}
declare module foo {}
declare namespace foo {}
\```
Examples of **correct** code for this rule when `{ "allowDeclarations": false }`
\```typescript
declare module 'foo' {}
\```
### allowDefinitionFiles
type: `boolean`
default: `true`
Examples of **incorrect** code for this rule when `{ "allowDefinitionFiles": true }`
\```typescript
// if outside a d.ts file
module foo {}
namespace foo {}
// if outside a d.ts file
module foo {}
namespace foo {}
declare module foo {}
declare namespace foo {}
\```
Examples of **correct** code for this rule when `{ "allowDefinitionFiles": true }`
\```typescript
declare module 'foo' {}
// anything inside a d.ts file
\```
```
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
0 commit comments