From 15829bcf39ab13b3c878ba9a957b084f3bcf189b Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Thu, 22 Dec 2022 19:53:38 +0100 Subject: [PATCH 01/19] add LSP-rome --- .gitattributes | 6 + .github/dependabot.yml | 7 + LICENSE | 21 + LSP-rome.sublime-commands | 10 + LSP-rome.sublime-settings | 8 + Main.sublime-menu | 34 + README.md | 18 + dependencies.json | 8 + language-server/package-lock.json | 155 +++ language-server/package.json | 6 + plugin.py | 51 + pyrightconfig.json | 3 + sublime-package.json | 1754 +++++++++++++++++++++++++++++ tox.ini | 14 + 14 files changed, 2095 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 LICENSE create mode 100644 LSP-rome.sublime-commands create mode 100644 LSP-rome.sublime-settings create mode 100644 Main.sublime-menu create mode 100644 README.md create mode 100644 dependencies.json create mode 100644 language-server/package-lock.json create mode 100644 language-server/package.json create mode 100644 plugin.py create mode 100644 pyrightconfig.json create mode 100644 sublime-package.json create mode 100644 tox.ini diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..57c101c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +.dependabot export-ignore +.github/ export-ignore +codecov.yml export-ignore +mypy.ini export-ignore +tox.ini export-ignore +unittesting.json export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2e6915c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: /language-server + schedule: + interval: daily + time: "11:00" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..35ea22e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 SublimeLSP + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LSP-rome.sublime-commands b/LSP-rome.sublime-commands new file mode 100644 index 0000000..da1f41b --- /dev/null +++ b/LSP-rome.sublime-commands @@ -0,0 +1,10 @@ +[ + { + "caption": "Preferences: LSP-rome Settings", + "command": "edit_settings", + "args": { + "base_file": "${packages}/LSP-rome/LSP-rome.sublime-settings", + "default": "// Settings in here override those in \"LSP-rome/LSP-rome.sublime-settings\"\n\n{\n\t$0\n}\n" + } + }, +] diff --git a/LSP-rome.sublime-settings b/LSP-rome.sublime-settings new file mode 100644 index 0000000..7dffd85 --- /dev/null +++ b/LSP-rome.sublime-settings @@ -0,0 +1,8 @@ +{ + "settings": { + // Enable/Disable Rome handling renames in the workspace. (Experimental) + "rome.rename": null + }, + "command": ["${server_path}", "lsp-proxy"], + "selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", +} diff --git a/Main.sublime-menu b/Main.sublime-menu new file mode 100644 index 0000000..b36ad23 --- /dev/null +++ b/Main.sublime-menu @@ -0,0 +1,34 @@ +[ + { + "id": "preferences", + "children": [ + { + "caption": "Package Settings", + "mnemonic": "P", + "id": "package-settings", + "children": [ + { + "caption": "LSP", + "id": "lsp-settings", + "children": [ + { + "caption": "Servers", + "id": "lsp-servers", + "children": [ + { + "caption": "LSP-rome", + "command": "edit_settings", + "args": { + "base_file": "${packages}/LSP-rome/LSP-rome.sublime-settings", + "default": "// Settings in here override those in \"LSP-rome/LSP-rome.sublime-settings\"\n\n{\n\t$0\n}\n", + } + } + ] + } + ] + } + ] + } + ] + } +] diff --git a/README.md b/README.md new file mode 100644 index 0000000..76b9e24 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# LSP-rome + +Rome LSP server for Sublime LSP provided through [Rome](https://rome.tools/). + +## Installation + +1. Install [LSP](https://packagecontrol.io/packages/LSP) and [LSP-rome](https://packagecontrol.io/packages/LSP-rome) via Package Control. +2. (Optional but recommended) Install [LSP-file-watcher-chokidar](https://github.com/sublimelsp/LSP-file-watcher-chokidar) via Package Control to enable functionality to notify the server about changes to `rome.json` configuration file. +3. Restart Sublime. + +### Configuration + +Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. + +#### languages + +Defines on which types of files the ESLint server will run. + diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 0000000..3d55a18 --- /dev/null +++ b/dependencies.json @@ -0,0 +1,8 @@ +{ + "*": { + "*": [ + "lsp_utils", + "sublime_lib" + ] + } +} diff --git a/language-server/package-lock.json b/language-server/package-lock.json new file mode 100644 index 0000000..4a7bca7 --- /dev/null +++ b/language-server/package-lock.json @@ -0,0 +1,155 @@ +{ + "name": "language-server", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "rome": "^11.0.0" + } + }, + "node_modules/@rometools/cli-darwin-arm64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-11.0.0.tgz", + "integrity": "sha512-F3vkdY+s3FLIEnAjSbyHTuIPB88cLpccimW4ecid5I7S6GzGG3iUJI4xT00JhH73K4P/qW20/9r+kH1T9Du8Xg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rometools/cli-darwin-x64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-11.0.0.tgz", + "integrity": "sha512-X6jhtS6Iml4GOzgNtnLwIp/KXXhSdqeVyfv69m/AHnIzx3gQAjPZ7BPnJLvTCbhe4SKHL+uTZYFSCJpkUUKE6w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rometools/cli-linux-arm64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-11.0.0.tgz", + "integrity": "sha512-dktTJJlTpmycBZ2TwhJBcAO8ztK8DdevdyZnFFxdYRvtmJgTjIsC2UFayf/SbKew8B8q1IhI0it+D6ihAeIpeg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rometools/cli-linux-x64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-11.0.0.tgz", + "integrity": "sha512-WVcnXPNdWGUWo0p4NU8YzuthjYR7q+b4vRcjdxtP1DlpphZmSsoC/RSE85nEqRAz8hChcKUansVzOPM8BSsuGA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rometools/cli-win32-arm64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-11.0.0.tgz", + "integrity": "sha512-tPj6RThQzS7Q45jqQll7NlTYvNcsg/BEP3LYiiazqSh9FAFnMkrV6ewUcMPKWyAfiyLs7jlz4rRvdNRUSygzfQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rometools/cli-win32-x64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-11.0.0.tgz", + "integrity": "sha512-bmBai8WHxYjsGk1+je7ZTfCUCWq30WJI3pQM8pzTA674lfGTZ9ymJoZwTaIMSO4rL5V9mlO6uLunsBKso9VqOg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/rome": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/rome/-/rome-11.0.0.tgz", + "integrity": "sha512-rRo6JOwpMLc3OkeTDRXkrmrDqnxDvZ75GS4f0jLDBNmRgDXWbu0F8eVnJoRn+VbK2AE7vWvhVOMBjnWowcopkQ==", + "hasInstallScript": true, + "bin": { + "rome": "bin/rome" + }, + "engines": { + "node": ">=14.*" + }, + "optionalDependencies": { + "@rometools/cli-darwin-arm64": "11.0.0", + "@rometools/cli-darwin-x64": "11.0.0", + "@rometools/cli-linux-arm64": "11.0.0", + "@rometools/cli-linux-x64": "11.0.0", + "@rometools/cli-win32-arm64": "11.0.0", + "@rometools/cli-win32-x64": "11.0.0" + } + } + }, + "dependencies": { + "@rometools/cli-darwin-arm64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-11.0.0.tgz", + "integrity": "sha512-F3vkdY+s3FLIEnAjSbyHTuIPB88cLpccimW4ecid5I7S6GzGG3iUJI4xT00JhH73K4P/qW20/9r+kH1T9Du8Xg==", + "optional": true + }, + "@rometools/cli-darwin-x64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-11.0.0.tgz", + "integrity": "sha512-X6jhtS6Iml4GOzgNtnLwIp/KXXhSdqeVyfv69m/AHnIzx3gQAjPZ7BPnJLvTCbhe4SKHL+uTZYFSCJpkUUKE6w==", + "optional": true + }, + "@rometools/cli-linux-arm64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-11.0.0.tgz", + "integrity": "sha512-dktTJJlTpmycBZ2TwhJBcAO8ztK8DdevdyZnFFxdYRvtmJgTjIsC2UFayf/SbKew8B8q1IhI0it+D6ihAeIpeg==", + "optional": true + }, + "@rometools/cli-linux-x64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-11.0.0.tgz", + "integrity": "sha512-WVcnXPNdWGUWo0p4NU8YzuthjYR7q+b4vRcjdxtP1DlpphZmSsoC/RSE85nEqRAz8hChcKUansVzOPM8BSsuGA==", + "optional": true + }, + "@rometools/cli-win32-arm64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-11.0.0.tgz", + "integrity": "sha512-tPj6RThQzS7Q45jqQll7NlTYvNcsg/BEP3LYiiazqSh9FAFnMkrV6ewUcMPKWyAfiyLs7jlz4rRvdNRUSygzfQ==", + "optional": true + }, + "@rometools/cli-win32-x64": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-11.0.0.tgz", + "integrity": "sha512-bmBai8WHxYjsGk1+je7ZTfCUCWq30WJI3pQM8pzTA674lfGTZ9ymJoZwTaIMSO4rL5V9mlO6uLunsBKso9VqOg==", + "optional": true + }, + "rome": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/rome/-/rome-11.0.0.tgz", + "integrity": "sha512-rRo6JOwpMLc3OkeTDRXkrmrDqnxDvZ75GS4f0jLDBNmRgDXWbu0F8eVnJoRn+VbK2AE7vWvhVOMBjnWowcopkQ==", + "requires": { + "@rometools/cli-darwin-arm64": "11.0.0", + "@rometools/cli-darwin-x64": "11.0.0", + "@rometools/cli-linux-arm64": "11.0.0", + "@rometools/cli-linux-x64": "11.0.0", + "@rometools/cli-win32-arm64": "11.0.0", + "@rometools/cli-win32-x64": "11.0.0" + } + } + } +} diff --git a/language-server/package.json b/language-server/package.json new file mode 100644 index 0000000..8d7af33 --- /dev/null +++ b/language-server/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "rome": "^11.0.0" + } +} diff --git a/plugin.py b/plugin.py new file mode 100644 index 0000000..e063899 --- /dev/null +++ b/plugin.py @@ -0,0 +1,51 @@ +from LSP.plugin import ClientConfig, WorkspaceFolder +from LSP.plugin.core.typing import List, Optional +from lsp_utils import NpmClientHandler +import os +import sublime + + +PLATFORMS = { + 'windows': { + 'x64': '@rometools/cli-win32-x64/rome.exe', + 'arm64': '@rometools/cli-win32-arm64/rome.exe', + }, + 'osx': { + 'x64': '@rometools/cli-darwin-x64/rome', + 'arm64': '@rometools/cli-darwin-arm64/rome', + }, + 'linux': { + 'x64': '@rometools/cli-linux-x64/rome', + 'arm64': '@rometools/cli-linux-arm64/rome', + }, +} + + +def resolve_platform_binary() -> Optional[str]: + return PLATFORMS.get(sublime.platform(), {}).get(sublime.arch()) + + +class LspRomePlugin(NpmClientHandler): + package_name = __package__ + server_directory = 'language-server' + server_binary_path = os.path.join(server_directory, 'node_modules', resolve_platform_binary() or '') + + @classmethod + def is_allowed_to_start( + cls, + window: sublime.Window, + initiating_view: Optional[sublime.View] = None, + workspace_folders: Optional[List[WorkspaceFolder]] = None, + configuration: Optional[ClientConfig] = None + ) -> Optional[str]: + if not resolve_platform_binary(): + return 'LSP-rome does not support your platform currently.' + return None + + +def plugin_loaded() -> None: + LspRomePlugin.setup() + + +def plugin_unloaded() -> None: + LspRomePlugin.cleanup() diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..eb7655d --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,3 @@ +{ + "pythonVersion": "3.11" +} diff --git a/sublime-package.json b/sublime-package.json new file mode 100644 index 0000000..17b041f --- /dev/null +++ b/sublime-package.json @@ -0,0 +1,1754 @@ +{ + "contributions": { + "settings": [ + { + "file_patterns": [ + "/LSP-rome.sublime-settings" + ], + "schema": { + "$id": "sublime://settings/LSP-rome", + "definitions": { + "PluginConfig": { + "properties": { + "settings": { + "type": "object", + "additionalProperties": false, + "properties": { + "rome.rename": { + "type": [ + "boolean", + "null" + ], + "default": null, + "markdownDescription": "Enable/Disable Rome handling renames in the workspace. (Experimental)" + } + } + } + } + } + }, + "type": "object", + "allOf": [ + { + "$ref": "sublime://settings/LSP-plugin-base" + }, + { + "$ref": "sublime://settings/LSP-rome#/definitions/PluginConfig" + } + ] + } + }, + { + "file_patterns": [ + "/*.sublime-project" + ], + "schema": { + "properties": { + "settings": { + "properties": { + "LSP": { + "properties": { + "LSP-rome": { + "$ref": "sublime://settings/LSP-rome#/definitions/PluginConfig" + } + } + } + } + } + } + } + }, + { + "file_patterns": [ + "/rome.json", + ], + "schema": { + "properties": { + "$schema": { + "description": "A field for the [JSON schema](https://json-schema.org/) specification", + "type": [ + "string", + "null" + ] + }, + "files": { + "description": "The configuration of the filesystem", + "defaultSnippets": [ + { + "body": { + "ignore": ["$0"], + "maxSize": null, + } + } + ], + "anyOf": [ + { + "$ref": "#/definitions/FilesConfiguration" + }, + { + "type": "null" + } + ] + }, + "formatter": { + "description": "The configuration of the formatter", + "defaultSnippets": [ + { + "body": { + "formatWithErrors": false, + "ignore": null, + "indentSize": 2, + "lineWidth": 80, + } + } + ], + "anyOf": [ + { + "$ref": "#/definitions/FormatterConfiguration" + }, + { + "type": "null" + } + ] + }, + "javascript": { + "description": "Specific configuration for the JavaScript language", + "anyOf": [ + { + "$ref": "#/definitions/JavascriptConfiguration" + }, + { + "type": "null" + } + ] + }, + "linter": { + "description": "The configuration for the linter", + "anyOf": [ + { + "$ref": "#/definitions/LinterConfiguration" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "A11y": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAutofocus": { + "description": "Avoid the autoFocus attribute", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBlankTarget": { + "description": "Disallow target=\"_blank\" attribute without rel=\"noreferrer\"", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPositiveTabindex": { + "description": "Prevent the usage of positive integers on tabIndex property", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAltText": { + "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAnchorContent": { + "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useButtonType": { + "description": "Enforces the usage of the attribute type for the element button", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHtmlLang": { + "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithClickEvents": { + "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useKeyWithMouseEvents": { + "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAnchor": { + "description": "Enforce that all anchors are valid, and they are navigable elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Complexity": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noExtraBooleanCast": { + "description": "Disallow unnecessary boolean casts", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noMultipleSpacesInRegularExpressionLiterals": { + "description": "Disallow unclear usage of multiple space characters in regular expression literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessFragments": { + "description": "Disallow unnecessary fragments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useFlatMap": { + "description": "Promotes the use of .flatMap() when map().flat() are used together.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useOptionalChain": { + "description": "Enforce using concise optional chain instead of chained logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSimplifiedLogicExpression": { + "description": "Discard redundant terms from logical expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Correctness": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noChildrenProp": { + "description": "Prevent passing of children as props.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstAssign": { + "description": "Prevents from having const variables being re-assigned.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyPattern": { + "description": "Disallows empty destructuring patterns.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNewSymbol": { + "description": "Disallow new operators with the Symbol object", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRenderReturnValue": { + "description": "Prevent the usage of the return value of React.render.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUndeclaredVariables": { + "description": "Prevents the usage of variables that haven't been declared inside the document", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnnecessaryContinue": { + "description": "Avoid using unnecessary continue.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachable": { + "description": "Disallow unreachable code", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedVariables": { + "description": "Disallow unused variables.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidElementsWithChildren": { + "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useValidForDirection": { + "description": "Enforce \"for\" loop update clause moving the counter in the right direction.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "FilesConfiguration": { + "description": "The configuration of the filesystem", + "type": "object", + "properties": { + "ignore": { + "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "maxSize": { + "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + } + }, + "additionalProperties": false + }, + "FormatterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "default": true, + "type": "boolean" + }, + "formatWithErrors": { + "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", + "default": false, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "indentSize": { + "description": "The size of the indentation, 2 by default", + "default": 2, + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "indentStyle": { + "description": "The indent style.", + "default": "tab", + "allOf": [ + { + "$ref": "#/definitions/PlainIndentStyle" + } + ] + }, + "lineWidth": { + "description": "What's the max width of a line. Defaults to 80.", + "default": 80, + "allOf": [ + { + "$ref": "#/definitions/LineWidth" + } + ] + } + }, + "additionalProperties": false + }, + "JavascriptConfiguration": { + "type": "object", + "properties": { + "formatter": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptFormatter" + }, + { + "type": "null" + } + ] + }, + "globals": { + "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false + }, + "JavascriptFormatter": { + "type": "object", + "properties": { + "quoteProperties": { + "description": "When properties in objects are quoted. Defaults to asNeeded.", + "default": "asNeeded", + "allOf": [ + { + "$ref": "#/definitions/QuoteProperties" + } + ] + }, + "quoteStyle": { + "description": "The style for quotes. Defaults to double.", + "default": "double", + "allOf": [ + { + "$ref": "#/definitions/QuoteStyle" + } + ] + }, + "semicolons": { + "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", + "default": "always", + "allOf": [ + { + "$ref": "#/definitions/Semicolons" + } + ] + }, + "trailingComma": { + "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", + "default": "all", + "allOf": [ + { + "$ref": "#/definitions/TrailingComma" + } + ] + } + }, + "additionalProperties": false + }, + "LineWidth": { + "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", + "type": "integer", + "format": "uint16", + "minimum": 0.0 + }, + "LinterConfiguration": { + "type": "object", + "properties": { + "enabled": { + "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", + "default": true, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "rules": { + "description": "List of rules", + "default": { + "recommended": true + }, + "anyOf": [ + { + "$ref": "#/definitions/Rules" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Nursery": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noAccessKey": { + "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAssignInExpressions": { + "description": "Disallow assignments in expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noBannedTypes": { + "description": "Disallow certain types.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noClassAssign": { + "description": "Disallow reassigning class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommaOperator": { + "description": "Disallow comma operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstEnum": { + "description": "Disallow TypeScript const enum", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noConstructorReturn": { + "description": "Disallow returning a value from a constructor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDistractingElements": { + "description": "Enforces that no distracting elements are used.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateCase": { + "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateObjectKeys": { + "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyInterface": { + "description": "Disallow the declaration of empty interfaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraNonNullAssertion": { + "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExtraSemicolons": { + "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noHeaderScope": { + "description": "Check that the scope attribute is only used on th elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInvalidConstructorSuper": { + "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNonNullAssertion": { + "description": "Disallow non-null assertions using the ! postfix operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noPrecisionLoss": { + "description": "Disallow literal numbers that lose precision", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedundantUseStrict": { + "description": "Prevents from having redundant \"use strict\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSetterReturn": { + "description": "Disallow returning a value from a setter", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noStringCaseMismatch": { + "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeFinally": { + "description": "Disallow control flow statements in finally blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVar": { + "description": "Disallow the use of var", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noWith": { + "description": "Disallow with statements in non-strict contexts.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useCamelCase": { + "description": "Enforce camel case naming convention.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useConst": { + "description": "Require const declarations for variables that are never reassigned after declared.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultParameterLast": { + "description": "Enforce default function parameters and optional parameters to be last.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultSwitchClauseLast": { + "description": "Enforce default clauses in switch statements to be last", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useEnumInitializers": { + "description": "Require that each enum member value be explicitly initialized.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExponentiationOperator": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIframeTitle": { + "description": "Enforces the usage of the attribute title for the element iframe", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIsNan": { + "description": "Require calls to isNaN() when checking for NaN.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useMediaCaption": { + "description": "Enforces that audio and video elements must have a track for captions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useNumericLiterals": { + "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidAriaProps": { + "description": "Ensures that ARIA properties aria-* are all valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidLang": { + "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Performance": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDelete": { + "description": "Disallow the use of the delete operator", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + } + } + }, + "PlainIndentStyle": { + "type": "string", + "enum": [ + "tab", + "space" + ] + }, + "QuoteProperties": { + "type": "string", + "enum": [ + "asNeeded", + "preserve" + ] + }, + "QuoteStyle": { + "type": "string", + "enum": [ + "double", + "single" + ] + }, + "RuleConfiguration": { + "anyOf": [ + { + "$ref": "#/definitions/RulePlainConfiguration" + }, + { + "$ref": "#/definitions/RuleWithOptions" + } + ] + }, + "RulePlainConfiguration": { + "type": "string", + "enum": [ + "warn", + "error", + "off" + ] + }, + "RuleWithOptions": { + "type": "object", + "required": [ + "level", + "options" + ], + "properties": { + "level": { + "$ref": "#/definitions/RulePlainConfiguration" + }, + "options": true + }, + "additionalProperties": false + }, + "Rules": { + "type": "object", + "properties": { + "a11y": { + "anyOf": [ + { + "$ref": "#/definitions/A11y" + }, + { + "type": "null" + } + ] + }, + "complexity": { + "anyOf": [ + { + "$ref": "#/definitions/Complexity" + }, + { + "type": "null" + } + ] + }, + "correctness": { + "anyOf": [ + { + "$ref": "#/definitions/Correctness" + }, + { + "type": "null" + } + ] + }, + "nursery": { + "anyOf": [ + { + "$ref": "#/definitions/Nursery" + }, + { + "type": "null" + } + ] + }, + "performance": { + "anyOf": [ + { + "$ref": "#/definitions/Performance" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the lint rules recommended by Rome. `true` by default.", + "type": [ + "boolean", + "null" + ] + }, + "security": { + "anyOf": [ + { + "$ref": "#/definitions/Security" + }, + { + "type": "null" + } + ] + }, + "style": { + "anyOf": [ + { + "$ref": "#/definitions/Style" + }, + { + "type": "null" + } + ] + }, + "suspicious": { + "anyOf": [ + { + "$ref": "#/definitions/Suspicious" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Security": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noDangerouslySetInnerHtml": { + "description": "Prevent the usage of dangerous JSX props", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDangerouslySetInnerHtmlWithChildren": { + "description": "Report when a DOM element or a component uses both children and dangerouslySetInnerHTML prop.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + } + } + }, + "Semicolons": { + "type": "string", + "enum": [ + "always", + "asNeeded" + ] + }, + "Style": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArguments": { + "description": "Disallow the use of arguments", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImplicitBoolean": { + "description": "Disallow implicit true values on JSX boolean attributes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNegationElse": { + "description": "Disallow negation in the condition of an if statement if it has an else clause", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShoutyConstants": { + "description": "Disallow the use of constants which its value is the upper-case version of its name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnusedTemplateLiteral": { + "description": "Disallow template literals if interpolation and special-character handling are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useBlockStatements": { + "description": "Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useFragmentSyntax": { + "description": "This rule enforces the use of <>... over ....", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSelfClosingElements": { + "description": "Prevent extra closing tags for components without children", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useShorthandArrayType": { + "description": "When expressing array types, this rule promotes the usage of T[] shorthand instead of Array.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleCaseStatement": { + "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useSingleVarDeclarator": { + "description": "Disallow multiple variable declarations in the same variable statement", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useTemplate": { + "description": "Template literals are preferred over string concatenation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useWhile": { + "description": "Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "Suspicious": { + "description": "A list of rules that belong to this group", + "type": "object", + "properties": { + "noArrayIndexKey": { + "description": "Discourage the usage of Array index in keys.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noAsyncPromiseExecutor": { + "description": "Disallows using an async function as a Promise executor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCatchAssign": { + "description": "Disallow reassigning exceptions in catch clauses", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCommentText": { + "description": "Prevent comments from being inserted as text nodes", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noCompareNegZero": { + "description": "Disallow comparing against -0", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDebugger": { + "description": "Disallow the use of debugger", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDoubleEquals": { + "description": "Require the use of === and !==", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateParameters": { + "description": "Disallow duplicate function arguments name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noExplicitAny": { + "description": "Disallow the any type usage.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noFunctionAssign": { + "description": "Disallow reassigning function declarations.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noImportAssign": { + "description": "Disallow assigning to imported bindings", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noLabelVar": { + "description": "Disallow labels that share a name with a variable", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noShadowRestrictedNames": { + "description": "Disallow identifiers from shadowing restricted names.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSparseArray": { + "description": "Disallow sparse arrays", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUnsafeNegation": { + "description": "Disallow using unsafe negation.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useValidTypeof": { + "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + } + } + }, + "TrailingComma": { + "type": "string", + "enum": [ + "all", + "es5", + "none" + ] + } + } + } + }, + ] + } +} diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..3d9d8cb --- /dev/null +++ b/tox.ini @@ -0,0 +1,14 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py3 +skipsdist = True + +[pycodestyle] +max-line-length = 120 + +[flake8] +max-line-length = 120 From a15be466e39eb74838fd422d55a1b7900f67b1fd Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Thu, 22 Dec 2022 19:56:17 +0100 Subject: [PATCH 02/19] pyrightconfig.json --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 57c101c..f3faa53 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,5 +2,6 @@ .github/ export-ignore codecov.yml export-ignore mypy.ini export-ignore +pyrightconfig.json export-ignore tox.ini export-ignore unittesting.json export-ignore From 90e20fc24260264967863d4f8ead4d3c8d3cbbb4 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 21 Jan 2023 17:55:09 +0100 Subject: [PATCH 03/19] resolve rome binary from workspace --- LSP-rome.sublime-settings | 9 ++-- README.md | 16 +++++-- plugin.py | 87 ++++++++++++++++++++++++++++++++++----- sublime-package.json | 15 ++++++- 4 files changed, 108 insertions(+), 19 deletions(-) diff --git a/LSP-rome.sublime-settings b/LSP-rome.sublime-settings index 7dffd85..6ed6ebb 100644 --- a/LSP-rome.sublime-settings +++ b/LSP-rome.sublime-settings @@ -1,8 +1,11 @@ { + "selector": "source.json | source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", "settings": { + // The rome lsp server executable. If the path is relative, the workspace folder will be used as base path. + "rome.lspBin": null, // Enable/Disable Rome handling renames in the workspace. (Experimental) - "rome.rename": null + "rome.rename": null, + // Require a Rome configuration file to enable syntax errors, formatting and linting. + "rome.requireConfiguration": false, }, - "command": ["${server_path}", "lsp-proxy"], - "selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", } diff --git a/README.md b/README.md index 76b9e24..7eb30b0 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,26 @@ # LSP-rome -Rome LSP server for Sublime LSP provided through [Rome](https://rome.tools/). +[Rome](https://rome.tools/) is a unified linter and formatter for JavaScript and TypeScript files. + +This package enables Sublime Text integration so that you can: + - Format files on save or when issuing the `LSP: Format Document` command + - See linting hints while you type and apply code fixes + - Perform refactors ## Installation 1. Install [LSP](https://packagecontrol.io/packages/LSP) and [LSP-rome](https://packagecontrol.io/packages/LSP-rome) via Package Control. -2. (Optional but recommended) Install [LSP-file-watcher-chokidar](https://github.com/sublimelsp/LSP-file-watcher-chokidar) via Package Control to enable functionality to notify the server about changes to `rome.json` configuration file. +2. (Optional but recommended) Install [LSP-file-watcher-chokidar](https://github.com/sublimelsp/LSP-file-watcher-chokidar) via Package Control to enable functionality to notify the server about changes to the `rome.json` configuration file. 3. Restart Sublime. ### Configuration Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. -#### languages +## Rome Resolution + +The package tries to use Rome from your project's local dependencies (`node_modules/rome`). We recommend adding Rome as a project dependency to ensure that NPM scripts and the extension use the same Rome version. -Defines on which types of files the ESLint server will run. +You can also explicitly specify the `rome` binary the extension should use by configuring the `rome.lspBin` setting in `LSP-rome` Settings. +If the project has no dependency on Rome and no explicit path is configured, the extension uses the Rome version managed by this package. diff --git a/plugin.py b/plugin.py index e063899..6f76dcf 100644 --- a/plugin.py +++ b/plugin.py @@ -1,28 +1,48 @@ from LSP.plugin import ClientConfig, WorkspaceFolder -from LSP.plugin.core.typing import List, Optional +from LSP.plugin.core.typing import Dict, List, Optional from lsp_utils import NpmClientHandler +import json import os import sublime PLATFORMS = { 'windows': { - 'x64': '@rometools/cli-win32-x64/rome.exe', - 'arm64': '@rometools/cli-win32-arm64/rome.exe', + 'x64': { + 'binary': '@rometools/cli-win32-x64/rome.exe', + 'package': '@rometools/cli-win32-x64' + }, + 'arm64': { + 'binary': '@rometools/cli-win32-arm64/rome.exe', + 'package': '@rometools/cli-win32-arm64' + }, }, 'osx': { - 'x64': '@rometools/cli-darwin-x64/rome', - 'arm64': '@rometools/cli-darwin-arm64/rome', + 'x64': { + 'binary': '@rometools/cli-darwin-x64/rome', + 'package': '@rometools/cli-darwin-x64' + }, + 'arm64': { + 'binary': '@rometools/cli-darwin-arm64/rome', + 'package': '@rometools/cli-darwin-arm64' + }, }, 'linux': { - 'x64': '@rometools/cli-linux-x64/rome', - 'arm64': '@rometools/cli-linux-arm64/rome', + 'x64': { + 'binary': '@rometools/cli-linux-x64/rome', + 'package': '@rometools/cli-linux-x64' + }, + 'arm64': { + 'binary': '@rometools/cli-linux-arm64/rome', + 'package': '@rometools/cli-linux-arm64' + }, }, } +RESOLVED_PLATFORM = PLATFORMS.get(sublime.platform(), {}).get(sublime.arch(), {}) # type: Optional[Dict[str, str]] def resolve_platform_binary() -> Optional[str]: - return PLATFORMS.get(sublime.platform(), {}).get(sublime.arch()) + return RESOLVED_PLATFORM.get('binary') if RESOLVED_PLATFORM else None class LspRomePlugin(NpmClientHandler): @@ -34,12 +54,57 @@ class LspRomePlugin(NpmClientHandler): def is_allowed_to_start( cls, window: sublime.Window, - initiating_view: Optional[sublime.View] = None, - workspace_folders: Optional[List[WorkspaceFolder]] = None, - configuration: Optional[ClientConfig] = None + initiating_view: sublime.View, + workspace_folders: List[WorkspaceFolder], + configuration: ClientConfig ) -> Optional[str]: if not resolve_platform_binary(): return 'LSP-rome does not support your platform currently.' + rome_path = cls._resolve_rome_path(workspace_folders, configuration) + if not rome_path: + return 'LSP-rome could not resolve specified rome binary.' + configuration.command = [rome_path, 'lsp-proxy'] + return None + + @classmethod + def _resolve_rome_path(cls, workspace_folders: List[WorkspaceFolder], configuration: ClientConfig) -> Optional[str]: + rome_lsp_bin = configuration.settings.get('rome.lspBin') + if isinstance(rome_lsp_bin, str) and rome_lsp_bin: + return cls._get_workspace_relative_path(rome_lsp_bin, workspace_folders) + return cls._get_workspace_dependency(workspace_folders) or '${server_path}' + + @classmethod + def _get_workspace_relative_path(cls, rome_lsp_bin: str, workspace_folders: List[WorkspaceFolder]) -> Optional[str]: + if os.path.isabs(rome_lsp_bin): + return rome_lsp_bin + for folder in workspace_folders: + possible_path = os.path.join(folder.path, rome_lsp_bin) + if os.path.isfile(possible_path): + return possible_path + return None + + @classmethod + def _get_workspace_dependency(cls, workspace_folders: List[WorkspaceFolder]) -> Optional[str]: + if not RESOLVED_PLATFORM: + return + package_name = RESOLVED_PLATFORM['package'] + package_json = os.path.join(package_name, 'package.json'); + binary_name = os.path.join(package_name, ('rome.exe' if 'win32' in package_name else 'rome')) + for folder in workspace_folders: + package_json_path = os.path.join(folder.path, 'node_modules', package_json) + binary_path = os.path.join(folder.path, 'node_modules', binary_name) + if not os.path.isfile(package_json_path) or not os.path.isfile(binary_path): + continue + try: + with open(package_json_path , 'r') as fp: + version = json.loads(fp.read())['version'] + # Ignore versions lower than 0.9.0 as those didn't embed LSP server. + version_tuple = tuple(map(int, (version.split('.')))) + if len(version_tuple) == 3 and version_tuple < (0, 9, 0): + continue + return binary_path + except: + continue return None diff --git a/sublime-package.json b/sublime-package.json index 17b041f..3d8234e 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -14,6 +14,14 @@ "type": "object", "additionalProperties": false, "properties": { + "rome.lspBin": { + "type": [ + "string", + "null" + ], + "default": null, + "markdownDescription": "The rome lsp server executable. If the path is relative, the workspace folder will be used as base path." + }, "rome.rename": { "type": [ "boolean", @@ -21,7 +29,12 @@ ], "default": null, "markdownDescription": "Enable/Disable Rome handling renames in the workspace. (Experimental)" - } + }, + "rome.requireConfiguration": { + "type": "boolean", + "default": false, + "markdownDescription": "Require a Rome configuration file to enable syntax errors, formatting and linting." + }, } } } From 604f068e32a723faaba1238e7844494347b029b4 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 21 Jan 2023 19:13:18 +0100 Subject: [PATCH 04/19] less code --- plugin.py | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/plugin.py b/plugin.py index 6f76dcf..726f044 100644 --- a/plugin.py +++ b/plugin.py @@ -6,43 +6,27 @@ import sublime -PLATFORMS = { +PACKAGE_NAMES = { 'windows': { - 'x64': { - 'binary': '@rometools/cli-win32-x64/rome.exe', - 'package': '@rometools/cli-win32-x64' - }, - 'arm64': { - 'binary': '@rometools/cli-win32-arm64/rome.exe', - 'package': '@rometools/cli-win32-arm64' - }, + 'x64': '@rometools/cli-win32-x64', + 'arm64': '@rometools/cli-win32-arm64', }, 'osx': { - 'x64': { - 'binary': '@rometools/cli-darwin-x64/rome', - 'package': '@rometools/cli-darwin-x64' - }, - 'arm64': { - 'binary': '@rometools/cli-darwin-arm64/rome', - 'package': '@rometools/cli-darwin-arm64' - }, + 'x64': '@rometools/cli-darwin-x64', + 'arm64': '@rometools/cli-darwin-arm64', }, 'linux': { - 'x64': { - 'binary': '@rometools/cli-linux-x64/rome', - 'package': '@rometools/cli-linux-x64' - }, - 'arm64': { - 'binary': '@rometools/cli-linux-arm64/rome', - 'package': '@rometools/cli-linux-arm64' - }, + 'x64': '@rometools/cli-linux-x64', + 'arm64': '@rometools/cli-linux-arm64', }, } -RESOLVED_PLATFORM = PLATFORMS.get(sublime.platform(), {}).get(sublime.arch(), {}) # type: Optional[Dict[str, str]] +RESOLVED_PACKAGE_NAME = PACKAGE_NAMES.get(sublime.platform(), {}).get(sublime.arch()) # type: Optional[str] def resolve_platform_binary() -> Optional[str]: - return RESOLVED_PLATFORM.get('binary') if RESOLVED_PLATFORM else None + if not RESOLVED_PACKAGE_NAME: + return None + return os.path.join(RESOLVED_PACKAGE_NAME, ('rome.exe' if sublime.platform() == 'windows' else 'rome')) class LspRomePlugin(NpmClientHandler): @@ -85,11 +69,10 @@ def _get_workspace_relative_path(cls, rome_lsp_bin: str, workspace_folders: List @classmethod def _get_workspace_dependency(cls, workspace_folders: List[WorkspaceFolder]) -> Optional[str]: - if not RESOLVED_PLATFORM: + binary_name = resolve_platform_binary() + if not RESOLVED_PACKAGE_NAME or not binary_name: return - package_name = RESOLVED_PLATFORM['package'] - package_json = os.path.join(package_name, 'package.json'); - binary_name = os.path.join(package_name, ('rome.exe' if 'win32' in package_name else 'rome')) + package_json = os.path.join(RESOLVED_PACKAGE_NAME, 'package.json'); for folder in workspace_folders: package_json_path = os.path.join(folder.path, 'node_modules', package_json) binary_path = os.path.join(folder.path, 'node_modules', binary_name) From ee6ea6ca900dff1472609e5c54d63c39bf8d79e9 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Fri, 14 Apr 2023 23:46:28 +0200 Subject: [PATCH 05/19] rome 12 --- language-server/package-lock.json | 110 +++++++++++++++--------------- language-server/package.json | 2 +- plugin.py | 19 ++++-- pyproject.toml | 8 +++ 4 files changed, 79 insertions(+), 60 deletions(-) create mode 100644 pyproject.toml diff --git a/language-server/package-lock.json b/language-server/package-lock.json index 4a7bca7..85e7f5b 100644 --- a/language-server/package-lock.json +++ b/language-server/package-lock.json @@ -5,13 +5,13 @@ "packages": { "": { "dependencies": { - "rome": "^11.0.0" + "rome": "^12.0.0" } }, "node_modules/@rometools/cli-darwin-arm64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-11.0.0.tgz", - "integrity": "sha512-F3vkdY+s3FLIEnAjSbyHTuIPB88cLpccimW4ecid5I7S6GzGG3iUJI4xT00JhH73K4P/qW20/9r+kH1T9Du8Xg==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.0.0.tgz", + "integrity": "sha512-kEFCzU6cgy6vfY0mkMzq57ea3srqV5X2wyCAxjVfA2JF7fioq695uWhy7yOCBW+nUUFIz62N9v1nf/aYqX8XkA==", "cpu": [ "arm64" ], @@ -21,9 +21,9 @@ ] }, "node_modules/@rometools/cli-darwin-x64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-11.0.0.tgz", - "integrity": "sha512-X6jhtS6Iml4GOzgNtnLwIp/KXXhSdqeVyfv69m/AHnIzx3gQAjPZ7BPnJLvTCbhe4SKHL+uTZYFSCJpkUUKE6w==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.0.0.tgz", + "integrity": "sha512-YDevVPKrkRFdjjM/3zOpOWI5mEY2ivjKM2eR8Yqv9xH3SZhyD/t67f/xo7Azp6NkGUVXSnHLGdkmIg+qrYgz5A==", "cpu": [ "x64" ], @@ -33,9 +33,9 @@ ] }, "node_modules/@rometools/cli-linux-arm64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-11.0.0.tgz", - "integrity": "sha512-dktTJJlTpmycBZ2TwhJBcAO8ztK8DdevdyZnFFxdYRvtmJgTjIsC2UFayf/SbKew8B8q1IhI0it+D6ihAeIpeg==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.0.0.tgz", + "integrity": "sha512-n2LJg6eAZENUcJF99wjDeqQCr/40IqGUJDbX7NwiU1RvCy+RBZNmhcmSAaKOc6rCoLUcM9W5q+H4jfn4bWfJBA==", "cpu": [ "arm64" ], @@ -45,9 +45,9 @@ ] }, "node_modules/@rometools/cli-linux-x64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-11.0.0.tgz", - "integrity": "sha512-WVcnXPNdWGUWo0p4NU8YzuthjYR7q+b4vRcjdxtP1DlpphZmSsoC/RSE85nEqRAz8hChcKUansVzOPM8BSsuGA==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.0.0.tgz", + "integrity": "sha512-VuQO4eOrKmfrLrc8KzMaZypz3i1rD9FXRxwOFk6ha16DNHV+17dRQYm7jRZ1p+HrXdjAJYTScxR/E03yGLThlQ==", "cpu": [ "x64" ], @@ -57,9 +57,9 @@ ] }, "node_modules/@rometools/cli-win32-arm64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-11.0.0.tgz", - "integrity": "sha512-tPj6RThQzS7Q45jqQll7NlTYvNcsg/BEP3LYiiazqSh9FAFnMkrV6ewUcMPKWyAfiyLs7jlz4rRvdNRUSygzfQ==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.0.0.tgz", + "integrity": "sha512-lvOh5/B8YuQdI2ieGJnJ6CUMZxvVwA8+1VDkEZJyl5IEF8AXzbXYx4k6SFA5a79cfXEL9tJuJy0rn+Zs/+1yJQ==", "cpu": [ "arm64" ], @@ -69,9 +69,9 @@ ] }, "node_modules/@rometools/cli-win32-x64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-11.0.0.tgz", - "integrity": "sha512-bmBai8WHxYjsGk1+je7ZTfCUCWq30WJI3pQM8pzTA674lfGTZ9ymJoZwTaIMSO4rL5V9mlO6uLunsBKso9VqOg==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.0.0.tgz", + "integrity": "sha512-yTfz71k8+9QIDzglKnMbEMMv1JUk30qfeSomgEUG2v0qDSbSq0Gs1ff0H0dysYOHLvZZmWA3IheOY/SC8fj1nA==", "cpu": [ "x64" ], @@ -81,9 +81,9 @@ ] }, "node_modules/rome": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/rome/-/rome-11.0.0.tgz", - "integrity": "sha512-rRo6JOwpMLc3OkeTDRXkrmrDqnxDvZ75GS4f0jLDBNmRgDXWbu0F8eVnJoRn+VbK2AE7vWvhVOMBjnWowcopkQ==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/rome/-/rome-12.0.0.tgz", + "integrity": "sha512-w/tLvLj5PGUCx3R+Kna08BMq4zL83Xzh9spvrqoWa3Nkzk16SkD8JSpyWWP9WhI2r3qv3Xvc7FnYZ4QDnjAiYg==", "hasInstallScript": true, "bin": { "rome": "bin/rome" @@ -92,63 +92,63 @@ "node": ">=14.*" }, "optionalDependencies": { - "@rometools/cli-darwin-arm64": "11.0.0", - "@rometools/cli-darwin-x64": "11.0.0", - "@rometools/cli-linux-arm64": "11.0.0", - "@rometools/cli-linux-x64": "11.0.0", - "@rometools/cli-win32-arm64": "11.0.0", - "@rometools/cli-win32-x64": "11.0.0" + "@rometools/cli-darwin-arm64": "12.0.0", + "@rometools/cli-darwin-x64": "12.0.0", + "@rometools/cli-linux-arm64": "12.0.0", + "@rometools/cli-linux-x64": "12.0.0", + "@rometools/cli-win32-arm64": "12.0.0", + "@rometools/cli-win32-x64": "12.0.0" } } }, "dependencies": { "@rometools/cli-darwin-arm64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-11.0.0.tgz", - "integrity": "sha512-F3vkdY+s3FLIEnAjSbyHTuIPB88cLpccimW4ecid5I7S6GzGG3iUJI4xT00JhH73K4P/qW20/9r+kH1T9Du8Xg==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.0.0.tgz", + "integrity": "sha512-kEFCzU6cgy6vfY0mkMzq57ea3srqV5X2wyCAxjVfA2JF7fioq695uWhy7yOCBW+nUUFIz62N9v1nf/aYqX8XkA==", "optional": true }, "@rometools/cli-darwin-x64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-11.0.0.tgz", - "integrity": "sha512-X6jhtS6Iml4GOzgNtnLwIp/KXXhSdqeVyfv69m/AHnIzx3gQAjPZ7BPnJLvTCbhe4SKHL+uTZYFSCJpkUUKE6w==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.0.0.tgz", + "integrity": "sha512-YDevVPKrkRFdjjM/3zOpOWI5mEY2ivjKM2eR8Yqv9xH3SZhyD/t67f/xo7Azp6NkGUVXSnHLGdkmIg+qrYgz5A==", "optional": true }, "@rometools/cli-linux-arm64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-11.0.0.tgz", - "integrity": "sha512-dktTJJlTpmycBZ2TwhJBcAO8ztK8DdevdyZnFFxdYRvtmJgTjIsC2UFayf/SbKew8B8q1IhI0it+D6ihAeIpeg==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.0.0.tgz", + "integrity": "sha512-n2LJg6eAZENUcJF99wjDeqQCr/40IqGUJDbX7NwiU1RvCy+RBZNmhcmSAaKOc6rCoLUcM9W5q+H4jfn4bWfJBA==", "optional": true }, "@rometools/cli-linux-x64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-11.0.0.tgz", - "integrity": "sha512-WVcnXPNdWGUWo0p4NU8YzuthjYR7q+b4vRcjdxtP1DlpphZmSsoC/RSE85nEqRAz8hChcKUansVzOPM8BSsuGA==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.0.0.tgz", + "integrity": "sha512-VuQO4eOrKmfrLrc8KzMaZypz3i1rD9FXRxwOFk6ha16DNHV+17dRQYm7jRZ1p+HrXdjAJYTScxR/E03yGLThlQ==", "optional": true }, "@rometools/cli-win32-arm64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-11.0.0.tgz", - "integrity": "sha512-tPj6RThQzS7Q45jqQll7NlTYvNcsg/BEP3LYiiazqSh9FAFnMkrV6ewUcMPKWyAfiyLs7jlz4rRvdNRUSygzfQ==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.0.0.tgz", + "integrity": "sha512-lvOh5/B8YuQdI2ieGJnJ6CUMZxvVwA8+1VDkEZJyl5IEF8AXzbXYx4k6SFA5a79cfXEL9tJuJy0rn+Zs/+1yJQ==", "optional": true }, "@rometools/cli-win32-x64": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-11.0.0.tgz", - "integrity": "sha512-bmBai8WHxYjsGk1+je7ZTfCUCWq30WJI3pQM8pzTA674lfGTZ9ymJoZwTaIMSO4rL5V9mlO6uLunsBKso9VqOg==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.0.0.tgz", + "integrity": "sha512-yTfz71k8+9QIDzglKnMbEMMv1JUk30qfeSomgEUG2v0qDSbSq0Gs1ff0H0dysYOHLvZZmWA3IheOY/SC8fj1nA==", "optional": true }, "rome": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/rome/-/rome-11.0.0.tgz", - "integrity": "sha512-rRo6JOwpMLc3OkeTDRXkrmrDqnxDvZ75GS4f0jLDBNmRgDXWbu0F8eVnJoRn+VbK2AE7vWvhVOMBjnWowcopkQ==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/rome/-/rome-12.0.0.tgz", + "integrity": "sha512-w/tLvLj5PGUCx3R+Kna08BMq4zL83Xzh9spvrqoWa3Nkzk16SkD8JSpyWWP9WhI2r3qv3Xvc7FnYZ4QDnjAiYg==", "requires": { - "@rometools/cli-darwin-arm64": "11.0.0", - "@rometools/cli-darwin-x64": "11.0.0", - "@rometools/cli-linux-arm64": "11.0.0", - "@rometools/cli-linux-x64": "11.0.0", - "@rometools/cli-win32-arm64": "11.0.0", - "@rometools/cli-win32-x64": "11.0.0" + "@rometools/cli-darwin-arm64": "12.0.0", + "@rometools/cli-darwin-x64": "12.0.0", + "@rometools/cli-linux-arm64": "12.0.0", + "@rometools/cli-linux-x64": "12.0.0", + "@rometools/cli-win32-arm64": "12.0.0", + "@rometools/cli-win32-x64": "12.0.0" } } } diff --git a/language-server/package.json b/language-server/package.json index 8d7af33..a3251f6 100644 --- a/language-server/package.json +++ b/language-server/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "rome": "^11.0.0" + "rome": "^12.0.0" } } diff --git a/plugin.py b/plugin.py index 726f044..64af58c 100644 --- a/plugin.py +++ b/plugin.py @@ -1,5 +1,6 @@ -from LSP.plugin import ClientConfig, WorkspaceFolder -from LSP.plugin.core.typing import Dict, List, Optional +from LSP.plugin import ClientConfig, Response, WorkspaceFolder +from LSP.plugin.core.protocol import InitializeResult +from LSP.plugin.core.typing import List, Optional from lsp_utils import NpmClientHandler import json import os @@ -23,6 +24,7 @@ RESOLVED_PACKAGE_NAME = PACKAGE_NAMES.get(sublime.platform(), {}).get(sublime.arch()) # type: Optional[str] + def resolve_platform_binary() -> Optional[str]: if not RESOLVED_PACKAGE_NAME: return None @@ -72,7 +74,7 @@ def _get_workspace_dependency(cls, workspace_folders: List[WorkspaceFolder]) -> binary_name = resolve_platform_binary() if not RESOLVED_PACKAGE_NAME or not binary_name: return - package_json = os.path.join(RESOLVED_PACKAGE_NAME, 'package.json'); + package_json = os.path.join(RESOLVED_PACKAGE_NAME, 'package.json') for folder in workspace_folders: package_json_path = os.path.join(folder.path, 'node_modules', package_json) binary_path = os.path.join(folder.path, 'node_modules', binary_name) @@ -86,10 +88,19 @@ def _get_workspace_dependency(cls, workspace_folders: List[WorkspaceFolder]) -> if len(version_tuple) == 3 and version_tuple < (0, 9, 0): continue return binary_path - except: + except Exception: continue return None + def on_server_response_async(self, method: str, response: Response) -> None: + if method == 'initialize': + result = response.result # type: InitializeResult + version = result.get('serverInfo', {}).get('version') + if version: + session = self.weaksession() + if session: + session.set_config_status_async(version) + def plugin_loaded() -> None: LspRomePlugin.setup() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3940b3e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[tool.pyright] +pythonVersion = '3.11' + +[tool.ruff] +select = ["E", "F", "W"] +ignore = ["F401"] +line-length = 120 +target-version = 'py38' From 991c9408564ebfded98a823b9f2be44a9e6b3f84 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 15 Apr 2023 00:02:15 +0200 Subject: [PATCH 06/19] updates --- LSP-rome.sublime-settings | 3 +- sublime-package.json | 605 +++++++++++++++++++++++++++++++++----- 2 files changed, 528 insertions(+), 80 deletions(-) diff --git a/LSP-rome.sublime-settings b/LSP-rome.sublime-settings index 6ed6ebb..95777a5 100644 --- a/LSP-rome.sublime-settings +++ b/LSP-rome.sublime-settings @@ -1,5 +1,6 @@ { - "selector": "source.json | source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", + // Also supports source.json but is not able to tell if file is jsonc without "$schema" present. + "selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", "settings": { // The rome lsp server executable. If the path is relative, the workspace folder will be used as base path. "rome.lspBin": null, diff --git a/sublime-package.json b/sublime-package.json index 3d8234e..6a3bef1 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -89,7 +89,9 @@ "defaultSnippets": [ { "body": { - "ignore": ["$0"], + "ignore": [ + "$0" + ], "maxSize": null, } } @@ -145,6 +147,17 @@ "type": "null" } ] + }, + "organizeImports": { + "description": "The configuration of the import sorting", + "anyOf": [ + { + "$ref": "#/definitions/OrganizeImports" + }, + { + "type": "null" + } + ] } }, "additionalProperties": false, @@ -153,6 +166,24 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, + "noAccessKey": { + "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noAutofocus": { "description": "Avoid the autoFocus attribute", "anyOf": [ @@ -175,6 +206,28 @@ } ] }, + "noDistractingElements": { + "description": "Enforces that no distracting elements are used.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noHeaderScope": { + "description": "Check that the scope attribute is only used on th elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noPositiveTabindex": { "description": "Prevent the usage of positive integers on tabIndex property", "anyOf": [ @@ -276,6 +329,13 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, "noExtraBooleanCast": { "description": "Disallow unnecessary boolean casts", "anyOf": [ @@ -355,6 +415,13 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, "noChildrenProp": { "description": "Prevent passing of children as props.", "anyOf": [ @@ -377,6 +444,17 @@ } ] }, + "noConstructorReturn": { + "description": "Disallow returning a value from a constructor.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noEmptyPattern": { "description": "Disallows empty destructuring patterns.", "anyOf": [ @@ -399,6 +477,17 @@ } ] }, + "noPrecisionLoss": { + "description": "Disallow literal numbers that lose precision", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noRenderReturnValue": { "description": "Prevent the usage of the return value of React.render.", "anyOf": [ @@ -410,6 +499,28 @@ } ] }, + "noSetterReturn": { + "description": "Disallow returning a value from a setter", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noStringCaseMismatch": { + "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noUndeclaredVariables": { "description": "Prevents the usage of variables that haven't been declared inside the document", "anyOf": [ @@ -443,6 +554,17 @@ } ] }, + "noUnsafeFinally": { + "description": "Disallow control flow statements in finally blocks.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noUnusedVariables": { "description": "Disallow unused variables.", "anyOf": [ @@ -465,6 +587,17 @@ } ] }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "recommended": { "description": "It enables the recommended rules for this group", "type": [ @@ -587,6 +720,16 @@ "type": "string" }, "uniqueItems": true + }, + "organize_imports": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptOrganizeImports" + }, + { + "type": "null" + } + ] } }, "additionalProperties": false @@ -633,6 +776,10 @@ }, "additionalProperties": false }, + "JavascriptOrganizeImports": { + "type": "object", + "additionalProperties": false + }, "LineWidth": { "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", "type": "integer", @@ -679,8 +826,15 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { - "noAccessKey": { - "description": "Enforce that the accessKey attribute is not used on any HTML element.", + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, + "noAriaUnsupportedElements": { + "description": "Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -734,8 +888,8 @@ } ] }, - "noConstEnum": { - "description": "Disallow TypeScript const enum", + "noConfusingArrow": { + "description": "Disallow arrow functions where they could be confused with comparisons.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -745,8 +899,8 @@ } ] }, - "noConstructorReturn": { - "description": "Disallow returning a value from a constructor.", + "noConfusingLabels": { + "description": "Disallow labeled statements that are not loops.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -756,8 +910,8 @@ } ] }, - "noDistractingElements": { - "description": "Enforces that no distracting elements are used.", + "noConsoleLog": { + "description": "Disallow the use of console.log", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -778,8 +932,8 @@ } ] }, - "noDuplicateObjectKeys": { - "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "noDuplicateClassMembers": { + "description": "Disallow duplicate class members.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -789,8 +943,8 @@ } ] }, - "noEmptyInterface": { - "description": "Disallow the declaration of empty interfaces.", + "noDuplicateJsxProps": { + "description": "Prevents JSX properties to be assigned multiple times.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -800,8 +954,8 @@ } ] }, - "noExtraNonNullAssertion": { - "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "noExtraLabels": { + "description": "Disallow unnecessary labels.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -822,8 +976,41 @@ } ] }, - "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", + "noForEach": { + "description": "Prefer for...of statement instead of Array.forEach.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noGlobalObjectCalls": { + "description": "Disallow calling global object properties as functions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInferrableTypes": { + "description": "Disallow type annotations for variables, parameters, and class properties initialized with a literal expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInnerDeclarations": { + "description": "Disallow function and var declarations in nested blocks.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -844,8 +1031,8 @@ } ] }, - "noNonNullAssertion": { - "description": "Disallow non-null assertions using the ! postfix operator.", + "noNamespace": { + "description": "Disallow the use of TypeScript's namespaces.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -866,8 +1053,8 @@ } ] }, - "noPrecisionLoss": { - "description": "Disallow literal numbers that lose precision", + "noNoninteractiveTabindex": { + "description": "Enforce that tabIndex is not assigned to non-interactive HTML elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -877,8 +1064,8 @@ } ] }, - "noRedundantAlt": { - "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "noParameterAssign": { + "description": "Disallow reassigning function parameters.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -888,8 +1075,8 @@ } ] }, - "noRedundantUseStrict": { - "description": "Prevents from having redundant \"use strict\".", + "noParameterProperties": { + "description": "Disallow the use of parameter properties in class constructors.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -899,8 +1086,8 @@ } ] }, - "noRestrictedGlobals": { - "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "noPrototypeBuiltins": { + "description": "Disallow direct use of Object.prototype builtins.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -910,8 +1097,8 @@ } ] }, - "noSelfCompare": { - "description": "Disallow comparisons where both sides are exactly the same.", + "noRedeclare": { + "description": "Disallow variable, function, class, and type redeclarations in the same scope.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -921,8 +1108,8 @@ } ] }, - "noSetterReturn": { - "description": "Disallow returning a value from a setter", + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -932,8 +1119,8 @@ } ] }, - "noStringCaseMismatch": { - "description": "Disallow comparison of expressions modifying the string case with non-compliant value.", + "noRedundantRoles": { + "description": "Enforce explicit role property is not the same as implicit/default role property on an element.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -943,8 +1130,8 @@ } ] }, - "noUnreachableSuper": { - "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -954,8 +1141,8 @@ } ] }, - "noUnsafeFinally": { - "description": "Disallow control flow statements in finally blocks.", + "noSelfAssign": { + "description": "Disallow assignments where both sides are exactly the same.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -965,8 +1152,8 @@ } ] }, - "noUselessSwitchCase": { - "description": "Disallow useless case in switch statements.", + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -976,8 +1163,8 @@ } ] }, - "noVar": { - "description": "Disallow the use of var", + "noSvgWithoutTitle": { + "description": "Enforces the usage of the title element for the svg element.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -987,8 +1174,8 @@ } ] }, - "noVoidTypeReturn": { - "description": "Disallow returning a value from a function with the return type 'void'", + "noSwitchDeclarations": { + "description": "Disallow lexical declarations in switch clauses.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -998,8 +1185,8 @@ } ] }, - "noWith": { - "description": "Disallow with statements in non-strict contexts.", + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1009,15 +1196,19 @@ } ] }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" + "noUnsafeOptionalChaining": { + "description": "Disallow the use of optional chaining in contexts where the undefined value is not allowed.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } ] }, - "useAriaPropTypes": { - "description": "Enforce that ARIA state and property values are valid.", + "noUnusedLabels": { + "description": "Disallow unused labels.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1027,8 +1218,8 @@ } ] }, - "useAriaPropsForRole": { - "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", + "noUselessCatch": { + "description": "Disallow unnecessary catch clauses.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1038,8 +1229,8 @@ } ] }, - "useCamelCase": { - "description": "Enforce camel case naming convention.", + "noUselessRename": { + "description": "Disallow renaming import, export, and destructured assignments to the same name.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1049,8 +1240,8 @@ } ] }, - "useConst": { - "description": "Require const declarations for variables that are never reassigned after declared.", + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1060,8 +1251,8 @@ } ] }, - "useDefaultParameterLast": { - "description": "Enforce default function parameters and optional parameters to be last.", + "noWith": { + "description": "Disallow with statements in non-strict contexts.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1071,8 +1262,15 @@ } ] }, - "useDefaultSwitchClauseLast": { - "description": "Enforce default clauses in switch statements to be last", + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1082,8 +1280,8 @@ } ] }, - "useEnumInitializers": { - "description": "Require that each enum member value be explicitly initialized.", + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1093,8 +1291,8 @@ } ] }, - "useExhaustiveDependencies": { - "description": "Enforce all dependencies are correctly specified.", + "useCamelCase": { + "description": "Enforce camel case naming convention.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1104,8 +1302,8 @@ } ] }, - "useExponentiationOperator": { - "description": "Disallow the use of Math.pow in favor of the ** operator.", + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1148,6 +1346,17 @@ } ] }, + "useLiteralKeys": { + "description": "Enforce the usage of a literal access to properties over computed property access.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useMediaCaption": { "description": "Enforces that audio and video elements must have a track for captions.", "anyOf": [ @@ -1159,8 +1368,8 @@ } ] }, - "useNumericLiterals": { - "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "useNamespaceKeyword": { + "description": "Require using the namespace keyword over the module keyword to declare TypeScript namespaces.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1191,15 +1400,55 @@ "type": "null" } ] + }, + "useYield": { + "description": "Require generator functions to contain yield.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] } } }, + "OrganizeImports": { + "type": "object", + "properties": { + "enabled": { + "description": "Enables the organization of imports", + "default": false, + "type": "boolean" + }, + "ignore": { + "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + }, + "uniqueItems": true + } + }, + "additionalProperties": false + }, "Performance": { "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, "noDelete": { - "description": "Disallow the use of the delete operator", + "description": "Disallow the use of the delete operator.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1219,10 +1468,21 @@ } }, "PlainIndentStyle": { - "type": "string", - "enum": [ - "tab", - "space" + "oneOf": [ + { + "description": "Tab", + "type": "string", + "enum": [ + "tab" + ] + }, + { + "description": "Space", + "type": "string", + "enum": [ + "space" + ] + } ] }, "QuoteProperties": { @@ -1284,6 +1544,13 @@ } ] }, + "all": { + "description": "It enables ALL rules. The rules that belong to `nursery` won't be enabled.", + "type": [ + "boolean", + "null" + ] + }, "complexity": { "anyOf": [ { @@ -1368,6 +1635,13 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, "noDangerouslySetInnerHtml": { "description": "Prevent the usage of dangerous JSX props", "anyOf": [ @@ -1410,6 +1684,13 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, "noArguments": { "description": "Disallow the use of arguments", "anyOf": [ @@ -1443,6 +1724,17 @@ } ] }, + "noNonNullAssertion": { + "description": "Disallow non-null assertions using the ! postfix operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noShoutyConstants": { "description": "Disallow the use of constants which its value is the upper-case version of its name.", "anyOf": [ @@ -1465,6 +1757,17 @@ } ] }, + "noVar": { + "description": "Disallow the use of var", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "recommended": { "description": "It enables the recommended rules for this group", "type": [ @@ -1483,6 +1786,50 @@ } ] }, + "useConst": { + "description": "Require const declarations for variables that are never reassigned after declared.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useDefaultParameterLast": { + "description": "Enforce default function parameters and optional parameters to be last.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useEnumInitializers": { + "description": "Require that each enum member value be explicitly initialized.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useExponentiationOperator": { + "description": "Disallow the use of Math.pow in favor of the ** operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useFragmentSyntax": { "description": "This rule enforces the use of <>... over ....", "anyOf": [ @@ -1494,6 +1841,17 @@ } ] }, + "useNumericLiterals": { + "description": "Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useSelfClosingElements": { "description": "Prevent extra closing tags for components without children", "anyOf": [ @@ -1517,7 +1875,7 @@ ] }, "useSingleCaseStatement": { - "description": "Enforces case clauses have a single statement, emits a quick fix wrapping the statements in a block", + "description": "Enforces switch clauses have a single statement, emits a quick fix wrapping the statements in a block.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1566,6 +1924,13 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { + "all": { + "description": "It enables ALL rules for this group.", + "type": [ + "boolean", + "null" + ] + }, "noArrayIndexKey": { "description": "Discourage the usage of Array index in keys.", "anyOf": [ @@ -1589,7 +1954,7 @@ ] }, "noCatchAssign": { - "description": "Disallow reassigning exceptions in catch clauses", + "description": "Disallow reassigning exceptions in catch clauses.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1621,6 +1986,17 @@ } ] }, + "noConstEnum": { + "description": "Disallow TypeScript const enum", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noDebugger": { "description": "Disallow the use of debugger", "anyOf": [ @@ -1643,8 +2019,30 @@ } ] }, + "noDuplicateObjectKeys": { + "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noDuplicateParameters": { - "description": "Disallow duplicate function arguments name.", + "description": "Disallow duplicate function parameter name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noEmptyInterface": { + "description": "Disallow the declaration of empty interfaces.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1665,6 +2063,17 @@ } ] }, + "noExtraNonNullAssertion": { + "description": "Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noFunctionAssign": { "description": "Disallow reassigning function declarations.", "anyOf": [ @@ -1698,6 +2107,17 @@ } ] }, + "noRedundantUseStrict": { + "description": "Prevents from having redundant \"use strict\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noShadowRestrictedNames": { "description": "Disallow identifiers from shadowing restricted names.", "anyOf": [ @@ -1738,6 +2158,17 @@ "null" ] }, + "useDefaultSwitchClauseLast": { + "description": "Enforce default clauses in switch statements to be last", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useValidTypeof": { "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", "anyOf": [ @@ -1762,6 +2193,22 @@ } } }, + { + "file_patterns": [ + "LSP.sublime-settings" + ], + "schema": { + "properties": { + "lsp_code_actions_on_save": { + "properties": { + "source.organizeImports.rome": { + "type": "boolean" + }, + } + } + } + } + }, ] - } + }, } From 9e263e937778fe6424cfb0ab6ccdc8884335d825 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 15 Apr 2023 00:04:29 +0200 Subject: [PATCH 07/19] source.fixAll.rome --- sublime-package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sublime-package.json b/sublime-package.json index 6a3bef1..2d4f35c 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -2204,6 +2204,9 @@ "source.organizeImports.rome": { "type": "boolean" }, + "source.fixAll.rome": { + "type": "boolean" + }, } } } From 44138372da6b07a308703bd120084eb422eae214 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 15 Apr 2023 00:14:29 +0200 Subject: [PATCH 08/19] jsonc comment --- LSP-rome.sublime-settings | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LSP-rome.sublime-settings b/LSP-rome.sublime-settings index 95777a5..e7ec225 100644 --- a/LSP-rome.sublime-settings +++ b/LSP-rome.sublime-settings @@ -1,5 +1,7 @@ { - // Also supports source.json but is not able to tell if file is jsonc without "$schema" present. + // Also supports source.json but in Sublime Text it's not possible to differentiate JSON and JSONC and enabling + // Rome for JSONC by default would produce error diagnostics due to comments and trailing commas if those don't + // have proper "$schema" assigned. "selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", "settings": { // The rome lsp server executable. If the path is relative, the workspace folder will be used as base path. From c5cb248c34a2ba461f15fcee4a480e39e00a8429 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 14:42:01 +0200 Subject: [PATCH 09/19] updates --- LSP-rome.sublime-commands | 7 ++ LSP-rome.sublime-settings | 2 +- README.md | 54 +++++++++++++-- language-server/package-lock.json | 110 +++++++++++++++--------------- language-server/package.json | 2 +- 5 files changed, 114 insertions(+), 61 deletions(-) diff --git a/LSP-rome.sublime-commands b/LSP-rome.sublime-commands index da1f41b..c0a40dd 100644 --- a/LSP-rome.sublime-commands +++ b/LSP-rome.sublime-commands @@ -7,4 +7,11 @@ "default": "// Settings in here override those in \"LSP-rome/LSP-rome.sublime-settings\"\n\n{\n\t$0\n}\n" } }, + { + "caption": "LSP-rome: Organize Imports", + "command": "lsp_code_actions", + "args": { + "only_kinds": ["source.organizeImports.rome"], + } + }, ] diff --git a/LSP-rome.sublime-settings b/LSP-rome.sublime-settings index e7ec225..b71615a 100644 --- a/LSP-rome.sublime-settings +++ b/LSP-rome.sublime-settings @@ -9,6 +9,6 @@ // Enable/Disable Rome handling renames in the workspace. (Experimental) "rome.rename": null, // Require a Rome configuration file to enable syntax errors, formatting and linting. - "rome.requireConfiguration": false, + "rome.requireConfiguration": true, }, } diff --git a/README.md b/README.md index 7eb30b0..4579086 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,24 @@ # LSP-rome -[Rome](https://rome.tools/) is a unified linter and formatter for JavaScript and TypeScript files. - -This package enables Sublime Text integration so that you can: +> [Rome](https://rome.tools/) unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This package enables Sublime Text integration so that you can: - Format files on save or when issuing the `LSP: Format Document` command - See linting hints while you type and apply code fixes - Perform refactors +The package supports JavaScript and TypeScript files. + ## Installation 1. Install [LSP](https://packagecontrol.io/packages/LSP) and [LSP-rome](https://packagecontrol.io/packages/LSP-rome) via Package Control. 2. (Optional but recommended) Install [LSP-file-watcher-chokidar](https://github.com/sublimelsp/LSP-file-watcher-chokidar) via Package Control to enable functionality to notify the server about changes to the `rome.json` configuration file. 3. Restart Sublime. -### Configuration +## Configuration Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. +> NOTE: By default the package requires a Rome configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. + ## Rome Resolution The package tries to use Rome from your project's local dependencies (`node_modules/rome`). We recommend adding Rome as a project dependency to ensure that NPM scripts and the extension use the same Rome version. @@ -24,3 +26,47 @@ The package tries to use Rome from your project's local dependencies (`node_modu You can also explicitly specify the `rome` binary the extension should use by configuring the `rome.lspBin` setting in `LSP-rome` Settings. If the project has no dependency on Rome and no explicit path is configured, the extension uses the Rome version managed by this package. + +## Usage + +### Format document + +To format an entire document, open the _Command Palette_ (Ctrl/++P) and select `LSP: Format Document`. + +To format a text range, select the text you want to format, open the _Command Palette_ (Ctrl/++P), and select `LSP: Format Selection`. + +### Format on save + +To enable format on save, open the `Preferences: LSP Settings` from the _Command Palette_ and set or edit the `lsp_code_actions_on_save` option: + +```json +s +``` + +### Fix on save + +To enable fix on save, open `Preferences: LSP Settings` from the _Command Palette_ and set or edit the `lsp_code_actions_on_save: { "quickfix.rome": true }` option. + +### Imports Sorting [Experimental] + +Rome has experimental support for imports sorting through the "Organize Imports" code action. This action is accessible through the _Command Palette_ (Ctrl/++P) by selecting `LSP-rome: Organize Imports`. + +Currently this functionality needs to be explicitly enabled in the `rome.json` configuration file: + +```json +{ + "organizeImports": { + "enabled": true + } +} +``` + +You can add the following to `Preferences: LSP Settings` if you want the action to run automatically on save instead of calling it manually: + +```json +{ + "lsp_code_actions_on_save":{ + "source.organizeImports.rome": true + } +} +``` diff --git a/language-server/package-lock.json b/language-server/package-lock.json index 85e7f5b..2f5a844 100644 --- a/language-server/package-lock.json +++ b/language-server/package-lock.json @@ -5,13 +5,13 @@ "packages": { "": { "dependencies": { - "rome": "^12.0.0" + "rome": "^12.1.3" } }, "node_modules/@rometools/cli-darwin-arm64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.0.0.tgz", - "integrity": "sha512-kEFCzU6cgy6vfY0mkMzq57ea3srqV5X2wyCAxjVfA2JF7fioq695uWhy7yOCBW+nUUFIz62N9v1nf/aYqX8XkA==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.1.3.tgz", + "integrity": "sha512-AmFTUDYjBuEGQp/Wwps+2cqUr+qhR7gyXAUnkL5psCuNCz3807TrUq/ecOoct5MIavGJTH6R4aaSL6+f+VlBEg==", "cpu": [ "arm64" ], @@ -21,9 +21,9 @@ ] }, "node_modules/@rometools/cli-darwin-x64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.0.0.tgz", - "integrity": "sha512-YDevVPKrkRFdjjM/3zOpOWI5mEY2ivjKM2eR8Yqv9xH3SZhyD/t67f/xo7Azp6NkGUVXSnHLGdkmIg+qrYgz5A==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.1.3.tgz", + "integrity": "sha512-k8MbWna8q4LRlb005N2X+JS1UQ+s3ZLBBvwk4fP8TBxlAJXUz17jLLu/Fi+7DTTEmMhM84TWj4FDKW+rNar28g==", "cpu": [ "x64" ], @@ -33,9 +33,9 @@ ] }, "node_modules/@rometools/cli-linux-arm64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.0.0.tgz", - "integrity": "sha512-n2LJg6eAZENUcJF99wjDeqQCr/40IqGUJDbX7NwiU1RvCy+RBZNmhcmSAaKOc6rCoLUcM9W5q+H4jfn4bWfJBA==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.1.3.tgz", + "integrity": "sha512-X/uLhJ2/FNA3nu5TiyeNPqiD3OZoFfNfRvw6a3ut0jEREPvEn72NI7WPijH/gxSz55znfQ7UQ6iM4DZumUknJg==", "cpu": [ "arm64" ], @@ -45,9 +45,9 @@ ] }, "node_modules/@rometools/cli-linux-x64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.0.0.tgz", - "integrity": "sha512-VuQO4eOrKmfrLrc8KzMaZypz3i1rD9FXRxwOFk6ha16DNHV+17dRQYm7jRZ1p+HrXdjAJYTScxR/E03yGLThlQ==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.1.3.tgz", + "integrity": "sha512-csP17q1eWiUXx9z6Jr/JJPibkplyKIwiWPYNzvPCGE8pHlKhwZj3YHRuu7Dm/4EOqx0XFIuqqWZUYm9bkIC8xg==", "cpu": [ "x64" ], @@ -57,9 +57,9 @@ ] }, "node_modules/@rometools/cli-win32-arm64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.0.0.tgz", - "integrity": "sha512-lvOh5/B8YuQdI2ieGJnJ6CUMZxvVwA8+1VDkEZJyl5IEF8AXzbXYx4k6SFA5a79cfXEL9tJuJy0rn+Zs/+1yJQ==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.1.3.tgz", + "integrity": "sha512-RymHWeod57EBOJY4P636CgUwYA6BQdkQjh56XKk4pLEHO6X1bFyMet2XL7KlHw5qOTalzuzf5jJqUs+vf3jdXQ==", "cpu": [ "arm64" ], @@ -69,9 +69,9 @@ ] }, "node_modules/@rometools/cli-win32-x64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.0.0.tgz", - "integrity": "sha512-yTfz71k8+9QIDzglKnMbEMMv1JUk30qfeSomgEUG2v0qDSbSq0Gs1ff0H0dysYOHLvZZmWA3IheOY/SC8fj1nA==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.1.3.tgz", + "integrity": "sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ==", "cpu": [ "x64" ], @@ -81,9 +81,9 @@ ] }, "node_modules/rome": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/rome/-/rome-12.0.0.tgz", - "integrity": "sha512-w/tLvLj5PGUCx3R+Kna08BMq4zL83Xzh9spvrqoWa3Nkzk16SkD8JSpyWWP9WhI2r3qv3Xvc7FnYZ4QDnjAiYg==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/rome/-/rome-12.1.3.tgz", + "integrity": "sha512-e+ff72hxDpe/t5/Us7YRBVw3PBET7SeczTQNn6tvrWdrCaAw3qOukQQ+tDCkyFtS4yGsnhjrJbm43ctNbz27Yg==", "hasInstallScript": true, "bin": { "rome": "bin/rome" @@ -92,63 +92,63 @@ "node": ">=14.*" }, "optionalDependencies": { - "@rometools/cli-darwin-arm64": "12.0.0", - "@rometools/cli-darwin-x64": "12.0.0", - "@rometools/cli-linux-arm64": "12.0.0", - "@rometools/cli-linux-x64": "12.0.0", - "@rometools/cli-win32-arm64": "12.0.0", - "@rometools/cli-win32-x64": "12.0.0" + "@rometools/cli-darwin-arm64": "12.1.3", + "@rometools/cli-darwin-x64": "12.1.3", + "@rometools/cli-linux-arm64": "12.1.3", + "@rometools/cli-linux-x64": "12.1.3", + "@rometools/cli-win32-arm64": "12.1.3", + "@rometools/cli-win32-x64": "12.1.3" } } }, "dependencies": { "@rometools/cli-darwin-arm64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.0.0.tgz", - "integrity": "sha512-kEFCzU6cgy6vfY0mkMzq57ea3srqV5X2wyCAxjVfA2JF7fioq695uWhy7yOCBW+nUUFIz62N9v1nf/aYqX8XkA==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-12.1.3.tgz", + "integrity": "sha512-AmFTUDYjBuEGQp/Wwps+2cqUr+qhR7gyXAUnkL5psCuNCz3807TrUq/ecOoct5MIavGJTH6R4aaSL6+f+VlBEg==", "optional": true }, "@rometools/cli-darwin-x64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.0.0.tgz", - "integrity": "sha512-YDevVPKrkRFdjjM/3zOpOWI5mEY2ivjKM2eR8Yqv9xH3SZhyD/t67f/xo7Azp6NkGUVXSnHLGdkmIg+qrYgz5A==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-12.1.3.tgz", + "integrity": "sha512-k8MbWna8q4LRlb005N2X+JS1UQ+s3ZLBBvwk4fP8TBxlAJXUz17jLLu/Fi+7DTTEmMhM84TWj4FDKW+rNar28g==", "optional": true }, "@rometools/cli-linux-arm64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.0.0.tgz", - "integrity": "sha512-n2LJg6eAZENUcJF99wjDeqQCr/40IqGUJDbX7NwiU1RvCy+RBZNmhcmSAaKOc6rCoLUcM9W5q+H4jfn4bWfJBA==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-12.1.3.tgz", + "integrity": "sha512-X/uLhJ2/FNA3nu5TiyeNPqiD3OZoFfNfRvw6a3ut0jEREPvEn72NI7WPijH/gxSz55znfQ7UQ6iM4DZumUknJg==", "optional": true }, "@rometools/cli-linux-x64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.0.0.tgz", - "integrity": "sha512-VuQO4eOrKmfrLrc8KzMaZypz3i1rD9FXRxwOFk6ha16DNHV+17dRQYm7jRZ1p+HrXdjAJYTScxR/E03yGLThlQ==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-12.1.3.tgz", + "integrity": "sha512-csP17q1eWiUXx9z6Jr/JJPibkplyKIwiWPYNzvPCGE8pHlKhwZj3YHRuu7Dm/4EOqx0XFIuqqWZUYm9bkIC8xg==", "optional": true }, "@rometools/cli-win32-arm64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.0.0.tgz", - "integrity": "sha512-lvOh5/B8YuQdI2ieGJnJ6CUMZxvVwA8+1VDkEZJyl5IEF8AXzbXYx4k6SFA5a79cfXEL9tJuJy0rn+Zs/+1yJQ==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-12.1.3.tgz", + "integrity": "sha512-RymHWeod57EBOJY4P636CgUwYA6BQdkQjh56XKk4pLEHO6X1bFyMet2XL7KlHw5qOTalzuzf5jJqUs+vf3jdXQ==", "optional": true }, "@rometools/cli-win32-x64": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.0.0.tgz", - "integrity": "sha512-yTfz71k8+9QIDzglKnMbEMMv1JUk30qfeSomgEUG2v0qDSbSq0Gs1ff0H0dysYOHLvZZmWA3IheOY/SC8fj1nA==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-12.1.3.tgz", + "integrity": "sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ==", "optional": true }, "rome": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/rome/-/rome-12.0.0.tgz", - "integrity": "sha512-w/tLvLj5PGUCx3R+Kna08BMq4zL83Xzh9spvrqoWa3Nkzk16SkD8JSpyWWP9WhI2r3qv3Xvc7FnYZ4QDnjAiYg==", + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/rome/-/rome-12.1.3.tgz", + "integrity": "sha512-e+ff72hxDpe/t5/Us7YRBVw3PBET7SeczTQNn6tvrWdrCaAw3qOukQQ+tDCkyFtS4yGsnhjrJbm43ctNbz27Yg==", "requires": { - "@rometools/cli-darwin-arm64": "12.0.0", - "@rometools/cli-darwin-x64": "12.0.0", - "@rometools/cli-linux-arm64": "12.0.0", - "@rometools/cli-linux-x64": "12.0.0", - "@rometools/cli-win32-arm64": "12.0.0", - "@rometools/cli-win32-x64": "12.0.0" + "@rometools/cli-darwin-arm64": "12.1.3", + "@rometools/cli-darwin-x64": "12.1.3", + "@rometools/cli-linux-arm64": "12.1.3", + "@rometools/cli-linux-x64": "12.1.3", + "@rometools/cli-win32-arm64": "12.1.3", + "@rometools/cli-win32-x64": "12.1.3" } } } diff --git a/language-server/package.json b/language-server/package.json index a3251f6..73e88f3 100644 --- a/language-server/package.json +++ b/language-server/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "rome": "^12.0.0" + "rome": "^12.1.3" } } From 78d4f81025b913460d309bdde0a4d8e0784aaa90 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 15:56:42 +0200 Subject: [PATCH 10/19] update schema --- sublime-package.json | 1257 +++++++++++++++++++++++++++--------------- 1 file changed, 800 insertions(+), 457 deletions(-) diff --git a/sublime-package.json b/sublime-package.json index 2d4f35c..1aef891 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -76,6 +76,10 @@ "/rome.json", ], "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Configuration", + "description": "The configuration that is contained inside the file `rome.json`", + "type": "object", "properties": { "$schema": { "description": "A field for the [JSON schema](https://json-schema.org/) specification", @@ -92,7 +96,6 @@ "ignore": [ "$0" ], - "maxSize": null, } } ], @@ -110,10 +113,7 @@ "defaultSnippets": [ { "body": { - "formatWithErrors": false, - "ignore": null, - "indentSize": 2, - "lineWidth": 80, + "enabled": true, } } ], @@ -128,6 +128,11 @@ }, "javascript": { "description": "Specific configuration for the JavaScript language", + "defaultSnippets": [ + { + "body": {} + } + ], "anyOf": [ { "$ref": "#/definitions/JavascriptConfiguration" @@ -139,6 +144,13 @@ }, "linter": { "description": "The configuration for the linter", + "defaultSnippets": [ + { + "body": { + "enabled": true, + } + } + ], "anyOf": [ { "$ref": "#/definitions/LinterConfiguration" @@ -150,6 +162,13 @@ }, "organizeImports": { "description": "The configuration of the import sorting", + "defaultSnippets": [ + { + "body": { + "enabled": true, + } + } + ], "anyOf": [ { "$ref": "#/definitions/OrganizeImports" @@ -158,6 +177,24 @@ "type": "null" } ] + }, + "vcs": { + "description": "The configuration of the VCS integration", + "defaultSnippets": [ + { + "body": { + "enabled": true, + } + } + ], + "anyOf": [ + { + "$ref": "#/definitions/VcsConfiguration" + }, + { + "type": "null" + } + ] } }, "additionalProperties": false, @@ -185,7 +222,7 @@ ] }, "noAutofocus": { - "description": "Avoid the autoFocus attribute", + "description": "Enforce that autoFocus prop is not used on elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -218,7 +255,18 @@ ] }, "noHeaderScope": { - "description": "Check that the scope attribute is only used on th elements.", + "description": "The scope prop should be used only on elements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNoninteractiveElementToInteractiveRole": { + "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -239,6 +287,28 @@ } ] }, + "noRedundantAlt": { + "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noSvgWithoutTitle": { + "description": "Enforces the usage of the title element for the svg element.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "recommended": { "description": "It enables the recommended rules for this group", "type": [ @@ -247,7 +317,7 @@ ] }, "useAltText": { - "description": "It asserts that alternative text to images or areas, help to rely on to screen readers to understand the purpose and the context of the image.", + "description": "Enforce that all elements that require alternative text have meaningful information to relay back to the end user.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -258,7 +328,18 @@ ] }, "useAnchorContent": { - "description": "Enforce that anchor elements have content and that the content is accessible to screen readers.", + "description": "Enforce that anchors have content and that the content is accessible to screen readers.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useAriaPropsForRole": { + "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -280,7 +361,18 @@ ] }, "useHtmlLang": { - "description": "Enforce that html element has lang attribute. This allows users to choose a language other than the default.", + "description": "Enforce that html element has lang attribute.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useIframeTitle": { + "description": "Enforces the usage of the attribute title for the element iframe.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -291,7 +383,7 @@ ] }, "useKeyWithClickEvents": { - "description": "Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.", + "description": "Enforce onClick is accompanied by at least one of the following: onKeyUp, onKeyDown, onKeyPress.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -302,7 +394,18 @@ ] }, "useKeyWithMouseEvents": { - "description": "Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users. It is important to take into account users with physical disabilities who cannot use a mouse, who use assistive technology or screenreader.", + "description": "Enforce onMouseOver / onMouseOut are accompanied by onFocus / onBlur.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useMediaCaption": { + "description": "Enforces that audio and video elements must have a track for captions.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -322,6 +425,28 @@ "type": "null" } ] + }, + "useValidAriaProps": { + "description": "Ensures that ARIA properties aria-* are all valid.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "useValidLang": { + "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] } } }, @@ -358,6 +483,28 @@ } ] }, + "noUselessCatch": { + "description": "Disallow unnecessary catch clauses.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessConstructor": { + "description": "Disallow unnecessary constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noUselessFragments": { "description": "Disallow unnecessary fragments", "anyOf": [ @@ -369,6 +516,61 @@ } ] }, + "noUselessLabel": { + "description": "Disallow unnecessary labels.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessRename": { + "description": "Disallow renaming import, export, and destructured assignments to the same name.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessSwitchCase": { + "description": "Disallow useless case in switch statements.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noUselessTypeConstraint": { + "description": "Disallow using any or unknown as type constraint.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noWith": { + "description": "Disallow with statements in non-strict contexts.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "recommended": { "description": "It enables the recommended rules for this group", "type": [ @@ -466,6 +668,39 @@ } ] }, + "noGlobalObjectCalls": { + "description": "Disallow calling global object properties as functions", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInnerDeclarations": { + "description": "Disallow function and var declarations that are accessible outside their block.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noInvalidConstructorSuper": { + "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noNewSymbol": { "description": "Disallow new operators with the Symbol object", "anyOf": [ @@ -521,6 +756,17 @@ } ] }, + "noSwitchDeclarations": { + "description": "Disallow lexical declarations in switch clauses.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noUndeclaredVariables": { "description": "Prevents the usage of variables that haven't been declared inside the document", "anyOf": [ @@ -554,6 +800,17 @@ } ] }, + "noUnreachableSuper": { + "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noUnsafeFinally": { "description": "Disallow control flow statements in finally blocks.", "anyOf": [ @@ -565,8 +822,8 @@ } ] }, - "noUnusedVariables": { - "description": "Disallow unused variables.", + "noUnsafeOptionalChaining": { + "description": "Disallow the use of optional chaining in contexts where the undefined value is not allowed.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -576,8 +833,8 @@ } ] }, - "noVoidElementsWithChildren": { - "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "noUnusedLabels": { + "description": "Disallow unused labels.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -587,8 +844,30 @@ } ] }, - "noVoidTypeReturn": { - "description": "Disallow returning a value from a function with the return type 'void'", + "noUnusedVariables": { + "description": "Disallow unused variables.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidElementsWithChildren": { + "description": "This rules prevents void elements (AKA self-closing elements) from having children.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noVoidTypeReturn": { + "description": "Disallow returning a value from a function with the return type 'void'", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -615,6 +894,17 @@ "type": "null" } ] + }, + "useYield": { + "description": "Require generator functions to contain yield.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] } } }, @@ -624,14 +914,21 @@ "properties": { "ignore": { "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", + "anyOf": [ + { + "$ref": "#/definitions/StringSet" + }, + { + "type": "null" + } + ] + }, + "ignoreUnknown": { + "description": "Tells Rome to not emit diagnostics when handling files that doesn't know", "type": [ - "array", + "boolean", "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true + ] }, "maxSize": { "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", @@ -647,56 +944,120 @@ "additionalProperties": false }, "FormatterConfiguration": { + "description": "Options applied to the formatter", "type": "object", "properties": { "enabled": { "default": true, - "type": "boolean" + "type": [ + "boolean", + "null" + ] }, "formatWithErrors": { "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", "default": false, - "type": "boolean" + "type": [ + "boolean", + "null" + ] }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true + "anyOf": [ + { + "$ref": "#/definitions/StringSet" + }, + { + "type": "null" + } + ] }, "indentSize": { "description": "The size of the indentation, 2 by default", "default": 2, - "type": "integer", + "type": [ + "integer", + "null" + ], "format": "uint8", "minimum": 0.0 }, "indentStyle": { "description": "The indent style.", "default": "tab", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/PlainIndentStyle" + }, + { + "type": "null" } ] }, "lineWidth": { "description": "What's the max width of a line. Defaults to 80.", "default": 80, - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/LineWidth" + }, + { + "type": "null" } ] } }, "additionalProperties": false }, + "Hooks": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "closureIndex": { + "description": "The \"position\" of the closure function, starting from zero.\n\n### Example", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0.0 + }, + "dependenciesIndex": { + "description": "The \"position\" of the array of dependencies, starting from zero.", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0.0 + }, + "name": { + "description": "The name of the hook", + "type": "string" + } + }, + "additionalProperties": false + }, + "HooksOptions": { + "description": "Options for the rule `useExhaustiveDependencies` and `useHookAtTopLevel`", + "type": "object", + "required": [ + "hooks" + ], + "properties": { + "hooks": { + "description": "List of safe hooks", + "type": "array", + "items": { + "$ref": "#/definitions/Hooks" + } + } + }, + "additionalProperties": false + }, "JavascriptConfiguration": { "type": "object", "properties": { @@ -712,14 +1073,14 @@ }, "globals": { "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true + "anyOf": [ + { + "$ref": "#/definitions/StringSet" + }, + { + "type": "null" + } + ] }, "organize_imports": { "anyOf": [ @@ -730,6 +1091,16 @@ "type": "null" } ] + }, + "parser": { + "anyOf": [ + { + "$ref": "#/definitions/JavascriptParser" + }, + { + "type": "null" + } + ] } }, "additionalProperties": false @@ -737,39 +1108,58 @@ "JavascriptFormatter": { "type": "object", "properties": { + "jsxQuoteStyle": { + "description": "The style for JSX quotes. Defaults to double.", + "anyOf": [ + { + "$ref": "#/definitions/QuoteStyle" + }, + { + "type": "null" + } + ] + }, "quoteProperties": { "description": "When properties in objects are quoted. Defaults to asNeeded.", - "default": "asNeeded", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/QuoteProperties" + }, + { + "type": "null" } ] }, "quoteStyle": { "description": "The style for quotes. Defaults to double.", - "default": "double", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/QuoteStyle" + }, + { + "type": "null" } ] }, "semicolons": { "description": "Whether the formatter prints semicolons for all statements or only in for statements where it is necessary because of ASI.", - "default": "always", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/Semicolons" + }, + { + "type": "null" } ] }, "trailingComma": { "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to \"all\".", - "default": "all", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/TrailingComma" + }, + { + "type": "null" } ] } @@ -780,6 +1170,19 @@ "type": "object", "additionalProperties": false }, + "JavascriptParser": { + "type": "object", + "properties": { + "unsafeParameterDecoratorsEnabled": { + "description": "It enables the experimental and unsafe parsing of parameter decorators\n\nThese decorators belong to an old proposal, and they are subject to change.", + "type": [ + "boolean", + "null" + ] + } + }, + "additionalProperties": false + }, "LineWidth": { "description": "Validated value for the `line_width` formatter options\n\nThe allowed range of values is 1..=320", "type": "integer", @@ -792,18 +1195,21 @@ "enabled": { "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", "default": true, - "type": "boolean" + "type": [ + "boolean", + "null" + ] }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true + "anyOf": [ + { + "$ref": "#/definitions/StringSet" + }, + { + "type": "null" + } + ] }, "rules": { "description": "List of rules", @@ -833,8 +1239,8 @@ "null" ] }, - "noAriaUnsupportedElements": { - "description": "Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.", + "noAccumulatingSpread": { + "description": "Disallow the use of spread (...) syntax on accumulators.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -844,8 +1250,8 @@ } ] }, - "noAssignInExpressions": { - "description": "Disallow assignments in expressions.", + "noAriaUnsupportedElements": { + "description": "Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -866,8 +1272,8 @@ } ] }, - "noClassAssign": { - "description": "Disallow reassigning class members.", + "noConfusingArrow": { + "description": "Disallow arrow functions where they could be confused with comparisons.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -877,8 +1283,8 @@ } ] }, - "noCommaOperator": { - "description": "Disallow comma operator.", + "noConsoleLog": { + "description": "Disallow the use of console.log", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -888,8 +1294,8 @@ } ] }, - "noConfusingArrow": { - "description": "Disallow arrow functions where they could be confused with comparisons.", + "noConstantCondition": { + "description": "Disallow constant expressions in conditions", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -899,8 +1305,8 @@ } ] }, - "noConfusingLabels": { - "description": "Disallow labeled statements that are not loops.", + "noDuplicateJsxProps": { + "description": "Prevents JSX properties to be assigned multiple times.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -910,8 +1316,8 @@ } ] }, - "noConsoleLog": { - "description": "Disallow the use of console.log", + "noForEach": { + "description": "Prefer for...of statement instead of Array.forEach.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -921,8 +1327,8 @@ } ] }, - "noDuplicateCase": { - "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "noNoninteractiveTabindex": { + "description": "Enforce that tabIndex is not assigned to non-interactive HTML elements.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -932,8 +1338,8 @@ } ] }, - "noDuplicateClassMembers": { - "description": "Disallow duplicate class members.", + "noRedundantRoles": { + "description": "Enforce explicit role property is not the same as implicit/default role property on an element.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -943,8 +1349,8 @@ } ] }, - "noDuplicateJsxProps": { - "description": "Prevents JSX properties to be assigned multiple times.", + "noSelfAssign": { + "description": "Disallow assignments where both sides are exactly the same.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -954,8 +1360,8 @@ } ] }, - "noExtraLabels": { - "description": "Disallow unnecessary labels.", + "noStaticOnlyClass": { + "description": "This rule reports when a class has no non-static members, such as for a class used exclusively as a static namespace.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -965,8 +1371,15 @@ } ] }, - "noExtraSemicolons": { - "description": "Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.", + "recommended": { + "description": "It enables the recommended rules for this group", + "type": [ + "boolean", + "null" + ] + }, + "useAriaPropTypes": { + "description": "Enforce that ARIA state and property values are valid.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -976,8 +1389,8 @@ } ] }, - "noForEach": { - "description": "Prefer for...of statement instead of Array.forEach.", + "useCamelCase": { + "description": "Enforce camel case naming convention.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -987,8 +1400,8 @@ } ] }, - "noGlobalObjectCalls": { - "description": "Disallow calling global object properties as functions", + "useExhaustiveDependencies": { + "description": "Enforce all dependencies are correctly specified.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -998,8 +1411,8 @@ } ] }, - "noInferrableTypes": { - "description": "Disallow type annotations for variables, parameters, and class properties initialized with a literal expression.", + "useGroupedTypeImport": { + "description": "Enforce the use of import type when an import only has specifiers with type qualifier.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1009,8 +1422,8 @@ } ] }, - "noInnerDeclarations": { - "description": "Disallow function and var declarations in nested blocks.", + "useHeadingContent": { + "description": "Enforce that heading elements (h1, h2, etc.) have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the aria-hidden prop.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1020,8 +1433,8 @@ } ] }, - "noInvalidConstructorSuper": { - "description": "Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.", + "useHookAtTopLevel": { + "description": "Enforce that all React hooks are being called from the Top Level component functions.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1031,8 +1444,8 @@ } ] }, - "noNamespace": { - "description": "Disallow the use of TypeScript's namespaces.", + "useIsNan": { + "description": "Require calls to isNaN() when checking for NaN.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1042,301 +1455,8 @@ } ] }, - "noNoninteractiveElementToInteractiveRole": { - "description": "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noNoninteractiveTabindex": { - "description": "Enforce that tabIndex is not assigned to non-interactive HTML elements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noParameterAssign": { - "description": "Disallow reassigning function parameters.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noParameterProperties": { - "description": "Disallow the use of parameter properties in class constructors.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noPrototypeBuiltins": { - "description": "Disallow direct use of Object.prototype builtins.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedeclare": { - "description": "Disallow variable, function, class, and type redeclarations in the same scope.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantAlt": { - "description": "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\".", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRedundantRoles": { - "description": "Enforce explicit role property is not the same as implicit/default role property on an element.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noRestrictedGlobals": { - "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSelfAssign": { - "description": "Disallow assignments where both sides are exactly the same.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSelfCompare": { - "description": "Disallow comparisons where both sides are exactly the same.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSvgWithoutTitle": { - "description": "Enforces the usage of the title element for the svg element.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noSwitchDeclarations": { - "description": "Disallow lexical declarations in switch clauses.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnreachableSuper": { - "description": "Ensures the super() constructor is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnsafeOptionalChaining": { - "description": "Disallow the use of optional chaining in contexts where the undefined value is not allowed.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUnusedLabels": { - "description": "Disallow unused labels.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessCatch": { - "description": "Disallow unnecessary catch clauses.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessRename": { - "description": "Disallow renaming import, export, and destructured assignments to the same name.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noUselessSwitchCase": { - "description": "Disallow useless case in switch statements.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "noWith": { - "description": "Disallow with statements in non-strict contexts.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - }, - "useAriaPropTypes": { - "description": "Enforce that ARIA state and property values are valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useAriaPropsForRole": { - "description": "Enforce that elements with ARIA roles must have all required ARIA attributes for that role.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useCamelCase": { - "description": "Enforce camel case naming convention.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useExhaustiveDependencies": { - "description": "Enforce all dependencies are correctly specified.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useHookAtTopLevel": { - "description": "Enforce that all React hooks are being called from the Top Level component functions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIframeTitle": { - "description": "Enforces the usage of the attribute title for the element iframe", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useIsNan": { - "description": "Require calls to isNaN() when checking for NaN.", + "useLiteralEnumMembers": { + "description": "Require all enum members to be literal values.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1357,52 +1477,8 @@ } ] }, - "useMediaCaption": { - "description": "Enforces that audio and video elements must have a track for captions.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useNamespaceKeyword": { - "description": "Require using the namespace keyword over the module keyword to declare TypeScript namespaces.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidAriaProps": { - "description": "Ensures that ARIA properties aria-* are all valid.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useValidLang": { - "description": "Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "useYield": { - "description": "Require generator functions to contain yield.", + "useSimpleNumberKeys": { + "description": "Disallow number literal object member names which are not base10 or uses underscore as separator", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1420,18 +1496,21 @@ "enabled": { "description": "Enables the organization of imports", "default": false, - "type": "boolean" + "type": [ + "boolean", + "null" + ] }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - }, - "uniqueItems": true + "anyOf": [ + { + "$ref": "#/definitions/StringSet" + }, + { + "type": "null" + } + ] } }, "additionalProperties": false @@ -1485,6 +1564,22 @@ } ] }, + "PossibleOptions": { + "anyOf": [ + { + "description": "Options for `useExhaustiveDependencies` and `useHookAtTopLevel` rule", + "allOf": [ + { + "$ref": "#/definitions/HooksOptions" + } + ] + }, + { + "description": "No options available", + "type": "null" + } + ] + }, "QuoteProperties": { "type": "string", "enum": [ @@ -1520,14 +1615,22 @@ "RuleWithOptions": { "type": "object", "required": [ - "level", - "options" + "level" ], "properties": { "level": { "$ref": "#/definitions/RulePlainConfiguration" }, - "options": true + "options": { + "anyOf": [ + { + "$ref": "#/definitions/PossibleOptions" + }, + { + "type": "null" + } + ] + } }, "additionalProperties": false }, @@ -1680,6 +1783,13 @@ "asNeeded" ] }, + "StringSet": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, "Style": { "description": "A list of rules that belong to this group", "type": "object", @@ -1702,6 +1812,17 @@ } ] }, + "noCommaOperator": { + "description": "Disallow comma operator.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noImplicitBoolean": { "description": "Disallow implicit true values on JSX boolean attributes", "anyOf": [ @@ -1713,6 +1834,28 @@ } ] }, + "noInferrableTypes": { + "description": "Disallow type annotations for variables, parameters, and class properties initialized with a literal expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noNamespace": { + "description": "Disallow the use of TypeScript's namespaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noNegationElse": { "description": "Disallow negation in the condition of an if statement if it has an else clause", "anyOf": [ @@ -1735,6 +1878,39 @@ } ] }, + "noParameterAssign": { + "description": "Disallow reassigning function parameters.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noParameterProperties": { + "description": "Disallow the use of parameter properties in class constructors.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRestrictedGlobals": { + "description": "This rule allows you to specify global variable names that you don’t want to use in your application.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noShoutyConstants": { "description": "Disallow the use of constants which its value is the upper-case version of its name.", "anyOf": [ @@ -1798,7 +1974,7 @@ ] }, "useDefaultParameterLast": { - "description": "Enforce default function parameters and optional parameters to be last.", + "description": "Enforce default function parameters and optional function parameters to be last.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" @@ -1942,6 +2118,17 @@ } ] }, + "noAssignInExpressions": { + "description": "Disallow assignments in expressions.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noAsyncPromiseExecutor": { "description": "Disallows using an async function as a Promise executor.", "anyOf": [ @@ -1964,6 +2151,17 @@ } ] }, + "noClassAssign": { + "description": "Disallow reassigning class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noCommentText": { "description": "Prevent comments from being inserted as text nodes", "anyOf": [ @@ -1986,6 +2184,17 @@ } ] }, + "noConfusingLabels": { + "description": "Disallow labeled statements that are not loops.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noConstEnum": { "description": "Disallow TypeScript const enum", "anyOf": [ @@ -2019,6 +2228,28 @@ } ] }, + "noDuplicateCase": { + "description": "Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noDuplicateClassMembers": { + "description": "Disallow duplicate class members.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noDuplicateObjectKeys": { "description": "Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.", "anyOf": [ @@ -2107,6 +2338,28 @@ } ] }, + "noPrototypeBuiltins": { + "description": "Disallow direct use of Object.prototype builtins.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, + "noRedeclare": { + "description": "Disallow variable, function, class, and type redeclarations in the same scope.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noRedundantUseStrict": { "description": "Prevents from having redundant \"use strict\".", "anyOf": [ @@ -2118,6 +2371,17 @@ } ] }, + "noSelfCompare": { + "description": "Disallow comparisons where both sides are exactly the same.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "noShadowRestrictedNames": { "description": "Disallow identifiers from shadowing restricted names.", "anyOf": [ @@ -2169,6 +2433,17 @@ } ] }, + "useNamespaceKeyword": { + "description": "Require using the namespace keyword over the module keyword to declare TypeScript namespaces.", + "anyOf": [ + { + "$ref": "#/definitions/RuleConfiguration" + }, + { + "type": "null" + } + ] + }, "useValidTypeof": { "description": "This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions", "anyOf": [ @@ -2183,12 +2458,80 @@ } }, "TrailingComma": { - "type": "string", - "enum": [ - "all", - "es5", - "none" + "description": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures.", + "oneOf": [ + { + "description": "Trailing commas wherever possible (including function parameters and calls).", + "type": "string", + "enum": [ + "all" + ] + }, + { + "description": "Trailing commas where valid in ES5 (objects, arrays, etc.). No trailing commas in type parameters in TypeScript.", + "type": "string", + "enum": [ + "es5" + ] + }, + { + "description": "No trailing commas.", + "type": "string", + "enum": [ + "none" + ] + } + ] + }, + "VcsClientKind": { + "oneOf": [ + { + "description": "Integration with the git client as VCS", + "type": "string", + "enum": [ + "git" + ] + } ] + }, + "VcsConfiguration": { + "description": "Set of properties to integrate Rome with a VCS software.", + "type": "object", + "properties": { + "clientKind": { + "description": "The kind of client.", + "anyOf": [ + { + "$ref": "#/definitions/VcsClientKind" + }, + { + "type": "null" + } + ] + }, + "enabled": { + "description": "Whether Rome should integrate itself with the VCS client", + "type": [ + "boolean", + "null" + ] + }, + "root": { + "description": "The folder where Rome should check for VCS files. By default, Rome will use the same folder where `rome.json` was found.\n\nIf Rome can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, Rome won't use the VCS integration, and a diagnostic will be emitted", + "type": [ + "string", + "null" + ] + }, + "useIgnoreFile": { + "description": "Whether Rome should use the VCS ignore file. When [true], Rome will ignore the files specified in the ignore file.", + "type": [ + "boolean", + "null" + ] + } + }, + "additionalProperties": false } } } From ec9682d62641cd40c18d90394ba3969b5f936e7d Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:19:43 +0200 Subject: [PATCH 11/19] allow trailing --- sublime-package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sublime-package.json b/sublime-package.json index 1aef891..4a95c76 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -77,6 +77,7 @@ ], "schema": { "$schema": "http://json-schema.org/draft-07/schema#", + "allowTrailingCommas": true, "title": "Configuration", "description": "The configuration that is contained inside the file `rome.json`", "type": "object", From 7f6456c0d4dfebfd815aac0be27e1c02e197566c Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:25:21 +0200 Subject: [PATCH 12/19] style --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 64af58c..812e2a9 100644 --- a/plugin.py +++ b/plugin.py @@ -81,7 +81,7 @@ def _get_workspace_dependency(cls, workspace_folders: List[WorkspaceFolder]) -> if not os.path.isfile(package_json_path) or not os.path.isfile(binary_path): continue try: - with open(package_json_path , 'r') as fp: + with open(package_json_path, 'r') as fp: version = json.loads(fp.read())['version'] # Ignore versions lower than 0.9.0 as those didn't embed LSP server. version_tuple = tuple(map(int, (version.split('.')))) From 529ea5601770d897b69f1727982d4f99c0d53045 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:26:23 +0200 Subject: [PATCH 13/19] ordering --- LSP-rome.sublime-settings | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LSP-rome.sublime-settings b/LSP-rome.sublime-settings index b71615a..d1d9962 100644 --- a/LSP-rome.sublime-settings +++ b/LSP-rome.sublime-settings @@ -1,8 +1,4 @@ { - // Also supports source.json but in Sublime Text it's not possible to differentiate JSON and JSONC and enabling - // Rome for JSONC by default would produce error diagnostics due to comments and trailing commas if those don't - // have proper "$schema" assigned. - "selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", "settings": { // The rome lsp server executable. If the path is relative, the workspace folder will be used as base path. "rome.lspBin": null, @@ -11,4 +7,8 @@ // Require a Rome configuration file to enable syntax errors, formatting and linting. "rome.requireConfiguration": true, }, + // Also supports source.json but in Sublime Text it's not possible to differentiate JSON and JSONC and enabling + // Rome for JSONC by default would produce error diagnostics due to comments and trailing commas if those don't + // have proper "$schema" assigned. + "selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react", } From a384b4f2c1f4648d3078d0b5bea6c9b9043c3f2e Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:27:12 +0200 Subject: [PATCH 14/19] readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4579086..12e58e9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LSP-rome -> [Rome](https://rome.tools/) unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This package enables Sublime Text integration so that you can: +[Rome](https://rome.tools/) unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This package enables Sublime Text integration so that you can: - Format files on save or when issuing the `LSP: Format Document` command - See linting hints while you type and apply code fixes - Perform refactors @@ -17,7 +17,8 @@ The package supports JavaScript and TypeScript files. Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. -> NOTE: By default the package requires a Rome configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. +> Note: +> By default the package requires a Rome configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. ## Rome Resolution @@ -51,7 +52,7 @@ To enable fix on save, open `Preferences: LSP Settings` from the _Command Palett Rome has experimental support for imports sorting through the "Organize Imports" code action. This action is accessible through the _Command Palette_ (Ctrl/++P) by selecting `LSP-rome: Organize Imports`. -Currently this functionality needs to be explicitly enabled in the `rome.json` configuration file: +Currently, this functionality needs to be explicitly enabled in the `rome.json` configuration file: ```json { From 823c993603499a3d52f84d3a88e4d03a044a845d Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:31:32 +0200 Subject: [PATCH 15/19] note --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12e58e9..80d8204 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The package supports JavaScript and TypeScript files. Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. -> Note: +> Note > By default the package requires a Rome configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. ## Rome Resolution From 0d88fc067418eddefbdd67841be3e2c2926e717d Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:32:41 +0200 Subject: [PATCH 16/19] note --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80d8204..b3e78d5 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The package supports JavaScript and TypeScript files. Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. -> Note +> **Note** > By default the package requires a Rome configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. ## Rome Resolution From 81ebb6db81ba294baec0d9e8c2d130e996c78746 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:35:44 +0200 Subject: [PATCH 17/19] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3e78d5..4ff9505 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The package supports JavaScript and TypeScript files. Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu. > **Note** -> By default the package requires a Rome configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. +> By default Rome requires a configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`. ## Rome Resolution From 5eb1ddfae9a0ed334c7d121912f2eeaca8b938db Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:36:49 +0200 Subject: [PATCH 18/19] remove section --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 4ff9505..45103af 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,6 @@ To format an entire document, open the _Command Palette_ (Ctrl/Ctrl/++P), and select `LSP: Format Selection`. -### Format on save - -To enable format on save, open the `Preferences: LSP Settings` from the _Command Palette_ and set or edit the `lsp_code_actions_on_save` option: - -```json -s -``` - ### Fix on save To enable fix on save, open `Preferences: LSP Settings` from the _Command Palette_ and set or edit the `lsp_code_actions_on_save: { "quickfix.rome": true }` option. From e119e46ae736f7010167f849390d2a525e42342d Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 18 Jun 2023 16:38:07 +0200 Subject: [PATCH 19/19] format --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 45103af..50a884d 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,15 @@ To format a text range, select the text you want to format, open the _Command Pa ### Fix on save -To enable fix on save, open `Preferences: LSP Settings` from the _Command Palette_ and set or edit the `lsp_code_actions_on_save: { "quickfix.rome": true }` option. +To enable fix on save, open `Preferences: LSP Settings` from the _Command Palette_ and set: + +```json +{ + "lsp_code_actions_on_save": { + "quickfix.rome": true + } +} +``` ### Imports Sorting [Experimental]