From aa6c63457eaa050d20ea09fb288782be312b115e Mon Sep 17 00:00:00 2001 From: Ernisto <63774497+ernisto@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:37:56 -0300 Subject: [PATCH] feat: add luaurc schema, resolves: #842 (#850) --- editors/code/package.json | 6 ++ editors/code/schemas/luaurc.json | 104 +++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 editors/code/schemas/luaurc.json diff --git a/editors/code/package.json b/editors/code/package.json index e68754ba..0337a911 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -91,6 +91,12 @@ } } ], + "jsonValidation": [ + { + "fileMatch": ".luaurc", + "url": "./schemas/luaurc.json" + } + ], "commands": [ { "command": "luau-lsp.updateApi", diff --git a/editors/code/schemas/luaurc.json b/editors/code/schemas/luaurc.json new file mode 100644 index 00000000..33dcea89 --- /dev/null +++ b/editors/code/schemas/luaurc.json @@ -0,0 +1,104 @@ +{ + "$id": "https://json.schemastore.org/luaurc.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "type": "object", + "properties": { + "languageMode": { + "title": "Type checking mode", + "description": "A option that will affect which errors will be detected.", + "default": "nonstrict", + "examples": [ + "strict" + ], + "type": "string", + "enum": ["strict", "nonstrict", "nocheck"] + }, + "lintErrors": { + "title": "Report lint errors", + "description": "A boolean that controls whether lint issues are reported as errors or warnings.", + "default": "false", + "examples": [ + "true" + ], + "type": "boolean" + }, + "typeErrors": { + "title": "Report type errors", + "description": "A boolean that controls whether type issues are reported as errors or warnings.", + "default": "true", + "examples": [ + "false" + ], + "type": "boolean" + }, + "globals": { + "title": "Extra global values", + "description": "An array of strings where each string names a global that the type checker and linter must assume is valid and of type any.", + "examples": [ + [ "describe", "it", "expect" ], + [ "warn" ] + ], + "type": "array", + "items": { "type": "string", "pattern": "^[a-zA-Z_]\\w*" } + }, + "aliases": { + "title": "Require path aliases", + "description": "The path is resolved by first checking if the first word is an alias defined in a .luaurc file. If so, we perform a string substitution.", + "examples": [ + { "Roact": "C:/LuauModules/Roact-v1.4.2" }, + { "@lib": "packages/lib" } + ], + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^(?!\\.{1,2}$)(?!.*\\/)[a-zA-Z0-9\\-\\._]+$": { + "type": "string" + } + } + }, + "lint": { + "title": "Lints to enable", + "description": "Points to an object that maps string literals that correspond to the names of linting rules (see https://luau-lang.org/lint), or \"*\" that means \"all rules\", to a boolean (to enable/disable the lint)", + "examples": [ + { "*": false, "FormatString": true }, + { "LocalShadow": false } + ], + "$comment": "source: https://github.com/luau-lang/luau/blob/master/Config/include/Luau/LinterConfig.h", + "type": "object", + "additionalProperties": false, + "properties": { + "*": { "type": "boolean" }, + "UnknownGlobal": { "type": "boolean" }, + "DeprecatedGlobal": { "type": "boolean" }, + "GlobalUsedAsLocal": { "type": "boolean" }, + "LocalShadow": { "type": "boolean" }, + "SameLineStatement": { "type": "boolean" }, + "MultiLineStatement": { "type": "boolean" }, + "LocalUnused": { "type": "boolean" }, + "FunctionUnused": { "type": "boolean" }, + "ImportUnused": { "type": "boolean" }, + "BuiltinGlobalWrite": { "type": "boolean" }, + "PlaceholderRead": { "type": "boolean" }, + "UnreachableCode": { "type": "boolean" }, + "UnknownType": { "type": "boolean" }, + "ForRange": { "type": "boolean" }, + "UnbalancedAssignment": { "type": "boolean" }, + "ImplicitReturn": { "type": "boolean" }, + "DuplicateLocal": { "type": "boolean" }, + "FormatString": { "type": "boolean" }, + "TableLiteral": { "type": "boolean" }, + "UninitializedLocal": { "type": "boolean" }, + "DuplicateFunction": { "type": "boolean" }, + "DeprecatedApi": { "type": "boolean" }, + "TableOperations": { "type": "boolean" }, + "DuplicateCondition": { "type": "boolean" }, + "MisleadingAndOr": { "type": "boolean" }, + "CommentDirective": { "type": "boolean" }, + "IntegerParsing": { "type": "boolean" }, + "ComparisonPrecedence": { "type": "boolean" }, + "RedundantNativeAttribute": { "type": "boolean" } + } + } + } +} \ No newline at end of file