Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biome should not parse when disabled / ignored #3749

Closed
1 of 3 tasks
pikeas opened this issue Aug 31, 2024 · 8 comments
Closed
1 of 3 tasks

Biome should not parse when disabled / ignored #3749

pikeas opened this issue Aug 31, 2024 · 8 comments

Comments

@pikeas
Copy link

pikeas commented Aug 31, 2024

VS Code version

1.92.2

Extension version

2.3.0

Biome version

1.8.3

Operating system

  • Windows
  • macOS
  • Linux

Description

Biome parses CSS files with the following config:

{
	"css": {
		"formatter": { "enabled": false },
		"linter": { "enabled": false }
	},
	"files": {
		"include": [
			"**/*.ts",
		]
	}
}

This surfaced due to a parse error as described on #3107.

This issue is distinct from the parsing error - per the Biome config, CSS files are not in scope - they are not in files.include, and CSS formatting/linting are disabled.

Biome should not display parse errors in this case, and ideally should not parse the files at all as there is no work to be done.

Steps to reproduce

Disable CSS formatting and linting, reload the Biome extension.

Expected behavior

No CSS parse errors displayed, no CSS parsing.

Does this issue occur when using the CLI directly?

Not applicable - CLI outputs No files were processed in the specified paths.

@nhedger
Copy link
Member

nhedger commented Sep 1, 2024

The extension has no control over this behavior, so I'll move this to the main repo.

@nhedger nhedger transferred this issue from biomejs/biome-vscode Sep 1, 2024
@pikeas
Copy link
Author

pikeas commented Sep 3, 2024

The extension has no control over this behavior, so I'll move this to the main repo.

Are you sure this is the case? When run directly, the Biome CLI outputs No files were processed in the specified paths.. So it appears the CLI has the expected behavior, which is to skip parsing of files that are not in scope.

@ematipico
Copy link
Member

I am going ahead and close this issue as not planned.

We will improve the documentation soon, but Biome is different from other tools, because Biome is meant to be a language server.

A language server always attempts to parse a file, and it always emits parsing diagnostics regardless. That's the same behaviour you get from the TS language server.

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@pikeas
Copy link
Author

pikeas commented Sep 4, 2024

A language server always attempts to parse a file, and it always emits parsing diagnostics regardless. That's the same behaviour you get from the TS language server.

Thanks for the explanation. In this case, is it considered a bug that the extension always displays parse errors? IMO, it is surprising to see any output from an extension when it is not enabled for a specific file.

@ematipico
Copy link
Member

If you disable the extension at all, you shouldn't get anything at all, but if the extension picks up any Biome binary (installed by your project or bundled), you'll always get syntax errors if any.

That's how the TS language server works in VScode. The tiny difference is that TS language always works because it's bundled in the editor.

@pikeas
Copy link
Author

pikeas commented Sep 4, 2024

That's how the TS language server works in VScode. The tiny difference is that TS language always works because it's bundled in the editor.

I just tested this:

const valid = 123

invalid-

With VS Code's TS language server, this file displays errors when typescript.validate.enable = true (default), and displays no errors when set to false. Biome always displays errors, even when linting is disabled.

It may be the case that architecturally, Biome's LSP must parse any file with a qualifying language type. However, as the built-in TS LSP demonstrates, errors can (and should) only be surfaced to the user when validation/linting/formatting are enabled and the file isn't ignored.

@ematipico
Copy link
Member

I'll think about it, thank you for your input.

Feel free to open a discussion to make this proposal more visible.

@OliverJAsh
Copy link

OliverJAsh commented Sep 28, 2024

Coming here from biomejs/biome-vscode#222 (comment). I agree with @pikeas' points above.

As it stands I have to choose between either disabling the Biome extension or enabling it and tolerating extraneous errors in CSS files, which is really distracting. For example:

image

I could reduce parsing errors e.g. by enabling "cssModules": true, but that won't work for everything because we have other custom CSS syntax enabled via PostCSS, e.g.:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants