Skip to content

docs(eslint-plugin): add warning about superfluous rules with typescript #7372

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

Merged
merged 20 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"summary",
"sup",
"TabItem",
"Tabs"
"Tabs",
"TypeScriptOverlap"
]
},
// MD034/no-bare-urls - Bare URL used
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/docs/rules/no-dupe-class-members.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ description: 'Disallow duplicate class members.'
>
> See **https://typescript-eslint.io/rules/no-dupe-class-members** for documentation.

import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";

<TypeScriptOverlap />

This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule.
It adds support for TypeScript's method overload definitions.
4 changes: 4 additions & 0 deletions packages/eslint-plugin/docs/rules/no-invalid-this.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ description: 'Disallow `this` keywords outside of classes or class-like objects.
>
> See **https://typescript-eslint.io/rules/no-invalid-this** for documentation.

import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";

<TypeScriptOverlap strict />

This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule.
It adds support for TypeScript's `this` parameters.
4 changes: 4 additions & 0 deletions packages/eslint-plugin/docs/rules/no-redeclare.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description: 'Disallow variable redeclaration.'
>
> See **https://typescript-eslint.io/rules/no-redeclare** for documentation.

import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";

<TypeScriptOverlap />

This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule.
It adds support for TypeScript function overloads, and declaration merging.

Expand Down
32 changes: 32 additions & 0 deletions packages/website/src/components/TypeScriptOverlap/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Admonition from '@theme/Admonition';
import React from 'react';

export default function TypeScriptOverlap({
strict,
}: {
strict?: string;
}): React.JSX.Element {
return (
<div>
<Admonition type="danger">
<p>
The code problem checked by this ESLint rule is automatically checked
by the TypeScript compiler. Thus, it is not recommended to turn on
this rule in new TypeScript projects. You only need to enable this
rule if you prefer the ESLint error messages over the TypeScript
compiler error messages.
</p>
{strict === undefined ? (
<></>
) : (
<p>
(Note that technically, TypeScript will only catch this if you have
the <code>strict</code> or <code>noImplicitThis</code> flags
enabled. These are enabled in most TypeScript projects, since they
are considered to be best practice.)
</p>
)}
</Admonition>
</div>
);
}