Skip to content

🐛 checkAllProperties option for useReadonlyClassProperties has error in formatting #7948

@jakeleventhal

Description

@jakeleventhal

Environment information

CLI:
  Version:                      2.3.2
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         xterm-256color
  JS_RUNTIME_VERSION:           v22.20.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/10.11.1

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.jsonc
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true

Workspace:
  Open Documents:               0

What happened?

I cannot get it to reproduce in the playground. It shows no diagnostics but this is the class:

export interface ErrorResponseOptions {
	message?: string;
	headers?: Record<string, unknown> | undefined;
	rawCode?: string | undefined;
	rawData?: any | undefined;
	[key: string]: unknown;
}

export class ErrorResponse extends Error {
	statusCode: number;

	readonly rawCode: ErrorResponseOptions["rawCode"];

	override readonly stack?: string | undefined;

	readonly rawData: ErrorResponseOptions["rawData"];

	readonly data: Record<string, unknown>;

	readonly headers: ErrorResponseOptions["headers"];

	constructor(
		apiError: number,
		{ headers, message, rawCode, rawData, ...data }: ErrorResponseOptions,
	) {
		super(message);

		this.rawCode = rawCode;
		this.rawData = rawData;
		this.message = message ?? "";
		this.statusCode = apiError;
		this.data = data;
		this.headers = headers;
	}
}

and this is the diagnostic:

packages/riptech/utils/src/errors/ErrorResponse.ts:40:2 lint/style/useReadonlyClassProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ℹ Member 'statusCode' is never reassigned.
  
    39 │ export class ErrorResponse extends Error {
  > 40 │  statusCode: number;
       │  ^^^^^^^^^^
    41 │ 
    42 │  readonly rawCode: ErrorResponseOptions["rawCode"];
  
  ℹ Using readonly improves code safety, clarity, and helps prevent unintended mutations.
  
  ℹ Unsafe fix: Add readonly decorator.
  
    38 38 │   
    39 39 │   export class ErrorResponse extends Error {
    40    │ - → statusCode:·number;
       40 │ + → readonly·
       41 │ + → statusCode:·number;
    41 42 │   
    42 43 │     readonly rawCode: ErrorResponseOptions["rawCode"];

Expected result

The readonly should go before the word, not above it.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions