biomejs / biome-vscode

Biome extension for Visual Studio Code and VSCodium
https://marketplace.visualstudio.com/items?itemName=biomejs.biome
Apache License 2.0
202 stars 24 forks source link

πŸ› `suspicious/noRedundantUseStrict` is reported for `.cjs` files #362

Open risu729 opened 1 week ago

risu729 commented 1 week ago

VS Code version

1.94.0-insider

Extension version

2.3.0

Biome version

1.9.2

Operating system

Description

The extension reports an error for use strict directive in .cjs files with suspicious/noRedundantUseStrict.

Steps to reproduce

  1. Create a file with .cjs exntension.
  2. Add use strict directive.
  3. Error is shown as a problem.

Expected behavior

No errors are shown as documents says.

Instead, .cjs files are considered β€œscripts” and the directive "use strict" is accepted and advised.

Does this issue occur when using the CLI directly?

No

Link to a minimal reproduction

https://github.com/risu729/biome-repro-1727086476220

Logs

CLI:
  Version:                      1.9.2
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v22.9.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.8.3"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Discovering running Biome servers...

Running Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i The client isn't connected to any server but rage discovered this running Biome server.

Server:
  Version:                      1.9.2
  Name:                         biome_lsp
  CPU Architecture:             x86_64
  OS:                           linux

Workspace:
  Open Documents:               0

Other Active Server Workspaces:

Workspace:
  Open Documents:               2
  Client Name:                  Visual Studio Code - Insiders
  Client Version:               1.94.0-insider

Biome Server Log:

! Please review the content of the log file before sharing it publicly as it may contain sensitive information:
  * Path names that may reveal your name, a project name, or the name of your employer.
  * Source code

┐biome_cli::commands::daemon::Running Server{pid=9130}
β”œβ”€ INFO biome_cli::service::unix Trying to connect to socket /home/risu/.cache/biome/biome-socket-1.9.2
β”œβ”€ INFO biome_lsp::server Starting Biome Language Server...
β”œβ”€ WARN biome_lsp::server The Biome Server was initialized with the deprecated `root_path` parameter: this is not supported, use `root_uri` instead
β”œβ”€ INFO biome_lsp::server Attempting to load the configuration from 'biome.json' file
β”œβ”€ INFO biome_lsp::session Detected workspace folder.
β”œβ”€ INFO biome_lsp::session Attempt to load the configuration file in Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/risu/github/use-strict-biome/biome-repro-1727086476220", query: None, fragment: None }
└─┐biome_fs::fs::os::OsFileSystem::open_with_options{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/biome.json", options=OpenOptions { read: true, write: false, truncate: false, create: false, create_new: false }}
β”Œβ”€β”˜
└─┐biome_fs::fs::os::OsFile::read_to_string{}
β”Œβ”€β”˜
└─┐biome_json_parser::parse{}
β”Œβ”€β”˜
β”œβ”€ INFO biome_lsp::session Configuration loaded successfully from disk.
β”œβ”€ INFO biome_lsp::session Update workspace settings.
β”œβ”€ DEBUG biome_service::workspace::server Compare the current project with the new one None Some("/home/risu/github/use-strict-biome/biome-repro-1727086476220") true
└─┐biome_fs::fs::os::OsFileSystem::open_with_options{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/package.json", options=OpenOptions { read: true, write: false, truncate: false, create: false, create_new: false }}
β”Œβ”€β”˜
└─┐biome_fs::fs::os::OsFile::read_to_string{}
β”Œβ”€β”˜
└─┐biome_json_parser::parse{}
β”Œβ”€β”˜
└─┐biome_lsp::handlers::text_document::did_open{text_document_uri=file:///home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs, text_document_language_id=javascript}
  └─┐biome_service::file_handlers::try_from_language_id{language_id="javascript"}
  β”Œβ”€β”˜
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  β”œβ”€ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  β”œβ”€ DEBUG biome_service::workspace The file has the following feature sets: 
  β”‚ {Format: Supported, Search: Supported, Assists: Supported, Lint: Supported, OrganizeImports: Supported}
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  β”œβ”€ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  └─┐biome_js_parser::parse::parse{}
  β”Œβ”€β”˜
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  β”œβ”€ DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }
  └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  └─┐biome_service::workspace::server::Pulling diagnostics{categories=RuleCategories(BitFlags<Categories>(0b111, Syntax | Lint | Action))}
    └─┐biome_service::file_handlers::try_from_path{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
      └─┐biome_service::file_handlers::try_from_well_known{path="/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs"}
      β”Œβ”€β”˜
      └─┐biome_service::file_handlers::try_from_extension{extension="cjs"}
      β”Œβ”€β”˜
    β”Œβ”€β”˜
    └─┐biome_service::file_handlers::javascript::Linting JavaScript file{path=BiomePath { path: "/home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs", kind: FileKinds(BitFlags<FileKind>(0b10000, Handleable)), was_written: false }, language=Js(JsFileSource { language: JavaScript, variant: Jsx, module_kind: Module, version: ES2022, embedding_kind: None })}
      β”œβ”€ INFO biome_service::file_handlers::javascript Analyze file /home/risu/github/use-strict-biome/biome-repro-1727086476220/index.cjs
      β”œβ”€ DEBUG biome_rowan::ast::batch pushing change...
      β”œβ”€ DEBUG biome_rowan::ast::batch pushing change...
    β”Œβ”€β”˜
  β”Œβ”€β”˜
  β”œβ”€ INFO biome_service::workspace::server Pulled 1 diagnostic(s)
β”Œβ”€β”˜
β”œβ”€ INFO biome_lsp::session Loaded client configuration: Object {
β”‚     "enabled": Bool(true),
β”‚     "lspBin": String(""),
β”‚     "searchInPath": Bool(true),
β”‚     "rename": Bool(false),
β”‚ }
β”œβ”€ INFO biome_lsp::session Unregister capabilities "workspace/didChangeConfiguration, textDocument/rangeFormatting, textDocument/onTypeFormatting, textDocument/rename, textDocument/formatting, workspace/didChangeWatchedFiles"
β”œβ”€ INFO biome_lsp::session Register capabilities "workspace/didChangeConfiguration, textDocument/rangeFormatting, textDocument/onTypeFormatting, textDocument/formatting, workspace/didChangeWatchedFiles"
risu729 commented 1 week ago

might be related to #338