Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87b7dbb

Browse files
authored
docs(eslint-plugin): cleanup: standardise extension doc style, mark deprecated rules (typescript-eslint#1887)
1 parent f5edb99 commit 87b7dbb

31 files changed

+432
-1734
lines changed

packages/eslint-plugin/docs/rules/ban-ts-ignore.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ This rule has been deprecated in favor of [`ban-ts-comment`](./ban-ts-comment.md
44

55
Suppressing TypeScript Compiler Errors can be hard to discover.
66

7+
## DEPRECATED
8+
9+
This rule has been deprecated in favour of the [`ban-ts-comment`](./ban-ts-comment.md) rule.
10+
It will be removed in a future version of this plugin.
11+
712
## Rule Details
813

914
Does not allow the use of `// @ts-ignore` comments.

packages/eslint-plugin/docs/rules/brace-style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
## Rule Details
44

55
This rule extends the base [`eslint/brace-style`](https://eslint.org/docs/rules/brace-style) rule.
6-
It supports all options and features of the base rule.
6+
It adds support for `enum`, `interface`, `namespace` and `module` declarations.
77

88
## How to use
99

10-
```cjson
10+
```jsonc
1111
{
1212
// note you must disable the base rule as it can report incorrect errors
1313
"brace-style": "off",
Lines changed: 22 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,43 @@
11
# Enforce camelCase naming convention (`camelcase`)
22

3-
When it comes to naming variables, style guides generally fall into one of two
4-
camps: camelCase (`variableName`) and underscores (`variable_name`). This rule
5-
focuses on using the camelCase approach. If your style guide calls for
6-
camelCasing your variable names, then this rule is for you!
3+
## DEPRECATED
74

8-
## Rule Details
5+
This rule has been deprecated in favour of the [`naming-convention`](./naming-convention.md) rule.
6+
It will be removed in a future version of this plugin.
97

10-
This rule looks for any underscores (`_`) located within the source code.
11-
It ignores leading and trailing underscores and only checks those in the middle
12-
of a variable name. If ESLint decides that the variable is a constant
13-
(all uppercase), then no warning will be thrown. Otherwise, a warning will be
14-
thrown. This rule only flags definitions and assignments but not function calls.
15-
In case of ES6 `import` statements, this rule only targets the name of the
16-
variable that will be imported into the local module scope.
8+
## Rule Details
179

18-
**_This rule was taken from the ESLint core rule `camelcase`._**
19-
**_Available options and test cases may vary depending on the version of ESLint installed in the system._**
10+
This rule extends the base [`eslint/camelcase`](https://eslint.org/docs/rules/camelcase) rule.
11+
It adds support for numerous TypeScript features.
2012

21-
## Options
13+
## How to use
2214

23-
```cjson
15+
```jsonc
2416
{
25-
// note you must disable the base rule as it can report incorrect errors
26-
"camelcase": "off",
27-
"@typescript-eslint/camelcase": ["error", { "properties": "always" }]
17+
// note you must disable the base rule as it can report incorrect errors
18+
"camelcase": "off",
19+
"@typescript-eslint/camelcase": ["error"]
2820
}
2921
```
3022

31-
This rule has an object option:
32-
33-
- `"properties": "never"` (default) does not check property names
34-
- `"properties": "always"` enforces camelCase style for property names
35-
- `"genericType": "never"` (default) does not check generic identifiers
36-
- `"genericType": "always"` enforces camelCase style for generic identifiers
37-
- `"ignoreDestructuring": false` (default) enforces camelCase style for destructured identifiers
38-
- `"ignoreDestructuring": true` does not check destructured identifiers
39-
- `allow` (`string[]`) list of properties to accept. Accept regex.
40-
41-
### properties: "always"
42-
43-
Examples of **incorrect** code for this rule with the default `{ "properties": "always" }` option:
44-
45-
```js
46-
/*eslint @typescript-eslint/camelcase: "error"*/
47-
48-
import { no_camelcased } from 'external-module';
49-
50-
var my_favorite_color = '#112C85';
51-
52-
function do_something() {
53-
// ...
54-
}
55-
56-
obj.do_something = function() {
57-
// ...
58-
};
23+
## Options
5924

60-
function foo({ no_camelcased }) {
61-
// ...
62-
}
25+
See [`eslint/camelcase` options](https://eslint.org/docs/rules/camelcase#options).
26+
This rule adds the following options:
6327

64-
function foo({ isCamelcased: no_camelcased }) {
65-
// ...
28+
```ts
29+
interface Options extends BaseCamelcaseOptions {
30+
genericType?: 'always' | 'never';
6631
}
6732

68-
function foo({ no_camelcased = 'default value' }) {
69-
// ...
70-
}
71-
72-
var obj = {
73-
my_pref: 1,
33+
const defaultOptions: Options = {
34+
...baseCamelcaseDefaultOptions,
35+
genericType: 'never',
7436
};
75-
76-
var { category_id = 1 } = query;
77-
78-
var { foo: no_camelcased } = bar;
79-
80-
var { foo: bar_baz = 1 } = quz;
81-
```
82-
83-
Examples of **correct** code for this rule with the default `{ "properties": "always" }` option:
84-
85-
```js
86-
/*eslint @typescript-eslint/camelcase: "error"*/
87-
88-
import { no_camelcased as camelCased } from 'external-module';
89-
90-
var myFavoriteColor = '#112C85';
91-
var _myFavoriteColor = '#112C85';
92-
var myFavoriteColor_ = '#112C85';
93-
var MY_FAVORITE_COLOR = '#112C85';
94-
var foo = bar.baz_boom;
95-
var foo = { qux: bar.baz_boom };
96-
97-
obj.do_something();
98-
do_something();
99-
new do_something();
100-
101-
var { category_id: category } = query;
102-
103-
function foo({ isCamelCased }) {
104-
// ...
105-
}
106-
107-
function foo({ isCamelCased: isAlsoCamelCased }) {
108-
// ...
109-
}
110-
111-
function foo({ isCamelCased = 'default value' }) {
112-
// ...
113-
}
114-
115-
var { categoryId = 1 } = query;
116-
117-
var { foo: isCamelCased } = bar;
118-
119-
var { foo: isCamelCased = 1 } = quz;
12037
```
12138

122-
### `properties: "never"`
123-
124-
Examples of **correct** code for this rule with the `{ "properties": "never" }` option:
125-
126-
```js
127-
/*eslint @typescript-eslint/camelcase: ["error", {properties: "never"}]*/
128-
129-
var obj = {
130-
my_pref: 1,
131-
};
132-
```
39+
- `"genericType": "never"` (default) does not check generic identifiers
40+
- `"genericType": "always"` enforces camelCase style for generic identifiers
13341

13442
### `genericType: "always"`
13543

@@ -225,74 +133,4 @@ class Foo {
225133
}
226134
```
227135

228-
### `ignoreDestructuring: false`
229-
230-
Examples of **incorrect** code for this rule with the default `{ "ignoreDestructuring": false }` option:
231-
232-
```js
233-
/*eslint @typescript-eslint/camelcase: "error"*/
234-
235-
var { category_id } = query;
236-
237-
var { category_id = 1 } = query;
238-
239-
var { category_id: category_id } = query;
240-
241-
var { category_id: category_alias } = query;
242-
243-
var { category_id: categoryId, ...other_props } = query;
244-
```
245-
246-
### `ignoreDestructuring: true`
247-
248-
Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring": true }` option:
249-
250-
```js
251-
/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/
252-
253-
var { category_id: category_alias } = query;
254-
255-
var { category_id, ...other_props } = query;
256-
```
257-
258-
Examples of **correct** code for this rule with the `{ "ignoreDestructuring": true }` option:
259-
260-
```js
261-
/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/
262-
263-
var { category_id } = query;
264-
265-
var { category_id = 1 } = query;
266-
267-
var { category_id: category_id } = query;
268-
```
269-
270-
## allow
271-
272-
Examples of **correct** code for this rule with the `allow` option:
273-
274-
```js
275-
/*eslint @typescript-eslint/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/
276-
277-
function UNSAFE_componentWillMount() {
278-
// ...
279-
}
280-
```
281-
282-
```js
283-
/*eslint @typescript-eslint/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/
284-
285-
function UNSAFE_componentWillMount() {
286-
// ...
287-
}
288-
289-
function UNSAFE_componentWillMount() {
290-
// ...
291-
}
292-
```
293-
294-
## When Not To Use It
295-
296-
If you have established coding standards using a different naming convention (separating words with underscores), turn this rule off.
297-
298136
<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/camelcase.md)</sup>

packages/eslint-plugin/docs/rules/class-name-casing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This rule enforces PascalCase names for classes and interfaces.
44

5+
## DEPRECATED
6+
7+
This rule has been deprecated in favour of the [`naming-convention`](./naming-convention.md) rule.
8+
It will be removed in a future version of this plugin.
9+
510
## Rule Details
611

712
This rule aims to make it easy to differentiate classes from regular variables at a glance.

packages/eslint-plugin/docs/rules/comma-spacing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It adds support for trailing comma in a types parameters list.
77

88
## How to use
99

10-
```cjson
10+
```jsonc
1111
{
1212
// note you must disable the base rule as it can report incorrect errors
1313
"comma-spacing": "off",

packages/eslint-plugin/docs/rules/default-param-last.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Rule Details
44

5-
This rule enforces default or optional parameters to be the last of parameters.
5+
This rule extends the base [`eslint/default-param-last`](https://eslint.org/docs/rules/default-param-last) rule.
6+
It adds support for optional parameters.
67

78
Examples of **incorrect** code for this rule:
89

@@ -38,4 +39,18 @@ class Foo {
3839
}
3940
```
4041

42+
## How to use
43+
44+
```jsonc
45+
{
46+
// note you must disable the base rule as it can report incorrect errors
47+
"default-param-last": "off",
48+
"@typescript-eslint/default-param-last": ["error"]
49+
}
50+
```
51+
52+
## Options
53+
54+
See [`eslint/default-param-last` options](https://eslint.org/docs/rules/default-param-last#options).
55+
4156
<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/default-param-last.md)</sup>

packages/eslint-plugin/docs/rules/func-call-spacing.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
# Require or disallow spacing between function identifiers and their invocations (`func-call-spacing`)
22

3-
When calling a function, developers may insert optional whitespace between the function’s name and the parentheses that invoke it.
4-
This rule requires or disallows spaces between the function name and the opening parenthesis that calls it.
5-
63
## Rule Details
74

85
This rule extends the base [`eslint/func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) rule.
9-
It supports all options and features of the base rule.
10-
This version adds support for generic type parameters on function calls.
6+
It adds support for generic type parameters on function calls.
117

128
## How to use
139

14-
```cjson
10+
```jsonc
1511
{
1612
// note you must disable the base rule as it can report incorrect errors
1713
"func-call-spacing": "off",

packages/eslint-plugin/docs/rules/generic-type-naming.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
It can be helpful to enforce a consistent naming style for generic type variables used within a type.
44
For example, prefixing them with `T` and ensuring a somewhat descriptive name, or enforcing Hungarian notation.
55

6+
## DEPRECATED
7+
8+
This rule has been deprecated in favour of the [`naming-convention`](./naming-convention.md) rule.
9+
It will be removed in a future version of this plugin.
10+
611
## Rule Details
712

813
This rule allows you to enforce conventions over type variables. By default, it does nothing.
@@ -13,7 +18,7 @@ The rule takes a single string option, which is a regular expression that type v
1318

1419
Examples of **correct** code with a configuration of `'^T[A-Z][a-zA-Z]+$'`:
1520

16-
```typescript
21+
```ts
1722
type ReadOnly<TType extends object> = {
1823
readonly [TKey in keyof TType]: TType[TKey];
1924
};
@@ -25,7 +30,7 @@ interface SimpleMap<TValue> {
2530

2631
Examples of **incorrect** code with a configuration of `'^T[A-Z][a-zA-Z]+$'`:
2732

28-
```typescript
33+
```ts
2934
type ReadOnly<T extends object> = { readonly [Key in keyof T]: T[Key] };
3035

3136
interface SimpleMap<T> {

0 commit comments

Comments
 (0)