Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): add new 'strict' config #4706

Merged
merged 25 commits into from May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7b05b84
feat: add new 'strict' config
JoshuaKGoldberg Mar 20, 2022
418577c
chore: simplified strict to always be 'warn'
JoshuaKGoldberg Mar 21, 2022
792c751
Merge branch 'main' into strict-config
JoshuaKGoldberg Mar 21, 2022
c17ad3e
chore: missing | false
JoshuaKGoldberg Mar 21, 2022
1707478
test: update tests for new strictness
JoshuaKGoldberg Apr 4, 2022
9c0dbd6
test: update .md file templates and docs.test.ts
JoshuaKGoldberg Apr 4, 2022
d741d55
chore: update configs.test.ts too
JoshuaKGoldberg Apr 4, 2022
903247f
Merge branch 'main' into strict-config
JoshuaKGoldberg Apr 4, 2022
b237870
chore: update website docs
JoshuaKGoldberg Apr 8, 2022
a4a7c45
Merge branch 'main' into strict-config
JoshuaKGoldberg Apr 8, 2022
5131919
docs: add sub-list of configs to attributes
JoshuaKGoldberg Apr 12, 2022
51b19d2
docs: unified configs readme and presets file
JoshuaKGoldberg Apr 12, 2022
cc23e5f
Merge branch 'main'
JoshuaKGoldberg Apr 12, 2022
48d7225
docs: finish trimming configs readme
JoshuaKGoldberg Apr 12, 2022
c9d67dc
fix: sidebar.base.js
JoshuaKGoldberg Apr 13, 2022
a5134bd
fix: finish renaming presets to config
JoshuaKGoldberg Apr 13, 2022
009bc6d
fix: configs docs id
JoshuaKGoldberg Apr 13, 2022
789cab6
fix: typo; not 'three'
JoshuaKGoldberg Apr 13, 2022
d577332
fix: tip colons
JoshuaKGoldberg Apr 13, 2022
3bebc55
chore: replace heavy_check_mark with lock
JoshuaKGoldberg May 15, 2022
3e8ed85
Merge branch 'main'
JoshuaKGoldberg May 15, 2022
0fe329e
chore: mostly fixed up docs, probably one or two more things to do
JoshuaKGoldberg May 15, 2022
9f9921c
docs: method-signature-style period, more in configs.ts
JoshuaKGoldberg May 15, 2022
aa469d2
docs: method-signature-style period, more in configs.ts; fix readmes
JoshuaKGoldberg May 15, 2022
be77517
chore: passing configs.test.ts, docs.test.ts locally
JoshuaKGoldberg May 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/linting/PRESETS.md
@@ -0,0 +1,54 @@
---
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
id: presets
sidebar_label: Presets
title: Presets
---

`@typescript-eslint/eslint-plugin` includes three rulesets you can extend from to pull in the recommended starting rules.

### `plugin:@typescript-eslint/recommended`

Recommended rules for code correctness that you can drop in without additional configuration.
We strongly recommend all TypeScript projects extend from this preset.

This preset is considered "stable": rule additions and removals will only be done in major version bumps.

```json
{
"extends": ["plugin:@typescript-eslint/recommended"]
}
```

### `plugin:@typescript-eslint/recommended-requiring-type-checking`

```json
{
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
]
}
```

Additional recommended rules that require type information.
We recommend all TypeScript projects extend from this preset, with the caveat that rules using type information take longer to run.
See [Linting with Type Information](/docs/linting/type-linting) for more details.

This preset is considered "stable": rule additions and removals will only be done in major version bumps.

### `plugin:@typescript-eslint/strict`

```json
{
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict"
]
}
```

Additional strict rules that can also catch bugs but are more opinionated than recommended rules.
If you are an experienced TypeScript user, you may find benefit from extending from this preset.

This preset is considered "unstable": rule additions and removals may be done in minor or even patch version bumps.
262 changes: 131 additions & 131 deletions packages/eslint-plugin/README.md

Large diffs are not rendered by default.

263 changes: 131 additions & 132 deletions packages/eslint-plugin/docs/rules/README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/eslint-plugin/docs/rules/TEMPLATE.md
Expand Up @@ -22,6 +22,8 @@ To fill out: tell us more about this rule.

## Options

This rule is not configurable.

