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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ fn prefer_enum_initializers_diagnostic(member_name: &str, span: Span) -> OxcDiag
OxcDiagnostic::warn(format!(
"The value of the member {member_name:?} should be explicitly defined."
))
.with_help(format!(
"Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give {member_name:?} an explicit initializer (for example `= 0` or `= '{member_name}'`)."
))
.with_note(
"TypeScript computes uninitialized enum members as numbers: the first one defaults \
to `0`, and each following uninitialized member is the previous numeric value plus `1`.",
)
.with_label(span)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ source: crates/oxc_linter/src/tester.rs
· ──
4 │ }
╰────
help: Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give "Up" an explicit initializer (for example `= 0` or `= 'Up'`).
note: TypeScript computes uninitialized enum members as numbers: the first one defaults to `0`, and each following uninitialized member is the previous numeric value plus `1`.

⚠ typescript-eslint(prefer-enum-initializers): The value of the member "Up" should be explicitly defined.
╭─[prefer_enum_initializers.tsx:3:15]
Expand All @@ -17,6 +19,8 @@ source: crates/oxc_linter/src/tester.rs
· ──
4 │ Down,
╰────
help: Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give "Up" an explicit initializer (for example `= 0` or `= 'Up'`).
note: TypeScript computes uninitialized enum members as numbers: the first one defaults to `0`, and each following uninitialized member is the previous numeric value plus `1`.

⚠ typescript-eslint(prefer-enum-initializers): The value of the member "Down" should be explicitly defined.
╭─[prefer_enum_initializers.tsx:4:15]
Expand All @@ -25,6 +29,8 @@ source: crates/oxc_linter/src/tester.rs
· ────
5 │ }
╰────
help: Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give "Down" an explicit initializer (for example `= 0` or `= 'Down'`).
note: TypeScript computes uninitialized enum members as numbers: the first one defaults to `0`, and each following uninitialized member is the previous numeric value plus `1`.

⚠ typescript-eslint(prefer-enum-initializers): The value of the member "Down" should be explicitly defined.
╭─[prefer_enum_initializers.tsx:4:15]
Expand All @@ -33,6 +39,8 @@ source: crates/oxc_linter/src/tester.rs
· ────
5 │ }
╰────
help: Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give "Down" an explicit initializer (for example `= 0` or `= 'Down'`).
note: TypeScript computes uninitialized enum members as numbers: the first one defaults to `0`, and each following uninitialized member is the previous numeric value plus `1`.

⚠ typescript-eslint(prefer-enum-initializers): The value of the member "Up" should be explicitly defined.
╭─[prefer_enum_initializers.tsx:3:15]
Expand All @@ -41,3 +49,5 @@ source: crates/oxc_linter/src/tester.rs
· ──
4 │ Down = 'Down',
╰────
help: Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give "Up" an explicit initializer (for example `= 0` or `= 'Up'`).
note: TypeScript computes uninitialized enum members as numbers: the first one defaults to `0`, and each following uninitialized member is the previous numeric value plus `1`.
Loading