Skip to content

chore(website): generate rule docs h1 and description automatically #5249

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
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `your-rule-name`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@armano2 starting a thread for #5249 (comment):

I think the idea is that the docs should not be viewed on GitHub but should be as maintainable as possible.

if that is a case than we should move it out of eslint-plugin to docs

I think I agree, it would be best long term to have these docs files in the docs area. But: the old .md files still have much better SEO than the site. We can't move them all-up just yet. The most we could do would be to leave a .md file in the old location with just the redirect notice.

What would you prefer I do in this PR? I don't have strong feelings one way or another, as long as we're moving towards automating more of the rule docs pages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally - I think it's still a good idea to co-locate them with the plugin - that way they're easy to find and update for contributors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am 100% behind treating the .md files in the repo as source code for most things (i.e. users shouldn't read them).
It's what I said a year ago with the first versions of the website!

Also LMAO I had a different opinion back then about where to put the files:

TBH - I also don't see any tangible value in co-locating the docs with the packages.

So I'll say - I don't mind either way. As long as we keep things clearly documented for contributors (i.e. tests to fail if they've not been added, or not been deleted) - then it shouldn't matter.


Your rule description here.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/your-rule-name** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `adjacent-overload-signatures`

Requires that member overloads be consecutive.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/adjacent-overload-signatures** for documentation.

Grouping overloaded members together can improve readability of the code.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/array-type.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `array-type`

Requires using either `T[]` or `Array<T>` for arrays.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/array-type** for documentation.

Using the same style for array definitions across your codebase makes it easier for your developers to read and understand the types.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/await-thenable.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `await-thenable`

Disallows awaiting a value that is not a Thenable.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/await-thenable** for documentation.

This rule disallows awaiting a value that is not a "Thenable" (an object which has `then` method, such as a Promise).
While it is valid JavaScript to await a non-`Promise`-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/ban-ts-comment.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `ban-ts-comment`

Disallows `@ts-<directive>` comments or requires descriptions after directive.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/ban-ts-comment** for documentation.

TypeScript provides several directive comments that can be used to alter how it processes files.
Using these to suppress TypeScript Compiler Errors reduces the effectiveness of TypeScript overall.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/ban-tslint-comment.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `ban-tslint-comment`

Disallows `// tslint:<rule-flag>` comments.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/ban-tslint-comment** for documentation.

Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this rule helps locate TSLint annotations (e.g. `// tslint:disable`).

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/ban-types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `ban-types`

Disallows certain types.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/ban-types** for documentation.

Some builtin types have aliases, some types are considered dangerous or harmful.
It's often a good idea to ban certain types to help with consistency and safety.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/brace-style.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `brace-style`

Enforces consistent brace style for blocks.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/brace-style** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `class-literal-property-style`

Enforces that literals on classes are exposed in a consistent style.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/class-literal-property-style** for documentation.

When writing TypeScript applications, it's typically safe to store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned.
When writing TypeScript libraries that could be used by JavaScript users however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/comma-dangle.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `comma-dangle`

Requires or disallows trailing commas.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/comma-dangle** for documentation.

## Rule Details

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/comma-spacing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `comma-spacing`

Enforces consistent spacing before and after commas.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/comma-spacing** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `consistent-generic-constructors`

Enforces specifying generic type arguments on type annotation or constructor name of a constructor call.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/consistent-generic-constructors** for documentation.

When constructing a generic class, you can specify the type arguments on either the left-hand side (as a type annotation) or the right-hand side (as part of the constructor call):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `consistent-indexed-object-style`

Requires or disallows the `Record` type.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/consistent-indexed-object-style** for documentation.

TypeScript supports defining object show keys can be flexible using an index signature. TypeScript also has a builtin type named `Record` to create an empty object defining only an index signature. For example, the following types are equal:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `consistent-type-assertions`

Enforces consistent usage of type assertions.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/consistent-type-assertions** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `consistent-type-definitions`

Enforces type definitions to consistently use either `interface` or `type`.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/consistent-type-definitions** for documentation.

There are two ways to define a type.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/consistent-type-exports.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `consistent-type-exports`

Enforces consistent usage of type exports.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/consistent-type-exports** for documentation.

TypeScript 3.8 added support for type-only exports.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/consistent-type-imports.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `consistent-type-imports`

Enforces consistent usage of type imports.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/consistent-type-imports** for documentation.

TypeScript 3.8 added support for type-only imports.
Type-only imports allow you to specify that an import can only be used in a type location, allowing certain optimizations within compilers.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/default-param-last.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `default-param-last`

Enforces default parameters to be last.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/default-param-last** for documentation.

## Rule Details

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/dot-notation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `dot-notation`

Enforces dot notation whenever possible.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/dot-notation** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `explicit-function-return-type`

Requires explicit return types on functions and class methods.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/explicit-function-return-type** for documentation.

Explicit types for function return values makes it clear to any calling code what type is returned.
This ensures that the return value is assigned to a variable of the correct type; or in the case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `explicit-member-accessibility`

Requires explicit accessibility modifiers on class properties and methods.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/explicit-member-accessibility** for documentation.

Leaving off accessibility modifier and making everything public can make
your interface hard to use by others.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `explicit-module-boundary-types`

Requires explicit return and argument types on exported functions' and classes' public class methods.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/explicit-module-boundary-types** for documentation.

Explicit types for function return values and arguments makes it clear to any calling code what is the module boundary's input and output.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/func-call-spacing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `func-call-spacing`

Requires or disallows spacing between function identifiers and their invocations.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/func-call-spacing** for documentation.

## Rule Details

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/indent.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `indent`

Enforces consistent indentation.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/indent** for documentation.

## Warning

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/init-declarations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `init-declarations`

Requires or disallows initialization in variable declarations.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/init-declarations** for documentation.

## Rule Details

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/keyword-spacing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `keyword-spacing`

Enforces consistent spacing before and after keywords.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/keyword-spacing** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `lines-between-class-members`

Requires or disallows an empty line between class members.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/lines-between-class-members** for documentation.

This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the last member. This rule require or disallow an empty line between class members.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/member-delimiter-style.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `member-delimiter-style`

Requires a specific member delimiter style for interfaces and type literals.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/member-delimiter-style** for documentation.

Enforces a consistent member delimiter style in interfaces and type literals. There are three member delimiter styles primarily used in TypeScript:

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/member-ordering.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `member-ordering`

Requires a consistent member declaration order.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/member-ordering** for documentation.

A consistent ordering of fields, methods and constructors can make interfaces, type literals, classes and class expressions easier to read, navigate, and edit.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/method-signature-style.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `method-signature-style`

Enforces using a particular method signature syntax.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/method-signature-style** for documentation.

There are two ways to define an object/interface function property.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/naming-convention.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `naming-convention`

Enforces naming conventions for everything across a codebase.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/naming-convention** for documentation.

Enforcing naming conventions helps keep the codebase consistent, and reduces overhead when thinking about how to name a variable.
Additionally, a well-designed style guide can help communicate intent, such as by enforcing all private properties begin with an `_`, and all global-level constants are written in `UPPER_CASE`.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/no-array-constructor.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-array-constructor`

Disallows generic `Array` constructors.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-array-constructor** for documentation.

## Rule Details

Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/docs/rules/no-base-to-string.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# `no-base-to-string`
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-base-to-string** for documentation.

Requires `.toString()` to only be called on objects which provide useful information when stringified.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-confusing-non-null-assertion`

Disallows non-null assertion in locations that may be confusing.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-confusing-non-null-assertion** for documentation.

## Rule Details

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-confusing-void-expression`

Requires expressions of type void to appear in statement position.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-confusing-void-expression** for documentation.

Returning the results of an expression whose type is void can be misleading.
Attempting to do so is likely a symptom of expecting a different return type from a function.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/no-dupe-class-members.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-dupe-class-members`

Disallows duplicate class members.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-dupe-class-members** for documentation.

## Rule Details

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-duplicate-enum-values`

Disallows duplicate enum member values.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-duplicate-enum-values** for documentation.

Although TypeScript supports duplicate enum member values, people usually expect members to have unique values within the same enum. Duplicate values can lead to bugs that are hard to track down.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/no-duplicate-imports.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-duplicate-imports`

Disallows duplicate imports.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-duplicate-imports** for documentation.

## DEPRECATED

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/no-dynamic-delete.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-dynamic-delete`

Disallows using the `delete` operator on computed key expressions.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-dynamic-delete** for documentation.

Deleting dynamically computed keys can be dangerous and in some cases not well optimized.

Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/docs/rules/no-empty-function.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `no-empty-function`

Disallows empty functions.
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-empty-function** for documentation.

## Rule Details

Expand Down
Loading