Skip to content

linter: Add tests for JSON Schema validation checks #15468

@connorshea

Description

@connorshea

See also #15247.

The JSON Schema for the oxlint config file - and how it's generated - is fairly complex, it'd be good if we had some basic tests in the codebase to ensure we don't end up with regressions (like happened with #12117 (comment)).

The idea would be to create a handful of JSON example configs that we expect to pass validation, and a handful we expect not to. Then we have a tester - maybe we can use the jsonschema crate? - that would use configuration_schema.json in the repo and confirm that each of our test files pass/fail validation as expected.

So this should fail for using an invalid plugin name:

{
  "plugins": [
    "invalid"
  ]
}

This should fail for using an invalid category name:

{
  "categories": {
    "invalid": "off"
  }
}

And this should validate fine:

{
  "plugins": [
    "import",
    "typescript",
    "unicorn"
  ],
  "env": {
    "browser": true
  },
  "globals": {
    "foo": "readonly"
  },
  "settings": {},
  "rules": {
    "eqeqeq": "warn",
    "import/no-cycle": "error",
    "react/self-closing-comp": [
      "error",
      {
        "html": false
      }
    ]
  },
  "overrides": [
    {
      "files": [
        "*.test.ts",
        "*.spec.ts"
      ],
      "rules": {
        "@typescript-eslint/no-explicit-any": "off"
      }
    }
  ]
}

Metadata

Metadata

Labels

A-linterArea - LinterC-testCategory - Testing. Code is missing test cases, or a PR is adding them

Priority

None yet

Start date

None yet

Target date

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions