Skip to content

linter: .oxlintrc.json configuration file improvements #15247

@connorshea

Description

@connorshea

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:

Image Image

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:

Image

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:

Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions