oxc/npm/oxlint/configuration_schema.json
Don Isaac a0effab160
feat(linter): support more flexible config.globals values (#4990)
Support `"readable", `"writable"`, and boolean values for `GlobalValue`.

I also enhanced the documentation for `OxcGlobals`

## Screenshot
<img width="797" alt="image"
src="https://github.com/user-attachments/assets/8f76de4c-4ae8-44d1-9be1-720fc3c7e0ec">
2024-08-19 16:23:47 -04:00

298 lines
No EOL
8.5 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "OxlintConfig",
"description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported. You can use comments in configuration files.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json { \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
"type": "object",
"properties": {
"env": {
"description": "Environments enable and disable collections of global variables.",
"allOf": [
{
"$ref": "#/definitions/OxlintEnv"
}
]
},
"globals": {
"description": "Enabled or disabled specific global variables.",
"allOf": [
{
"$ref": "#/definitions/OxlintGlobals"
}
]
},
"rules": {
"description": "See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html).",
"allOf": [
{
"$ref": "#/definitions/OxlintRules"
}
]
},
"settings": {
"$ref": "#/definitions/OxlintSettings"
}
},
"definitions": {
"AllowWarnDeny": {
"oneOf": [
{
"description": "Oxlint rule.\n- \"allow\" or \"off\": Turn off the rule.\n- \"warn\": Turn the rule on as a warning (doesn't affect exit code).\n- \"error\" or \"deny\": Turn the rule on as an error (will exit with a failure code).",
"type": "string",
"enum": [
"allow",
"off",
"warn",
"error",
"deny"
]
},
{
"description": "Oxlint rule.\n \n- 0: Turn off the rule.\n- 1: Turn the rule on as a warning (doesn't affect exit code).\n- 2: Turn the rule on as an error (will exit with a failure code).",
"type": "integer",
"format": "uint32",
"maximum": 2.0,
"minimum": 0.0
}
]
},
"CustomComponent": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"required": [
"attribute",
"name"
],
"properties": {
"attribute": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"attributes",
"name"
],
"properties": {
"attributes": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
}
}
}
]
},
"DummyRule": {
"anyOf": [
{
"$ref": "#/definitions/AllowWarnDeny"
},
{
"type": "array",
"items": true
}
]
},
"DummyRuleMap": {
"description": "See [Oxlint Rules](https://oxc.rs/docs/guide/usage/linter/rules.html)",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/DummyRule"
}
},
"GlobalValue": {
"type": "string",
"enum": [
"readonly",
"writeable",
"off"
]
},
"JSDocPluginSettings": {
"type": "object",
"properties": {
"augmentsExtendsReplacesDocs": {
"description": "Only for `require-(yields|returns|description|example|param|throws)` rule",
"default": false,
"type": "boolean"
},
"exemptDestructuredRootsFromChecks": {
"description": "Only for `require-param-type` and `require-param-description` rule",
"default": false,
"type": "boolean"
},
"ignoreInternal": {
"description": "For all rules but NOT apply to `empty-tags` rule",
"default": false,
"type": "boolean"
},
"ignorePrivate": {
"description": "For all rules but NOT apply to `check-access` and `empty-tags` rule",
"default": false,
"type": "boolean"
},
"ignoreReplacesDocs": {
"description": "Only for `require-(yields|returns|description|example|param|throws)` rule",
"default": true,
"type": "boolean"
},
"implementsReplacesDocs": {
"description": "Only for `require-(yields|returns|description|example|param|throws)` rule",
"default": false,
"type": "boolean"
},
"overrideReplacesDocs": {
"description": "Only for `require-(yields|returns|description|example|param|throws)` rule",
"default": true,
"type": "boolean"
},
"tagNamePreference": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/TagNamePreference"
}
}
}
},
"JSXA11yPluginSettings": {
"type": "object",
"properties": {
"components": {
"default": {},
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"polymorphicPropName": {
"type": [
"string",
"null"
]
}
}
},
"NextPluginSettings": {
"type": "object",
"properties": {
"rootDir": {
"$ref": "#/definitions/OneOrMany_for_String"
}
}
},
"OneOrMany_for_String": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"OxlintEnv": {
"description": "Predefine global variables.\n\nEnvironments specify what global variables are predefined. See [ESLint's list of environments](https://eslint.org/docs/v8.x/use/configure/language-options#specifying-environments) for what environments are available and what each one provides.",
"type": "object",
"additionalProperties": {
"type": "boolean"
}
},
"OxlintGlobals": {
"description": "Add or remove global variables.\n\nFor each global variable, set the corresponding value equal to `\"writable\"` to allow the variable to be overwritten or `\"readonly\"` to disallow overwriting.\n\nGlobals can be disabled by setting their value to `\"off\"`. For example, in an environment where most Es2015 globals are available but `Promise` is unavailable, you might use this config:\n\n```json\n\n{ \"env\": { \"es6\": true }, \"globals\": { \"Promise\": \"off\" } }\n\n```\n\nYou may also use `\"readable\"` or `false` to represent `\"readonly\"`, and `\"writeable\"` or `true` to represent `\"writable\"`.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/GlobalValue"
}
},
"OxlintRules": {
"$ref": "#/definitions/DummyRuleMap"
},
"OxlintSettings": {
"description": "Shared settings for plugins",
"type": "object",
"properties": {
"jsdoc": {
"$ref": "#/definitions/JSDocPluginSettings"
},
"jsx-a11y": {
"$ref": "#/definitions/JSXA11yPluginSettings"
},
"next": {
"$ref": "#/definitions/NextPluginSettings"
},
"react": {
"$ref": "#/definitions/ReactPluginSettings"
}
}
},
"ReactPluginSettings": {
"type": "object",
"properties": {
"formComponents": {
"type": "array",
"items": {
"$ref": "#/definitions/CustomComponent"
}
},
"linkComponents": {
"type": "array",
"items": {
"$ref": "#/definitions/CustomComponent"
}
}
}
},
"TagNamePreference": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"required": [
"message",
"replacement"
],
"properties": {
"message": {
"type": "string"
},
"replacement": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string"
}
}
},
{
"type": "boolean"
}
]
}
}
}