Skip to content

Commit

Permalink
docs: add recommended rules to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Sep 17, 2023
1 parent d1488cb commit f868726
Show file tree
Hide file tree
Showing 19 changed files with 240 additions and 2 deletions.
127 changes: 127 additions & 0 deletions website/src/components/generated/RecommendedRules.astro

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions website/src/content/docs/linter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description: How to use the Biome linter.

import PackageManagerBiomeCommand from "@src/components/PackageManagerBiomeCommand.astro";
import NumberOfRules from "@src/components/generated/NumberOfRules.astro";
import RecommendedRules from "@src/components/generated/RecommendedRules.astro";

Biome's linter statically analyzes your code to catch common errors and to help writing idiomatic code.

Expand Down Expand Up @@ -66,6 +67,12 @@ Available options:
```

## Recommended rules

When the linter is enabled, it recommends a number of rules. Below the list of recommended rules:

<RecommendedRules />

## Code fixes

Lint rules may provide automatic code fixes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noAccumulatingSpread (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallow the use of spread (`...`) syntax on accumulators.

Spread syntax allows an iterable to be expanded into its individual elements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noConfusingVoidType (since v1.2.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallow `void` type outside of generic or return types.

`void` in TypeScript refers to a function return that is meant to be ignored. Attempting to use a void type outside of a return type or generic type argument is often a sign of programmer error. void can also be misleading for other developers even if used correctly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noDuplicateJsonKeys (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallow two keys with the same name inside a JSON object.

## Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noExcessiveComplexity (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallow functions that exceed a given complexity score.

The more complexity a function contains, the harder it is to understand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noFallthroughSwitchClause (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallow fallthrough of `switch` clauses.

Switch clauses in `switch` statements fall through by default.
Expand Down
4 changes: 4 additions & 0 deletions website/src/content/docs/linter/rules/no-global-is-finite.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noGlobalIsFinite (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Use `Number.isFinite` instead of global `isFinite`.

`Number.isFinite()` and `isFinite()` [have not the same behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite#difference_between_number.isfinite_and_global_isfinite).
Expand Down
4 changes: 4 additions & 0 deletions website/src/content/docs/linter/rules/no-global-is-nan.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noGlobalIsNan (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Use `Number.isNaN` instead of global `isNaN`.

`Number.isNaN()` and `isNaN()` [have not the same behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN#description).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noMisleadingInstantiator (since vnext)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Enforce proper usage of `new` and `constructor`.

In JavaScript, classes utilize the `constructor` method to initialize a new instance. On the other hand, TypeScript interfaces can describe a class type with a `new()` method signature, though this pattern is not commonly seen in real-world code. Developers, especially those new to JavaScript or TypeScript, might occasionally confuse the use of `constructor` with `new`.
Expand Down
4 changes: 4 additions & 0 deletions website/src/content/docs/linter/rules/no-void.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: noVoid (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallow the use of `void` operators, which is not a familiar operator.

>The `void` operator is often used merely to obtain the undefined primitive value,
Expand Down
4 changes: 4 additions & 0 deletions website/src/content/docs/linter/rules/use-arrow-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useArrowFunction (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Use arrow functions over function expressions.

An arrow function expression is a compact alternative to a regular function expression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useCollapsedElseIf (since v1.1.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Enforce using `else if` instead of nested `if` in `else` clauses.

If an `if` statement is the only statement in the `else` block, it is often clearer to use an `else if` form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useExhaustiveDependencies (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Enforce all dependencies are correctly specified.

## Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useGroupedTypeImport (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Enforce the use of `import type` when an `import` only has specifiers with `type` qualifier.

The [`--verbatimModuleSyntax`](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax) _TypeScript_'s compiler option causes _TypeScript_ to do simple and predictable transpilation on `import` declarations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useHookAtTopLevel (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Enforce that all React hooks are being called from the Top Level
component functions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useImportRestrictions (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Disallows package private imports.

This rules enforces the following restrictions:
Expand Down
4 changes: 4 additions & 0 deletions website/src/content/docs/linter/rules/use-is-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: useIsArray (since v1.0.0)
---


:::caution
This rule is part of the [nursery](/linter/rules/#nursery) group
:::

Use `Array.isArray()` instead of `instanceof Array`.

In _JavaScript_ some array-like objects such as _arguments_ are not instances of the `Array` class. ///
Expand Down
Loading

0 comments on commit f868726

Please sign in to comment.