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

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions