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 all 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
92 changes: 92 additions & 0 deletions docs/linting/CONFIGS.md
@@ -0,0 +1,92 @@
---
id: configs
sidebar_label: Configurations
title: Configurations
---

## Built-In Configurations

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

With the exception of `strict`, all configurations are considered "stable".
Rule additions and removals are treated as breaking changes and will only be done in major version bumps.

### `eslint-recommended`

This ruleset is meant to be used after extending `eslint:recommended`.
It disables core ESLint rules that are already checked by the TypeScript compiler.
Additionally, it enables rules that promote using the more modern constructs TypeScript allows for.

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

This config is automatically included if you use any of the other configurations mentioned on this page.

### `recommended`

Recommended rules for code correctness that you can drop in without additional configuration.
These rules are those whose reports are almost always for a bad practice and/or likely bug.
`recommended` also disables rules known to conflict with this repository, or cause issues in TypeScript codebases.

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

::tip
We strongly recommend all TypeScript projects extend from this configuration.
:::

### `recommended-requiring-type-checking`

Additional recommended rules that require type information.
Rules in this configuration are similarly useful to those in `recommended`.

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

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

### `strict`

Additional strict rules that can also catch bugs but are more opinionated than recommended rules.

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

::tip
We recommend a TypeScript project extend from this configuration only if a nontrivial percentage of its developers are highly proficient in TypeScript.
:::

## Overriding Configurations

These configurations are our recommended starting points, but **you don't need to use them as-is**.
ESLint allows you to configure your own rule settings on top of any extended configurations.
See [ESLint's Configuring Rules docs](https://eslint.org/docs/user-guide/configuring/rules#using-configuration-files).

### Suggesting Configuration Changes

If you feel strongly that a specific rule should (or should not) be one of these configurations, please feel free to [file an issue](TODO: NEW ISSUE TEMPLATE) along with a **detailed** argument explaining your reasoning.
264 changes: 132 additions & 132 deletions packages/eslint-plugin/README.md

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion 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 @@ -52,6 +54,8 @@ For example if this rule requires a feature released in a certain TS version.

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -107,6 +107,8 @@ If you don't care about the general structure of the code, then you will not nee

## Attributes

- [x] ✅ Recommended
- Configs:
- [x] ✅ Recommended
- [x] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/array-type.md
Expand Up @@ -125,6 +125,8 @@ This matrix lists all possible option combinations and their expected results fo

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/await-thenable.md
Expand Up @@ -53,6 +53,8 @@ This is generally not preferred, but can sometimes be useful for visual consiste

## Attributes

- [x] ✅ Recommended
- Configs:
- [x] ✅ Recommended
- [x] 🔒 Strict
- [ ] 🔧 Fixable
- [x] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/ban-ts-comment.md
Expand Up @@ -145,6 +145,8 @@ If you want to use all of the TypeScript directives.

## Attributes

- [x] ✅ Recommended
- Configs:
- [x] ✅ Recommended
- [x] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
17 changes: 16 additions & 1 deletion packages/eslint-plugin/docs/rules/ban-tslint-comment.md
Expand Up @@ -30,12 +30,27 @@ 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
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/ban-types.md
Expand Up @@ -195,6 +195,8 @@ const curly2: Record<'a', string> = { a: 'string' };

## Attributes

- [x] ✅ Recommended
- Configs:
- [x] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/brace-style.md
Expand Up @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -111,6 +111,8 @@ for how literal values are exposed by your classes.

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/comma-dangle.md
Expand Up @@ -41,6 +41,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/comma-spacing.md
Expand Up @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -85,6 +85,8 @@ type Foo = {

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -119,6 +119,8 @@ If you do not want to enforce consistent type assertions.

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -87,6 +87,8 @@ If you specifically want to use an interface or type literal for stylistic reaso

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/consistent-type-exports.md
Expand Up @@ -112,6 +112,8 @@ export { Button, type ButtonProps } from 'some-library';

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [x] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/consistent-type-imports.md
Expand Up @@ -67,6 +67,8 @@ const x: import('Bar') = 1;

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/default-param-last.md
Expand Up @@ -65,6 +65,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/dot-notation.md
Expand Up @@ -90,6 +90,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [x] 🔒 Strict
- [x] 🔧 Fixable
- [x] 💭 Requires type information
Expand Up @@ -293,6 +293,8 @@ you will not need this rule.

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -351,6 +351,8 @@ If you think defaulting to public is a good default, then you should consider us

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
Expand Up @@ -288,6 +288,8 @@ If you wish to make sure all functions have explicit return types, as opposed to

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/func-call-spacing.md
Expand Up @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/indent.md
Expand Up @@ -33,6 +33,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/init-declarations.md
Expand Up @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [ ] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/keyword-spacing.md
Expand Up @@ -29,6 +29,8 @@ Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/

## Attributes

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

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/member-delimiter-style.md
Expand Up @@ -211,6 +211,8 @@ If you don't care about enforcing a consistent member delimiter in interfaces an

## Attributes

- [ ] ✅ Recommended
- Configs:
- [ ] ✅ Recommended
- [ ] 🔒 Strict
- [x] 🔧 Fixable
- [ ] 💭 Requires type information