```jsonc
// .eslintrc.json
{
Expand Down Expand Up @@ -53,5 +55,6 @@ For example if this rule requires a feature released in a certain TS version.
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -108,5 +108,6 @@ If you don't care about the general structure of the code, then you will not nee
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/array-type.md
Expand Up @@ -126,5 +126,6 @@ This matrix lists all possible option combinations and their expected results fo
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/await-thenable.md
Expand Up @@ -54,5 +54,6 @@ This is generally not preferred, but can sometimes be useful for visual consiste
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [ ] 🔧 Fixable
- [x] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/ban-ts-comment.md
Expand Up @@ -146,5 +146,6 @@ If you want to use all of the TypeScript directives.
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
14 changes: 14 additions & 0 deletions packages/eslint-plugin/docs/rules/ban-tslint-comment.md
Expand Up @@ -30,12 +30,26 @@ someCode(); // tslint:disable-line
someCode(); // This is a comment that just happens to mention tslint
```

## Options

```jsonc
// .eslintrc.json
{
"rules": {
"@typescript-eslint/ban-tslint-comment": "warn"
}
}
```

This rule is not configurable.

## When Not To Use It

If you are still using TSLint.

## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/ban-types.md
Expand Up @@ -190,5 +190,6 @@ const curly2: Record<'a', string> = { a: 'string' };
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/brace-style.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -112,5 +112,6 @@ for how literal values are exposed by your classes.
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/comma-dangle.md
Expand Up @@ -42,5 +42,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/comma-spacing.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -86,5 +86,6 @@ type Foo = {
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -120,5 +120,6 @@ If you do not want to enforce consistent type assertions.
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -88,5 +88,6 @@ If you specifically want to use an interface or type literal for stylistic reaso
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -83,5 +83,6 @@ export { Button, type ButtonProps } from 'some-library';
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [x] 💭 Requires type information
Expand Up @@ -68,5 +68,6 @@ const x: import('Bar') = 1;
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/default-param-last.md
Expand Up @@ -66,5 +66,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/dot-notation.md
Expand Up @@ -91,5 +91,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [x] 💭 Requires type information
Expand Up @@ -294,5 +294,6 @@ you will not need this rule.
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -352,5 +352,6 @@ If you think defaulting to public is a good default, then you should consider us
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -289,5 +289,6 @@ If you wish to make sure all functions have explicit return types, as opposed to
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/func-call-spacing.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/indent.md
Expand Up @@ -34,5 +34,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/init-declarations.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/keyword-spacing.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -81,5 +81,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -212,5 +212,6 @@ If you don't care about enforcing a consistent member delimiter in interfaces an
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/member-ordering.md
Expand Up @@ -1116,5 +1116,6 @@ If you don't care about the general structure of your classes and interfaces, th
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -108,5 +108,6 @@ If you don't want to enforce a particular style for object/interface function ty
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/naming-convention.md
Expand Up @@ -704,5 +704,6 @@ If you do not want to enforce naming conventions for anything.
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [x] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/no-array-constructor.md
Expand Up @@ -53,5 +53,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/no-base-to-string.md
Expand Up @@ -93,5 +93,6 @@ If you don't mind `"[object Object]"` in your strings, then you will not need th
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [ ] 🔧 Fixable
- [x] 💭 Requires type information
Expand Up @@ -41,6 +41,19 @@ const isEqualsBar = foo.bar == 'hello';
const isEqualsNum = (1 + foo.num!) == 2;
```

## Options

```jsonc
// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-confusing-non-null-assertion": "warn"
}
}
```

This rule is not configurable.

## When Not To Use It

If you don't care about this confusion, then you will not need this rule.
Expand All @@ -52,5 +65,6 @@ If you don't care about this confusion, then you will not need this rule.
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -155,5 +155,6 @@ Also, if you prefer concise coding style then also don't use it.
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [x] 🔧 Fixable
- [x] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/no-dupe-class-members.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/no-duplicate-imports.md
Expand Up @@ -30,5 +30,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [ ] ✅ Recommended
- [ ] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
14 changes: 14 additions & 0 deletions packages/eslint-plugin/docs/rules/no-dynamic-delete.md
Expand Up @@ -40,6 +40,19 @@ delete container[7];
delete container['-Infinity'];
```

## Options

```jsonc
// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-dynamic-delete": "warn"
}
}
```

This rule is not configurable.

## When Not To Use It

When you know your keys are safe to delete, this rule can be unnecessary.
Expand All @@ -55,5 +68,6 @@ Even repeated minor performance slowdowns likely do not significantly affect you
## Attributes

- [ ] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/no-empty-function.md
Expand Up @@ -96,5 +96,6 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/no-empty-interface.md
Expand Up @@ -72,5 +72,6 @@ If you don't care about having empty/meaningless interfaces, then you will not n
## Attributes

- [x] ✅ Recommended
- [x] ✔ Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information