diff --git a/.github/ISSUE_TEMPLATE/a_question.md b/.github/ISSUE_TEMPLATE/a_question.md index 4057f2c59..c4e486ff8 100644 --- a/.github/ISSUE_TEMPLATE/a_question.md +++ b/.github/ISSUE_TEMPLATE/a_question.md @@ -4,9 +4,10 @@ about: Usage question or discussion about the YAML Language Server title: '' labels: 'kind/question' assignees: '' - --- + ## Summary ## Relevant information + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f46516efd..0bda832b1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,10 +4,10 @@ about: Report a bug found in the YAML Language Server title: '' labels: 'kind/bug' assignees: '' - --- ## Describe the bug + ## Expected Behavior + ## Current Behavior + ## Steps to Reproduce + + 1. 2. -3. +3. ## Environment + - [ ] Windows - [ ] Mac - [ ] Linux diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md index 37180e51b..f1599e074 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.md +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -4,16 +4,20 @@ about: Suggest an enhancement for the YAML Language Server title: '' labels: 'kind/enhancement' assignees: '' - --- + ### Is your enhancement related to a problem? Please describe. + ### Describe the solution you would like + ### Describe alternatives you have considered + ### Additional context - \ No newline at end of file + + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 86471612d..a44facf23 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,8 +1,7 @@ ### What does this PR do? - ### What issues does this PR fix or reference? - ### Is it tested? How? + diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index d23790a09..76108472a 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -11,15 +11,14 @@ on: branches: [main] permissions: - contents: read - + contents: read # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: permissions: - checks: write ## for coveralls + checks: write ## for coveralls contents: read ## for docker-push security-events: write ## for upload-sarif # The type of runner that the job will run on @@ -38,7 +37,7 @@ jobs: uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2.5.2 with: node-version: 16 - registry-url: "https://registry.npmjs.org" + registry-url: 'https://registry.npmjs.org' # Run install dependencies - name: Install dependencies @@ -84,7 +83,7 @@ jobs: - name: Set up QEMU if: ${{ success() && runner.os == 'Linux' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0 - + # Setup DockerBuildx as requirement for docker - name: Set up Docker Buildx if: ${{ success() && runner.os == 'Linux' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} @@ -93,7 +92,7 @@ jobs: # Login to Quay - name: Login to Quay if: ${{ success() && runner.os == 'Linux' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 53dc26976..33f840165 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,63 +20,63 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - # Set up Node - - name: Use Node 16 - uses: actions/setup-node@v1 - with: - node-version: 16 - registry-url: 'https://registry.npmjs.org' + # Set up Node + - name: Use Node 16 + uses: actions/setup-node@v1 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' - # Run install dependencies - - name: Install dependencies - run: yarn + # Run install dependencies + - name: Install dependencies + run: yarn - # Build extension - - name: Run build - run: yarn build + # Build extension + - name: Run build + run: yarn build - # Run tests - - name: Run Test - run: yarn test + # Run tests + - name: Run Test + run: yarn test - # Publish to npm - - run: | - yarn check-dependencies - yarn publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + # Publish to npm + - run: | + yarn check-dependencies + yarn publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - # Get the current package.json version so we can tag the image correctly - - name: Get current package.json version - id: package-version - uses: martinbeentjes/npm-get-version-action@7aa1d82604bb2dbe377a64ca35e692e6fe333c9c #master + # Get the current package.json version so we can tag the image correctly + - name: Get current package.json version + id: package-version + uses: martinbeentjes/npm-get-version-action@7aa1d82604bb2dbe377a64ca35e692e6fe333c9c #master - # Setup QEMU as requirement for docker - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - # Setup DockerBuildx as requirement for docker - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + # Setup QEMU as requirement for docker + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 - # Login to Quay - - name: Login to Quay - uses: docker/login-action@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_TOKEN }} + # Setup DockerBuildx as requirement for docker + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - # Build and push the latest version of yaml language server image - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64 - push: true - tags: | - quay.io/redhat-developer/yaml-language-server:latest - quay.io/redhat-developer/yaml-language-server:${{ steps.package-version.outputs.current-version}} + # Login to Quay + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + + # Build and push the latest version of yaml language server image + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + quay.io/redhat-developer/yaml-language-server:latest + quay.io/redhat-developer/yaml-language-server:${{ steps.package-version.outputs.current-version}} diff --git a/.mocharc.json b/.mocharc.json index b445eb05d..11c3a6f01 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,9 +1,9 @@ { "timeout": "5000", - "ui": "bdd", + "ui": "bdd", "extension": ["ts"], "package": "./package.json", "reporter": "spec", "watch-files": ["./test/*.test.ts"], - "spec": ["./test/*.test.ts"] + "spec": ["./test/*.test.ts"] } diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c381fd8..c760e6052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 1.14.0 -- Fix: Request textDocument/hover failed with message: Invalid regular expression: /(?s).*/: Invalid group [#874](https://github.com/redhat-developer/yaml-language-server/issues/874) + +- Fix: Request `textDocument/hover` failed with message: `Invalid regular expression: /(?s).*/: Invalid group` [#874](https://github.com/redhat-developer/yaml-language-server/issues/874) - Fix: nested anyof const [#888](https://github.com/redhat-developer/yaml-language-server/pull/888) - Fix: Parsing example object as plain string [#889](https://github.com/redhat-developer/yaml-language-server/issues/889) - Fix: Improve smart select [#307](https://github.com/redhat-developer/vscode-yaml/issues/307) @@ -9,6 +10,7 @@ Thanks to [Tony](https://github.com/Legend-Master),[Ace](https://github.com/AceTheCreator) and [PetrSpacek](https://github.com/p-spacek) for your contributions. ### 1.13.0 + - Fix: The default value for keyorder [#859](https://github.com/redhat-developer/yaml-language-server/pull/859) - Fix: older changelog heading levels [#861](https://github.com/redhat-developer/yaml-language-server/pull/861) - Fix: hover behavior when indentation not set [#863](https://github.com/redhat-developer/yaml-language-server/pull/863) @@ -19,6 +21,7 @@ Thanks to [Tony](https://github.com/Legend-Master),[Ace](https://github.com/AceT Thanks to [Kasama](https://github.com/Kasama) ### 1.12.0 + - Fix: Completion Value with dash [#832](https://github.com/redhat-developer/yaml-language-server/pull/832) - Add: Enforce alphabetical ordering of keys in mappings and provide codeaction to fix it. [#839](https://github.com/redhat-developer/yaml-language-server/pull/839) - Fix: Value completion with trailing spaces [#834](https://github.com/redhat-developer/yaml-language-server/pull/834) @@ -31,6 +34,7 @@ Thanks to [Kasama](https://github.com/Kasama) Thanks to Petr Spacek ### 1.11.0 + - Fix: only the first choice is shown when hovering anyOf-typed properties [#784](https://github.com/redhat-developer/vscode-yaml/issues/784) - Fix: Description in the schema root does not get displayed [#809](https://github.com/redhat-developer/vscode-yaml/issues/809) - Fix: yaml.validation.error telemetry events are broken [#816](https://github.com/redhat-developer/vscode-yaml/issues/816) @@ -45,6 +49,7 @@ Thanks to Petr Spacek Thanks to Petr Spacek,Josh Pinkney ### 1.10.0 + - Fix: TypeError: i.startsWith is not a function [#747](https://github.com/redhat-developer/yaml-language-server/issues/747) - Fix: fix: autocomplete indent on object within an array [#751](https://github.com/redhat-developer/yaml-language-server/pull/751) - Add: Yaml style linting to forbid flow style [#753](https://github.com/redhat-developer/yaml-language-server/pull/753) @@ -55,6 +60,7 @@ Thanks to Petr Spacek,Josh Pinkney Thanks to Rickcowan ### 1.9.0 + - Add: Publish pre-release extension on nightly CI build [#682](https://github.com/redhat-developer/vscode-yaml/issues/682) - Add: Add title to extension configuration [#793](https://github.com/redhat-developer/vscode-yaml/pull/793) - Fix: [object Object] with malformed type definition on hover [#788](https://github.com/redhat-developer/vscode-yaml/issues/788) @@ -65,7 +71,9 @@ Thanks to Rickcowan - Fix: proper indenting of snippet within an array [#745](https://github.com/redhat-developer/yaml-language-server/pull/745) Thanks to Whazor Nanne, Petr Spacek, Golergka and Rickcowan + ### 1.8.0 + - Fix: yaml-language-server fails for yaml version [#711](https://github.com/redhat-developer/yaml-language-server/issues/711) - Fix: Missing Schema from catalog.json in ui [#747] (https://github.com/redhat-developer/vscode-yaml/issues/747) - Fix: JSON Schema not applied for custom file extension [#701] (https://github.com/redhat-developer/vscode-yaml/issues/701) @@ -79,6 +87,7 @@ Thanks to Whazor Nanne, Petr Spacek, Golergka and Rickcowan Thanks to Petr Spacek and Grant Dickinson ### 1.7.0 + - Fix: merge simple property completion [#685](https://github.com/redhat-developer/yaml-language-server/pull/685) - Fix: schemaStore.enable setting does not work as expected [#721](https://github.com/redhat-developer/vscode-yaml/issues/721) - Fix: oneOf: misleading validation failures with Incorrect type. Expected "object" [#692](https://github.com/redhat-developer/vscode-yaml/issues/692) @@ -95,6 +104,7 @@ Thanks to Petr Spacek and Grant Dickinson Thanks to Petr Spacek ### 1.6.0 + - Add: differentiate similar schemas on completion [#681](https://github.com/redhat-developer/yaml-language-server/pull/681) - Fix: changed on specific to undefined check instead of null and undefined check [#678](https://github.com/redhat-developer/yaml-language-server/issues/665) - Fix: array object completion - should not suggest const [#620](https://github.com/redhat-developer/yaml-language-server/pull/670) @@ -102,9 +112,11 @@ Thanks to Petr Spacek Thanks to Petr Spacek ### 1.5.1 + - Fix: Yaml errors after updating to v1.5.0 [#708](https://github.com/redhat-developer/vscode-yaml/issues/708) ### 1.5.0 + - Fix: TypeError: Cannot create property 'url' on string [#652](https://github.com/redhat-developer/yaml-language-server/issues/652) - Fix: suggestion item title [#659](https://github.com/redhat-developer/yaml-language-server/pull/659) - Remove data from unused anchor diagnostics [#661](https://github.com/redhat-developer/yaml-language-server/pull/661) @@ -118,6 +130,7 @@ Thanks to Petr Spacek Thanks to lijing00333, Remco Haszing, Petr Spacek and yassun4dev ### 1.4.0 + - Feat: Report unused anchors [#587](https://github.com/redhat-developer/yaml-language-server/issues/587) - Fix: Formatter does not respect `Editor: Detect Indentation = false` [#573](https://github.com/redhat-developer/vscode-yaml/issues/573) - Fix: Flakiness in validator: Incorrect type. Expected "string" [#671](https://github.com/redhat-developer/vscode-yaml/issues/671) @@ -128,6 +141,7 @@ Thanks to lijing00333, Remco Haszing, Petr Spacek and yassun4dev - Fix: Schema validation matches @bitnami as a uri-formatted string. [#586](https://github.com/redhat-developer/yaml-language-server/issues/586) ### 1.3.0 + - Fix: Wrong hover information [#647](https://github.com/redhat-developer/vscode-yaml/issues/647) - Fix: relative file paths with fragments [#603](https://github.com/redhat-developer/yaml-language-server/pull/603) - Update K8S json schema version from 1.20.5 to 1.22.4 [#611](https://github.com/redhat-developer/yaml-language-server/pull/611) @@ -146,18 +160,20 @@ Thanks to lijing00333, Remco Haszing, Petr Spacek and yassun4dev - Feat: disable default props [#606](https://github.com/redhat-developer/yaml-language-server/pull/606) - Fix: Schema validation matches `@bitnami` as a uri-formatted string. [#586](https://github.com/redhat-developer/yaml-language-server/issues/586) - Fix: Array indent doesn't work properly inside another array [#634](https://github.com/redhat-developer/yaml-language-server/pull/634) -- Fix: _PROXY environment and setting not honoured since 1.1.1 [#588](https://github.com/redhat-developer/yaml-language-server/issues/588) +- Fix: `_PROXY` environment and setting not honoured since 1.1.1 [#588](https://github.com/redhat-developer/yaml-language-server/issues/588) - Fix: array indent on different index position [#635](https://github.com/redhat-developer/yaml-language-server/pull/635) - Feat: parent completion [#628](https://github.com/redhat-developer/yaml-language-server/pull/628) Thanks to tonypai, Martti Laine, Petr Spacek, sfalmo ### 1.2.2 + - Fix: LSP triggeringregisterCapability despite dynamicRegistration set to false [#583](https://github.com/redhat-developer/yaml-language-server/issues/583) - Add methods which allow client get schemas info [#556](https://github.com/redhat-developer/yaml-language-server/pull/556) - Fix: links error reporting [#596](https://github.com/redhat-developer/yaml-language-server/pull/596) ### 1.2.1 + - Fix: Can not load schema file when the URL is redirected. [#586](https://github.com/redhat-developer/vscode-yaml/issues/586) - docs: fix typos [#592](https://github.com/redhat-developer/yaml-language-server/pull/592) - Fix: Schema comment still not working properly in 1.1.0. [#629](https://github.com/redhat-developer/vscode-yaml/issues/629) @@ -193,10 +209,12 @@ Thanks to Aurélien Pupier Thanks to Johnny Graettinger, Martin Aeschlimann and Aurélien Pupier ### 1.0.0 + - Use [eemeli/yaml](https://github.com/eemeli/yaml) as YAML parser [#421](https://github.com/redhat-developer/yaml-language-server/issues/421) - Fix: Completion provider: t.replace is not a function [#547](https://github.com/redhat-developer/yaml-language-server/issues/547) ### 0.23.0 + - Replace js-yaml with yaml [#526](https://github.com/redhat-developer/yaml-language-server/pull/526) - Update monaco-yaml link in docs [#527](https://github.com/redhat-developer/yaml-language-server/pull/527) - Update vscode-nls and vscode-uri dependencies [#531](https://github.com/redhat-developer/yaml-language-server/pull/531) @@ -216,7 +234,6 @@ Thanks to Remco Haszing - Fix: Schema URL fragments broken since 0.21.0 [#557](https://github.com/redhat-developer/vscode-yaml/issues/557) - Fix: Unhandled Promise rejections with dynamicRegistration disabled [#498](https://github.com/redhat-developer/yaml-language-server/issues/498) - Thanks to Rob Anderson ### 0.21.1 @@ -285,7 +302,7 @@ Thanks to Andrew Metcalf, Remco Haszing, Petr Spacek and Sorin Sbarnea ### 0.16.0 - CodeAction to open json schema from yaml error [#395](https://github.com/redhat-developer/yaml-language-server/pull/395) -- Upgrade to `4.0.2` vscode-json-languageservice [#405](https://github.com/redhat-developer/yaml-language-server/issues/405) +- Upgrade to `4.0.2` vscode-json-languageservice [#405](https://github.com/redhat-developer/yaml-language-server/issues/405) - feat: add ability to delete all schemas from cache [#397](https://github.com/redhat-developer/yaml-language-server/pull/397) - feat: multiple schema distinction in validation [#410](https://github.com/redhat-developer/yaml-language-server/pull/410) - Fix: Object autocompletion in arrays with custom indentation produces invalid output [#432](https://github.com/redhat-developer/vscode-yaml/issues/432) diff --git a/README.md b/README.md index 6d6c052a8..9877b7158 100755 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The following settings are supported: - `[yaml].editor.formatOnType`: Enable/disable on type indent and auto formatting array - `yaml.disableDefaultProperties`: Disable adding not required properties with default values into completion text - `yaml.suggest.parentSkeletonSelectedFirst`: If true, the user must select some parent skeleton first before autocompletion starts to suggest the rest of the properties.\nWhen yaml object is not empty, autocompletion ignores this setting and returns all properties and skeletons. -- `yaml.style.flowMapping` : Forbids flow style mappings if set to `forbid` +- `yaml.style.flowMapping` : Forbids flow style mappings if set to `forbid` - `yaml.style.flowSequence` : Forbids flow style sequences if set to `forbid` - `yaml.keyOrdering` : Enforces alphabetical ordering of keys in mappings when set to `true`. Default is `false` @@ -261,6 +261,7 @@ or absolute path: ### Schema priority The following is the priority of schema association in highest to lowest priority: + 1. Modeline 2. CustomSchemaProvider API 3. yaml.settings diff --git a/package.json b/package.json index 62be0e23e..9404dfd20 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,10 @@ "type": "git", "url": "https://github.com/redhat-developer/yaml-language-server.git" }, - "optionalDependencies": { - "prettier": "2.8.7" - }, "dependencies": { "ajv": "^8.11.0", "lodash": "4.17.21", + "prettier": "^3.0.0", "request-light": "^0.5.7", "vscode-json-languageservice": "4.1.8", "vscode-languageserver": "^7.0.0", @@ -49,7 +47,6 @@ "@types/chai": "^4.2.12", "@types/mocha": "8.2.2", "@types/node": "16.x", - "@types/prettier": "2.7.2", "@types/sinon": "^9.0.5", "@types/sinon-chai": "^3.2.5", "@typescript-eslint/eslint-plugin": "^5.38.0", @@ -59,7 +56,7 @@ "eslint": "^8.24.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-prettier": "^5.0.0", "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0", "mocha": "9.2.2", @@ -104,5 +101,6 @@ "scripts" ], "all": true - } + }, + "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" } diff --git a/src/languageserver/handlers/languageHandlers.ts b/src/languageserver/handlers/languageHandlers.ts index df7005b94..7f971167b 100644 --- a/src/languageserver/handlers/languageHandlers.ts +++ b/src/languageserver/handlers/languageHandlers.ts @@ -114,7 +114,7 @@ export class LanguageHandlers { * Called when the formatter is invoked * Returns the formatted document content using prettier */ - formatterHandler(formatParams: DocumentFormattingParams): TextEdit[] { + formatterHandler(formatParams: DocumentFormattingParams): Promise { const document = this.yamlSettings.documents.get(formatParams.textDocument.uri); if (!document) { diff --git a/src/languageserver/handlers/requestHandlers.ts b/src/languageserver/handlers/requestHandlers.ts index 120dcb124..50d21f007 100644 --- a/src/languageserver/handlers/requestHandlers.ts +++ b/src/languageserver/handlers/requestHandlers.ts @@ -14,7 +14,10 @@ import { SchemaModificationNotification } from '../../requestTypes'; export class RequestHandlers { private languageService: LanguageService; - constructor(private readonly connection: Connection, languageService: LanguageService) { + constructor( + private readonly connection: Connection, + languageService: LanguageService + ) { this.languageService = languageService; } diff --git a/src/languageserver/handlers/validationHandlers.ts b/src/languageserver/handlers/validationHandlers.ts index b0dd75f5b..e0db58d7b 100644 --- a/src/languageserver/handlers/validationHandlers.ts +++ b/src/languageserver/handlers/validationHandlers.ts @@ -14,7 +14,11 @@ export class ValidationHandler { private languageService: LanguageService; private yamlSettings: SettingsState; - constructor(private readonly connection: Connection, languageService: LanguageService, yamlSettings: SettingsState) { + constructor( + private readonly connection: Connection, + languageService: LanguageService, + yamlSettings: SettingsState + ) { this.languageService = languageService; this.yamlSettings = yamlSettings; diff --git a/src/languageserver/handlers/workspaceHandlers.ts b/src/languageserver/handlers/workspaceHandlers.ts index 448933ffb..05b808b41 100644 --- a/src/languageserver/handlers/workspaceHandlers.ts +++ b/src/languageserver/handlers/workspaceHandlers.ts @@ -7,7 +7,10 @@ import { ExecuteCommandParams, Connection } from 'vscode-languageserver'; import { CommandExecutor } from '../commandExecutor'; export class WorkspaceHandlers { - constructor(private readonly connection: Connection, private readonly commandExecutor: CommandExecutor) {} + constructor( + private readonly connection: Connection, + private readonly commandExecutor: CommandExecutor + ) {} registerHandlers(): void { this.connection.onExecuteCommand((params) => this.executeCommand(params)); diff --git a/src/languageservice/parser/jsonParser07.ts b/src/languageservice/parser/jsonParser07.ts index b4fdfe4b7..452e34e3b 100644 --- a/src/languageservice/parser/jsonParser07.ts +++ b/src/languageservice/parser/jsonParser07.ts @@ -286,7 +286,10 @@ export interface ISchemaCollector { class SchemaCollector implements ISchemaCollector { schemas: IApplicableSchema[] = []; - constructor(private focusOffset = -1, private exclude: ASTNode = null) {} + constructor( + private focusOffset = -1, + private exclude: ASTNode = null + ) {} add(schema: IApplicableSchema): void { this.schemas.push(schema); } diff --git a/src/languageservice/services/documentSymbols.ts b/src/languageservice/services/documentSymbols.ts index 42520736b..e50c992cb 100644 --- a/src/languageservice/services/documentSymbols.ts +++ b/src/languageservice/services/documentSymbols.ts @@ -17,7 +17,10 @@ import { convertErrorToTelemetryMsg } from '../utils/objects'; export class YAMLDocumentSymbols { private jsonDocumentSymbols; - constructor(schemaService: YAMLSchemaService, private readonly telemetry?: Telemetry) { + constructor( + schemaService: YAMLSchemaService, + private readonly telemetry?: Telemetry + ) { this.jsonDocumentSymbols = new JSONDocumentSymbols(schemaService); // override 'getKeyLabel' to handle complex mapping diff --git a/src/languageservice/services/yamlCodeLens.ts b/src/languageservice/services/yamlCodeLens.ts index b1ae69d37..fdfde4fa2 100644 --- a/src/languageservice/services/yamlCodeLens.ts +++ b/src/languageservice/services/yamlCodeLens.ts @@ -15,7 +15,10 @@ import { convertErrorToTelemetryMsg } from '../utils/objects'; import { getSchemaTitle } from '../utils/schemaUtils'; export class YamlCodeLens { - constructor(private schemaService: YAMLSchemaService, private readonly telemetry?: Telemetry) {} + constructor( + private schemaService: YAMLSchemaService, + private readonly telemetry?: Telemetry + ) {} async getCodeLens(document: TextDocument): Promise { const result = []; diff --git a/src/languageservice/services/yamlFormatter.ts b/src/languageservice/services/yamlFormatter.ts index fff674444..2d9bcaf60 100644 --- a/src/languageservice/services/yamlFormatter.ts +++ b/src/languageservice/services/yamlFormatter.ts @@ -6,9 +6,8 @@ import { Range, Position, TextEdit, FormattingOptions } from 'vscode-languageserver-types'; import { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService'; -import * as prettier from 'prettier'; -import { Options } from 'prettier'; -import * as parser from 'prettier/parser-yaml'; +import { format, Options } from 'prettier'; +import * as parser from 'prettier/plugins/yaml'; import { TextDocument } from 'vscode-languageserver-textdocument'; export class YAMLFormatter { @@ -20,7 +19,10 @@ export class YAMLFormatter { } } - public format(document: TextDocument, options: Partial & CustomFormatterOptions = {}): TextEdit[] { + public async format( + document: TextDocument, + options: Partial & CustomFormatterOptions = {} + ): Promise { if (!this.formatterEnabled) { return []; } @@ -43,7 +45,7 @@ export class YAMLFormatter { printWidth: options.printWidth, }; - const formatted = prettier.format(text, prettierOptions); + const formatted = await format(text, prettierOptions); return [TextEdit.replace(Range.create(Position.create(0, 0), document.positionAt(text.length)), formatted)]; } catch (error) { diff --git a/src/languageservice/services/yamlHover.ts b/src/languageservice/services/yamlHover.ts index a0e72ce3a..f02c29d17 100644 --- a/src/languageservice/services/yamlHover.ts +++ b/src/languageservice/services/yamlHover.ts @@ -26,7 +26,10 @@ export class YAMLHover { private indentation: string; private schemaService: YAMLSchemaService; - constructor(schemaService: YAMLSchemaService, private readonly telemetry?: Telemetry) { + constructor( + schemaService: YAMLSchemaService, + private readonly telemetry?: Telemetry + ) { this.shouldHover = true; this.schemaService = schemaService; } diff --git a/src/languageservice/services/yamlValidation.ts b/src/languageservice/services/yamlValidation.ts index fd26af2e8..04c58edf5 100644 --- a/src/languageservice/services/yamlValidation.ts +++ b/src/languageservice/services/yamlValidation.ts @@ -48,7 +48,10 @@ export class YAMLValidation { private MATCHES_MULTIPLE = 'Matches multiple schemas when only one must validate.'; - constructor(schemaService: YAMLSchemaService, private readonly telemetry?: Telemetry) { + constructor( + schemaService: YAMLSchemaService, + private readonly telemetry?: Telemetry + ) { this.validationEnabled = true; this.jsonValidation = new JSONValidation(schemaService, Promise); } diff --git a/src/languageservice/yamlLanguageService.ts b/src/languageservice/yamlLanguageService.ts index 539371d8b..7fa9dcee7 100644 --- a/src/languageservice/yamlLanguageService.ts +++ b/src/languageservice/yamlLanguageService.ts @@ -166,7 +166,7 @@ export interface LanguageService { findDocumentSymbols2: (document: TextDocument, context?: DocumentSymbolsContext) => DocumentSymbol[]; findLinks: (document: TextDocument) => Promise; resetSchema: (uri: string) => boolean; - doFormat: (document: TextDocument, options?: CustomFormatterOptions) => TextEdit[]; + doFormat: (document: TextDocument, options?: CustomFormatterOptions) => Promise; doDefinition: (document: TextDocument, params: DefinitionParams) => DefinitionLink[] | undefined; doDocumentOnTypeFormatting: (document: TextDocument, params: DocumentOnTypeFormattingParams) => TextEdit[] | undefined; addSchema: (schemaID: string, schema: JSONSchema) => void; diff --git a/test/fixtures/defaultSnippets-const-if-else.json b/test/fixtures/defaultSnippets-const-if-else.json index 4e9cdd4c5..8d997e48a 100644 --- a/test/fixtures/defaultSnippets-const-if-else.json +++ b/test/fixtures/defaultSnippets-const-if-else.json @@ -2,71 +2,70 @@ "title": "Example", "type": "object", "properties": { - "foo": { - "title": "Foo", - "type": "string", - "defaultSnippets": [ - { - "label": "foobar", - "markdownDescription": "# FooBar\n```Foo Bar```", - "body": "foobar" - }, - { - "label": "foobaz", - "markdownDescription": "# FooBaz\n```Foo Baz```", - "body": "foobaz" - } - ] - }, - "bar": { - "title": "Bar", - "type": "object", - "default": {} - } + "foo": { + "title": "Foo", + "type": "string", + "defaultSnippets": [ + { + "label": "foobar", + "markdownDescription": "# FooBar\n```Foo Bar```", + "body": "foobar" + }, + { + "label": "foobaz", + "markdownDescription": "# FooBaz\n```Foo Baz```", + "body": "foobaz" + } + ] + }, + "bar": { + "title": "Bar", + "type": "object", + "default": {} + } }, "allOf": [ - { - "if": { + { + "if": { + "properties": { + "foo": { + "const": "foobar" + } + } + }, + "then": { + "properties": { + "bar": { "properties": { - "foo": { - "const": "foobar" + "barbar": { + "title": "BarBar", + "description": "Bar Bar Bar" } } - }, - "then": { - "properties": { - "bar": { - "properties": { - "barbar": { - "title": "BarBar", - "description": "Bar Bar Bar" - } - } - } - } } + } + } + }, + { + "if": { + "properties": { + "foo": { + "const": "foobaz" + } + } }, - { - "if": { + "then": { + "properties": { + "bar": { "properties": { - "foo": { - "const": "foobaz" + "barbaz": { + "title": "BarBaz", + "description": "Bar Baz Bar" } } - }, - "then": { - "properties": { - "bar": { - "properties": { - "barbaz": { - "title": "BarBaz", - "description": "Bar Baz Bar" - } - } - } - } } + } } + } ] } - diff --git a/test/fixtures/sample-association.json b/test/fixtures/sample-association.json index cebe2d95c..419a19d42 100644 --- a/test/fixtures/sample-association.json +++ b/test/fixtures/sample-association.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft-07/schema", - "properties": { - "association": { - "type":"string" - } + "$schema": "http://json-schema.org/draft-07/schema", + "properties": { + "association": { + "type": "string" } + } } diff --git a/test/fixtures/sample-modeline.json b/test/fixtures/sample-modeline.json index 2dc2e385d..78577ef6b 100644 --- a/test/fixtures/sample-modeline.json +++ b/test/fixtures/sample-modeline.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft-07/schema", - "properties": { - "modeline": { - "type":"string" - } + "$schema": "http://json-schema.org/draft-07/schema", + "properties": { + "modeline": { + "type": "string" } + } } diff --git a/test/fixtures/sample-schemastore.json b/test/fixtures/sample-schemastore.json index 64cf1fde6..fa120e35c 100644 --- a/test/fixtures/sample-schemastore.json +++ b/test/fixtures/sample-schemastore.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft-07/schema", - "properties": { - "schemastore": { - "type":"string" - } + "$schema": "http://json-schema.org/draft-07/schema", + "properties": { + "schemastore": { + "type": "string" } + } } diff --git a/test/fixtures/sample-settings.json b/test/fixtures/sample-settings.json index e2c1dcd8c..3f881aee3 100644 --- a/test/fixtures/sample-settings.json +++ b/test/fixtures/sample-settings.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft-07/schema", - "properties": { - "settings": { - "type":"string" - } + "$schema": "http://json-schema.org/draft-07/schema", + "properties": { + "settings": { + "type": "string" } + } } diff --git a/test/fixtures/test-completion-oneOf.json b/test/fixtures/test-completion-oneOf.json index a975751ac..64e3dfc53 100644 --- a/test/fixtures/test-completion-oneOf.json +++ b/test/fixtures/test-completion-oneOf.json @@ -1,8 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "required": [ - "metadata" - ], + "required": ["metadata"], "type": "object", "additionalProperties": false, "properties": { @@ -40,11 +38,7 @@ "FUNC_item": { "type": "object", "additionalProperties": false, - "required": [ - "attribute", - "operation", - "value" - ], + "required": ["attribute", "operation", "value"], "properties": { "attribute": { "type": "string" @@ -123,11 +117,7 @@ } }, "queryItem": { - "oneOf": [ - - {"$ref": "#/definitions/AND_Item"}, - {"$ref": "#/definitions/OR_Item"} - ] + "oneOf": [{ "$ref": "#/definitions/AND_Item" }, { "$ref": "#/definitions/OR_Item" }] } } } diff --git a/test/fixtures/test-nested-object-array.json b/test/fixtures/test-nested-object-array.json index 47c70ccbc..65f42fb54 100644 --- a/test/fixtures/test-nested-object-array.json +++ b/test/fixtures/test-nested-object-array.json @@ -1,11 +1,8 @@ { - "allOf": [ - { "$ref": "#/$configs/objectA" }, - { "$ref": "#/$configs/objectB" } - ], + "allOf": [{ "$ref": "#/$configs/objectA" }, { "$ref": "#/$configs/objectB" }], "$defs": { - "name": { + "name": { "name": { "type": "string", "description": "name" } }, "prop1": { @@ -14,7 +11,7 @@ "prop2": { "prop1": { "type": "string", "description": "prop2" } } - }, + }, "$configs": { "objectA": { diff --git a/test/fixtures/testMultipleSimilarSchema.json b/test/fixtures/testMultipleSimilarSchema.json index 0dfd6abd0..b3e9b4ec3 100644 --- a/test/fixtures/testMultipleSimilarSchema.json +++ b/test/fixtures/testMultipleSimilarSchema.json @@ -15,11 +15,7 @@ "const": "constForType1" } }, - "required": [ - "objA", - "propA", - "constA" - ], + "required": ["objA", "propA", "constA"], "type": "object" } } @@ -33,9 +29,7 @@ "type": "object" } }, - "required": [ - "obj2" - ], + "required": ["obj2"], "type": "object" }, "type3": { @@ -51,11 +45,7 @@ "const": "constForType3" } }, - "required": [ - "objA", - "propA", - "constA" - ], + "required": ["objA", "propA", "constA"], "type": "object" } }, diff --git a/test/formatter.test.ts b/test/formatter.test.ts index ed970a001..5ab02ae44 100644 --- a/test/formatter.test.ts +++ b/test/formatter.test.ts @@ -24,7 +24,7 @@ describe('Formatter Tests', () => { describe('Formatter', function () { describe('Test that formatter works with custom tags', function () { // eslint-disable-next-line @typescript-eslint/no-explicit-any - function parseSetup(content: string, options: any = {}): TextEdit[] { + function parseSetup(content: string, options: any = {}): Promise { const testTextDocument = setupTextDocument(content); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); @@ -35,31 +35,32 @@ describe('Formatter Tests', () => { }); } - it('Formatting works without custom tags', () => { + it('Formatting works without custom tags', async () => { const content = 'cwd: test'; - const edits = parseSetup(content); + const edits = await parseSetup(content); + console.dir({ edits }); assert.notEqual(edits.length, 0); assert.equal(edits[0].newText, 'cwd: test\n'); }); - it('Formatting works with custom tags', () => { + it('Formatting works with custom tags', async () => { const content = 'cwd: !Test test'; - const edits = parseSetup(content); + const edits = await parseSetup(content); assert.notEqual(edits.length, 0); assert.equal(edits[0].newText, 'cwd: !Test test\n'); }); - it('Formatting wraps text', () => { + it('Formatting wraps text', async () => { const content = `comments: > test test test test test test test test test test test test`; - const edits = parseSetup(content, { + const edits = await parseSetup(content, { printWidth: 20, proseWrap: 'always', }); assert.equal(edits[0].newText, 'comments: >\n test test test\n test test test\n test test test\n test test test\n'); }); - it('Formatting uses tabSize', () => { + it('Formatting uses tabSize', async () => { const content = `map: k1: v1 k2: v2 @@ -68,7 +69,7 @@ list: - item2 `; - const edits = parseSetup(content, { + const edits = await parseSetup(content, { tabSize: 5, }); @@ -82,7 +83,7 @@ list: assert.equal(edits[0].newText, expected); }); - it('Formatting uses tabWidth', () => { + it('Formatting uses tabWidth', async () => { const content = `map: k1: v1 k2: v2 @@ -91,7 +92,7 @@ list: - item2 `; - const edits = parseSetup(content, { + const edits = await parseSetup(content, { tabWidth: 5, }); @@ -105,7 +106,7 @@ list: assert.equal(edits[0].newText, expected); }); - it('Formatting uses tabWidth over tabSize', () => { + it('Formatting uses tabWidth over tabSize', async () => { const content = `map: k1: v1 k2: v2 @@ -114,7 +115,7 @@ list: - item2 `; - const edits = parseSetup(content, { + const edits = await parseSetup(content, { tabSize: 3, tabWidth: 5, }); diff --git a/tsconfig.esm.json b/tsconfig.esm.json index a2c13969e..1ddcfd5ff 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -4,12 +4,7 @@ "downlevelIteration": true, "lib": ["WebWorker"], "module": "esnext", - "outDir": "./lib/esm", + "outDir": "./lib/esm" }, - "exclude": [ - "node_modules", - "out", - "lib", - "test" - ] + "exclude": ["node_modules", "out", "lib", "test"] } diff --git a/tsconfig.json b/tsconfig.json index 5294b2662..3a4110a08 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,9 +9,9 @@ "outDir": "./out/server", "sourceMap": true, "target": "es2020", - "allowSyntheticDefaultImports": true, + "allowSyntheticDefaultImports": true, "skipLibCheck": true }, - "include": [ "src", "test" ], + "include": ["src", "test"], "exclude": ["node_modules", "out"] } diff --git a/tsconfig.umd.json b/tsconfig.umd.json index 7da9c61ff..85c95ccd7 100644 --- a/tsconfig.umd.json +++ b/tsconfig.umd.json @@ -3,12 +3,7 @@ "compilerOptions": { "lib": ["webworker"], "module": "umd", - "outDir": "./lib/umd", + "outDir": "./lib/umd" }, - "exclude": [ - "node_modules", - "out", - "lib", - "test" - ] + "exclude": ["node_modules", "out", "lib", "test"] } diff --git a/yarn.lock b/yarn.lock index fd794ffda..f688e36c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -347,6 +347,11 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@pkgr/core@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" + integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== + "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.1": version "1.8.3" resolved "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz" @@ -425,11 +430,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.60.tgz#a1fbca80c18dd80c8783557304cdb7d55ac3aff5" integrity sha512-kYIYa1D1L+HDv5M5RXQeEu1o0FKA6yedZIoyugm/MBPROkLpX4L7HRxMrPVyo8bnvjpW/wDlqFNGzXNMb7AdRw== -"@types/prettier@2.7.2": - version "2.7.2" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0" - integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg== - "@types/sinon-chai@^3.2.5": version "3.2.5" resolved "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.5.tgz" @@ -1193,12 +1193,13 @@ eslint-plugin-import@^2.26.0: resolve "^1.22.0" tsconfig-paths "^3.14.1" -eslint-plugin-prettier@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b" - integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ== +eslint-plugin-prettier@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz#6887780ed95f7708340ec79acfdf60c35b9be57a" + integrity sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w== dependencies: prettier-linter-helpers "^1.0.0" + synckit "^0.8.5" eslint-scope@^5.1.1: version "5.1.1" @@ -2570,10 +2571,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@2.8.7: - version "2.8.7" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.7.tgz#bb79fc8729308549d28fe3a98fce73d2c0656450" - integrity sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw== +prettier@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.1.tgz#65271fc9320ce4913c57747a70ce635b30beaa40" + integrity sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ== process-on-spawn@^1.0.0: version "1.0.0" @@ -2783,7 +2784,7 @@ side-channel@^1.0.4: signal-exit@^3.0.2: version "3.0.7" - resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== sinon-chai@^3.5.0: @@ -2928,6 +2929,14 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +synckit@^0.8.5: + version "0.8.8" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.8.tgz#fe7fe446518e3d3d49f5e429f443cf08b6edfcd7" + integrity sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ== + dependencies: + "@pkgr/core" "^0.1.0" + tslib "^2.6.2" + test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz" @@ -2996,6 +3005,11 @@ tslib@^1.8.1: resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"