-
-
Notifications
You must be signed in to change notification settings - Fork 711
Description
An issue for dumping various ideas on improvements to the .oxlinrc.json configuration_schema.json. These sections can be split into individual issues based on whether the maintainers think they're worthwhile improvements.
Basically, I think it's a much better developer experience if their editor (VS Code, Cursor, IntelliJ, etc) can provide useful information/links about the configuration options and do some basic validation. This is already implemented in many regards, but it's imperfect right now.
Add markdownDescription for everything that has description
VS Code (and thus Cursor and friends) support this for JSON Schemas
Unfortunately there's no current way to do this in the schemars crate as far as I know. But schematic has code already that hacks this into schemars, and they also use schemars v0.8, so it can potentially be reused by oxc?: https://github.com/moonrepo/schematic/blob/d3a9422cead2802b940c96f8ab8b188c86ab281f/crates/schematic/src/schema/renderers/json_schema.rs#L85
The difference in quality of hover info is pretty obvious, before and after using markdownDescription with VS Code:
Generate the configuration schema with embedded documentation for each rule
This may be difficult, but it seems possible? Basically, when I hover over a rule, it should be able to display the docs defined from the declare_oxc_lint! macro. Or at the very least, it should link to the documentation page for each rule. This would only support the built-in rules, no js plugin rules obviously.
Right now it just displays this for every rule:
Improved validation/enforcement of valid values
I think this was better in previous versions, but there have been regressions in the validation with the emitted json schema See this comment for an example: #12117 (comment)
Basically, we should be able to have validation in-editor like this:
Add tests for the configuration_schema.json to ensure regressions do not occur
To ensure the validations don't break in the future, we may want to consider a simple CI script to validate example JSON files that should fail to validate? e.g. an .oxlintrc.json file with an invalid plugins value or invalid categories value. Not everything can be validated, such as the jsPlugins array, but some parts can be, and we should ensure we keep it working for end-users via some basic tests. We could potentially run these tests via JavaScript with ajv? Although there is presumably an equivalent for Rust we could use.