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

Questions on probe vs validate #1736

Closed
MarvinXu opened this issue Nov 20, 2023 · 3 comments
Closed

Questions on probe vs validate #1736

MarvinXu opened this issue Nov 20, 2023 · 3 comments

Comments

@MarvinXu
Copy link

MarvinXu commented Nov 20, 2023

I'm learning eslint and settings in vscode. As I try to understand what files does vscode-eslint validate, I came across these two settings which made me confused.

eslint.probe - an array for language identifiers for which the ESLint extension should be activated and should try to validate the file. If validation fails for probed languages the extension says silent. Defaults to ["javascript", "javascriptreact", "typescript", "typescriptreact", "html", "vue", "markdown"].

eslint.validate - an array of language identifiers specifying the files for which validation is to be enforced. This is an old legacy setting and should in normal cases not be necessary anymore. Defaults to ["javascript", "javascriptreact"].

From what I understand,

  • they both define what language should be validated
  • validate is a legacy so we only need to set probe to enable a new language (in normal cases)

But as I try to setup validation for json, with the eslint-plugin-jsonc, adding json to eslint.probe simply doesn't work. I have to set in eslint.validate as the plugin doc suggested. So is this a abnormal case?

I don't know if I understand this correctly. Can someone shed some light on this?

@dbaeumer
Copy link
Member

The difference is as follows:

  • probe tries to find a plugin but if it fails it doesn't validate the file.
  • validate forces the validation even if a corresponding plugin can't be detected.

Since we don't have autodetection / probing for jsonc yet, you need to use validate.

Hope that helps.

@MarvinXu
Copy link
Author

@dbaeumer Thanks for your quick reply! So why should I use probe at all if validate can work regardless of probing support?

@dbaeumer
Copy link
Member

Probing ensures that the right plugins are installed. With validate you force the validation of the file. So you could force the validation of a C++ file which will result in very strange error messages since ESLint can't lint any C++ code.

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

2 participants