Skip to content
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
249 changes: 154 additions & 95 deletions Cargo.lock

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,48 @@ path = "codegen/src/lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.100"
biome_analyze = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896", features = [
biome_analyze = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b", features = [
"schema",
] }
biome_cli = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_configuration = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896", features = [
biome_cli = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_configuration = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b", features = [
"schema",
] }
biome_console = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_css_analyze = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_css_parser = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_css_semantic = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_css_syntax = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_deserialize = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_diagnostics = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_flags = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_formatter = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_fs = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_graphql_analyze = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_graphql_parser = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_graphql_syntax = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_html_analyze = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_html_parser = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_html_syntax = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_js_analyze = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_js_formatter = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_js_parser = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_js_syntax = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_json_analyze = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_json_factory = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_json_formatter = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_json_parser = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_json_syntax = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_module_graph = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_project_layout = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_rowan = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_ruledoc_utils = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_service = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_string_case = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_test_utils = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_text_edit = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896" }
biome_console = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_css_analyze = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_css_parser = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_css_semantic = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_css_syntax = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_deserialize = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_diagnostics = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_flags = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_formatter = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_fs = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_graphql_analyze = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_graphql_parser = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_graphql_syntax = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_html_analyze = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_html_parser = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_html_syntax = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_js_analyze = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_js_formatter = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_js_parser = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_js_syntax = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_json_analyze = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_json_factory = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_json_formatter = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_json_parser = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_json_syntax = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_module_graph = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_project_layout = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_rowan = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_ruledoc_utils = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_service = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_string_case = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_test_utils = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
biome_text_edit = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b" }
bpaf = { version = "0.9.22", features = ["docgen"] }
xtask_codegen = { git = "https://github.com/biomejs/biome.git", rev = "f6bb0105d30eeb4f23c06604184eca7802aa1896", features = [
xtask_codegen = { git = "https://github.com/biomejs/biome.git", rev = "0bd1c1b3122e152925d19ed8013ee38a94a2d16b", features = [
"schema",
] }
# Needed to fix some weird dependency
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@astrojs/starlight": "0.37.3",
"@biomejs/biome": "2.3.11",
"@biomejs/version-utils": "0.4.0",
"@biomejs/wasm-web": "https://pkg.pr.new/biomejs/biome/@biomejs/wasm-web@f6bb010",
"@biomejs/wasm-web": "https://pkg.pr.new/biomejs/biome/@biomejs/wasm-web@0bd1c1b",
"@codemirror/lang-css": "6.3.1",
"@codemirror/lang-html": "6.4.11",
"@codemirror/lang-javascript": "6.2.4",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export default {
'/linter/rules/useConsistentArrowReturn': '/linter/rules/use-consistent-arrow-return',
'/linter/rules/useConsistentBuiltinInstantiation': '/linter/rules/use-consistent-builtin-instantiation',
'/linter/rules/useConsistentCurlyBraces': '/linter/rules/use-consistent-curly-braces',
'/linter/rules/useConsistentEnumValueType': '/linter/rules/use-consistent-enum-value-type',
'/linter/rules/useConsistentGraphqlDescriptions': '/linter/rules/use-consistent-graphql-descriptions',
'/linter/rules/useConsistentMemberAccessibility': '/linter/rules/use-consistent-member-accessibility',
'/linter/rules/useConsistentObjectDefinitions': '/linter/rules/use-consistent-object-definitions',
Expand Down
2 changes: 1 addition & 1 deletion src/components/generated/linter/NumberOfRules.astro

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

1 change: 1 addition & 0 deletions src/content/docs/linter/domains.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Rules that belong to the domain:
- [noUnresolvedImports](/linter/rules/no-unresolved-imports) [(nursery)](/linter/#nursery)
- [useArraySortCompare](/linter/rules/use-array-sort-compare) [(nursery)](/linter/#nursery)
- [useAwaitThenable](/linter/rules/use-await-thenable) [(nursery)](/linter/#nursery)
- [useConsistentEnumValueType](/linter/rules/use-consistent-enum-value-type) [(nursery)](/linter/#nursery)
- [useExhaustiveSwitchCases](/linter/rules/use-exhaustive-switch-cases) [(nursery)](/linter/#nursery)
- [useFind](/linter/rules/use-find) [(nursery)](/linter/#nursery)
- [useRegexpExec](/linter/rules/use-regexp-exec) [(nursery)](/linter/#nursery)
Expand Down
1 change: 1 addition & 0 deletions src/content/docs/linter/javascript/rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ Below the list of rules supported by Biome, divided by group. Here's a legend of
| [useArraySortCompare](/linter/rules/use-array-sort-compare) | Require Array#sort and Array#toSorted calls to always provide a compareFunction. | |
| [useAwaitThenable](/linter/rules/use-await-thenable) | Enforce that `await` is only used on `Promise` values. | |
| [useConsistentArrowReturn](/linter/rules/use-consistent-arrow-return) | Enforce consistent arrow function bodies. | <span class='inline-icon' title='The rule has a safe fix.'><Icon name="seti:config" label="The rule has a safe fix" size="1.2rem" /></span> |
| [useConsistentEnumValueType](/linter/rules/use-consistent-enum-value-type) | Disallow enums from having both number and string members. | <span class='inline-icon' title="This rule is not released yet"><Icon name="moon" label="This rule is not released yet" size="1.2rem" /></span> |
| [useDestructuring](/linter/rules/use-destructuring) | Require destructuring from arrays and/or objects | |
| [useErrorCause](/linter/rules/use-error-cause) | Enforce that `new Error()` is thrown with the original error as `cause`. | |
| [useExhaustiveSwitchCases](/linter/rules/use-exhaustive-switch-cases) | Require switch-case statements to be exhaustive. | <span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span> |
Expand Down
100 changes: 100 additions & 0 deletions src/content/docs/linter/rules/use-consistent-enum-value-type.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useConsistentEnumValueType
description: Learn more about useConsistentEnumValueType
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="TypeScript and TSX" icon="seti:typescript">
:::note
This rule has been implemented but not released yet. It will be available in the next release.
:::
:::caution
This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time.
:::
:::note
This rule belongs to the project domain. This means that its activation will activate the Biome Scanner, which might affect the performance. Read more about it in the [documentation page](/linter/domains#project)
:::
## Summary
- Diagnostic Category: [`lint/nursery/useConsistentEnumValueType`](/reference/diagnostics#diagnostic-category)
- This rule doesn't have a fix.
- The default severity of this rule is [**information**](/reference/diagnostics#information).
- This rule belongs to the following domains:
- [`project`](/linter/domains#project)
- Sources:
- Same as [`@typescript-eslint/no-mixed-enums`](https://typescript-eslint.io/rules/no-mixed-enums)

## How to configure
```json title="biome.json"
{
"linter": {
"rules": {
"nursery": {
"useConsistentEnumValueType": "error"
}
}
}
}

```
## Description
Disallow enums from having both number and string members.

TypeScript enums are allowed to assign numeric or string values to their members.
Most enums contain either all numbers or all strings, but in theory you can mix-and-match within the same enum.
Mixing enum member types is generally considered confusing and a bad practice.

## Examples

### Invalid

```ts
enum Status {
Unknown,
Closed = 1,
Open = 'open',
}
```

<pre class="language-text"><code class="language-text">code-block.ts:3:3 <a href="https://biomejs.dev/linter/rules/use-consistent-enum-value-type">lint/nursery/useConsistentEnumValueType</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br /> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Inconsistent enum value type.</span><br /> <br /> <strong>1 │ </strong>enum Status &#123;<br /> <strong>2 │ </strong> Unknown,<br /> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>3 │ </strong> Closed = 1,<br /> <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br /> <strong>4 │ </strong> Open = 'open',<br /> <strong>5 │ </strong>&#125;<br /> <br /> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Another inconsistent enum value type.</span><br /> <br /> <strong>2 │ </strong> Unknown,<br /> <strong>3 │ </strong> Closed = 1,<br /> <strong><span style="color: Tomato;">&gt;</span></strong> <strong>4 │ </strong> Open = 'open',<br /> <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br /> <strong>5 │ </strong>&#125;<br /> <strong>6 │ </strong><br /> <br /> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Mixing number and string enums can be confusing. Make sure to use a consistent value type within your enum.</span><br /> <br /> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit </span><span style="color: lightgreen;"><a href="https://biomejs.dev/linter/#nursery">https://biomejs.dev/linter/#nursery</a></span><span style="color: lightgreen;"> for more information.</span><br /> <br /></code></pre>

### Valid

```ts
enum Status {
Unknown = 0,
Closed = 1,
Open = 2,
}
```

```ts
enum Status {
Unknown,
Closed,
Open,
}
```

```ts
enum Status {
Unknown = 'unknown',
Closed = 'closed',
Open = 'open',
}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/nursery/use_consistent_enum_value_type.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/nursery/useConsistentEnumValueType)

</TabItem>
</Tabs>

Loading
Loading