Skip to content

Commit 071e5a0

Browse files
authored
docs: various updates based on v3 feedback (typescript-eslint#2070)
1 parent 66f1278 commit 071e5a0

File tree

7 files changed

+90
-9
lines changed

7 files changed

+90
-9
lines changed

docs/getting-started/linting/FAQ.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
---
1313

14+
<br />
15+
<br />
16+
<br />
17+
1418
## My linting feels really slow
1519

1620
As mentioned in the [type-aware linting doc](./TYPED_LINTING.md), if you're using type-aware linting, your lint times should be roughly the same as your build times.
@@ -61,8 +65,16 @@ This rule helps ensure your codebase follows a consistent indentation pattern. H
6165

6266
We recommend not using this rule, and instead using a tool like [`prettier`](https://www.npmjs.com/package/) to enforce a standardized formatting.
6367

68+
<br />
69+
<br />
70+
<br />
71+
6472
---
6573

74+
<br />
75+
<br />
76+
<br />
77+
6678
## I get errors telling me "The file must be included in at least one of the projects provided"
6779

6880
This error means that the file that's being linted is not included in any of the tsconfig files you provided us. A lot of the time this happens when users have test files or similar that are not included.
@@ -78,8 +90,16 @@ There are a couple of solutions to this, depending on what you want to achieve.
7890
- Check the `include` option of each of the tsconfigs that you provide to `parserOptions.project` - you must ensure that all files match an `include` glob, or else our tooling will not be able to find it.
7991
- If your file shouldn't be a part of one of your existing tsconfigs (for example, it is a script/tool local to the repo), then consider creating a new tsconfig (we advise calling it `tsconfig.eslint.json`) in your project root which lists this file in its `include`.
8092

93+
<br />
94+
<br />
95+
<br />
96+
8197
---
8298

99+
<br />
100+
<br />
101+
<br />
102+
83103
## I use a framework (like Vue) that requires custom file extensions, and I get errors like "You should add `parserOptions.extraFileExtensions` to your config"
84104

85105
You can use `parserOptions.extraFileExtensions` to specify an array of non-TypeScript extensions to allow, for example:
@@ -92,8 +112,16 @@ You can use `parserOptions.extraFileExtensions` to specify an array of non-TypeS
92112
},
93113
```
94114

115+
<br />
116+
<br />
117+
<br />
118+
95119
---
96120

121+
<br />
122+
<br />
123+
<br />
124+
97125
## I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code
98126

99127
This is a pretty common thing because TypeScript adds new features that ESLint doesn't know about.
@@ -111,16 +139,32 @@ The first step is to [check our list of "extension" rules here](../../../package
111139

112140
If you don't find an existing extension rule, or the extension rule doesn't work for your case, then you can go ahead and check our issues. [The contributing guide outlines the best way to raise an issue](../../../CONTRIBUTING.md#raising-issues).
113141

142+
<br />
143+
<br />
144+
<br />
145+
114146
---
115147

148+
<br />
149+
<br />
150+
<br />
151+
116152
## One of my lint rules isn't working correctly on a pure JavaScript file
117153

118154
This is to be expected - ESLint rules do not check file extensions on purpose, as it causes issues in environments that use non-standard extensions (for example, a `.vue` and a `.md` file can both contain TypeScript code to be linted).
119155

120156
If you have some pure JavaScript code that you do not want to apply certain lint rules to, then you can use [ESLint's `overrides` configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) to turn off certain rules, or even change the parser based on glob patterns.
121157

158+
<br />
159+
<br />
160+
<br />
161+
122162
---
123163

164+
<br />
165+
<br />
166+
<br />
167+
124168
## TypeScript should be installed locally
125169

126170
Make sure that you have installed TypeScript locally i.e. by using `npm install typescript`, not `npm install -g typescript`,

docs/getting-started/linting/MONOREPO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ For example, this is how we specify all of our `tsconfig.json` within this repo.
2828
plugins: ['@typescript-eslint'],
2929
extends: [
3030
'eslint:recommended',
31-
'plugin:@typescript-eslint/eslint-recommended',
3231
'plugin:@typescript-eslint/recommended',
3332
'plugin:@typescript-eslint/recommended-requiring-type-checking',
3433
],

docs/getting-started/linting/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ To use one of these complete config packages, you would replace the `extends` wi
102102
],
103103
extends: [
104104
- 'eslint:recommended',
105-
- 'plugin:@typescript-eslint/eslint-recommended',
106105
- 'plugin:@typescript-eslint/recommended',
107106
+ 'airbnb-typescript',
108107
],
@@ -124,7 +123,6 @@ Using this config is as simple as adding it to the end of your `extends`:
124123
],
125124
extends: [
126125
'eslint:recommended',
127-
'plugin:@typescript-eslint/eslint-recommended',
128126
'plugin:@typescript-eslint/recommended',
129127
+ 'prettier/@typescript-eslint',
130128
],
@@ -153,7 +151,6 @@ Every plugin that is out there includes documentation on the various rules they
153151
],
154152
extends: [
155153
'eslint:recommended',
156-
'plugin:@typescript-eslint/eslint-recommended',
157154
'plugin:@typescript-eslint/recommended',
158155
+ 'plugin:jest/recommended',
159156
],

docs/getting-started/linting/TYPED_LINTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ How can we tap into this? There are two small changes you need to make to your c
1717
plugins: ['@typescript-eslint'],
1818
extends: [
1919
'eslint:recommended',
20-
'plugin:@typescript-eslint/eslint-recommended',
2120
'plugin:@typescript-eslint/recommended',
2221
+ 'plugin:@typescript-eslint/recommended-requiring-type-checking',
2322
],

packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export var arrowFn = () => 'test';
2626

2727
// All arguments should be typed
2828
export var arrowFn = (arg): string => `test ${arg}`;
29+
export var arrowFn = (arg: any): string => `test ${arg}`;
2930

3031
export class Test {
3132
// Should indicate that no value is returned (void)
@@ -51,6 +52,10 @@ export var fn = function (): number {
5152
// A return value of type string
5253
export var arrowFn = (arg: string): string => `test ${arg}`;
5354

55+
// All arguments should be typed
56+
export var arrowFn = (arg: string): string => `test ${arg}`;
57+
export var arrowFn = (arg: unknown): string => `test ${arg}`;
58+
5459
// Class is not exported
5560
class Test {
5661
method() {

packages/eslint-plugin/docs/rules/naming-convention.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,30 @@ Group Selectors are provided for convenience, and essentially bundle up sets of
320320
}
321321
```
322322

323+
### Enforce that interface names do not begin with an `I`
324+
325+
```json
326+
{
327+
"@typescript-eslint/naming-convention": [
328+
"error",
329+
{
330+
"selector": "interface",
331+
"format": ["PascalCase"],
332+
"prefix": ["T"],
333+
"custom": {
334+
"regex": "^I[A-Z]",
335+
"match": false
336+
}
337+
}
338+
]
339+
}
340+
```
341+
323342
### Enforce the codebase follows ESLint's `camelcase` conventions
324343

325344
```json
326345
{
346+
"camelcase": "off",
327347
"@typescript-eslint/naming-convention": [
328348
"error",
329349
{

packages/eslint-plugin/src/configs/README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ These configs exist for your convenience. They contain configuration intended to
66

77
The `eslint-recommended` ruleset is meant to be used after extending `eslint:recommended`. It disables rules that are already checked by the TypeScript compiler and enables rules that promote using the more modern constructs TypeScript allows for.
88

9+
This config is automatically included if you use either the `recommended` or `recommended-requiring-type-checking` configs.
10+
911
```cjson
1012
{
1113
"extends": [
@@ -15,9 +17,11 @@ The `eslint-recommended` ruleset is meant to be used after extending `eslint:rec
1517
}
1618
```
1719

20+
We will not add new rules to the `eslint-recommended` set unless we release a major package version (i.e. it is seen as a breaking change).
21+
1822
## `recommended`
1923

20-
The recommended set is an **_opinionated_** set of rules that we think you should use because:
24+
The `recommended` set is an **_opinionated_** set of rules that we think you should use because:
2125

2226
1. They help you adhere to TypeScript best practices.
2327
2. They help catch probable issue vectors in your code.
@@ -30,9 +34,9 @@ That being said, it is not the only way to use `@typescript-eslint/eslint-plugin
3034
- The style used by many OSS TypeScript projects.
3135
2. The combined state of community contributed rulesets at the time of creation.
3236

33-
We will not add new rules to the recommended set unless we release a major package version (i.e. it is seen as a breaking change).
37+
We will not add new rules to the `recommended` set unless we release a major package version (i.e. it is seen as a breaking change).
3438

35-
### Altering the recommended set to suit your project
39+
### Altering the `recommended` set to suit your project
3640

3741
If you disagree with a rule (or it disagrees with your codebase), consider using your local config to change the rule config so it works for your project.
3842

@@ -46,7 +50,20 @@ If you disagree with a rule (or it disagrees with your codebase), consider using
4650
}
4751
```
4852

49-
### Suggesting changes to the recommended set
53+
### Suggesting changes to the `recommended` set
5054

5155
<!-- prettier-ignore -->
5256
If you feel _very_, **very**, ***very*** strongly that a specific rule should (or should not) be in the recommended ruleset, please feel free to file an issue along with a **detailed** argument explaining your reasoning. We expect to see you citing concrete evidence supporting why (or why not) a rule is considered best practice. **Please note that if your reasoning is along the lines of "it's what my project/company does", or "I don't like the rule", then we will likely close the request without discussion.**
57+
58+
## `recommended-requiring-type-checking`
59+
60+
Similar to `recommended`, the `recommended-requiring-type-checking` set is an **_opinionated_** set of rules. The difference being that all rules in this set will require type information to use.
61+
62+
We will not add new rules to the `recommended-requiring-type-checking` set unless we release a major package version (i.e. it is seen as a breaking change).
63+
64+
## `all`
65+
66+
The `all` set simply contains every single rule in this plugin, turn on with its default configuration.
67+
There may be some conflicts between the rules as defaults do not quite align - please file an issue if you encounter any of these.
68+
69+
This set is considered unstable, as any new rules will be added with only a minor package version bump.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy