From d0da4282d31393afae2cbf6a0a28168bfc13995e Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Mon, 5 Oct 2026 17:20:41 -0400 Subject: [PATCH 01/18] switch to full ESM Signed-off-by: Morgan Chang --- .github/workflows/CI.yaml | 4 +- .gitignore | 3 - .mocharc.json | 9 - .npmignore | 7 +- README.md | 2 +- bin/yaml-language-server | 6 +- package-lock.json | 2116 +++-------------- package.json | 40 +- scripts/check-dependencies.js | 9 +- src/index.ts | 2 +- .../handlers/languageHandlers.ts | 10 +- .../handlers/notificationHandlers.ts | 10 +- .../handlers/requestHandlers.ts | 8 +- .../handlers/schemaSelectionHandlers.ts | 14 +- .../handlers/settingsHandlers.ts | 24 +- .../handlers/validationHandlers.ts | 8 +- .../handlers/workspaceHandlers.ts | 2 +- src/languageserver/telemetry.ts | 4 +- src/languageservice/jsonLanguageTypes.ts | 86 +- src/languageservice/jsonSchema.ts | 5 +- src/languageservice/parser/ast-converter.ts | 6 +- .../parser/custom-tag-provider.ts | 4 +- src/languageservice/parser/isKubernetes.ts | 4 +- src/languageservice/parser/jsonDocument.ts | 14 +- .../parser/schemaValidation/baseValidator.ts | 24 +- .../schemaValidation/draft04Validator.ts | 8 +- .../schemaValidation/draft07Validator.ts | 8 +- .../schemaValidation/draft2019Validator.ts | 14 +- .../schemaValidation/draft2020Validator.ts | 14 +- .../schemaValidation/validatorFactory.ts | 12 +- src/languageservice/parser/yaml-documents.ts | 26 +- src/languageservice/parser/yamlParser07.ts | 6 +- .../services/documentSymbols.ts | 6 +- src/languageservice/services/dollarUtils.ts | 4 +- src/languageservice/services/k8sSchemaUtil.ts | 8 +- src/languageservice/services/modelineUtil.ts | 4 +- .../services/schemaRequestHandler.ts | 15 +- .../services/validation/map-key-order.ts | 4 +- .../services/validation/types.ts | 2 +- .../services/validation/unused-anchors.ts | 8 +- .../services/validation/yaml-style.ts | 6 +- .../services/yamlCodeActions.ts | 24 +- src/languageservice/services/yamlCodeLens.ts | 12 +- src/languageservice/services/yamlCommands.ts | 4 +- .../services/yamlCompletion.ts | 42 +- .../services/yamlDefinition.ts | 8 +- src/languageservice/services/yamlFolding.ts | 6 +- src/languageservice/services/yamlFormatter.ts | 2 +- src/languageservice/services/yamlHover.ts | 24 +- src/languageservice/services/yamlLinks.ts | 8 +- .../services/yamlOnTypeFormatting.ts | 2 +- src/languageservice/services/yamlRename.ts | 12 +- .../services/yamlSchemaService.ts | 50 +- .../services/yamlSelectionRanges.ts | 4 +- .../services/yamlValidation.ts | 32 +- src/languageservice/utils/arrUtils.ts | 2 +- src/languageservice/utils/astNodeUtils.ts | 2 +- .../utils/filePatternAssociation.ts | 2 +- .../utils/flow-style-rewriter.ts | 2 +- .../utils/indentationGuesser.ts | 4 +- src/languageservice/utils/objects.ts | 2 +- src/languageservice/utils/parseUtils.ts | 3 +- src/languageservice/utils/schemaUrls.ts | 8 +- src/languageservice/utils/schemaUtils.ts | 2 +- src/languageservice/utils/strings.ts | 2 +- src/languageservice/utils/yamlAstUtils.ts | 2 +- src/languageservice/yamlLanguageService.ts | 46 +- src/nodeTranslationSetup.ts | 3 +- src/requestTypes.ts | 6 +- src/server.ts | 16 +- src/webworker/yamlServerMain.ts | 10 +- src/yamlServerInit.ts | 28 +- src/yamlSettings.ts | 10 +- test/arrUtils.test.ts | 4 +- test/astUtils.test.ts | 10 +- test/autoCompletion.test.ts | 122 +- test/autoCompletionFix.test.ts | 32 +- test/bundlel10n.test.ts | 24 +- test/code-action-schema.test.ts | 16 +- test/customTags.test.ts | 12 +- test/defaultSnippets.test.ts | 14 +- test/diagnostic-filter.test.ts | 6 +- test/documentSymbols.test.ts | 14 +- test/findLinks.test.ts | 12 +- test/flow-style-rewriter.test.ts | 7 +- test/formatter.test.ts | 18 +- test/hover.test.ts | 16 +- test/integration.test.ts | 14 +- test/invalid-metaschema.test.ts | 19 +- test/multipleDocuments.test.ts | 18 +- test/objects.test.ts | 4 +- test/paths.test.ts | 19 +- test/schema.test.ts | 58 +- test/schema2019Validation.test.ts | 18 +- test/schema2020Validation.test.ts | 18 +- test/schemaRequestHandler.test.ts | 25 +- test/schemaSelectionHandlers.test.ts | 21 +- test/schemaValidation.test.ts | 60 +- test/settingsHandlers.test.ts | 56 +- test/strings.test.ts | 4 +- test/telemetry.test.ts | 13 +- test/textBuffer.test.ts | 4 +- test/utils/serviceSetup.ts | 4 +- test/utils/testHelper.ts | 30 +- test/utils/testsTypes.ts | 4 +- test/utils/verifyError.ts | 2 +- test/yaml-documents.test.ts | 29 +- test/yamlCodeActions.test.ts | 18 +- test/yamlCodeLens.test.ts | 35 +- test/yamlCommands.test.ts | 15 +- test/yamlDefinition.test.ts | 8 +- test/yamlFolding.test.ts | 8 +- test/yamlLanguageService.test.ts | 10 +- test/yamlOnTypeFormatting.test.ts | 6 +- test/yamlParser.test.ts | 10 +- test/yamlRename.test.ts | 3 +- test/yamlSchema.test.ts | 14 +- test/yamlSchemaService.test.ts | 43 +- test/yamlSelectionRanges.test.ts | 5 +- test/yamlValidation.test.ts | 18 +- tsconfig.esm.json | 11 - tsconfig.json | 2 +- tsconfig.umd.json | 12 - 123 files changed, 1188 insertions(+), 2703 deletions(-) delete mode 100644 .mocharc.json delete mode 100644 tsconfig.esm.json delete mode 100644 tsconfig.umd.json diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 82aeba130..85a30dd54 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -30,10 +30,10 @@ jobs: - uses: actions/checkout@v7 # Set up Node - - name: Use Node 22 + - name: Use Node 22.13.0 uses: actions/setup-node@v7 with: - node-version: 22 + node-version: 22.13.0 registry-url: 'https://registry.npmjs.org' # Run install dependencies diff --git a/.gitignore b/.gitignore index 8a0fe4b6d..71489877e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,9 @@ npm-debug.log .vscode node_modules/ -npm-debug.log -.nyc_output out/server .DS_Store yarn-error.log coverage -lib/ eslint-result.sarif yarn.lock diff --git a/.mocharc.json b/.mocharc.json deleted file mode 100644 index 7fdedf1c0..000000000 --- a/.mocharc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "timeout": "10000", - "ui": "bdd", - "extension": ["ts"], - "package": "./package.json", - "reporter": "spec", - "watch-files": ["./test/*.test.ts"], - "spec": ["./test/*.test.ts"] -} diff --git a/.npmignore b/.npmignore index 8103daf58..ef4d1425b 100644 --- a/.npmignore +++ b/.npmignore @@ -1,13 +1,10 @@ /src /test .editorconfig -Jenkinsfile tsconfig.json -.nyc_output/ coverage/ .vscode/ .github/ -.eslintrc.js .prettierrc.json -.travis.yml -.mocharc.json +eslint.config.mjs +eslint-result.sarif diff --git a/README.md b/README.md index 059839d3e..60b722ba2 100755 --- a/README.md +++ b/README.md @@ -620,7 +620,7 @@ Use `npm test` to run tests. ### Module builds -Building YAML Language Server produces [CommonJS](http://www.commonjs.org/) output in the `out/server/src` directory. In addition, a build also produces [UMD](https://github.com/umdjs/umd) (Universal Module Definition) modules and [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) in the `lib` directory. These module formats support different server-side module loaders and browser bundlers such as webpack. +Building YAML Language Server produces [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) and declarations in the `out/server/src` directory. ### CI diff --git a/bin/yaml-language-server b/bin/yaml-language-server index 9ed594594..c72a5c3b5 100755 --- a/bin/yaml-language-server +++ b/bin/yaml-language-server @@ -1,6 +1,8 @@ #!/usr/bin/env node -const version = require('../package.json').version; +import packageConfig from '../package.json' with { type: 'json' }; + +const version = packageConfig.version; const args = process.argv.slice(2); if (args.includes('--version') || args.includes('-version')) { @@ -24,4 +26,4 @@ Other: } process.env.YAML_LANGUAGE_SERVER_VERSION = version; -require('../out/server/src/server.js'); +await import('../out/server/src/server.js'); diff --git a/package-lock.json b/package-lock.json index b3febb87d..579c5b965 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,292 +29,35 @@ "devDependencies": { "@microsoft/eslint-formatter-sarif": "^3.0.0", "@types/chai": "^4.2.12", - "@types/mocha": "8.2.2", "@types/node": "22.x", "@types/picomatch": "^4.0.3", - "@types/sinon": "^9.0.5", + "@types/sinon": "^22.0.0", "@types/sinon-chai": "^3.2.5", "@typescript-eslint/parser": "^8.59.4", + "c8": "^12.0.0", "chai": "^4.2.0", "eslint": "^10.0.0", "eslint-plugin-import-x": "^4.0.0", "eslint-plugin-prettier": "^5.0.0", - "mocha": "12.0.0", - "nyc": "^18.0.0", "rimraf": "^3.0.2", - "sinon": "^9.0.3", + "sinon": "^22.1.0", "sinon-chai": "^3.5.0", - "source-map-support": "^0.5.19", "ts-node": "^10.0.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", - "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-validator-identifier": "^7.29.7", - "js-tokens": "^4.0.0", - "picocolors": "^1.1.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", - "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", - "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.7", - "@babel/helper-compilation-targets": "^7.29.7", - "@babel/helper-module-transforms": "^7.29.7", - "@babel/helpers": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/template": "^7.29.7", - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7", - "@jridgewell/remapping": "^2.3.5", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.7.tgz", - "integrity": "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.29.7", - "@babel/types": "^7.29.7", - "@jridgewell/gen-mapping": "^0.3.12", - "@jridgewell/trace-mapping": "^0.3.28", - "jsesc": "^3.0.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", - "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/compat-data": "^7.29.7", - "@babel/helper-validator-option": "^7.29.7", - "browserslist": "^4.24.0", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-globals": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", - "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", - "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7" }, "engines": { - "node": ">=6.9.0" + "node": ">=22.13.0" } }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", - "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-module-imports": "^7.29.7", - "@babel/helper-validator-identifier": "^7.29.7", - "@babel/traverse": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", - "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", - "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", - "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", - "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/template": "^7.29.7", - "@babel/types": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.7.tgz", - "integrity": "sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.29.7" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/template": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", - "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/types": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.7.tgz", - "integrity": "sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.7", - "@babel/helper-globals": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/template": "^7.29.7", - "@babel/types": "^7.29.7", - "debug": "^4.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.7.tgz", - "integrity": "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==", + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", "dev": true, "license": "MIT", - "dependencies": { - "@babel/helper-string-parser": "^7.29.7", - "@babel/helper-validator-identifier": "^7.29.7" - }, "engines": { - "node": ">=6.9.0" + "node": ">=18" } }, "node_modules/@cspotcode/source-map-support": { @@ -716,113 +459,6 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@istanbuljs/load-nyc-config": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "camelcase": "^5.3.1", - "find-up": "^4.1.0", - "get-package-type": "^0.1.0", - "js-yaml": "^3.13.1", - "resolve-from": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "license": "MIT", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { - "version": "3.15.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.2.tgz", - "integrity": "sha512-6EuL879VkRA+1Cz578mKMiKvjPNEuk6+r1JaFzoSWejZmtf7xWbIyw1e3KkxlkzTIt9Taw6JBhEppG7utc1P+w==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/@istanbuljs/schema": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", @@ -833,28 +469,6 @@ "node": ">=8" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, - "node_modules/@jridgewell/remapping": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", - "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", @@ -1150,9 +764,9 @@ } }, "node_modules/@sinonjs/commons": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", - "integrity": "sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -1170,34 +784,26 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz", - "integrity": "sha512-MZPUxrmFubI36XS1DI3qmI0YdN1gks62JtFZvxR67ljjSNCeK6U08Zx4msEWOXuofgqUt6zPHSi1H9fbjR/NRA==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-15.4.0.tgz", + "integrity": "sha512-DsG+8/LscQIQg68J6Ef3dv10u6nVyetYn923s3/sus5eaGfTo1of5WMZSLf0UJc9KDuKPilPH0UDJCjvNbDNCA==", "dev": true, "license": "BSD-3-Clause", "dependencies": { - "@sinonjs/commons": "^1.7.0" + "@sinonjs/commons": "^3.0.1" } }, "node_modules/@sinonjs/samsam": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.3.1.tgz", - "integrity": "sha512-1Hc0b1TtyfBu8ixF/tpfSHTVWKwCBLY4QJbkgnE7HcwyvT2xArDxb4K7dMgqRm3szI+LJbzmW/s4xxEhv6hwDg==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-10.0.2.tgz", + "integrity": "sha512-8lVwD1Df1BmzoaOLhMcGGcz/Jyr5QY2KSB75/YK1QgKzoabTeLdIVyhXNZK9ojfSKSdirbXqdbsXXqP9/Ve8+A==", "dev": true, "license": "BSD-3-Clause", "dependencies": { - "@sinonjs/commons": "^1.6.0", - "lodash.get": "^4.4.2", - "type-detect": "^4.0.8" + "@sinonjs/commons": "^3.0.1", + "type-detect": "^4.1.0" } }, - "node_modules/@sinonjs/text-encoding": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.3.tgz", - "integrity": "sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==", - "dev": true, - "license": "(Unlicense OR Apache-2.0)" - }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -1258,6 +864,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1265,13 +878,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/mocha": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.2.tgz", - "integrity": "sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/node": { "version": "22.20.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz", @@ -1290,9 +896,9 @@ "license": "MIT" }, "node_modules/@types/sinon": { - "version": "9.0.11", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-9.0.11.tgz", - "integrity": "sha512-PwP4UY33SeeVKodNE37ZlOsR9cReypbMJOhZ7BVE0lB+Hix3efCOxiJWiE5Ia+yL9Cn2Ch72EjFTRze8RZsNtg==", + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-22.0.0.tgz", + "integrity": "sha512-TDbVpbccc2HfiqHR09Argj3mHV1KMW7sCCKj52fsl8lbRLkEn7fB1966EWhOKWUBcqfBueZuPoA7/OK1CKiy3g==", "dev": true, "license": "MIT", "dependencies": { @@ -1948,20 +1554,6 @@ "node": ">=0.4.0" } }, - "node_modules/aggregate-error": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", - "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "clean-stack": "^2.0.0", - "indent-string": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/ajv": { "version": "8.18.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", @@ -2027,26 +1619,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/append-transform": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", - "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", - "dev": true, - "license": "MIT", - "dependencies": { - "default-require-extensions": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/archy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", - "dev": true, - "license": "MIT" - }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -2078,19 +1650,6 @@ "dev": true, "license": "MIT" }, - "node_modules/baseline-browser-mapping": { - "version": "2.11.21", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz", - "integrity": "sha512-uh8vpY/1/YyFkunIDFH/12p7/7VdPKA1hejMVEbdkEaWnUz0Hesvx5EbiU6XxjyHZIOju+ZMbQJkRh+es3/spQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "baseline-browser-mapping": "dist/cli.cjs" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/brace-expansion": { "version": "1.1.18", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", @@ -2102,68 +1661,38 @@ "concat-map": "0.0.1" } }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true, - "license": "ISC" - }, - "node_modules/browserslist": { - "version": "4.28.8", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz", - "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==", + "node_modules/c8": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-12.0.0.tgz", + "integrity": "sha512-4zpJvrd1nKWutnnKC2pXkFmb6iM1l+ffN//o1CzlTNwW7GSOs9a1xrLqkC48nU8oEkjmPZLPiwMsIaOvoF4Pqg==", "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", + "license": "ISC", "dependencies": { - "baseline-browser-mapping": "^2.11.12", - "caniuse-lite": "^1.0.30001809", - "electron-to-chromium": "^1.5.402", - "node-releases": "^2.0.53", - "update-browserslist-db": "^1.3.0" + "@bcoe/v8-coverage": "^1.0.1", + "@istanbuljs/schema": "^0.1.3", + "find-up": "^5.0.0", + "foreground-child": "^3.1.1", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.1.6", + "test-exclude": "^8.0.0", + "v8-to-istanbul": "^9.0.0", + "yargs": "^18.0.0", + "yargs-parser": "^21.1.1" }, "bin": { - "browserslist": "cli.js" + "c8": "bin/c8.js" }, "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/caching-transform": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", - "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", - "dev": true, - "license": "MIT", - "dependencies": { - "hasha": "^5.0.0", - "make-dir": "^3.0.0", - "package-hash": "^4.0.0", - "write-file-atomic": "^3.0.0" + "node": "^20.19.0 || ^22.12.0 || >=23" }, - "engines": { - "node": ">=8" + "peerDependencies": { + "monocart-coverage-reports": "^2" + }, + "peerDependenciesMeta": { + "monocart-coverage-reports": { + "optional": true + } } }, "node_modules/callsites": { @@ -2176,37 +1705,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001810", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", - "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "CC-BY-4.0" - }, "node_modules/chai": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", @@ -2256,30 +1754,66 @@ "node": "*" } }, - "node_modules/chokidar": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", - "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", + "node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", "dev": true, "license": "MIT", "dependencies": { - "readdirp": "^5.0.0" + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": ">= 20.19.0" + "node": ">=18" }, "funding": { - "url": "https://paulmillr.com/funding/" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/clean-stack": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", - "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "node_modules/cliui/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, "engines": { - "node": ">=6" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/color-convert": { @@ -2312,13 +1846,6 @@ "node": ">= 12.0.0" } }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true, - "license": "MIT" - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2326,13 +1853,6 @@ "dev": true, "license": "MIT" }, - "node_modules/convert-source-map": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", - "dev": true, - "license": "MIT" - }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -2373,16 +1893,6 @@ } } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/deep-eql": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", @@ -2403,22 +1913,6 @@ "dev": true, "license": "MIT" }, - "node_modules/default-require-extensions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", - "integrity": "sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==", - "dev": true, - "license": "MIT", - "dependencies": { - "strip-bom": "^4.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/diff": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz", @@ -2442,17 +1936,10 @@ "node": ">=6.0.0" } }, - "node_modules/electron-to-chromium": { - "version": "1.5.420", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.420.tgz", - "integrity": "sha512-2yD6XreGusOfNV+dUcvipJEXc3n/n7fgr7996aszTG+YY5E4mqM4tOq/3uhP129cazL9YHbVWSpc79ePotWtPA==", - "dev": true, - "license": "ISC" - }, - "node_modules/es6-error": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", - "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", "dev": true, "license": "MIT" }, @@ -2784,20 +2271,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "license": "BSD-2-Clause", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/esquery": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", @@ -2910,24 +2383,6 @@ "node": ">=16.0.0" } }, - "node_modules/find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", - "dev": true, - "license": "MIT", - "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/avajs/find-cache-dir?sponsor=1" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2983,27 +2438,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/fromentries": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", - "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3011,16 +2445,6 @@ "dev": true, "license": "ISC" }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -3031,24 +2455,27 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", "dev": true, "license": "MIT", "engines": { - "node": "*" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/get-package-type": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", - "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", "dev": true, "license": "MIT", "engines": { - "node": ">=8.0.0" + "node": "*" } }, "node_modules/get-tsconfig": { @@ -3134,13 +2561,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true, - "license": "ISC" - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -3158,33 +2578,6 @@ "node": ">=8" } }, - "node_modules/hasha": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", - "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-stream": "^2.0.0", - "type-fest": "^0.8.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/hasha/node_modules/type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=8" - } - }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -3229,16 +2622,6 @@ "node": ">=0.8.19" } }, - "node_modules/indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -3268,16 +2651,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -3301,49 +2674,6 @@ "node": ">=8" } }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", - "dev": true, - "license": "MIT" - }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -3361,140 +2691,51 @@ "node": ">=8" } }, - "node_modules/istanbul-lib-hook": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", - "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", "dev": true, "license": "BSD-3-Clause", "dependencies": { - "append-transform": "^2.0.0" + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" } }, - "node_modules/istanbul-lib-instrument": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", - "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "node_modules/istanbul-lib-report/node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, - "license": "BSD-3-Clause", + "license": "MIT", "dependencies": { - "@babel/core": "^7.23.9", - "@babel/parser": "^7.23.9", - "@istanbuljs/schema": "^0.1.3", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^7.5.4" + "semver": "^7.5.3" }, "engines": { "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/istanbul-lib-processinfo": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-3.0.1.tgz", - "integrity": "sha512-s3mX05h5wGZeScG6XnOanygPh4SJu5ujMc9YbvpnLGXWy1cRiGbp0NdVcjHxgoZt3WfQppfBsa0y+gWdYJ2pGQ==", + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", "dev": true, - "license": "ISC", + "license": "BSD-3-Clause", "dependencies": { - "archy": "^1.0.0", - "cross-spawn": "^7.0.3", - "istanbul-lib-coverage": "^3.2.0", - "p-map": "^3.0.0", - "rimraf": "^6.1.3" + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" }, "engines": { - "node": "20 || >=22" + "node": ">=8" } }, - "node_modules/istanbul-lib-processinfo/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^4.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-report/node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/istanbul-lib-source-maps": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", - "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^3.0.0", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-reports": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", - "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true, - "license": "MIT" - }, "node_modules/js-yaml": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", @@ -3528,19 +2769,6 @@ "node": ">=0.1.90" } }, - "node_modules/jsesc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", - "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", - "dev": true, - "license": "MIT", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -3561,32 +2789,12 @@ "dev": true, "license": "MIT" }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/jsonc-parser": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", "license": "MIT" }, - "node_modules/just-extend": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", - "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", - "dev": true, - "license": "MIT" - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -3634,21 +2842,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", - "deprecated": "This package is deprecated. Use the optional chaining (?.) operator instead.", - "dev": true, - "license": "MIT" - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3666,42 +2859,6 @@ "get-func-name": "^2.0.1" } }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -3732,128 +2889,6 @@ "node": ">=16 || 14 >=14.17" } }, - "node_modules/mocha": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-12.0.0.tgz", - "integrity": "sha512-NYNh5IFt6WYqm9bi4601m7vix8MZdXC0DwS4gY6WhXO2RgJWhivhISVmq1oklCif18OSI9l+vx5Mdm5oh1XGiQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "browser-stdout": "^1.3.1", - "chokidar": "^5.0.0", - "debug": "^4.3.5", - "diff": "^9.0.0", - "find-up": "^5.0.0", - "glob": "^13.0.0", - "is-path-inside": "^3.0.3", - "is-unicode-supported": "^0.1.0", - "js-yaml": "^5.0.0", - "minimatch": "^10.2.2", - "ms": "^2.1.3", - "picocolors": "^1.1.1", - "serialize-javascript": "^7.0.2", - "strip-json-comments": "^5.0.3", - "supports-color": "^8.1.1", - "workerpool": "^10.0.0" - }, - "bin": { - "mocha": "bin/mocha.js" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/mocha/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/mocha/node_modules/brace-expansion": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", - "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/mocha/node_modules/js-yaml": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.1.tgz", - "integrity": "sha512-28R/k+NAjeuf7+CKlTxWZVExJGwVVLwY06DgEnOMz2gEpfNkDcD7QvyiVPT0xy0XXhU8vHsd4Ot42OOPdJG7dQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/nodeca" - } - ], - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.mjs" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.8" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/mocha/node_modules/strip-json-comments": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", - "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -3884,271 +2919,6 @@ "dev": true, "license": "MIT" }, - "node_modules/nise": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/nise/-/nise-4.1.0.tgz", - "integrity": "sha512-eQMEmGN/8arp0xsvGoQ+B1qvSkR73B1nWSCh7nOt5neMCtwcQVYQGdzQMhcNscktTsWB54xnlSQFzOAPJD8nXA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^1.7.0", - "@sinonjs/fake-timers": "^6.0.0", - "@sinonjs/text-encoding": "^0.7.1", - "just-extend": "^4.0.2", - "path-to-regexp": "^1.7.0" - } - }, - "node_modules/node-preload": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", - "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "process-on-spawn": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/node-releases": { - "version": "2.0.54", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", - "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/nyc": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/nyc/-/nyc-18.0.0.tgz", - "integrity": "sha512-G5UyHinFkB1BxqGTrmZdB6uIYH0+v7ZnVssuflUDi+J+RhKWyAhRT1RCehBSI6jLFLuUUgFDyLt49mUtdO1XeQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "@istanbuljs/load-nyc-config": "^1.0.0", - "@istanbuljs/schema": "^0.1.2", - "caching-transform": "^4.0.0", - "convert-source-map": "^1.7.0", - "decamelize": "^1.2.0", - "find-cache-dir": "^3.2.0", - "find-up": "^4.1.0", - "foreground-child": "^3.3.0", - "get-package-type": "^0.1.0", - "glob": "^13.0.6", - "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-hook": "^3.0.0", - "istanbul-lib-instrument": "^6.0.2", - "istanbul-lib-processinfo": "^3.0.0", - "istanbul-lib-report": "^3.0.0", - "istanbul-lib-source-maps": "^4.0.0", - "istanbul-reports": "^3.0.2", - "make-dir": "^3.0.0", - "node-preload": "^0.2.1", - "p-map": "^3.0.0", - "process-on-spawn": "^1.0.0", - "resolve-from": "^5.0.0", - "rimraf": "^6.1.3", - "signal-exit": "^3.0.2", - "spawn-wrap": "^3.0.0", - "test-exclude": "^8.0.0", - "yargs": "^15.0.2" - }, - "bin": { - "nyc": "bin/nyc.js" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/nyc/node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/nyc/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/nyc/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/nyc/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/nyc/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/nyc/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/nyc/node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -4209,52 +2979,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-map": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", - "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "aggregate-error": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/package-hash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", - "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "graceful-fs": "^4.1.15", - "hasha": "^5.0.0", - "lodash.flattendeep": "^4.4.0", - "release-zalgo": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -4325,23 +3049,6 @@ "node": "20 || >=22" } }, - "node_modules/path-to-regexp": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.9.0.tgz", - "integrity": "sha512-xIp7/apCFJuUHdDLWe8O1HIkb0kQrOMb/0u6FXQjemHn/ii5LrIzU6bdECnsiTF/GjZkMEKg1xdiZwNqDYlZ6g==", - "dev": true, - "license": "MIT", - "dependencies": { - "isarray": "0.0.1" - } - }, - "node_modules/path-to-regexp/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true, - "license": "MIT" - }, "node_modules/pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -4349,95 +3056,19 @@ "dev": true, "license": "MIT", "engines": { - "node": "*" - } - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, - "license": "ISC" - }, - "node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": "*" } }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/prelude-ls": { @@ -4478,19 +3109,6 @@ "node": ">=6.0.0" } }, - "node_modules/process-on-spawn": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.1.0.tgz", - "integrity": "sha512-JOnOPQ/8TZgjs1JIH/m9ni7FfimjNa/PRx7y/Wb5qdItsnhO0jE4AT7fC0HjC28DUQWDr50dwSYZLdRMlqDq3Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "fromentries": "^1.2.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4522,49 +3140,12 @@ ], "license": "MIT" }, - "node_modules/readdirp": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.1.1.tgz", - "integrity": "sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 20.19.0" - }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/release-zalgo": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", - "dev": true, - "license": "ISC", - "dependencies": { - "es6-error": "^4.0.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/request-light": { "version": "0.5.8", "resolved": "https://registry.npmjs.org/request-light/-/request-light-0.5.8.tgz", "integrity": "sha512-3Zjgh+8b5fhRJBQZoy+zbVKpAQGLyka0MPgW3zruTF4dFFJ8Fqcfu9YsAvi/rvdcaTeWG3MkbZv4WKxAn/84Lg==", "license": "MIT" }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -4574,13 +3155,6 @@ "node": ">=0.10.0" } }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true, - "license": "ISC" - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -4688,23 +3262,6 @@ "node": ">=10" } }, - "node_modules/serialize-javascript": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.1.1.tgz", - "integrity": "sha512-k3CMsaIvvdSwm8oLB4MXSl0wH2/cwlH7xGcnRd2DaeRmBkbzYmyT8j0tsX60DwD1eRwHTpNpH8ljKu9oUT1MeQ==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", - "dev": true, - "license": "ISC" - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4742,19 +3299,16 @@ } }, "node_modules/sinon": { - "version": "9.2.4", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", - "integrity": "sha512-zljcULZQsJxVra28qIAL6ow1Z9tpattkCTEJR4RBP3TGc00FcttsP5pK284Nas5WjMZU5Yzy3kAIp3B3KRf5Yg==", - "deprecated": "16.1.1", + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-22.1.0.tgz", + "integrity": "sha512-n1ajF2rBWMTtEwbKcw4UdFg4nCnDdq/U6RDoxtOd7oapOlRoJ5ynwFx60owROyhDpA9QhMZi0pCO/xtmwFjG7w==", "dev": true, "license": "BSD-3-Clause", "dependencies": { - "@sinonjs/commons": "^1.8.1", - "@sinonjs/fake-timers": "^6.0.1", - "@sinonjs/samsam": "^5.3.1", - "diff": "^4.0.2", - "nise": "^4.0.4", - "supports-color": "^7.1.0" + "@sinonjs/commons": "^3.0.1", + "@sinonjs/fake-timers": "^15.4.0", + "@sinonjs/samsam": "^10.0.2", + "diff": "^9.0.0" }, "funding": { "type": "opencollective", @@ -4772,112 +3326,60 @@ "sinon": ">=4.0.0" } }, - "node_modules/sinon/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "node_modules/stable-hash-x": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/stable-hash-x/-/stable-hash-x-0.2.0.tgz", + "integrity": "sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==", "dev": true, - "license": "BSD-3-Clause", + "license": "MIT", "engines": { - "node": ">=0.10.0" + "node": ">=12.0.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "node_modules/string-width": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", "dev": true, "license": "MIT", "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/spawn-wrap": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-3.0.0.tgz", - "integrity": "sha512-z+s5vv4KzFPJVddGab0xX2n7kQPGMdNUX5l9T8EJqsXdKTWpcxmAqWHpsgHEXoC1taGBCc7b79bi62M5kdbrxQ==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "cross-spawn": "^7.0.6", - "foreground-child": "^2.0.0", - "is-windows": "^1.0.2", - "make-dir": "^3.0.0", - "rimraf": "^6.1.3", - "signal-exit": "^3.0.2", - "which": "^2.0.1" + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" }, "engines": { - "node": ">=8" - } - }, - "node_modules/spawn-wrap/node_modules/foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", - "dev": true, - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" + "node": ">=20" }, - "engines": { - "node": ">=8.0.0" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/spawn-wrap/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", + "node_modules/string-width/node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, + "license": "MIT", "engines": { - "node": "20 || >=22" + "node": ">=12" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/spawn-wrap/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true, - "license": "BSD-3-Clause" - }, - "node_modules/stable-hash-x": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/stable-hash-x/-/stable-hash-x-0.2.0.tgz", - "integrity": "sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==", + "node_modules/string-width/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, "engines": { - "node": ">=12.0.0" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/strip-ansi": { @@ -4893,16 +3395,6 @@ "node": ">=8" } }, - "node_modules/strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -5152,16 +3644,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-typedarray": "^1.0.0" - } - }, "node_modules/typescript": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", @@ -5245,37 +3727,6 @@ "@unrs/resolver-binding-win32-x64-msvc": "1.12.2" } }, - "node_modules/update-browserslist-db": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", - "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -5300,6 +3751,28 @@ "dev": true, "license": "MIT" }, + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "license": "ISC", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/vscode-jsonrpc": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", @@ -5365,13 +3838,6 @@ "node": ">= 8" } }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", - "dev": true, - "license": "ISC" - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -5382,47 +3848,101 @@ "node": ">=0.10.0" } }, - "node_modules/workerpool": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-10.0.3.tgz", - "integrity": "sha512-6z2Iis68Wqth93/G/wJP9u+R3O+d2XTlgWChGCwuT1qLbBsOYueGRZuJ++v3mtDP5KjYdy+WzvWC+VWETSVXJA==", + "node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", "dev": true, - "license": "Apache-2.0" + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", "dev": true, - "license": "ISC" + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } }, - "node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", "dev": true, - "license": "ISC", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/write-file-atomic/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, - "license": "ISC" + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, "license": "ISC" }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, "node_modules/yaml": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", @@ -5438,6 +3958,44 @@ "url": "https://github.com/sponsors/eemeli" } }, + "node_modules/yargs": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", + "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^8.2.1", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", diff --git a/package.json b/package.json index abba50994..02178242e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "name": "Google LLC" } ], + "type": "module", "bin": { "yaml-language-server": "bin/yaml-language-server" }, @@ -26,6 +27,9 @@ "type": "git", "url": "git+https://github.com/redhat-developer/yaml-language-server.git" }, + "engines": { + "node": ">=22.13.0" + }, "dependencies": { "@vscode/l10n": "^0.0.18", "ajv": "^8.17.1", @@ -44,56 +48,42 @@ "devDependencies": { "@microsoft/eslint-formatter-sarif": "^3.0.0", "@types/chai": "^4.2.12", - "@types/mocha": "8.2.2", "@types/node": "22.x", "@types/picomatch": "^4.0.3", - "@types/sinon": "^9.0.5", + "@types/sinon": "^22.0.0", "@types/sinon-chai": "^3.2.5", "@typescript-eslint/parser": "^8.59.4", + "c8": "^12.0.0", "chai": "^4.2.0", "eslint": "^10.0.0", "eslint-plugin-import-x": "^4.0.0", "eslint-plugin-prettier": "^5.0.0", - "mocha": "12.0.0", - "nyc": "^18.0.0", "rimraf": "^3.0.2", - "sinon": "^9.0.3", + "sinon": "^22.1.0", "sinon-chai": "^3.5.0", - "source-map-support": "^0.5.19", "ts-node": "^10.0.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" }, "scripts": { - "clean": "rimraf out/server && rimraf lib", + "clean": "rimraf out/server", "compile": "tsc -p .", "watch": "tsc --watch -p .", - "test": "mocha --require ts-node/register --timeout 10000 --ui bdd ./test/*.test.ts", - "coverage": "nyc mocha --require ts-node/register --timeout 10000 --require source-map-support/register --recursive --ui bdd ./test/*.test.ts", - "coveralls": "nyc --reporter=lcov --reporter=text mocha --timeout 10000 --require ts-node/register --require source-map-support/register --recursive --ui bdd ./test/*.test.ts", + "test": "node --enable-source-maps --experimental-loader=ts-node/esm --test test/*.test.ts", + "coveralls": "c8 --reporter=lcov --reporter=text npm test", "lint": "eslint --max-warnings 0", "lint-ci": "eslint --max-warnings 0 -f @microsoft/eslint-formatter-sarif -o eslint-result.sarif", "prettier-fix": "npm run prettier --write .", - "build": "npm run clean && npm run lint && npm run compile && npm run build:libs", - "build:libs": "npm run compile:umd && npm run compile:esm", - "compile:umd": "tsc -p ./tsconfig.umd.json", - "compile:esm": "tsc -p ./tsconfig.esm.json", + "build": "npm run clean && npm run lint && npm run compile", "check-dependencies": "node ./scripts/check-dependencies.js", "pull-remote": "git pull https://github.com/redhat-developer/yaml-language-server.git main" }, - "nyc": { - "extension": [ - ".ts", - ".tsx" + "c8": { + "include": [ + "src/**/*.ts" ], "exclude": [ - "**/*.d.ts", - "test/", - "out", - "lib", - "coverage/", - ".eslintrc.js", - "scripts" + "**/*.d.ts" ], "all": true } diff --git a/scripts/check-dependencies.js b/scripts/check-dependencies.js index 1381a06a9..5be1d8c19 100644 --- a/scripts/check-dependencies.js +++ b/scripts/check-dependencies.js @@ -5,17 +5,18 @@ //check package.json do not have dependency with 'next' version -/* eslint-disable no-undef, @typescript-eslint/no-require-imports */ +/* eslint-disable no-undef */ -const exit = require('process').exit; -const dependencies = require('../package.json').dependencies; +import packageConfig from '../package.json' with { type: 'json' }; + +const dependencies = packageConfig.dependencies; for (const dep in dependencies) { if (Object.prototype.hasOwnProperty.call(dependencies, dep)) { const version = dependencies[dep]; if (version === 'next') { console.error(`Dependency ${dep} has "${version}" version, please change it to fixed version`); - exit(1); + process.exit(1); } } } diff --git a/src/index.ts b/src/index.ts index 118af54c2..2c5af298b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,2 @@ -export * from './languageservice/yamlLanguageService'; +export * from './languageservice/yamlLanguageService.js'; export * from 'vscode-languageserver-types'; diff --git a/src/languageserver/handlers/languageHandlers.ts b/src/languageserver/handlers/languageHandlers.ts index 3cf7104d0..c2cef06a7 100644 --- a/src/languageserver/handlers/languageHandlers.ts +++ b/src/languageserver/handlers/languageHandlers.ts @@ -34,11 +34,11 @@ import type { TextEdit, WorkspaceEdit, } from 'vscode-languageserver-types'; -import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes'; -import type { CustomFormatterOptions, LanguageService } from '../../languageservice/yamlLanguageService'; -import type { SettingsState } from '../../yamlSettings'; -import type { ValidationHandler } from './validationHandlers'; -import { ResultLimitReachedNotification } from '../../requestTypes'; +import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes.js'; +import type { CustomFormatterOptions, LanguageService } from '../../languageservice/yamlLanguageService.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { ValidationHandler } from './validationHandlers.js'; +import { ResultLimitReachedNotification } from '../../requestTypes.js'; import * as path from 'path'; import type { TextDocument } from 'vscode-languageserver-textdocument'; diff --git a/src/languageserver/handlers/notificationHandlers.ts b/src/languageserver/handlers/notificationHandlers.ts index 998b10083..1f9abeb00 100644 --- a/src/languageserver/handlers/notificationHandlers.ts +++ b/src/languageserver/handlers/notificationHandlers.ts @@ -3,17 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import type { CustomSchemaProvider } from '../../languageservice/services/yamlSchemaService'; -import type { LanguageService, SchemaConfiguration } from '../../languageservice/yamlLanguageService'; +import type { CustomSchemaProvider } from '../../languageservice/services/yamlSchemaService.js'; +import type { LanguageService, SchemaConfiguration } from '../../languageservice/yamlLanguageService.js'; import { CustomSchemaRequest, DynamicCustomSchemaRequestRegistration, SchemaAssociationNotification, SchemaSelectionRequests, VSCodeContentRequestRegistration, -} from '../../requestTypes'; -import type { SettingsState } from '../../yamlSettings'; -import type { SettingsHandler } from './settingsHandlers'; +} from '../../requestTypes.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { SettingsHandler } from './settingsHandlers.js'; export class NotificationHandlers { private languageService: LanguageService; diff --git a/src/languageserver/handlers/requestHandlers.ts b/src/languageserver/handlers/requestHandlers.ts index 4bacdea03..6d3476c95 100644 --- a/src/languageserver/handlers/requestHandlers.ts +++ b/src/languageserver/handlers/requestHandlers.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import type { SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from '../../languageservice/services/yamlSchemaService'; -import { MODIFICATION_ACTIONS } from '../../languageservice/services/yamlSchemaService'; -import type { LanguageService } from '../../languageservice/yamlLanguageService'; -import { SchemaModificationNotification } from '../../requestTypes'; +import type { SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from '../../languageservice/services/yamlSchemaService.js'; +import { MODIFICATION_ACTIONS } from '../../languageservice/services/yamlSchemaService.js'; +import type { LanguageService } from '../../languageservice/yamlLanguageService.js'; +import { SchemaModificationNotification } from '../../requestTypes.js'; export class RequestHandlers { private languageService: LanguageService; diff --git a/src/languageserver/handlers/schemaSelectionHandlers.ts b/src/languageserver/handlers/schemaSelectionHandlers.ts index d041c0e76..d721de11e 100644 --- a/src/languageserver/handlers/schemaSelectionHandlers.ts +++ b/src/languageserver/handlers/schemaSelectionHandlers.ts @@ -3,13 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Connection } from 'vscode-languageserver/node'; -import type { JSONSchema } from '../../languageservice/jsonSchema'; -import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents'; -import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService'; -import type { SettingsState } from '../../yamlSettings'; -import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes'; -import { SchemaSelectionRequests } from '../../requestTypes'; +import type { Connection } from 'vscode-languageserver/node.js'; +import type { JSONSchema } from '../../languageservice/jsonSchema.js'; +import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents.js'; +import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes.js'; +import { SchemaSelectionRequests } from '../../requestTypes.js'; export class JSONSchemaSelection { constructor( diff --git a/src/languageserver/handlers/settingsHandlers.ts b/src/languageserver/handlers/settingsHandlers.ts index 2d30a84cf..60f6b2570 100644 --- a/src/languageserver/handlers/settingsHandlers.ts +++ b/src/languageserver/handlers/settingsHandlers.ts @@ -3,19 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as path from 'path'; -import { configure as configureHttpRequests, xhr } from 'request-light'; +import requestLight from 'request-light'; import type { Connection } from 'vscode-languageserver'; import { DidChangeConfigurationNotification, DocumentFormattingRequest } from 'vscode-languageserver'; import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol'; -import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths'; -import { checkSchemaURI, EMPTY_SCHEMA_URL, isKubernetes, JSON_SCHEMASTORE_URL } from '../../languageservice/utils/schemaUrls'; -import { equals } from '../../languageservice/utils/objects'; -import type { LanguageService, LanguageSettings, SchemasSettings } from '../../languageservice/yamlLanguageService'; -import { SchemaPriority } from '../../languageservice/yamlLanguageService'; -import { SchemaSelectionRequests } from '../../requestTypes'; -import type { Settings, SettingsState } from '../../yamlSettings'; -import type { Telemetry } from '../../languageservice/telemetry'; -import type { ValidationHandler } from './validationHandlers'; +import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths.js'; +import { checkSchemaURI, EMPTY_SCHEMA_URL, isKubernetes, JSON_SCHEMASTORE_URL } from '../../languageservice/utils/schemaUrls.js'; +import { equals } from '../../languageservice/utils/objects.js'; +import type { LanguageService, LanguageSettings, SchemasSettings } from '../../languageservice/yamlLanguageService.js'; +import { SchemaPriority } from '../../languageservice/yamlLanguageService.js'; +import { SchemaSelectionRequests } from '../../requestTypes.js'; +import type { Settings, SettingsState } from '../../yamlSettings.js'; +import type { Telemetry } from '../../languageservice/telemetry.js'; +import type { ValidationHandler } from './validationHandlers.js'; export class SettingsHandler { private schemaSettings: SchemasSettings[] | undefined; @@ -69,7 +69,7 @@ export class SettingsHandler { } private async setConfiguration(settings: Settings): Promise { - configureHttpRequests(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL); + requestLight.configure(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL); this.yamlSettings.specificValidatorPaths = []; if (settings.yaml) { @@ -242,7 +242,7 @@ export class SettingsHandler { */ // eslint-disable-next-line @typescript-eslint/no-explicit-any private async getSchemaStoreMatchingSchemas(schemaStoreUrl: string): Promise<{ schemas: any[] }> { - const response = await xhr({ url: schemaStoreUrl }); + const response = await requestLight.xhr({ url: schemaStoreUrl }); const languageSettings = { schemas: [], diff --git a/src/languageserver/handlers/validationHandlers.ts b/src/languageserver/handlers/validationHandlers.ts index 644901ab4..b7a37b9dc 100644 --- a/src/languageserver/handlers/validationHandlers.ts +++ b/src/languageserver/handlers/validationHandlers.ts @@ -5,10 +5,10 @@ import type { Connection } from 'vscode-languageserver'; import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Diagnostic } from 'vscode-languageserver-types'; -import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes'; -import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils'; -import type { LanguageService } from '../../languageservice/yamlLanguageService'; -import type { SettingsState } from '../../yamlSettings'; +import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes.js'; +import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils.js'; +import type { LanguageService } from '../../languageservice/yamlLanguageService.js'; +import type { SettingsState } from '../../yamlSettings.js'; export class ValidationHandler { private languageService: LanguageService; diff --git a/src/languageserver/handlers/workspaceHandlers.ts b/src/languageserver/handlers/workspaceHandlers.ts index abb95e8f1..f419ca435 100644 --- a/src/languageserver/handlers/workspaceHandlers.ts +++ b/src/languageserver/handlers/workspaceHandlers.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import type { ExecuteCommandParams, Connection } from 'vscode-languageserver'; -import type { CommandExecutor } from '../commandExecutor'; +import type { CommandExecutor } from '../commandExecutor.js'; export class WorkspaceHandlers { constructor( diff --git a/src/languageserver/telemetry.ts b/src/languageserver/telemetry.ts index a28e88143..afcc7a745 100644 --- a/src/languageserver/telemetry.ts +++ b/src/languageserver/telemetry.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import type { TelemetryEvent, Telemetry } from '../languageservice/telemetry'; -import { convertErrorToTelemetryMsg } from '../languageservice/utils/objects'; +import type { TelemetryEvent, Telemetry } from '../languageservice/telemetry.js'; +import { convertErrorToTelemetryMsg } from '../languageservice/utils/objects.js'; export class TelemetryImpl implements Telemetry { constructor(private readonly connection: Connection) {} diff --git a/src/languageservice/jsonLanguageTypes.ts b/src/languageservice/jsonLanguageTypes.ts index 91c3a3999..516f9a126 100644 --- a/src/languageservice/jsonLanguageTypes.ts +++ b/src/languageservice/jsonLanguageTypes.ts @@ -6,90 +6,12 @@ // Forked from vscode-json-languageservice@6.0.0-next.1 // Source: https://github.com/microsoft/vscode-json-languageservice/blob/810471bbb462bb6b87351c2232e209a3bb4062ca/src/jsonLanguageTypes.ts -import { JSONSchema } from './jsonSchema'; +import type { JSONSchema } from './jsonSchema.js'; import type { FormattingOptions as LSPFormattingOptions } from 'vscode-languageserver-types'; -import { - Range, - Position, - DocumentUri, - MarkupContent, - MarkupKind, - Color, - ColorInformation, - ColorPresentation, - FoldingRange, - FoldingRangeKind, - SelectionRange, - Diagnostic, - DiagnosticSeverity, - CompletionItem, - CompletionItemKind, - CompletionList, - CompletionItemTag, - InsertTextFormat, - SymbolInformation, - SymbolKind, - DocumentSymbol, - Location, - Hover, - MarkedString, - DefinitionLink, - CodeActionContext, - Command, - CodeAction, - DocumentHighlight, - DocumentLink, - WorkspaceEdit, - TextEdit, - CodeActionKind, - TextDocumentEdit, - VersionedTextDocumentIdentifier, - DocumentHighlightKind, -} from 'vscode-languageserver-types'; -import { TextDocument, TextDocumentContentChangeEvent } from 'vscode-languageserver-textdocument'; +import { MarkupKind } from 'vscode-languageserver-types'; import type { Node, Pair } from 'yaml'; -import type { CustomTagReturnType } from './utils/customTags'; -export { - TextDocument, - TextDocumentContentChangeEvent, - Range, - Position, - DocumentUri, - MarkupContent, - MarkupKind, - JSONSchema, - Color, - ColorInformation, - ColorPresentation, - FoldingRange, - FoldingRangeKind, - SelectionRange, - Diagnostic, - DiagnosticSeverity, - CompletionItem, - CompletionItemKind, - CompletionList, - CompletionItemTag, - InsertTextFormat, - DefinitionLink, - SymbolInformation, - SymbolKind, - DocumentSymbol, - Location, - Hover, - MarkedString, - CodeActionContext, - Command, - CodeAction, - DocumentHighlight, - DocumentLink, - WorkspaceEdit, - TextEdit, - CodeActionKind, - TextDocumentEdit, - VersionedTextDocumentIdentifier, - DocumentHighlightKind, -}; +import type { CustomTagReturnType } from './utils/customTags.js'; + /** * Error codes used by diagnostics */ diff --git a/src/languageservice/jsonSchema.ts b/src/languageservice/jsonSchema.ts index dce0dc0f3..b99d77f2e 100644 --- a/src/languageservice/jsonSchema.ts +++ b/src/languageservice/jsonSchema.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { CompletionItemKind, SchemaDraft } from './jsonLanguageTypes'; -import type { SchemaVersions } from './yamlTypes'; +import type { CompletionItemKind } from 'vscode-languageserver-types'; +import type { SchemaDraft } from './jsonLanguageTypes.js'; +import type { SchemaVersions } from './yamlTypes.js'; export type JSONSchemaRef = JSONSchema | boolean; diff --git a/src/languageservice/parser/ast-converter.ts b/src/languageservice/parser/ast-converter.ts index 7c9dfa561..98d5d0ca0 100644 --- a/src/languageservice/parser/ast-converter.ts +++ b/src/languageservice/parser/ast-converter.ts @@ -5,8 +5,8 @@ import type { Node, Scalar, YAMLMap, Pair, YAMLSeq, Alias, Document, LineCounter } from 'yaml'; import { isScalar, isMap, isPair, isSeq, isNode, isAlias } from 'yaml'; -import type { ASTNode, YamlNode } from '../jsonLanguageTypes'; -import { getCustomTagReturnType } from '../utils/customTags'; +import type { ASTNode, YamlNode } from '../jsonLanguageTypes.js'; +import { getCustomTagReturnType } from '../utils/customTags.js'; import { NullASTNodeImpl, PropertyASTNodeImpl, @@ -15,7 +15,7 @@ import { NumberASTNodeImpl, ArrayASTNodeImpl, BooleanASTNodeImpl, -} from './jsonDocument'; +} from './jsonDocument.js'; type NodeRange = [number, number, number]; diff --git a/src/languageservice/parser/custom-tag-provider.ts b/src/languageservice/parser/custom-tag-provider.ts index 275e3d6f0..d47951e29 100644 --- a/src/languageservice/parser/custom-tag-provider.ts +++ b/src/languageservice/parser/custom-tag-provider.ts @@ -1,7 +1,7 @@ import type { Tags, YAMLMap, YAMLSeq } from 'yaml'; import { isSeq, isMap, Scalar } from 'yaml'; -import type { CustomTagInputType, CustomTagReturnType } from '../utils/customTags'; -import { parseCustomTag, setCustomTagReturnType } from '../utils/customTags'; +import type { CustomTagInputType, CustomTagReturnType } from '../utils/customTags.js'; +import { parseCustomTag, setCustomTagReturnType } from '../utils/customTags.js'; class CommonTagImpl { tag: string; diff --git a/src/languageservice/parser/isKubernetes.ts b/src/languageservice/parser/isKubernetes.ts index ebd9de8b5..e98fd6ddd 100644 --- a/src/languageservice/parser/isKubernetes.ts +++ b/src/languageservice/parser/isKubernetes.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { FilePatternAssociation } from '../utils/filePatternAssociation'; -import type * as Parser from './jsonDocument'; +import { FilePatternAssociation } from '../utils/filePatternAssociation.js'; +import type * as Parser from './jsonDocument.js'; export function setKubernetesParserOption(jsonDocuments: Parser.JSONDocument[], option: boolean): void { for (const jsonDoc of jsonDocuments) { diff --git a/src/languageservice/parser/jsonDocument.ts b/src/languageservice/parser/jsonDocument.ts index bb566f6ce..3598ac8e9 100644 --- a/src/languageservice/parser/jsonDocument.ts +++ b/src/languageservice/parser/jsonDocument.ts @@ -3,7 +3,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema } from '../jsonSchema'; +import type { JSONSchema } from '../jsonSchema.js'; import type { ASTNode, ObjectASTNode, @@ -14,14 +14,14 @@ import type { NullASTNode, PropertyASTNode, YamlNode, -} from '../jsonLanguageTypes'; -import type { CustomTagReturnType } from '../utils/customTags'; +} from '../jsonLanguageTypes.js'; +import type { CustomTagReturnType } from '../utils/customTags.js'; import type { Diagnostic, Range } from 'vscode-languageserver-types'; import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Node, Pair } from 'yaml'; -import type { IApplicableSchema } from './schemaValidation/baseValidator'; -import { findNodeAtOffset } from '../utils/astNodeUtils'; -import { getValidator } from './schemaValidation/validatorFactory'; +import type { IApplicableSchema } from './schemaValidation/baseValidator.js'; +import { findNodeAtOffset } from '../utils/astNodeUtils.js'; +import { getValidator } from './schemaValidation/validatorFactory.js'; abstract class ASTNodeImpl { public abstract readonly type: 'object' | 'property' | 'array' | 'number' | 'boolean' | 'null' | 'string'; @@ -232,6 +232,7 @@ export class JSONDocument { isKubernetes: this.isKubernetes, disableAdditionalProperties: this.disableAdditionalProperties, uri: this.uri, + createValidator: getValidator, }); } @@ -252,6 +253,7 @@ export class JSONDocument { disableAdditionalProperties: this.disableAdditionalProperties, uri: this.uri, callFromAutoComplete: didCallFromAutoComplete, + createValidator: getValidator, }, focusOffset, exclude diff --git a/src/languageservice/parser/schemaValidation/baseValidator.ts b/src/languageservice/parser/schemaValidation/baseValidator.ts index 6ec00e997..2a3920a6e 100644 --- a/src/languageservice/parser/schemaValidation/baseValidator.ts +++ b/src/languageservice/parser/schemaValidation/baseValidator.ts @@ -4,7 +4,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema'; +import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema.js'; import type { ASTNode, ArrayASTNode, @@ -13,20 +13,19 @@ import type { PropertyASTNode, StringASTNode, SchemaDraft, -} from '../../jsonLanguageTypes'; -import { equals, isBoolean, isDefined, isIterable, isNumber, isString } from '../../utils/objects'; -import { getSchemaTypeName } from '../../utils/schemaUtils'; -import { isArrayEqual } from '../../utils/arrUtils'; -import { safeCreateUnicodeRegExp } from '../../utils/strings'; -import { FilePatternAssociation } from '../../utils/filePatternAssociation'; -import { floatSafeRemainder } from '../../utils/math'; -import { ErrorCode } from '../../jsonLanguageTypes'; +} from '../../jsonLanguageTypes.js'; +import { equals, isBoolean, isDefined, isIterable, isNumber, isString } from '../../utils/objects.js'; +import { getSchemaTypeName } from '../../utils/schemaUtils.js'; +import { isArrayEqual } from '../../utils/arrUtils.js'; +import { safeCreateUnicodeRegExp } from '../../utils/strings.js'; +import { FilePatternAssociation } from '../../utils/filePatternAssociation.js'; +import { floatSafeRemainder } from '../../utils/math.js'; +import { ErrorCode } from '../../jsonLanguageTypes.js'; import * as l10n from '@vscode/l10n'; import { URI } from 'vscode-uri'; import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { contains, getNodeValue } from '../../utils/astNodeUtils'; -import { getValidator } from './validatorFactory'; +import { contains, getNodeValue } from '../../utils/astNodeUtils.js'; export const YAML_SOURCE = 'YAML'; const YAML_SCHEMA_PREFIX = 'yaml-schema: '; @@ -314,6 +313,7 @@ export interface Options { disableAdditionalProperties: boolean; uri: string; callFromAutoComplete?: boolean; + createValidator: (schemaDraft: SchemaDraft) => BaseValidator; } interface IValidationMatch { @@ -465,7 +465,7 @@ export abstract class BaseValidator { const subSchemaDraft = schema._schemaDraft; const currentSchemaDraft = this.getCurrentSchemaDraft(); if (subSchemaDraft !== currentSchemaDraft) { - const subValidator = getValidator(subSchemaDraft); + const subValidator = options.createValidator(subSchemaDraft); subValidator.validateNode(node, schema, originalSchema, validationResult, matchingSchemas, options); return; } diff --git a/src/languageservice/parser/schemaValidation/draft04Validator.ts b/src/languageservice/parser/schemaValidation/draft04Validator.ts index 2c67bf329..65c4f6a53 100644 --- a/src/languageservice/parser/schemaValidation/draft04Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft04Validator.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema } from '../../jsonSchema'; -import { SchemaDraft } from '../../jsonLanguageTypes'; -import { isBoolean, isNumber } from '../../utils/objects'; -import { BaseValidator } from './baseValidator'; +import type { JSONSchema } from '../../jsonSchema.js'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import { isBoolean, isNumber } from '../../utils/objects.js'; +import { BaseValidator } from './baseValidator.js'; export class Draft04Validator extends BaseValidator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/draft07Validator.ts b/src/languageservice/parser/schemaValidation/draft07Validator.ts index 73d5b3d2c..954b5fbe5 100644 --- a/src/languageservice/parser/schemaValidation/draft07Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft07Validator.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema } from '../../jsonSchema'; -import { SchemaDraft } from '../../jsonLanguageTypes'; -import { isNumber } from '../../utils/objects'; -import { BaseValidator } from './baseValidator'; +import type { JSONSchema } from '../../jsonSchema.js'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import { isNumber } from '../../utils/objects.js'; +import { BaseValidator } from './baseValidator.js'; export class Draft07Validator extends BaseValidator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/draft2019Validator.ts b/src/languageservice/parser/schemaValidation/draft2019Validator.ts index 14d84ff16..509947dca 100644 --- a/src/languageservice/parser/schemaValidation/draft2019Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft2019Validator.ts @@ -3,15 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema'; -import { ErrorCode, SchemaDraft } from '../../jsonLanguageTypes'; -import type { ASTNode, ArrayASTNode, ObjectASTNode } from '../../jsonLanguageTypes'; -import { isNumber } from '../../utils/objects'; +import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema.js'; +import { ErrorCode, SchemaDraft } from '../../jsonLanguageTypes.js'; +import type { ASTNode, ArrayASTNode, ObjectASTNode } from '../../jsonLanguageTypes.js'; +import { isNumber } from '../../utils/objects.js'; import * as l10n from '@vscode/l10n'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; -import { Draft07Validator } from './draft07Validator'; -import { ValidationResult, asSchema } from './baseValidator'; -import type { ISchemaCollector, Options } from './baseValidator'; +import { Draft07Validator } from './draft07Validator.js'; +import { ValidationResult, asSchema } from './baseValidator.js'; +import type { ISchemaCollector, Options } from './baseValidator.js'; export class Draft2019Validator extends Draft07Validator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/draft2020Validator.ts b/src/languageservice/parser/schemaValidation/draft2020Validator.ts index 36d02fa00..b4af4eec7 100644 --- a/src/languageservice/parser/schemaValidation/draft2020Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft2020Validator.ts @@ -3,15 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema'; -import { SchemaDraft } from '../../jsonLanguageTypes'; -import type { ASTNode, ArrayASTNode } from '../../jsonLanguageTypes'; -import { isNumber } from '../../utils/objects'; +import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema.js'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import type { ASTNode, ArrayASTNode } from '../../jsonLanguageTypes.js'; +import { isNumber } from '../../utils/objects.js'; import * as l10n from '@vscode/l10n'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; -import { Draft2019Validator } from './draft2019Validator'; -import type { ISchemaCollector, Options } from './baseValidator'; -import { ValidationResult, asSchema } from './baseValidator'; +import { Draft2019Validator } from './draft2019Validator.js'; +import type { ISchemaCollector, Options } from './baseValidator.js'; +import { ValidationResult, asSchema } from './baseValidator.js'; export class Draft2020Validator extends Draft2019Validator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/validatorFactory.ts b/src/languageservice/parser/schemaValidation/validatorFactory.ts index e59c1ddc8..69fd3fc0f 100644 --- a/src/languageservice/parser/schemaValidation/validatorFactory.ts +++ b/src/languageservice/parser/schemaValidation/validatorFactory.ts @@ -3,12 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { SchemaDraft } from '../../jsonLanguageTypes'; -import type { BaseValidator } from './baseValidator'; -import { Draft04Validator } from './draft04Validator'; -import { Draft07Validator } from './draft07Validator'; -import { Draft2019Validator } from './draft2019Validator'; -import { Draft2020Validator } from './draft2020Validator'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import type { BaseValidator } from './baseValidator.js'; +import { Draft04Validator } from './draft04Validator.js'; +import { Draft07Validator } from './draft07Validator.js'; +import { Draft2019Validator } from './draft2019Validator.js'; +import { Draft2020Validator } from './draft2020Validator.js'; export function getValidator(schemaDraft: SchemaDraft): BaseValidator { switch (schemaDraft) { diff --git a/src/languageservice/parser/yaml-documents.ts b/src/languageservice/parser/yaml-documents.ts index f6c108eb5..95b8c63b0 100644 --- a/src/languageservice/parser/yaml-documents.ts +++ b/src/languageservice/parser/yaml-documents.ts @@ -4,19 +4,19 @@ *--------------------------------------------------------------------------------------------*/ import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { JSONDocument } from './jsonDocument'; +import { JSONDocument } from './jsonDocument.js'; import type { CST, Document, LineCounter, Node, YAMLError } from 'yaml'; import { isNode, isPair, isScalar, visit } from 'yaml'; -import type { ASTNode, YamlNode } from '../jsonLanguageTypes'; -import type { ParserOptions } from './yamlParser07'; -import { defaultOptions, parse as parseYAML } from './yamlParser07'; -import { ErrorCode } from '../jsonLanguageTypes'; -import { convertAST } from './ast-converter'; -import type { YAMLDocDiagnostic } from '../utils/parseUtils'; -import { isArrayEqual } from '../utils/arrUtils'; -import { getParent } from '../utils/yamlAstUtils'; -import type { TextBuffer } from '../utils/textBuffer'; -import { getIndentation } from '../utils/strings'; +import type { ASTNode, YamlNode } from '../jsonLanguageTypes.js'; +import type { ParserOptions } from './yamlParser07.js'; +import { defaultOptions, parse as parseYAML } from './yamlParser07.js'; +import { ErrorCode } from '../jsonLanguageTypes.js'; +import { convertAST } from './ast-converter.js'; +import type { YAMLDocDiagnostic } from '../utils/parseUtils.js'; +import { isArrayEqual } from '../utils/arrUtils.js'; +import { getParent } from '../utils/yamlAstUtils.js'; +import type { TextBuffer } from '../utils/textBuffer.js'; +import { getIndentation } from '../utils/strings.js'; /** * These documents are collected into a final YAMLDocument @@ -272,6 +272,8 @@ export class YamlDocuments { // a mapping of URIs to cached documents private cache = new Map(); + constructor(private readonly parse: typeof parseYAML = parseYAML) {} + /** * Get cached YAMLDocument * @param document TextDocument to parse @@ -306,7 +308,7 @@ export class YamlDocuments { if (addRootObject && !/\S/.test(text)) { text = `{${text}}`; } - const doc = parseYAML(text, parserOptions, document); + const doc = this.parse(text, parserOptions, document); cacheEntry.document = doc; cacheEntry.version = document.version; cacheEntry.parserOptions = parserOptions; diff --git a/src/languageservice/parser/yamlParser07.ts b/src/languageservice/parser/yamlParser07.ts index aeea9214e..9195b3b91 100644 --- a/src/languageservice/parser/yamlParser07.ts +++ b/src/languageservice/parser/yamlParser07.ts @@ -6,10 +6,10 @@ import type { CST, Document, ParseOptions, DocumentOptions, SchemaOptions } from 'yaml'; import { Parser, Composer, LineCounter } from 'yaml'; -import { YAMLDocument, SingleYAMLDocument } from './yaml-documents'; -import { getCustomTags } from './custom-tag-provider'; +import { YAMLDocument, SingleYAMLDocument } from './yaml-documents.js'; +import { getCustomTags } from './custom-tag-provider.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { TextBuffer } from '../utils/textBuffer'; +import { TextBuffer } from '../utils/textBuffer.js'; export { YAMLDocument, SingleYAMLDocument }; diff --git a/src/languageservice/services/documentSymbols.ts b/src/languageservice/services/documentSymbols.ts index 185d2009d..15d41a627 100644 --- a/src/languageservice/services/documentSymbols.ts +++ b/src/languageservice/services/documentSymbols.ts @@ -6,10 +6,10 @@ import { Location, Range, SymbolKind } from 'vscode-languageserver-types'; import type { DocumentSymbol, SymbolInformation } from 'vscode-languageserver-types'; -import type { DocumentSymbolsContext, ASTNode, PropertyASTNode } from '../jsonLanguageTypes'; +import type { DocumentSymbolsContext, ASTNode, PropertyASTNode } from '../jsonLanguageTypes.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { Telemetry } from '../telemetry'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { Telemetry } from '../telemetry.js'; import { isMap, isSeq } from 'yaml'; export class YAMLDocumentSymbols { diff --git a/src/languageservice/services/dollarUtils.ts b/src/languageservice/services/dollarUtils.ts index 8adff1469..304fa3dbf 100644 --- a/src/languageservice/services/dollarUtils.ts +++ b/src/languageservice/services/dollarUtils.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { SingleYAMLDocument } from '../parser/yamlParser07'; -import { JSONDocument } from '../parser/jsonDocument'; +import { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import { JSONDocument } from '../parser/jsonDocument.js'; /** * Retrieve schema if declared by `$schema`. diff --git a/src/languageservice/services/k8sSchemaUtil.ts b/src/languageservice/services/k8sSchemaUtil.ts index e2c0cb66a..f2e8da0d9 100644 --- a/src/languageservice/services/k8sSchemaUtil.ts +++ b/src/languageservice/services/k8sSchemaUtil.ts @@ -1,8 +1,8 @@ -import type { JSONDocument } from '../parser/jsonDocument'; -import { SingleYAMLDocument } from '../parser/yamlParser07'; +import type { JSONDocument } from '../parser/jsonDocument.js'; +import { SingleYAMLDocument } from '../parser/yamlParser07.js'; -import type { ResolvedSchema } from './yamlSchemaService'; -import type { JSONSchema } from '../jsonSchema'; +import type { ResolvedSchema } from './yamlSchemaService.js'; +import type { JSONSchema } from '../jsonSchema.js'; /** * Attempt to retrieve the schema for a given YAML document based on the Kubernetes GroupVersionKind (GVK). diff --git a/src/languageservice/services/modelineUtil.ts b/src/languageservice/services/modelineUtil.ts index 974929c46..c0530ac1e 100644 --- a/src/languageservice/services/modelineUtil.ts +++ b/src/languageservice/services/modelineUtil.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { SingleYAMLDocument } from '../parser/yamlParser07'; -import type { JSONDocument } from '../parser/jsonDocument'; +import { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { JSONDocument } from '../parser/jsonDocument.js'; /** * Retrieve schema if declared as modeline. diff --git a/src/languageservice/services/schemaRequestHandler.ts b/src/languageservice/services/schemaRequestHandler.ts index 55ef10766..a8ae08052 100644 --- a/src/languageservice/services/schemaRequestHandler.ts +++ b/src/languageservice/services/schemaRequestHandler.ts @@ -1,12 +1,11 @@ import { join } from 'path'; -import { getErrorStatusDescription, xhr } from 'request-light'; -import * as URL from 'url'; +import requestLight from 'request-light'; import type { Connection, WorkspaceFolder } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; -import { CustomSchemaContentRequest, VSCodeContentRequest } from '../../requestTypes'; -import { isRelativePath, relativeToAbsolutePath } from '../utils/paths'; -import type { WorkspaceContextService } from '../yamlLanguageService'; +import { CustomSchemaContentRequest, VSCodeContentRequest } from '../../requestTypes.js'; +import { isRelativePath, relativeToAbsolutePath } from '../utils/paths.js'; +import type { WorkspaceContextService } from '../yamlLanguageService.js'; export interface FileSystem { readFile(fsPath: string, encoding?: string): Promise; @@ -120,7 +119,7 @@ async function requestSchemaWithRetry( for (let attempt = 0; ; attempt++) { try { - const response = await xhr({ url, followRedirects: 5, headers }); + const response = await requestLight.xhr({ url, followRedirects: 5, headers }); return response.responseText; } catch (error) { if (attempt >= maxRetries || !isRetryableError(error)) { @@ -217,7 +216,7 @@ export const schemaRequestHandler = async ( try { return await requestSchemaWithRetry(uri, headers, retryOptions); } catch (error) { - throw error.responseText || getErrorStatusDescription(error.status) || error.toString(); + throw error.responseText || requestLight.getErrorStatusDescription(error.status) || error.toString(); } } @@ -227,6 +226,6 @@ export const schemaRequestHandler = async ( export const workspaceContext: WorkspaceContextService = { resolveRelativePath: (relativePath: string, resource: string) => { - return URL.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; diff --git a/src/languageservice/services/validation/map-key-order.ts b/src/languageservice/services/validation/map-key-order.ts index 71f80630a..34e9b41de 100644 --- a/src/languageservice/services/validation/map-key-order.ts +++ b/src/languageservice/services/validation/map-key-order.ts @@ -7,8 +7,8 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types'; import type { CST, Node, Pair } from 'yaml'; import { isMap, visit } from 'yaml'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; -import type { AdditionalValidator } from './types'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; +import type { AdditionalValidator } from './types.js'; export class MapKeyOrderValidator implements AdditionalValidator { validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[] { diff --git a/src/languageservice/services/validation/types.ts b/src/languageservice/services/validation/types.ts index 9ad2d38ee..37d910cf6 100644 --- a/src/languageservice/services/validation/types.ts +++ b/src/languageservice/services/validation/types.ts @@ -5,7 +5,7 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Diagnostic } from 'vscode-languageserver-types'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; export interface AdditionalValidator { validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[]; diff --git a/src/languageservice/services/validation/unused-anchors.ts b/src/languageservice/services/validation/unused-anchors.ts index da5a91046..1cd6489d8 100644 --- a/src/languageservice/services/validation/unused-anchors.ts +++ b/src/languageservice/services/validation/unused-anchors.ts @@ -7,10 +7,10 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Diagnostic, DiagnosticSeverity, DiagnosticTag, Range } from 'vscode-languageserver-types'; import type { Node, Scalar, YAMLMap, YAMLSeq, Pair } from 'yaml'; import { isAlias, isCollection, isNode, isScalar, visit, CST } from 'yaml'; -import type { YamlNode } from '../../jsonLanguageTypes'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; -import type { AdditionalValidator } from './types'; -import { isCollectionItem } from '../../utils/yamlAstUtils'; +import type { YamlNode } from '../../jsonLanguageTypes.js'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; +import type { AdditionalValidator } from './types.js'; +import { isCollectionItem } from '../../utils/yamlAstUtils.js'; import * as l10n from '@vscode/l10n'; export class UnusedAnchorsValidator implements AdditionalValidator { diff --git a/src/languageservice/services/validation/yaml-style.ts b/src/languageservice/services/validation/yaml-style.ts index 255c72834..605ad0fc6 100644 --- a/src/languageservice/services/validation/yaml-style.ts +++ b/src/languageservice/services/validation/yaml-style.ts @@ -2,9 +2,9 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types'; import type { CST } from 'yaml'; import { isMap, isSeq, visit } from 'yaml'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; -import type { LanguageSettings } from '../../yamlLanguageService'; -import type { AdditionalValidator } from './types'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; +import type { LanguageSettings } from '../../yamlLanguageService.js'; +import type { AdditionalValidator } from './types.js'; import * as l10n from '@vscode/l10n'; export class YAMLStyleValidator implements AdditionalValidator { diff --git a/src/languageservice/services/yamlCodeActions.ts b/src/languageservice/services/yamlCodeActions.ts index 036c706c3..eae7dce5a 100644 --- a/src/languageservice/services/yamlCodeActions.ts +++ b/src/languageservice/services/yamlCodeActions.ts @@ -5,7 +5,7 @@ import * as l10n from '@vscode/l10n'; import * as path from 'path'; -import { ErrorCode } from '../jsonLanguageTypes'; +import { ErrorCode } from '../jsonLanguageTypes.js'; import type { Diagnostic, WorkspaceEdit } from 'vscode-languageserver-types'; import { CodeAction, CodeActionKind, Command, Position, Range, TextEdit } from 'vscode-languageserver-types'; import type { ClientCapabilities, CodeActionParams } from 'vscode-languageserver-protocol'; @@ -14,19 +14,19 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Scalar, YAMLMap } from 'yaml'; import { CST, isMap, isSeq, isScalar, visit } from 'yaml'; -import { YamlCommands } from '../../commands'; -import { TextBuffer } from '../utils/textBuffer'; -import { toYamlStringScalar } from '../utils/yamlScalar'; -import type { LanguageSettings } from '../yamlLanguageService'; -import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator'; -import { getFirstNonWhitespaceCharacterAfterOffset } from '../utils/strings'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; +import { YamlCommands } from '../../commands.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import { toYamlStringScalar } from '../utils/yamlScalar.js'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator.js'; +import { getFirstNonWhitespaceCharacterAfterOffset } from '../utils/strings.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; -import { BlockStringRewriter } from '../utils/block-string-rewriter'; -import { FlowStyleRewriter } from '../utils/flow-style-rewriter'; +import { BlockStringRewriter } from '../utils/block-string-rewriter.js'; +import { FlowStyleRewriter } from '../utils/flow-style-rewriter.js'; -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; interface YamlDiagnosticData { schemaUri: string[]; diff --git a/src/languageservice/services/yamlCodeLens.ts b/src/languageservice/services/yamlCodeLens.ts index 8681b719f..9070e4377 100644 --- a/src/languageservice/services/yamlCodeLens.ts +++ b/src/languageservice/services/yamlCodeLens.ts @@ -5,12 +5,12 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { CodeLens, Range } from 'vscode-languageserver-types'; -import { YamlCommands } from '../../commands'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { YAMLSchemaService } from './yamlSchemaService'; -import type { Telemetry } from '../telemetry'; -import { getSchemaUrls } from '../utils/schemaUrls'; -import { getSchemaTitle } from '../utils/schemaUtils'; +import { YamlCommands } from '../../commands.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { YAMLSchemaService } from './yamlSchemaService.js'; +import type { Telemetry } from '../telemetry.js'; +import { getSchemaUrls } from '../utils/schemaUrls.js'; +import { getSchemaTitle } from '../utils/schemaUtils.js'; export class YamlCodeLens { constructor( diff --git a/src/languageservice/services/yamlCommands.ts b/src/languageservice/services/yamlCommands.ts index efdee7682..fc1ad3848 100644 --- a/src/languageservice/services/yamlCommands.ts +++ b/src/languageservice/services/yamlCommands.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import { YamlCommands } from '../../commands'; -import type { CommandExecutor } from '../../languageserver/commandExecutor'; +import { YamlCommands } from '../../commands.js'; +import type { CommandExecutor } from '../../languageserver/commandExecutor.js'; import { URI } from 'vscode-uri'; export function registerCommands(commandExecutor: CommandExecutor, connection: Connection): void { diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts index b258cbe2d..97963aa34 100644 --- a/src/languageservice/services/yamlCompletion.ts +++ b/src/languageservice/services/yamlCompletion.ts @@ -19,27 +19,27 @@ import { } from 'vscode-languageserver-types'; import type { Node, YAMLMap, YAMLSeq, Pair } from 'yaml'; import { isPair, isScalar, isMap, isSeq, isNode } from 'yaml'; -import { parseCustomTag } from '../utils/customTags'; -import type { Telemetry } from '../telemetry'; -import type { SingleYAMLDocument, YamlDocuments } from '../parser/yaml-documents'; -import type { YamlVersion } from '../parser/yamlParser07'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { guessIndentation } from '../utils/indentationGuesser'; -import { TextBuffer } from '../utils/textBuffer'; -import type { LanguageSettings } from '../yamlLanguageService'; -import type { ResolvedSchema, YAMLSchemaService } from './yamlSchemaService'; -import type { JSONSchema, JSONSchemaRef } from '../jsonSchema'; -import type { StringifySettings } from '../utils/json'; -import { stringifyObject } from '../utils/json'; -import { isDefined, isString } from '../utils/objects'; -import { setKubernetesParserOption } from '../parser/isKubernetes'; -import { asSchema } from '../parser/schemaValidation/baseValidator'; -import { indexOf, isInComment, isMapContainsEmptyPair } from '../utils/yamlAstUtils'; -import { isModeline } from './modelineUtil'; -import { getSchemaTypeName, isAnyOfAllOfOneOfType, isPrimitiveType } from '../utils/schemaUtils'; -import type { YamlNode } from '../jsonLanguageTypes'; -import type { SettingsState } from '../../yamlSettings'; -import { toYamlStringScalar } from '../utils/yamlScalar'; +import { parseCustomTag } from '../utils/customTags.js'; +import type { Telemetry } from '../telemetry.js'; +import type { SingleYAMLDocument, YamlDocuments } from '../parser/yaml-documents.js'; +import type { YamlVersion } from '../parser/yamlParser07.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { guessIndentation } from '../utils/indentationGuesser.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import type { ResolvedSchema, YAMLSchemaService } from './yamlSchemaService.js'; +import type { JSONSchema, JSONSchemaRef } from '../jsonSchema.js'; +import type { StringifySettings } from '../utils/json.js'; +import { stringifyObject } from '../utils/json.js'; +import { isDefined, isString } from '../utils/objects.js'; +import { setKubernetesParserOption } from '../parser/isKubernetes.js'; +import { asSchema } from '../parser/schemaValidation/baseValidator.js'; +import { indexOf, isInComment, isMapContainsEmptyPair } from '../utils/yamlAstUtils.js'; +import { isModeline } from './modelineUtil.js'; +import { getSchemaTypeName, isAnyOfAllOfOneOfType, isPrimitiveType } from '../utils/schemaUtils.js'; +import type { YamlNode } from '../jsonLanguageTypes.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import { toYamlStringScalar } from '../utils/yamlScalar.js'; import * as l10n from '@vscode/l10n'; const parentCompletionKind = CompletionItemKind.Class; diff --git a/src/languageservice/services/yamlDefinition.ts b/src/languageservice/services/yamlDefinition.ts index d7d3bc49f..2b790f097 100644 --- a/src/languageservice/services/yamlDefinition.ts +++ b/src/languageservice/services/yamlDefinition.ts @@ -8,10 +8,10 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { DefinitionLink } from 'vscode-languageserver-types'; import { LocationLink, Range } from 'vscode-languageserver-types'; import { isAlias } from 'yaml'; -import type { Telemetry } from '../telemetry'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { TextBuffer } from '../utils/textBuffer'; +import type { Telemetry } from '../telemetry.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { TextBuffer } from '../utils/textBuffer.js'; export class YamlDefinition { constructor(private readonly telemetry?: Telemetry) {} diff --git a/src/languageservice/services/yamlFolding.ts b/src/languageservice/services/yamlFolding.ts index d9c19c718..d15942aa4 100644 --- a/src/languageservice/services/yamlFolding.ts +++ b/src/languageservice/services/yamlFolding.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { FoldingRange, Range } from 'vscode-languageserver-types'; -import type { FoldingRangesContext } from '../yamlTypes'; -import type { ASTNode } from '../jsonLanguageTypes'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; +import type { FoldingRangesContext } from '../yamlTypes.js'; +import type { ASTNode } from '../jsonLanguageTypes.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; export function getFoldingRanges(document: TextDocument, context: FoldingRangesContext): FoldingRange[] | undefined { diff --git a/src/languageservice/services/yamlFormatter.ts b/src/languageservice/services/yamlFormatter.ts index f980d98f4..b3d00ef94 100644 --- a/src/languageservice/services/yamlFormatter.ts +++ b/src/languageservice/services/yamlFormatter.ts @@ -6,7 +6,7 @@ import type { FormattingOptions } from 'vscode-languageserver-types'; import { Range, Position, TextEdit } from 'vscode-languageserver-types'; -import type { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService'; +import type { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService.js'; import type { Options } from 'prettier'; import * as yamlPlugin from 'prettier/plugins/yaml'; import * as estreePlugin from 'prettier/plugins/estree'; diff --git a/src/languageservice/services/yamlHover.ts b/src/languageservice/services/yamlHover.ts index bf74361e4..d28aa3a94 100644 --- a/src/languageservice/services/yamlHover.ts +++ b/src/languageservice/services/yamlHover.ts @@ -12,18 +12,18 @@ import { MarkupKind, Range } from 'vscode-languageserver-types'; import { URI } from 'vscode-uri'; import type { Node } from 'yaml'; import { isAlias, isMap, isSeq, stringify as stringifyYAML } from 'yaml'; -import type { ASTNode, ObjectASTNode, PropertyASTNode } from '../jsonLanguageTypes'; -import type { JSONSchema } from '../jsonSchema'; -import { setKubernetesParserOption } from '../parser/isKubernetes'; -import { getNodeValue } from '../utils/astNodeUtils'; -import type { IApplicableSchema } from '../parser/schemaValidation/baseValidator'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { SingleYAMLDocument } from '../parser/yamlParser07'; -import type { Telemetry } from '../telemetry'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { toYamlStringScalar } from '../utils/yamlScalar'; -import type { LanguageSettings } from '../yamlLanguageService'; -import type { YAMLSchemaService } from './yamlSchemaService'; +import type { ASTNode, ObjectASTNode, PropertyASTNode } from '../jsonLanguageTypes.js'; +import type { JSONSchema } from '../jsonSchema.js'; +import { setKubernetesParserOption } from '../parser/isKubernetes.js'; +import { getNodeValue } from '../utils/astNodeUtils.js'; +import type { IApplicableSchema } from '../parser/schemaValidation/baseValidator.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { Telemetry } from '../telemetry.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { toYamlStringScalar } from '../utils/yamlScalar.js'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import type { YAMLSchemaService } from './yamlSchemaService.js'; export class YAMLHover { private shouldHover: boolean; diff --git a/src/languageservice/services/yamlLinks.ts b/src/languageservice/services/yamlLinks.ts index f92fc0028..434c97090 100644 --- a/src/languageservice/services/yamlLinks.ts +++ b/src/languageservice/services/yamlLinks.ts @@ -6,10 +6,10 @@ import type { DocumentLink } from 'vscode-languageserver-types'; import { Range } from 'vscode-languageserver-types'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import type { Telemetry } from '../telemetry'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { ASTNode, PropertyASTNode } from '../jsonLanguageTypes'; -import type { JSONDocument } from '../parser/jsonDocument'; +import type { Telemetry } from '../telemetry.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { ASTNode, PropertyASTNode } from '../jsonLanguageTypes.js'; +import type { JSONDocument } from '../parser/jsonDocument.js'; export class YamlLinks { constructor(private readonly telemetry?: Telemetry) {} diff --git a/src/languageservice/services/yamlOnTypeFormatting.ts b/src/languageservice/services/yamlOnTypeFormatting.ts index 27f80dcda..93db1aa7b 100644 --- a/src/languageservice/services/yamlOnTypeFormatting.ts +++ b/src/languageservice/services/yamlOnTypeFormatting.ts @@ -6,7 +6,7 @@ import type { DocumentOnTypeFormattingParams } from 'vscode-languageserver'; import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Position, Range, TextEdit } from 'vscode-languageserver-types'; -import { TextBuffer } from '../utils/textBuffer'; +import { TextBuffer } from '../utils/textBuffer.js'; export function doDocumentOnTypeFormatting( document: TextDocument, diff --git a/src/languageservice/services/yamlRename.ts b/src/languageservice/services/yamlRename.ts index df633208b..41e475c6a 100644 --- a/src/languageservice/services/yamlRename.ts +++ b/src/languageservice/services/yamlRename.ts @@ -6,14 +6,14 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Position, WorkspaceEdit } from 'vscode-languageserver-types'; import { Range, TextEdit } from 'vscode-languageserver-types'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { TextBuffer } from '../utils/textBuffer'; -import type { Telemetry } from '../telemetry'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import type { Telemetry } from '../telemetry.js'; import type { Node } from 'yaml'; import { CST, isAlias, isCollection, isScalar, visit } from 'yaml'; -import type { SingleYAMLDocument } from '../parser/yamlParser07'; -import { isCollectionItem } from '../utils/yamlAstUtils'; +import type { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import { isCollectionItem } from '../utils/yamlAstUtils.js'; import type { PrepareRenameParams, RenameParams } from 'vscode-languageserver-protocol'; import { ResponseError, ErrorCodes } from 'vscode-languageserver-protocol'; diff --git a/src/languageservice/services/yamlSchemaService.ts b/src/languageservice/services/yamlSchemaService.ts index b5bfd68e7..8010e8e3c 100644 --- a/src/languageservice/services/yamlSchemaService.ts +++ b/src/languageservice/services/yamlSchemaService.ts @@ -5,44 +5,44 @@ *--------------------------------------------------------------------------------------------*/ import type { AnySchemaObject, DefinedError, ErrorObject, ValidateFunction } from 'ajv'; -import type { Localize } from 'ajv-i18n/localize/types'; +import type { Localize } from 'ajv-i18n/localize/types.js'; import type { DiagnosticRelatedInformation } from 'vscode-languageserver-types'; -import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes'; -import type { SettingsState } from '../../yamlSettings'; -import type { PromiseConstructor, SchemaConfiguration } from '../jsonLanguageTypes'; -import type { JSONSchema, JSONSchemaMap, JSONSchemaRef } from '../jsonSchema'; -import type { JSONDocument } from '../parser/jsonDocument'; -import type { SingleYAMLDocument } from '../parser/yamlParser07'; -import type { SchemaRequestService, WorkspaceContextService } from '../yamlLanguageService'; -import type { SchemaVersions } from '../yamlTypes'; +import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { PromiseConstructor, SchemaConfiguration } from '../jsonLanguageTypes.js'; +import type { JSONSchema, JSONSchemaMap, JSONSchemaRef } from '../jsonSchema.js'; +import type { JSONDocument } from '../parser/jsonDocument.js'; +import type { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { SchemaRequestService, WorkspaceContextService } from '../yamlLanguageService.js'; +import type { SchemaVersions } from '../yamlTypes.js'; import * as path from 'path'; import * as l10n from '@vscode/l10n'; import Ajv from 'ajv'; -import Ajv2019 from 'ajv/dist/2019'; -import Ajv2020 from 'ajv/dist/2020'; +import Ajv2019 from 'ajv/dist/2019.js'; +import Ajv2020 from 'ajv/dist/2020.js'; import Ajv4 from 'ajv-draft-04'; -import * as ajvLocalizers from 'ajv-i18n'; +import ajvLocalizers from 'ajv-i18n'; import * as Json from 'jsonc-parser'; import picomatch from 'picomatch'; import { Range } from 'vscode-languageserver-types'; import { URI } from 'vscode-uri'; import { parse } from 'yaml'; -import { getDollarSchema } from './dollarUtils'; -import { getSchemaFromModeline } from './modelineUtil'; -import { ErrorCode, SchemaDraft } from '../jsonLanguageTypes'; -import { asSchema } from '../parser/schemaValidation/baseValidator'; -import { SchemaPriority } from '../yamlLanguageService'; -import { autoDetectKubernetesSchema } from './k8sSchemaUtil'; -import { CRD_CATALOG_URL, EMPTY_SCHEMA_URL, isKubernetes } from '../utils/schemaUrls'; -import * as Strings from '../utils/strings'; - -const ajv4 = new Ajv4({ allErrors: true }); -const ajv7 = new Ajv({ allErrors: true }); -const ajv2019 = new Ajv2019({ allErrors: true }); -const ajv2020 = new Ajv2020({ allErrors: true }); +import { getDollarSchema } from './dollarUtils.js'; +import { getSchemaFromModeline } from './modelineUtil.js'; +import { ErrorCode, SchemaDraft } from '../jsonLanguageTypes.js'; +import { asSchema } from '../parser/schemaValidation/baseValidator.js'; +import { SchemaPriority } from '../yamlLanguageService.js'; +import { autoDetectKubernetesSchema } from './k8sSchemaUtil.js'; +import { CRD_CATALOG_URL, EMPTY_SCHEMA_URL, isKubernetes } from '../utils/schemaUrls.js'; +import * as Strings from '../utils/strings.js'; + +const ajv4 = new Ajv4.default({ allErrors: true }); +const ajv7 = new Ajv.default({ allErrors: true }); +const ajv2019 = new Ajv2019.default({ allErrors: true }); +const ajv2020 = new Ajv2020.default({ allErrors: true }); const schema04Validator = getDefaultMetaSchemaValidator(ajv4); const schema07Validator = getDefaultMetaSchemaValidator(ajv7); diff --git a/src/languageservice/services/yamlSelectionRanges.ts b/src/languageservice/services/yamlSelectionRanges.ts index 2b6c2c14d..e66e7a174 100644 --- a/src/languageservice/services/yamlSelectionRanges.ts +++ b/src/languageservice/services/yamlSelectionRanges.ts @@ -1,8 +1,8 @@ import type { Position, Range } from 'vscode-languageserver-types'; import { SelectionRange } from 'vscode-languageserver-types'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; export function getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[] { const doc = yamlDocumentsCache.getYamlDocument(document); diff --git a/src/languageservice/services/yamlValidation.ts b/src/languageservice/services/yamlValidation.ts index 7592f96d5..cea31d810 100644 --- a/src/languageservice/services/yamlValidation.ts +++ b/src/languageservice/services/yamlValidation.ts @@ -6,23 +6,23 @@ import { Diagnostic, DiagnosticSeverity, Position, Range } from 'vscode-languageserver-types'; import type { DiagnosticRelatedInformation } from 'vscode-languageserver-types'; -import type { LanguageSettings } from '../yamlLanguageService'; -import type { YamlVersion, SingleYAMLDocument } from '../parser/yamlParser07'; -import type { YAMLSchemaService } from './yamlSchemaService'; -import type { YAMLDocDiagnostic } from '../utils/parseUtils'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import type { YamlVersion, SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { YAMLSchemaService } from './yamlSchemaService.js'; +import type { YAMLDocDiagnostic } from '../utils/parseUtils.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator'; -import { TextBuffer } from '../utils/textBuffer'; -import { filterSuppressedDiagnostics } from '../utils/diagnostic-filter'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { Telemetry } from '../telemetry'; -import type { AdditionalValidator } from './validation/types'; -import { UnusedAnchorsValidator } from './validation/unused-anchors'; -import { YAMLStyleValidator } from './validation/yaml-style'; -import { MapKeyOrderValidator } from './validation/map-key-order'; -import { getSchemaFromModeline } from './modelineUtil'; -import { isKubernetes as isKubernetesSchemaURI } from '../utils/schemaUrls'; -import type { ErrorCode } from '../jsonLanguageTypes'; +import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import { filterSuppressedDiagnostics } from '../utils/diagnostic-filter.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { Telemetry } from '../telemetry.js'; +import type { AdditionalValidator } from './validation/types.js'; +import { UnusedAnchorsValidator } from './validation/unused-anchors.js'; +import { YAMLStyleValidator } from './validation/yaml-style.js'; +import { MapKeyOrderValidator } from './validation/map-key-order.js'; +import { getSchemaFromModeline } from './modelineUtil.js'; +import { isKubernetes as isKubernetesSchemaURI } from '../utils/schemaUrls.js'; +import type { ErrorCode } from '../jsonLanguageTypes.js'; /** * Convert a YAMLDocDiagnostic to a language server Diagnostic diff --git a/src/languageservice/utils/arrUtils.ts b/src/languageservice/utils/arrUtils.ts index 6180eaade..2950524b1 100644 --- a/src/languageservice/utils/arrUtils.ts +++ b/src/languageservice/utils/arrUtils.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { YAMLDocument, SingleYAMLDocument } from '../parser/yamlParser07'; +import type { YAMLDocument, SingleYAMLDocument } from '../parser/yamlParser07.js'; export function getLineOffsets(textDocString: string): number[] { const lineOffsets: number[] = []; diff --git a/src/languageservice/utils/astNodeUtils.ts b/src/languageservice/utils/astNodeUtils.ts index 6c44353cf..495a1ff25 100644 --- a/src/languageservice/utils/astNodeUtils.ts +++ b/src/languageservice/utils/astNodeUtils.ts @@ -1,4 +1,4 @@ -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function getNodeValue(node: ASTNode): any { diff --git a/src/languageservice/utils/filePatternAssociation.ts b/src/languageservice/utils/filePatternAssociation.ts index 7edba5d42..d1124cd3e 100644 --- a/src/languageservice/utils/filePatternAssociation.ts +++ b/src/languageservice/utils/filePatternAssociation.ts @@ -1,4 +1,4 @@ -import { convertSimple2RegExpPattern } from './strings'; +import { convertSimple2RegExpPattern } from './strings.js'; export class FilePatternAssociation { private schemas: string[]; diff --git a/src/languageservice/utils/flow-style-rewriter.ts b/src/languageservice/utils/flow-style-rewriter.ts index db872ce2b..6273907d6 100644 --- a/src/languageservice/utils/flow-style-rewriter.ts +++ b/src/languageservice/utils/flow-style-rewriter.ts @@ -1,5 +1,5 @@ import { CST, visit } from 'yaml'; -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; export class FlowStyleRewriter { constructor(private readonly indentation: string) {} diff --git a/src/languageservice/utils/indentationGuesser.ts b/src/languageservice/utils/indentationGuesser.ts index 3cca1955f..7f665861e 100644 --- a/src/languageservice/utils/indentationGuesser.ts +++ b/src/languageservice/utils/indentationGuesser.ts @@ -5,8 +5,8 @@ //copied from https://github.com/Microsoft/vscode/blob/015c3afe96966df50c15a7d66be2ab0ef1dc5f49/src/vs/editor/common/model/indentationGuesser.ts -import { CharCode } from './charCode'; -import type { TextBuffer } from './textBuffer'; +import { CharCode } from './charCode.js'; +import type { TextBuffer } from './textBuffer.js'; class SpacesDiffResult { public spacesDiff = 0; diff --git a/src/languageservice/utils/objects.ts b/src/languageservice/utils/objects.ts index e6db971c2..dc8d6425e 100644 --- a/src/languageservice/utils/objects.ts +++ b/src/languageservice/utils/objects.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { parseYamlBoolean } from '../parser/scalar-type'; +import { parseYamlBoolean } from '../parser/scalar-type.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function equals(one: any, other: any, type?: any): boolean { diff --git a/src/languageservice/utils/parseUtils.ts b/src/languageservice/utils/parseUtils.ts index a4b0fb7c3..dd54eae02 100644 --- a/src/languageservice/utils/parseUtils.ts +++ b/src/languageservice/utils/parseUtils.ts @@ -1,5 +1,4 @@ -import type { ErrorCode } from '../jsonLanguageTypes'; -export const DUPLICATE_KEY_REASON = 'duplicate key'; +import type { ErrorCode } from '../jsonLanguageTypes.js'; /** * An individual YAML diagnostic, diff --git a/src/languageservice/utils/schemaUrls.ts b/src/languageservice/utils/schemaUrls.ts index bc7fa836b..da844c4f8 100644 --- a/src/languageservice/utils/schemaUrls.ts +++ b/src/languageservice/utils/schemaUrls.ts @@ -1,10 +1,10 @@ import type { WorkspaceFolder } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; import * as path from 'path'; -import type { Telemetry } from '../telemetry'; -import type { JSONSchema, JSONSchemaRef } from '../jsonSchema'; -import { isBoolean } from './objects'; -import { isRelativePath, relativeToAbsolutePath } from './paths'; +import type { Telemetry } from '../telemetry.js'; +import type { JSONSchema, JSONSchemaRef } from '../jsonSchema.js'; +import { isBoolean } from './objects.js'; +import { isRelativePath, relativeToAbsolutePath } from './paths.js'; export const DEFAULT_KUBERNETES_SCHEMA_VERSION = 'v1.34.1'; export const JSON_SCHEMASTORE_URL = 'https://www.schemastore.org/api/json/catalog.json'; diff --git a/src/languageservice/utils/schemaUtils.ts b/src/languageservice/utils/schemaUtils.ts index 373539b64..aab976153 100644 --- a/src/languageservice/utils/schemaUtils.ts +++ b/src/languageservice/utils/schemaUtils.ts @@ -1,5 +1,5 @@ import { URI } from 'vscode-uri'; -import type { JSONSchema } from '../jsonSchema'; +import type { JSONSchema } from '../jsonSchema.js'; import * as path from 'path'; export function getSchemaTypeName(schema: JSONSchema, ignoreFileNameRefs = false): string { diff --git a/src/languageservice/utils/strings.ts b/src/languageservice/utils/strings.ts index e74380206..3a33e4997 100644 --- a/src/languageservice/utils/strings.ts +++ b/src/languageservice/utils/strings.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CharCode } from './charCode'; +import { CharCode } from './charCode.js'; export function startsWith(haystack: string, needle: string): boolean { if (haystack.length < needle.length) { diff --git a/src/languageservice/utils/yamlAstUtils.ts b/src/languageservice/utils/yamlAstUtils.ts index 6bd6c5418..042bf385f 100644 --- a/src/languageservice/utils/yamlAstUtils.ts +++ b/src/languageservice/utils/yamlAstUtils.ts @@ -5,7 +5,7 @@ import type { CST, Document, Node, YAMLMap, YAMLSeq } from 'yaml'; import { isDocument, isScalar, visit } from 'yaml'; -import type { YamlNode } from '../jsonLanguageTypes'; +import type { YamlNode } from '../jsonLanguageTypes.js'; type Visitor = (item: CST.SourceToken, path: CST.VisitPath) => number | symbol | Visitor | void; diff --git a/src/languageservice/yamlLanguageService.ts b/src/languageservice/yamlLanguageService.ts index b67d9f719..8283c80d8 100644 --- a/src/languageservice/yamlLanguageService.ts +++ b/src/languageservice/yamlLanguageService.ts @@ -4,8 +4,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { CustomSchemaProvider, SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from './services/yamlSchemaService'; -import { YAMLSchemaService } from './services/yamlSchemaService'; +import type { CustomSchemaProvider, SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from './services/yamlSchemaService.js'; +import { YAMLSchemaService } from './services/yamlSchemaService.js'; import type { Position, CodeAction, @@ -23,13 +23,13 @@ import type { Range, WorkspaceEdit, } from 'vscode-languageserver-types'; -import type { JSONSchema } from './jsonSchema'; -import { YAMLDocumentSymbols } from './services/documentSymbols'; -import { YAMLHover } from './services/yamlHover'; -import { YAMLValidation } from './services/yamlValidation'; -import { YAMLFormatter } from './services/yamlFormatter'; -import type { DocumentSymbolsContext } from './jsonLanguageTypes'; -import { YamlLinks } from './services/yamlLinks'; +import type { JSONSchema } from './jsonSchema.js'; +import { YAMLDocumentSymbols } from './services/documentSymbols.js'; +import { YAMLHover } from './services/yamlHover.js'; +import { YAMLValidation } from './services/yamlValidation.js'; +import { YAMLFormatter } from './services/yamlFormatter.js'; +import type { DocumentSymbolsContext } from './jsonLanguageTypes.js'; +import { YamlLinks } from './services/yamlLinks.js'; import type { ClientCapabilities, CodeActionParams, @@ -40,20 +40,20 @@ import type { RenameParams, } from 'vscode-languageserver'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { getFoldingRanges } from './services/yamlFolding'; -import type { FoldingRangesContext, SchemaVersions } from './yamlTypes'; -import { YamlCodeActions } from './services/yamlCodeActions'; -import { doDocumentOnTypeFormatting } from './services/yamlOnTypeFormatting'; -import { YamlCodeLens } from './services/yamlCodeLens'; -import type { Telemetry } from './telemetry'; -import type { YamlVersion } from './parser/yamlParser07'; -import { YamlCompletion } from './services/yamlCompletion'; -import { yamlDocumentsCache } from './parser/yaml-documents'; -import type { SettingsState } from '../yamlSettings'; -import { JSONSchemaSelection } from '../languageserver/handlers/schemaSelectionHandlers'; -import { YamlDefinition } from './services/yamlDefinition'; -import { getSelectionRanges } from './services/yamlSelectionRanges'; -import { YamlRename } from './services/yamlRename'; +import { getFoldingRanges } from './services/yamlFolding.js'; +import type { FoldingRangesContext, SchemaVersions } from './yamlTypes.js'; +import { YamlCodeActions } from './services/yamlCodeActions.js'; +import { doDocumentOnTypeFormatting } from './services/yamlOnTypeFormatting.js'; +import { YamlCodeLens } from './services/yamlCodeLens.js'; +import type { Telemetry } from './telemetry.js'; +import type { YamlVersion } from './parser/yamlParser07.js'; +import { YamlCompletion } from './services/yamlCompletion.js'; +import { yamlDocumentsCache } from './parser/yaml-documents.js'; +import type { SettingsState } from '../yamlSettings.js'; +import { JSONSchemaSelection } from '../languageserver/handlers/schemaSelectionHandlers.js'; +import { YamlDefinition } from './services/yamlDefinition.js'; +import { getSelectionRanges } from './services/yamlSelectionRanges.js'; +import { YamlRename } from './services/yamlRename.js'; export enum SchemaPriority { SchemaStore = 1, diff --git a/src/nodeTranslationSetup.ts b/src/nodeTranslationSetup.ts index 25d5ef773..c7c8d6359 100644 --- a/src/nodeTranslationSetup.ts +++ b/src/nodeTranslationSetup.ts @@ -16,8 +16,7 @@ import type { InitializeParams } from 'vscode-languageserver'; * @param params the language server initialization parameters */ export async function setupl10nBundle(params: InitializeParams): Promise { - const __dirname = path.dirname(__filename); - const l10nPath: string = params.initializationOptions?.l10nPath || path.join(__dirname, '../../../l10n'); + const l10nPath: string = params.initializationOptions?.l10nPath || path.join(import.meta.dirname, '../../../l10n'); const locale: string = params.locale || 'en'; if (l10nPath) { const bundleFile = !existsSync(path.join(l10nPath, `bundle.l10n.${locale}.json`)) diff --git a/src/requestTypes.ts b/src/requestTypes.ts index 4e4087ad2..1ebdeefba 100644 --- a/src/requestTypes.ts +++ b/src/requestTypes.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-namespace */ import { NotificationType, RequestType } from 'vscode-languageserver'; -import type { SchemaAdditions, SchemaDeletions } from './languageservice/services/yamlSchemaService'; -import type { SchemaConfiguration } from './languageservice/yamlLanguageService'; -import type { SchemaVersions } from './languageservice/yamlTypes'; +import type { SchemaAdditions, SchemaDeletions } from './languageservice/services/yamlSchemaService.js'; +import type { SchemaConfiguration } from './languageservice/yamlLanguageService.js'; +import type { SchemaVersions } from './languageservice/yamlTypes.js'; export type ISchemaAssociations = Record; diff --git a/src/server.ts b/src/server.ts index 86cb855ba..8dcf8f440 100644 --- a/src/server.ts +++ b/src/server.ts @@ -6,14 +6,14 @@ *--------------------------------------------------------------------------------------------*/ import { promises as fs } from 'fs'; -import type { Connection } from 'vscode-languageserver/node'; -import { createConnection, ProposedFeatures } from 'vscode-languageserver/node'; -import { TelemetryImpl } from './languageserver/telemetry'; -import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler'; -import { convertErrorToTelemetryMsg } from './languageservice/utils/objects'; -import { setupl10nBundle } from './nodeTranslationSetup'; -import { YAMLServerInit } from './yamlServerInit'; -import { SettingsState } from './yamlSettings'; +import type { Connection } from 'vscode-languageserver/node.js'; +import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js'; +import { TelemetryImpl } from './languageserver/telemetry.js'; +import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler.js'; +import { convertErrorToTelemetryMsg } from './languageservice/utils/objects.js'; +import { setupl10nBundle } from './nodeTranslationSetup.js'; +import { YAMLServerInit } from './yamlServerInit.js'; +import { SettingsState } from './yamlSettings.js'; // Create a connection for the server. let connection: Connection = null; diff --git a/src/webworker/yamlServerMain.ts b/src/webworker/yamlServerMain.ts index 0e2c5ae40..d7c01965e 100644 --- a/src/webworker/yamlServerMain.ts +++ b/src/webworker/yamlServerMain.ts @@ -6,11 +6,11 @@ import * as l10n from '@vscode/l10n'; import type { Connection } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; -import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'; -import { TelemetryImpl } from '../languageserver/telemetry'; -import { schemaRequestHandler, workspaceContext } from '../languageservice/services/schemaRequestHandler'; -import { YAMLServerInit } from '../yamlServerInit'; -import { SettingsState } from '../yamlSettings'; +import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser.js'; +import { TelemetryImpl } from '../languageserver/telemetry.js'; +import { schemaRequestHandler, workspaceContext } from '../languageservice/services/schemaRequestHandler.js'; +import { YAMLServerInit } from '../yamlServerInit.js'; +import { SettingsState } from '../yamlSettings.js'; // eslint-disable-next-line @typescript-eslint/no-namespace namespace FSReadFile { diff --git a/src/yamlServerInit.ts b/src/yamlServerInit.ts index e4edc9181..a22a13b86 100644 --- a/src/yamlServerInit.ts +++ b/src/yamlServerInit.ts @@ -1,20 +1,20 @@ import type { Connection, InitializeParams, InitializeResult } from 'vscode-languageserver'; import { TextDocumentSyncKind } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; -import { YamlCommands } from './commands'; -import { commandExecutor } from './languageserver/commandExecutor'; -import { LanguageHandlers } from './languageserver/handlers/languageHandlers'; -import { NotificationHandlers } from './languageserver/handlers/notificationHandlers'; -import { RequestHandlers } from './languageserver/handlers/requestHandlers'; -import { SettingsHandler } from './languageserver/handlers/settingsHandlers'; -import { ValidationHandler } from './languageserver/handlers/validationHandlers'; -import { WorkspaceHandlers } from './languageserver/handlers/workspaceHandlers'; -import { registerCommands } from './languageservice/services/yamlCommands'; -import type { Telemetry } from './languageservice/telemetry'; -import { workspaceFoldersChanged } from './languageservice/utils/paths'; -import type { LanguageService, SchemaRequestService, WorkspaceContextService } from './languageservice/yamlLanguageService'; -import { getLanguageService as getCustomLanguageService } from './languageservice/yamlLanguageService'; -import type { SettingsState } from './yamlSettings'; +import { YamlCommands } from './commands.js'; +import { commandExecutor } from './languageserver/commandExecutor.js'; +import { LanguageHandlers } from './languageserver/handlers/languageHandlers.js'; +import { NotificationHandlers } from './languageserver/handlers/notificationHandlers.js'; +import { RequestHandlers } from './languageserver/handlers/requestHandlers.js'; +import { SettingsHandler } from './languageserver/handlers/settingsHandlers.js'; +import { ValidationHandler } from './languageserver/handlers/validationHandlers.js'; +import { WorkspaceHandlers } from './languageserver/handlers/workspaceHandlers.js'; +import { registerCommands } from './languageservice/services/yamlCommands.js'; +import type { Telemetry } from './languageservice/telemetry.js'; +import { workspaceFoldersChanged } from './languageservice/utils/paths.js'; +import type { LanguageService, SchemaRequestService, WorkspaceContextService } from './languageservice/yamlLanguageService.js'; +import { getLanguageService as getCustomLanguageService } from './languageservice/yamlLanguageService.js'; +import type { SettingsState } from './yamlSettings.js'; export class YAMLServerInit { languageService: LanguageService; diff --git a/src/yamlSettings.ts b/src/yamlSettings.ts index 01f2c46d0..707f5096d 100644 --- a/src/yamlSettings.ts +++ b/src/yamlSettings.ts @@ -1,12 +1,12 @@ import type { Disposable, ClientCapabilities, WorkspaceFolder } from 'vscode-languageserver'; import { TextDocuments } from 'vscode-languageserver'; -import type { CustomFormatterOptions, SchemaConfiguration } from './languageservice/yamlLanguageService'; -import type { ISchemaAssociations } from './requestTypes'; +import type { CustomFormatterOptions, SchemaConfiguration } from './languageservice/yamlLanguageService.js'; +import type { ISchemaAssociations } from './requestTypes.js'; import type { URI } from 'vscode-uri'; -import type { JSONSchema } from './languageservice/jsonSchema'; +import type { JSONSchema } from './languageservice/jsonSchema.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import { CRD_CATALOG_URL, JSON_SCHEMASTORE_URL } from './languageservice/utils/schemaUrls'; -import type { YamlVersion } from './languageservice/parser/yamlParser07'; +import { CRD_CATALOG_URL, JSON_SCHEMASTORE_URL } from './languageservice/utils/schemaUrls.js'; +import type { YamlVersion } from './languageservice/parser/yamlParser07.js'; // Client settings interface to grab settings relevant for the language server export interface Settings { diff --git a/test/arrUtils.test.ts b/test/arrUtils.test.ts index 9f926f966..c3be46dda 100644 --- a/test/arrUtils.test.ts +++ b/test/arrUtils.test.ts @@ -2,7 +2,9 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { getLineOffsets, removeDuplicatesObj } from '../src/languageservice/utils/arrUtils'; + +import { describe, it } from 'node:test'; +import { getLineOffsets, removeDuplicatesObj } from '../src/languageservice/utils/arrUtils.js'; import assert from 'assert'; describe('Array Utils Tests', () => { diff --git a/test/astUtils.test.ts b/test/astUtils.test.ts index 28859ed7d..b9399c5cb 100644 --- a/test/astUtils.test.ts +++ b/test/astUtils.test.ts @@ -3,13 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it, beforeEach } from 'node:test'; + import * as chai from 'chai'; import type { Pair, YAMLSeq } from 'yaml'; import { isPair, isSeq } from 'yaml'; -import { YamlDocuments } from '../src/languageservice/parser/yaml-documents'; -import { getParent, isInComment } from '../src/languageservice/utils/yamlAstUtils'; -import { TextBuffer } from '../src/languageservice/utils/textBuffer'; -import { setupTextDocument } from './utils/testHelper'; +import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; +import { getParent, isInComment } from '../src/languageservice/utils/yamlAstUtils.js'; +import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; +import { setupTextDocument } from './utils/testHelper.js'; const expect = chai.expect; describe('AST Utils Tests', () => { diff --git a/test/autoCompletion.test.ts b/test/autoCompletion.test.ts index f8ab0b2c4..f04121aeb 100644 --- a/test/autoCompletion.test.ts +++ b/test/autoCompletion.test.ts @@ -3,19 +3,27 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, toFsPath } from './utils/testHelper'; +import { describe, it, before, beforeEach, afterEach } from 'node:test'; + +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, toFsPath } from './utils/testHelper.js'; import assert from 'assert'; import * as path from 'path'; -import { createExpectedCompletion } from './utils/verifyError'; -import { ServiceSetup } from './utils/serviceSetup'; +import { createExpectedCompletion } from './utils/verifyError.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { CompletionList, MarkupContent } from 'vscode-languageserver-types'; import { CompletionItemKind, InsertTextFormat, MarkupKind, Position } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageService } from '../src'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageService } from '../src/index.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; + +import requiredPropertiesSchema from './fixtures/testRequiredProperties.json' with { type: 'json' }; +import arrayMaxPropertiesSchema from './fixtures/testArrayMaxProperties.json' with { type: 'json' }; +import stringArraySchema from './fixtures/testStringArray.json' with { type: 'json' }; +import arrayIndentSchema from './fixtures/testArrayIndent.json' with { type: 'json' }; +import arrayCompletionSchema from './fixtures/testArrayCompletionSchema.json' with { type: 'json' }; describe('Auto Completion Tests', () => { let languageSettingsSetup: ServiceSetup; @@ -695,9 +703,7 @@ describe('Auto Completion Tests', () => { }); it('Insert required attributes at correct level', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, requiredPropertiesSchema); const content = '- top:\n prop1: demo\n- '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 1); @@ -710,9 +716,7 @@ describe('Auto Completion Tests', () => { }); it('Insert required attributes at correct level even on first element', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, requiredPropertiesSchema); const content = '- '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 1); @@ -725,9 +729,7 @@ describe('Auto Completion Tests', () => { }); it('Provide the 3 types when none provided', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 3); @@ -752,9 +754,7 @@ describe('Auto Completion Tests', () => { }); it('Provide the 2 types when one is provided', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- prop1:\n '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -773,9 +773,7 @@ describe('Auto Completion Tests', () => { }); it('Provide the 2 types when one is provided and the second is typed', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- prop1:\n p'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -794,9 +792,7 @@ describe('Auto Completion Tests', () => { }); it('Provide no completion when maxProperties reached', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- prop1:\n prop2:\n '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 0); @@ -932,9 +928,7 @@ describe('Auto Completion Tests', () => { describe('Array Specific Tests', function () { it('Should insert empty array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testStringArray.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, stringArraySchema); const content = 'fooBa'; // len: 5 const result = await parseSetup(content, content.lastIndexOf('Ba') + 2); // pos: 3+2 assert.strictEqual('fooBar:\n - ${1}', result.items[0].insertText); @@ -1547,7 +1541,7 @@ describe('Auto Completion Tests', () => { }); // For some reason, this gets inserted at the cursor (char 4) // It should be inserted at char 2 - xit('Next line const no :', async () => { + it.skip('Next line const no :', async () => { const content = 'test:\n - constProp\n '; const result = await parseSetup(content, content.length); expect(result.items.length).to.be.equal(1); @@ -1772,9 +1766,7 @@ describe('Auto Completion Tests', () => { describe('Indentation Specific Tests', function () { it('Indent should be considered with position relative to slash', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayIndentSchema); const content = 'install:\n - he'; // len: 15 const result = await parseSetup(content, content.lastIndexOf('he') + 2); // pos: 13+2 assert.equal(result.items.length, 2); @@ -1787,9 +1779,7 @@ describe('Auto Completion Tests', () => { }); it('Large indent should be considered with position relative to slash', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayIndentSchema); const content = 'install:\n - he'; // len: 25 const result = await parseSetup(content, content.lastIndexOf('he') + 2); // pos: 23+2 assert.equal(result.items.length, 2); @@ -1802,9 +1792,7 @@ describe('Auto Completion Tests', () => { }); it('Tab indent should be considered with position relative to slash', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayIndentSchema); const content = 'install:\n -\t he'; // len: 27 const result = await parseSetup(content, content.lastIndexOf('he') + 2); // pos: 25+2 assert.equal(result.items.length, 2); @@ -1818,7 +1806,7 @@ describe('Auto Completion Tests', () => { }); describe('Yaml schema defined in file', function () { - const uri = toFsPath(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); + const uri = toFsPath(path.join(import.meta.dirname, './fixtures/testArrayMaxProperties.json')); it('Provide completion from schema declared in file', async () => { const content = `# yaml-language-server: $schema=${uri}\n- `; @@ -1850,7 +1838,7 @@ describe('Auto Completion Tests', () => { it('should handle absolute path', async () => { const documentContent = `# yaml-language-server: $schema=${path.join( - __dirname, + import.meta.dirname, './fixtures/testArrayMaxProperties.json' )} anothermodeline=value\n- `; // len: 142 const content = `${documentContent}|\n|---\n- `; // len: 149, pos: 142 @@ -1861,7 +1849,7 @@ describe('Auto Completion Tests', () => { it('should handle relative path', async () => { const documentContent = `# yaml-language-server: $schema=./fixtures/testArrayMaxProperties.json anothermodeline=value\n- `; // 95 const content = `${documentContent}\n---\n- `; - const testTextDocument = setupSchemaIDTextDocument(content, path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument(content, path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1874,7 +1862,7 @@ describe('Auto Completion Tests', () => { const inlineSchemaLabel = 'Inline schema'; it('should provide modeline completion on first character with no schema associated and no modeline yet', async () => { - const testTextDocument = setupSchemaIDTextDocument('', path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument('', path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1886,7 +1874,7 @@ describe('Auto Completion Tests', () => { }); it('should not provide modeline completion on first character when schema is associated', async () => { - const specificSchemaId = path.join(__dirname, 'test.yaml'); + const specificSchemaId = path.join(import.meta.dirname, 'test.yaml'); const testTextDocument = setupSchemaIDTextDocument('', specificSchemaId); schemaProvider.addSchema(specificSchemaId, { type: 'object', @@ -1907,7 +1895,7 @@ describe('Auto Completion Tests', () => { }); it('should not provide modeline completion on first character when modeline already present', async () => { - const testTextDocument = setupSchemaIDTextDocument('# yaml-language-server:', path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument('# yaml-language-server:', path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1919,7 +1907,7 @@ describe('Auto Completion Tests', () => { it('should provide schema id completion in modeline', async () => { const modeline = '# yaml-language-server: $schema='; - const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1932,7 +1920,7 @@ describe('Auto Completion Tests', () => { it('should provide schema id completion in modeline for any line', async () => { const modeline = 'foo:\n bar\n# yaml-language-server: $schema='; - const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -2701,9 +2689,7 @@ describe('Auto Completion Tests', () => { describe('Array completion', () => { it('Simple array object completion with "-" without any item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -2712,9 +2698,7 @@ describe('Auto Completion Tests', () => { }); it('Simple array object completion without "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 1); @@ -2722,9 +2706,7 @@ describe('Auto Completion Tests', () => { }); it('Simple array object completion with "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -2733,9 +2715,7 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion with "- " without any item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 4); @@ -2746,9 +2726,7 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion with "-" without any item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 4); @@ -2757,9 +2735,7 @@ describe('Auto Completion Tests', () => { }); it('Simple array object completion without "-" befor array empty item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n |\n| -'; // len: 30, pos: 26 const result = await parseSetup(content); assert.equal(result.items.length, 1); @@ -2767,27 +2743,21 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion without "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n '; const result = await parseSetup(content, content.length); expect(result.items.map((i) => i.label)).deep.eq(['- (array item) obj1', '- (array item) obj2']); }); it('Array nested anyOf without "-" should return all array items', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_nested_anyOf:\n - obj1:\n name:1\n '; const result = await parseSetup(content, content.length); expect(result.items.map((i) => i.label)).deep.eq(['- (array item) obj1', '- (array item) obj2', '- (array item) obj3']); }); it('Array anyOf two objects completion with "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 4); @@ -2796,9 +2766,7 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion indentation', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - obj'; const completion = await parseSetup(content, content.length); expect(completion.items.length).is.equal(4); diff --git a/test/autoCompletionFix.test.ts b/test/autoCompletionFix.test.ts index fd3a821cd..a5832df69 100644 --- a/test/autoCompletionFix.test.ts +++ b/test/autoCompletionFix.test.ts @@ -3,19 +3,23 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it, before, beforeEach, afterEach } from 'node:test'; + import type { CompletionList } from 'vscode-languageserver-types'; import { CompletionItemKind, InsertTextFormat, Position, Range } from 'vscode-languageserver-types'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import { expect } from 'chai'; -import { createExpectedCompletion } from './utils/verifyError'; -import * as path from 'path'; -import type { JSONSchema } from './../src/languageservice/jsonSchema'; +import { createExpectedCompletion } from './utils/verifyError.js'; +import type { JSONSchema } from './../src/languageservice/jsonSchema.js'; + +import nestedObjectArraySchema from './fixtures/test-nested-object-array.json' with { type: 'json' }; +import completionOneOfSchema from './fixtures/test-completion-oneOf.json' with { type: 'json' }; describe('Auto Completion Fix Tests', () => { let languageSettingsSetup: ServiceSetup; @@ -196,9 +200,7 @@ spec: }); it('should complete array', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/test-nested-object-array.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, nestedObjectArraySchema as JSONSchema); const content = `objA: - name: nameA1 @@ -211,9 +213,7 @@ objB: }); it('should complete array item for "oneOf" schema', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/test-completion-oneOf.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, completionOneOfSchema); const content = `metadata: Selector: query: diff --git a/test/bundlel10n.test.ts b/test/bundlel10n.test.ts index 4506c1641..a92872dce 100644 --- a/test/bundlel10n.test.ts +++ b/test/bundlel10n.test.ts @@ -2,17 +2,19 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before, after } from 'node:test'; import * as l10n from '@vscode/l10n'; import assert from 'assert'; import * as path from 'path'; -import type { Connection } from 'vscode-languageserver/node'; -import { createConnection } from 'vscode-languageserver/node'; -import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler'; -import { setupl10nBundle } from '../src/nodeTranslationSetup'; -import { YAMLServerInit } from '../src/yamlServerInit'; -import { SettingsState } from '../src/yamlSettings'; -import { TestCustomSchemaProvider, testFileSystem } from './utils/testHelper'; -import { TestTelemetry } from './utils/testsTypes'; +import type { Connection } from 'vscode-languageserver/node.js'; +import { createConnection } from 'vscode-languageserver/node.js'; +import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler.js'; +import { setupl10nBundle } from '../src/nodeTranslationSetup.js'; +import { YAMLServerInit } from '../src/yamlServerInit.js'; +import { SettingsState } from '../src/yamlSettings.js'; +import { TestCustomSchemaProvider, testFileSystem } from './utils/testHelper.js'; +import { TestTelemetry } from './utils/testsTypes.js'; describe('Bundle l10n Test', () => { let serverInit: YAMLServerInit; @@ -49,7 +51,7 @@ describe('Bundle l10n Test', () => { rootUri: '', capabilities: undefined, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, }); }); @@ -62,7 +64,7 @@ describe('Bundle l10n Test', () => { rootUri: '', capabilities: undefined, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, }); assert.equal(l10n.t('Default value'), 'Valeur par défaut'); @@ -75,7 +77,7 @@ describe('Bundle l10n Test', () => { rootUri: '', capabilities: undefined, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, }); assert.equal(l10n.t('Default value'), 'Default value'); diff --git a/test/code-action-schema.test.ts b/test/code-action-schema.test.ts index c440ee055..c10faca5f 100644 --- a/test/code-action-schema.test.ts +++ b/test/code-action-schema.test.ts @@ -2,16 +2,18 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, TEST_URI } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, TEST_URI } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { CodeActionParams } from 'vscode-languageserver'; import { TextDocumentIdentifier, CodeActionContext, TextEdit, Range } from 'vscode-languageserver'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; describe('Schema Errors Code Action Tests', () => { diff --git a/test/customTags.test.ts b/test/customTags.test.ts index fe4f70aaf..947716103 100644 --- a/test/customTags.test.ts +++ b/test/customTags.test.ts @@ -2,13 +2,15 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; -import { createExpectedError } from './utils/verifyError'; + +import { describe, it, before } from 'node:test'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import { createExpectedError } from './utils/verifyError.js'; import assert from 'assert'; import type { Diagnostic } from 'vscode-languageserver-types'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; // Defines a Mocha test describe to group tests of similar kind together describe('Custom Tag tests Tests', () => { diff --git a/test/defaultSnippets.test.ts b/test/defaultSnippets.test.ts index 610c85303..195046bc0 100644 --- a/test/defaultSnippets.test.ts +++ b/test/defaultSnippets.test.ts @@ -2,13 +2,15 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { toFsPath, setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper'; + +import { describe, it, before } from 'node:test'; +import { toFsPath, setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper.js'; import assert from 'assert'; import * as path from 'path'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { CompletionList, TextEdit } from 'vscode-languageserver-types'; import { expect } from 'chai'; @@ -17,7 +19,7 @@ describe('Default Snippet Tests', () => { let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(__dirname, './fixtures/defaultSnippets.json')); + const uri = toFsPath(path.join(import.meta.dirname, './fixtures/defaultSnippets.json')); const fileMatch = ['*.yml', '*.yaml']; const languageSettingsSetup = new ServiceSetup().withCompletion().withSchemaFileMatch({ fileMatch, diff --git a/test/diagnostic-filter.test.ts b/test/diagnostic-filter.test.ts index 395385ac7..f9fee8f5a 100644 --- a/test/diagnostic-filter.test.ts +++ b/test/diagnostic-filter.test.ts @@ -3,14 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it } from 'node:test'; + import { expect } from 'chai'; -import type { GetLineText } from '../src/languageservice/utils/diagnostic-filter'; +import type { GetLineText } from '../src/languageservice/utils/diagnostic-filter.js'; import { filterSuppressedDiagnostics, YAML_DISABLE_PATTERN, parseDisableSpecifiers, shouldSuppressDiagnostic, -} from '../src/languageservice/utils/diagnostic-filter'; +} from '../src/languageservice/utils/diagnostic-filter.js'; function makeDiag(startLine: number, message: string): { startLine: number; message: string } { return { startLine, message }; diff --git a/test/documentSymbols.test.ts b/test/documentSymbols.test.ts index a6ce3bb16..7e3d2aa3b 100644 --- a/test/documentSymbols.test.ts +++ b/test/documentSymbols.test.ts @@ -2,19 +2,21 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper'; + +import { describe, it, before, afterEach } from 'node:test'; +import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper.js'; import { createExpectedSymbolInformation, createExpectedDocumentSymbol, createExpectedDocumentSymbolNoDetail, -} from './utils/verifyError'; +} from './utils/verifyError.js'; import type { DocumentSymbol, SymbolInformation } from 'vscode-languageserver-types'; import { SymbolKind } from 'vscode-languageserver-types'; import assert from 'assert'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; describe('Document Symbols Tests', () => { let languageHandler: LanguageHandlers; diff --git a/test/findLinks.test.ts b/test/findLinks.test.ts index 4f6651f54..df44e203b 100644 --- a/test/findLinks.test.ts +++ b/test/findLinks.test.ts @@ -2,13 +2,15 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; + +import { describe, it, before } from 'node:test'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; import assert from 'assert'; -import { ServiceSetup } from './utils/serviceSetup'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { DocumentLink } from 'vscode-languageserver-types'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; describe('Find Links Tests', () => { let languageHandler: LanguageHandlers; diff --git a/test/flow-style-rewriter.test.ts b/test/flow-style-rewriter.test.ts index 7cc773755..8738e0756 100644 --- a/test/flow-style-rewriter.test.ts +++ b/test/flow-style-rewriter.test.ts @@ -1,7 +1,8 @@ +import { describe, it, beforeEach } from 'node:test'; import { expect } from 'chai'; -import { YamlDocuments } from '../src/languageservice/parser/yaml-documents'; -import { FlowStyleRewriter } from '../src/languageservice/utils/flow-style-rewriter'; -import { setupTextDocument } from './utils/testHelper'; +import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; +import { FlowStyleRewriter } from '../src/languageservice/utils/flow-style-rewriter.js'; +import { setupTextDocument } from './utils/testHelper.js'; describe('Flow style rewriter', () => { let writer: FlowStyleRewriter; diff --git a/test/formatter.test.ts b/test/formatter.test.ts index e3bb67f4c..f6eb446ff 100644 --- a/test/formatter.test.ts +++ b/test/formatter.test.ts @@ -2,16 +2,18 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before, afterEach } from 'node:test'; import assert from 'assert'; -import * as sinon from 'sinon'; +import { createSandbox } from 'sinon'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { FormattingOptions, TextEdit } from 'vscode-languageserver-types'; -import type { CustomFormatterOptions } from '../src'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import { ServiceSetup } from './utils/serviceSetup'; -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; +import type { CustomFormatterOptions } from '../src/index.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; type LanguageHandlerWithConnection = { connection: { @@ -24,7 +26,7 @@ type LanguageHandlerWithConnection = { }; describe('Formatter Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); let languageHandler: LanguageHandlers; let yamlSettings: SettingsState; diff --git a/test/hover.test.ts b/test/hover.test.ts index 8fa16f855..e00b61450 100644 --- a/test/hover.test.ts +++ b/test/hover.test.ts @@ -2,17 +2,19 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ServiceSetup } from './utils/serviceSetup'; -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; + +import { describe, it, before, afterEach } from 'node:test'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import assert from 'assert'; import type { Hover } from 'vscode-languageserver-types'; import { MarkupContent, Position } from 'vscode-languageserver-types'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; import { expect } from 'chai'; -import type { TestTelemetry } from './utils/testsTypes'; +import type { TestTelemetry } from './utils/testsTypes.js'; describe('Hover Tests', () => { let languageSettingsSetup: ServiceSetup; diff --git a/test/integration.test.ts b/test/integration.test.ts index ab8f52d1c..94c9944e9 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -2,15 +2,17 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; + +import { describe, it, before } from 'node:test'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; import assert from 'assert'; import type { Diagnostic, CompletionList, Hover } from 'vscode-languageserver-types'; import { MarkupContent } from 'vscode-languageserver-types'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; // Defines a Mocha test describe to group tests of similar kind together describe('Kubernetes Integration Tests', () => { diff --git a/test/invalid-metaschema.test.ts b/test/invalid-metaschema.test.ts index e584ea9cf..25d3a9216 100644 --- a/test/invalid-metaschema.test.ts +++ b/test/invalid-metaschema.test.ts @@ -2,19 +2,22 @@ * Copyright (c) IBM Corp. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, beforeEach, afterEach } from 'node:test'; import { assert } from 'chai'; -import * as sinon from 'sinon'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node'; -import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; -import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; -import { setupSchemaIDTextDocument } from './utils/testHelper'; +import type { SinonSpy } from 'sinon'; +import { createSandbox } from 'sinon'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; +import { setupSchemaIDTextDocument } from './utils/testHelper.js'; describe('unexpected meta schema', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: sinon.SinonSpy; + let requestServiceMock: SinonSpy; beforeEach(() => { requestServiceMock = sandbox.fake.resolves('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }'); diff --git a/test/multipleDocuments.test.ts b/test/multipleDocuments.test.ts index 4af4ae814..3476975f9 100644 --- a/test/multipleDocuments.test.ts +++ b/test/multipleDocuments.test.ts @@ -2,17 +2,19 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before } from 'node:test'; import * as path from 'path'; -import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper'; +import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper.js'; import assert from 'assert'; -import { ServiceSetup } from './utils/serviceSetup'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic, Hover } from 'vscode-languageserver-types'; import { MarkupContent } from 'vscode-languageserver-types'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; /** * Setup the schema we are going to use with the language settings @@ -27,7 +29,7 @@ describe('Multiple Documents Validation Tests', () => { let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(__dirname, './fixtures/customMultipleSchemaSequences.json')); + const uri = toFsPath(path.join(import.meta.dirname, './fixtures/customMultipleSchemaSequences.json')); const fileMatch = ['*.yml', '*.yaml']; languageSettingsSetup = new ServiceSetup() .withHover() diff --git a/test/objects.test.ts b/test/objects.test.ts index 121ebe87a..05be3de81 100644 --- a/test/objects.test.ts +++ b/test/objects.test.ts @@ -2,7 +2,9 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { equals, convertErrorToTelemetryMsg } from '../src/languageservice/utils/objects'; + +import { describe, it } from 'node:test'; +import { equals, convertErrorToTelemetryMsg } from '../src/languageservice/utils/objects.js'; import assert from 'assert'; describe('Object Equals Tests', () => { diff --git a/test/paths.test.ts b/test/paths.test.ts index 440274f7a..334892566 100644 --- a/test/paths.test.ts +++ b/test/paths.test.ts @@ -1,8 +1,9 @@ +import { describe, it } from 'node:test'; import assert from 'assert'; import type { WorkspaceFolder } from 'vscode-languageserver-protocol'; import { join } from 'path'; -import { relativeToAbsolutePath, isRelativePath, workspaceFoldersChanged } from '../src/languageservice/utils/paths'; +import { relativeToAbsolutePath, isRelativePath, workspaceFoldersChanged } from '../src/languageservice/utils/paths.js'; import { URI } from 'vscode-uri'; class TestWorkspace { @@ -224,33 +225,33 @@ describe('File path tests', () => { describe('Path with mixed delimiters (Windows only)', () => { const path = 'some/strange\\but/functional\\path\\file.json'; - it('Recognises relative path "' + path + '"', function () { + it('Recognises relative path "' + path + '"', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert(isRelativePath(path)); } }); - it('Resolves "' + path + '" in single-root workspace', function () { + it('Resolves "' + path + '" in single-root workspace', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert.equal(ws1.resolve(path), 'file:///home/aFolder/some/strange/but/functional/path/file.json'); } }); - it('Resolves "' + path + '" in multi-root workspace', function () { + it('Resolves "' + path + '" in multi-root workspace', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert.equal(ws2.resolve(path), 'file:///usr/testuser/projects/workspace/some/strange/but/functional/path/file.json'); } }); - it('Resolves "' + path + '" in multi-root nested workspace', function () { + it('Resolves "' + path + '" in multi-root nested workspace', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert.equal(ws3.resolve(path), 'file:///c%3A/Users/testuser/dev/potatoes/some/strange/but/functional/path/file.json'); } diff --git a/test/schema.test.ts b/test/schema.test.ts index 746a9f815..03d0de987 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -1,26 +1,31 @@ +import { describe, it, before, beforeEach, afterEach } from 'node:test'; import assert from 'assert'; -import * as parser from '../src/languageservice/parser/yamlParser07'; -import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import type * as JsonSchema from '../src/languageservice/jsonSchema'; -import * as url from 'url'; +import * as parser from '../src/languageservice/parser/yamlParser07.js'; +import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; +import type * as JsonSchema from '../src/languageservice/jsonSchema.js'; import * as path from 'path'; -import { xhr } from 'request-light'; -import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService'; -import { MODIFICATION_ACTIONS } from '../src/languageservice/services/yamlSchemaService'; -import { EMPTY_SCHEMA_URL, DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; +import requestLight from 'request-light'; +import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService.js'; +import { MODIFICATION_ACTIONS } from '../src/languageservice/services/yamlSchemaService.js'; +import { EMPTY_SCHEMA_URL, DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; import { expect } from 'chai'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, setupTextDocument, TEST_URI } from './utils/testHelper'; -import type { LanguageService } from '../src'; -import { SchemaPriority } from '../src'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, setupTextDocument, TEST_URI } from './utils/testHelper.js'; +import type { LanguageService } from '../src/index.js'; +import { SchemaPriority } from '../src/index.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { Diagnostic, MarkupContent } from 'vscode-languageserver-types'; import { Position } from 'vscode-languageserver-types'; -import { getSchemaFromModeline } from '../src/languageservice/services/modelineUtil'; -import { getGroupVersionKindFromDocument } from '../src/languageservice/services/k8sSchemaUtil'; +import { getSchemaFromModeline } from '../src/languageservice/services/modelineUtil.js'; +import { getGroupVersionKindFromDocument } from '../src/languageservice/services/k8sSchemaUtil.js'; + +import schemaAssociationSample from './fixtures/sample-association.json' with { type: 'json' }; +import schemaStoreSample from './fixtures/sample-schemastore.json' with { type: 'json' }; +import schemaSettingsSample from './fixtures/sample-settings.json' with { type: 'json' }; +import schemaDefaultSnippetSample from './fixtures/defaultSnippets-const-if-else.json' with { type: 'json' }; const KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/all.json`; @@ -30,14 +35,14 @@ const requestServiceMock = function (uri: string): Promise { const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { - return url.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; const schemaRequestServiceForURL = async (uri: string): Promise => { const headers = { 'Accept-Encoding': 'gzip, deflate' }; try { - const response = await xhr({ url: uri, followRedirects: 5, headers }); + const response = await requestLight.xhr({ url: uri, followRedirects: 5, headers }); return response.responseText; } catch (error) { throw error.responseText || error.toString(); @@ -854,16 +859,9 @@ address: }); describe('Test schema priority', function () { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaAssociationSample = require(path.join(__dirname, './fixtures/sample-association.json')); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaStoreSample = require(path.join(__dirname, './fixtures/sample-schemastore.json')); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaSettingsSample = require(path.join(__dirname, './fixtures/sample-settings.json')); - const schemaModelineSample = path.join(__dirname, './fixtures/sample-modeline.json'); - const schemaDollarSample = path.join(__dirname, './fixtures/sample-dollar-schema.json'); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaDefaultSnippetSample = require(path.join(__dirname, './fixtures/defaultSnippets-const-if-else.json')); + const schemaModelineSample = path.join(import.meta.dirname, './fixtures/sample-modeline.json'); + const schemaDollarSample = path.join(import.meta.dirname, './fixtures/sample-dollar-schema.json'); + let languageSettingsSetup: ServiceSetup; beforeEach(() => { diff --git a/test/schema2019Validation.test.ts b/test/schema2019Validation.test.ts index 3ef1105a5..2bf767d80 100644 --- a/test/schema2019Validation.test.ts +++ b/test/schema2019Validation.test.ts @@ -2,16 +2,18 @@ * Copyright (c) IBM Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, beforeEach, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; describe('Validation Tests', () => { let languageSettingsSetup: ServiceSetup; diff --git a/test/schema2020Validation.test.ts b/test/schema2020Validation.test.ts index d49060272..48363067e 100644 --- a/test/schema2020Validation.test.ts +++ b/test/schema2020Validation.test.ts @@ -2,16 +2,18 @@ * Copyright (c) IBM Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, beforeEach, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; describe('Validation Tests', () => { let languageSettingsSetup: ServiceSetup; diff --git a/test/schemaRequestHandler.test.ts b/test/schemaRequestHandler.test.ts index 1c3301a27..c073b7090 100644 --- a/test/schemaRequestHandler.test.ts +++ b/test/schemaRequestHandler.test.ts @@ -3,10 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { schemaRequestHandler } from '../src/languageservice/services/schemaRequestHandler'; -import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler'; -import * as sinon from 'sinon'; -import * as request from 'request-light'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import { schemaRequestHandler } from '../src/languageservice/services/schemaRequestHandler.js'; +import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler.js'; +import type { SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; +import request from 'request-light'; import type { XHRResponse } from 'request-light'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; @@ -15,12 +18,12 @@ import sinonChai from 'sinon-chai'; const expect = chai.expect; chai.use(sinonChai); -import { testFileSystem } from './utils/testHelper'; +import { testFileSystem } from './utils/testHelper.js'; describe('Schema Request Handler Tests', () => { describe('schemaRequestHandler', () => { - const sandbox = sinon.createSandbox(); - let readFileStub: sinon.SinonStub; + const sandbox = createSandbox(); + let readFileStub: SinonStub; beforeEach(() => { readFileStub = sandbox.stub(testFileSystem, 'readFile'); @@ -71,8 +74,8 @@ describe('Schema Request Handler Tests', () => { }); describe('HTTP(S) schema requests', () => { - const sandbox = sinon.createSandbox(); - let xhrStub: sinon.SinonStub; + const sandbox = createSandbox(); + let xhrStub: SinonStub; const connection = {} as Connection; beforeEach(() => { @@ -152,8 +155,8 @@ describe('Schema Request Handler Tests', () => { }); describe('HTTP(S) schema request retries', () => { - const sandbox = sinon.createSandbox(); - let xhrStub: sinon.SinonStub; + const sandbox = createSandbox(); + let xhrStub: SinonStub; let delays: number[]; const connection = {} as Connection; diff --git a/test/schemaSelectionHandlers.test.ts b/test/schemaSelectionHandlers.test.ts index c84c7e95f..757275b08 100644 --- a/test/schemaSelectionHandlers.test.ts +++ b/test/schemaSelectionHandlers.test.ts @@ -2,24 +2,27 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import type { SinonSpy } from 'sinon'; +import { createSandbox } from 'sinon'; import * as chai from 'chai'; import sinonChai from 'sinon-chai'; -import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node'; -import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; -import { SchemaSelectionRequests } from '../src/requestTypes'; -import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper'; +import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; +import { SchemaSelectionRequests } from '../src/requestTypes.js'; +import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper.js'; const expect = chai.expect; chai.use(sinonChai); describe('Schema Selection Handlers', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: sinon.SinonSpy; + let requestServiceMock: SinonSpy; beforeEach(() => { requestServiceMock = sandbox.fake.resolves(undefined); diff --git a/test/schemaValidation.test.ts b/test/schemaValidation.test.ts index d38e367e0..b540d3008 100644 --- a/test/schemaValidation.test.ts +++ b/test/schemaValidation.test.ts @@ -2,10 +2,12 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; -import { createDiagnosticWithData, createExpectedError } from './utils/verifyError'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, after, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { createDiagnosticWithData, createExpectedError } from './utils/verifyError.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import { StringTypeError, BooleanTypeError, @@ -16,21 +18,22 @@ import { DuplicateKeyError, propertyIsNotAllowed, MissingRequiredPropWarning, -} from './utils/errorMessages'; +} from './utils/errorMessages.js'; import assert from 'assert'; -import * as path from 'path'; import type { Diagnostic } from 'vscode-languageserver-types'; import { DiagnosticSeverity, Position } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { IProblem } from '../src/languageservice/parser/schemaValidation/baseValidator'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; -import type { TestTelemetry } from './utils/testsTypes'; -import { ErrorCode } from '../src/languageservice/jsonLanguageTypes'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { IProblem } from '../src/languageservice/parser/schemaValidation/baseValidator.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; +import type { TestTelemetry } from './utils/testsTypes.js'; +import { ErrorCode } from '../src/languageservice/jsonLanguageTypes.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; + +import multipleSimilarSchemas from './fixtures/testMultipleSimilarSchema.json' with { type: 'json' }; const KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/all.json`; @@ -1769,10 +1772,8 @@ spec: schemaProvider.deleteSchema(sharedSchemaId); }); it('should distinguish types in error "Incorrect type (Expected "type1 | type2 | type3")"', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n '; const result = await parseSetup(content); @@ -1785,11 +1786,8 @@ spec: ]); }); it('should combine types in "Incorrect type error"', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - - schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n propA:'; const result = await parseSetup(content); @@ -1798,11 +1796,8 @@ spec: assert.strictEqual(result[2].source, 'yaml-schema: file:///sharedSchema.json | file:///default_schema_id.yaml'); }); it('should combine const value', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - - schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n constA:'; const result = await parseSetup(content); @@ -1811,11 +1806,8 @@ spec: assert.strictEqual(result[3].source, 'yaml-schema: file:///sharedSchema.json | file:///default_schema_id.yaml'); }); it('should distinguish types in error: "Missing property from multiple schemas"', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - - schemaProvider.addSchemaWithUri(sharedSchemaId, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(sharedSchemaId, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n someProp:'; const result = await parseSetup(content); diff --git a/test/settingsHandlers.test.ts b/test/settingsHandlers.test.ts index fb74bea38..54e624dd9 100644 --- a/test/settingsHandlers.test.ts +++ b/test/settingsHandlers.test.ts @@ -3,34 +3,42 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it, beforeEach, afterEach } from 'node:test'; + import * as chai from 'chai'; -import * as request from 'request-light'; -import * as sinon from 'sinon'; +import request from 'request-light'; +import type { SinonMock, SinonStub, SinonStubbedInstance } from 'sinon'; +import { createSandbox, spy, stub } from 'sinon'; import sinonChai from 'sinon-chai'; import type { Connection, RemoteClient, RemoteWorkspace } from 'vscode-languageserver'; import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; -import type { LanguageService, LanguageSettings, SchemaConfiguration } from '../src'; -import { SchemaPriority } from '../src'; -import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers'; -import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { EMPTY_SCHEMA_URL } from '../src/languageservice/utils/schemaUrls'; -import type { Telemetry } from '../src/languageservice/telemetry'; -import { SettingsState } from '../src/yamlSettings'; -import { TestCustomSchemaProvider, setupLanguageService, setupSchemaIDTextDocument, setupTextDocument } from './utils/testHelper'; -import { TestWorkspace } from './utils/testsTypes'; +import type { LanguageService, LanguageSettings, SchemaConfiguration } from '../src/index.js'; +import { SchemaPriority } from '../src/index.js'; +import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers.js'; +import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { EMPTY_SCHEMA_URL } from '../src/languageservice/utils/schemaUrls.js'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; +import { SettingsState } from '../src/yamlSettings.js'; +import { + TestCustomSchemaProvider, + setupLanguageService, + setupSchemaIDTextDocument, + setupTextDocument, +} from './utils/testHelper.js'; +import { TestWorkspace } from './utils/testsTypes.js'; const expect = chai.expect; chai.use(sinonChai); describe('Settings Handlers Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); const connection: Connection = {} as Connection; - let workspaceStub: sinon.SinonStubbedInstance; + let workspaceStub: SinonStubbedInstance; let languageService: LanguageService; let settingsState: SettingsState; - let validationHandler: sinon.SinonMock; - let xhrStub: sinon.SinonStub; + let validationHandler: SinonMock; + let xhrStub: SinonStub; beforeEach(() => { workspaceStub = sandbox.createStubInstance(TestWorkspace); @@ -266,7 +274,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings).deep.include({ @@ -300,7 +308,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); @@ -338,7 +346,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings.some((schema) => schema.uri === 'https://example.com/config.schema.json')).to.be @@ -363,7 +371,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings).deep.include({ @@ -401,7 +409,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings).deep.include({ @@ -418,7 +426,7 @@ describe('Settings Handlers Tests', () => { const testSchemaFileMatch = ['foo/*.yml']; async function configureSchemaSettingsTest(): Promise { - const telemetry = { send: sinon.stub(), sendError: sinon.stub() } as unknown as Telemetry; + const telemetry = { send: stub(), sendError: stub() } as unknown as Telemetry; const settingsHandler = new SettingsHandler( connection, languageService, @@ -426,7 +434,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, telemetry ); - const configureSpy = sinon.spy(languageService, 'configure'); + const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); return configureSpy.args[0][0]; @@ -547,7 +555,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - const configureSpy = sinon.spy(languageService, 'configure'); + const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); return configureSpy.args[0][0]; @@ -811,7 +819,7 @@ describe('Settings Handlers Tests', () => { workspaceStub.getConfiguration.resolves([{ schemaStore: { enable: false, url: 'http://shouldnot.activate' } }, {}, {}, {}]); - // const configureSpy = sinon.spy(languageService, 'configure'); + // const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); // configureSpy.restore(); expect(settingsState.schemaStoreEnabled).to.be.false; diff --git a/test/strings.test.ts b/test/strings.test.ts index fc5be71b4..09df40837 100644 --- a/test/strings.test.ts +++ b/test/strings.test.ts @@ -2,7 +2,9 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { startsWith, endsWith, convertSimple2RegExp, safeCreateUnicodeRegExp } from '../src/languageservice/utils/strings'; + +import { describe, it } from 'node:test'; +import { startsWith, endsWith, convertSimple2RegExp, safeCreateUnicodeRegExp } from '../src/languageservice/utils/strings.js'; import assert from 'assert'; import { expect } from 'chai'; diff --git a/test/telemetry.test.ts b/test/telemetry.test.ts index 879f59075..87e78f87b 100644 --- a/test/telemetry.test.ts +++ b/test/telemetry.test.ts @@ -2,11 +2,14 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import type { SinonStubbedInstance } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { checkSchemaURI } from '../src/languageservice/utils/schemaUrls'; -import { TelemetryImpl } from '../src/languageserver/telemetry'; +import { checkSchemaURI } from '../src/languageservice/utils/schemaUrls.js'; +import { TelemetryImpl } from '../src/languageserver/telemetry.js'; import { URI } from 'vscode-uri'; import type { Connection } from 'vscode-languageserver'; @@ -14,9 +17,9 @@ const expect = chai.expect; chai.use(sinonChai); describe('Telemetry Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); - let telemetry: sinon.SinonStubbedInstance; + let telemetry: SinonStubbedInstance; beforeEach(() => { const telemetryInstance = new TelemetryImpl({} as Connection); telemetry = sandbox.stub(telemetryInstance); diff --git a/test/textBuffer.test.ts b/test/textBuffer.test.ts index 385644484..b3de5af1b 100644 --- a/test/textBuffer.test.ts +++ b/test/textBuffer.test.ts @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TextBuffer } from '../src/languageservice/utils/textBuffer'; +import { describe, it } from 'node:test'; + +import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; import assert from 'assert'; diff --git a/test/utils/serviceSetup.ts b/test/utils/serviceSetup.ts index ac8333c8a..a163861c4 100644 --- a/test/utils/serviceSetup.ts +++ b/test/utils/serviceSetup.ts @@ -2,8 +2,8 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { LanguageSettings, SchemasSettings } from '../../src/languageservice/yamlLanguageService'; -import type { YamlVersion } from '../../src/languageservice/parser/yamlParser07'; +import type { LanguageSettings, SchemasSettings } from '../../src/languageservice/yamlLanguageService.js'; +import type { YamlVersion } from '../../src/languageservice/parser/yamlParser07.js'; export class ServiceSetup { /* diff --git a/test/utils/testHelper.ts b/test/utils/testHelper.ts index b74492441..e97e7a326 100644 --- a/test/utils/testHelper.ts +++ b/test/utils/testHelper.ts @@ -2,21 +2,22 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + import { promises as fs } from 'fs'; -import { ClientCapabilities } from '../../src/languageservice/jsonLanguageTypes'; +import { ClientCapabilities } from '../../src/languageservice/jsonLanguageTypes.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node'; -import { createConnection } from 'vscode-languageserver/node'; -import type { LanguageService, LanguageSettings } from '../../src'; -import type { LanguageHandlers } from '../../src/languageserver/handlers/languageHandlers'; -import type { ValidationHandler } from '../../src/languageserver/handlers/validationHandlers'; -import type { JSONSchema } from '../../src/languageservice/jsonSchema'; -import { yamlDocumentsCache } from '../../src/languageservice/parser/yaml-documents'; -import type { FileSystem } from '../../src/languageservice/services/schemaRequestHandler'; -import { schemaRequestHandler, workspaceContext } from '../../src/languageservice/services/schemaRequestHandler'; -import { YAMLServerInit } from '../../src/yamlServerInit'; -import { SettingsState } from '../../src/yamlSettings'; -import { TestTelemetry } from './testsTypes'; +import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node.js'; +import { createConnection } from 'vscode-languageserver/node.js'; +import type { LanguageService, LanguageSettings } from '../../src/index.js'; +import type { LanguageHandlers } from '../../src/languageserver/handlers/languageHandlers.js'; +import type { ValidationHandler } from '../../src/languageserver/handlers/validationHandlers.js'; +import type { JSONSchema } from '../../src/languageservice/jsonSchema.js'; +import { yamlDocumentsCache } from '../../src/languageservice/parser/yaml-documents.js'; +import type { FileSystem } from '../../src/languageservice/services/schemaRequestHandler.js'; +import { schemaRequestHandler, workspaceContext } from '../../src/languageservice/services/schemaRequestHandler.js'; +import { YAMLServerInit } from '../../src/yamlServerInit.js'; +import { SettingsState } from '../../src/yamlSettings.js'; +import { TestTelemetry } from './testsTypes.js'; import * as path from 'path'; export function toFsPath(str: unknown): string { @@ -85,14 +86,13 @@ export function setupLanguageService(languageSettings: LanguageSettings): TestLa const schemaRequestService = schemaRequestHandlerWrapper.bind(this, connection); const telemetry = new TestTelemetry(connection); const serverInit = new YAMLServerInit(connection, yamlSettings, workspaceContext, schemaRequestService, telemetry); - const __dirname = path.resolve(path.dirname(__filename), '..'); serverInit.connectionInitialized({ processId: null, capabilities: ClientCapabilities.LATEST as LSPClientCapabilities, rootUri: null, workspaceFolders: null, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, locale: 'en', }); diff --git a/test/utils/testsTypes.ts b/test/utils/testsTypes.ts index b580f9a45..cf874775a 100644 --- a/test/utils/testsTypes.ts +++ b/test/utils/testsTypes.ts @@ -18,8 +18,8 @@ import type { ServerCapabilities, } from 'vscode-languageserver-protocol'; import type { Connection, RemoteWorkspace } from 'vscode-languageserver'; -import { TelemetryImpl } from '../../src/languageserver/telemetry'; -import type { TelemetryEvent } from '../../src/languageservice/telemetry'; +import { TelemetryImpl } from '../../src/languageserver/telemetry.js'; +import type { TelemetryEvent } from '../../src/languageservice/telemetry.js'; /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ diff --git a/test/utils/verifyError.ts b/test/utils/verifyError.ts index ef0f10cb9..ee54f2732 100644 --- a/test/utils/verifyError.ts +++ b/test/utils/verifyError.ts @@ -11,7 +11,7 @@ import type { SymbolInformation, } from 'vscode-languageserver-types'; import { Diagnostic, DiagnosticSeverity, DiagnosticTag, DocumentSymbol, Range } from 'vscode-languageserver-types'; -import { ErrorCode } from '../../src/languageservice/jsonLanguageTypes'; +import { ErrorCode } from '../../src/languageservice/jsonLanguageTypes.js'; export function createExpectedError( message: string, diff --git a/test/yaml-documents.test.ts b/test/yaml-documents.test.ts index 2c3a80c9a..9688f4028 100644 --- a/test/yaml-documents.test.ts +++ b/test/yaml-documents.test.ts @@ -3,26 +3,29 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import type { SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { YamlDocuments } from '../src/languageservice/parser/yaml-documents'; -import { setupTextDocument } from './utils/testHelper'; -import * as yamlParser from '../src/languageservice/parser/yamlParser07'; +import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; +import { setupTextDocument } from './utils/testHelper.js'; +import type { ParserOptions } from '../src/languageservice/parser/yamlParser07.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml'; import { isMap, isScalar, isSeq } from 'yaml'; -import { TextBuffer } from '../src/languageservice/utils/textBuffer'; +import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; const expect = chai.expect; chai.use(sinonChai); describe('YAML Documents', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); describe('YAML Documents Cache Tests', () => { - let parseStub: sinon.SinonStub; + let parseStub: SinonStub; beforeEach(() => { - parseStub = sandbox.stub(yamlParser, 'parse'); + parseStub = sandbox.stub(); }); afterEach(() => { @@ -30,7 +33,7 @@ describe('YAML Documents', () => { }); it('should cache parsed document', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.returns({}); @@ -42,7 +45,7 @@ describe('YAML Documents', () => { }); it('should re parse document if document changed', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.onFirstCall().returns({}); @@ -57,7 +60,7 @@ describe('YAML Documents', () => { }); it('should invalidate cache if custom tags provided', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.onFirstCall().returns({}); parseStub.onSecondCall().returns({ foo: 'bar' }); @@ -70,7 +73,7 @@ describe('YAML Documents', () => { }); it('should use cache if custom tags are same', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.onFirstCall().returns({}); parseStub.onSecondCall().returns({ foo: 'bar' }); @@ -249,6 +252,6 @@ objB: }); }); -function getParserOptions(customTags: string[]): yamlParser.ParserOptions { +function getParserOptions(customTags: string[]): ParserOptions { return { customTags, yamlVersion: '1.2' }; } diff --git a/test/yamlCodeActions.test.ts b/test/yamlCodeActions.test.ts index 675ac1758..5f1753330 100644 --- a/test/yamlCodeActions.test.ts +++ b/test/yamlCodeActions.test.ts @@ -3,10 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions'; +import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions.js'; import { CodeAction, CodeActionContext, @@ -19,11 +21,11 @@ import { WorkspaceEdit, } from 'vscode-languageserver-types'; import type { ClientCapabilities, CodeActionParams } from 'vscode-languageserver'; -import { setupTextDocument, TEST_URI } from './utils/testHelper'; -import { createDiagnosticWithData, createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError'; -import { YamlCommands } from '../src/commands'; -import type { LanguageSettings } from '../src'; -import { ErrorCode } from '../src/languageservice/jsonLanguageTypes'; +import { setupTextDocument, TEST_URI } from './utils/testHelper.js'; +import { createDiagnosticWithData, createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError.js'; +import { YamlCommands } from '../src/commands.js'; +import type { LanguageSettings } from '../src/index.js'; +import { ErrorCode } from '../src/languageservice/jsonLanguageTypes.js'; const expect = chai.expect; chai.use(sinonChai); @@ -32,7 +34,7 @@ const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; const JSON_SCHEMA2_LOCAL = 'file://some/path/schema2.json'; describe('CodeActions Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); let clientCapabilities: ClientCapabilities; beforeEach(() => { diff --git a/test/yamlCodeLens.test.ts b/test/yamlCodeLens.test.ts index 537b5caef..c7f93b41b 100644 --- a/test/yamlCodeLens.test.ts +++ b/test/yamlCodeLens.test.ts @@ -2,32 +2,35 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import type { SinonStubbedInstance } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { YamlCodeLens } from '../src/languageservice/services/yamlCodeLens'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; -import { setupTextDocument } from './utils/testHelper'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; +import { YamlCodeLens } from '../src/languageservice/services/yamlCodeLens.js'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import { setupTextDocument } from './utils/testHelper.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; import type { Command } from 'vscode-languageserver-protocol'; import { CodeLens, Range } from 'vscode-languageserver-protocol'; import type { Connection } from 'vscode-languageserver'; -import { YamlCommands } from '../src/commands'; -import { TelemetryImpl } from '../src/languageserver/telemetry'; -import type { Telemetry } from '../src/languageservice/telemetry'; -import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; -import type { SingleYAMLDocument } from '../src/languageservice/parser/yaml-documents'; +import { YamlCommands } from '../src/commands.js'; +import { TelemetryImpl } from '../src/languageserver/telemetry.js'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; +import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { SingleYAMLDocument } from '../src/languageservice/parser/yaml-documents.js'; const expect = chai.expect; chai.use(sinonChai); describe('YAML CodeLens', () => { - const sandbox = sinon.createSandbox(); - let yamlSchemaService: sinon.SinonStubbedInstance; - let telemetryStub: sinon.SinonStubbedInstance; + const sandbox = createSandbox(); + let yamlSchemaService: SinonStubbedInstance; + let telemetryStub: SinonStubbedInstance; let telemetry: Telemetry; beforeEach(() => { diff --git a/test/yamlCommands.test.ts b/test/yamlCommands.test.ts index ee784e0e9..3e3a90190 100644 --- a/test/yamlCommands.test.ts +++ b/test/yamlCommands.test.ts @@ -3,11 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import type { SinonStub } from 'sinon'; +import { createSandbox, match } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { registerCommands } from '../src/languageservice/services/yamlCommands'; -import { commandExecutor } from '../src/languageserver/commandExecutor'; +import { registerCommands } from '../src/languageservice/services/yamlCommands.js'; +import { commandExecutor } from '../src/languageserver/commandExecutor.js'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; @@ -16,9 +19,9 @@ chai.use(sinonChai); describe('Yaml Commands', () => { const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); - let commandExecutorStub: sinon.SinonStub; + let commandExecutorStub: SinonStub; beforeEach(() => { commandExecutorStub = sandbox.stub(commandExecutor, 'registerCommand'); @@ -30,7 +33,7 @@ describe('Yaml Commands', () => { it('should register handler for "JumpToSchema" command', () => { registerCommands(commandExecutor, {} as Connection); - expect(commandExecutorStub).to.have.been.calledWithMatch(sinon.match('jumpToSchema'), sinon.match.func); + expect(commandExecutorStub).to.have.been.calledWithMatch(match('jumpToSchema'), match.func); }); it('JumpToSchema handler should call "showDocument"', async () => { diff --git a/test/yamlDefinition.test.ts b/test/yamlDefinition.test.ts index 18a7136bb..bd1cdd480 100644 --- a/test/yamlDefinition.test.ts +++ b/test/yamlDefinition.test.ts @@ -3,11 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupTextDocument, TEST_URI } from './utils/testHelper'; +import { describe, it } from 'node:test'; + +import { setupTextDocument, TEST_URI } from './utils/testHelper.js'; import { expect } from 'chai'; -import { YamlDefinition } from '../src/languageservice/services/yamlDefinition'; +import { YamlDefinition } from '../src/languageservice/services/yamlDefinition.js'; import { LocationLink, Position, Range } from 'vscode-languageserver-types'; -import type { Telemetry } from '../src/languageservice/telemetry'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; describe('YAML Definition', () => { it('should not provide definition for non anchor node', () => { diff --git a/test/yamlFolding.test.ts b/test/yamlFolding.test.ts index fee416a74..6cc985f47 100644 --- a/test/yamlFolding.test.ts +++ b/test/yamlFolding.test.ts @@ -3,11 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it } from 'node:test'; + import { expect } from 'chai'; import { FoldingRange } from 'vscode-languageserver-types'; -import { getFoldingRanges } from '../src/languageservice/services/yamlFolding'; -import type { FoldingRangesContext } from '../src/languageservice/yamlTypes'; -import { setupTextDocument, TEST_URI } from './utils/testHelper'; +import { getFoldingRanges } from '../src/languageservice/services/yamlFolding.js'; +import type { FoldingRangesContext } from '../src/languageservice/yamlTypes.js'; +import { setupTextDocument, TEST_URI } from './utils/testHelper.js'; const context: FoldingRangesContext = { rangeLimit: 10_0000 }; diff --git a/test/yamlLanguageService.test.ts b/test/yamlLanguageService.test.ts index 1e31d8db6..143f82909 100644 --- a/test/yamlLanguageService.test.ts +++ b/test/yamlLanguageService.test.ts @@ -2,12 +2,14 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before } from 'node:test'; import { assert } from 'chai'; import type { Position, TextDocument } from 'vscode-languageserver-textdocument'; -import type { LanguageService, SchemaRequestService, WorkspaceContextService } from '../src'; -import { getLanguageService } from '../src'; -import { workspaceContext } from '../src/languageservice/services/schemaRequestHandler'; -import { caretPosition, setupSchemaIDTextDocument } from './utils/testHelper'; +import type { LanguageService, SchemaRequestService, WorkspaceContextService } from '../src/index.js'; +import { getLanguageService } from '../src/index.js'; +import { workspaceContext } from '../src/languageservice/services/schemaRequestHandler.js'; +import { caretPosition, setupSchemaIDTextDocument } from './utils/testHelper.js'; /** * Builds a simple schema request service diff --git a/test/yamlOnTypeFormatting.test.ts b/test/yamlOnTypeFormatting.test.ts index e42ea779e..9ac12fb00 100644 --- a/test/yamlOnTypeFormatting.test.ts +++ b/test/yamlOnTypeFormatting.test.ts @@ -2,11 +2,13 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from 'node:test'; import { expect } from 'chai'; import type { DocumentOnTypeFormattingParams } from 'vscode-languageserver-protocol'; import { FormattingOptions, Position, Range, TextEdit } from 'vscode-languageserver-types'; -import { doDocumentOnTypeFormatting } from '../src/languageservice/services/yamlOnTypeFormatting'; -import { setupTextDocument } from './utils/testHelper'; +import { doDocumentOnTypeFormatting } from '../src/languageservice/services/yamlOnTypeFormatting.js'; +import { setupTextDocument } from './utils/testHelper.js'; function createParams(position: Position): DocumentOnTypeFormattingParams { return { diff --git a/test/yamlParser.test.ts b/test/yamlParser.test.ts index 940820fc6..ab1f349cb 100644 --- a/test/yamlParser.test.ts +++ b/test/yamlParser.test.ts @@ -2,12 +2,14 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from 'node:test'; import assert from 'assert'; import { expect } from 'chai'; -import type { ArrayASTNode, ObjectASTNode, PropertyASTNode } from '../src/languageservice/jsonLanguageTypes'; -import type { YAMLDocument } from './../src/languageservice/parser/yamlParser07'; -import { parse } from './../src/languageservice/parser/yamlParser07'; -import { aliasDepth } from '../src/languageservice/parser/ast-converter'; +import type { ArrayASTNode, ObjectASTNode, PropertyASTNode } from '../src/languageservice/jsonLanguageTypes.js'; +import type { YAMLDocument } from './../src/languageservice/parser/yamlParser07.js'; +import { parse } from './../src/languageservice/parser/yamlParser07.js'; +import { aliasDepth } from '../src/languageservice/parser/ast-converter.js'; describe('YAML parser', () => { describe('YAML parser', function () { diff --git a/test/yamlRename.test.ts b/test/yamlRename.test.ts index 248e1fe2b..36f53908e 100644 --- a/test/yamlRename.test.ts +++ b/test/yamlRename.test.ts @@ -1,7 +1,8 @@ +import { describe, it } from 'node:test'; import { expect } from 'chai'; import type { TextEdit } from 'vscode-languageserver-types'; import { Position } from 'vscode-languageserver-types'; -import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper'; +import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; function applyEdits(document: TextDocument, edits: TextEdit[]): string { diff --git a/test/yamlSchema.test.ts b/test/yamlSchema.test.ts index 39aee28a6..6a65cc311 100644 --- a/test/yamlSchema.test.ts +++ b/test/yamlSchema.test.ts @@ -2,9 +2,11 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import * as url from 'url'; -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; +import type { SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; import * as chai from 'chai'; import sinonChai from 'sinon-chai'; @@ -13,13 +15,13 @@ chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { - return url.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; describe('YAML Schema', () => { - const sandbox = sinon.createSandbox(); - let requestServiceStub: sinon.SinonStub; + const sandbox = createSandbox(); + let requestServiceStub: SinonStub; beforeEach(() => { requestServiceStub = sandbox.stub(); }); diff --git a/test/yamlSchemaService.test.ts b/test/yamlSchemaService.test.ts index 56f69ca14..cd24dd7e3 100644 --- a/test/yamlSchemaService.test.ts +++ b/test/yamlSchemaService.test.ts @@ -2,21 +2,23 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, beforeEach, afterEach } from 'node:test'; import * as chai from 'chai'; import * as JSONC from 'jsonc-parser'; import * as path from 'path'; -import * as sinon from 'sinon'; +import type { SinonFakeTimers, SinonSpy, SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; -import * as url from 'url'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { URI } from 'vscode-uri'; import * as YAML from 'yaml'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; -import { parse } from '../src/languageservice/parser/yamlParser07'; -import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION, getSchemaUrls } from '../src/languageservice/utils/schemaUrls'; -import { SchemaPriority } from '../src/languageservice/yamlLanguageService'; -import { SettingsState } from '../src/yamlSettings'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; +import { parse } from '../src/languageservice/parser/yamlParser07.js'; +import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION, getSchemaUrls } from '../src/languageservice/utils/schemaUrls.js'; +import { SchemaPriority } from '../src/languageservice/yamlLanguageService.js'; +import { SettingsState } from '../src/yamlSettings.js'; const BASE_KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/`; const KUBERNETES_SCHEMA_URL = BASE_KUBERNETES_SCHEMA_URL + 'all.json'; @@ -25,18 +27,18 @@ const expect = chai.expect; chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { - return url.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; describe('YAML Schema Service', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); afterEach(() => { sandbox.restore(); }); describe('Schema for resource', () => { - let requestServiceMock: sinon.SinonSpy; + let requestServiceMock: SinonSpy; beforeEach(() => { requestServiceMock = sandbox.fake.resolves(undefined); @@ -125,7 +127,10 @@ describe('YAML Schema Service', () => { expect(requestServiceMock).calledTwice; if (process.platform === 'win32') { - const driveLetter = path.parse(__dirname).root.split(':')[0].toLowerCase(); + const driveLetter = path + .parse(import.meta.dirname) + .root.split(':')[0] + .toLowerCase(); expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json`); expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json#/definitions/schemaArray`); } else { @@ -139,8 +144,8 @@ describe('YAML Schema Service', () => { it('should resolve encoded characters in a relative modeline schema path', async () => { const content = `# yaml-language-server: $schema=./encoded%20schema.json\nfoo: bar`; const yamlDock = parse(content); - const resource = URI.file(path.join(__dirname, 'test.yaml')).toString(); - const expectedSchemaPath = URI.parse(URI.file(path.join(__dirname, 'encoded schema.json')).toString()).fsPath; + const resource = URI.file(path.join(import.meta.dirname, 'test.yaml')).toString(); + const expectedSchemaPath = URI.parse(URI.file(path.join(import.meta.dirname, 'encoded schema.json')).toString()).fsPath; requestServiceMock = sandbox.fake.resolves( JSON.stringify({ type: 'object', @@ -159,13 +164,13 @@ describe('YAML Schema Service', () => { }); it('should resolve encoded characters in an absolute modeline schema path', async () => { - const rootPath = path.parse(__dirname).root.replace(/\\/g, '/'); + const rootPath = path.parse(import.meta.dirname).root.replace(/\\/g, '/'); const encodedSchemaPath = path.posix.join(rootPath, 'encoded%20schema.json'); const content = `# yaml-language-server: $schema=${encodedSchemaPath}\nfoo: bar`; const yamlDock = parse(content); - const resource = URI.file(path.join(__dirname, 'test.yaml')).toString(); + const resource = URI.file(path.join(import.meta.dirname, 'test.yaml')).toString(); const expectedSchemaPath = URI.parse( - URI.file(path.join(path.parse(__dirname).root, 'encoded schema.json')).toString() + URI.file(path.join(path.parse(import.meta.dirname).root, 'encoded schema.json')).toString() ).fsPath; requestServiceMock = sandbox.fake.resolves( JSON.stringify({ @@ -1579,7 +1584,7 @@ properties: describe('Caching of failed schema loads', () => { const SCHEMA_URI = 'https://example.com/schema.json'; const schemaContent = JSON.stringify({ type: 'object', properties: { foo: { type: 'string' } } }); - let clock: sinon.SinonFakeTimers; + let clock: SinonFakeTimers; beforeEach(() => { clock = sandbox.useFakeTimers({ now: Date.now(), shouldAdvanceTime: false }); @@ -1589,7 +1594,7 @@ properties: clock.restore(); }); - const createService = (requestService: sinon.SinonStub): SchemaService.YAMLSchemaService => { + const createService = (requestService: SinonStub): SchemaService.YAMLSchemaService => { const service = new SchemaService.YAMLSchemaService(requestService, workspaceContext); service.registerExternalSchema(SCHEMA_URI, ['*.yaml']); return service; diff --git a/test/yamlSelectionRanges.test.ts b/test/yamlSelectionRanges.test.ts index 625f82ad8..25f7139a5 100644 --- a/test/yamlSelectionRanges.test.ts +++ b/test/yamlSelectionRanges.test.ts @@ -1,7 +1,8 @@ +import { describe, it } from 'node:test'; import { expect } from 'chai'; import type { Position, Range, SelectionRange } from 'vscode-languageserver-types'; -import { setupTextDocument } from './utils/testHelper'; -import { getSelectionRanges } from '../src/languageservice/services/yamlSelectionRanges'; +import { setupTextDocument } from './utils/testHelper.js'; +import { getSelectionRanges } from '../src/languageservice/services/yamlSelectionRanges.js'; function isRangesEqual(range1: Range, range2: Range): boolean { return ( diff --git a/test/yamlValidation.test.ts b/test/yamlValidation.test.ts index fbf710f48..e0b0ef625 100644 --- a/test/yamlValidation.test.ts +++ b/test/yamlValidation.test.ts @@ -2,16 +2,18 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before, afterEach } from 'node:test'; import type { Diagnostic } from 'vscode-languageserver-types'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import { ServiceSetup } from './utils/serviceSetup'; -import { setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import { setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import { expect } from 'chai'; -import * as sinon from 'sinon'; -import { createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError'; +import { createSandbox } from 'sinon'; +import { createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError.js'; type ValidationHandlerWithConnection = { connection: { @@ -22,7 +24,7 @@ type ValidationHandlerWithConnection = { }; describe('YAML Validation Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); let languageSettingsSetup: ServiceSetup; let validationHandler: ValidationHandler; let yamlSettings: SettingsState; diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index 1499520fb..000000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "lib": ["WebWorker"], - "module": "esnext", - "moduleResolution": "bundler", - "outDir": "./lib/esm", - "rootDir": "./src" - }, - "include": ["src"] -} diff --git a/tsconfig.json b/tsconfig.json index c138cce25..044e1bdb1 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "strictFunctionTypes": false, "strictNullChecks": false, "target": "es2020", - "types": ["mocha", "node"], + "types": ["node"], "useUnknownInCatchVariables": false }, "include": ["src", "test"], diff --git a/tsconfig.umd.json b/tsconfig.umd.json deleted file mode 100644 index 5ad269ac6..000000000 --- a/tsconfig.umd.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "ignoreDeprecations": "6.0", - "lib": ["webworker"], - "module": "umd", - "moduleResolution": "node10", - "outDir": "./lib/umd", - "rootDir": "./src" - }, - "include": ["src"] -} From 25bc8477a36ad609804c698d4454b72954b95c8e Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Mon, 5 Oct 2026 22:53:43 -0400 Subject: [PATCH 02/18] remove ts-node Signed-off-by: Morgan Chang --- package-lock.json | 158 --------------------------------- package.json | 6 +- test/customTags.test.ts | 1 - test/defaultSnippets.test.ts | 8 +- test/integration.test.ts | 1 - test/multipleDocuments.test.ts | 9 +- test/schema.test.ts | 17 ++-- 7 files changed, 24 insertions(+), 176 deletions(-) diff --git a/package-lock.json b/package-lock.json index e461ff72c..8c098a1d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,6 @@ "rimraf": "^3.0.2", "sinon": "^22.1.0", "sinon-chai": "^3.5.0", - "ts-node": "^10.0.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" }, @@ -60,30 +59,6 @@ "node": ">=18" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@emnapi/core": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", @@ -804,34 +779,6 @@ "type-detect": "^4.1.0" } }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, "node_modules/@tybys/wasm-util": { "version": "0.10.2", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz", @@ -1541,19 +1488,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/ajv": { "version": "8.18.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", @@ -1619,13 +1553,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1853,13 +1780,6 @@ "dev": true, "license": "MIT" }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, - "license": "MIT" - }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2859,13 +2779,6 @@ "get-func-name": "^2.0.1" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, "node_modules/minimatch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", @@ -3546,60 +3459,6 @@ "typescript": ">=4.8.4" } }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/ts-node/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -3744,13 +3603,6 @@ "dev": true, "license": "MIT" }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -3996,16 +3848,6 @@ "node": "^20.19.0 || ^22.12.0 || >=23" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 02178242e..1b6f82af2 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "rimraf": "^3.0.2", "sinon": "^22.1.0", "sinon-chai": "^3.5.0", - "ts-node": "^10.0.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" }, @@ -69,7 +68,7 @@ "clean": "rimraf out/server", "compile": "tsc -p .", "watch": "tsc --watch -p .", - "test": "node --enable-source-maps --experimental-loader=ts-node/esm --test test/*.test.ts", + "test": "npm run compile && node --enable-source-maps --test out/server/test/*.test.js", "coveralls": "c8 --reporter=lcov --reporter=text npm test", "lint": "eslint --max-warnings 0", "lint-ci": "eslint --max-warnings 0 -f @microsoft/eslint-formatter-sarif -o eslint-result.sarif", @@ -85,6 +84,7 @@ "exclude": [ "**/*.d.ts" ], - "all": true + "all": true, + "exclude-after-remap": true } } diff --git a/test/customTags.test.ts b/test/customTags.test.ts index 947716103..8884b226e 100644 --- a/test/customTags.test.ts +++ b/test/customTags.test.ts @@ -12,7 +12,6 @@ import type { Diagnostic } from 'vscode-languageserver-types'; import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; -// Defines a Mocha test describe to group tests of similar kind together describe('Custom Tag tests Tests', () => { let languageSettingsSetup: ServiceSetup; let languageService: LanguageService; diff --git a/test/defaultSnippets.test.ts b/test/defaultSnippets.test.ts index 195046bc0..daa7d3add 100644 --- a/test/defaultSnippets.test.ts +++ b/test/defaultSnippets.test.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { describe, it, before } from 'node:test'; -import { toFsPath, setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper.js'; +import { setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper.js'; import assert from 'assert'; -import * as path from 'path'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; import type { SettingsState } from '../src/yamlSettings.js'; @@ -14,16 +13,19 @@ import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { CompletionList, TextEdit } from 'vscode-languageserver-types'; import { expect } from 'chai'; +import defaultSnippetsSchema from './fixtures/defaultSnippets.json' with { type: 'json' }; + describe('Default Snippet Tests', () => { let languageHandler: LanguageHandlers; let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(import.meta.dirname, './fixtures/defaultSnippets.json')); + const uri = new URL('./fixtures/defaultSnippets.json', import.meta.url).href; const fileMatch = ['*.yml', '*.yaml']; const languageSettingsSetup = new ServiceSetup().withCompletion().withSchemaFileMatch({ fileMatch, uri, + schema: defaultSnippetsSchema, }); const { languageHandler: langHandler, yamlSettings: settings } = setupLanguageService(languageSettingsSetup.languageSettings); languageHandler = langHandler; diff --git a/test/integration.test.ts b/test/integration.test.ts index 94c9944e9..e84669ca4 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -14,7 +14,6 @@ import type { SettingsState } from '../src/yamlSettings.js'; import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; -// Defines a Mocha test describe to group tests of similar kind together describe('Kubernetes Integration Tests', () => { let languageSettingsSetup: ServiceSetup; let languageHandler: LanguageHandlers; diff --git a/test/multipleDocuments.test.ts b/test/multipleDocuments.test.ts index 3476975f9..f921e265d 100644 --- a/test/multipleDocuments.test.ts +++ b/test/multipleDocuments.test.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { describe, it, before } from 'node:test'; -import * as path from 'path'; -import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper.js'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; import assert from 'assert'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic, Hover } from 'vscode-languageserver-types'; @@ -16,11 +15,12 @@ import type { LanguageService } from '../src/languageservice/yamlLanguageService import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import multipleDocumentsSchema from './fixtures/customMultipleSchemaSequences.json' with { type: 'json' }; + /** * Setup the schema we are going to use with the language settings */ -// Defines a Mocha test describe to group tests of similar kind together describe('Multiple Documents Validation Tests', () => { let languageSettingsSetup: ServiceSetup; let languageHandler: LanguageHandlers; @@ -29,7 +29,7 @@ describe('Multiple Documents Validation Tests', () => { let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(import.meta.dirname, './fixtures/customMultipleSchemaSequences.json')); + const uri = new URL('./fixtures/customMultipleSchemaSequences.json', import.meta.url).href; const fileMatch = ['*.yml', '*.yaml']; languageSettingsSetup = new ServiceSetup() .withHover() @@ -38,6 +38,7 @@ describe('Multiple Documents Validation Tests', () => { .withSchemaFileMatch({ fileMatch, uri, + schema: multipleDocumentsSchema, }) .withCustomTags(['!Test', '!Ref sequence']); const { diff --git a/test/schema.test.ts b/test/schema.test.ts index 03d0de987..ac6273e7e 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -3,7 +3,6 @@ import assert from 'assert'; import * as parser from '../src/languageservice/parser/yamlParser07.js'; import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; import type * as JsonSchema from '../src/languageservice/jsonSchema.js'; -import * as path from 'path'; import requestLight from 'request-light'; import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService.js'; import { MODIFICATION_ACTIONS } from '../src/languageservice/services/yamlSchemaService.js'; @@ -27,6 +26,9 @@ import schemaStoreSample from './fixtures/sample-schemastore.json' with { type: import schemaSettingsSample from './fixtures/sample-settings.json' with { type: 'json' }; import schemaDefaultSnippetSample from './fixtures/defaultSnippets-const-if-else.json' with { type: 'json' }; +import schemaModelineSample from './fixtures/sample-modeline.json' with { type: 'json' }; +import schemaDollarSample from './fixtures/sample-dollar-schema.json' with { type: 'json' }; + const KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/all.json`; const requestServiceMock = function (uri: string): Promise { @@ -859,13 +861,16 @@ address: }); describe('Test schema priority', function () { - const schemaModelineSample = path.join(import.meta.dirname, './fixtures/sample-modeline.json'); - const schemaDollarSample = path.join(import.meta.dirname, './fixtures/sample-dollar-schema.json'); + const modelineSchemaUri = new URL('./fixtures/sample-modeline.json', import.meta.url).href; + const dollarSchemaUri = new URL('./fixtures/sample-dollar-schema.json', import.meta.url).href; let languageSettingsSetup: ServiceSetup; beforeEach(() => { - languageSettingsSetup = new ServiceSetup().withCompletion(); + languageSettingsSetup = new ServiceSetup() + .withCompletion() + .withSchemaFileMatch({ uri: modelineSchemaUri, fileMatch: [], schema: schemaModelineSample }) + .withSchemaFileMatch({ uri: dollarSchemaUri, fileMatch: [], schema: schemaDollarSample }); }); for (const { description, uri } of [ @@ -923,7 +928,7 @@ address: languageService.configure(languageSettingsSetup.languageSettings); languageService.registerCustomSchemaProvider((uri: string) => Promise.resolve(uri)); const testTextDocument = setupTextDocument( - `# yaml-language-server: $schema=${schemaModelineSample}\n$schema: ${schemaDollarSample}\n\n` + `# yaml-language-server: $schema=${modelineSchemaUri}\n$schema: ${dollarSchemaUri}\n\n` ); const result = await languageService.doComplete(testTextDocument, Position.create(1, 0), false); assert.strictEqual(result.items.length, 1); @@ -952,7 +957,7 @@ address: }); languageService.configure(languageSettingsSetup.languageSettings); languageService.registerCustomSchemaProvider((uri: string) => Promise.resolve(uri)); - const testTextDocument = setupTextDocument(`$schema: ${schemaDollarSample}\n\n`); + const testTextDocument = setupTextDocument(`$schema: ${dollarSchemaUri}\n\n`); const result = await languageService.doComplete(testTextDocument, Position.create(1, 0), false); assert.strictEqual(result.items.length, 1); assert.strictEqual(result.items[0].label, 'dollar-schema'); From b87ec01eae1eda4c3204d21e8eca27759fedb1ab Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Tue, 6 Oct 2026 11:26:43 -0400 Subject: [PATCH 03/18] update launch.json and tasks.json Signed-off-by: Morgan Chang --- .vscode/launch.json | 22 +++++++++++++--------- .vscode/tasks.json | 6 ++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e4f816d53..459055101 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,37 +8,41 @@ "request": "attach", "port": 6009, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/out/server/**/*.ts"], + "outFiles": ["${workspaceRoot}/out/server/**/*.js"], "protocol": "inspector", "trace": true, "preLaunchTask": "watch typescript", }, - // A launch configuration that compiles the server and runs mocha unit tests + // A launch configuration that compiles the server and runs tests with Node's test runner { "type": "node", "request": "launch", "name": "Launch Tests", - "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", - "args": ["-u", "bdd", "--timeout", "999999", "--colors", "-r", "ts-node/register", "${workspaceRoot}/test/*.test.ts"], - "preLaunchTask": "watch typescript", + "runtimeArgs": ["--enable-source-maps", "--test"], + "args": ["${workspaceFolder}/out/server/test/*.test.js"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "npm: compile", "resolveSourceMapLocations": [ "${workspaceFolder}/**", "!**/node_modules/**" ], + "console": "integratedTerminal", }, - // A launch configuration that compiles the server and runs mocha unit tests + // A launch configuration that compiles the server and runs the currently open test file { "type": "node", "request": "launch", "name": "Launch Single File Tests", - "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", - "args": ["-u", "bdd", "--timeout", "999999", "--colors", "-r", "ts-node/register", "${workspaceRoot}/${relativeFile}"], - "preLaunchTask": "watch typescript", + "runtimeArgs": ["--enable-source-maps", "--test"], + "args": ["${workspaceFolder}/out/server/test/${fileBasenameNoExtension}.js"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "npm: compile", "sourceMaps": true, "resolveSourceMapLocations": [ "${workspaceFolder}/**", "!**/node_modules/**" ], + "console": "integratedTerminal", } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5c223ea12..46f02e762 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -17,6 +17,12 @@ "isDefault": true } }, + { + "type": "npm", + "script": "compile", + "problemMatcher": ["$tsc"], + "label": "npm: compile" + }, { "type": "npm", "script": "lint", From 9fdf4abca24ca7c56f2b5455c069b1e0194287e2 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Wed, 7 Oct 2026 13:51:54 -0400 Subject: [PATCH 04/18] upgrade vscode-languageserver and remove sinon and sinon-chai Signed-off-by: Morgan Chang --- package-lock.json | 145 +----- package.json | 8 +- .../handlers/schemaSelectionHandlers.ts | 2 +- .../services/yamlCodeActions.ts | 2 +- .../services/yamlValidation.ts | 2 +- src/server.ts | 4 +- src/webworker/yamlServerMain.ts | 2 +- test/bundlel10n.test.ts | 4 +- test/formatter.test.ts | 12 +- test/invalid-metaschema.test.ts | 21 +- test/schema2019Validation.test.ts | 6 +- test/schema2020Validation.test.ts | 14 +- test/schemaRequestHandler.test.ts | 97 ++-- test/schemaSelectionHandlers.test.ts | 47 +- test/schemaValidation.test.ts | 30 +- test/settingsHandlers.test.ts | 392 +++++++++------ test/telemetry.test.ts | 30 +- test/utils/testHelper.ts | 9 +- test/utils/testsTypes.ts | 1 + test/yaml-documents.test.ts | 40 +- test/yamlCodeActions.test.ts | 11 +- test/yamlCodeLens.test.ts | 67 +-- test/yamlCommands.test.ts | 104 ++-- test/yamlSchema.test.ts | 46 +- test/yamlSchemaService.test.ts | 457 +++++++++++------- test/yamlValidation.test.ts | 8 +- 26 files changed, 820 insertions(+), 741 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c098a1d1..59379000c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,9 +17,9 @@ "picomatch": "^4.0.4", "prettier": "^3.8.1", "request-light": "^0.5.7", - "vscode-languageserver": "^9.0.0", + "vscode-languageserver": "^10.1.2", "vscode-languageserver-textdocument": "^1.0.1", - "vscode-languageserver-types": "~3.17.5", + "vscode-languageserver-types": "^3.18.4", "vscode-uri": "^3.0.2", "yaml": "2.8.3" }, @@ -31,8 +31,6 @@ "@types/chai": "^4.2.12", "@types/node": "22.x", "@types/picomatch": "^4.0.3", - "@types/sinon": "^22.0.0", - "@types/sinon-chai": "^3.2.5", "@typescript-eslint/parser": "^8.59.4", "c8": "^12.0.0", "chai": "^4.2.0", @@ -40,8 +38,6 @@ "eslint-plugin-import-x": "^4.0.0", "eslint-plugin-prettier": "^5.0.0", "rimraf": "^3.0.2", - "sinon": "^22.1.0", - "sinon-chai": "^3.5.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" }, @@ -738,47 +734,6 @@ "url": "https://opencollective.com/pkgr" } }, - "node_modules/@sinonjs/commons": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", - "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "type-detect": "4.0.8" - } - }, - "node_modules/@sinonjs/commons/node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/@sinonjs/fake-timers": { - "version": "15.4.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-15.4.0.tgz", - "integrity": "sha512-DsG+8/LscQIQg68J6Ef3dv10u6nVyetYn923s3/sus5eaGfTo1of5WMZSLf0UJc9KDuKPilPH0UDJCjvNbDNCA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^3.0.1" - } - }, - "node_modules/@sinonjs/samsam": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-10.0.2.tgz", - "integrity": "sha512-8lVwD1Df1BmzoaOLhMcGGcz/Jyr5QY2KSB75/YK1QgKzoabTeLdIVyhXNZK9ojfSKSdirbXqdbsXXqP9/Ve8+A==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^3.0.1", - "type-detect": "^4.1.0" - } - }, "node_modules/@tybys/wasm-util": { "version": "0.10.2", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz", @@ -842,34 +797,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/sinon": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-22.0.0.tgz", - "integrity": "sha512-TDbVpbccc2HfiqHR09Argj3mHV1KMW7sCCKj52fsl8lbRLkEn7fB1966EWhOKWUBcqfBueZuPoA7/OK1CKiy3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/sinonjs__fake-timers": "*" - } - }, - "node_modules/@types/sinon-chai": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.12.tgz", - "integrity": "sha512-9y0Gflk3b0+NhQZ/oxGtaAJDvRywCa5sIyaVnounqLvmf93yBF4EgIRspePtkMs3Tr844nCclYMlcCNmLCvjuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/chai": "*", - "@types/sinon": "*" - } - }, - "node_modules/@types/sinonjs__fake-timers": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.5.tgz", - "integrity": "sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==", - "dev": true, - "license": "MIT" - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.61.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.61.0.tgz", @@ -1833,16 +1760,6 @@ "dev": true, "license": "MIT" }, - "node_modules/diff": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz", - "integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -3211,34 +3128,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/sinon": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-22.1.0.tgz", - "integrity": "sha512-n1ajF2rBWMTtEwbKcw4UdFg4nCnDdq/U6RDoxtOd7oapOlRoJ5ynwFx60owROyhDpA9QhMZi0pCO/xtmwFjG7w==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^3.0.1", - "@sinonjs/fake-timers": "^15.4.0", - "@sinonjs/samsam": "^10.0.2", - "diff": "^9.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/sinon" - } - }, - "node_modules/sinon-chai": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz", - "integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==", - "dev": true, - "license": "(BSD-2-Clause OR WTFPL)", - "peerDependencies": { - "chai": "^4.0.0", - "sinon": ">=4.0.0" - } - }, "node_modules/stable-hash-x": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/stable-hash-x/-/stable-hash-x-0.2.0.tgz", @@ -3626,34 +3515,34 @@ "license": "MIT" }, "node_modules/vscode-jsonrpc": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", - "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-9.0.3.tgz", + "integrity": "sha512-qETYf9PCl1lVfwR+oBmMfc4vP2nqLNA35ABxorw3j06+xlKRgDVxbLgKm4Y/xPL0YWdeDjLoI4ImICIT3nB0zQ==", "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageserver": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz", - "integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-10.1.2.tgz", + "integrity": "sha512-pXPWde3RytdeBVEs6PulOOT5OpeXC5GkWRpcT11f5rNn41jviQsAYPyAqJ/0oVGETQLKPJtYbHNiMPlfLb0NTQ==", "license": "MIT", "dependencies": { - "vscode-languageserver-protocol": "3.17.5" + "vscode-languageserver-protocol": "3.18.4" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz", - "integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==", + "version": "3.18.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.18.4.tgz", + "integrity": "sha512-CCXbyr99dafRJzJH/0Ryk7ly5T8XPmSR0//OuF2w4m+9JiOin7zcAT5iET8GRE7Z9taFBejb3GbM0a0mbjdbrg==", "license": "MIT", "dependencies": { - "vscode-jsonrpc": "8.2.0", - "vscode-languageserver-types": "3.17.5" + "vscode-jsonrpc": "9.0.3", + "vscode-languageserver-types": "3.18.4" } }, "node_modules/vscode-languageserver-textdocument": { @@ -3663,9 +3552,9 @@ "license": "MIT" }, "node_modules/vscode-languageserver-types": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", - "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==", + "version": "3.18.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.18.4.tgz", + "integrity": "sha512-nQsacoiijvl0fRf2q28uFDrAVwRhdCa3QveiF7/CX0r18mLR5FU/1WskSsCKOjmEbtteKUnY8x8Yzxop+k0zwg==", "license": "MIT" }, "node_modules/vscode-uri": { diff --git a/package.json b/package.json index 1b6f82af2..65334dc14 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,9 @@ "picomatch": "^4.0.4", "prettier": "^3.8.1", "request-light": "^0.5.7", - "vscode-languageserver": "^9.0.0", + "vscode-languageserver": "^10.1.2", "vscode-languageserver-textdocument": "^1.0.1", - "vscode-languageserver-types": "~3.17.5", + "vscode-languageserver-types": "^3.18.4", "vscode-uri": "^3.0.2", "yaml": "2.8.3" }, @@ -50,8 +50,6 @@ "@types/chai": "^4.2.12", "@types/node": "22.x", "@types/picomatch": "^4.0.3", - "@types/sinon": "^22.0.0", - "@types/sinon-chai": "^3.2.5", "@typescript-eslint/parser": "^8.59.4", "c8": "^12.0.0", "chai": "^4.2.0", @@ -59,8 +57,6 @@ "eslint-plugin-import-x": "^4.0.0", "eslint-plugin-prettier": "^5.0.0", "rimraf": "^3.0.2", - "sinon": "^22.1.0", - "sinon-chai": "^3.5.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" }, diff --git a/src/languageserver/handlers/schemaSelectionHandlers.ts b/src/languageserver/handlers/schemaSelectionHandlers.ts index d721de11e..7ba9c1dbb 100644 --- a/src/languageserver/handlers/schemaSelectionHandlers.ts +++ b/src/languageserver/handlers/schemaSelectionHandlers.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Connection } from 'vscode-languageserver/node.js'; +import type { Connection } from 'vscode-languageserver/node'; import type { JSONSchema } from '../../languageservice/jsonSchema.js'; import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents.js'; import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService.js'; diff --git a/src/languageservice/services/yamlCodeActions.ts b/src/languageservice/services/yamlCodeActions.ts index eae7dce5a..c96d8991b 100644 --- a/src/languageservice/services/yamlCodeActions.ts +++ b/src/languageservice/services/yamlCodeActions.ts @@ -184,7 +184,7 @@ export class YamlCodeActions { const result = []; const buffer = new TextBuffer(document); for (const diag of diagnostics) { - if (diag.message.startsWith('Unused anchor') && diag.source === YAML_SOURCE) { + if (typeof diag.message === 'string' && diag.message.startsWith('Unused anchor') && diag.source === YAML_SOURCE) { const range = Range.create(diag.range.start, diag.range.end); const actual = buffer.getText(range); const lineContent = buffer.getLineContent(range.end.line); diff --git a/src/languageservice/services/yamlValidation.ts b/src/languageservice/services/yamlValidation.ts index cea31d810..566253243 100644 --- a/src/languageservice/services/yamlValidation.ts +++ b/src/languageservice/services/yamlValidation.ts @@ -150,7 +150,7 @@ export class YAMLValidation { return filterSuppressedDiagnostics( duplicateMessagesRemoved, (d) => d.range.start.line, - (d) => d.message, + (d) => (typeof d.message === 'string' ? d.message : d.message.value), (line) => { if (line < 0 || line >= textBuffer.getLineCount()) { return undefined; diff --git a/src/server.ts b/src/server.ts index 8dcf8f440..0f510378a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -6,8 +6,8 @@ *--------------------------------------------------------------------------------------------*/ import { promises as fs } from 'fs'; -import type { Connection } from 'vscode-languageserver/node.js'; -import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js'; +import type { Connection } from 'vscode-languageserver/node'; +import { createConnection, ProposedFeatures } from 'vscode-languageserver/node'; import { TelemetryImpl } from './languageserver/telemetry.js'; import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler.js'; import { convertErrorToTelemetryMsg } from './languageservice/utils/objects.js'; diff --git a/src/webworker/yamlServerMain.ts b/src/webworker/yamlServerMain.ts index d7c01965e..fc2a8dd10 100644 --- a/src/webworker/yamlServerMain.ts +++ b/src/webworker/yamlServerMain.ts @@ -6,7 +6,7 @@ import * as l10n from '@vscode/l10n'; import type { Connection } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; -import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser.js'; +import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'; import { TelemetryImpl } from '../languageserver/telemetry.js'; import { schemaRequestHandler, workspaceContext } from '../languageservice/services/schemaRequestHandler.js'; import { YAMLServerInit } from '../yamlServerInit.js'; diff --git a/test/bundlel10n.test.ts b/test/bundlel10n.test.ts index a92872dce..643e5291e 100644 --- a/test/bundlel10n.test.ts +++ b/test/bundlel10n.test.ts @@ -7,8 +7,8 @@ import { describe, it, before, after } from 'node:test'; import * as l10n from '@vscode/l10n'; import assert from 'assert'; import * as path from 'path'; -import type { Connection } from 'vscode-languageserver/node.js'; -import { createConnection } from 'vscode-languageserver/node.js'; +import type { Connection } from 'vscode-languageserver/node'; +import { createConnection } from 'vscode-languageserver/node'; import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler.js'; import { setupl10nBundle } from '../src/nodeTranslationSetup.js'; import { YAMLServerInit } from '../src/yamlServerInit.js'; diff --git a/test/formatter.test.ts b/test/formatter.test.ts index f6eb446ff..d0c1579f4 100644 --- a/test/formatter.test.ts +++ b/test/formatter.test.ts @@ -3,9 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, before, afterEach } from 'node:test'; +import { describe, it, before, afterEach, mock } from 'node:test'; import assert from 'assert'; -import { createSandbox } from 'sinon'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { FormattingOptions, TextEdit } from 'vscode-languageserver-types'; import type { CustomFormatterOptions } from '../src/index.js'; @@ -26,12 +25,11 @@ type LanguageHandlerWithConnection = { }; describe('Formatter Tests', () => { - const sandbox = createSandbox(); let languageHandler: LanguageHandlers; let yamlSettings: SettingsState; afterEach(() => { - sandbox.restore(); + mock.reset(); }); before(() => { @@ -72,7 +70,7 @@ describe('Formatter Tests', () => { yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const connection = (languageHandler as unknown as LanguageHandlerWithConnection).connection; - sandbox.stub(connection.workspace, 'getConfiguration').resolves([{}, { 'yaml.format.enable': false }]); + mock.method(connection.workspace, 'getConfiguration', () => Promise.resolve([{}, { 'yaml.format.enable': false }])); yamlSettings.hasConfigurationCapability = true; const edits = await languageHandler.formatterHandler({ options: { tabSize: 2, insertSpaces: true }, @@ -92,7 +90,7 @@ describe('Formatter Tests', () => { yamlSettings.hasConfigurationCapability = true; const connection = (languageHandler as unknown as LanguageHandlerWithConnection).connection; - const getConfiguration = sandbox.stub(connection.workspace, 'getConfiguration').callsFake(async (items) => { + const getConfiguration = mock.method(connection.workspace, 'getConfiguration', async (items) => { assert.ok(Array.isArray(items)); assert.equal(items[0].section, 'yaml.format'); assert.equal(items[1].section, '[yaml]'); @@ -111,7 +109,7 @@ describe('Formatter Tests', () => { assert.equal(singleQuoteEdits[0].newText, "root:\n - child: 'text'\n"); assert.equal(doubleQuoteEdits.length, 0); - assert.equal(getConfiguration.callCount, 2); + assert.equal(getConfiguration.mock.callCount(), 2); }); it('Formatting works with custom tags', async () => { diff --git a/test/invalid-metaschema.test.ts b/test/invalid-metaschema.test.ts index 25d3a9216..cfb9f12ef 100644 --- a/test/invalid-metaschema.test.ts +++ b/test/invalid-metaschema.test.ts @@ -3,32 +3,33 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import { assert } from 'chai'; -import type { SinonSpy } from 'sinon'; -import { createSandbox } from 'sinon'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import assert from 'node:assert/strict'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node'; import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; import { setupSchemaIDTextDocument } from './utils/testHelper.js'; describe('unexpected meta schema', () => { - const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: SinonSpy; + let requestServiceMock: Mock; beforeEach(() => { - requestServiceMock = sandbox.fake.resolves('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }'); + requestServiceMock = mock.fn(() => + Promise.resolve('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }') + ); service = new YAMLSchemaService(requestServiceMock); connection.client = {} as RemoteClient; - const onRequest = sandbox.fake(); + const onRequest = mock.fn(); connection.onRequest = onRequest; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should not throw when a non-standard meta schema is used', async () => { diff --git a/test/schema2019Validation.test.ts b/test/schema2019Validation.test.ts index 2bf767d80..c3f5b7c28 100644 --- a/test/schema2019Validation.test.ts +++ b/test/schema2019Validation.test.ts @@ -5,7 +5,7 @@ import { describe, it, before, beforeEach, afterEach } from 'node:test'; import type { TestCustomSchemaProvider } from './utils/testHelper.js'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, getDiagnosticMessage } from './utils/testHelper.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; @@ -2680,7 +2680,7 @@ unknown: 1 schemaProvider.addSchema(SCHEMA_ID, root); const yaml = `x: A`; const result = await parseSetup(yaml); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2711,7 +2711,7 @@ unknown: 1 schemaProvider.addSchema(SCHEMA_ID, root); const yaml = `address:\n zipCode: "123"`; const result = await parseSetup(yaml); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result[0].message).to.include('String is shorter than the minimum length of 5.'); }); }); diff --git a/test/schema2020Validation.test.ts b/test/schema2020Validation.test.ts index 48363067e..0ce7712e7 100644 --- a/test/schema2020Validation.test.ts +++ b/test/schema2020Validation.test.ts @@ -5,7 +5,7 @@ import { describe, it, before, beforeEach, afterEach } from 'node:test'; import type { TestCustomSchemaProvider } from './utils/testHelper.js'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, getDiagnosticMessage } from './utils/testHelper.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; @@ -2000,8 +2000,10 @@ a: true`); elements: - b: 1`); expect(result).to.have.length(2); - expect(result.some((d) => d.message.includes('Missing property') && d.message.includes('a'))).to.eq(true); - expect(result.some((d) => d.message.includes('Property b is not allowed.'))).to.eq(true); + expect( + result.some((d) => getDiagnosticMessage(d).includes('Missing property') && getDiagnosticMessage(d).includes('a')) + ).to.eq(true); + expect(result.some((d) => getDiagnosticMessage(d).includes('Property b is not allowed.'))).to.eq(true); }); it('correct extended schema', async () => { @@ -2055,8 +2057,10 @@ a: true`); elements: - b: 1`); expect(result).to.have.length(2); - expect(result.some((d) => d.message.includes('Missing property') && d.message.includes('a'))).to.eq(true); - expect(result.some((d) => d.message.includes('Property b is not allowed.'))).to.eq(true); + expect( + result.some((d) => getDiagnosticMessage(d).includes('Missing property') && getDiagnosticMessage(d).includes('a')) + ).to.eq(true); + expect(result.some((d) => getDiagnosticMessage(d).includes('Property b is not allowed.'))).to.eq(true); }); it('correct extended schema', async () => { diff --git a/test/schemaRequestHandler.test.ts b/test/schemaRequestHandler.test.ts index c073b7090..6e6a73a3d 100644 --- a/test/schemaRequestHandler.test.ts +++ b/test/schemaRequestHandler.test.ts @@ -3,35 +3,32 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import { schemaRequestHandler } from '../src/languageservice/services/schemaRequestHandler.js'; import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler.js'; -import type { SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; import request from 'request-light'; import type { XHRResponse } from 'request-light'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; import * as chai from 'chai'; -import sinonChai from 'sinon-chai'; const expect = chai.expect; -chai.use(sinonChai); import { testFileSystem } from './utils/testHelper.js'; describe('Schema Request Handler Tests', () => { describe('schemaRequestHandler', () => { - const sandbox = createSandbox(); - let readFileStub: SinonStub; + let readFileStub: Mock; beforeEach(() => { - readFileStub = sandbox.stub(testFileSystem, 'readFile'); - readFileStub.returns(Promise.resolve('{some: "json"}')); + readFileStub = mock.method(testFileSystem, 'readFile', () => undefined); + readFileStub.mock.mockImplementation(() => Promise.resolve('{some: "json"}')); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('Should care Win URI', async () => { const connection = {} as Connection; @@ -44,7 +41,8 @@ describe('Schema Request Handler Tests', () => { testFileSystem, false ); - expect(readFileStub).calledOnceWith('c:\\some\\window\\path\\scheme.json'); + assert.equal(readFileStub.mock.callCount(), 1); + assert.deepEqual(readFileStub.mock.calls[0].arguments.slice(0, 1), ['c:\\some\\window\\path\\scheme.json']); const result = await resultPromise; expect(result).to.be.equal('{some: "json"}'); }); @@ -67,24 +65,26 @@ describe('Schema Request Handler Tests', () => { testFileSystem, false ); - expect(readFileStub).calledOnceWith(URI.file('a:/some/window/path/scheme.json').fsPath); + assert.equal(readFileStub.mock.callCount(), 1); + assert.deepEqual(readFileStub.mock.calls[0].arguments.slice(0, 1), [URI.file('a:/some/window/path/scheme.json').fsPath]); const result = await resultPromise; expect(result).to.be.equal('{some: "json"}'); }); }); describe('HTTP(S) schema requests', () => { - const sandbox = createSandbox(); - let xhrStub: SinonStub; + let xhrStub: Mock; const connection = {} as Connection; beforeEach(() => { - xhrStub = sandbox.stub(request, 'xhr'); - xhrStub.resolves({ responseText: '{"$schema":"http://json-schema.org/draft-07/schema"}', status: 200 } as XHRResponse); + xhrStub = mock.method(request, 'xhr', () => undefined); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ responseText: '{"$schema":"http://json-schema.org/draft-07/schema"}', status: 200 } as XHRResponse) + ); }); afterEach(() => { - sandbox.restore(); + mock.reset(); delete process.env.YAML_LANGUAGE_SERVER_VERSION; }); @@ -92,8 +92,8 @@ describe('Schema Request Handler Tests', () => { process.env.YAML_LANGUAGE_SERVER_VERSION = '1.0.0-test'; await schemaRequestHandler(connection, 'https://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - expect(xhrStub).calledOnce; - const { headers } = xhrStub.firstCall.args[0]; + assert.equal(xhrStub.mock.callCount(), 1); + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['User-Agent']).to.equal( `yaml-language-server/1.0.0-test (RedHat) node/${process.versions.node} (${process.platform})` ); @@ -103,7 +103,7 @@ describe('Schema Request Handler Tests', () => { delete process.env.YAML_LANGUAGE_SERVER_VERSION; await schemaRequestHandler(connection, 'https://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - const { headers } = xhrStub.firstCall.args[0]; + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['User-Agent']).to.match(/^yaml-language-server\/unknown \(RedHat\)/); }); @@ -111,14 +111,14 @@ describe('Schema Request Handler Tests', () => { process.env.YAML_LANGUAGE_SERVER_VERSION = '2.0.0'; await schemaRequestHandler(connection, 'http://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - const { headers } = xhrStub.firstCall.args[0]; + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['User-Agent']).to.match(/^yaml-language-server\/2\.0\.0 \(RedHat\)/); }); it('should preserve Accept-Encoding header alongside User-Agent', async () => { await schemaRequestHandler(connection, 'https://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - const { headers } = xhrStub.firstCall.args[0]; + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['Accept-Encoding']).to.equal('gzip, deflate'); }); @@ -136,7 +136,7 @@ describe('Schema Request Handler Tests', () => { }); it('should reject with responseText on xhr error', async () => { - xhrStub.rejects({ responseText: 'Not Found', status: 404 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Not Found', status: 404 } as XHRResponse)); try { await schemaRequestHandler( connection, @@ -155,8 +155,7 @@ describe('Schema Request Handler Tests', () => { }); describe('HTTP(S) schema request retries', () => { - const sandbox = createSandbox(); - let xhrStub: SinonStub; + let xhrStub: Mock; let delays: number[]; const connection = {} as Connection; @@ -182,35 +181,35 @@ describe('Schema Request Handler Tests', () => { beforeEach(() => { delays = []; - xhrStub = sandbox.stub(request, 'xhr'); + xhrStub = mock.method(request, 'xhr', () => undefined); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should retry a transient status and return the eventual response', async () => { - xhrStub.onFirstCall().rejects({ responseText: '', status: 429 } as XHRResponse); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce(() => Promise.reject({ responseText: '', status: 429 } as XHRResponse), 0); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); const result = await doRequest(); - expect(xhrStub).calledTwice; + assert.equal(xhrStub.mock.callCount(), 2); expect(result).to.equal(success.responseText); }); it('should retry connection level failures', async () => { - xhrStub.onFirstCall().rejects({ code: 'ECONNRESET', message: 'socket hang up' }); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce(() => Promise.reject({ code: 'ECONNRESET', message: 'socket hang up' }), 0); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); const result = await doRequest(); - expect(xhrStub).calledTwice; + assert.equal(xhrStub.mock.callCount(), 2); expect(result).to.equal(success.responseText); }); it('should not retry a permanent status', async () => { - xhrStub.rejects({ responseText: 'Not Found', status: 404 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Not Found', status: 404 } as XHRResponse)); try { await doRequest(); @@ -218,11 +217,11 @@ describe('Schema Request Handler Tests', () => { } catch (err) { expect(err).to.equal('Not Found'); } - expect(xhrStub).calledOnce; + assert.equal(xhrStub.mock.callCount(), 1); }); it('should give up after the retry budget is exhausted', async () => { - xhrStub.rejects({ responseText: 'Service Unavailable', status: 503 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Service Unavailable', status: 503 } as XHRResponse)); try { await doRequest(); @@ -231,14 +230,15 @@ describe('Schema Request Handler Tests', () => { expect(err).to.equal('Service Unavailable'); } // The initial attempt plus the default budget of 2 retries. - expect(xhrStub).calledThrice; + assert.equal(xhrStub.mock.callCount(), 3); }); it('should honour a Retry-After header in preference to backoff', async () => { - xhrStub - .onFirstCall() - .rejects({ responseText: '', status: 429, headers: { 'retry-after': '0.5' } } as unknown as XHRResponse); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce( + () => Promise.reject({ responseText: '', status: 429, headers: { 'retry-after': '0.5' } } as unknown as XHRResponse), + 0 + ); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); await doRequest(); @@ -246,10 +246,11 @@ describe('Schema Request Handler Tests', () => { }); it('should cap an excessive Retry-After value', async () => { - xhrStub - .onFirstCall() - .rejects({ responseText: '', status: 429, headers: { 'retry-after': '600' } } as unknown as XHRResponse); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce( + () => Promise.reject({ responseText: '', status: 429, headers: { 'retry-after': '600' } } as unknown as XHRResponse), + 0 + ); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); await doRequest(); @@ -257,7 +258,7 @@ describe('Schema Request Handler Tests', () => { }); it('should back off between attempts when no Retry-After is given', async () => { - xhrStub.rejects({ responseText: 'Service Unavailable', status: 503 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Service Unavailable', status: 503 } as XHRResponse)); try { await doRequest(); @@ -273,7 +274,7 @@ describe('Schema Request Handler Tests', () => { }); it('should not retry when the budget is zero', async () => { - xhrStub.rejects({ responseText: 'Too Many Requests', status: 429 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Too Many Requests', status: 429 } as XHRResponse)); try { await doRequest({ ...retryOptions, maxRetries: 0 }); @@ -281,7 +282,7 @@ describe('Schema Request Handler Tests', () => { } catch (err) { expect(err).to.equal('Too Many Requests'); } - expect(xhrStub).calledOnce; + assert.equal(xhrStub.mock.callCount(), 1); }); }); }); diff --git a/test/schemaSelectionHandlers.test.ts b/test/schemaSelectionHandlers.test.ts index 757275b08..dbb9b72a6 100644 --- a/test/schemaSelectionHandlers.test.ts +++ b/test/schemaSelectionHandlers.test.ts @@ -3,43 +3,47 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import type { SinonSpy } from 'sinon'; -import { createSandbox } from 'sinon'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import { isDeepStrictEqual } from 'node:util'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; -import sinonChai from 'sinon-chai'; import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node'; import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; import { SchemaSelectionRequests } from '../src/requestTypes.js'; import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper.js'; const expect = chai.expect; -chai.use(sinonChai); describe('Schema Selection Handlers', () => { - const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: SinonSpy; + let requestServiceMock: Mock; + let onRequest: Mock; beforeEach(() => { - requestServiceMock = sandbox.fake.resolves(undefined); + requestServiceMock = mock.fn(() => Promise.resolve(undefined)); service = new YAMLSchemaService(requestServiceMock); connection.client = {} as RemoteClient; - const onRequest = sandbox.fake(); + onRequest = mock.fn(); connection.onRequest = onRequest; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('add handler for "getSchema" and "getAllSchemas" requests', () => { new JSONSchemaSelection(service, new SettingsState(), connection); - expect(connection.onRequest).calledWith(SchemaSelectionRequests.getSchema); - expect(connection.onRequest).calledWith(SchemaSelectionRequests.getAllSchemas); + assert.ok( + onRequest.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [SchemaSelectionRequests.getSchema])) + ); + assert.ok( + onRequest.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [SchemaSelectionRequests.getAllSchemas])) + ); }); it('getAllSchemas should return all schemas', async () => { @@ -105,7 +109,7 @@ describe('Schema Selection Handlers', () => { it('getSchemas should return an inline $schema', async () => { const schemaUri = 'https://some.com/inline.json'; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schemaUri) { return Promise.resolve( JSON.stringify({ @@ -143,11 +147,12 @@ describe('Schema Selection Handlers', () => { versions: undefined, }, ]); - expect(requestServiceMock).calledOnceWith(schemaUri); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), [schemaUri]); }); it('getSchemas should not resolve schema references', async () => { - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'https://some.com/some.json') { return Promise.resolve( JSON.stringify({ @@ -180,8 +185,12 @@ describe('Schema Selection Handlers', () => { description: 'Schema description', versions: undefined, }); - expect(requestServiceMock).calledOnceWith('https://some.com/some.json'); - expect(requestServiceMock).not.calledWith('https://some.com/ref.json'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://some.com/some.json']); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), ['https://some.com/ref.json'])), + false + ); }); it('getSchemas should use registered schema metadata without loading schema content', async () => { @@ -212,7 +221,7 @@ describe('Schema Selection Handlers', () => { description: 'Schema description', versions, }); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('getSchemas should handle empty schemas', async () => { diff --git a/test/schemaValidation.test.ts b/test/schemaValidation.test.ts index b540d3008..928885440 100644 --- a/test/schemaValidation.test.ts +++ b/test/schemaValidation.test.ts @@ -5,7 +5,7 @@ import { describe, it, before, after, afterEach } from 'node:test'; import type { TestCustomSchemaProvider } from './utils/testHelper.js'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, getDiagnosticMessage } from './utils/testHelper.js'; import { createDiagnosticWithData, createExpectedError } from './utils/verifyError.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import { @@ -474,11 +474,11 @@ describe('Validation Tests', () => { }); const result = await parseSetup('prop: "tes "'); assert.equal(result.length, 1); - assert.ok(result[0].message.startsWith('String does not match the pattern')); + assert.ok(getDiagnosticMessage(result[0]).startsWith('String does not match the pattern')); assert.deepEqual( result[0], createDiagnosticWithData( - result[0].message, + getDiagnosticMessage(result[0]), 0, 6, 0, @@ -1168,7 +1168,7 @@ obj: const content = 'ImageId: !FindInMap [AWSRegionArch2AMI, !Ref "AWS::Region", HVM64]'; const result = await parseSetup(content); assert.equal(result.length, 1); - assert.ok(result[0].message.includes('Incorrect type. Expected "string".')); + assert.ok(getDiagnosticMessage(result[0]).includes('Incorrect type. Expected "string".')); }); }); @@ -2140,7 +2140,7 @@ spec: x: A `; const result = await parseSetup(yaml, 'file:///root.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2169,7 +2169,7 @@ x: A x: A `; const result = await parseSetup(yaml, 'file:///nested-base.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2200,7 +2200,7 @@ x: A x: A `; const result = await parseSetup(yaml, 'file:///embedded-resource.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2225,7 +2225,7 @@ x: A pkg: 123 `; const result = await parseSetup(yaml, 'file:///baseuri-ok.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result[0].message).to.include('Incorrect type.'); }); @@ -2244,7 +2244,11 @@ pkg: 123 `; const result = await parseSetup(yaml, 'file:///baseuri-fail.schema.json'); expect(result).to.not.be.empty; - expect(result.some((d) => /Problems loading reference/i.test(d.message) && /No content/i.test(d.message))).to.eq(true); + expect( + result.some( + (d) => /Problems loading reference/i.test(getDiagnosticMessage(d)) && /No content/i.test(getDiagnosticMessage(d)) + ) + ).to.eq(true); }); it('root $id ending in the loaded schema filename should not break embedded resource refs', async () => { @@ -2278,7 +2282,7 @@ option: suboption: 1 `; const result = await parseSetup(yaml, 'file:///validated.yaml'); - expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(d.message))).to.eq(false); + expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('Incorrect type. Expected "string".'); }); @@ -2318,8 +2322,8 @@ option: suboption: 1 `; const result = await parseSetup(yaml, 'file:///validated-local-sibling.yaml'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); - expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); + expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('Incorrect type. Expected "string".'); }); @@ -2357,7 +2361,7 @@ option: option: local `; const result = await parseSetup(yaml, 'file:///validated-embedded-precedence.yaml'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('embedded'); }); diff --git a/test/settingsHandlers.test.ts b/test/settingsHandlers.test.ts index 54e624dd9..e52ec2cc6 100644 --- a/test/settingsHandlers.test.ts +++ b/test/settingsHandlers.test.ts @@ -3,20 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; import request from 'request-light'; -import type { SinonMock, SinonStub, SinonStubbedInstance } from 'sinon'; -import { createSandbox, spy, stub } from 'sinon'; -import sinonChai from 'sinon-chai'; import type { Connection, RemoteClient, RemoteWorkspace } from 'vscode-languageserver'; import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; import type { LanguageService, LanguageSettings, SchemaConfiguration } from '../src/index.js'; import { SchemaPriority } from '../src/index.js'; import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers.js'; -import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; import { EMPTY_SCHEMA_URL } from '../src/languageservice/utils/schemaUrls.js'; import type { Telemetry } from '../src/languageservice/telemetry.js'; import { SettingsState } from '../src/yamlSettings.js'; @@ -26,37 +25,36 @@ import { setupSchemaIDTextDocument, setupTextDocument, } from './utils/testHelper.js'; -import { TestWorkspace } from './utils/testsTypes.js'; const expect = chai.expect; -chai.use(sinonChai); describe('Settings Handlers Tests', () => { - const sandbox = createSandbox(); const connection: Connection = {} as Connection; - let workspaceStub: SinonStubbedInstance; + let workspaceStub: { getConfiguration: Mock }; + let register: Mock; let languageService: LanguageService; let settingsState: SettingsState; - let validationHandler: SinonMock; - let xhrStub: SinonStub; + let validationHandler: Pick; + let xhrStub: Mock; beforeEach(() => { - workspaceStub = sandbox.createStubInstance(TestWorkspace); + workspaceStub = { getConfiguration: mock.fn() }; connection.workspace = workspaceStub as unknown as RemoteWorkspace; - connection.onDidChangeConfiguration = sandbox.mock(); + connection.onDidChangeConfiguration = mock.fn(); connection.client = {} as RemoteClient; - connection.client.register = sandbox.mock(); + register = mock.fn(); + connection.client.register = register; const languageServerSetup = setupLanguageService({}); languageService = languageServerSetup.languageService; settingsState = new SettingsState(); - validationHandler = sandbox.mock(ValidationHandler); - xhrStub = sandbox.stub(request, 'xhr'); - const sendRequest = sandbox.fake(); + validationHandler = { validate: mock.fn() }; + xhrStub = mock.method(request, 'xhr', () => undefined); + const sendRequest = mock.fn(); connection.sendRequest = sendRequest; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should not register configuration notification handler if client not supports dynamic handlers', () => { @@ -71,7 +69,7 @@ describe('Settings Handlers Tests', () => { ); settingsHandler.registerHandlers(); - expect(connection.client.register).not.called; + assert.equal(register.mock.callCount(), 0); }); it('should register configuration notification handler only if client supports dynamic handlers', () => { @@ -86,23 +84,28 @@ describe('Settings Handlers Tests', () => { ); settingsHandler.registerHandlers(); - expect(connection.client.register).calledOnce; + assert.equal(register.mock.callCount(), 1); }); it('should request CodeLens refresh after schema settings update if client supports it', async () => { settingsState.hasCodeLensRefreshSupport = true; - const sendRequest = sandbox.stub().resolves(); + const sendRequest = mock.fn(() => Promise.resolve(undefined)); connection.sendRequest = sendRequest; - workspaceStub.getConfiguration.onFirstCall().resolves([{ schemaStore: { enable: false } }, {}, {}, {}, {}]); - workspaceStub.getConfiguration - .onSecondCall() - .resolves([ - { schemas: { 'https://example.com/schema.json': 'test.yaml' }, schemaStore: { enable: false } }, - {}, - {}, - {}, - {}, - ]); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ schemaStore: { enable: false } }, {}, {}, {}, {}]), + 0 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => + Promise.resolve([ + { schemas: { 'https://example.com/schema.json': 'test.yaml' }, schemaStore: { enable: false } }, + {}, + {}, + {}, + {}, + ]), + 1 + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -112,19 +115,23 @@ describe('Settings Handlers Tests', () => { ); await settingsHandler.pullConfiguration(); await settingsHandler.pullConfiguration(); - expect(sendRequest).calledOnceWithExactly(CodeLensRefreshRequest.type); + assert.equal(sendRequest.mock.callCount(), 1); + assert.deepEqual(sendRequest.mock.calls[0].arguments, [CodeLensRefreshRequest.type]); }); it('should not request CodeLens refresh when only non-schema settings update', async () => { settingsState.hasCodeLensRefreshSupport = true; - const sendRequest = sandbox.stub().resolves(); + const sendRequest = mock.fn(() => Promise.resolve(undefined)); connection.sendRequest = sendRequest; const yamlSettings = { schemas: { 'https://example.com/schema.json': 'test.yaml' }, schemaStore: { enable: false }, }; - workspaceStub.getConfiguration.onFirstCall().resolves([yamlSettings, {}, {}, {}, {}]); - workspaceStub.getConfiguration.onSecondCall().resolves([{ ...yamlSettings, keyOrdering: true }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementationOnce(() => Promise.resolve([yamlSettings, {}, {}, {}, {}]), 0); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ ...yamlSettings, keyOrdering: true }, {}, {}, {}, {}]), + 1 + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -134,7 +141,7 @@ describe('Settings Handlers Tests', () => { ); await settingsHandler.pullConfiguration(); await settingsHandler.pullConfiguration(); - expect(sendRequest).not.called; + assert.equal(sendRequest.mock.callCount(), 0); }); describe('Settings for YAML style should ', () => { @@ -146,7 +153,9 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{ style: { flowMapping: 'forbid', flowSequence: 'forbid' } }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ style: { flowMapping: 'forbid', flowSequence: 'forbid' } }, {}, {}, {}, {}]) + ); await settingsHandler.pullConfiguration(); expect(settingsState.style).to.exist; @@ -161,7 +170,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); await settingsHandler.pullConfiguration(); expect(settingsState.style).to.exist; @@ -179,7 +188,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{ keyOrdering: true }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ keyOrdering: true }, {}, {}, {}, {}])); await settingsHandler.pullConfiguration(); expect(settingsState.keyOrdering).to.exist; @@ -193,7 +202,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); await settingsHandler.pullConfiguration(); expect(settingsState.style).to.exist; @@ -211,11 +220,14 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); - workspaceStub.getConfiguration - .onFirstCall() - .resolves([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]) - .onSecondCall() - .resolves([{ kubernetesVersion: 'v1.37.2' }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]), + 0 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: 'v1.37.2' }, {}, {}, {}, {}]), + 1 + ); await settingsHandler.pullConfiguration(); expect(settingsState.kubernetesVersion).to.equal('v1.36.1'); @@ -232,13 +244,15 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration - .onFirstCall() - .resolves([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]) - .onSecondCall() - .resolves([{ kubernetesVersion: 'invalid' }, {}, {}, {}, {}]) - .onThirdCall() - .resolves([{}, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]), + 0 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: 'invalid' }, {}, {}, {}, {}]), + 1 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce(() => Promise.resolve([{}, {}, {}, {}, {}]), 2); await settingsHandler.pullConfiguration(); expect(settingsState.kubernetesVersion).to.equal('v1.36.1'); @@ -255,8 +269,12 @@ describe('Settings Handlers Tests', () => { it('should include patterns with nonstandard extensions', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "Butane config schema", "description": "Schema to validate butane files for Fedora CoreOS", @@ -265,7 +283,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/Relativ-IT/Butane-Schemas/Release/Butane-Schema.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -273,10 +292,10 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://raw.githubusercontent.com/Relativ-IT/Butane-Schemas/Release/Butane-Schema.json', fileMatch: ['*.bu'], @@ -289,8 +308,12 @@ describe('Settings Handlers Tests', () => { it('should include extensionless patterns', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "clang-format (.clang-format)", "description": "yaml clang-format config", @@ -299,7 +322,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://www.schemastore.org/clang-format-21.x.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -307,12 +331,12 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://www.schemastore.org/clang-format-21.x.json', fileMatch: ['.clang-format'], @@ -325,8 +349,12 @@ describe('Settings Handlers Tests', () => { it('should exclude JSON file extensions', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "JSON config schema", "description": "Schema to validate JSON config files", @@ -337,7 +365,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://example.com/config.schema.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -345,24 +374,29 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings.some((schema) => schema.uri === 'https://example.com/config.schema.json')).to.be .false; }); it('SettingsHandler should include schemas without file matches as selectable schemas', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "Traefik v3", "description": "Traefik v3 YAML configuration file", "url": "https://www.schemastore.org/traefik-v3.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -370,10 +404,10 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://www.schemastore.org/traefik-v3.json', fileMatch: [], @@ -390,8 +424,12 @@ describe('Settings Handlers Tests', () => { const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -400,7 +438,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -408,10 +447,10 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json', fileMatch: ['.adonisrc.yaml'], @@ -426,7 +465,7 @@ describe('Settings Handlers Tests', () => { const testSchemaFileMatch = ['foo/*.yml']; async function configureSchemaSettingsTest(): Promise { - const telemetry = { send: stub(), sendError: stub() } as unknown as Telemetry; + const telemetry = { send: mock.fn(), sendError: mock.fn() } as unknown as Telemetry; const settingsHandler = new SettingsHandler( connection, languageService, @@ -434,20 +473,20 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, telemetry ); - const configureSpy = spy(languageService, 'configure'); + const configureSpy = mock.method(languageService, 'configure'); await settingsHandler.pullConfiguration(); - configureSpy.restore(); - return configureSpy.args[0][0]; + configureSpy.mock.restore(); + return configureSpy.mock.calls[0].arguments[0]; } it('Schema Settings should normalize absolute local paths', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const absoluteSchemaPath = '/Users/test/schemas/schema.json'; const schemas = {}; schemas[absoluteSchemaPath] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -459,14 +498,14 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should preserve fragments when normalizing absolute local paths', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const absoluteSchemaPath = '/Users/test/schemas/schema.json'; const schemaUri = `${absoluteSchemaPath}#/definitions/foo`; const schemas = {}; schemas[schemaUri] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -478,13 +517,13 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should preserve remote schema URLs', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemaUri = 'https://example.com/schemas/schema.json#/definitions/foo'; const schemas = {}; schemas[schemaUri] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -496,14 +535,14 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should treat direct Kubernetes standalone-strict/all.json URLs as Kubernetes associations', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemaUri = 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.32.9-standalone-strict/all.json'; const schemas = {}; schemas[schemaUri] = ['*.yaml']; - workspaceStub.getConfiguration.resolves([{ schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -516,16 +555,16 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should normalize multiple absolute local paths for the same file', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemaPath1 = '/Users/test/schemas/schema1.json'; const schemaPath2 = '/Users/test/schemas/schema2.json'; const fileMatch = ['asdf.yaml']; const schemas = {}; schemas[schemaPath1] = fileMatch; schemas[schemaPath2] = fileMatch; - workspaceStub.getConfiguration.resolves([{ schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -555,15 +594,19 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - const configureSpy = spy(languageService, 'configure'); + const configureSpy = mock.method(languageService, 'configure'); await settingsHandler.pullConfiguration(); - configureSpy.restore(); - return configureSpy.args[0][0]; + configureSpy.mock.restore(); + return configureSpy.mock.calls[0].arguments[0]; } it('Schema Settings should have a priority', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -572,10 +615,11 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const schemas = {}; schemas[testSchemaURI] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -587,8 +631,12 @@ describe('Settings Handlers Tests', () => { }); it('SchemaDetectionDisabled should have a priority', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -597,9 +645,12 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const disabledSchemaFileMatch = ['foo/*.yml']; - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]) + ); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -611,8 +662,12 @@ describe('Settings Handlers Tests', () => { }); it('SchemaDetectionDisabled should accept a single file match string', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -621,9 +676,12 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const disabledSchemaFileMatch = 'foo/*.yml'; - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]) + ); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -635,8 +693,12 @@ describe('Settings Handlers Tests', () => { }); it('Schema Associations should have a priority when schema association is an array', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -645,7 +707,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); settingsState.schemaAssociations = [ { fileMatch: testSchemaFileMatch, @@ -653,7 +716,7 @@ describe('Settings Handlers Tests', () => { }, ] as SchemaConfiguration[]; - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -668,7 +731,7 @@ describe('Settings Handlers Tests', () => { settingsState.schemaAssociations = { [testSchemaURI]: testSchemaFileMatch, } as Record; - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -694,10 +757,14 @@ describe('Settings Handlers Tests', () => { const schemaUri = 'file:///schemas/schema-detection-disable-settings.json'; const schemaProvider = TestCustomSchemaProvider.instance(); schemaProvider.addSchemaWithUri('disableSchemaDetection-settings', schemaUri, restrictiveSchema); - xhrStub.resolves({ responseText: '{"schemas":[]}' }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemas = {}; schemas[schemaUri] = 'test.yaml'; - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: ['test.yaml'], schemas }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: ['test.yaml'], schemas }, {}, {}, {}, {}]) + ); try { await new SettingsHandler( @@ -721,19 +788,26 @@ describe('Settings Handlers Tests', () => { const githubWorkflowFileMatch = ['.github/workflows/*.yml']; const schemaProvider = TestCustomSchemaProvider.instance(); schemaProvider.addSchemaWithUri('disableSchemaDetection-github-actions', schemaUri, restrictiveSchema); - xhrStub.resolves({ - responseText: JSON.stringify({ - schemas: [ - { - name: 'GitHub Workflow', - description: 'GitHub Actions workflow schema', - fileMatch: githubWorkflowFileMatch, - url: schemaUri, - }, - ], - }), - }); - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: githubWorkflowFileMatch }, {}, {}, {}, {}]); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: JSON.stringify({ + schemas: [ + { + name: 'GitHub Workflow', + description: 'GitHub Actions workflow schema', + fileMatch: githubWorkflowFileMatch, + url: schemaUri, + }, + ], + }), + }) + ); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: githubWorkflowFileMatch }, {}, {}, {}, {}]) + ); try { await new SettingsHandler( @@ -759,8 +833,12 @@ describe('Settings Handlers Tests', () => { const schemaUri = 'file:///schemas/schema-detection-disable-modeline.json'; const schemaProvider = TestCustomSchemaProvider.instance(); schemaProvider.addSchemaWithUri('disableSchemaDetection-modeline', schemaUri, restrictiveSchema); - xhrStub.resolves({ responseText: '{"schemas":[]}' }); - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: ['test.yaml'] }, {}, {}, {}, {}]); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: ['test.yaml'] }, {}, {}, {}, {}]) + ); try { await new SettingsHandler( @@ -793,15 +871,13 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); await settingsHandler.pullConfiguration(); - expect(workspaceStub.getConfiguration).calledOnceWith([ - { section: 'yaml' }, - { section: 'http' }, - { section: '[yaml]' }, - { section: 'editor' }, + assert.equal(workspaceStub.getConfiguration.mock.callCount(), 1); + assert.deepEqual(workspaceStub.getConfiguration.mock.calls[0].arguments.slice(0, 1), [ + [{ section: 'yaml' }, { section: 'http' }, { section: '[yaml]' }, { section: 'editor' }], ]); }); it('should set schemaStoreSettings to empty when schemaStore is disabled', async () => { @@ -817,11 +893,13 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{ schemaStore: { enable: false, url: 'http://shouldnot.activate' } }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ schemaStore: { enable: false, url: 'http://shouldnot.activate' } }, {}, {}, {}]) + ); // const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); - // configureSpy.restore(); + // configureSpy.mock.restore(); expect(settingsState.schemaStoreEnabled).to.be.false; expect(settingsState.schemaStoreSettings).to.be.empty; }); @@ -833,14 +911,14 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, { tabSize: 4, detectIndentation: false }]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{}, {}, {}, { tabSize: 4, detectIndentation: false }]) + ); await settingsHandler.pullConfiguration(); - expect(workspaceStub.getConfiguration).calledOnceWith([ - { section: 'yaml' }, - { section: 'http' }, - { section: '[yaml]' }, - { section: 'editor' }, + assert.equal(workspaceStub.getConfiguration.mock.callCount(), 1); + assert.deepEqual(workspaceStub.getConfiguration.mock.calls[0].arguments.slice(0, 1), [ + [{ section: 'yaml' }, { section: 'http' }, { section: '[yaml]' }, { section: 'editor' }], ]); }); }); diff --git a/test/telemetry.test.ts b/test/telemetry.test.ts index 87e78f87b..56ac2a725 100644 --- a/test/telemetry.test.ts +++ b/test/telemetry.test.ts @@ -3,41 +3,35 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import type { SinonStubbedInstance } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; -import * as chai from 'chai'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import { checkSchemaURI } from '../src/languageservice/utils/schemaUrls.js'; -import { TelemetryImpl } from '../src/languageserver/telemetry.js'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; import { URI } from 'vscode-uri'; -import type { Connection } from 'vscode-languageserver'; - -const expect = chai.expect; -chai.use(sinonChai); describe('Telemetry Tests', () => { - const sandbox = createSandbox(); - - let telemetry: SinonStubbedInstance; + let telemetry: Telemetry & { send: Mock }; beforeEach(() => { - const telemetryInstance = new TelemetryImpl({} as Connection); - telemetry = sandbox.stub(telemetryInstance); + telemetry = { send: mock.fn(), sendError: mock.fn(), sendTrack: mock.fn() }; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); describe('Kubernetos schema mapping', () => { it('should not report if schema is not k8s', () => { checkSchemaURI([], URI.parse('file:///some/path'), 'file:///some/path/to/schema.json', telemetry); - expect(telemetry.send).not.called; + assert.equal(telemetry.send.mock.callCount(), 0); }); it('should report if schema is k8s', () => { checkSchemaURI([], URI.parse('file:///some/path'), 'kubernetes', telemetry); - expect(telemetry.send).calledOnceWith({ name: 'yaml.schema.configured', properties: { kubernetes: true } }); + assert.equal(telemetry.send.mock.callCount(), 1); + assert.deepEqual(telemetry.send.mock.calls[0].arguments.slice(0, 1), [ + { name: 'yaml.schema.configured', properties: { kubernetes: true } }, + ]); }); }); }); diff --git a/test/utils/testHelper.ts b/test/utils/testHelper.ts index e97e7a326..ed4975d1b 100644 --- a/test/utils/testHelper.ts +++ b/test/utils/testHelper.ts @@ -6,8 +6,8 @@ import { promises as fs } from 'fs'; import { ClientCapabilities } from '../../src/languageservice/jsonLanguageTypes.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node.js'; -import { createConnection } from 'vscode-languageserver/node.js'; +import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node'; +import { createConnection } from 'vscode-languageserver/node'; import type { LanguageService, LanguageSettings } from '../../src/index.js'; import type { LanguageHandlers } from '../../src/languageserver/handlers/languageHandlers.js'; import type { ValidationHandler } from '../../src/languageserver/handlers/validationHandlers.js'; @@ -19,6 +19,11 @@ import { YAMLServerInit } from '../../src/yamlServerInit.js'; import { SettingsState } from '../../src/yamlSettings.js'; import { TestTelemetry } from './testsTypes.js'; import * as path from 'path'; +import type { Diagnostic } from 'vscode-languageserver-types'; + +export function getDiagnosticMessage(diagnostic: Diagnostic): string { + return typeof diagnostic.message === 'string' ? diagnostic.message : diagnostic.message.value; +} export function toFsPath(str: unknown): string { if (typeof str !== 'string') { diff --git a/test/utils/testsTypes.ts b/test/utils/testsTypes.ts index cf874775a..1e5ba071a 100644 --- a/test/utils/testsTypes.ts +++ b/test/utils/testsTypes.ts @@ -25,6 +25,7 @@ import type { TelemetryEvent } from '../../src/languageservice/telemetry.js'; /* eslint-disable @typescript-eslint/no-unused-vars */ export class TestWorkspace implements RemoteWorkspace { connection: Connection; + textDocumentContent: RemoteWorkspace['textDocumentContent']; applyEdit(paramOrEdit: ApplyWorkspaceEditParams | WorkspaceEdit): Promise { throw new Error('Method not implemented.'); } diff --git a/test/yaml-documents.test.ts b/test/yaml-documents.test.ts index 9688f4028..1ae4f20a0 100644 --- a/test/yaml-documents.test.ts +++ b/test/yaml-documents.test.ts @@ -3,44 +3,42 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; -import type { SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; import * as chai from 'chai'; import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; import { setupTextDocument } from './utils/testHelper.js'; import type { ParserOptions } from '../src/languageservice/parser/yamlParser07.js'; +import { parse } from '../src/languageservice/parser/yamlParser07.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml'; import { isMap, isScalar, isSeq } from 'yaml'; import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; const expect = chai.expect; -chai.use(sinonChai); describe('YAML Documents', () => { - const sandbox = createSandbox(); describe('YAML Documents Cache Tests', () => { - let parseStub: SinonStub; + let parseStub: Mock; beforeEach(() => { - parseStub = sandbox.stub(); + parseStub = mock.fn(); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should cache parsed document', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.returns({}); + parseStub.mock.mockImplementation(() => parse('foo: bar')); const result1 = cache.getYamlDocument(doc); const result2 = cache.getYamlDocument(doc); - expect(parseStub).calledOnce; + assert.equal(parseStub.mock.callCount(), 1); expect(result1).to.be.equal(result2); }); @@ -48,40 +46,40 @@ describe('YAML Documents', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.onFirstCall().returns({}); - parseStub.onSecondCall().returns({ foo: 'bar' }); + parseStub.mock.mockImplementationOnce(() => parse('foo: bar'), 0); + parseStub.mock.mockImplementationOnce(() => parse('foo: baz'), 1); const result1 = cache.getYamlDocument(doc); TextDocument.update(doc, [], 2); const result2 = cache.getYamlDocument(doc); - expect(parseStub).calledTwice; + assert.equal(parseStub.mock.callCount(), 2); expect(result1).to.be.not.equal(result2); }); it('should invalidate cache if custom tags provided', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.onFirstCall().returns({}); - parseStub.onSecondCall().returns({ foo: 'bar' }); + parseStub.mock.mockImplementationOnce(() => parse('foo: bar'), 0); + parseStub.mock.mockImplementationOnce(() => parse('foo: baz'), 1); const result1 = cache.getYamlDocument(doc); const result2 = cache.getYamlDocument(doc, getParserOptions(['some'])); - expect(parseStub).calledTwice; + assert.equal(parseStub.mock.callCount(), 2); expect(result1).to.not.equal(result2); }); it('should use cache if custom tags are same', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.onFirstCall().returns({}); - parseStub.onSecondCall().returns({ foo: 'bar' }); + parseStub.mock.mockImplementationOnce(() => parse('foo: bar'), 0); + parseStub.mock.mockImplementationOnce(() => parse('foo: baz'), 1); const result1 = cache.getYamlDocument(doc, getParserOptions(['some'])); const result2 = cache.getYamlDocument(doc, getParserOptions(['some'])); - expect(parseStub).calledOnce; + assert.equal(parseStub.mock.callCount(), 1); expect(result1).to.be.equal(result2); }); }); @@ -93,7 +91,7 @@ describe('YAML Documents', () => { }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('Get node from position: key', () => { diff --git a/test/yamlCodeActions.test.ts b/test/yamlCodeActions.test.ts index 5f1753330..b62f85b15 100644 --- a/test/yamlCodeActions.test.ts +++ b/test/yamlCodeActions.test.ts @@ -3,10 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach } from 'node:test'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; import * as chai from 'chai'; import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions.js'; import { @@ -28,23 +26,16 @@ import type { LanguageSettings } from '../src/index.js'; import { ErrorCode } from '../src/languageservice/jsonLanguageTypes.js'; const expect = chai.expect; -chai.use(sinonChai); const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; const JSON_SCHEMA2_LOCAL = 'file://some/path/schema2.json'; describe('CodeActions Tests', () => { - const sandbox = createSandbox(); - let clientCapabilities: ClientCapabilities; beforeEach(() => { clientCapabilities = {}; }); - afterEach(() => { - sandbox.restore(); - }); - describe('JumpToSchema tests', () => { it('should not provide any actions if there are no diagnostics', () => { const doc = setupTextDocument(''); diff --git a/test/yamlCodeLens.test.ts b/test/yamlCodeLens.test.ts index c7f93b41b..4a8ee8ed4 100644 --- a/test/yamlCodeLens.test.ts +++ b/test/yamlCodeLens.test.ts @@ -3,20 +3,18 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import type { SinonStubbedInstance } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; import { YamlCodeLens } from '../src/languageservice/services/yamlCodeLens.js'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import type { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; import { setupTextDocument } from './utils/testHelper.js'; import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; import type { Command } from 'vscode-languageserver-protocol'; import { CodeLens, Range } from 'vscode-languageserver-protocol'; import type { Connection } from 'vscode-languageserver'; import { YamlCommands } from '../src/commands.js'; -import { TelemetryImpl } from '../src/languageserver/telemetry.js'; import type { Telemetry } from '../src/languageservice/telemetry.js'; import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; @@ -25,22 +23,18 @@ import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; import type { SingleYAMLDocument } from '../src/languageservice/parser/yaml-documents.js'; const expect = chai.expect; -chai.use(sinonChai); describe('YAML CodeLens', () => { - const sandbox = createSandbox(); - let yamlSchemaService: SinonStubbedInstance; - let telemetryStub: SinonStubbedInstance; + let yamlSchemaService: { getSchemaForResource: Mock }; let telemetry: Telemetry; beforeEach(() => { - yamlSchemaService = sandbox.createStubInstance(YAMLSchemaService); - telemetryStub = sandbox.createStubInstance(TelemetryImpl); - telemetry = telemetryStub; + yamlSchemaService = { getSchemaForResource: mock.fn() }; + telemetry = { send: mock.fn(), sendError: mock.fn(), sendTrack: mock.fn() }; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); function createCommand(title: string, command: string, arg: string): Command { @@ -66,7 +60,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).is.not.empty; @@ -81,7 +75,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result[0].range).is.deep.equal(Range.create(0, 0, 0, 0)); @@ -102,7 +96,7 @@ describe('YAML CodeLens', () => { resolveConfiguration = resolve; }); - const getCodeLensStub = sandbox.stub().returns([expected]); + const getCodeLensStub = mock.fn(() => [expected]); const languageService = { getCodeLens: getCodeLensStub, } as unknown as LanguageService; @@ -120,11 +114,12 @@ describe('YAML CodeLens', () => { await Promise.resolve(); expect(settled).to.be.false; - expect(getCodeLensStub).not.called; + assert.equal(getCodeLensStub.mock.callCount(), 0); resolveConfiguration(); const result = await response; - expect(getCodeLensStub).calledOnceWithExactly(doc); + assert.equal(getCodeLensStub.mock.callCount(), 1); + assert.deepEqual(getCodeLensStub.mock.calls[0].arguments, [doc]); expect(result).deep.equal([expected]); }); @@ -133,7 +128,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result.length).to.eq(2); @@ -152,7 +147,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); @@ -168,8 +163,14 @@ describe('YAML CodeLens', () => { const podSchemaUrl = 'https://example.com/v1.36.1-standalone-strict/_definitions.json#/definitions/io.k8s.api.core.v1.Pod'; const policySchemaUrl = 'https://example.com/v1.36.1-standalone-strict/_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingAdmissionPolicy'; - yamlSchemaService.getSchemaForResource.onFirstCall().resolves(createResolvedSchema({ url: podSchemaUrl })); - yamlSchemaService.getSchemaForResource.onSecondCall().resolves(createResolvedSchema({ url: policySchemaUrl })); + yamlSchemaService.getSchemaForResource.mock.mockImplementationOnce( + () => Promise.resolve(createResolvedSchema({ url: podSchemaUrl })), + 0 + ); + yamlSchemaService.getSchemaForResource.mock.mockImplementationOnce( + () => Promise.resolve(createResolvedSchema({ url: policySchemaUrl })), + 1 + ); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); @@ -178,14 +179,16 @@ describe('YAML CodeLens', () => { createCodeLens('Pod (Kubernetes v1.36.1)', YamlCommands.JUMP_TO_SCHEMA, podSchemaUrl), createCodeLens('MutatingAdmissionPolicy (Kubernetes v1.36.1)', YamlCommands.JUMP_TO_SCHEMA, policySchemaUrl, 3), ]); - expect((yamlSchemaService.getSchemaForResource.firstCall.args[1] as SingleYAMLDocument).currentDocIndex).to.eq(0); - expect((yamlSchemaService.getSchemaForResource.secondCall.args[1] as SingleYAMLDocument).currentDocIndex).to.eq(1); + expect((yamlSchemaService.getSchemaForResource.mock.calls[0].arguments[1] as SingleYAMLDocument).currentDocIndex).to.eq(0); + expect((yamlSchemaService.getSchemaForResource.mock.calls[1].arguments[1] as SingleYAMLDocument).currentDocIndex).to.eq(1); }); it('should show the Kubernetes version for the generic all.json schema', async () => { const doc = setupTextDocument('apiVersion: v1\nkind: UnknownCoreResource'); const schemaUrl = 'https://example.com/v1.36.1-standalone-strict/all.json'; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema({ url: schemaUrl })); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => + Promise.resolve(createResolvedSchema({ url: schemaUrl })) + ); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).is.deep.equal([createCodeLens('Kubernetes v1.36.1', YamlCommands.JUMP_TO_SCHEMA, schemaUrl)]); @@ -197,7 +200,7 @@ describe('YAML CodeLens', () => { url: 'some://url/to/schema.json', title: 'fooBar', } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result[0].command).is.deep.equal( @@ -212,7 +215,7 @@ describe('YAML CodeLens', () => { title: 'fooBar', description: 'fooBarDescription', } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result[0].command).is.deep.equal( @@ -226,7 +229,7 @@ describe('YAML CodeLens', () => { url: 'https://json-schema.org/draft/2020-12/schema', title: 'JSON Schema Draft 2020-12', } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); @@ -252,7 +255,7 @@ describe('YAML CodeLens', () => { }, ], } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).has.length(2); @@ -274,7 +277,7 @@ describe('YAML CodeLens', () => { }, ], } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).has.length(2); @@ -296,7 +299,7 @@ describe('YAML CodeLens', () => { }, ], } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).has.length(2); diff --git a/test/yamlCommands.test.ts b/test/yamlCommands.test.ts index 3e3a90190..533fa142f 100644 --- a/test/yamlCommands.test.ts +++ b/test/yamlCommands.test.ts @@ -3,42 +3,38 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import { isDeepStrictEqual } from 'node:util'; +import assert from 'node:assert/strict'; -import type { SinonStub } from 'sinon'; -import { createSandbox, match } from 'sinon'; -import sinonChai from 'sinon-chai'; -import * as chai from 'chai'; import { registerCommands } from '../src/languageservice/services/yamlCommands.js'; import { commandExecutor } from '../src/languageserver/commandExecutor.js'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; -const expect = chai.expect; -chai.use(sinonChai); - describe('Yaml Commands', () => { const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; - const sandbox = createSandbox(); - let commandExecutorStub: SinonStub; + let commandExecutorStub: Mock; beforeEach(() => { - commandExecutorStub = sandbox.stub(commandExecutor, 'registerCommand'); + commandExecutorStub = mock.method(commandExecutor, 'registerCommand', () => undefined); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should register handler for "JumpToSchema" command', () => { registerCommands(commandExecutor, {} as Connection); - expect(commandExecutorStub).to.have.been.calledWithMatch(match('jumpToSchema'), match.func); + assert.equal(commandExecutorStub.mock.calls[0].arguments[0], 'jumpToSchema'); + assert.equal(typeof commandExecutorStub.mock.calls[0].arguments[1], 'function'); }); it('JumpToSchema handler should call "showDocument"', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([])); const connection = { window: { showDocument: showDocumentStub, @@ -47,16 +43,19 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1](JSON_SCHEMA_LOCAL); - expect(showDocumentStub).to.have.been.calledWith({ uri: JSON_SCHEMA_LOCAL, external: false, takeFocus: true }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [{ uri: JSON_SCHEMA_LOCAL, external: false, takeFocus: true }]) + ) + ); }); it('JumpToSchema handler should call "showDocument" with plain win path', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([])); const connection = { window: { showDocument: showDocumentStub, @@ -65,20 +64,25 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1]('a:\\some\\path\\to\\schema.json'); - expect(showDocumentStub).to.have.been.calledWith({ - uri: URI.file('a:\\some\\path\\to\\schema.json').toString(), - external: false, - takeFocus: true, - }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [ + { + uri: URI.file('a:\\some\\path\\to\\schema.json').toString(), + external: false, + takeFocus: true, + }, + ]) + ) + ); }); it('JumpToSchema handler should call "showDocument" with plain POSIX path', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([])); const connection = { window: { showDocument: showDocumentStub, @@ -87,20 +91,25 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1]('/some/path/to/schema.json'); - expect(showDocumentStub).to.have.been.calledWith({ - uri: URI.file('/some/path/to/schema.json').toString(), - external: false, - takeFocus: true, - }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [ + { + uri: URI.file('/some/path/to/schema.json').toString(), + external: false, + takeFocus: true, + }, + ]) + ) + ); }); it('JumpToSchema handler should call "showDocument" with custom web schema', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([{ uri: 'vscode-test:///root/' }])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([{ uri: 'vscode-test:///root/' }])); const connection = { window: { showDocument: showDocumentStub, @@ -109,14 +118,19 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1]('my-file.json'); - expect(showDocumentStub).to.have.been.calledWith({ - uri: URI.parse('vscode-test:///root/my-file.json').toString(), - external: false, - takeFocus: true, - }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [ + { + uri: URI.parse('vscode-test:///root/my-file.json').toString(), + external: false, + takeFocus: true, + }, + ]) + ) + ); }); }); diff --git a/test/yamlSchema.test.ts b/test/yamlSchema.test.ts index 6a65cc311..8ab499822 100644 --- a/test/yamlSchema.test.ts +++ b/test/yamlSchema.test.ts @@ -3,15 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import assert from 'node:assert/strict'; import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; -import type { SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; import * as chai from 'chai'; -import sinonChai from 'sinon-chai'; const expect = chai.expect; -chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { @@ -20,18 +19,18 @@ const workspaceContext = { }; describe('YAML Schema', () => { - const sandbox = createSandbox(); - let requestServiceStub: SinonStub; + let requestServiceStub: Mock; beforeEach(() => { - requestServiceStub = sandbox.stub(); + requestServiceStub = mock.fn(); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('Loading yaml scheme', async () => { - requestServiceStub.resolves(`%YAML 1.2 + requestServiceStub.mock.mockImplementation(() => + Promise.resolve(`%YAML 1.2 --- properties: fooBar: @@ -39,10 +38,12 @@ properties: type: string type: array type: object -`); +`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('fooScheme.yaml'); - expect(requestServiceStub.calledOnceWith('fooScheme.yaml')); + assert.equal(requestServiceStub.mock.callCount(), 1); + assert.deepEqual(requestServiceStub.mock.calls[0].arguments.slice(0, 1), ['fooScheme.yaml']); expect(result.schema.properties['fooBar']).eql({ items: { type: 'string' }, type: 'array', @@ -50,7 +51,7 @@ type: object }); it('Error while loading yaml', async () => { - requestServiceStub.rejects(); + requestServiceStub.mock.mockImplementation(() => Promise.reject(new Error())); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('fooScheme.yaml'); expect(result.errors).length(1); @@ -58,7 +59,7 @@ type: object }); it('Error while loading yaml should keep the underlying reason', async () => { - requestServiceStub.rejects(new Error('Request failed with status code 429')); + requestServiceStub.mock.mockImplementation(() => Promise.reject(new Error('Request failed with status code 429'))); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -67,7 +68,7 @@ type: object }); it('Empty response while loading yaml should report no content', async () => { - requestServiceStub.resolves(''); + requestServiceStub.mock.mockImplementation(() => Promise.resolve('')); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -77,7 +78,9 @@ type: object it('Unreachable host should report the connection failure, not an empty reason', async () => { // request-light wraps connection errors as '. Error: ', and for // ECONNREFUSED the underlying message is empty - the reason must not collapse to '' - requestServiceStub.rejects(new Error('Unable to connect to https://example.com/fooScheme.json. Error: ')); + requestServiceStub.mock.mockImplementation(() => + Promise.reject(new Error('Unable to connect to https://example.com/fooScheme.json. Error: ')) + ); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -89,7 +92,7 @@ type: object it('Error with no message should fall back to the error code', async () => { const connectionError = new Error(''); (connectionError as Error & { code: string }).code = 'ECONNREFUSED'; - requestServiceStub.rejects(connectionError); + requestServiceStub.mock.mockImplementation(() => Promise.reject(connectionError)); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -98,7 +101,7 @@ type: object it('Non-Error rejection should still report its reason', async () => { // schemaRequestHandler rethrows the response body as a plain string, not an Error - requestServiceStub.callsFake(() => Promise.reject('Too Many Requests')); + requestServiceStub.mock.mockImplementation(() => Promise.reject('Too Many Requests')); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -106,10 +109,13 @@ type: object }); it('Error while parsing yaml scheme', async () => { - requestServiceStub.resolves(`%464*&^^&*%@$&^##$`); + requestServiceStub.mock.mockImplementation(() => Promise.resolve(`%464*&^^&*%@$&^##$`)); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('fooScheme.yaml'); - expect(requestServiceStub.calledOnceWith('fooScheme.yaml')); + assert.deepEqual( + requestServiceStub.mock.calls.map((call) => call.arguments), + [['fooScheme.yaml'], ['fooScheme.yaml']] + ); expect(result.errors).length(1); expect(result.errors[0].message).includes('Unable to parse content from'); }); diff --git a/test/yamlSchemaService.test.ts b/test/yamlSchemaService.test.ts index cd24dd7e3..378127940 100644 --- a/test/yamlSchemaService.test.ts +++ b/test/yamlSchemaService.test.ts @@ -3,13 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import { isDeepStrictEqual } from 'node:util'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; import * as JSONC from 'jsonc-parser'; import * as path from 'path'; -import type { SinonFakeTimers, SinonSpy, SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { URI } from 'vscode-uri'; import * as YAML from 'yaml'; @@ -19,12 +20,12 @@ import * as SchemaService from '../src/languageservice/services/yamlSchemaServic import { DEFAULT_KUBERNETES_SCHEMA_VERSION, getSchemaUrls } from '../src/languageservice/utils/schemaUrls.js'; import { SchemaPriority } from '../src/languageservice/yamlLanguageService.js'; import { SettingsState } from '../src/yamlSettings.js'; +import { getDiagnosticMessage } from './utils/testHelper.js'; const BASE_KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/`; const KUBERNETES_SCHEMA_URL = BASE_KUBERNETES_SCHEMA_URL + 'all.json'; const expect = chai.expect; -chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { return new URL(relativePath, resource).toString(); @@ -32,16 +33,15 @@ const workspaceContext = { }; describe('YAML Schema Service', () => { - const sandbox = createSandbox(); afterEach(() => { - sandbox.restore(); + mock.reset(); }); describe('Schema for resource', () => { - let requestServiceMock: SinonSpy; + let requestServiceMock: Mock; beforeEach(() => { - requestServiceMock = sandbox.fake.resolves(undefined); + requestServiceMock = mock.fn(() => Promise.resolve(undefined)); }); it('should handle inline schema http url', () => { @@ -52,7 +52,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWith('http://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['http://json-schema.org/draft-07/schema#']); }); it('should handle inline schema https url', () => { @@ -63,25 +64,36 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWith('https://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://json-schema.org/draft-07/schema#']); }); it('should handle url with fragments', async () => { const content = `# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#/definitions/schemaArray\nfoo: bar`; const yamlDock = parse(content); - requestServiceMock = sandbox.fake.resolves(`{"definitions": {"schemaArray": { + requestServiceMock = mock.fn(() => + Promise.resolve(`{"definitions": {"schemaArray": { "type": "array", "minItems": 1, "items": { "$ref": "#" } - }}, "properties": {}}`); + }}, "properties": {}}`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledTwice; - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema'); - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema#/definitions/schemaArray'); + assert.equal(requestServiceMock.mock.callCount(), 2); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema']) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema#/definitions/schemaArray']) + ) + ); expect(schema.schema.type).eqls('array'); }); @@ -90,7 +102,8 @@ describe('YAML Schema Service', () => { const content = `# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#/definitions/schemaArray`; const yamlDock = parse(content); - requestServiceMock = sandbox.fake.resolves(`{"definitions": {"schemaArray": { + requestServiceMock = mock.fn(() => + Promise.resolve(`{"definitions": {"schemaArray": { "type": "array", "minItems": 1, "items": { "$ref": "#" } @@ -98,14 +111,23 @@ describe('YAML Schema Service', () => { "bar": { "type": "string" } - }, "properties": {"foo": {"type": "boolean"}}, "required": ["foo"]}`); + }, "properties": {"foo": {"type": "boolean"}}, "required": ["foo"]}`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledTwice; - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema'); - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema#/definitions/schemaArray'); + assert.equal(requestServiceMock.mock.callCount(), 2); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema']) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema#/definitions/schemaArray']) + ) + ); expect(schema.schema.type).eqls('array'); expect(schema.schema.required).is.undefined; @@ -116,26 +138,38 @@ describe('YAML Schema Service', () => { const content = `# yaml-language-server: $schema=schema.json#/definitions/schemaArray\nfoo: bar`; const yamlDock = parse(content); - requestServiceMock = sandbox.fake.resolves(`{"definitions": {"schemaArray": { + requestServiceMock = mock.fn(() => + Promise.resolve(`{"definitions": {"schemaArray": { "type": "array", "minItems": 1, "items": { "$ref": "#" } - }}, "properties": {}}`); + }}, "properties": {}}`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledTwice; + assert.equal(requestServiceMock.mock.callCount(), 2); if (process.platform === 'win32') { const driveLetter = path .parse(import.meta.dirname) .root.split(':')[0] .toLowerCase(); - expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json`); - expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json#/definitions/schemaArray`); + assert.ok( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [`file:///${driveLetter}:/schema.json`])) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [`file:///${driveLetter}:/schema.json#/definitions/schemaArray`]) + ) + ); } else { - expect(requestServiceMock).calledWithExactly('file:///schema.json'); - expect(requestServiceMock).calledWithExactly('file:///schema.json#/definitions/schemaArray'); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///schema.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['file:///schema.json#/definitions/schemaArray']) + ) + ); } expect(schema.schema.type).eqls('array'); @@ -146,20 +180,22 @@ describe('YAML Schema Service', () => { const yamlDock = parse(content); const resource = URI.file(path.join(import.meta.dirname, 'test.yaml')).toString(); const expectedSchemaPath = URI.parse(URI.file(path.join(import.meta.dirname, 'encoded schema.json')).toString()).fsPath; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - type: 'object', - properties: { - foo: { type: 'string' }, - }, - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + type: 'object', + properties: { + foo: { type: 'string' }, + }, + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource(resource, yamlDock.documents[0]); - expect(requestServiceMock).calledOnce; - expect(URI.parse(requestServiceMock.firstCall.args[0]).fsPath).equals(expectedSchemaPath); + assert.equal(requestServiceMock.mock.callCount(), 1); + expect(URI.parse(requestServiceMock.mock.calls[0].arguments[0]).fsPath).equals(expectedSchemaPath); expect(schema.schema.properties.foo).to.include({ type: 'string' }); }); @@ -172,20 +208,22 @@ describe('YAML Schema Service', () => { const expectedSchemaPath = URI.parse( URI.file(path.join(path.parse(import.meta.dirname).root, 'encoded schema.json')).toString() ).fsPath; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - type: 'object', - properties: { - foo: { type: 'string' }, - }, - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + type: 'object', + properties: { + foo: { type: 'string' }, + }, + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource(resource, yamlDock.documents[0]); - expect(requestServiceMock).calledOnce; - expect(URI.parse(requestServiceMock.firstCall.args[0]).fsPath).equals(expectedSchemaPath); + assert.equal(requestServiceMock.mock.callCount(), 1); + expect(URI.parse(requestServiceMock.mock.calls[0].arguments[0]).fsPath).equals(expectedSchemaPath); expect(schema.schema.properties.foo).to.include({ type: 'string' }); }); @@ -196,20 +234,23 @@ describe('YAML Schema Service', () => { it(`should resolve a schema URI with an ${description}`, async () => { const yamlDock = parse('foo: bar'); const normalizedUri = 'file:///c:/Users/user1/schema.json'; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - type: 'object', - properties: { - foo: { type: 'string' }, - }, - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + type: 'object', + properties: { + foo: { type: 'string' }, + }, + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.registerExternalSchema(uri, ['test.yaml']); const schema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWithExactly(normalizedUri); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments, [normalizedUri]); expect(schema.schema.properties.foo).to.include({ type: 'string' }); }); } @@ -232,7 +273,7 @@ describe('YAML Schema Service', () => { enum: ['dev', 'prod'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -245,7 +286,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///schemas/primary.json'); expect(requestedUris).to.include('file:///schemas/secondary.json'); expect(requestedUris).to.not.include('https://example.com/schemas/secondary.json'); @@ -286,7 +327,7 @@ describe('YAML Schema Service', () => { }, }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/repro_main_schema.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -299,7 +340,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///schemas/repro_main_schema.json'); expect(requestedUris).to.include('file:///schemas/repro_defs.json'); expect(requestedUris).to.not.include('https://example.com/schemas/repro_defs.json'); @@ -331,7 +372,7 @@ describe('YAML Schema Service', () => { oneOf: [{ $ref: 'node.json' }], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/node.json') { return Promise.resolve(JSON.stringify(nodeSchema)); } @@ -385,7 +426,7 @@ describe('YAML Schema Service', () => { }, }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schemaUri) { return Promise.resolve(JSON.stringify(schema3)); } @@ -396,12 +437,13 @@ describe('YAML Schema Service', () => { const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); expect(resolvedSchema.schema._sourceUri).to.equal(schemaUri); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.eql([schemaUri]); expect(resolvedSchema.errors).to.eql([]); expect(resolvedSchema.schema.properties.child).to.deep.include({ type: 'object' }); expect((resolvedSchema.schema.properties.child as JSONSchema).properties.value).to.deep.include({ type: 'integer' }); - expect(requestServiceMock).calledOnceWithExactly(schemaUri); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments, [schemaUri]); }); it('should resolve a relative local sibling-file reference through non-standard schema containers', async () => { @@ -439,7 +481,7 @@ describe('YAML Schema Service', () => { }, }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schema3Uri) { return Promise.resolve(JSON.stringify(schema3)); } @@ -452,7 +494,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.eql([schema3Uri, schema2Uri]); expect(resolvedSchema.errors).to.eql([]); expect(resolvedSchema.schema.properties.child).to.deep.include({ @@ -460,9 +502,9 @@ describe('YAML Schema Service', () => { url: schema2Uri, }); expect((resolvedSchema.schema.properties.child as JSONSchema).properties.value).to.deep.include({ type: 'integer' }); - expect(requestServiceMock).calledWithExactly(schema3Uri); - expect(requestServiceMock).calledWithExactly(schema2Uri); - expect(requestServiceMock).callCount(2); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [schema3Uri]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [schema2Uri]))); + assert.equal(requestServiceMock.mock.callCount(), 2); }); it('should resolve nested local sibling refs relative to the loaded sibling schema file', async () => { @@ -492,7 +534,7 @@ describe('YAML Schema Service', () => { enum: ['ok'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -508,7 +550,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///schemas/primary.json'); expect(requestedUris).to.include('file:///schemas/secondary.json'); expect(requestedUris).to.include('file:///schemas/third.json'); @@ -539,7 +581,7 @@ describe('YAML Schema Service', () => { required: ['name', 'age'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -552,7 +594,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///dir/primary.json'); expect(requestedUris).to.include('file:///dir/secondary.json'); expect(requestedUris).to.not.include('file:///schemas/secondary.json'); @@ -577,7 +619,7 @@ describe('YAML Schema Service', () => { required: ['name', 'age'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -590,7 +632,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///dir/primary.json'); expect(requestedUris).to.include('file:///dir/secondary.json'); expect(requestedUris).to.include('https://example.com/schemas/secondary.json'); @@ -618,7 +660,7 @@ describe('YAML Schema Service', () => { enum: ['dev', 'prod'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -631,9 +673,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedSecondaryUrisAfterFirstLoad = requestServiceMock - .getCalls() - .map((call) => call.args[0]) + const requestedSecondaryUrisAfterFirstLoad = requestServiceMock.mock.calls + .map((call) => call.arguments[0]) .filter((uri) => uri === 'file:///schemas/secondary.json'); expect(requestedSecondaryUrisAfterFirstLoad).to.have.length(1); @@ -641,9 +682,8 @@ describe('YAML Schema Service', () => { service.onResourceChange('file:///schemas/secondary.json'); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedSecondaryUrisAfterChange = requestServiceMock - .getCalls() - .map((call) => call.args[0]) + const requestedSecondaryUrisAfterChange = requestServiceMock.mock.calls + .map((call) => call.arguments[0]) .filter((uri) => uri === 'file:///schemas/secondary.json'); expect(requestedSecondaryUrisAfterChange).to.have.length(2); }); @@ -672,7 +712,7 @@ describe('YAML Schema Service', () => { required: ['openapi', 'info'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'https://example.com/schemas/openapi-extensions.json') { return Promise.resolve(JSON.stringify(extensionsSchema)); } @@ -685,7 +725,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('https://example.com/schemas/openapi-extensions.json'); expect(requestedUris).to.include('https://example.com/schemas/openapi.v3.1.json'); // _preferLocalBaseForRemoteId should NOT probe for the $id basename as a local sibling @@ -699,7 +739,7 @@ describe('YAML Schema Service', () => { const schemaOneUri = 'file:///Users/test/schemas/schema1.json'; const schemaTwoUri = 'file:///Users/test/schemas/schema2.json'; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schemaOneUri) { return Promise.resolve(JSON.stringify({ title: 'Schema 1', type: 'object' })); } @@ -715,7 +755,7 @@ describe('YAML Schema Service', () => { const schema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include(schemaOneUri); expect(requestedUris).to.include(schemaTwoUri); expect(requestedUris.some((uri) => uri.startsWith('schemaservice:///'))).to.be.false; @@ -737,7 +777,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('should ignore modeline schema comment using $schema in the middle of file after yaml content', async () => { @@ -748,7 +788,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('should handle modeline schema comment in multiline comments at document header', async () => { @@ -759,7 +799,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWith('https://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://json-schema.org/draft-07/schema#']); }); it('should ignore modeline schema comment in multiline comments after yaml content', async () => { @@ -770,7 +811,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('should handle modeline schema comment after document separator', () => { @@ -780,7 +821,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.getSchemaForResource('', yamlDock.documents[1]); - expect(requestServiceMock).calledOnceWith('https://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://json-schema.org/draft-07/schema#']); }); it('should handle crd catalog for crd', async () => { @@ -793,15 +835,15 @@ describe('YAML Schema Service', () => { kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { "$ref": "_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook" } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -811,13 +853,17 @@ describe('YAML Schema Service', () => { 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); - expect(requestServiceMock).calledWithExactly( - 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json' + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json', + ]) + ) ); - expect(requestServiceMock).calledThrice; + assert.equal(requestServiceMock.mock.callCount(), 3); }); it('should handle nonstandard location for OpenShift crd', async () => { @@ -836,15 +882,15 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { "$ref": "_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook" } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -854,13 +900,17 @@ spec: 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/openshift/v4.15-strict/route_route.openshift.io_v1.json' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); - expect(requestServiceMock).calledWithExactly( - 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/openshift/v4.15-strict/route_route.openshift.io_v1.json' + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/openshift/v4.15-strict/route_route.openshift.io_v1.json', + ]) + ) ); - expect(requestServiceMock).calledThrice; + assert.equal(requestServiceMock.mock.callCount(), 3); }); it('should not get schema from crd catalog if definition in kubernetes schema', async () => { @@ -873,15 +923,15 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { "$ref": "_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook" } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -890,13 +940,21 @@ spec: BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); - expect(requestServiceMock).calledWithExactly( - BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook' + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook', + ]) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [BASE_KUBERNETES_SCHEMA_URL + '_definitions.json']) + ) ); - expect(requestServiceMock).calledWithExactly(BASE_KUBERNETES_SCHEMA_URL + '_definitions.json'); - expect(requestServiceMock.callCount).equals(4); + expect(requestServiceMock.mock.callCount()).equals(4); }); it('should treat CustomResourceDefinition as a builtin Kubernetes resource', async () => { @@ -912,10 +970,12 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - oneOf: [{ $ref: builtinDefinition }], - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + oneOf: [{ $ref: builtinDefinition }], + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -923,7 +983,10 @@ spec: const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(BASE_KUBERNETES_SCHEMA_URL + builtinDefinition); - expect(requestServiceMock).not.calledWith(crdCatalogURL); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [crdCatalogURL])), + false + ); }); it('should treat an older CustomResourceDefinition version as builtin when present', async () => { @@ -939,10 +1002,12 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - oneOf: [{ $ref: builtinDefinition }], - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + oneOf: [{ $ref: builtinDefinition }], + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -950,7 +1015,10 @@ spec: const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(BASE_KUBERNETES_SCHEMA_URL + builtinDefinition); - expect(requestServiceMock).not.calledWith(crdCatalogURL); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [crdCatalogURL])), + false + ); }); it('should fall back to all.json for an unsupported CustomResourceDefinition version', async () => { @@ -964,14 +1032,17 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves('{"oneOf": []}'); + requestServiceMock = mock.fn(() => Promise.resolve('{"oneOf": []}')); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).not.calledWith(crdCatalogURL); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [crdCatalogURL])), + false + ); }); it('should still use the CRD catalog for a similarly named custom API group', async () => { @@ -985,14 +1056,16 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - oneOf: [ - { - $ref: '_definitions.json#/definitions/io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinition', - }, - ], - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + oneOf: [ + { + $ref: '_definitions.json#/definitions/io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinition', + }, + ], + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -1000,21 +1073,22 @@ spec: const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(crdCatalogURL); - expect(requestServiceMock).calledWithExactly(crdCatalogURL); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [crdCatalogURL]))); }); it('should fall back to all.json instead of the CRD catalog for an unknown core resource', async () => { const yamlDock = parse('apiVersion: v1\nkind: UnknownCoreResource'); const settings = new SettingsState(); settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves('{"oneOf": []}'); + requestServiceMock = mock.fn(() => Promise.resolve('{"oneOf": []}')); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledOnceWithExactly(KUBERNETES_SCHEMA_URL); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments, [KUBERNETES_SCHEMA_URL]); }); it('should not get schema from crd catalog if definition in kubernetes schema (multiple oneOf)', async () => { @@ -1027,8 +1101,8 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { @@ -1039,7 +1113,7 @@ spec: } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -1048,13 +1122,21 @@ spec: BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.apps.v1.Deployment' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); - expect(requestServiceMock).calledWithExactly( - BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.apps.v1.Deployment' + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.apps.v1.Deployment', + ]) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [BASE_KUBERNETES_SCHEMA_URL + '_definitions.json']) + ) ); - expect(requestServiceMock).calledWithExactly(BASE_KUBERNETES_SCHEMA_URL + '_definitions.json'); - expect(requestServiceMock.callCount).equals(4); + expect(requestServiceMock.mock.callCount()).equals(4); }); it('should not get schema from crd catalog for RBAC-related resources', async () => { @@ -1067,8 +1149,8 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { @@ -1076,7 +1158,7 @@ spec: } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -1085,13 +1167,21 @@ spec: BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.rbac.v1.RoleBinding' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); - expect(requestServiceMock).calledWithExactly( - BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.rbac.v1.RoleBinding' + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.rbac.v1.RoleBinding', + ]) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [BASE_KUBERNETES_SCHEMA_URL + '_definitions.json']) + ) ); - expect(requestServiceMock).calledWithExactly(BASE_KUBERNETES_SCHEMA_URL + '_definitions.json'); - expect(requestServiceMock.callCount).equals(4); + expect(requestServiceMock.mock.callCount()).equals(4); }); it('should use GVK to get correct schema', async () => { @@ -1123,7 +1213,7 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake((uri) => { + requestServiceMock = mock.fn((uri) => { if (uri === KUBERNETES_SCHEMA_URL) { return Promise.resolve(` { @@ -1279,7 +1369,7 @@ spec: }, }, }); - requestServiceMock = sandbox.fake((uri) => { + requestServiceMock = mock.fn((uri) => { if (uri === KUBERNETES_SCHEMA_URL) { return Promise.resolve( JSON.stringify({ @@ -1312,7 +1402,7 @@ spec: yamlDock.documents.map((document) => service.getSchemaForResource('templates/policies/foo.yaml', document)) ); const messages = yamlDock.documents.flatMap((document, index) => - document.validate(textDocument, resolvedSchemas[index].schema).map((diagnostic) => diagnostic.message) + document.validate(textDocument, resolvedSchemas[index].schema).map(getDiagnosticMessage) ); return { schemaUrls: resolvedSchemas.map((schema) => schema.schema.url), @@ -1480,7 +1570,7 @@ spec: required: ['name', 'age'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/my-schema.yaml') { return Promise.resolve(YAML.stringify(mySchema)); } @@ -1490,7 +1580,7 @@ spec: const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///dir/my-schema.yaml'); expect(requestedUris.length).to.equal(1); expect(resolvedSchema.errors.length).to.equal(0); @@ -1559,7 +1649,7 @@ properties: "$ref": "#/$defs/contact" description: Maintainers of the apis.json file`; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/my-schema.yaml') { return Promise.resolve(mySchema); } @@ -1569,7 +1659,7 @@ properties: const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); const errors = []; const parsedSchema = JSONC.parse(mySchema, errors); @@ -1584,17 +1674,14 @@ properties: describe('Caching of failed schema loads', () => { const SCHEMA_URI = 'https://example.com/schema.json'; const schemaContent = JSON.stringify({ type: 'object', properties: { foo: { type: 'string' } } }); - let clock: SinonFakeTimers; + let now: number; beforeEach(() => { - clock = sandbox.useFakeTimers({ now: Date.now(), shouldAdvanceTime: false }); + now = Date.now(); + mock.method(Date, 'now', () => now); }); - afterEach(() => { - clock.restore(); - }); - - const createService = (requestService: SinonStub): SchemaService.YAMLSchemaService => { + const createService = (requestService: SchemaRequestService): SchemaService.YAMLSchemaService => { const service = new SchemaService.YAMLSchemaService(requestService, workspaceContext); service.registerExternalSchema(SCHEMA_URI, ['*.yaml']); return service; @@ -1604,56 +1691,58 @@ properties: service.getSchemaForResource('test.yaml', parse('foo: bar\n').documents[0]); it('should not request a failed schema again within the caching window', async () => { - const requestService = sandbox.stub().rejects(new Error('Request failed with status code 429')); + const requestService = mock.fn(() => + Promise.reject(new Error('Request failed with status code 429')) + ); const service = createService(requestService); await resolveSchema(service); - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS - 1); + now += SchemaService.FAILED_SCHEMA_CACHE_MS - 1; await resolveSchema(service); - expect(requestService).calledOnce; + assert.equal(requestService.mock.callCount(), 1); }); it('should request a failed schema again once the caching window has passed', async () => { - const requestService = sandbox.stub(); - requestService.onFirstCall().rejects(new Error('Request failed with status code 429')); - requestService.resolves(schemaContent); + const requestService = mock.fn(); + requestService.mock.mockImplementationOnce(() => Promise.reject(new Error('Request failed with status code 429')), 0); + requestService.mock.mockImplementation(() => Promise.resolve(schemaContent)); const service = createService(requestService); const failed = await resolveSchema(service); expect(failed.errors).to.not.be.empty; - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS); + now += SchemaService.FAILED_SCHEMA_CACHE_MS; const recovered = await resolveSchema(service); - expect(requestService).calledTwice; + assert.equal(requestService.mock.callCount(), 2); expect(recovered.errors).to.be.empty; expect(recovered.schema.properties).to.have.property('foo'); }); it('should keep caching a successful schema load', async () => { - const requestService = sandbox.stub().resolves(schemaContent); + const requestService = mock.fn(() => Promise.resolve(schemaContent)); const service = createService(requestService); await resolveSchema(service); - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS * 10); + now += SchemaService.FAILED_SCHEMA_CACHE_MS * 10; const second = await resolveSchema(service); - expect(requestService).calledOnce; + assert.equal(requestService.mock.callCount(), 1); expect(second.errors).to.be.empty; }); it('should not serve a stale resolved schema after a cached failure expires', async () => { - const requestService = sandbox.stub(); - requestService.onFirstCall().rejects(new Error('Request failed with status code 429')); - requestService.resolves(schemaContent); + const requestService = mock.fn(); + requestService.mock.mockImplementationOnce(() => Promise.reject(new Error('Request failed with status code 429')), 0); + requestService.mock.mockImplementation(() => Promise.resolve(schemaContent)); const service = createService(requestService); // Resolve first, so a resolved schema built from the failure is cached too. const failed = await resolveSchema(service); expect(failed.errors).to.not.be.empty; - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS); + now += SchemaService.FAILED_SCHEMA_CACHE_MS; const recovered = await resolveSchema(service); expect(recovered.errors).to.be.empty; diff --git a/test/yamlValidation.test.ts b/test/yamlValidation.test.ts index e0b0ef625..c4707fdd5 100644 --- a/test/yamlValidation.test.ts +++ b/test/yamlValidation.test.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, before, afterEach } from 'node:test'; +import { describe, it, before, afterEach, mock } from 'node:test'; import type { Diagnostic } from 'vscode-languageserver-types'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; @@ -12,7 +12,6 @@ import { TextDocumentTestManager } from '../src/yamlSettings.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import { setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import { expect } from 'chai'; -import { createSandbox } from 'sinon'; import { createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError.js'; type ValidationHandlerWithConnection = { @@ -24,13 +23,12 @@ type ValidationHandlerWithConnection = { }; describe('YAML Validation Tests', () => { - const sandbox = createSandbox(); let languageSettingsSetup: ServiceSetup; let validationHandler: ValidationHandler; let yamlSettings: SettingsState; afterEach(() => { - sandbox.restore(); + mock.reset(); }); before(() => { @@ -54,7 +52,7 @@ describe('YAML Validation Tests', () => { yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const connection = (validationHandler as unknown as ValidationHandlerWithConnection).connection; - sandbox.stub(connection.workspace, 'getConfiguration').resolves({ 'yaml.validate': false }); + mock.method(connection.workspace, 'getConfiguration', () => Promise.resolve({ 'yaml.validate': false })); yamlSettings.hasConfigurationCapability = true; const result = await validationHandler.validateTextDocument(testTextDocument); expect(result).to.be.empty; From aa23af36045b1e0b6ff1c29b89683efe8b1b11aa Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Wed, 7 Oct 2026 16:34:12 -0400 Subject: [PATCH 05/18] update README.md Signed-off-by: Morgan Chang --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60b722ba2..1d20ed80f 100755 --- a/README.md +++ b/README.md @@ -594,7 +594,7 @@ interface JSONSchemaDescriptionExt extends JSONSchemaDescription { ### Prerequisites -- [Node.js](https://nodejs.org/) v18.18.0 or higher +- [Node.js](https://nodejs.org/) v22.13.0 or higher - npm ### Setup @@ -618,6 +618,14 @@ The main server output is generated in `out/server/src`. Use `npm test` to run tests. +Use `npm run coveralls` to run tests with coverage and generate text and LCOV reports. Coverage uses nyc with pre-instrumented ESM: + +1. Clean and compile the source and tests into `out/server`. +2. Run `npm run coverage:instrument` to create a copy in `out/coverage`, adding coverage counters to the server JavaScript and copying tests and fixtures unchanged. +3. Run the copied tests with `nyc --instrument=false`, collecting the existing counters and mapping coverage back to TypeScript through source maps. + +The instrumented copy is only for coverage; the package entry point remains under `out/server`. + ### Module builds Building YAML Language Server produces [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) and declarations in the `out/server/src` directory. From 2c1cd23055e038848f512b64203a535e32eea9aa Mon Sep 17 00:00:00 2001 From: Noritaka Kobayashi Date: Thu, 8 Oct 2026 07:58:49 +0900 Subject: [PATCH 06/18] chore: remove redundant direct dependency on @typescript-eslint/parser (#1357) Co-authored-by: Morgan Chang --- package-lock.json | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 14da34d3e..21cd8b0f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,6 @@ "@types/picomatch": "^4.0.3", "@types/sinon": "^9.0.5", "@types/sinon-chai": "^3.2.5", - "@typescript-eslint/parser": "^8.59.4", "chai": "^4.2.0", "eslint": "^10.0.0", "eslint-plugin-import-x": "^4.0.0", diff --git a/package.json b/package.json index abba50994..f99af9d26 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "@types/picomatch": "^4.0.3", "@types/sinon": "^9.0.5", "@types/sinon-chai": "^3.2.5", - "@typescript-eslint/parser": "^8.59.4", "chai": "^4.2.0", "eslint": "^10.0.0", "eslint-plugin-import-x": "^4.0.0", From f7aaab724bab53788ee052d21151960255c8d18c Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Wed, 7 Oct 2026 17:12:51 -0400 Subject: [PATCH 07/18] upgrade rimraf to v6 Signed-off-by: Morgan Chang --- package-lock.json | 136 ++++++++++++++++------------------------------ package.json | 2 +- 2 files changed, 49 insertions(+), 89 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21cd8b0f6..655ea856d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "eslint-plugin-prettier": "^5.0.0", "mocha": "12.0.0", "nyc": "^18.0.0", - "rimraf": "^3.0.2", + "rimraf": "^6.1.3", "sinon": "^9.0.3", "sinon-chai": "^3.5.0", "source-map-support": "^0.5.19", @@ -1048,6 +1048,28 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@microsoft/eslint-formatter-sarif/node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", @@ -1071,6 +1093,23 @@ "dev": true, "license": "MIT" }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@napi-rs/wasm-runtime": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.5.tgz", @@ -3407,26 +3446,6 @@ "node": "20 || >=22" } }, - "node_modules/istanbul-lib-processinfo/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/istanbul-lib-report": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", @@ -4047,26 +4066,6 @@ "node": ">=8" } }, - "node_modules/nyc/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/nyc/node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -4612,39 +4611,20 @@ } }, "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", + "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { - "glob": "^7.1.3" + "glob": "^13.0.3", + "package-json-from-dist": "^1.0.1" }, "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/rimraf/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": "*" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -4835,26 +4815,6 @@ "node": ">=8.0.0" } }, - "node_modules/spawn-wrap/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/spawn-wrap/node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", diff --git a/package.json b/package.json index f99af9d26..0e9f681f3 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "eslint-plugin-prettier": "^5.0.0", "mocha": "12.0.0", "nyc": "^18.0.0", - "rimraf": "^3.0.2", + "rimraf": "^6.1.3", "sinon": "^9.0.3", "sinon-chai": "^3.5.0", "source-map-support": "^0.5.19", From 4d0130632404e6d9473054608905911eea12a87d Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Wed, 7 Oct 2026 16:59:32 -0400 Subject: [PATCH 08/18] fix DEP0169 warning Signed-off-by: Morgan Chang --- .../services/schemaRequestHandler.ts | 3 +- test/schema.test.ts | 3 +- test/schemaRequestHandler.test.ts | 49 ++++++++++++++++++- test/yamlSchema.test.ts | 3 +- test/yamlSchemaService.test.ts | 3 +- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/languageservice/services/schemaRequestHandler.ts b/src/languageservice/services/schemaRequestHandler.ts index 55ef10766..cb49cbbb6 100644 --- a/src/languageservice/services/schemaRequestHandler.ts +++ b/src/languageservice/services/schemaRequestHandler.ts @@ -1,6 +1,5 @@ import { join } from 'path'; import { getErrorStatusDescription, xhr } from 'request-light'; -import * as URL from 'url'; import type { Connection, WorkspaceFolder } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; @@ -227,6 +226,6 @@ export const schemaRequestHandler = async ( export const workspaceContext: WorkspaceContextService = { resolveRelativePath: (relativePath: string, resource: string) => { - return URL.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; diff --git a/test/schema.test.ts b/test/schema.test.ts index 746a9f815..e9ca25cd7 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -2,7 +2,6 @@ import assert from 'assert'; import * as parser from '../src/languageservice/parser/yamlParser07'; import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; import type * as JsonSchema from '../src/languageservice/jsonSchema'; -import * as url from 'url'; import * as path from 'path'; import { xhr } from 'request-light'; import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService'; @@ -30,7 +29,7 @@ const requestServiceMock = function (uri: string): Promise { const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { - return url.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; diff --git a/test/schemaRequestHandler.test.ts b/test/schemaRequestHandler.test.ts index 1c3301a27..90a51484a 100644 --- a/test/schemaRequestHandler.test.ts +++ b/test/schemaRequestHandler.test.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { schemaRequestHandler } from '../src/languageservice/services/schemaRequestHandler'; +import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler'; import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler'; import * as sinon from 'sinon'; import * as request from 'request-light'; @@ -18,6 +18,53 @@ chai.use(sinonChai); import { testFileSystem } from './utils/testHelper'; describe('Schema Request Handler Tests', () => { + describe('workspaceContext', () => { + const cases = [ + { + name: 'relative HTTP schema references', + resource: 'https://example.com/schemas/root.json', + relativePath: '../shared.json#/definitions/value', + expected: 'https://example.com/shared.json#/definitions/value', + }, + { + name: 'absolute schema references', + resource: 'https://example.com/schemas/root.json', + relativePath: 'https://other.example.com/schema.json', + expected: 'https://other.example.com/schema.json', + }, + { + name: 'schema fragments', + resource: 'https://example.com/schema.json', + relativePath: '#/definitions/value', + expected: 'https://example.com/schema.json#/definitions/value', + }, + { + name: 'file URLs with encoded spaces', + resource: 'file:///home/user/my%20schemas/root.json', + relativePath: './other%20schema.json', + expected: 'file:///home/user/my%20schemas/other%20schema.json', + }, + { + name: 'Windows file URLs', + resource: 'file:///c%3A/Users/user/schemas/root.json', + relativePath: '../shared.json', + expected: 'file:///c%3A/Users/user/shared.json', + }, + { + name: 'custom document schemes', + resource: 'vscode-test:///workspace/schemas/root.json', + relativePath: '../shared.json', + expected: 'vscode-test:///workspace/shared.json', + }, + ]; + + for (const { name, resource, relativePath, expected } of cases) { + it(`should resolve ${name}`, () => { + expect(workspaceContext.resolveRelativePath(relativePath, resource)).to.equal(expected); + }); + } + }); + describe('schemaRequestHandler', () => { const sandbox = sinon.createSandbox(); let readFileStub: sinon.SinonStub; diff --git a/test/yamlSchema.test.ts b/test/yamlSchema.test.ts index 39aee28a6..1d3f594df 100644 --- a/test/yamlSchema.test.ts +++ b/test/yamlSchema.test.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import * as url from 'url'; import * as sinon from 'sinon'; import * as chai from 'chai'; import sinonChai from 'sinon-chai'; @@ -13,7 +12,7 @@ chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { - return url.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; diff --git a/test/yamlSchemaService.test.ts b/test/yamlSchemaService.test.ts index 56f69ca14..f2eb8b7bc 100644 --- a/test/yamlSchemaService.test.ts +++ b/test/yamlSchemaService.test.ts @@ -7,7 +7,6 @@ import * as JSONC from 'jsonc-parser'; import * as path from 'path'; import * as sinon from 'sinon'; import sinonChai from 'sinon-chai'; -import * as url from 'url'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { URI } from 'vscode-uri'; import * as YAML from 'yaml'; @@ -25,7 +24,7 @@ const expect = chai.expect; chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { - return url.resolve(resource, relativePath); + return new URL(relativePath, resource).toString(); }, }; From 794d241400c0dd94b38031382a9c58a8fb9dadee Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Fri, 9 Oct 2026 14:10:30 -0400 Subject: [PATCH 09/18] update README.md Signed-off-by: Morgan Chang --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 1d20ed80f..bd9e17d75 100755 --- a/README.md +++ b/README.md @@ -618,14 +618,6 @@ The main server output is generated in `out/server/src`. Use `npm test` to run tests. -Use `npm run coveralls` to run tests with coverage and generate text and LCOV reports. Coverage uses nyc with pre-instrumented ESM: - -1. Clean and compile the source and tests into `out/server`. -2. Run `npm run coverage:instrument` to create a copy in `out/coverage`, adding coverage counters to the server JavaScript and copying tests and fixtures unchanged. -3. Run the copied tests with `nyc --instrument=false`, collecting the existing counters and mapping coverage back to TypeScript through source maps. - -The instrumented copy is only for coverage; the package entry point remains under `out/server`. - ### Module builds Building YAML Language Server produces [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) and declarations in the `out/server/src` directory. From b80d6df5b2af22146b20298b8fc29f9b2a4b18e3 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Fri, 9 Oct 2026 13:54:41 -0400 Subject: [PATCH 10/18] CHANGELOG for 1.25.0 Signed-off-by: Morgan Chang --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 272dbe977..9d2bd9f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +### 1.25.0 + +- Feat: Add support for negated schema file-match patterns in `yaml.schemas`. See [#1345](https://github.com/redhat-developer/yaml-language-server/pull/1345). +- Feat: Show a separate schema CodeLens for each YAML document, with resource-specific titles for Kubernetes schemas. See [#1309](https://github.com/redhat-developer/yaml-language-server/pull/1309). +- Fix: Schema fileMatch regression in 1.24.0 where single `*` in glob patterns matches across path separators. See [#1295](https://github.com/redhat-developer/yaml-language-server/issues/1295). +- Fix: Preserve Kubernetes schema priority after resource-specific schema detection, preventing SchemaStore associations from overriding the configured Kubernetes schema. See [#1298](https://github.com/redhat-developer/yaml-language-server/issues/1298). +- Fix: Schema priority lookup for normalized file URIs. See [#1312](https://github.com/redhat-developer/yaml-language-server/pull/1312). +- Fix: Type diagnostic reports schema filenames instead of `"object"` when multiple schemas match. See [#1317](https://github.com/redhat-developer/yaml-language-server/issues/1317). +- Fix: `enum` and `const` validation for nested boolean values. See [#1323](https://github.com/redhat-developer/yaml-language-server/pull/1323). +- Fix: Resolve schema references through non-standard containers such as `#/components/schemas`, including nested references to the same local file or a sibling file. See [#1322](https://github.com/redhat-developer/yaml-language-server/issues/1322). +- Fix: Report the underlying reason when a schema fails to load instead of always reporting `No content`. See [#1337](https://github.com/redhat-developer/yaml-language-server/issues/1337) and [vscode-yaml#1282](https://github.com/redhat-developer/vscode-yaml/pull/1282). +- Fix: Retry remote schema requests after transient HTTP or connection failures. See [#1341](https://github.com/redhat-developer/yaml-language-server/issues/1341) and [vscode-yaml#1284](https://github.com/redhat-developer/vscode-yaml/issues/1284). +- Fix: Resolve nested schema paths prefixed with a workspace folder name and match a workspace folder name only as a whole path segment in multi-root workspaces. See [#1348](https://github.com/redhat-developer/yaml-language-server/pull/1348) and [#1349](https://github.com/redhat-developer/yaml-language-server/pull/1349). +- Fix: Improve handling of schemas written using YAML when the first key is quoted, and avoid requesting the same schema content twice. See [vscode-yaml#1275](https://github.com/redhat-developer/vscode-yaml/issues/1275). +- Fix: Detect SchemaStore schemas for nonstandard and extensionless YAML filenames such as `.clang-format`. See [vscode-yaml#1124](https://github.com/redhat-developer/vscode-yaml/issues/1124). +- Fix: Make formatter settings resource scoped. See [vscode-yaml#1240](https://github.com/redhat-developer/vscode-yaml/issues/1240). +- Fix: Keep automatic schema detection for more specific extensions out of user settings. See [vscode-yaml#1271](https://github.com/redhat-developer/vscode-yaml/issues/1271). +- Fix: Restore auto indentation after a key with an anchor when `editor.autoIndent` is set to `full`. See [vscode-yaml#1289](https://github.com/redhat-developer/vscode-yaml/pull/1289). +- Fix: Exclude YAML delimiters from word selection. See [vscode-yaml#940](https://github.com/redhat-developer/vscode-yaml/issues/940). +- Chore: Remove the unmaintained `setup-xvfb` CI action to eliminate Node 20 deprecation warnings. See [#1343](https://github.com/redhat-developer/yaml-language-server/issues/1343). +- Chore: Remove the unused `mocha-lcov-reporter` dependency. See [#1351](https://github.com/redhat-developer/yaml-language-server/pull/1351). +- Chore: Remove the redundant direct dependency on `@typescript-eslint/parser`. See [#1357](https://github.com/redhat-developer/yaml-language-server/pull/1357). +- Chore: Replace legacy URL resolution to address `DEP0169`. See [#1359](https://github.com/redhat-developer/yaml-language-server/pull/1359). +- Chore: Upgrade `rimraf` to v6. See [#1360](https://github.com/redhat-developer/yaml-language-server/pull/1360). + +Thanks to [Simon Heather](https://github.com/X-Guardian), [Yusuke Hayashi](https://github.com/yhay81), [Noritaka Kobayashi](https://github.com/noritaka1166), [Alexandre Kohler](https://github.com/kwy404), [youdie006](https://github.com/youdie006), and [hassan](https://github.com/h55n) for your contributions. + ### 1.24.0 - Feat: Add support for declaring a schema using an inline `$schema` property. See [#964](https://github.com/redhat-developer/yaml-language-server/issues/964). - Feat: Add support for the `yaml.disableSchemaDetection` setting to disable automatic schema association for matching files. See [#1140](https://github.com/redhat-developer/yaml-language-server/issues/1140) and [vscode-yaml#245](https://github.com/redhat-developer/vscode-yaml/issues/245). From dc9af277ba1aeeb384b0b551c499d6521a72f033 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Fri, 9 Oct 2026 14:46:22 -0400 Subject: [PATCH 11/18] update CHANGELOG for 1.25.0 Signed-off-by: Morgan Chang --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d2bd9f88..b81142929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,14 @@ - Feat: Show a separate schema CodeLens for each YAML document, with resource-specific titles for Kubernetes schemas. See [#1309](https://github.com/redhat-developer/yaml-language-server/pull/1309). - Fix: Schema fileMatch regression in 1.24.0 where single `*` in glob patterns matches across path separators. See [#1295](https://github.com/redhat-developer/yaml-language-server/issues/1295). - Fix: Preserve Kubernetes schema priority after resource-specific schema detection, preventing SchemaStore associations from overriding the configured Kubernetes schema. See [#1298](https://github.com/redhat-developer/yaml-language-server/issues/1298). +- Fix: Do not depend on specific working directory within container image. See [#1301](https://github.com/redhat-developer/yaml-language-server/pull/1301). +- Fix: Recognize Kubernetes CRD schema as built-in resources. See [#1310](https://github.com/redhat-developer/yaml-language-server/issues/1310). - Fix: Schema priority lookup for normalized file URIs. See [#1312](https://github.com/redhat-developer/yaml-language-server/pull/1312). +- Fix: Resolve percent-encoded schema paths in modelines without encoding them a second time. See [#1316](https://github.com/redhat-developer/yaml-language-server/pull/1316). - Fix: Type diagnostic reports schema filenames instead of `"object"` when multiple schemas match. See [#1317](https://github.com/redhat-developer/yaml-language-server/issues/1317). - Fix: `enum` and `const` validation for nested boolean values. See [#1323](https://github.com/redhat-developer/yaml-language-server/pull/1323). - Fix: Resolve schema references through non-standard containers such as `#/components/schemas`, including nested references to the same local file or a sibling file. See [#1322](https://github.com/redhat-developer/yaml-language-server/issues/1322). +- Fix: Keep constraints on cyclic cross-file `$refs` in unindexed resources. See [#1326](https://github.com/redhat-developer/yaml-language-server/pull/1326). - Fix: Report the underlying reason when a schema fails to load instead of always reporting `No content`. See [#1337](https://github.com/redhat-developer/yaml-language-server/issues/1337) and [vscode-yaml#1282](https://github.com/redhat-developer/vscode-yaml/pull/1282). - Fix: Retry remote schema requests after transient HTTP or connection failures. See [#1341](https://github.com/redhat-developer/yaml-language-server/issues/1341) and [vscode-yaml#1284](https://github.com/redhat-developer/vscode-yaml/issues/1284). - Fix: Resolve nested schema paths prefixed with a workspace folder name and match a workspace folder name only as a whole path segment in multi-root workspaces. See [#1348](https://github.com/redhat-developer/yaml-language-server/pull/1348) and [#1349](https://github.com/redhat-developer/yaml-language-server/pull/1349). @@ -23,7 +27,7 @@ - Chore: Replace legacy URL resolution to address `DEP0169`. See [#1359](https://github.com/redhat-developer/yaml-language-server/pull/1359). - Chore: Upgrade `rimraf` to v6. See [#1360](https://github.com/redhat-developer/yaml-language-server/pull/1360). -Thanks to [Simon Heather](https://github.com/X-Guardian), [Yusuke Hayashi](https://github.com/yhay81), [Noritaka Kobayashi](https://github.com/noritaka1166), [Alexandre Kohler](https://github.com/kwy404), [youdie006](https://github.com/youdie006), and [hassan](https://github.com/h55n) for your contributions. +Thanks to [Alexandre Kohler](https://github.com/kwy404), [Andreas Reichel](https://github.com/AndreasReichel), [Noritaka Kobayashi](https://github.com/noritaka1166), [Simon Heather](https://github.com/X-Guardian), [Yusuke Hayashi](https://github.com/yhay81), [ProbstDJakob](https://github.com/ProbstDJakob), [youdie006](https://github.com/youdie006), [hassan](https://github.com/h55n), [sama Pyb](https://github.com/Pybsama)for your contributions. ### 1.24.0 - Feat: Add support for declaring a schema using an inline `$schema` property. See [#964](https://github.com/redhat-developer/yaml-language-server/issues/964). From f7d70d939b957e9cad46e21f3e9ba979b3fd3238 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Tue, 13 Oct 2026 12:25:01 -0400 Subject: [PATCH 12/18] upversion to 2.0.0 (#1362) Signed-off-by: Morgan Chang --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 655ea856d..861bda1a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "yaml-language-server", - "version": "1.25.0", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yaml-language-server", - "version": "1.25.0", + "version": "2.0.0", "license": "MIT", "dependencies": { "@vscode/l10n": "^0.0.18", diff --git a/package.json b/package.json index 0e9f681f3..256979c25 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yaml-language-server", "description": "YAML language server", - "version": "1.25.0", + "version": "2.0.0", "author": "Red Hat", "license": "MIT", "contributors": [ From 5e4d5c8e04d7155df4f0630b46ef72e36bbd8008 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Mon, 5 Oct 2026 17:20:41 -0400 Subject: [PATCH 13/18] switch to full ESM Signed-off-by: Morgan Chang --- .github/workflows/CI.yaml | 4 +- .gitignore | 3 - .mocharc.json | 9 - .npmignore | 7 +- README.md | 2 +- bin/yaml-language-server | 6 +- package-lock.json | 3110 ++++------------- package.json | 44 +- scripts/check-dependencies.js | 9 +- src/index.ts | 2 +- .../handlers/languageHandlers.ts | 10 +- .../handlers/notificationHandlers.ts | 10 +- .../handlers/requestHandlers.ts | 8 +- .../handlers/schemaSelectionHandlers.ts | 14 +- .../handlers/settingsHandlers.ts | 24 +- .../handlers/validationHandlers.ts | 8 +- .../handlers/workspaceHandlers.ts | 2 +- src/languageserver/telemetry.ts | 4 +- src/languageservice/jsonLanguageTypes.ts | 86 +- src/languageservice/jsonSchema.ts | 5 +- src/languageservice/parser/ast-converter.ts | 6 +- .../parser/custom-tag-provider.ts | 4 +- src/languageservice/parser/isKubernetes.ts | 4 +- src/languageservice/parser/jsonDocument.ts | 14 +- .../parser/schemaValidation/baseValidator.ts | 24 +- .../schemaValidation/draft04Validator.ts | 8 +- .../schemaValidation/draft07Validator.ts | 8 +- .../schemaValidation/draft2019Validator.ts | 14 +- .../schemaValidation/draft2020Validator.ts | 14 +- .../schemaValidation/validatorFactory.ts | 12 +- src/languageservice/parser/yaml-documents.ts | 26 +- src/languageservice/parser/yamlParser07.ts | 6 +- .../services/documentSymbols.ts | 6 +- src/languageservice/services/dollarUtils.ts | 4 +- src/languageservice/services/k8sSchemaUtil.ts | 8 +- src/languageservice/services/modelineUtil.ts | 4 +- .../services/schemaRequestHandler.ts | 12 +- .../services/validation/map-key-order.ts | 4 +- .../services/validation/types.ts | 2 +- .../services/validation/unused-anchors.ts | 8 +- .../services/validation/yaml-style.ts | 6 +- .../services/yamlCodeActions.ts | 24 +- src/languageservice/services/yamlCodeLens.ts | 12 +- src/languageservice/services/yamlCommands.ts | 4 +- .../services/yamlCompletion.ts | 42 +- .../services/yamlDefinition.ts | 8 +- src/languageservice/services/yamlFolding.ts | 6 +- src/languageservice/services/yamlFormatter.ts | 2 +- src/languageservice/services/yamlHover.ts | 24 +- src/languageservice/services/yamlLinks.ts | 8 +- .../services/yamlOnTypeFormatting.ts | 2 +- src/languageservice/services/yamlRename.ts | 12 +- .../services/yamlSchemaService.ts | 50 +- .../services/yamlSelectionRanges.ts | 4 +- .../services/yamlValidation.ts | 32 +- src/languageservice/utils/arrUtils.ts | 2 +- src/languageservice/utils/astNodeUtils.ts | 2 +- .../utils/filePatternAssociation.ts | 2 +- .../utils/flow-style-rewriter.ts | 2 +- .../utils/indentationGuesser.ts | 4 +- src/languageservice/utils/objects.ts | 2 +- src/languageservice/utils/parseUtils.ts | 3 +- src/languageservice/utils/schemaUrls.ts | 8 +- src/languageservice/utils/schemaUtils.ts | 2 +- src/languageservice/utils/strings.ts | 2 +- src/languageservice/utils/yamlAstUtils.ts | 2 +- src/languageservice/yamlLanguageService.ts | 46 +- src/nodeTranslationSetup.ts | 3 +- src/requestTypes.ts | 6 +- src/server.ts | 16 +- src/webworker/yamlServerMain.ts | 10 +- src/yamlServerInit.ts | 28 +- src/yamlSettings.ts | 10 +- test/arrUtils.test.ts | 4 +- test/astUtils.test.ts | 10 +- test/autoCompletion.test.ts | 122 +- test/autoCompletionFix.test.ts | 32 +- test/bundlel10n.test.ts | 24 +- test/code-action-schema.test.ts | 16 +- test/customTags.test.ts | 12 +- test/defaultSnippets.test.ts | 14 +- test/diagnostic-filter.test.ts | 6 +- test/documentSymbols.test.ts | 14 +- test/findLinks.test.ts | 12 +- test/flow-style-rewriter.test.ts | 7 +- test/formatter.test.ts | 18 +- test/hover.test.ts | 16 +- test/integration.test.ts | 14 +- test/invalid-metaschema.test.ts | 19 +- test/multipleDocuments.test.ts | 18 +- test/objects.test.ts | 4 +- test/paths.test.ts | 19 +- test/schema.test.ts | 55 +- test/schema2019Validation.test.ts | 18 +- test/schema2020Validation.test.ts | 18 +- test/schemaRequestHandler.test.ts | 25 +- test/schemaSelectionHandlers.test.ts | 21 +- test/schemaValidation.test.ts | 60 +- test/settingsHandlers.test.ts | 56 +- test/strings.test.ts | 4 +- test/telemetry.test.ts | 13 +- test/textBuffer.test.ts | 4 +- test/utils/serviceSetup.ts | 4 +- test/utils/testHelper.ts | 30 +- test/utils/testsTypes.ts | 4 +- test/utils/verifyError.ts | 2 +- test/yaml-documents.test.ts | 29 +- test/yamlCodeActions.test.ts | 18 +- test/yamlCodeLens.test.ts | 35 +- test/yamlCommands.test.ts | 15 +- test/yamlDefinition.test.ts | 8 +- test/yamlFolding.test.ts | 8 +- test/yamlLanguageService.test.ts | 10 +- test/yamlOnTypeFormatting.test.ts | 6 +- test/yamlParser.test.ts | 10 +- test/yamlRename.test.ts | 3 +- test/yamlSchema.test.ts | 11 +- test/yamlSchemaService.test.ts | 40 +- test/yamlSelectionRanges.test.ts | 5 +- test/yamlValidation.test.ts | 18 +- tsconfig.esm.json | 11 - tsconfig.json | 2 +- tsconfig.umd.json | 12 - 123 files changed, 1550 insertions(+), 3327 deletions(-) delete mode 100644 .mocharc.json delete mode 100644 tsconfig.esm.json delete mode 100644 tsconfig.umd.json diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 82aeba130..85a30dd54 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -30,10 +30,10 @@ jobs: - uses: actions/checkout@v7 # Set up Node - - name: Use Node 22 + - name: Use Node 22.13.0 uses: actions/setup-node@v7 with: - node-version: 22 + node-version: 22.13.0 registry-url: 'https://registry.npmjs.org' # Run install dependencies diff --git a/.gitignore b/.gitignore index 8a0fe4b6d..71489877e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,9 @@ npm-debug.log .vscode node_modules/ -npm-debug.log -.nyc_output out/server .DS_Store yarn-error.log coverage -lib/ eslint-result.sarif yarn.lock diff --git a/.mocharc.json b/.mocharc.json deleted file mode 100644 index 7fdedf1c0..000000000 --- a/.mocharc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "timeout": "10000", - "ui": "bdd", - "extension": ["ts"], - "package": "./package.json", - "reporter": "spec", - "watch-files": ["./test/*.test.ts"], - "spec": ["./test/*.test.ts"] -} diff --git a/.npmignore b/.npmignore index 8103daf58..ef4d1425b 100644 --- a/.npmignore +++ b/.npmignore @@ -1,13 +1,10 @@ /src /test .editorconfig -Jenkinsfile tsconfig.json -.nyc_output/ coverage/ .vscode/ .github/ -.eslintrc.js .prettierrc.json -.travis.yml -.mocharc.json +eslint.config.mjs +eslint-result.sarif diff --git a/README.md b/README.md index 059839d3e..60b722ba2 100755 --- a/README.md +++ b/README.md @@ -620,7 +620,7 @@ Use `npm test` to run tests. ### Module builds -Building YAML Language Server produces [CommonJS](http://www.commonjs.org/) output in the `out/server/src` directory. In addition, a build also produces [UMD](https://github.com/umdjs/umd) (Universal Module Definition) modules and [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) in the `lib` directory. These module formats support different server-side module loaders and browser bundlers such as webpack. +Building YAML Language Server produces [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) and declarations in the `out/server/src` directory. ### CI diff --git a/bin/yaml-language-server b/bin/yaml-language-server index 9ed594594..c72a5c3b5 100755 --- a/bin/yaml-language-server +++ b/bin/yaml-language-server @@ -1,6 +1,8 @@ #!/usr/bin/env node -const version = require('../package.json').version; +import packageConfig from '../package.json' with { type: 'json' }; + +const version = packageConfig.version; const args = process.argv.slice(2); if (args.includes('--version') || args.includes('-version')) { @@ -24,4 +26,4 @@ Other: } process.env.YAML_LANGUAGE_SERVER_VERSION = version; -require('../out/server/src/server.js'); +await import('../out/server/src/server.js'); diff --git a/package-lock.json b/package-lock.json index 861bda1a5..ebb50c191 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,315 +29,64 @@ "devDependencies": { "@microsoft/eslint-formatter-sarif": "^3.0.0", "@types/chai": "^4.2.12", - "@types/mocha": "8.2.2", "@types/node": "22.x", "@types/picomatch": "^4.0.3", - "@types/sinon": "^9.0.5", - "@types/sinon-chai": "^3.2.5", + "c8": "^12.0.0", "chai": "^4.2.0", "eslint": "^10.0.0", "eslint-plugin-import-x": "^4.0.0", "eslint-plugin-prettier": "^5.0.0", - "mocha": "12.0.0", - "nyc": "^18.0.0", "rimraf": "^6.1.3", - "sinon": "^9.0.3", - "sinon-chai": "^3.5.0", - "source-map-support": "^0.5.19", - "ts-node": "^10.0.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", - "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-validator-identifier": "^7.29.7", - "js-tokens": "^4.0.0", - "picocolors": "^1.1.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", - "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", - "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.7", - "@babel/helper-compilation-targets": "^7.29.7", - "@babel/helper-module-transforms": "^7.29.7", - "@babel/helpers": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/template": "^7.29.7", - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7", - "@jridgewell/remapping": "^2.3.5", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.7.tgz", - "integrity": "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.29.7", - "@babel/types": "^7.29.7", - "@jridgewell/gen-mapping": "^0.3.12", - "@jridgewell/trace-mapping": "^0.3.28", - "jsesc": "^3.0.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", - "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/compat-data": "^7.29.7", - "@babel/helper-validator-option": "^7.29.7", - "browserslist": "^4.24.0", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-globals": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", - "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", - "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", - "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-module-imports": "^7.29.7", - "@babel/helper-validator-identifier": "^7.29.7", - "@babel/traverse": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", - "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", - "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", - "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", - "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/template": "^7.29.7", - "@babel/types": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.7.tgz", - "integrity": "sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.29.7" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/template": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", - "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/types": "^7.29.7" }, "engines": { - "node": ">=6.9.0" + "node": ">=22.13.0" } }, - "node_modules/@babel/traverse": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.7.tgz", - "integrity": "sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==", + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", "dev": true, "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.7", - "@babel/helper-globals": "^7.29.7", - "@babel/parser": "^7.29.7", - "@babel/template": "^7.29.7", - "@babel/types": "^7.29.7", - "debug": "^4.3.1" - }, "engines": { - "node": ">=6.9.0" + "node": ">=18" } }, - "node_modules/@babel/types": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.7.tgz", - "integrity": "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==", + "node_modules/@cacheable/memory": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", + "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.29.7", - "@babel/helper-validator-identifier": "^7.29.7" - }, - "engines": { - "node": ">=6.9.0" + "@cacheable/utils": "^2.5.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "node_modules/@cacheable/utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.5.0.tgz", + "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" + "hashery": "^1.5.1", + "keyv": "^5.6.0" } }, - "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "node_modules/@dual-bundle/import-meta-resolve": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@dual-bundle/import-meta-resolve/-/import-meta-resolve-4.2.1.tgz", + "integrity": "sha512-id+7YRUgoUX6CgV0DtuhirQWodeeA7Lf4i2x71JS/vtA5pRb/hIGWlw+G6MeXvsM+MXrz0VAydTGElX1rAfgPg==", "dev": true, "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "funding": { + "type": "github", + "url": "https://github.com/sponsors/JounQin" } }, "node_modules/@emnapi/core": { @@ -375,9 +124,9 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", - "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", "dev": true, "license": "MIT", "dependencies": { @@ -431,49 +180,10 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, - "node_modules/@eslint/config-array/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/@eslint/config-array/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/@eslint/config-array/node_modules/minimatch": { - "version": "10.2.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", - "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.5" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@eslint/config-helpers": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.6.0.tgz", - "integrity": "sha512-ii6Bw9jJ2zi2cWA2Z+9/QZ/+3DX6kwaV5Q986D/CdP3Lap3w/pgQZ373FV7byY/i7L4IRH/G43I5dz1ClsCbpA==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -537,6 +247,24 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/@eslint/eslintrc/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", @@ -568,22 +296,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -591,6 +303,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@eslint/js": { "version": "8.57.1", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", @@ -612,9 +337,9 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.2.tgz", - "integrity": "sha512-+CNAzxglkrpNf/kKywqQfk74QjtceuOE7Qm+AF8miRvPF/wmmK5+OJOgVh3AVTT3RP2mH3+FOaxlE5v72owk0A==", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz", + "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -679,6 +404,37 @@ "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/config-array/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -715,173 +471,68 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@istanbuljs/load-nyc-config": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "node_modules/@istanbuljs/schema": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", + "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", "dev": true, - "license": "ISC", - "dependencies": { - "camelcase": "^5.3.1", - "find-up": "^4.1.0", - "get-package-type": "^0.1.0", - "js-yaml": "^3.13.1", - "resolve-from": "^5.0.0" - }, + "license": "MIT", "engines": { "node": ">=8" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, "license": "MIT", - "dependencies": { - "sprintf-js": "~1.0.2" + "engines": { + "node": ">=6.0.0" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", "dev": true, "license": "MIT", "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { - "version": "3.15.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.2.tgz", - "integrity": "sha512-6EuL879VkRA+1Cz578mKMiKvjPNEuk6+r1JaFzoSWejZmtf7xWbIyw1e3KkxlkzTIt9Taw6JBhEppG7utc1P+w==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "node_modules/@keyv/bigmap": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", "dev": true, "license": "MIT", "dependencies": { - "p-try": "^2.0.0" + "hashery": "^1.4.0", + "hookified": "^1.15.0" }, "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" + "node": ">= 18" }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", - "integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, - "node_modules/@jridgewell/remapping": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", - "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" + "peerDependencies": { + "keyv": "^5.6.0" } }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz", - "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==", + "node_modules/@keyv/serialize": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.1.1.tgz", + "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==", "dev": true, "license": "MIT" }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.31", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", - "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, "node_modules/@microsoft/eslint-formatter-sarif": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@microsoft/eslint-formatter-sarif/-/eslint-formatter-sarif-3.1.0.tgz", @@ -915,6 +566,34 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/@microsoft/eslint-formatter-sarif/node_modules/eslint": { "version": "8.57.1", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", @@ -1070,22 +749,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@microsoft/eslint-formatter-sarif/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@microsoft/eslint-formatter-sarif/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -1093,6 +756,29 @@ "dev": true, "license": "MIT" }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@microsoft/eslint-formatter-sarif/node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -1110,23 +796,39 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@microsoft/eslint-formatter-sarif/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@napi-rs/wasm-runtime": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.5.tgz", - "integrity": "sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.5.tgz", + "integrity": "sha512-HshSvXzmBxNzqejd3k/KemgQ3hdREUYFRRrgxOZ+gPljDIsO2SDZrVZMd4Z/HsxudQbE62OVyVFE8z9BCurfjA==", "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@tybys/wasm-util": "^0.10.2" + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" }, "funding": { "type": "github", "url": "https://github.com/sponsors/Brooooooklyn" }, "peerDependencies": { - "@emnapi/core": "^1.7.1", - "@emnapi/runtime": "^1.7.1" + "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.4", + "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4" } }, "node_modules/@nodelib/fs.scandir": { @@ -1167,13 +869,6 @@ "node": ">= 8" } }, - "node_modules/@package-json/types": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/@package-json/types/-/types-0.0.12.tgz", - "integrity": "sha512-uu43FGU34B5VM9mCNjXCwLaGHYjXdNincqKLaraaCW+7S2+SmiBg1Nv8bPnmschrIfZmfKNY9f3fC376MRrObw==", - "dev": true, - "license": "MIT" - }, "node_modules/@pkgr/core": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.3.6.tgz", @@ -1187,87 +882,10 @@ "url": "https://opencollective.com/pkgr" } }, - "node_modules/@sinonjs/commons": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", - "integrity": "sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "type-detect": "4.0.8" - } - }, - "node_modules/@sinonjs/commons/node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/@sinonjs/fake-timers": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz", - "integrity": "sha512-MZPUxrmFubI36XS1DI3qmI0YdN1gks62JtFZvxR67ljjSNCeK6U08Zx4msEWOXuofgqUt6zPHSi1H9fbjR/NRA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^1.7.0" - } - }, - "node_modules/@sinonjs/samsam": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.3.1.tgz", - "integrity": "sha512-1Hc0b1TtyfBu8ixF/tpfSHTVWKwCBLY4QJbkgnE7HcwyvT2xArDxb4K7dMgqRm3szI+LJbzmW/s4xxEhv6hwDg==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^1.6.0", - "lodash.get": "^4.4.2", - "type-detect": "^4.0.8" - } - }, - "node_modules/@sinonjs/text-encoding": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.3.tgz", - "integrity": "sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==", - "dev": true, - "license": "(Unlicense OR Apache-2.0)" - }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, "node_modules/@tybys/wasm-util": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz", - "integrity": "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz", + "integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==", "dev": true, "license": "MIT", "optional": true, @@ -1296,6 +914,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1303,17 +928,10 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/mocha": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.2.tgz", - "integrity": "sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/node": { - "version": "22.20.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz", - "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==", + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", "dev": true, "license": "MIT", "dependencies": { @@ -1327,46 +945,18 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/sinon": { - "version": "9.0.11", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-9.0.11.tgz", - "integrity": "sha512-PwP4UY33SeeVKodNE37ZlOsR9cReypbMJOhZ7BVE0lB+Hix3efCOxiJWiE5Ia+yL9Cn2Ch72EjFTRze8RZsNtg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/sinonjs__fake-timers": "*" - } - }, - "node_modules/@types/sinon-chai": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.12.tgz", - "integrity": "sha512-9y0Gflk3b0+NhQZ/oxGtaAJDvRywCa5sIyaVnounqLvmf93yBF4EgIRspePtkMs3Tr844nCclYMlcCNmLCvjuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/chai": "*", - "@types/sinon": "*" - } - }, - "node_modules/@types/sinonjs__fake-timers": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.5.tgz", - "integrity": "sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==", - "dev": true, - "license": "MIT" - }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.61.0.tgz", - "integrity": "sha512-bFNvl9ZczlVb+wR2Akszf3gHfKVj/8WanXaGJ3UstTA7brNKg0cNdk6X1Psu5V7MZ2oQtzZKOEzIUehaoxbDGw==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.2.tgz", + "integrity": "sha512-K72/pvT7qpm8q3k8G5u93NCSN1RcLxX5h7Gw0bQpbMXviBHeY6Nx1WEwmk9wP+eKTSQ8ecxvcgt/ZX/rB938xQ==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.61.0", - "@typescript-eslint/type-utils": "8.61.0", - "@typescript-eslint/utils": "8.61.0", - "@typescript-eslint/visitor-keys": "8.61.0", + "@typescript-eslint/scope-manager": "8.71.2", + "@typescript-eslint/type-utils": "8.71.2", + "@typescript-eslint/utils": "8.71.2", + "@typescript-eslint/visitor-keys": "8.71.2", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -1379,15 +969,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.61.0", + "@typescript-eslint/parser": "^8.71.2", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", - "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz", + "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==", "dev": true, "license": "MIT", "engines": { @@ -1395,16 +985,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.61.0.tgz", - "integrity": "sha512-5B7PfA2e1NQGCnDHd/0lW7W3gvp3d59Ryw54FYO8Uswxo9f6ikw3AZV+Xj/TvpImmpsiYyUqAfhC6kJID1jF6w==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.2.tgz", + "integrity": "sha512-aTtmZjp/x3gsGHkDs04/1I8kNogBJkpQaeGaN0PfiG43NzDEmW2n+OP5im9wfsvyX0yP1UZWBrAGtDBfH9jEVw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.61.0", - "@typescript-eslint/types": "8.61.0", - "@typescript-eslint/typescript-estree": "8.61.0", - "@typescript-eslint/visitor-keys": "8.61.0", + "@typescript-eslint/scope-manager": "8.71.2", + "@typescript-eslint/types": "8.71.2", + "@typescript-eslint/typescript-estree": "8.71.2", + "@typescript-eslint/visitor-keys": "8.71.2", "debug": "^4.4.3" }, "engines": { @@ -1420,14 +1010,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.61.0.tgz", - "integrity": "sha512-DV42F7MLJO6Rax7SK1yg43tcnEfGUrurSpSxKuVX+a3RCTzBlH3fuxprrOJXKCJGAaw82xXocikJ0uQaqwXgGA==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.2.tgz", + "integrity": "sha512-Pd68GsLVh5ZXlcEccFPdhSOvtHZ/2WU0XsA8zmXOS3F158lVlcTLhfQ6qvtL1RzbMie0Kp8xtbVwAg4nejKPHw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.61.0", - "@typescript-eslint/types": "^8.61.0", + "@typescript-eslint/tsconfig-utils": "^8.71.2", + "@typescript-eslint/types": "^8.71.2", "debug": "^4.4.3" }, "engines": { @@ -1442,14 +1032,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.61.0.tgz", - "integrity": "sha512-IWdXFHFSb6mlC3HPc7QsLDm5zYEbUla6trDEHf32D3/dnuUyXd87plScSNXSbm0/RxMvObpI17sv/EDTGrGZkA==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.2.tgz", + "integrity": "sha512-YF4wgg5iUX5Obywoac27B56FhozMNFhdJSbh11H5GBAwmBtfyRhmgTQqW9tRNNmHDvsZ2CX6UGzoz+YfYn2Leg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.61.0", - "@typescript-eslint/visitor-keys": "8.61.0" + "@typescript-eslint/types": "8.71.2", + "@typescript-eslint/visitor-keys": "8.71.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1460,9 +1050,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.61.0.tgz", - "integrity": "sha512-O5Amvdv9ztMpxpf+vmFULGG78IE6Qwdr3bCGvqwG4nwc9H2qXkOYJJnRbRHyMkQTjv1d03olqwwwzHLMqpFePQ==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.2.tgz", + "integrity": "sha512-jz49TAWokm/7yWD9/o837nYax9DyALxIPOImdImvVzo6canBCZYzin8zJyqNR5k1j9K1DE0bVvr0XYB+99uAdg==", "dev": true, "license": "MIT", "engines": { @@ -1477,15 +1067,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.61.0.tgz", - "integrity": "sha512-TuBiQYIkd97yBfInHCTKVYMbX4kvEmpOEuixIuzCU9p8BGT1SfyyO0d0IfDMbPIHcjn/hWnusUX5e8v5Xg+X8A==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.2.tgz", + "integrity": "sha512-cC8UaalCViJkb3rH/xLIvidEwoFRtMZMUqDjjJMGEKaTFwYRHYBcoczlEGHuvkHEO8svRDrgZ0yQgOArFmwang==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.61.0", - "@typescript-eslint/typescript-estree": "8.61.0", - "@typescript-eslint/utils": "8.61.0", + "@typescript-eslint/types": "8.71.2", + "@typescript-eslint/typescript-estree": "8.71.2", + "@typescript-eslint/utils": "8.71.2", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -1502,9 +1092,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.61.0.tgz", - "integrity": "sha512-9QTQpZ5Iin4CdIodfbDQFSeiSJKidgYJYug1P9CC2xWgUTvlmixViqDZNciMjwLBZyJnG4tGmPl97rVAFb1AJg==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.2.tgz", + "integrity": "sha512-y5Ukl3oVp7e/VGxqIoEXoeb/Roj71PAJ4WG/N/RGj+eeDvKRLM15kGr9MijLbN0i03S52zxu31Z98E5gWChJKw==", "dev": true, "license": "MIT", "engines": { @@ -1516,16 +1106,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.61.0.tgz", - "integrity": "sha512-42zatd5qSvvcV1JdDBCLxYRznvP4eIHpPoZXdkPFnAmanA4FuZ5dibSnCBggY8hQnqajPpoGjXFdZ7fIJKQnlA==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.2.tgz", + "integrity": "sha512-DgNOEsl4pdYzwSL+N/Cl33tX1Hlw3FvId73LnKXfq7jnrF2viOEn7X+P7RBkkSWCVm92gnWd28GIC5vJuLREeA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.61.0", - "@typescript-eslint/tsconfig-utils": "8.61.0", - "@typescript-eslint/types": "8.61.0", - "@typescript-eslint/visitor-keys": "8.61.0", + "@typescript-eslint/project-service": "8.71.2", + "@typescript-eslint/tsconfig-utils": "8.71.2", + "@typescript-eslint/types": "8.71.2", + "@typescript-eslint/visitor-keys": "8.71.2", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -1543,56 +1133,17 @@ "typescript": ">=4.8.4 <6.1.0" } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "10.2.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", - "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.5" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@typescript-eslint/utils": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.61.0.tgz", - "integrity": "sha512-3bzFt7ImFMW/jVYwJamDoe/dMOdFLSC6pom6rRjdh4SZJEYupyMzem8e7vKZLclLfpHjlwSAXOUxtKxGXUiLqA==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.2.tgz", + "integrity": "sha512-RyKa1G1M9rKHDhrk+HJtiF1MvLD5Ux2JW3TSkzw+02pRALdpJb+QzG1Y5em+LvCgzGwgg8H7mBRFKljNz7ImPw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.61.0", - "@typescript-eslint/types": "8.61.0", - "@typescript-eslint/typescript-estree": "8.61.0" + "@typescript-eslint/scope-manager": "8.71.2", + "@typescript-eslint/types": "8.71.2", + "@typescript-eslint/typescript-estree": "8.71.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1607,13 +1158,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.61.0.tgz", - "integrity": "sha512-QVLZu3ZPQEE+HICQyAMZ2yLQhxf0meY/wx6Hx14YcTNj13JB3qHlX3lJ02L3fLGHgERRH71kvYDwiXIguT3AjQ==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.2.tgz", + "integrity": "sha512-zozlN0UA32bSG2zkKAgQyRYSbEISVoyU6vvkKYo2aSny74D8Jh4e+POkJ6Lk0dlezZi5x7TtD+88Xb06IB8nhg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.61.0", + "@typescript-eslint/types": "8.71.2", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -1625,9 +1176,9 @@ } }, "node_modules/@ungap/structured-clone": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.1.tgz", - "integrity": "sha512-mUFwbeTqrVgDQxFveS+df2yfap6iuP20NAKAsBt5jDEoOTDew+zwLAOilHCeQJOVSvmgCX4ogqIrA0mnyr08yQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz", + "integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==", "dev": true, "license": "ISC" }, @@ -1737,6 +1288,9 @@ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1751,6 +1305,9 @@ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1765,6 +1322,9 @@ "loong64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1779,6 +1339,9 @@ "loong64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1793,6 +1356,9 @@ "ppc64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1807,6 +1373,9 @@ "riscv64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1821,6 +1390,9 @@ "riscv64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1835,6 +1407,9 @@ "s390x" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1849,6 +1424,9 @@ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1863,6 +1441,9 @@ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1951,9 +1532,9 @@ "license": "MIT" }, "node_modules/acorn": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.17.0.tgz", - "integrity": "sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", "dev": true, "license": "MIT", "bin": { @@ -1973,37 +1554,10 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/aggregate-error": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", - "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "clean-stack": "^2.0.0", - "indent-string": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/ajv": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", - "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", @@ -2040,58 +1594,31 @@ } }, "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", "dev": true, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", "dev": true, "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, "engines": { - "node": ">=8" + "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/append-transform": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", - "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", - "dev": true, - "license": "MIT", - "dependencies": { - "default-require-extensions": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/archy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", - "dev": true, - "license": "MIT" - }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -2110,98 +1637,74 @@ } }, "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/baseline-browser-mapping": { - "version": "2.11.21", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz", - "integrity": "sha512-uh8vpY/1/YyFkunIDFH/12p7/7VdPKA1hejMVEbdkEaWnUz0Hesvx5EbiU6XxjyHZIOju+ZMbQJkRh+es3/spQ==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", "dev": true, - "license": "Apache-2.0", - "bin": { - "baseline-browser-mapping": "dist/cli.cjs" - }, + "license": "MIT", "engines": { - "node": ">=6.0.0" + "node": "18 || 20 || >=22" } }, "node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" } }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true, - "license": "ISC" - }, - "node_modules/browserslist": { - "version": "4.28.8", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz", - "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==", + "node_modules/c8": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-12.0.0.tgz", + "integrity": "sha512-4zpJvrd1nKWutnnKC2pXkFmb6iM1l+ffN//o1CzlTNwW7GSOs9a1xrLqkC48nU8oEkjmPZLPiwMsIaOvoF4Pqg==", "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", + "license": "ISC", "dependencies": { - "baseline-browser-mapping": "^2.11.12", - "caniuse-lite": "^1.0.30001809", - "electron-to-chromium": "^1.5.402", - "node-releases": "^2.0.53", - "update-browserslist-db": "^1.3.0" + "@bcoe/v8-coverage": "^1.0.1", + "@istanbuljs/schema": "^0.1.3", + "find-up": "^5.0.0", + "foreground-child": "^3.1.1", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.1.6", + "test-exclude": "^8.0.0", + "v8-to-istanbul": "^9.0.0", + "yargs": "^18.0.0", + "yargs-parser": "^21.1.1" }, "bin": { - "browserslist": "cli.js" + "c8": "bin/c8.js" }, "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + "node": "^20.19.0 || ^22.12.0 || >=23" + }, + "peerDependencies": { + "monocart-coverage-reports": "^2" + }, + "peerDependenciesMeta": { + "monocart-coverage-reports": { + "optional": true + } } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/caching-transform": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", - "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "node_modules/cacheable": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.5.0.tgz", + "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==", "dev": true, "license": "MIT", "dependencies": { - "hasha": "^5.0.0", - "make-dir": "^3.0.0", - "package-hash": "^4.0.0", - "write-file-atomic": "^3.0.0" - }, - "engines": { - "node": ">=8" + "@cacheable/memory": "^2.2.0", + "@cacheable/utils": "^2.5.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.10.1" } }, "node_modules/callsites": { @@ -2214,37 +1717,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001810", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", - "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "CC-BY-4.0" - }, "node_modules/chai": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", @@ -2281,6 +1753,22 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/check-error": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", @@ -2294,30 +1782,37 @@ "node": "*" } }, - "node_modules/chokidar": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", - "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", + "node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", "dev": true, - "license": "MIT", + "license": "ISC", "dependencies": { - "readdirp": "^5.0.0" + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" }, "engines": { - "node": ">= 20.19.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" + "node": ">=20" } }, - "node_modules/clean-stack": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", - "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", "dev": true, "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, "engines": { - "node": ">=6" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/color-convert": { @@ -2341,22 +1836,15 @@ "license": "MIT" }, "node_modules/comment-parser": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.7.tgz", - "integrity": "sha512-0h+uSNtQGW3D98eQt3jJ8L06Fves8hncB4V/PKdw/Qb8Hnk19VaKuTr55UNRYiSoVa7WwrFls+rh3ux9agmkeQ==", + "version": "1.4.9", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.9.tgz", + "integrity": "sha512-+2AvZKjJaNq9GQljm3tr0utwrig5BL+jgJGvz5rDpGKNIp+ojcRXWUwBbh/sGIi1QCprR6PsKFakub+w1v+4hQ==", "dev": true, "license": "MIT", "engines": { "node": ">= 12.0.0" } }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true, - "license": "MIT" - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2365,16 +1853,9 @@ "license": "MIT" }, "node_modules/convert-source-map": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", - "dev": true, - "license": "MIT" - }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true, "license": "MIT" }, @@ -2411,16 +1892,6 @@ } } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/deep-eql": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", @@ -2441,32 +1912,6 @@ "dev": true, "license": "MIT" }, - "node_modules/default-require-extensions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", - "integrity": "sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==", - "dev": true, - "license": "MIT", - "dependencies": { - "strip-bom": "^4.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/diff": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz", - "integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -2480,17 +1925,10 @@ "node": ">=6.0.0" } }, - "node_modules/electron-to-chromium": { - "version": "1.5.420", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.420.tgz", - "integrity": "sha512-2yD6XreGusOfNV+dUcvipJEXc3n/n7fgr7996aszTG+YY5E4mqM4tOq/3uhP129cazL9YHbVWSpc79ePotWtPA==", - "dev": true, - "license": "ISC" - }, - "node_modules/es6-error": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", - "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", "dev": true, "license": "MIT" }, @@ -2518,9 +1956,9 @@ } }, "node_modules/eslint": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.5.0.tgz", - "integrity": "sha512-1y+7C+vi12bUK1IpZeaV3gsH9fHLBmPvYmPx42pvT/E9yG0IC8g3PUZZgp0+JLJl7ZDK0flc2gc+Aw9dpCvIsQ==", + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.12.0.tgz", + "integrity": "sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==", "dev": true, "license": "MIT", "workspaces": [ @@ -2530,9 +1968,9 @@ "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", "@eslint/config-array": "^0.23.5", - "@eslint/config-helpers": "^0.6.0", + "@eslint/config-helpers": "^0.7.0", "@eslint/core": "^1.2.1", - "@eslint/plugin-kit": "^0.7.2", + "@eslint/plugin-kit": "^0.7.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", @@ -2547,14 +1985,14 @@ "esquery": "^1.7.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", + "file-entry-cache": "11.1.5 || >11.1.6 <12", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "minimatch": "^10.2.4", + "minimatch": "^10.2.5", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, @@ -2602,13 +2040,12 @@ } }, "node_modules/eslint-plugin-import-x": { - "version": "4.16.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.16.2.tgz", - "integrity": "sha512-rM9K8UBHcWKpzQzStn1YRN2T5NvdeIfSVoKu/lKF41znQXHAUcBbYXe5wd6GNjZjTrP7viQ49n1D83x/2gYgIw==", + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.17.1.tgz", + "integrity": "sha512-4cdstYkKCyjumM2Q9NSI03K8D2a9F4Ssz33K2lv2hQa4KmR9jPLwk3uWGtNvclfqBrPGfGuMBwsGMbe6dMRbfg==", "dev": true, "license": "MIT", "dependencies": { - "@package-json/types": "^0.0.12", "@typescript-eslint/types": "^8.56.0", "comment-parser": "^1.4.1", "debug": "^4.4.1", @@ -2639,54 +2076,15 @@ } } }, - "node_modules/eslint-plugin-import-x/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/eslint-plugin-import-x/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/eslint-plugin-import-x/node_modules/minimatch": { - "version": "10.2.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", - "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.5" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/eslint-plugin-prettier": { - "version": "5.5.6", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.6.tgz", - "integrity": "sha512-ifetmTcxWfz+4qRW3pH/ujdTq2jQIj59AxJMIN26K5avYgU8dxycUETQonWiW+wPrYXA0j3Try0l1CnwVQtDqQ==", + "version": "5.5.7", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.7.tgz", + "integrity": "sha512-WjHyn3GrFd+ZR0rzsLiM4zJZ35PZMOE0SUIxzGmnWNG0126yNfJKJzObmmkYDwHJfGlkz3PSlzyG9ez/LJntwg==", "dev": true, "license": "MIT", "dependencies": { "prettier-linter-helpers": "^1.0.1", - "synckit": "^0.11.13" + "synckit": "^0.12.3" }, "engines": { "node": "^14.18.0 || >=16.0.0" @@ -2758,51 +2156,12 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/eslint/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "node_modules/eslint/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/eslint/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/eslint/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true, - "license": "MIT" - }, - "node_modules/eslint/node_modules/minimatch": { - "version": "10.2.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", - "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.5" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } + "license": "MIT" }, "node_modules/espree": { "version": "11.2.0", @@ -2822,20 +2181,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "license": "BSD-2-Clause", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/esquery": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", @@ -2910,9 +2255,9 @@ "license": "MIT" }, "node_modules/fast-uri": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.7.tgz", - "integrity": "sha512-dOvZVzjdZdz7phd9v6jCbwxrBW3fK6n8Rc0CtdmM4bumzMnxywBYhuph6J819RRw/ku+rLbelwfMunktuzVVHg==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz", + "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==", "funding": [ { "type": "github", @@ -2926,44 +2271,41 @@ "license": "BSD-3-Clause" }, "node_modules/fastq": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", - "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.3.tgz", + "integrity": "sha512-XKv5nnLs6nLF71NgiKJLIZFLkPyIEuOselLG7ujZnGrRfQK8HpvY+WqKhAJUAdLomwVHErVS4LfxFlPq0/FTAw==", "dev": true, "license": "ISC", "dependencies": { "reusify": "^1.0.4" } }, - "node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dev": true, "license": "MIT", - "dependencies": { - "flat-cache": "^4.0.0" - }, "engines": { - "node": ">=16.0.0" + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } } }, - "node_modules/find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "node_modules/file-entry-cache": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.5.tgz", + "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==", "dev": true, "license": "MIT", "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + "flat-cache": "^6.1.23" } }, "node_modules/find-up": { @@ -2984,23 +2326,21 @@ } }, "node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "version": "6.1.23", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.23.tgz", + "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==", "dev": true, "license": "MIT", "dependencies": { - "flatted": "^3.2.9", - "keyv": "^4.5.4" - }, - "engines": { - "node": ">=16" + "cacheable": "^2.5.0", + "flatted": "^3.4.2", + "hookified": "^1.15.0" } }, "node_modules/flatted": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz", - "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==", + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", "dev": true, "license": "ISC" }, @@ -3021,27 +2361,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/fromentries": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", - "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3049,16 +2368,6 @@ "dev": true, "license": "ISC" }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -3069,30 +2378,33 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", "dev": true, "license": "MIT", "engines": { - "node": "*" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/get-package-type": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", - "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", "dev": true, "license": "MIT", "engines": { - "node": ">=8.0.0" + "node": "*" } }, "node_modules/get-tsconfig": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.14.0.tgz", - "integrity": "sha512-yTb+8DXzDREzgvYmh6s9vHsSVCHeC0G3PI5bEXNBHtmshPnO+S5O7qgLEOn0I5QvMy6kpZN8K1NKGyilLb93wA==", + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.14.3.tgz", + "integrity": "sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA==", "dev": true, "license": "MIT", "dependencies": { @@ -3133,52 +2445,22 @@ "node": ">=10.13.0" } }, - "node_modules/glob/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/glob/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/glob/node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.8" + "type-fest": "^0.20.2" }, "engines": { - "node": "18 || 20 || >=22" + "node": ">=8" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true, - "license": "ISC" - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -3196,32 +2478,25 @@ "node": ">=8" } }, - "node_modules/hasha": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", - "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", + "node_modules/hashery": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", "dev": true, "license": "MIT", "dependencies": { - "is-stream": "^2.0.0", - "type-fest": "^0.8.0" + "hookified": "^1.15.0" }, "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=20" } }, - "node_modules/hasha/node_modules/type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "node_modules/hookified": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=8" - } + "license": "MIT" }, "node_modules/html-escaper": { "version": "2.0.2", @@ -3267,16 +2542,6 @@ "node": ">=0.8.19" } }, - "node_modules/indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -3306,16 +2571,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -3339,49 +2594,6 @@ "node": ">=8" } }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", - "dev": true, - "license": "MIT" - }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -3399,53 +2611,6 @@ "node": ">=8" } }, - "node_modules/istanbul-lib-hook": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", - "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "append-transform": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", - "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@babel/core": "^7.23.9", - "@babel/parser": "^7.23.9", - "@istanbuljs/schema": "^0.1.3", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-processinfo": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-3.0.1.tgz", - "integrity": "sha512-s3mX05h5wGZeScG6XnOanygPh4SJu5ujMc9YbvpnLGXWy1cRiGbp0NdVcjHxgoZt3WfQppfBsa0y+gWdYJ2pGQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "archy": "^1.0.0", - "cross-spawn": "^7.0.3", - "istanbul-lib-coverage": "^3.2.0", - "p-map": "^3.0.0", - "rimraf": "^6.1.3" - }, - "engines": { - "node": "20 || >=22" - } - }, "node_modules/istanbul-lib-report": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", @@ -3461,41 +2626,10 @@ "node": ">=10" } }, - "node_modules/istanbul-lib-report/node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/istanbul-lib-source-maps": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", - "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^3.0.0", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/istanbul-reports": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", - "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -3506,13 +2640,6 @@ "node": ">=8" } }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true, - "license": "MIT" - }, "node_modules/js-yaml": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", @@ -3537,26 +2664,16 @@ } }, "node_modules/jschardet": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-3.1.4.tgz", - "integrity": "sha512-/kmVISmrwVwtyYU40iQUOp3SUPk2dhNCMsZBQX0R1/jZ8maaXJ/oZIzUOiyOqcgtLnETFKYChbJ5iDC/eWmFHg==", - "dev": true, - "license": "LGPL-2.1+", - "engines": { - "node": ">=0.1.90" - } - }, - "node_modules/jsesc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", - "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-4.0.0.tgz", + "integrity": "sha512-EsNiLV+xzeMBtkGL/HeWoUivNkGIr8JmaC5A5j7DBlKnhp4CcBTWKEOtNg6vlmf+mkn9yQ9Wals47u7+LoTr7w==", "dev": true, - "license": "MIT", + "license": "0BSD", "bin": { - "jsesc": "bin/jsesc" + "jschardet": "build/cli.js" }, "engines": { - "node": ">=6" + "node": ">=20" } }, "node_modules/json-buffer": { @@ -3579,40 +2696,20 @@ "dev": true, "license": "MIT" }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/jsonc-parser": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", "license": "MIT" }, - "node_modules/just-extend": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", - "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", - "dev": true, - "license": "MIT" - }, "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", "dev": true, "license": "MIT", "dependencies": { - "json-buffer": "3.0.1" + "@keyv/serialize": "^1.1.1" } }, "node_modules/levn": { @@ -3652,21 +2749,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", - "deprecated": "This package is deprecated. Use the optional chaining (?.) operator instead.", - "dev": true, - "license": "MIT" - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3685,149 +2767,32 @@ } }, "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^3.0.2" + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" } }, "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, "license": "MIT", "dependencies": { - "semver": "^6.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, "node_modules/minimatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", - "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minipass": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", - "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/mocha": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-12.0.0.tgz", - "integrity": "sha512-NYNh5IFt6WYqm9bi4601m7vix8MZdXC0DwS4gY6WhXO2RgJWhivhISVmq1oklCif18OSI9l+vx5Mdm5oh1XGiQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "browser-stdout": "^1.3.1", - "chokidar": "^5.0.0", - "debug": "^4.3.5", - "diff": "^9.0.0", - "find-up": "^5.0.0", - "glob": "^13.0.0", - "is-path-inside": "^3.0.3", - "is-unicode-supported": "^0.1.0", - "js-yaml": "^5.0.0", - "minimatch": "^10.2.2", - "ms": "^2.1.3", - "picocolors": "^1.1.1", - "serialize-javascript": "^7.0.2", - "strip-json-comments": "^5.0.3", - "supports-color": "^8.1.1", - "workerpool": "^10.0.0" - }, - "bin": { - "mocha": "bin/mocha.js" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/mocha/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/mocha/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/mocha/node_modules/js-yaml": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.1.tgz", - "integrity": "sha512-28R/k+NAjeuf7+CKlTxWZVExJGwVVLwY06DgEnOMz2gEpfNkDcD7QvyiVPT0xy0XXhU8vHsd4Ot42OOPdJG7dQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/nodeca" - } - ], - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.mjs" - } - }, - "node_modules/mocha/node_modules/minimatch": { "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", @@ -3843,33 +2808,14 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mocha/node_modules/strip-json-comments": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", - "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, + "license": "BlueOak-1.0.0", "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "node": ">=16 || 14 >=14.17" } }, "node_modules/ms": { @@ -3902,251 +2848,6 @@ "dev": true, "license": "MIT" }, - "node_modules/nise": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/nise/-/nise-4.1.0.tgz", - "integrity": "sha512-eQMEmGN/8arp0xsvGoQ+B1qvSkR73B1nWSCh7nOt5neMCtwcQVYQGdzQMhcNscktTsWB54xnlSQFzOAPJD8nXA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^1.7.0", - "@sinonjs/fake-timers": "^6.0.0", - "@sinonjs/text-encoding": "^0.7.1", - "just-extend": "^4.0.2", - "path-to-regexp": "^1.7.0" - } - }, - "node_modules/node-preload": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", - "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "process-on-spawn": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/node-releases": { - "version": "2.0.54", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", - "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/nyc": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/nyc/-/nyc-18.0.0.tgz", - "integrity": "sha512-G5UyHinFkB1BxqGTrmZdB6uIYH0+v7ZnVssuflUDi+J+RhKWyAhRT1RCehBSI6jLFLuUUgFDyLt49mUtdO1XeQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "@istanbuljs/load-nyc-config": "^1.0.0", - "@istanbuljs/schema": "^0.1.2", - "caching-transform": "^4.0.0", - "convert-source-map": "^1.7.0", - "decamelize": "^1.2.0", - "find-cache-dir": "^3.2.0", - "find-up": "^4.1.0", - "foreground-child": "^3.3.0", - "get-package-type": "^0.1.0", - "glob": "^13.0.6", - "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-hook": "^3.0.0", - "istanbul-lib-instrument": "^6.0.2", - "istanbul-lib-processinfo": "^3.0.0", - "istanbul-lib-report": "^3.0.0", - "istanbul-lib-source-maps": "^4.0.0", - "istanbul-reports": "^3.0.2", - "make-dir": "^3.0.0", - "node-preload": "^0.2.1", - "p-map": "^3.0.0", - "process-on-spawn": "^1.0.0", - "resolve-from": "^5.0.0", - "rimraf": "^6.1.3", - "signal-exit": "^3.0.2", - "spawn-wrap": "^3.0.0", - "test-exclude": "^8.0.0", - "yargs": "^15.0.2" - }, - "bin": { - "nyc": "bin/nyc.js" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/nyc/node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/nyc/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/nyc/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/nyc/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/nyc/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/nyc/node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nyc/node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -4207,45 +2908,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-map": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", - "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "aggregate-error": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/package-hash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", - "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "graceful-fs": "^4.1.15", - "hasha": "^5.0.0", - "lodash.flattendeep": "^4.4.0", - "release-zalgo": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", @@ -4313,33 +2975,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/path-to-regexp": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.9.0.tgz", - "integrity": "sha512-xIp7/apCFJuUHdDLWe8O1HIkb0kQrOMb/0u6FXQjemHn/ii5LrIzU6bdECnsiTF/GjZkMEKg1xdiZwNqDYlZ6g==", - "dev": true, - "license": "MIT", - "dependencies": { - "isarray": "0.0.1" - } - }, - "node_modules/path-to-regexp/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true, - "license": "MIT" - }, "node_modules/pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -4350,17 +2985,10 @@ "node": "*" } }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, - "license": "ISC" - }, "node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "license": "MIT", "engines": { "node": ">=12" @@ -4369,75 +2997,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -4449,9 +3008,9 @@ } }, "node_modules/prettier": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", - "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.10.tgz", + "integrity": "sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==", "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" @@ -4476,19 +3035,6 @@ "node": ">=6.0.0" } }, - "node_modules/process-on-spawn": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.1.0.tgz", - "integrity": "sha512-JOnOPQ/8TZgjs1JIH/m9ni7FfimjNa/PRx7y/Wb5qdItsnhO0jE4AT7fC0HjC28DUQWDr50dwSYZLdRMlqDq3Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "fromentries": "^1.2.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4499,6 +3045,26 @@ "node": ">=6" } }, + "node_modules/qified": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz", + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^2.1.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/qified/node_modules/hookified": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz", + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==", + "dev": true, + "license": "MIT" + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -4512,40 +3078,13 @@ { "type": "patreon", "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/readdirp": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.1.1.tgz", - "integrity": "sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 20.19.0" - }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/release-zalgo": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", - "dev": true, - "license": "ISC", - "dependencies": { - "es6-error": "^4.0.1" - }, - "engines": { - "node": ">=4" - } + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" }, "node_modules/request-light": { "version": "0.5.8", @@ -4553,16 +3092,6 @@ "integrity": "sha512-3Zjgh+8b5fhRJBQZoy+zbVKpAQGLyka0MPgW3zruTF4dFFJ8Fqcfu9YsAvi/rvdcaTeWG3MkbZv4WKxAn/84Lg==", "license": "MIT" }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -4572,13 +3101,6 @@ "node": ">=0.10.0" } }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true, - "license": "ISC" - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -4655,9 +3177,9 @@ } }, "node_modules/semver": { - "version": "7.8.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.0.tgz", - "integrity": "sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==", + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", "dev": true, "license": "ISC", "bin": { @@ -4667,23 +3189,6 @@ "node": ">=10" } }, - "node_modules/serialize-javascript": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.1.2.tgz", - "integrity": "sha512-GL2BWwVa6JydKO6l/ljVgjAZF4QJ3S7dWDWi53s5GZT8PJzD2fNxi67HANQGKAqPrwEpL5ba7gUBGi0Ls/sEoQ==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", - "dev": true, - "license": "ISC" - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4720,115 +3225,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/sinon": { - "version": "9.2.4", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.4.tgz", - "integrity": "sha512-zljcULZQsJxVra28qIAL6ow1Z9tpattkCTEJR4RBP3TGc00FcttsP5pK284Nas5WjMZU5Yzy3kAIp3B3KRf5Yg==", - "deprecated": "16.1.1", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@sinonjs/commons": "^1.8.1", - "@sinonjs/fake-timers": "^6.0.1", - "@sinonjs/samsam": "^5.3.1", - "diff": "^4.0.2", - "nise": "^4.0.4", - "supports-color": "^7.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/sinon" - } - }, - "node_modules/sinon-chai": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz", - "integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==", - "dev": true, - "license": "(BSD-2-Clause OR WTFPL)", - "peerDependencies": { - "chai": "^4.0.0", - "sinon": ">=4.0.0" - } - }, - "node_modules/sinon/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/spawn-wrap": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-3.0.0.tgz", - "integrity": "sha512-z+s5vv4KzFPJVddGab0xX2n7kQPGMdNUX5l9T8EJqsXdKTWpcxmAqWHpsgHEXoC1taGBCc7b79bi62M5kdbrxQ==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "cross-spawn": "^7.0.6", - "foreground-child": "^2.0.0", - "is-windows": "^1.0.2", - "make-dir": "^3.0.0", - "rimraf": "^6.1.3", - "signal-exit": "^3.0.2", - "which": "^2.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/spawn-wrap/node_modules/foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", - "dev": true, - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/spawn-wrap/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true, - "license": "BSD-3-Clause" - }, "node_modules/stable-hash-x": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/stable-hash-x/-/stable-hash-x-0.2.0.tgz", @@ -4839,27 +3235,37 @@ "node": ">=12.0.0" } }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "node_modules/string-width": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", "dev": true, "license": "MIT", "dependencies": { - "ansi-regex": "^5.0.1" + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" }, "engines": { - "node": ">=8" + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/strip-json-comments": { @@ -4889,12 +3295,13 @@ } }, "node_modules/synckit": { - "version": "0.11.13", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.13.tgz", - "integrity": "sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.12.3.tgz", + "integrity": "sha512-U+/AXT6LWsxnj2vz9HeUuPWBNgdWxjyIEjEPdbJARC9txmgPzo2VEdqnFo4hHaNyMPtycyVJrSaQYeQv/PoyyA==", "dev": true, "license": "MIT", "dependencies": { + "@dual-bundle/import-meta-resolve": "^4.2.1", "@pkgr/core": "^0.3.6" }, "engines": { @@ -4919,45 +3326,6 @@ "node": "20 || >=22" } }, - "node_modules/test-exclude/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/test-exclude/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/test-exclude/node_modules/minimatch": { - "version": "10.2.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", - "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.5" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -4966,9 +3334,9 @@ "license": "MIT" }, "node_modules/tinyglobby": { - "version": "0.2.16", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", - "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", "dev": true, "license": "MIT", "dependencies": { @@ -4982,24 +3350,6 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/tinyglobby/node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } - } - }, "node_modules/ts-api-utils": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", @@ -5013,60 +3363,6 @@ "typescript": ">=4.8.4" } }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/ts-node/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -5111,16 +3407,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-typedarray": "^1.0.0" - } - }, "node_modules/typescript": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", @@ -5136,16 +3422,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.61.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.61.0.tgz", - "integrity": "sha512-8y31Rd0eGTrDKqhy6vT0HtzhN+YLjQizwX3aA3hPXP/ynSfnrBXcQY5IzsP9/DM7+klX4IUncZZjkchP0z+rUw==", + "version": "8.71.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.2.tgz", + "integrity": "sha512-Rz4effbMy2g9wnvOJZG6SbVavX313Lap1vNEbk1RUochzickvzP8P4HB+bkNg5e50eVz1hQGjh9K1omI1xB4Bw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.61.0", - "@typescript-eslint/parser": "8.61.0", - "@typescript-eslint/typescript-estree": "8.61.0", - "@typescript-eslint/utils": "8.61.0" + "@typescript-eslint/eslint-plugin": "8.71.2", + "@typescript-eslint/parser": "8.71.2", + "@typescript-eslint/typescript-estree": "8.71.2", + "@typescript-eslint/utils": "8.71.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -5204,37 +3490,6 @@ "@unrs/resolver-binding-win32-x64-msvc": "1.12.2" } }, - "node_modules/update-browserslist-db": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", - "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -5252,12 +3507,20 @@ "dev": true, "license": "MIT" }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", "dev": true, - "license": "MIT" + "license": "ISC", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } }, "node_modules/vscode-jsonrpc": { "version": "8.2.0", @@ -5291,9 +3554,9 @@ } }, "node_modules/vscode-languageserver-textdocument": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", - "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.15.tgz", + "integrity": "sha512-Gsfr9S8LU3S6885cS+NaleasJ0n3V5y/SOTqHCifQiXWFw3G9w9/YItDfwHrlCz+dSZWWZ8ilYVMcJe7Sz7Sxw==", "license": "MIT" }, "node_modules/vscode-languageserver-types": { @@ -5303,9 +3566,9 @@ "license": "MIT" }, "node_modules/vscode-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.1.0.tgz", - "integrity": "sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.2.0.tgz", + "integrity": "sha512-m2gXo3bn0G1kT9InzMf07fTbqMbGtyckj3bH5ktLO+1Ssv+yiATZ4dhwaQv9UZWxJh6E9IFGnQyjgWVDWVBDrg==", "license": "MIT" }, "node_modules/which": { @@ -5324,13 +3587,6 @@ "node": ">= 8" } }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", - "dev": true, - "license": "ISC" - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -5341,12 +3597,41 @@ "node": ">=0.10.0" } }, - "node_modules/workerpool": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-10.0.3.tgz", - "integrity": "sha512-6z2Iis68Wqth93/G/wJP9u+R3O+d2XTlgWChGCwuT1qLbBsOYueGRZuJ++v3mtDP5KjYdy+WzvWC+VWETSVXJA==", + "node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", "dev": true, - "license": "Apache-2.0" + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/wrappy": { "version": "1.0.2", @@ -5355,33 +3640,16 @@ "dev": true, "license": "ISC" }, - "node_modules/write-file-atomic": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", - "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, "license": "ISC", - "dependencies": { - "imurmurhash": "^0.1.4", - "is-typedarray": "^1.0.0", - "signal-exit": "^3.0.2", - "typedarray-to-buffer": "^3.1.5" + "engines": { + "node": ">=10" } }, - "node_modules/write-file-atomic/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true, - "license": "ISC" - }, "node_modules/yaml": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", @@ -5397,14 +3665,42 @@ "url": "https://github.com/sponsors/eemeli" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "node_modules/yargs": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", + "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", "dev": true, "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^8.2.1", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, "engines": { - "node": ">=6" + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" } }, "node_modules/yocto-queue": { diff --git a/package.json b/package.json index 256979c25..ef35f8c6a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "name": "Google LLC" } ], + "type": "module", "bin": { "yaml-language-server": "bin/yaml-language-server" }, @@ -26,6 +27,9 @@ "type": "git", "url": "git+https://github.com/redhat-developer/yaml-language-server.git" }, + "engines": { + "node": ">=22.13.0" + }, "dependencies": { "@vscode/l10n": "^0.0.18", "ajv": "^8.17.1", @@ -44,56 +48,38 @@ "devDependencies": { "@microsoft/eslint-formatter-sarif": "^3.0.0", "@types/chai": "^4.2.12", - "@types/mocha": "8.2.2", "@types/node": "22.x", "@types/picomatch": "^4.0.3", - "@types/sinon": "^9.0.5", - "@types/sinon-chai": "^3.2.5", + "c8": "^12.0.0", "chai": "^4.2.0", "eslint": "^10.0.0", "eslint-plugin-import-x": "^4.0.0", "eslint-plugin-prettier": "^5.0.0", - "mocha": "12.0.0", - "nyc": "^18.0.0", "rimraf": "^6.1.3", - "sinon": "^9.0.3", - "sinon-chai": "^3.5.0", - "source-map-support": "^0.5.19", - "ts-node": "^10.0.0", "typescript": "^6.0.0", "typescript-eslint": "^8.59.4" }, "scripts": { - "clean": "rimraf out/server && rimraf lib", + "clean": "rimraf out/server", "compile": "tsc -p .", "watch": "tsc --watch -p .", - "test": "mocha --require ts-node/register --timeout 10000 --ui bdd ./test/*.test.ts", - "coverage": "nyc mocha --require ts-node/register --timeout 10000 --require source-map-support/register --recursive --ui bdd ./test/*.test.ts", - "coveralls": "nyc --reporter=lcov --reporter=text mocha --timeout 10000 --require ts-node/register --require source-map-support/register --recursive --ui bdd ./test/*.test.ts", + "test": "npm run compile && node --enable-source-maps --test out/server/test/*.test.js", + "coveralls": "c8 --reporter=lcov --reporter=text npm test", "lint": "eslint --max-warnings 0", "lint-ci": "eslint --max-warnings 0 -f @microsoft/eslint-formatter-sarif -o eslint-result.sarif", "prettier-fix": "npm run prettier --write .", - "build": "npm run clean && npm run lint && npm run compile && npm run build:libs", - "build:libs": "npm run compile:umd && npm run compile:esm", - "compile:umd": "tsc -p ./tsconfig.umd.json", - "compile:esm": "tsc -p ./tsconfig.esm.json", + "build": "npm run clean && npm run lint && npm run compile", "check-dependencies": "node ./scripts/check-dependencies.js", "pull-remote": "git pull https://github.com/redhat-developer/yaml-language-server.git main" }, - "nyc": { - "extension": [ - ".ts", - ".tsx" + "c8": { + "include": [ + "src/**/*.ts" ], "exclude": [ - "**/*.d.ts", - "test/", - "out", - "lib", - "coverage/", - ".eslintrc.js", - "scripts" + "**/*.d.ts" ], - "all": true + "all": true, + "exclude-after-remap": true } } diff --git a/scripts/check-dependencies.js b/scripts/check-dependencies.js index 1381a06a9..5be1d8c19 100644 --- a/scripts/check-dependencies.js +++ b/scripts/check-dependencies.js @@ -5,17 +5,18 @@ //check package.json do not have dependency with 'next' version -/* eslint-disable no-undef, @typescript-eslint/no-require-imports */ +/* eslint-disable no-undef */ -const exit = require('process').exit; -const dependencies = require('../package.json').dependencies; +import packageConfig from '../package.json' with { type: 'json' }; + +const dependencies = packageConfig.dependencies; for (const dep in dependencies) { if (Object.prototype.hasOwnProperty.call(dependencies, dep)) { const version = dependencies[dep]; if (version === 'next') { console.error(`Dependency ${dep} has "${version}" version, please change it to fixed version`); - exit(1); + process.exit(1); } } } diff --git a/src/index.ts b/src/index.ts index 118af54c2..2c5af298b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,2 @@ -export * from './languageservice/yamlLanguageService'; +export * from './languageservice/yamlLanguageService.js'; export * from 'vscode-languageserver-types'; diff --git a/src/languageserver/handlers/languageHandlers.ts b/src/languageserver/handlers/languageHandlers.ts index 3cf7104d0..c2cef06a7 100644 --- a/src/languageserver/handlers/languageHandlers.ts +++ b/src/languageserver/handlers/languageHandlers.ts @@ -34,11 +34,11 @@ import type { TextEdit, WorkspaceEdit, } from 'vscode-languageserver-types'; -import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes'; -import type { CustomFormatterOptions, LanguageService } from '../../languageservice/yamlLanguageService'; -import type { SettingsState } from '../../yamlSettings'; -import type { ValidationHandler } from './validationHandlers'; -import { ResultLimitReachedNotification } from '../../requestTypes'; +import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes.js'; +import type { CustomFormatterOptions, LanguageService } from '../../languageservice/yamlLanguageService.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { ValidationHandler } from './validationHandlers.js'; +import { ResultLimitReachedNotification } from '../../requestTypes.js'; import * as path from 'path'; import type { TextDocument } from 'vscode-languageserver-textdocument'; diff --git a/src/languageserver/handlers/notificationHandlers.ts b/src/languageserver/handlers/notificationHandlers.ts index 998b10083..1f9abeb00 100644 --- a/src/languageserver/handlers/notificationHandlers.ts +++ b/src/languageserver/handlers/notificationHandlers.ts @@ -3,17 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import type { CustomSchemaProvider } from '../../languageservice/services/yamlSchemaService'; -import type { LanguageService, SchemaConfiguration } from '../../languageservice/yamlLanguageService'; +import type { CustomSchemaProvider } from '../../languageservice/services/yamlSchemaService.js'; +import type { LanguageService, SchemaConfiguration } from '../../languageservice/yamlLanguageService.js'; import { CustomSchemaRequest, DynamicCustomSchemaRequestRegistration, SchemaAssociationNotification, SchemaSelectionRequests, VSCodeContentRequestRegistration, -} from '../../requestTypes'; -import type { SettingsState } from '../../yamlSettings'; -import type { SettingsHandler } from './settingsHandlers'; +} from '../../requestTypes.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { SettingsHandler } from './settingsHandlers.js'; export class NotificationHandlers { private languageService: LanguageService; diff --git a/src/languageserver/handlers/requestHandlers.ts b/src/languageserver/handlers/requestHandlers.ts index 4bacdea03..6d3476c95 100644 --- a/src/languageserver/handlers/requestHandlers.ts +++ b/src/languageserver/handlers/requestHandlers.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import type { SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from '../../languageservice/services/yamlSchemaService'; -import { MODIFICATION_ACTIONS } from '../../languageservice/services/yamlSchemaService'; -import type { LanguageService } from '../../languageservice/yamlLanguageService'; -import { SchemaModificationNotification } from '../../requestTypes'; +import type { SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from '../../languageservice/services/yamlSchemaService.js'; +import { MODIFICATION_ACTIONS } from '../../languageservice/services/yamlSchemaService.js'; +import type { LanguageService } from '../../languageservice/yamlLanguageService.js'; +import { SchemaModificationNotification } from '../../requestTypes.js'; export class RequestHandlers { private languageService: LanguageService; diff --git a/src/languageserver/handlers/schemaSelectionHandlers.ts b/src/languageserver/handlers/schemaSelectionHandlers.ts index d041c0e76..d721de11e 100644 --- a/src/languageserver/handlers/schemaSelectionHandlers.ts +++ b/src/languageserver/handlers/schemaSelectionHandlers.ts @@ -3,13 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Connection } from 'vscode-languageserver/node'; -import type { JSONSchema } from '../../languageservice/jsonSchema'; -import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents'; -import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService'; -import type { SettingsState } from '../../yamlSettings'; -import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes'; -import { SchemaSelectionRequests } from '../../requestTypes'; +import type { Connection } from 'vscode-languageserver/node.js'; +import type { JSONSchema } from '../../languageservice/jsonSchema.js'; +import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents.js'; +import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes.js'; +import { SchemaSelectionRequests } from '../../requestTypes.js'; export class JSONSchemaSelection { constructor( diff --git a/src/languageserver/handlers/settingsHandlers.ts b/src/languageserver/handlers/settingsHandlers.ts index 2d30a84cf..60f6b2570 100644 --- a/src/languageserver/handlers/settingsHandlers.ts +++ b/src/languageserver/handlers/settingsHandlers.ts @@ -3,19 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as path from 'path'; -import { configure as configureHttpRequests, xhr } from 'request-light'; +import requestLight from 'request-light'; import type { Connection } from 'vscode-languageserver'; import { DidChangeConfigurationNotification, DocumentFormattingRequest } from 'vscode-languageserver'; import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol'; -import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths'; -import { checkSchemaURI, EMPTY_SCHEMA_URL, isKubernetes, JSON_SCHEMASTORE_URL } from '../../languageservice/utils/schemaUrls'; -import { equals } from '../../languageservice/utils/objects'; -import type { LanguageService, LanguageSettings, SchemasSettings } from '../../languageservice/yamlLanguageService'; -import { SchemaPriority } from '../../languageservice/yamlLanguageService'; -import { SchemaSelectionRequests } from '../../requestTypes'; -import type { Settings, SettingsState } from '../../yamlSettings'; -import type { Telemetry } from '../../languageservice/telemetry'; -import type { ValidationHandler } from './validationHandlers'; +import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths.js'; +import { checkSchemaURI, EMPTY_SCHEMA_URL, isKubernetes, JSON_SCHEMASTORE_URL } from '../../languageservice/utils/schemaUrls.js'; +import { equals } from '../../languageservice/utils/objects.js'; +import type { LanguageService, LanguageSettings, SchemasSettings } from '../../languageservice/yamlLanguageService.js'; +import { SchemaPriority } from '../../languageservice/yamlLanguageService.js'; +import { SchemaSelectionRequests } from '../../requestTypes.js'; +import type { Settings, SettingsState } from '../../yamlSettings.js'; +import type { Telemetry } from '../../languageservice/telemetry.js'; +import type { ValidationHandler } from './validationHandlers.js'; export class SettingsHandler { private schemaSettings: SchemasSettings[] | undefined; @@ -69,7 +69,7 @@ export class SettingsHandler { } private async setConfiguration(settings: Settings): Promise { - configureHttpRequests(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL); + requestLight.configure(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL); this.yamlSettings.specificValidatorPaths = []; if (settings.yaml) { @@ -242,7 +242,7 @@ export class SettingsHandler { */ // eslint-disable-next-line @typescript-eslint/no-explicit-any private async getSchemaStoreMatchingSchemas(schemaStoreUrl: string): Promise<{ schemas: any[] }> { - const response = await xhr({ url: schemaStoreUrl }); + const response = await requestLight.xhr({ url: schemaStoreUrl }); const languageSettings = { schemas: [], diff --git a/src/languageserver/handlers/validationHandlers.ts b/src/languageserver/handlers/validationHandlers.ts index 644901ab4..b7a37b9dc 100644 --- a/src/languageserver/handlers/validationHandlers.ts +++ b/src/languageserver/handlers/validationHandlers.ts @@ -5,10 +5,10 @@ import type { Connection } from 'vscode-languageserver'; import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Diagnostic } from 'vscode-languageserver-types'; -import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes'; -import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils'; -import type { LanguageService } from '../../languageservice/yamlLanguageService'; -import type { SettingsState } from '../../yamlSettings'; +import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes.js'; +import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils.js'; +import type { LanguageService } from '../../languageservice/yamlLanguageService.js'; +import type { SettingsState } from '../../yamlSettings.js'; export class ValidationHandler { private languageService: LanguageService; diff --git a/src/languageserver/handlers/workspaceHandlers.ts b/src/languageserver/handlers/workspaceHandlers.ts index abb95e8f1..f419ca435 100644 --- a/src/languageserver/handlers/workspaceHandlers.ts +++ b/src/languageserver/handlers/workspaceHandlers.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import type { ExecuteCommandParams, Connection } from 'vscode-languageserver'; -import type { CommandExecutor } from '../commandExecutor'; +import type { CommandExecutor } from '../commandExecutor.js'; export class WorkspaceHandlers { constructor( diff --git a/src/languageserver/telemetry.ts b/src/languageserver/telemetry.ts index a28e88143..afcc7a745 100644 --- a/src/languageserver/telemetry.ts +++ b/src/languageserver/telemetry.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import type { TelemetryEvent, Telemetry } from '../languageservice/telemetry'; -import { convertErrorToTelemetryMsg } from '../languageservice/utils/objects'; +import type { TelemetryEvent, Telemetry } from '../languageservice/telemetry.js'; +import { convertErrorToTelemetryMsg } from '../languageservice/utils/objects.js'; export class TelemetryImpl implements Telemetry { constructor(private readonly connection: Connection) {} diff --git a/src/languageservice/jsonLanguageTypes.ts b/src/languageservice/jsonLanguageTypes.ts index 91c3a3999..516f9a126 100644 --- a/src/languageservice/jsonLanguageTypes.ts +++ b/src/languageservice/jsonLanguageTypes.ts @@ -6,90 +6,12 @@ // Forked from vscode-json-languageservice@6.0.0-next.1 // Source: https://github.com/microsoft/vscode-json-languageservice/blob/810471bbb462bb6b87351c2232e209a3bb4062ca/src/jsonLanguageTypes.ts -import { JSONSchema } from './jsonSchema'; +import type { JSONSchema } from './jsonSchema.js'; import type { FormattingOptions as LSPFormattingOptions } from 'vscode-languageserver-types'; -import { - Range, - Position, - DocumentUri, - MarkupContent, - MarkupKind, - Color, - ColorInformation, - ColorPresentation, - FoldingRange, - FoldingRangeKind, - SelectionRange, - Diagnostic, - DiagnosticSeverity, - CompletionItem, - CompletionItemKind, - CompletionList, - CompletionItemTag, - InsertTextFormat, - SymbolInformation, - SymbolKind, - DocumentSymbol, - Location, - Hover, - MarkedString, - DefinitionLink, - CodeActionContext, - Command, - CodeAction, - DocumentHighlight, - DocumentLink, - WorkspaceEdit, - TextEdit, - CodeActionKind, - TextDocumentEdit, - VersionedTextDocumentIdentifier, - DocumentHighlightKind, -} from 'vscode-languageserver-types'; -import { TextDocument, TextDocumentContentChangeEvent } from 'vscode-languageserver-textdocument'; +import { MarkupKind } from 'vscode-languageserver-types'; import type { Node, Pair } from 'yaml'; -import type { CustomTagReturnType } from './utils/customTags'; -export { - TextDocument, - TextDocumentContentChangeEvent, - Range, - Position, - DocumentUri, - MarkupContent, - MarkupKind, - JSONSchema, - Color, - ColorInformation, - ColorPresentation, - FoldingRange, - FoldingRangeKind, - SelectionRange, - Diagnostic, - DiagnosticSeverity, - CompletionItem, - CompletionItemKind, - CompletionList, - CompletionItemTag, - InsertTextFormat, - DefinitionLink, - SymbolInformation, - SymbolKind, - DocumentSymbol, - Location, - Hover, - MarkedString, - CodeActionContext, - Command, - CodeAction, - DocumentHighlight, - DocumentLink, - WorkspaceEdit, - TextEdit, - CodeActionKind, - TextDocumentEdit, - VersionedTextDocumentIdentifier, - DocumentHighlightKind, -}; +import type { CustomTagReturnType } from './utils/customTags.js'; + /** * Error codes used by diagnostics */ diff --git a/src/languageservice/jsonSchema.ts b/src/languageservice/jsonSchema.ts index dce0dc0f3..b99d77f2e 100644 --- a/src/languageservice/jsonSchema.ts +++ b/src/languageservice/jsonSchema.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { CompletionItemKind, SchemaDraft } from './jsonLanguageTypes'; -import type { SchemaVersions } from './yamlTypes'; +import type { CompletionItemKind } from 'vscode-languageserver-types'; +import type { SchemaDraft } from './jsonLanguageTypes.js'; +import type { SchemaVersions } from './yamlTypes.js'; export type JSONSchemaRef = JSONSchema | boolean; diff --git a/src/languageservice/parser/ast-converter.ts b/src/languageservice/parser/ast-converter.ts index 7c9dfa561..98d5d0ca0 100644 --- a/src/languageservice/parser/ast-converter.ts +++ b/src/languageservice/parser/ast-converter.ts @@ -5,8 +5,8 @@ import type { Node, Scalar, YAMLMap, Pair, YAMLSeq, Alias, Document, LineCounter } from 'yaml'; import { isScalar, isMap, isPair, isSeq, isNode, isAlias } from 'yaml'; -import type { ASTNode, YamlNode } from '../jsonLanguageTypes'; -import { getCustomTagReturnType } from '../utils/customTags'; +import type { ASTNode, YamlNode } from '../jsonLanguageTypes.js'; +import { getCustomTagReturnType } from '../utils/customTags.js'; import { NullASTNodeImpl, PropertyASTNodeImpl, @@ -15,7 +15,7 @@ import { NumberASTNodeImpl, ArrayASTNodeImpl, BooleanASTNodeImpl, -} from './jsonDocument'; +} from './jsonDocument.js'; type NodeRange = [number, number, number]; diff --git a/src/languageservice/parser/custom-tag-provider.ts b/src/languageservice/parser/custom-tag-provider.ts index 275e3d6f0..d47951e29 100644 --- a/src/languageservice/parser/custom-tag-provider.ts +++ b/src/languageservice/parser/custom-tag-provider.ts @@ -1,7 +1,7 @@ import type { Tags, YAMLMap, YAMLSeq } from 'yaml'; import { isSeq, isMap, Scalar } from 'yaml'; -import type { CustomTagInputType, CustomTagReturnType } from '../utils/customTags'; -import { parseCustomTag, setCustomTagReturnType } from '../utils/customTags'; +import type { CustomTagInputType, CustomTagReturnType } from '../utils/customTags.js'; +import { parseCustomTag, setCustomTagReturnType } from '../utils/customTags.js'; class CommonTagImpl { tag: string; diff --git a/src/languageservice/parser/isKubernetes.ts b/src/languageservice/parser/isKubernetes.ts index ebd9de8b5..e98fd6ddd 100644 --- a/src/languageservice/parser/isKubernetes.ts +++ b/src/languageservice/parser/isKubernetes.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { FilePatternAssociation } from '../utils/filePatternAssociation'; -import type * as Parser from './jsonDocument'; +import { FilePatternAssociation } from '../utils/filePatternAssociation.js'; +import type * as Parser from './jsonDocument.js'; export function setKubernetesParserOption(jsonDocuments: Parser.JSONDocument[], option: boolean): void { for (const jsonDoc of jsonDocuments) { diff --git a/src/languageservice/parser/jsonDocument.ts b/src/languageservice/parser/jsonDocument.ts index bb566f6ce..3598ac8e9 100644 --- a/src/languageservice/parser/jsonDocument.ts +++ b/src/languageservice/parser/jsonDocument.ts @@ -3,7 +3,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema } from '../jsonSchema'; +import type { JSONSchema } from '../jsonSchema.js'; import type { ASTNode, ObjectASTNode, @@ -14,14 +14,14 @@ import type { NullASTNode, PropertyASTNode, YamlNode, -} from '../jsonLanguageTypes'; -import type { CustomTagReturnType } from '../utils/customTags'; +} from '../jsonLanguageTypes.js'; +import type { CustomTagReturnType } from '../utils/customTags.js'; import type { Diagnostic, Range } from 'vscode-languageserver-types'; import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Node, Pair } from 'yaml'; -import type { IApplicableSchema } from './schemaValidation/baseValidator'; -import { findNodeAtOffset } from '../utils/astNodeUtils'; -import { getValidator } from './schemaValidation/validatorFactory'; +import type { IApplicableSchema } from './schemaValidation/baseValidator.js'; +import { findNodeAtOffset } from '../utils/astNodeUtils.js'; +import { getValidator } from './schemaValidation/validatorFactory.js'; abstract class ASTNodeImpl { public abstract readonly type: 'object' | 'property' | 'array' | 'number' | 'boolean' | 'null' | 'string'; @@ -232,6 +232,7 @@ export class JSONDocument { isKubernetes: this.isKubernetes, disableAdditionalProperties: this.disableAdditionalProperties, uri: this.uri, + createValidator: getValidator, }); } @@ -252,6 +253,7 @@ export class JSONDocument { disableAdditionalProperties: this.disableAdditionalProperties, uri: this.uri, callFromAutoComplete: didCallFromAutoComplete, + createValidator: getValidator, }, focusOffset, exclude diff --git a/src/languageservice/parser/schemaValidation/baseValidator.ts b/src/languageservice/parser/schemaValidation/baseValidator.ts index 6ec00e997..2a3920a6e 100644 --- a/src/languageservice/parser/schemaValidation/baseValidator.ts +++ b/src/languageservice/parser/schemaValidation/baseValidator.ts @@ -4,7 +4,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema'; +import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema.js'; import type { ASTNode, ArrayASTNode, @@ -13,20 +13,19 @@ import type { PropertyASTNode, StringASTNode, SchemaDraft, -} from '../../jsonLanguageTypes'; -import { equals, isBoolean, isDefined, isIterable, isNumber, isString } from '../../utils/objects'; -import { getSchemaTypeName } from '../../utils/schemaUtils'; -import { isArrayEqual } from '../../utils/arrUtils'; -import { safeCreateUnicodeRegExp } from '../../utils/strings'; -import { FilePatternAssociation } from '../../utils/filePatternAssociation'; -import { floatSafeRemainder } from '../../utils/math'; -import { ErrorCode } from '../../jsonLanguageTypes'; +} from '../../jsonLanguageTypes.js'; +import { equals, isBoolean, isDefined, isIterable, isNumber, isString } from '../../utils/objects.js'; +import { getSchemaTypeName } from '../../utils/schemaUtils.js'; +import { isArrayEqual } from '../../utils/arrUtils.js'; +import { safeCreateUnicodeRegExp } from '../../utils/strings.js'; +import { FilePatternAssociation } from '../../utils/filePatternAssociation.js'; +import { floatSafeRemainder } from '../../utils/math.js'; +import { ErrorCode } from '../../jsonLanguageTypes.js'; import * as l10n from '@vscode/l10n'; import { URI } from 'vscode-uri'; import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { contains, getNodeValue } from '../../utils/astNodeUtils'; -import { getValidator } from './validatorFactory'; +import { contains, getNodeValue } from '../../utils/astNodeUtils.js'; export const YAML_SOURCE = 'YAML'; const YAML_SCHEMA_PREFIX = 'yaml-schema: '; @@ -314,6 +313,7 @@ export interface Options { disableAdditionalProperties: boolean; uri: string; callFromAutoComplete?: boolean; + createValidator: (schemaDraft: SchemaDraft) => BaseValidator; } interface IValidationMatch { @@ -465,7 +465,7 @@ export abstract class BaseValidator { const subSchemaDraft = schema._schemaDraft; const currentSchemaDraft = this.getCurrentSchemaDraft(); if (subSchemaDraft !== currentSchemaDraft) { - const subValidator = getValidator(subSchemaDraft); + const subValidator = options.createValidator(subSchemaDraft); subValidator.validateNode(node, schema, originalSchema, validationResult, matchingSchemas, options); return; } diff --git a/src/languageservice/parser/schemaValidation/draft04Validator.ts b/src/languageservice/parser/schemaValidation/draft04Validator.ts index 2c67bf329..65c4f6a53 100644 --- a/src/languageservice/parser/schemaValidation/draft04Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft04Validator.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema } from '../../jsonSchema'; -import { SchemaDraft } from '../../jsonLanguageTypes'; -import { isBoolean, isNumber } from '../../utils/objects'; -import { BaseValidator } from './baseValidator'; +import type { JSONSchema } from '../../jsonSchema.js'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import { isBoolean, isNumber } from '../../utils/objects.js'; +import { BaseValidator } from './baseValidator.js'; export class Draft04Validator extends BaseValidator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/draft07Validator.ts b/src/languageservice/parser/schemaValidation/draft07Validator.ts index 73d5b3d2c..954b5fbe5 100644 --- a/src/languageservice/parser/schemaValidation/draft07Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft07Validator.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema } from '../../jsonSchema'; -import { SchemaDraft } from '../../jsonLanguageTypes'; -import { isNumber } from '../../utils/objects'; -import { BaseValidator } from './baseValidator'; +import type { JSONSchema } from '../../jsonSchema.js'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import { isNumber } from '../../utils/objects.js'; +import { BaseValidator } from './baseValidator.js'; export class Draft07Validator extends BaseValidator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/draft2019Validator.ts b/src/languageservice/parser/schemaValidation/draft2019Validator.ts index 14d84ff16..509947dca 100644 --- a/src/languageservice/parser/schemaValidation/draft2019Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft2019Validator.ts @@ -3,15 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema'; -import { ErrorCode, SchemaDraft } from '../../jsonLanguageTypes'; -import type { ASTNode, ArrayASTNode, ObjectASTNode } from '../../jsonLanguageTypes'; -import { isNumber } from '../../utils/objects'; +import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema.js'; +import { ErrorCode, SchemaDraft } from '../../jsonLanguageTypes.js'; +import type { ASTNode, ArrayASTNode, ObjectASTNode } from '../../jsonLanguageTypes.js'; +import { isNumber } from '../../utils/objects.js'; import * as l10n from '@vscode/l10n'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; -import { Draft07Validator } from './draft07Validator'; -import { ValidationResult, asSchema } from './baseValidator'; -import type { ISchemaCollector, Options } from './baseValidator'; +import { Draft07Validator } from './draft07Validator.js'; +import { ValidationResult, asSchema } from './baseValidator.js'; +import type { ISchemaCollector, Options } from './baseValidator.js'; export class Draft2019Validator extends Draft07Validator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/draft2020Validator.ts b/src/languageservice/parser/schemaValidation/draft2020Validator.ts index 36d02fa00..b4af4eec7 100644 --- a/src/languageservice/parser/schemaValidation/draft2020Validator.ts +++ b/src/languageservice/parser/schemaValidation/draft2020Validator.ts @@ -3,15 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema'; -import { SchemaDraft } from '../../jsonLanguageTypes'; -import type { ASTNode, ArrayASTNode } from '../../jsonLanguageTypes'; -import { isNumber } from '../../utils/objects'; +import type { JSONSchema, JSONSchemaRef } from '../../jsonSchema.js'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import type { ASTNode, ArrayASTNode } from '../../jsonLanguageTypes.js'; +import { isNumber } from '../../utils/objects.js'; import * as l10n from '@vscode/l10n'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; -import { Draft2019Validator } from './draft2019Validator'; -import type { ISchemaCollector, Options } from './baseValidator'; -import { ValidationResult, asSchema } from './baseValidator'; +import { Draft2019Validator } from './draft2019Validator.js'; +import type { ISchemaCollector, Options } from './baseValidator.js'; +import { ValidationResult, asSchema } from './baseValidator.js'; export class Draft2020Validator extends Draft2019Validator { protected override getCurrentSchemaDraft(): SchemaDraft { diff --git a/src/languageservice/parser/schemaValidation/validatorFactory.ts b/src/languageservice/parser/schemaValidation/validatorFactory.ts index e59c1ddc8..69fd3fc0f 100644 --- a/src/languageservice/parser/schemaValidation/validatorFactory.ts +++ b/src/languageservice/parser/schemaValidation/validatorFactory.ts @@ -3,12 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { SchemaDraft } from '../../jsonLanguageTypes'; -import type { BaseValidator } from './baseValidator'; -import { Draft04Validator } from './draft04Validator'; -import { Draft07Validator } from './draft07Validator'; -import { Draft2019Validator } from './draft2019Validator'; -import { Draft2020Validator } from './draft2020Validator'; +import { SchemaDraft } from '../../jsonLanguageTypes.js'; +import type { BaseValidator } from './baseValidator.js'; +import { Draft04Validator } from './draft04Validator.js'; +import { Draft07Validator } from './draft07Validator.js'; +import { Draft2019Validator } from './draft2019Validator.js'; +import { Draft2020Validator } from './draft2020Validator.js'; export function getValidator(schemaDraft: SchemaDraft): BaseValidator { switch (schemaDraft) { diff --git a/src/languageservice/parser/yaml-documents.ts b/src/languageservice/parser/yaml-documents.ts index f6c108eb5..95b8c63b0 100644 --- a/src/languageservice/parser/yaml-documents.ts +++ b/src/languageservice/parser/yaml-documents.ts @@ -4,19 +4,19 @@ *--------------------------------------------------------------------------------------------*/ import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { JSONDocument } from './jsonDocument'; +import { JSONDocument } from './jsonDocument.js'; import type { CST, Document, LineCounter, Node, YAMLError } from 'yaml'; import { isNode, isPair, isScalar, visit } from 'yaml'; -import type { ASTNode, YamlNode } from '../jsonLanguageTypes'; -import type { ParserOptions } from './yamlParser07'; -import { defaultOptions, parse as parseYAML } from './yamlParser07'; -import { ErrorCode } from '../jsonLanguageTypes'; -import { convertAST } from './ast-converter'; -import type { YAMLDocDiagnostic } from '../utils/parseUtils'; -import { isArrayEqual } from '../utils/arrUtils'; -import { getParent } from '../utils/yamlAstUtils'; -import type { TextBuffer } from '../utils/textBuffer'; -import { getIndentation } from '../utils/strings'; +import type { ASTNode, YamlNode } from '../jsonLanguageTypes.js'; +import type { ParserOptions } from './yamlParser07.js'; +import { defaultOptions, parse as parseYAML } from './yamlParser07.js'; +import { ErrorCode } from '../jsonLanguageTypes.js'; +import { convertAST } from './ast-converter.js'; +import type { YAMLDocDiagnostic } from '../utils/parseUtils.js'; +import { isArrayEqual } from '../utils/arrUtils.js'; +import { getParent } from '../utils/yamlAstUtils.js'; +import type { TextBuffer } from '../utils/textBuffer.js'; +import { getIndentation } from '../utils/strings.js'; /** * These documents are collected into a final YAMLDocument @@ -272,6 +272,8 @@ export class YamlDocuments { // a mapping of URIs to cached documents private cache = new Map(); + constructor(private readonly parse: typeof parseYAML = parseYAML) {} + /** * Get cached YAMLDocument * @param document TextDocument to parse @@ -306,7 +308,7 @@ export class YamlDocuments { if (addRootObject && !/\S/.test(text)) { text = `{${text}}`; } - const doc = parseYAML(text, parserOptions, document); + const doc = this.parse(text, parserOptions, document); cacheEntry.document = doc; cacheEntry.version = document.version; cacheEntry.parserOptions = parserOptions; diff --git a/src/languageservice/parser/yamlParser07.ts b/src/languageservice/parser/yamlParser07.ts index aeea9214e..9195b3b91 100644 --- a/src/languageservice/parser/yamlParser07.ts +++ b/src/languageservice/parser/yamlParser07.ts @@ -6,10 +6,10 @@ import type { CST, Document, ParseOptions, DocumentOptions, SchemaOptions } from 'yaml'; import { Parser, Composer, LineCounter } from 'yaml'; -import { YAMLDocument, SingleYAMLDocument } from './yaml-documents'; -import { getCustomTags } from './custom-tag-provider'; +import { YAMLDocument, SingleYAMLDocument } from './yaml-documents.js'; +import { getCustomTags } from './custom-tag-provider.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { TextBuffer } from '../utils/textBuffer'; +import { TextBuffer } from '../utils/textBuffer.js'; export { YAMLDocument, SingleYAMLDocument }; diff --git a/src/languageservice/services/documentSymbols.ts b/src/languageservice/services/documentSymbols.ts index 185d2009d..15d41a627 100644 --- a/src/languageservice/services/documentSymbols.ts +++ b/src/languageservice/services/documentSymbols.ts @@ -6,10 +6,10 @@ import { Location, Range, SymbolKind } from 'vscode-languageserver-types'; import type { DocumentSymbol, SymbolInformation } from 'vscode-languageserver-types'; -import type { DocumentSymbolsContext, ASTNode, PropertyASTNode } from '../jsonLanguageTypes'; +import type { DocumentSymbolsContext, ASTNode, PropertyASTNode } from '../jsonLanguageTypes.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { Telemetry } from '../telemetry'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { Telemetry } from '../telemetry.js'; import { isMap, isSeq } from 'yaml'; export class YAMLDocumentSymbols { diff --git a/src/languageservice/services/dollarUtils.ts b/src/languageservice/services/dollarUtils.ts index 8adff1469..304fa3dbf 100644 --- a/src/languageservice/services/dollarUtils.ts +++ b/src/languageservice/services/dollarUtils.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { SingleYAMLDocument } from '../parser/yamlParser07'; -import { JSONDocument } from '../parser/jsonDocument'; +import { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import { JSONDocument } from '../parser/jsonDocument.js'; /** * Retrieve schema if declared by `$schema`. diff --git a/src/languageservice/services/k8sSchemaUtil.ts b/src/languageservice/services/k8sSchemaUtil.ts index e2c0cb66a..f2e8da0d9 100644 --- a/src/languageservice/services/k8sSchemaUtil.ts +++ b/src/languageservice/services/k8sSchemaUtil.ts @@ -1,8 +1,8 @@ -import type { JSONDocument } from '../parser/jsonDocument'; -import { SingleYAMLDocument } from '../parser/yamlParser07'; +import type { JSONDocument } from '../parser/jsonDocument.js'; +import { SingleYAMLDocument } from '../parser/yamlParser07.js'; -import type { ResolvedSchema } from './yamlSchemaService'; -import type { JSONSchema } from '../jsonSchema'; +import type { ResolvedSchema } from './yamlSchemaService.js'; +import type { JSONSchema } from '../jsonSchema.js'; /** * Attempt to retrieve the schema for a given YAML document based on the Kubernetes GroupVersionKind (GVK). diff --git a/src/languageservice/services/modelineUtil.ts b/src/languageservice/services/modelineUtil.ts index 974929c46..c0530ac1e 100644 --- a/src/languageservice/services/modelineUtil.ts +++ b/src/languageservice/services/modelineUtil.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { SingleYAMLDocument } from '../parser/yamlParser07'; -import type { JSONDocument } from '../parser/jsonDocument'; +import { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { JSONDocument } from '../parser/jsonDocument.js'; /** * Retrieve schema if declared as modeline. diff --git a/src/languageservice/services/schemaRequestHandler.ts b/src/languageservice/services/schemaRequestHandler.ts index cb49cbbb6..a8ae08052 100644 --- a/src/languageservice/services/schemaRequestHandler.ts +++ b/src/languageservice/services/schemaRequestHandler.ts @@ -1,11 +1,11 @@ import { join } from 'path'; -import { getErrorStatusDescription, xhr } from 'request-light'; +import requestLight from 'request-light'; import type { Connection, WorkspaceFolder } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; -import { CustomSchemaContentRequest, VSCodeContentRequest } from '../../requestTypes'; -import { isRelativePath, relativeToAbsolutePath } from '../utils/paths'; -import type { WorkspaceContextService } from '../yamlLanguageService'; +import { CustomSchemaContentRequest, VSCodeContentRequest } from '../../requestTypes.js'; +import { isRelativePath, relativeToAbsolutePath } from '../utils/paths.js'; +import type { WorkspaceContextService } from '../yamlLanguageService.js'; export interface FileSystem { readFile(fsPath: string, encoding?: string): Promise; @@ -119,7 +119,7 @@ async function requestSchemaWithRetry( for (let attempt = 0; ; attempt++) { try { - const response = await xhr({ url, followRedirects: 5, headers }); + const response = await requestLight.xhr({ url, followRedirects: 5, headers }); return response.responseText; } catch (error) { if (attempt >= maxRetries || !isRetryableError(error)) { @@ -216,7 +216,7 @@ export const schemaRequestHandler = async ( try { return await requestSchemaWithRetry(uri, headers, retryOptions); } catch (error) { - throw error.responseText || getErrorStatusDescription(error.status) || error.toString(); + throw error.responseText || requestLight.getErrorStatusDescription(error.status) || error.toString(); } } diff --git a/src/languageservice/services/validation/map-key-order.ts b/src/languageservice/services/validation/map-key-order.ts index 71f80630a..34e9b41de 100644 --- a/src/languageservice/services/validation/map-key-order.ts +++ b/src/languageservice/services/validation/map-key-order.ts @@ -7,8 +7,8 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types'; import type { CST, Node, Pair } from 'yaml'; import { isMap, visit } from 'yaml'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; -import type { AdditionalValidator } from './types'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; +import type { AdditionalValidator } from './types.js'; export class MapKeyOrderValidator implements AdditionalValidator { validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[] { diff --git a/src/languageservice/services/validation/types.ts b/src/languageservice/services/validation/types.ts index 9ad2d38ee..37d910cf6 100644 --- a/src/languageservice/services/validation/types.ts +++ b/src/languageservice/services/validation/types.ts @@ -5,7 +5,7 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Diagnostic } from 'vscode-languageserver-types'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; export interface AdditionalValidator { validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[]; diff --git a/src/languageservice/services/validation/unused-anchors.ts b/src/languageservice/services/validation/unused-anchors.ts index da5a91046..1cd6489d8 100644 --- a/src/languageservice/services/validation/unused-anchors.ts +++ b/src/languageservice/services/validation/unused-anchors.ts @@ -7,10 +7,10 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Diagnostic, DiagnosticSeverity, DiagnosticTag, Range } from 'vscode-languageserver-types'; import type { Node, Scalar, YAMLMap, YAMLSeq, Pair } from 'yaml'; import { isAlias, isCollection, isNode, isScalar, visit, CST } from 'yaml'; -import type { YamlNode } from '../../jsonLanguageTypes'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; -import type { AdditionalValidator } from './types'; -import { isCollectionItem } from '../../utils/yamlAstUtils'; +import type { YamlNode } from '../../jsonLanguageTypes.js'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; +import type { AdditionalValidator } from './types.js'; +import { isCollectionItem } from '../../utils/yamlAstUtils.js'; import * as l10n from '@vscode/l10n'; export class UnusedAnchorsValidator implements AdditionalValidator { diff --git a/src/languageservice/services/validation/yaml-style.ts b/src/languageservice/services/validation/yaml-style.ts index 255c72834..605ad0fc6 100644 --- a/src/languageservice/services/validation/yaml-style.ts +++ b/src/languageservice/services/validation/yaml-style.ts @@ -2,9 +2,9 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types'; import type { CST } from 'yaml'; import { isMap, isSeq, visit } from 'yaml'; -import type { SingleYAMLDocument } from '../../parser/yaml-documents'; -import type { LanguageSettings } from '../../yamlLanguageService'; -import type { AdditionalValidator } from './types'; +import type { SingleYAMLDocument } from '../../parser/yaml-documents.js'; +import type { LanguageSettings } from '../../yamlLanguageService.js'; +import type { AdditionalValidator } from './types.js'; import * as l10n from '@vscode/l10n'; export class YAMLStyleValidator implements AdditionalValidator { diff --git a/src/languageservice/services/yamlCodeActions.ts b/src/languageservice/services/yamlCodeActions.ts index 036c706c3..eae7dce5a 100644 --- a/src/languageservice/services/yamlCodeActions.ts +++ b/src/languageservice/services/yamlCodeActions.ts @@ -5,7 +5,7 @@ import * as l10n from '@vscode/l10n'; import * as path from 'path'; -import { ErrorCode } from '../jsonLanguageTypes'; +import { ErrorCode } from '../jsonLanguageTypes.js'; import type { Diagnostic, WorkspaceEdit } from 'vscode-languageserver-types'; import { CodeAction, CodeActionKind, Command, Position, Range, TextEdit } from 'vscode-languageserver-types'; import type { ClientCapabilities, CodeActionParams } from 'vscode-languageserver-protocol'; @@ -14,19 +14,19 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Scalar, YAMLMap } from 'yaml'; import { CST, isMap, isSeq, isScalar, visit } from 'yaml'; -import { YamlCommands } from '../../commands'; -import { TextBuffer } from '../utils/textBuffer'; -import { toYamlStringScalar } from '../utils/yamlScalar'; -import type { LanguageSettings } from '../yamlLanguageService'; -import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator'; -import { getFirstNonWhitespaceCharacterAfterOffset } from '../utils/strings'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; +import { YamlCommands } from '../../commands.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import { toYamlStringScalar } from '../utils/yamlScalar.js'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator.js'; +import { getFirstNonWhitespaceCharacterAfterOffset } from '../utils/strings.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; -import { BlockStringRewriter } from '../utils/block-string-rewriter'; -import { FlowStyleRewriter } from '../utils/flow-style-rewriter'; +import { BlockStringRewriter } from '../utils/block-string-rewriter.js'; +import { FlowStyleRewriter } from '../utils/flow-style-rewriter.js'; -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; interface YamlDiagnosticData { schemaUri: string[]; diff --git a/src/languageservice/services/yamlCodeLens.ts b/src/languageservice/services/yamlCodeLens.ts index 8681b719f..9070e4377 100644 --- a/src/languageservice/services/yamlCodeLens.ts +++ b/src/languageservice/services/yamlCodeLens.ts @@ -5,12 +5,12 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import { CodeLens, Range } from 'vscode-languageserver-types'; -import { YamlCommands } from '../../commands'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { YAMLSchemaService } from './yamlSchemaService'; -import type { Telemetry } from '../telemetry'; -import { getSchemaUrls } from '../utils/schemaUrls'; -import { getSchemaTitle } from '../utils/schemaUtils'; +import { YamlCommands } from '../../commands.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { YAMLSchemaService } from './yamlSchemaService.js'; +import type { Telemetry } from '../telemetry.js'; +import { getSchemaUrls } from '../utils/schemaUrls.js'; +import { getSchemaTitle } from '../utils/schemaUtils.js'; export class YamlCodeLens { constructor( diff --git a/src/languageservice/services/yamlCommands.ts b/src/languageservice/services/yamlCommands.ts index efdee7682..fc1ad3848 100644 --- a/src/languageservice/services/yamlCommands.ts +++ b/src/languageservice/services/yamlCommands.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import type { Connection } from 'vscode-languageserver'; -import { YamlCommands } from '../../commands'; -import type { CommandExecutor } from '../../languageserver/commandExecutor'; +import { YamlCommands } from '../../commands.js'; +import type { CommandExecutor } from '../../languageserver/commandExecutor.js'; import { URI } from 'vscode-uri'; export function registerCommands(commandExecutor: CommandExecutor, connection: Connection): void { diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts index b258cbe2d..97963aa34 100644 --- a/src/languageservice/services/yamlCompletion.ts +++ b/src/languageservice/services/yamlCompletion.ts @@ -19,27 +19,27 @@ import { } from 'vscode-languageserver-types'; import type { Node, YAMLMap, YAMLSeq, Pair } from 'yaml'; import { isPair, isScalar, isMap, isSeq, isNode } from 'yaml'; -import { parseCustomTag } from '../utils/customTags'; -import type { Telemetry } from '../telemetry'; -import type { SingleYAMLDocument, YamlDocuments } from '../parser/yaml-documents'; -import type { YamlVersion } from '../parser/yamlParser07'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { guessIndentation } from '../utils/indentationGuesser'; -import { TextBuffer } from '../utils/textBuffer'; -import type { LanguageSettings } from '../yamlLanguageService'; -import type { ResolvedSchema, YAMLSchemaService } from './yamlSchemaService'; -import type { JSONSchema, JSONSchemaRef } from '../jsonSchema'; -import type { StringifySettings } from '../utils/json'; -import { stringifyObject } from '../utils/json'; -import { isDefined, isString } from '../utils/objects'; -import { setKubernetesParserOption } from '../parser/isKubernetes'; -import { asSchema } from '../parser/schemaValidation/baseValidator'; -import { indexOf, isInComment, isMapContainsEmptyPair } from '../utils/yamlAstUtils'; -import { isModeline } from './modelineUtil'; -import { getSchemaTypeName, isAnyOfAllOfOneOfType, isPrimitiveType } from '../utils/schemaUtils'; -import type { YamlNode } from '../jsonLanguageTypes'; -import type { SettingsState } from '../../yamlSettings'; -import { toYamlStringScalar } from '../utils/yamlScalar'; +import { parseCustomTag } from '../utils/customTags.js'; +import type { Telemetry } from '../telemetry.js'; +import type { SingleYAMLDocument, YamlDocuments } from '../parser/yaml-documents.js'; +import type { YamlVersion } from '../parser/yamlParser07.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { guessIndentation } from '../utils/indentationGuesser.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import type { ResolvedSchema, YAMLSchemaService } from './yamlSchemaService.js'; +import type { JSONSchema, JSONSchemaRef } from '../jsonSchema.js'; +import type { StringifySettings } from '../utils/json.js'; +import { stringifyObject } from '../utils/json.js'; +import { isDefined, isString } from '../utils/objects.js'; +import { setKubernetesParserOption } from '../parser/isKubernetes.js'; +import { asSchema } from '../parser/schemaValidation/baseValidator.js'; +import { indexOf, isInComment, isMapContainsEmptyPair } from '../utils/yamlAstUtils.js'; +import { isModeline } from './modelineUtil.js'; +import { getSchemaTypeName, isAnyOfAllOfOneOfType, isPrimitiveType } from '../utils/schemaUtils.js'; +import type { YamlNode } from '../jsonLanguageTypes.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import { toYamlStringScalar } from '../utils/yamlScalar.js'; import * as l10n from '@vscode/l10n'; const parentCompletionKind = CompletionItemKind.Class; diff --git a/src/languageservice/services/yamlDefinition.ts b/src/languageservice/services/yamlDefinition.ts index d7d3bc49f..2b790f097 100644 --- a/src/languageservice/services/yamlDefinition.ts +++ b/src/languageservice/services/yamlDefinition.ts @@ -8,10 +8,10 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { DefinitionLink } from 'vscode-languageserver-types'; import { LocationLink, Range } from 'vscode-languageserver-types'; import { isAlias } from 'yaml'; -import type { Telemetry } from '../telemetry'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { TextBuffer } from '../utils/textBuffer'; +import type { Telemetry } from '../telemetry.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { TextBuffer } from '../utils/textBuffer.js'; export class YamlDefinition { constructor(private readonly telemetry?: Telemetry) {} diff --git a/src/languageservice/services/yamlFolding.ts b/src/languageservice/services/yamlFolding.ts index d9c19c718..d15942aa4 100644 --- a/src/languageservice/services/yamlFolding.ts +++ b/src/languageservice/services/yamlFolding.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { FoldingRange, Range } from 'vscode-languageserver-types'; -import type { FoldingRangesContext } from '../yamlTypes'; -import type { ASTNode } from '../jsonLanguageTypes'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; +import type { FoldingRangesContext } from '../yamlTypes.js'; +import type { ASTNode } from '../jsonLanguageTypes.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; export function getFoldingRanges(document: TextDocument, context: FoldingRangesContext): FoldingRange[] | undefined { diff --git a/src/languageservice/services/yamlFormatter.ts b/src/languageservice/services/yamlFormatter.ts index f980d98f4..b3d00ef94 100644 --- a/src/languageservice/services/yamlFormatter.ts +++ b/src/languageservice/services/yamlFormatter.ts @@ -6,7 +6,7 @@ import type { FormattingOptions } from 'vscode-languageserver-types'; import { Range, Position, TextEdit } from 'vscode-languageserver-types'; -import type { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService'; +import type { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService.js'; import type { Options } from 'prettier'; import * as yamlPlugin from 'prettier/plugins/yaml'; import * as estreePlugin from 'prettier/plugins/estree'; diff --git a/src/languageservice/services/yamlHover.ts b/src/languageservice/services/yamlHover.ts index bf74361e4..d28aa3a94 100644 --- a/src/languageservice/services/yamlHover.ts +++ b/src/languageservice/services/yamlHover.ts @@ -12,18 +12,18 @@ import { MarkupKind, Range } from 'vscode-languageserver-types'; import { URI } from 'vscode-uri'; import type { Node } from 'yaml'; import { isAlias, isMap, isSeq, stringify as stringifyYAML } from 'yaml'; -import type { ASTNode, ObjectASTNode, PropertyASTNode } from '../jsonLanguageTypes'; -import type { JSONSchema } from '../jsonSchema'; -import { setKubernetesParserOption } from '../parser/isKubernetes'; -import { getNodeValue } from '../utils/astNodeUtils'; -import type { IApplicableSchema } from '../parser/schemaValidation/baseValidator'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { SingleYAMLDocument } from '../parser/yamlParser07'; -import type { Telemetry } from '../telemetry'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { toYamlStringScalar } from '../utils/yamlScalar'; -import type { LanguageSettings } from '../yamlLanguageService'; -import type { YAMLSchemaService } from './yamlSchemaService'; +import type { ASTNode, ObjectASTNode, PropertyASTNode } from '../jsonLanguageTypes.js'; +import type { JSONSchema } from '../jsonSchema.js'; +import { setKubernetesParserOption } from '../parser/isKubernetes.js'; +import { getNodeValue } from '../utils/astNodeUtils.js'; +import type { IApplicableSchema } from '../parser/schemaValidation/baseValidator.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { Telemetry } from '../telemetry.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { toYamlStringScalar } from '../utils/yamlScalar.js'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import type { YAMLSchemaService } from './yamlSchemaService.js'; export class YAMLHover { private shouldHover: boolean; diff --git a/src/languageservice/services/yamlLinks.ts b/src/languageservice/services/yamlLinks.ts index f92fc0028..434c97090 100644 --- a/src/languageservice/services/yamlLinks.ts +++ b/src/languageservice/services/yamlLinks.ts @@ -6,10 +6,10 @@ import type { DocumentLink } from 'vscode-languageserver-types'; import { Range } from 'vscode-languageserver-types'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import type { Telemetry } from '../telemetry'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { ASTNode, PropertyASTNode } from '../jsonLanguageTypes'; -import type { JSONDocument } from '../parser/jsonDocument'; +import type { Telemetry } from '../telemetry.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { ASTNode, PropertyASTNode } from '../jsonLanguageTypes.js'; +import type { JSONDocument } from '../parser/jsonDocument.js'; export class YamlLinks { constructor(private readonly telemetry?: Telemetry) {} diff --git a/src/languageservice/services/yamlOnTypeFormatting.ts b/src/languageservice/services/yamlOnTypeFormatting.ts index 27f80dcda..93db1aa7b 100644 --- a/src/languageservice/services/yamlOnTypeFormatting.ts +++ b/src/languageservice/services/yamlOnTypeFormatting.ts @@ -6,7 +6,7 @@ import type { DocumentOnTypeFormattingParams } from 'vscode-languageserver'; import type { TextDocument } from 'vscode-languageserver-textdocument'; import { Position, Range, TextEdit } from 'vscode-languageserver-types'; -import { TextBuffer } from '../utils/textBuffer'; +import { TextBuffer } from '../utils/textBuffer.js'; export function doDocumentOnTypeFormatting( document: TextDocument, diff --git a/src/languageservice/services/yamlRename.ts b/src/languageservice/services/yamlRename.ts index df633208b..41e475c6a 100644 --- a/src/languageservice/services/yamlRename.ts +++ b/src/languageservice/services/yamlRename.ts @@ -6,14 +6,14 @@ import type { TextDocument } from 'vscode-languageserver-textdocument'; import type { Position, WorkspaceEdit } from 'vscode-languageserver-types'; import { Range, TextEdit } from 'vscode-languageserver-types'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import { matchOffsetToDocument } from '../utils/arrUtils'; -import { TextBuffer } from '../utils/textBuffer'; -import type { Telemetry } from '../telemetry'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import { matchOffsetToDocument } from '../utils/arrUtils.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import type { Telemetry } from '../telemetry.js'; import type { Node } from 'yaml'; import { CST, isAlias, isCollection, isScalar, visit } from 'yaml'; -import type { SingleYAMLDocument } from '../parser/yamlParser07'; -import { isCollectionItem } from '../utils/yamlAstUtils'; +import type { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import { isCollectionItem } from '../utils/yamlAstUtils.js'; import type { PrepareRenameParams, RenameParams } from 'vscode-languageserver-protocol'; import { ResponseError, ErrorCodes } from 'vscode-languageserver-protocol'; diff --git a/src/languageservice/services/yamlSchemaService.ts b/src/languageservice/services/yamlSchemaService.ts index b5bfd68e7..8010e8e3c 100644 --- a/src/languageservice/services/yamlSchemaService.ts +++ b/src/languageservice/services/yamlSchemaService.ts @@ -5,44 +5,44 @@ *--------------------------------------------------------------------------------------------*/ import type { AnySchemaObject, DefinedError, ErrorObject, ValidateFunction } from 'ajv'; -import type { Localize } from 'ajv-i18n/localize/types'; +import type { Localize } from 'ajv-i18n/localize/types.js'; import type { DiagnosticRelatedInformation } from 'vscode-languageserver-types'; -import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes'; -import type { SettingsState } from '../../yamlSettings'; -import type { PromiseConstructor, SchemaConfiguration } from '../jsonLanguageTypes'; -import type { JSONSchema, JSONSchemaMap, JSONSchemaRef } from '../jsonSchema'; -import type { JSONDocument } from '../parser/jsonDocument'; -import type { SingleYAMLDocument } from '../parser/yamlParser07'; -import type { SchemaRequestService, WorkspaceContextService } from '../yamlLanguageService'; -import type { SchemaVersions } from '../yamlTypes'; +import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes.js'; +import type { SettingsState } from '../../yamlSettings.js'; +import type { PromiseConstructor, SchemaConfiguration } from '../jsonLanguageTypes.js'; +import type { JSONSchema, JSONSchemaMap, JSONSchemaRef } from '../jsonSchema.js'; +import type { JSONDocument } from '../parser/jsonDocument.js'; +import type { SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { SchemaRequestService, WorkspaceContextService } from '../yamlLanguageService.js'; +import type { SchemaVersions } from '../yamlTypes.js'; import * as path from 'path'; import * as l10n from '@vscode/l10n'; import Ajv from 'ajv'; -import Ajv2019 from 'ajv/dist/2019'; -import Ajv2020 from 'ajv/dist/2020'; +import Ajv2019 from 'ajv/dist/2019.js'; +import Ajv2020 from 'ajv/dist/2020.js'; import Ajv4 from 'ajv-draft-04'; -import * as ajvLocalizers from 'ajv-i18n'; +import ajvLocalizers from 'ajv-i18n'; import * as Json from 'jsonc-parser'; import picomatch from 'picomatch'; import { Range } from 'vscode-languageserver-types'; import { URI } from 'vscode-uri'; import { parse } from 'yaml'; -import { getDollarSchema } from './dollarUtils'; -import { getSchemaFromModeline } from './modelineUtil'; -import { ErrorCode, SchemaDraft } from '../jsonLanguageTypes'; -import { asSchema } from '../parser/schemaValidation/baseValidator'; -import { SchemaPriority } from '../yamlLanguageService'; -import { autoDetectKubernetesSchema } from './k8sSchemaUtil'; -import { CRD_CATALOG_URL, EMPTY_SCHEMA_URL, isKubernetes } from '../utils/schemaUrls'; -import * as Strings from '../utils/strings'; - -const ajv4 = new Ajv4({ allErrors: true }); -const ajv7 = new Ajv({ allErrors: true }); -const ajv2019 = new Ajv2019({ allErrors: true }); -const ajv2020 = new Ajv2020({ allErrors: true }); +import { getDollarSchema } from './dollarUtils.js'; +import { getSchemaFromModeline } from './modelineUtil.js'; +import { ErrorCode, SchemaDraft } from '../jsonLanguageTypes.js'; +import { asSchema } from '../parser/schemaValidation/baseValidator.js'; +import { SchemaPriority } from '../yamlLanguageService.js'; +import { autoDetectKubernetesSchema } from './k8sSchemaUtil.js'; +import { CRD_CATALOG_URL, EMPTY_SCHEMA_URL, isKubernetes } from '../utils/schemaUrls.js'; +import * as Strings from '../utils/strings.js'; + +const ajv4 = new Ajv4.default({ allErrors: true }); +const ajv7 = new Ajv.default({ allErrors: true }); +const ajv2019 = new Ajv2019.default({ allErrors: true }); +const ajv2020 = new Ajv2020.default({ allErrors: true }); const schema04Validator = getDefaultMetaSchemaValidator(ajv4); const schema07Validator = getDefaultMetaSchemaValidator(ajv7); diff --git a/src/languageservice/services/yamlSelectionRanges.ts b/src/languageservice/services/yamlSelectionRanges.ts index 2b6c2c14d..e66e7a174 100644 --- a/src/languageservice/services/yamlSelectionRanges.ts +++ b/src/languageservice/services/yamlSelectionRanges.ts @@ -1,8 +1,8 @@ import type { Position, Range } from 'vscode-languageserver-types'; import { SelectionRange } from 'vscode-languageserver-types'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; export function getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[] { const doc = yamlDocumentsCache.getYamlDocument(document); diff --git a/src/languageservice/services/yamlValidation.ts b/src/languageservice/services/yamlValidation.ts index 7592f96d5..cea31d810 100644 --- a/src/languageservice/services/yamlValidation.ts +++ b/src/languageservice/services/yamlValidation.ts @@ -6,23 +6,23 @@ import { Diagnostic, DiagnosticSeverity, Position, Range } from 'vscode-languageserver-types'; import type { DiagnosticRelatedInformation } from 'vscode-languageserver-types'; -import type { LanguageSettings } from '../yamlLanguageService'; -import type { YamlVersion, SingleYAMLDocument } from '../parser/yamlParser07'; -import type { YAMLSchemaService } from './yamlSchemaService'; -import type { YAMLDocDiagnostic } from '../utils/parseUtils'; +import type { LanguageSettings } from '../yamlLanguageService.js'; +import type { YamlVersion, SingleYAMLDocument } from '../parser/yamlParser07.js'; +import type { YAMLSchemaService } from './yamlSchemaService.js'; +import type { YAMLDocDiagnostic } from '../utils/parseUtils.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator'; -import { TextBuffer } from '../utils/textBuffer'; -import { filterSuppressedDiagnostics } from '../utils/diagnostic-filter'; -import { yamlDocumentsCache } from '../parser/yaml-documents'; -import type { Telemetry } from '../telemetry'; -import type { AdditionalValidator } from './validation/types'; -import { UnusedAnchorsValidator } from './validation/unused-anchors'; -import { YAMLStyleValidator } from './validation/yaml-style'; -import { MapKeyOrderValidator } from './validation/map-key-order'; -import { getSchemaFromModeline } from './modelineUtil'; -import { isKubernetes as isKubernetesSchemaURI } from '../utils/schemaUrls'; -import type { ErrorCode } from '../jsonLanguageTypes'; +import { YAML_SOURCE } from '../parser/schemaValidation/baseValidator.js'; +import { TextBuffer } from '../utils/textBuffer.js'; +import { filterSuppressedDiagnostics } from '../utils/diagnostic-filter.js'; +import { yamlDocumentsCache } from '../parser/yaml-documents.js'; +import type { Telemetry } from '../telemetry.js'; +import type { AdditionalValidator } from './validation/types.js'; +import { UnusedAnchorsValidator } from './validation/unused-anchors.js'; +import { YAMLStyleValidator } from './validation/yaml-style.js'; +import { MapKeyOrderValidator } from './validation/map-key-order.js'; +import { getSchemaFromModeline } from './modelineUtil.js'; +import { isKubernetes as isKubernetesSchemaURI } from '../utils/schemaUrls.js'; +import type { ErrorCode } from '../jsonLanguageTypes.js'; /** * Convert a YAMLDocDiagnostic to a language server Diagnostic diff --git a/src/languageservice/utils/arrUtils.ts b/src/languageservice/utils/arrUtils.ts index 6180eaade..2950524b1 100644 --- a/src/languageservice/utils/arrUtils.ts +++ b/src/languageservice/utils/arrUtils.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { YAMLDocument, SingleYAMLDocument } from '../parser/yamlParser07'; +import type { YAMLDocument, SingleYAMLDocument } from '../parser/yamlParser07.js'; export function getLineOffsets(textDocString: string): number[] { const lineOffsets: number[] = []; diff --git a/src/languageservice/utils/astNodeUtils.ts b/src/languageservice/utils/astNodeUtils.ts index 6c44353cf..495a1ff25 100644 --- a/src/languageservice/utils/astNodeUtils.ts +++ b/src/languageservice/utils/astNodeUtils.ts @@ -1,4 +1,4 @@ -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function getNodeValue(node: ASTNode): any { diff --git a/src/languageservice/utils/filePatternAssociation.ts b/src/languageservice/utils/filePatternAssociation.ts index 7edba5d42..d1124cd3e 100644 --- a/src/languageservice/utils/filePatternAssociation.ts +++ b/src/languageservice/utils/filePatternAssociation.ts @@ -1,4 +1,4 @@ -import { convertSimple2RegExpPattern } from './strings'; +import { convertSimple2RegExpPattern } from './strings.js'; export class FilePatternAssociation { private schemas: string[]; diff --git a/src/languageservice/utils/flow-style-rewriter.ts b/src/languageservice/utils/flow-style-rewriter.ts index db872ce2b..6273907d6 100644 --- a/src/languageservice/utils/flow-style-rewriter.ts +++ b/src/languageservice/utils/flow-style-rewriter.ts @@ -1,5 +1,5 @@ import { CST, visit } from 'yaml'; -import type { ASTNode } from '../jsonLanguageTypes'; +import type { ASTNode } from '../jsonLanguageTypes.js'; export class FlowStyleRewriter { constructor(private readonly indentation: string) {} diff --git a/src/languageservice/utils/indentationGuesser.ts b/src/languageservice/utils/indentationGuesser.ts index 3cca1955f..7f665861e 100644 --- a/src/languageservice/utils/indentationGuesser.ts +++ b/src/languageservice/utils/indentationGuesser.ts @@ -5,8 +5,8 @@ //copied from https://github.com/Microsoft/vscode/blob/015c3afe96966df50c15a7d66be2ab0ef1dc5f49/src/vs/editor/common/model/indentationGuesser.ts -import { CharCode } from './charCode'; -import type { TextBuffer } from './textBuffer'; +import { CharCode } from './charCode.js'; +import type { TextBuffer } from './textBuffer.js'; class SpacesDiffResult { public spacesDiff = 0; diff --git a/src/languageservice/utils/objects.ts b/src/languageservice/utils/objects.ts index e6db971c2..dc8d6425e 100644 --- a/src/languageservice/utils/objects.ts +++ b/src/languageservice/utils/objects.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { parseYamlBoolean } from '../parser/scalar-type'; +import { parseYamlBoolean } from '../parser/scalar-type.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function equals(one: any, other: any, type?: any): boolean { diff --git a/src/languageservice/utils/parseUtils.ts b/src/languageservice/utils/parseUtils.ts index a4b0fb7c3..dd54eae02 100644 --- a/src/languageservice/utils/parseUtils.ts +++ b/src/languageservice/utils/parseUtils.ts @@ -1,5 +1,4 @@ -import type { ErrorCode } from '../jsonLanguageTypes'; -export const DUPLICATE_KEY_REASON = 'duplicate key'; +import type { ErrorCode } from '../jsonLanguageTypes.js'; /** * An individual YAML diagnostic, diff --git a/src/languageservice/utils/schemaUrls.ts b/src/languageservice/utils/schemaUrls.ts index bc7fa836b..da844c4f8 100644 --- a/src/languageservice/utils/schemaUrls.ts +++ b/src/languageservice/utils/schemaUrls.ts @@ -1,10 +1,10 @@ import type { WorkspaceFolder } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; import * as path from 'path'; -import type { Telemetry } from '../telemetry'; -import type { JSONSchema, JSONSchemaRef } from '../jsonSchema'; -import { isBoolean } from './objects'; -import { isRelativePath, relativeToAbsolutePath } from './paths'; +import type { Telemetry } from '../telemetry.js'; +import type { JSONSchema, JSONSchemaRef } from '../jsonSchema.js'; +import { isBoolean } from './objects.js'; +import { isRelativePath, relativeToAbsolutePath } from './paths.js'; export const DEFAULT_KUBERNETES_SCHEMA_VERSION = 'v1.34.1'; export const JSON_SCHEMASTORE_URL = 'https://www.schemastore.org/api/json/catalog.json'; diff --git a/src/languageservice/utils/schemaUtils.ts b/src/languageservice/utils/schemaUtils.ts index 373539b64..aab976153 100644 --- a/src/languageservice/utils/schemaUtils.ts +++ b/src/languageservice/utils/schemaUtils.ts @@ -1,5 +1,5 @@ import { URI } from 'vscode-uri'; -import type { JSONSchema } from '../jsonSchema'; +import type { JSONSchema } from '../jsonSchema.js'; import * as path from 'path'; export function getSchemaTypeName(schema: JSONSchema, ignoreFileNameRefs = false): string { diff --git a/src/languageservice/utils/strings.ts b/src/languageservice/utils/strings.ts index e74380206..3a33e4997 100644 --- a/src/languageservice/utils/strings.ts +++ b/src/languageservice/utils/strings.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CharCode } from './charCode'; +import { CharCode } from './charCode.js'; export function startsWith(haystack: string, needle: string): boolean { if (haystack.length < needle.length) { diff --git a/src/languageservice/utils/yamlAstUtils.ts b/src/languageservice/utils/yamlAstUtils.ts index 6bd6c5418..042bf385f 100644 --- a/src/languageservice/utils/yamlAstUtils.ts +++ b/src/languageservice/utils/yamlAstUtils.ts @@ -5,7 +5,7 @@ import type { CST, Document, Node, YAMLMap, YAMLSeq } from 'yaml'; import { isDocument, isScalar, visit } from 'yaml'; -import type { YamlNode } from '../jsonLanguageTypes'; +import type { YamlNode } from '../jsonLanguageTypes.js'; type Visitor = (item: CST.SourceToken, path: CST.VisitPath) => number | symbol | Visitor | void; diff --git a/src/languageservice/yamlLanguageService.ts b/src/languageservice/yamlLanguageService.ts index b67d9f719..8283c80d8 100644 --- a/src/languageservice/yamlLanguageService.ts +++ b/src/languageservice/yamlLanguageService.ts @@ -4,8 +4,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { CustomSchemaProvider, SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from './services/yamlSchemaService'; -import { YAMLSchemaService } from './services/yamlSchemaService'; +import type { CustomSchemaProvider, SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from './services/yamlSchemaService.js'; +import { YAMLSchemaService } from './services/yamlSchemaService.js'; import type { Position, CodeAction, @@ -23,13 +23,13 @@ import type { Range, WorkspaceEdit, } from 'vscode-languageserver-types'; -import type { JSONSchema } from './jsonSchema'; -import { YAMLDocumentSymbols } from './services/documentSymbols'; -import { YAMLHover } from './services/yamlHover'; -import { YAMLValidation } from './services/yamlValidation'; -import { YAMLFormatter } from './services/yamlFormatter'; -import type { DocumentSymbolsContext } from './jsonLanguageTypes'; -import { YamlLinks } from './services/yamlLinks'; +import type { JSONSchema } from './jsonSchema.js'; +import { YAMLDocumentSymbols } from './services/documentSymbols.js'; +import { YAMLHover } from './services/yamlHover.js'; +import { YAMLValidation } from './services/yamlValidation.js'; +import { YAMLFormatter } from './services/yamlFormatter.js'; +import type { DocumentSymbolsContext } from './jsonLanguageTypes.js'; +import { YamlLinks } from './services/yamlLinks.js'; import type { ClientCapabilities, CodeActionParams, @@ -40,20 +40,20 @@ import type { RenameParams, } from 'vscode-languageserver'; import type { TextDocument } from 'vscode-languageserver-textdocument'; -import { getFoldingRanges } from './services/yamlFolding'; -import type { FoldingRangesContext, SchemaVersions } from './yamlTypes'; -import { YamlCodeActions } from './services/yamlCodeActions'; -import { doDocumentOnTypeFormatting } from './services/yamlOnTypeFormatting'; -import { YamlCodeLens } from './services/yamlCodeLens'; -import type { Telemetry } from './telemetry'; -import type { YamlVersion } from './parser/yamlParser07'; -import { YamlCompletion } from './services/yamlCompletion'; -import { yamlDocumentsCache } from './parser/yaml-documents'; -import type { SettingsState } from '../yamlSettings'; -import { JSONSchemaSelection } from '../languageserver/handlers/schemaSelectionHandlers'; -import { YamlDefinition } from './services/yamlDefinition'; -import { getSelectionRanges } from './services/yamlSelectionRanges'; -import { YamlRename } from './services/yamlRename'; +import { getFoldingRanges } from './services/yamlFolding.js'; +import type { FoldingRangesContext, SchemaVersions } from './yamlTypes.js'; +import { YamlCodeActions } from './services/yamlCodeActions.js'; +import { doDocumentOnTypeFormatting } from './services/yamlOnTypeFormatting.js'; +import { YamlCodeLens } from './services/yamlCodeLens.js'; +import type { Telemetry } from './telemetry.js'; +import type { YamlVersion } from './parser/yamlParser07.js'; +import { YamlCompletion } from './services/yamlCompletion.js'; +import { yamlDocumentsCache } from './parser/yaml-documents.js'; +import type { SettingsState } from '../yamlSettings.js'; +import { JSONSchemaSelection } from '../languageserver/handlers/schemaSelectionHandlers.js'; +import { YamlDefinition } from './services/yamlDefinition.js'; +import { getSelectionRanges } from './services/yamlSelectionRanges.js'; +import { YamlRename } from './services/yamlRename.js'; export enum SchemaPriority { SchemaStore = 1, diff --git a/src/nodeTranslationSetup.ts b/src/nodeTranslationSetup.ts index 25d5ef773..c7c8d6359 100644 --- a/src/nodeTranslationSetup.ts +++ b/src/nodeTranslationSetup.ts @@ -16,8 +16,7 @@ import type { InitializeParams } from 'vscode-languageserver'; * @param params the language server initialization parameters */ export async function setupl10nBundle(params: InitializeParams): Promise { - const __dirname = path.dirname(__filename); - const l10nPath: string = params.initializationOptions?.l10nPath || path.join(__dirname, '../../../l10n'); + const l10nPath: string = params.initializationOptions?.l10nPath || path.join(import.meta.dirname, '../../../l10n'); const locale: string = params.locale || 'en'; if (l10nPath) { const bundleFile = !existsSync(path.join(l10nPath, `bundle.l10n.${locale}.json`)) diff --git a/src/requestTypes.ts b/src/requestTypes.ts index 4e4087ad2..1ebdeefba 100644 --- a/src/requestTypes.ts +++ b/src/requestTypes.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-namespace */ import { NotificationType, RequestType } from 'vscode-languageserver'; -import type { SchemaAdditions, SchemaDeletions } from './languageservice/services/yamlSchemaService'; -import type { SchemaConfiguration } from './languageservice/yamlLanguageService'; -import type { SchemaVersions } from './languageservice/yamlTypes'; +import type { SchemaAdditions, SchemaDeletions } from './languageservice/services/yamlSchemaService.js'; +import type { SchemaConfiguration } from './languageservice/yamlLanguageService.js'; +import type { SchemaVersions } from './languageservice/yamlTypes.js'; export type ISchemaAssociations = Record; diff --git a/src/server.ts b/src/server.ts index 86cb855ba..8dcf8f440 100644 --- a/src/server.ts +++ b/src/server.ts @@ -6,14 +6,14 @@ *--------------------------------------------------------------------------------------------*/ import { promises as fs } from 'fs'; -import type { Connection } from 'vscode-languageserver/node'; -import { createConnection, ProposedFeatures } from 'vscode-languageserver/node'; -import { TelemetryImpl } from './languageserver/telemetry'; -import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler'; -import { convertErrorToTelemetryMsg } from './languageservice/utils/objects'; -import { setupl10nBundle } from './nodeTranslationSetup'; -import { YAMLServerInit } from './yamlServerInit'; -import { SettingsState } from './yamlSettings'; +import type { Connection } from 'vscode-languageserver/node.js'; +import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js'; +import { TelemetryImpl } from './languageserver/telemetry.js'; +import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler.js'; +import { convertErrorToTelemetryMsg } from './languageservice/utils/objects.js'; +import { setupl10nBundle } from './nodeTranslationSetup.js'; +import { YAMLServerInit } from './yamlServerInit.js'; +import { SettingsState } from './yamlSettings.js'; // Create a connection for the server. let connection: Connection = null; diff --git a/src/webworker/yamlServerMain.ts b/src/webworker/yamlServerMain.ts index 0e2c5ae40..d7c01965e 100644 --- a/src/webworker/yamlServerMain.ts +++ b/src/webworker/yamlServerMain.ts @@ -6,11 +6,11 @@ import * as l10n from '@vscode/l10n'; import type { Connection } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; -import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'; -import { TelemetryImpl } from '../languageserver/telemetry'; -import { schemaRequestHandler, workspaceContext } from '../languageservice/services/schemaRequestHandler'; -import { YAMLServerInit } from '../yamlServerInit'; -import { SettingsState } from '../yamlSettings'; +import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser.js'; +import { TelemetryImpl } from '../languageserver/telemetry.js'; +import { schemaRequestHandler, workspaceContext } from '../languageservice/services/schemaRequestHandler.js'; +import { YAMLServerInit } from '../yamlServerInit.js'; +import { SettingsState } from '../yamlSettings.js'; // eslint-disable-next-line @typescript-eslint/no-namespace namespace FSReadFile { diff --git a/src/yamlServerInit.ts b/src/yamlServerInit.ts index e4edc9181..a22a13b86 100644 --- a/src/yamlServerInit.ts +++ b/src/yamlServerInit.ts @@ -1,20 +1,20 @@ import type { Connection, InitializeParams, InitializeResult } from 'vscode-languageserver'; import { TextDocumentSyncKind } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; -import { YamlCommands } from './commands'; -import { commandExecutor } from './languageserver/commandExecutor'; -import { LanguageHandlers } from './languageserver/handlers/languageHandlers'; -import { NotificationHandlers } from './languageserver/handlers/notificationHandlers'; -import { RequestHandlers } from './languageserver/handlers/requestHandlers'; -import { SettingsHandler } from './languageserver/handlers/settingsHandlers'; -import { ValidationHandler } from './languageserver/handlers/validationHandlers'; -import { WorkspaceHandlers } from './languageserver/handlers/workspaceHandlers'; -import { registerCommands } from './languageservice/services/yamlCommands'; -import type { Telemetry } from './languageservice/telemetry'; -import { workspaceFoldersChanged } from './languageservice/utils/paths'; -import type { LanguageService, SchemaRequestService, WorkspaceContextService } from './languageservice/yamlLanguageService'; -import { getLanguageService as getCustomLanguageService } from './languageservice/yamlLanguageService'; -import type { SettingsState } from './yamlSettings'; +import { YamlCommands } from './commands.js'; +import { commandExecutor } from './languageserver/commandExecutor.js'; +import { LanguageHandlers } from './languageserver/handlers/languageHandlers.js'; +import { NotificationHandlers } from './languageserver/handlers/notificationHandlers.js'; +import { RequestHandlers } from './languageserver/handlers/requestHandlers.js'; +import { SettingsHandler } from './languageserver/handlers/settingsHandlers.js'; +import { ValidationHandler } from './languageserver/handlers/validationHandlers.js'; +import { WorkspaceHandlers } from './languageserver/handlers/workspaceHandlers.js'; +import { registerCommands } from './languageservice/services/yamlCommands.js'; +import type { Telemetry } from './languageservice/telemetry.js'; +import { workspaceFoldersChanged } from './languageservice/utils/paths.js'; +import type { LanguageService, SchemaRequestService, WorkspaceContextService } from './languageservice/yamlLanguageService.js'; +import { getLanguageService as getCustomLanguageService } from './languageservice/yamlLanguageService.js'; +import type { SettingsState } from './yamlSettings.js'; export class YAMLServerInit { languageService: LanguageService; diff --git a/src/yamlSettings.ts b/src/yamlSettings.ts index 01f2c46d0..707f5096d 100644 --- a/src/yamlSettings.ts +++ b/src/yamlSettings.ts @@ -1,12 +1,12 @@ import type { Disposable, ClientCapabilities, WorkspaceFolder } from 'vscode-languageserver'; import { TextDocuments } from 'vscode-languageserver'; -import type { CustomFormatterOptions, SchemaConfiguration } from './languageservice/yamlLanguageService'; -import type { ISchemaAssociations } from './requestTypes'; +import type { CustomFormatterOptions, SchemaConfiguration } from './languageservice/yamlLanguageService.js'; +import type { ISchemaAssociations } from './requestTypes.js'; import type { URI } from 'vscode-uri'; -import type { JSONSchema } from './languageservice/jsonSchema'; +import type { JSONSchema } from './languageservice/jsonSchema.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import { CRD_CATALOG_URL, JSON_SCHEMASTORE_URL } from './languageservice/utils/schemaUrls'; -import type { YamlVersion } from './languageservice/parser/yamlParser07'; +import { CRD_CATALOG_URL, JSON_SCHEMASTORE_URL } from './languageservice/utils/schemaUrls.js'; +import type { YamlVersion } from './languageservice/parser/yamlParser07.js'; // Client settings interface to grab settings relevant for the language server export interface Settings { diff --git a/test/arrUtils.test.ts b/test/arrUtils.test.ts index 9f926f966..c3be46dda 100644 --- a/test/arrUtils.test.ts +++ b/test/arrUtils.test.ts @@ -2,7 +2,9 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { getLineOffsets, removeDuplicatesObj } from '../src/languageservice/utils/arrUtils'; + +import { describe, it } from 'node:test'; +import { getLineOffsets, removeDuplicatesObj } from '../src/languageservice/utils/arrUtils.js'; import assert from 'assert'; describe('Array Utils Tests', () => { diff --git a/test/astUtils.test.ts b/test/astUtils.test.ts index 28859ed7d..b9399c5cb 100644 --- a/test/astUtils.test.ts +++ b/test/astUtils.test.ts @@ -3,13 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it, beforeEach } from 'node:test'; + import * as chai from 'chai'; import type { Pair, YAMLSeq } from 'yaml'; import { isPair, isSeq } from 'yaml'; -import { YamlDocuments } from '../src/languageservice/parser/yaml-documents'; -import { getParent, isInComment } from '../src/languageservice/utils/yamlAstUtils'; -import { TextBuffer } from '../src/languageservice/utils/textBuffer'; -import { setupTextDocument } from './utils/testHelper'; +import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; +import { getParent, isInComment } from '../src/languageservice/utils/yamlAstUtils.js'; +import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; +import { setupTextDocument } from './utils/testHelper.js'; const expect = chai.expect; describe('AST Utils Tests', () => { diff --git a/test/autoCompletion.test.ts b/test/autoCompletion.test.ts index f8ab0b2c4..f04121aeb 100644 --- a/test/autoCompletion.test.ts +++ b/test/autoCompletion.test.ts @@ -3,19 +3,27 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, toFsPath } from './utils/testHelper'; +import { describe, it, before, beforeEach, afterEach } from 'node:test'; + +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, toFsPath } from './utils/testHelper.js'; import assert from 'assert'; import * as path from 'path'; -import { createExpectedCompletion } from './utils/verifyError'; -import { ServiceSetup } from './utils/serviceSetup'; +import { createExpectedCompletion } from './utils/verifyError.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { CompletionList, MarkupContent } from 'vscode-languageserver-types'; import { CompletionItemKind, InsertTextFormat, MarkupKind, Position } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageService } from '../src'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageService } from '../src/index.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; + +import requiredPropertiesSchema from './fixtures/testRequiredProperties.json' with { type: 'json' }; +import arrayMaxPropertiesSchema from './fixtures/testArrayMaxProperties.json' with { type: 'json' }; +import stringArraySchema from './fixtures/testStringArray.json' with { type: 'json' }; +import arrayIndentSchema from './fixtures/testArrayIndent.json' with { type: 'json' }; +import arrayCompletionSchema from './fixtures/testArrayCompletionSchema.json' with { type: 'json' }; describe('Auto Completion Tests', () => { let languageSettingsSetup: ServiceSetup; @@ -695,9 +703,7 @@ describe('Auto Completion Tests', () => { }); it('Insert required attributes at correct level', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, requiredPropertiesSchema); const content = '- top:\n prop1: demo\n- '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 1); @@ -710,9 +716,7 @@ describe('Auto Completion Tests', () => { }); it('Insert required attributes at correct level even on first element', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, requiredPropertiesSchema); const content = '- '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 1); @@ -725,9 +729,7 @@ describe('Auto Completion Tests', () => { }); it('Provide the 3 types when none provided', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 3); @@ -752,9 +754,7 @@ describe('Auto Completion Tests', () => { }); it('Provide the 2 types when one is provided', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- prop1:\n '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -773,9 +773,7 @@ describe('Auto Completion Tests', () => { }); it('Provide the 2 types when one is provided and the second is typed', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- prop1:\n p'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -794,9 +792,7 @@ describe('Auto Completion Tests', () => { }); it('Provide no completion when maxProperties reached', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayMaxPropertiesSchema); const content = '- prop1:\n prop2:\n '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 0); @@ -932,9 +928,7 @@ describe('Auto Completion Tests', () => { describe('Array Specific Tests', function () { it('Should insert empty array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testStringArray.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, stringArraySchema); const content = 'fooBa'; // len: 5 const result = await parseSetup(content, content.lastIndexOf('Ba') + 2); // pos: 3+2 assert.strictEqual('fooBar:\n - ${1}', result.items[0].insertText); @@ -1547,7 +1541,7 @@ describe('Auto Completion Tests', () => { }); // For some reason, this gets inserted at the cursor (char 4) // It should be inserted at char 2 - xit('Next line const no :', async () => { + it.skip('Next line const no :', async () => { const content = 'test:\n - constProp\n '; const result = await parseSetup(content, content.length); expect(result.items.length).to.be.equal(1); @@ -1772,9 +1766,7 @@ describe('Auto Completion Tests', () => { describe('Indentation Specific Tests', function () { it('Indent should be considered with position relative to slash', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayIndentSchema); const content = 'install:\n - he'; // len: 15 const result = await parseSetup(content, content.lastIndexOf('he') + 2); // pos: 13+2 assert.equal(result.items.length, 2); @@ -1787,9 +1779,7 @@ describe('Auto Completion Tests', () => { }); it('Large indent should be considered with position relative to slash', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayIndentSchema); const content = 'install:\n - he'; // len: 25 const result = await parseSetup(content, content.lastIndexOf('he') + 2); // pos: 23+2 assert.equal(result.items.length, 2); @@ -1802,9 +1792,7 @@ describe('Auto Completion Tests', () => { }); it('Tab indent should be considered with position relative to slash', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayIndentSchema); const content = 'install:\n -\t he'; // len: 27 const result = await parseSetup(content, content.lastIndexOf('he') + 2); // pos: 25+2 assert.equal(result.items.length, 2); @@ -1818,7 +1806,7 @@ describe('Auto Completion Tests', () => { }); describe('Yaml schema defined in file', function () { - const uri = toFsPath(path.join(__dirname, './fixtures/testArrayMaxProperties.json')); + const uri = toFsPath(path.join(import.meta.dirname, './fixtures/testArrayMaxProperties.json')); it('Provide completion from schema declared in file', async () => { const content = `# yaml-language-server: $schema=${uri}\n- `; @@ -1850,7 +1838,7 @@ describe('Auto Completion Tests', () => { it('should handle absolute path', async () => { const documentContent = `# yaml-language-server: $schema=${path.join( - __dirname, + import.meta.dirname, './fixtures/testArrayMaxProperties.json' )} anothermodeline=value\n- `; // len: 142 const content = `${documentContent}|\n|---\n- `; // len: 149, pos: 142 @@ -1861,7 +1849,7 @@ describe('Auto Completion Tests', () => { it('should handle relative path', async () => { const documentContent = `# yaml-language-server: $schema=./fixtures/testArrayMaxProperties.json anothermodeline=value\n- `; // 95 const content = `${documentContent}\n---\n- `; - const testTextDocument = setupSchemaIDTextDocument(content, path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument(content, path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1874,7 +1862,7 @@ describe('Auto Completion Tests', () => { const inlineSchemaLabel = 'Inline schema'; it('should provide modeline completion on first character with no schema associated and no modeline yet', async () => { - const testTextDocument = setupSchemaIDTextDocument('', path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument('', path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1886,7 +1874,7 @@ describe('Auto Completion Tests', () => { }); it('should not provide modeline completion on first character when schema is associated', async () => { - const specificSchemaId = path.join(__dirname, 'test.yaml'); + const specificSchemaId = path.join(import.meta.dirname, 'test.yaml'); const testTextDocument = setupSchemaIDTextDocument('', specificSchemaId); schemaProvider.addSchema(specificSchemaId, { type: 'object', @@ -1907,7 +1895,7 @@ describe('Auto Completion Tests', () => { }); it('should not provide modeline completion on first character when modeline already present', async () => { - const testTextDocument = setupSchemaIDTextDocument('# yaml-language-server:', path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument('# yaml-language-server:', path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1919,7 +1907,7 @@ describe('Auto Completion Tests', () => { it('should provide schema id completion in modeline', async () => { const modeline = '# yaml-language-server: $schema='; - const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -1932,7 +1920,7 @@ describe('Auto Completion Tests', () => { it('should provide schema id completion in modeline for any line', async () => { const modeline = 'foo:\n bar\n# yaml-language-server: $schema='; - const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(__dirname, 'test.yaml')); + const testTextDocument = setupSchemaIDTextDocument(modeline, path.join(import.meta.dirname, 'test.yaml')); yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const result = await languageHandler.completionHandler({ @@ -2701,9 +2689,7 @@ describe('Auto Completion Tests', () => { describe('Array completion', () => { it('Simple array object completion with "-" without any item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -2712,9 +2698,7 @@ describe('Auto Completion Tests', () => { }); it('Simple array object completion without "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 1); @@ -2722,9 +2706,7 @@ describe('Auto Completion Tests', () => { }); it('Simple array object completion with "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 2); @@ -2733,9 +2715,7 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion with "- " without any item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - '; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 4); @@ -2746,9 +2726,7 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion with "-" without any item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 4); @@ -2757,9 +2735,7 @@ describe('Auto Completion Tests', () => { }); it('Simple array object completion without "-" befor array empty item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_simpleArrayObject:\n |\n| -'; // len: 30, pos: 26 const result = await parseSetup(content); assert.equal(result.items.length, 1); @@ -2767,27 +2743,21 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion without "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n '; const result = await parseSetup(content, content.length); expect(result.items.map((i) => i.label)).deep.eq(['- (array item) obj1', '- (array item) obj2']); }); it('Array nested anyOf without "-" should return all array items', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_nested_anyOf:\n - obj1:\n name:1\n '; const result = await parseSetup(content, content.length); expect(result.items.map((i) => i.label)).deep.eq(['- (array item) obj1', '- (array item) obj2', '- (array item) obj3']); }); it('Array anyOf two objects completion with "-" after array item', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n -'; const result = await parseSetup(content, content.length); assert.equal(result.items.length, 4); @@ -2796,9 +2766,7 @@ describe('Auto Completion Tests', () => { }); it('Array anyOf two objects completion indentation', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, arrayCompletionSchema); const content = 'test_array_anyOf_2objects:\n - obj'; const completion = await parseSetup(content, content.length); expect(completion.items.length).is.equal(4); diff --git a/test/autoCompletionFix.test.ts b/test/autoCompletionFix.test.ts index fd3a821cd..a5832df69 100644 --- a/test/autoCompletionFix.test.ts +++ b/test/autoCompletionFix.test.ts @@ -3,19 +3,23 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it, before, beforeEach, afterEach } from 'node:test'; + import type { CompletionList } from 'vscode-languageserver-types'; import { CompletionItemKind, InsertTextFormat, Position, Range } from 'vscode-languageserver-types'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import { expect } from 'chai'; -import { createExpectedCompletion } from './utils/verifyError'; -import * as path from 'path'; -import type { JSONSchema } from './../src/languageservice/jsonSchema'; +import { createExpectedCompletion } from './utils/verifyError.js'; +import type { JSONSchema } from './../src/languageservice/jsonSchema.js'; + +import nestedObjectArraySchema from './fixtures/test-nested-object-array.json' with { type: 'json' }; +import completionOneOfSchema from './fixtures/test-completion-oneOf.json' with { type: 'json' }; describe('Auto Completion Fix Tests', () => { let languageSettingsSetup: ServiceSetup; @@ -196,9 +200,7 @@ spec: }); it('should complete array', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/test-nested-object-array.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, nestedObjectArraySchema as JSONSchema); const content = `objA: - name: nameA1 @@ -211,9 +213,7 @@ objB: }); it('should complete array item for "oneOf" schema', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/test-completion-oneOf.json')); - schemaProvider.addSchema(SCHEMA_ID, schema); + schemaProvider.addSchema(SCHEMA_ID, completionOneOfSchema); const content = `metadata: Selector: query: diff --git a/test/bundlel10n.test.ts b/test/bundlel10n.test.ts index 4506c1641..a92872dce 100644 --- a/test/bundlel10n.test.ts +++ b/test/bundlel10n.test.ts @@ -2,17 +2,19 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before, after } from 'node:test'; import * as l10n from '@vscode/l10n'; import assert from 'assert'; import * as path from 'path'; -import type { Connection } from 'vscode-languageserver/node'; -import { createConnection } from 'vscode-languageserver/node'; -import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler'; -import { setupl10nBundle } from '../src/nodeTranslationSetup'; -import { YAMLServerInit } from '../src/yamlServerInit'; -import { SettingsState } from '../src/yamlSettings'; -import { TestCustomSchemaProvider, testFileSystem } from './utils/testHelper'; -import { TestTelemetry } from './utils/testsTypes'; +import type { Connection } from 'vscode-languageserver/node.js'; +import { createConnection } from 'vscode-languageserver/node.js'; +import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler.js'; +import { setupl10nBundle } from '../src/nodeTranslationSetup.js'; +import { YAMLServerInit } from '../src/yamlServerInit.js'; +import { SettingsState } from '../src/yamlSettings.js'; +import { TestCustomSchemaProvider, testFileSystem } from './utils/testHelper.js'; +import { TestTelemetry } from './utils/testsTypes.js'; describe('Bundle l10n Test', () => { let serverInit: YAMLServerInit; @@ -49,7 +51,7 @@ describe('Bundle l10n Test', () => { rootUri: '', capabilities: undefined, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, }); }); @@ -62,7 +64,7 @@ describe('Bundle l10n Test', () => { rootUri: '', capabilities: undefined, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, }); assert.equal(l10n.t('Default value'), 'Valeur par défaut'); @@ -75,7 +77,7 @@ describe('Bundle l10n Test', () => { rootUri: '', capabilities: undefined, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, }); assert.equal(l10n.t('Default value'), 'Default value'); diff --git a/test/code-action-schema.test.ts b/test/code-action-schema.test.ts index c440ee055..c10faca5f 100644 --- a/test/code-action-schema.test.ts +++ b/test/code-action-schema.test.ts @@ -2,16 +2,18 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, TEST_URI } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, TEST_URI } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { CodeActionParams } from 'vscode-languageserver'; import { TextDocumentIdentifier, CodeActionContext, TextEdit, Range } from 'vscode-languageserver'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; describe('Schema Errors Code Action Tests', () => { diff --git a/test/customTags.test.ts b/test/customTags.test.ts index fe4f70aaf..947716103 100644 --- a/test/customTags.test.ts +++ b/test/customTags.test.ts @@ -2,13 +2,15 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; -import { createExpectedError } from './utils/verifyError'; + +import { describe, it, before } from 'node:test'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import { createExpectedError } from './utils/verifyError.js'; import assert from 'assert'; import type { Diagnostic } from 'vscode-languageserver-types'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; // Defines a Mocha test describe to group tests of similar kind together describe('Custom Tag tests Tests', () => { diff --git a/test/defaultSnippets.test.ts b/test/defaultSnippets.test.ts index 610c85303..195046bc0 100644 --- a/test/defaultSnippets.test.ts +++ b/test/defaultSnippets.test.ts @@ -2,13 +2,15 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { toFsPath, setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper'; + +import { describe, it, before } from 'node:test'; +import { toFsPath, setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper.js'; import assert from 'assert'; import * as path from 'path'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { CompletionList, TextEdit } from 'vscode-languageserver-types'; import { expect } from 'chai'; @@ -17,7 +19,7 @@ describe('Default Snippet Tests', () => { let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(__dirname, './fixtures/defaultSnippets.json')); + const uri = toFsPath(path.join(import.meta.dirname, './fixtures/defaultSnippets.json')); const fileMatch = ['*.yml', '*.yaml']; const languageSettingsSetup = new ServiceSetup().withCompletion().withSchemaFileMatch({ fileMatch, diff --git a/test/diagnostic-filter.test.ts b/test/diagnostic-filter.test.ts index 395385ac7..f9fee8f5a 100644 --- a/test/diagnostic-filter.test.ts +++ b/test/diagnostic-filter.test.ts @@ -3,14 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it } from 'node:test'; + import { expect } from 'chai'; -import type { GetLineText } from '../src/languageservice/utils/diagnostic-filter'; +import type { GetLineText } from '../src/languageservice/utils/diagnostic-filter.js'; import { filterSuppressedDiagnostics, YAML_DISABLE_PATTERN, parseDisableSpecifiers, shouldSuppressDiagnostic, -} from '../src/languageservice/utils/diagnostic-filter'; +} from '../src/languageservice/utils/diagnostic-filter.js'; function makeDiag(startLine: number, message: string): { startLine: number; message: string } { return { startLine, message }; diff --git a/test/documentSymbols.test.ts b/test/documentSymbols.test.ts index a6ce3bb16..7e3d2aa3b 100644 --- a/test/documentSymbols.test.ts +++ b/test/documentSymbols.test.ts @@ -2,19 +2,21 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper'; + +import { describe, it, before, afterEach } from 'node:test'; +import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper.js'; import { createExpectedSymbolInformation, createExpectedDocumentSymbol, createExpectedDocumentSymbolNoDetail, -} from './utils/verifyError'; +} from './utils/verifyError.js'; import type { DocumentSymbol, SymbolInformation } from 'vscode-languageserver-types'; import { SymbolKind } from 'vscode-languageserver-types'; import assert from 'assert'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; describe('Document Symbols Tests', () => { let languageHandler: LanguageHandlers; diff --git a/test/findLinks.test.ts b/test/findLinks.test.ts index 4f6651f54..df44e203b 100644 --- a/test/findLinks.test.ts +++ b/test/findLinks.test.ts @@ -2,13 +2,15 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; + +import { describe, it, before } from 'node:test'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; import assert from 'assert'; -import { ServiceSetup } from './utils/serviceSetup'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { DocumentLink } from 'vscode-languageserver-types'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; describe('Find Links Tests', () => { let languageHandler: LanguageHandlers; diff --git a/test/flow-style-rewriter.test.ts b/test/flow-style-rewriter.test.ts index 7cc773755..8738e0756 100644 --- a/test/flow-style-rewriter.test.ts +++ b/test/flow-style-rewriter.test.ts @@ -1,7 +1,8 @@ +import { describe, it, beforeEach } from 'node:test'; import { expect } from 'chai'; -import { YamlDocuments } from '../src/languageservice/parser/yaml-documents'; -import { FlowStyleRewriter } from '../src/languageservice/utils/flow-style-rewriter'; -import { setupTextDocument } from './utils/testHelper'; +import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; +import { FlowStyleRewriter } from '../src/languageservice/utils/flow-style-rewriter.js'; +import { setupTextDocument } from './utils/testHelper.js'; describe('Flow style rewriter', () => { let writer: FlowStyleRewriter; diff --git a/test/formatter.test.ts b/test/formatter.test.ts index e3bb67f4c..f6eb446ff 100644 --- a/test/formatter.test.ts +++ b/test/formatter.test.ts @@ -2,16 +2,18 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before, afterEach } from 'node:test'; import assert from 'assert'; -import * as sinon from 'sinon'; +import { createSandbox } from 'sinon'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { FormattingOptions, TextEdit } from 'vscode-languageserver-types'; -import type { CustomFormatterOptions } from '../src'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import { ServiceSetup } from './utils/serviceSetup'; -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; +import type { CustomFormatterOptions } from '../src/index.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; type LanguageHandlerWithConnection = { connection: { @@ -24,7 +26,7 @@ type LanguageHandlerWithConnection = { }; describe('Formatter Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); let languageHandler: LanguageHandlers; let yamlSettings: SettingsState; diff --git a/test/hover.test.ts b/test/hover.test.ts index 8fa16f855..e00b61450 100644 --- a/test/hover.test.ts +++ b/test/hover.test.ts @@ -2,17 +2,19 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ServiceSetup } from './utils/serviceSetup'; -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; + +import { describe, it, before, afterEach } from 'node:test'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { caretPosition, SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import assert from 'assert'; import type { Hover } from 'vscode-languageserver-types'; import { MarkupContent, Position } from 'vscode-languageserver-types'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; import { expect } from 'chai'; -import type { TestTelemetry } from './utils/testsTypes'; +import type { TestTelemetry } from './utils/testsTypes.js'; describe('Hover Tests', () => { let languageSettingsSetup: ServiceSetup; diff --git a/test/integration.test.ts b/test/integration.test.ts index ab8f52d1c..94c9944e9 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -2,15 +2,17 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupLanguageService, setupTextDocument } from './utils/testHelper'; + +import { describe, it, before } from 'node:test'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; import assert from 'assert'; import type { Diagnostic, CompletionList, Hover } from 'vscode-languageserver-types'; import { MarkupContent } from 'vscode-languageserver-types'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; // Defines a Mocha test describe to group tests of similar kind together describe('Kubernetes Integration Tests', () => { diff --git a/test/invalid-metaschema.test.ts b/test/invalid-metaschema.test.ts index e584ea9cf..25d3a9216 100644 --- a/test/invalid-metaschema.test.ts +++ b/test/invalid-metaschema.test.ts @@ -2,19 +2,22 @@ * Copyright (c) IBM Corp. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, beforeEach, afterEach } from 'node:test'; import { assert } from 'chai'; -import * as sinon from 'sinon'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node'; -import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; -import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; -import { setupSchemaIDTextDocument } from './utils/testHelper'; +import type { SinonSpy } from 'sinon'; +import { createSandbox } from 'sinon'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; +import { setupSchemaIDTextDocument } from './utils/testHelper.js'; describe('unexpected meta schema', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: sinon.SinonSpy; + let requestServiceMock: SinonSpy; beforeEach(() => { requestServiceMock = sandbox.fake.resolves('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }'); diff --git a/test/multipleDocuments.test.ts b/test/multipleDocuments.test.ts index 4af4ae814..3476975f9 100644 --- a/test/multipleDocuments.test.ts +++ b/test/multipleDocuments.test.ts @@ -2,17 +2,19 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before } from 'node:test'; import * as path from 'path'; -import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper'; +import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper.js'; import assert from 'assert'; -import { ServiceSetup } from './utils/serviceSetup'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic, Hover } from 'vscode-languageserver-types'; import { MarkupContent } from 'vscode-languageserver-types'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; /** * Setup the schema we are going to use with the language settings @@ -27,7 +29,7 @@ describe('Multiple Documents Validation Tests', () => { let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(__dirname, './fixtures/customMultipleSchemaSequences.json')); + const uri = toFsPath(path.join(import.meta.dirname, './fixtures/customMultipleSchemaSequences.json')); const fileMatch = ['*.yml', '*.yaml']; languageSettingsSetup = new ServiceSetup() .withHover() diff --git a/test/objects.test.ts b/test/objects.test.ts index 121ebe87a..05be3de81 100644 --- a/test/objects.test.ts +++ b/test/objects.test.ts @@ -2,7 +2,9 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { equals, convertErrorToTelemetryMsg } from '../src/languageservice/utils/objects'; + +import { describe, it } from 'node:test'; +import { equals, convertErrorToTelemetryMsg } from '../src/languageservice/utils/objects.js'; import assert from 'assert'; describe('Object Equals Tests', () => { diff --git a/test/paths.test.ts b/test/paths.test.ts index 440274f7a..334892566 100644 --- a/test/paths.test.ts +++ b/test/paths.test.ts @@ -1,8 +1,9 @@ +import { describe, it } from 'node:test'; import assert from 'assert'; import type { WorkspaceFolder } from 'vscode-languageserver-protocol'; import { join } from 'path'; -import { relativeToAbsolutePath, isRelativePath, workspaceFoldersChanged } from '../src/languageservice/utils/paths'; +import { relativeToAbsolutePath, isRelativePath, workspaceFoldersChanged } from '../src/languageservice/utils/paths.js'; import { URI } from 'vscode-uri'; class TestWorkspace { @@ -224,33 +225,33 @@ describe('File path tests', () => { describe('Path with mixed delimiters (Windows only)', () => { const path = 'some/strange\\but/functional\\path\\file.json'; - it('Recognises relative path "' + path + '"', function () { + it('Recognises relative path "' + path + '"', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert(isRelativePath(path)); } }); - it('Resolves "' + path + '" in single-root workspace', function () { + it('Resolves "' + path + '" in single-root workspace', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert.equal(ws1.resolve(path), 'file:///home/aFolder/some/strange/but/functional/path/file.json'); } }); - it('Resolves "' + path + '" in multi-root workspace', function () { + it('Resolves "' + path + '" in multi-root workspace', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert.equal(ws2.resolve(path), 'file:///usr/testuser/projects/workspace/some/strange/but/functional/path/file.json'); } }); - it('Resolves "' + path + '" in multi-root nested workspace', function () { + it('Resolves "' + path + '" in multi-root nested workspace', function (t) { if (process.platform !== 'win32') { - this.skip(); + t.skip(); } else { assert.equal(ws3.resolve(path), 'file:///c%3A/Users/testuser/dev/potatoes/some/strange/but/functional/path/file.json'); } diff --git a/test/schema.test.ts b/test/schema.test.ts index e9ca25cd7..03d0de987 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -1,25 +1,31 @@ +import { describe, it, before, beforeEach, afterEach } from 'node:test'; import assert from 'assert'; -import * as parser from '../src/languageservice/parser/yamlParser07'; -import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import type * as JsonSchema from '../src/languageservice/jsonSchema'; +import * as parser from '../src/languageservice/parser/yamlParser07.js'; +import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; +import type * as JsonSchema from '../src/languageservice/jsonSchema.js'; import * as path from 'path'; -import { xhr } from 'request-light'; -import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService'; -import { MODIFICATION_ACTIONS } from '../src/languageservice/services/yamlSchemaService'; -import { EMPTY_SCHEMA_URL, DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; +import requestLight from 'request-light'; +import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService.js'; +import { MODIFICATION_ACTIONS } from '../src/languageservice/services/yamlSchemaService.js'; +import { EMPTY_SCHEMA_URL, DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; import { expect } from 'chai'; -import { ServiceSetup } from './utils/serviceSetup'; -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, setupTextDocument, TEST_URI } from './utils/testHelper'; -import type { LanguageService } from '../src'; -import { SchemaPriority } from '../src'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, setupTextDocument, TEST_URI } from './utils/testHelper.js'; +import type { LanguageService } from '../src/index.js'; +import { SchemaPriority } from '../src/index.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { Diagnostic, MarkupContent } from 'vscode-languageserver-types'; import { Position } from 'vscode-languageserver-types'; -import { getSchemaFromModeline } from '../src/languageservice/services/modelineUtil'; -import { getGroupVersionKindFromDocument } from '../src/languageservice/services/k8sSchemaUtil'; +import { getSchemaFromModeline } from '../src/languageservice/services/modelineUtil.js'; +import { getGroupVersionKindFromDocument } from '../src/languageservice/services/k8sSchemaUtil.js'; + +import schemaAssociationSample from './fixtures/sample-association.json' with { type: 'json' }; +import schemaStoreSample from './fixtures/sample-schemastore.json' with { type: 'json' }; +import schemaSettingsSample from './fixtures/sample-settings.json' with { type: 'json' }; +import schemaDefaultSnippetSample from './fixtures/defaultSnippets-const-if-else.json' with { type: 'json' }; const KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/all.json`; @@ -36,7 +42,7 @@ const workspaceContext = { const schemaRequestServiceForURL = async (uri: string): Promise => { const headers = { 'Accept-Encoding': 'gzip, deflate' }; try { - const response = await xhr({ url: uri, followRedirects: 5, headers }); + const response = await requestLight.xhr({ url: uri, followRedirects: 5, headers }); return response.responseText; } catch (error) { throw error.responseText || error.toString(); @@ -853,16 +859,9 @@ address: }); describe('Test schema priority', function () { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaAssociationSample = require(path.join(__dirname, './fixtures/sample-association.json')); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaStoreSample = require(path.join(__dirname, './fixtures/sample-schemastore.json')); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaSettingsSample = require(path.join(__dirname, './fixtures/sample-settings.json')); - const schemaModelineSample = path.join(__dirname, './fixtures/sample-modeline.json'); - const schemaDollarSample = path.join(__dirname, './fixtures/sample-dollar-schema.json'); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schemaDefaultSnippetSample = require(path.join(__dirname, './fixtures/defaultSnippets-const-if-else.json')); + const schemaModelineSample = path.join(import.meta.dirname, './fixtures/sample-modeline.json'); + const schemaDollarSample = path.join(import.meta.dirname, './fixtures/sample-dollar-schema.json'); + let languageSettingsSetup: ServiceSetup; beforeEach(() => { diff --git a/test/schema2019Validation.test.ts b/test/schema2019Validation.test.ts index 3ef1105a5..2bf767d80 100644 --- a/test/schema2019Validation.test.ts +++ b/test/schema2019Validation.test.ts @@ -2,16 +2,18 @@ * Copyright (c) IBM Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, beforeEach, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; describe('Validation Tests', () => { let languageSettingsSetup: ServiceSetup; diff --git a/test/schema2020Validation.test.ts b/test/schema2020Validation.test.ts index d49060272..48363067e 100644 --- a/test/schema2020Validation.test.ts +++ b/test/schema2020Validation.test.ts @@ -2,16 +2,18 @@ * Copyright (c) IBM Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, beforeEach, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; describe('Validation Tests', () => { let languageSettingsSetup: ServiceSetup; diff --git a/test/schemaRequestHandler.test.ts b/test/schemaRequestHandler.test.ts index 90a51484a..9d1936226 100644 --- a/test/schemaRequestHandler.test.ts +++ b/test/schemaRequestHandler.test.ts @@ -3,10 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler'; -import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler'; -import * as sinon from 'sinon'; -import * as request from 'request-light'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import { schemaRequestHandler } from '../src/languageservice/services/schemaRequestHandler.js'; +import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler.js'; +import type { SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; +import request from 'request-light'; import type { XHRResponse } from 'request-light'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; @@ -15,7 +18,7 @@ import sinonChai from 'sinon-chai'; const expect = chai.expect; chai.use(sinonChai); -import { testFileSystem } from './utils/testHelper'; +import { testFileSystem } from './utils/testHelper.js'; describe('Schema Request Handler Tests', () => { describe('workspaceContext', () => { @@ -66,8 +69,8 @@ describe('Schema Request Handler Tests', () => { }); describe('schemaRequestHandler', () => { - const sandbox = sinon.createSandbox(); - let readFileStub: sinon.SinonStub; + const sandbox = createSandbox(); + let readFileStub: SinonStub; beforeEach(() => { readFileStub = sandbox.stub(testFileSystem, 'readFile'); @@ -118,8 +121,8 @@ describe('Schema Request Handler Tests', () => { }); describe('HTTP(S) schema requests', () => { - const sandbox = sinon.createSandbox(); - let xhrStub: sinon.SinonStub; + const sandbox = createSandbox(); + let xhrStub: SinonStub; const connection = {} as Connection; beforeEach(() => { @@ -199,8 +202,8 @@ describe('Schema Request Handler Tests', () => { }); describe('HTTP(S) schema request retries', () => { - const sandbox = sinon.createSandbox(); - let xhrStub: sinon.SinonStub; + const sandbox = createSandbox(); + let xhrStub: SinonStub; let delays: number[]; const connection = {} as Connection; diff --git a/test/schemaSelectionHandlers.test.ts b/test/schemaSelectionHandlers.test.ts index c84c7e95f..757275b08 100644 --- a/test/schemaSelectionHandlers.test.ts +++ b/test/schemaSelectionHandlers.test.ts @@ -2,24 +2,27 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import type { SinonSpy } from 'sinon'; +import { createSandbox } from 'sinon'; import * as chai from 'chai'; import sinonChai from 'sinon-chai'; -import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node'; -import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; -import { SchemaSelectionRequests } from '../src/requestTypes'; -import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper'; +import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; +import { SchemaSelectionRequests } from '../src/requestTypes.js'; +import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper.js'; const expect = chai.expect; chai.use(sinonChai); describe('Schema Selection Handlers', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: sinon.SinonSpy; + let requestServiceMock: SinonSpy; beforeEach(() => { requestServiceMock = sandbox.fake.resolves(undefined); diff --git a/test/schemaValidation.test.ts b/test/schemaValidation.test.ts index d38e367e0..b540d3008 100644 --- a/test/schemaValidation.test.ts +++ b/test/schemaValidation.test.ts @@ -2,10 +2,12 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { TestCustomSchemaProvider } from './utils/testHelper'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; -import { createDiagnosticWithData, createExpectedError } from './utils/verifyError'; -import { ServiceSetup } from './utils/serviceSetup'; + +import { describe, it, before, after, afterEach } from 'node:test'; +import type { TestCustomSchemaProvider } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { createDiagnosticWithData, createExpectedError } from './utils/verifyError.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; import { StringTypeError, BooleanTypeError, @@ -16,21 +18,22 @@ import { DuplicateKeyError, propertyIsNotAllowed, MissingRequiredPropWarning, -} from './utils/errorMessages'; +} from './utils/errorMessages.js'; import assert from 'assert'; -import * as path from 'path'; import type { Diagnostic } from 'vscode-languageserver-types'; import { DiagnosticSeverity, Position } from 'vscode-languageserver-types'; import { expect } from 'chai'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import type { IProblem } from '../src/languageservice/parser/schemaValidation/baseValidator'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; -import type { TestTelemetry } from './utils/testsTypes'; -import { ErrorCode } from '../src/languageservice/jsonLanguageTypes'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import type { IProblem } from '../src/languageservice/parser/schemaValidation/baseValidator.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; +import type { TestTelemetry } from './utils/testsTypes.js'; +import { ErrorCode } from '../src/languageservice/jsonLanguageTypes.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION } from '../src/languageservice/utils/schemaUrls.js'; + +import multipleSimilarSchemas from './fixtures/testMultipleSimilarSchema.json' with { type: 'json' }; const KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/all.json`; @@ -1769,10 +1772,8 @@ spec: schemaProvider.deleteSchema(sharedSchemaId); }); it('should distinguish types in error "Incorrect type (Expected "type1 | type2 | type3")"', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n '; const result = await parseSetup(content); @@ -1785,11 +1786,8 @@ spec: ]); }); it('should combine types in "Incorrect type error"', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - - schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n propA:'; const result = await parseSetup(content); @@ -1798,11 +1796,8 @@ spec: assert.strictEqual(result[2].source, 'yaml-schema: file:///sharedSchema.json | file:///default_schema_id.yaml'); }); it('should combine const value', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - - schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n constA:'; const result = await parseSetup(content); @@ -1811,11 +1806,8 @@ spec: assert.strictEqual(result[3].source, 'yaml-schema: file:///sharedSchema.json | file:///default_schema_id.yaml'); }); it('should distinguish types in error: "Missing property from multiple schemas"', async () => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json')); - - schemaProvider.addSchemaWithUri(sharedSchemaId, 'file:///sharedSchema.json', schema.sharedSchema); - schemaProvider.addSchema(SCHEMA_ID, schema.schema); + schemaProvider.addSchemaWithUri(sharedSchemaId, 'file:///sharedSchema.json', multipleSimilarSchemas.sharedSchema); + schemaProvider.addSchema(SCHEMA_ID, multipleSimilarSchemas.schema); const content = 'test_anyOf_objects:\n someProp:'; const result = await parseSetup(content); diff --git a/test/settingsHandlers.test.ts b/test/settingsHandlers.test.ts index fb74bea38..54e624dd9 100644 --- a/test/settingsHandlers.test.ts +++ b/test/settingsHandlers.test.ts @@ -3,34 +3,42 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it, beforeEach, afterEach } from 'node:test'; + import * as chai from 'chai'; -import * as request from 'request-light'; -import * as sinon from 'sinon'; +import request from 'request-light'; +import type { SinonMock, SinonStub, SinonStubbedInstance } from 'sinon'; +import { createSandbox, spy, stub } from 'sinon'; import sinonChai from 'sinon-chai'; import type { Connection, RemoteClient, RemoteWorkspace } from 'vscode-languageserver'; import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; -import type { LanguageService, LanguageSettings, SchemaConfiguration } from '../src'; -import { SchemaPriority } from '../src'; -import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers'; -import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import { EMPTY_SCHEMA_URL } from '../src/languageservice/utils/schemaUrls'; -import type { Telemetry } from '../src/languageservice/telemetry'; -import { SettingsState } from '../src/yamlSettings'; -import { TestCustomSchemaProvider, setupLanguageService, setupSchemaIDTextDocument, setupTextDocument } from './utils/testHelper'; -import { TestWorkspace } from './utils/testsTypes'; +import type { LanguageService, LanguageSettings, SchemaConfiguration } from '../src/index.js'; +import { SchemaPriority } from '../src/index.js'; +import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers.js'; +import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import { EMPTY_SCHEMA_URL } from '../src/languageservice/utils/schemaUrls.js'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; +import { SettingsState } from '../src/yamlSettings.js'; +import { + TestCustomSchemaProvider, + setupLanguageService, + setupSchemaIDTextDocument, + setupTextDocument, +} from './utils/testHelper.js'; +import { TestWorkspace } from './utils/testsTypes.js'; const expect = chai.expect; chai.use(sinonChai); describe('Settings Handlers Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); const connection: Connection = {} as Connection; - let workspaceStub: sinon.SinonStubbedInstance; + let workspaceStub: SinonStubbedInstance; let languageService: LanguageService; let settingsState: SettingsState; - let validationHandler: sinon.SinonMock; - let xhrStub: sinon.SinonStub; + let validationHandler: SinonMock; + let xhrStub: SinonStub; beforeEach(() => { workspaceStub = sandbox.createStubInstance(TestWorkspace); @@ -266,7 +274,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings).deep.include({ @@ -300,7 +308,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); @@ -338,7 +346,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings.some((schema) => schema.uri === 'https://example.com/config.schema.json')).to.be @@ -363,7 +371,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings).deep.include({ @@ -401,7 +409,7 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = sinon.stub(languageService, 'configure'); + const configureSpy = stub(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); expect(settingsState.schemaStoreSettings).deep.include({ @@ -418,7 +426,7 @@ describe('Settings Handlers Tests', () => { const testSchemaFileMatch = ['foo/*.yml']; async function configureSchemaSettingsTest(): Promise { - const telemetry = { send: sinon.stub(), sendError: sinon.stub() } as unknown as Telemetry; + const telemetry = { send: stub(), sendError: stub() } as unknown as Telemetry; const settingsHandler = new SettingsHandler( connection, languageService, @@ -426,7 +434,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, telemetry ); - const configureSpy = sinon.spy(languageService, 'configure'); + const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); return configureSpy.args[0][0]; @@ -547,7 +555,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - const configureSpy = sinon.spy(languageService, 'configure'); + const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); configureSpy.restore(); return configureSpy.args[0][0]; @@ -811,7 +819,7 @@ describe('Settings Handlers Tests', () => { workspaceStub.getConfiguration.resolves([{ schemaStore: { enable: false, url: 'http://shouldnot.activate' } }, {}, {}, {}]); - // const configureSpy = sinon.spy(languageService, 'configure'); + // const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); // configureSpy.restore(); expect(settingsState.schemaStoreEnabled).to.be.false; diff --git a/test/strings.test.ts b/test/strings.test.ts index fc5be71b4..09df40837 100644 --- a/test/strings.test.ts +++ b/test/strings.test.ts @@ -2,7 +2,9 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { startsWith, endsWith, convertSimple2RegExp, safeCreateUnicodeRegExp } from '../src/languageservice/utils/strings'; + +import { describe, it } from 'node:test'; +import { startsWith, endsWith, convertSimple2RegExp, safeCreateUnicodeRegExp } from '../src/languageservice/utils/strings.js'; import assert from 'assert'; import { expect } from 'chai'; diff --git a/test/telemetry.test.ts b/test/telemetry.test.ts index 879f59075..87e78f87b 100644 --- a/test/telemetry.test.ts +++ b/test/telemetry.test.ts @@ -2,11 +2,14 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import type { SinonStubbedInstance } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { checkSchemaURI } from '../src/languageservice/utils/schemaUrls'; -import { TelemetryImpl } from '../src/languageserver/telemetry'; +import { checkSchemaURI } from '../src/languageservice/utils/schemaUrls.js'; +import { TelemetryImpl } from '../src/languageserver/telemetry.js'; import { URI } from 'vscode-uri'; import type { Connection } from 'vscode-languageserver'; @@ -14,9 +17,9 @@ const expect = chai.expect; chai.use(sinonChai); describe('Telemetry Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); - let telemetry: sinon.SinonStubbedInstance; + let telemetry: SinonStubbedInstance; beforeEach(() => { const telemetryInstance = new TelemetryImpl({} as Connection); telemetry = sandbox.stub(telemetryInstance); diff --git a/test/textBuffer.test.ts b/test/textBuffer.test.ts index 385644484..b3de5af1b 100644 --- a/test/textBuffer.test.ts +++ b/test/textBuffer.test.ts @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TextBuffer } from '../src/languageservice/utils/textBuffer'; +import { describe, it } from 'node:test'; + +import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; import assert from 'assert'; diff --git a/test/utils/serviceSetup.ts b/test/utils/serviceSetup.ts index ac8333c8a..a163861c4 100644 --- a/test/utils/serviceSetup.ts +++ b/test/utils/serviceSetup.ts @@ -2,8 +2,8 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { LanguageSettings, SchemasSettings } from '../../src/languageservice/yamlLanguageService'; -import type { YamlVersion } from '../../src/languageservice/parser/yamlParser07'; +import type { LanguageSettings, SchemasSettings } from '../../src/languageservice/yamlLanguageService.js'; +import type { YamlVersion } from '../../src/languageservice/parser/yamlParser07.js'; export class ServiceSetup { /* diff --git a/test/utils/testHelper.ts b/test/utils/testHelper.ts index b74492441..e97e7a326 100644 --- a/test/utils/testHelper.ts +++ b/test/utils/testHelper.ts @@ -2,21 +2,22 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + import { promises as fs } from 'fs'; -import { ClientCapabilities } from '../../src/languageservice/jsonLanguageTypes'; +import { ClientCapabilities } from '../../src/languageservice/jsonLanguageTypes.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node'; -import { createConnection } from 'vscode-languageserver/node'; -import type { LanguageService, LanguageSettings } from '../../src'; -import type { LanguageHandlers } from '../../src/languageserver/handlers/languageHandlers'; -import type { ValidationHandler } from '../../src/languageserver/handlers/validationHandlers'; -import type { JSONSchema } from '../../src/languageservice/jsonSchema'; -import { yamlDocumentsCache } from '../../src/languageservice/parser/yaml-documents'; -import type { FileSystem } from '../../src/languageservice/services/schemaRequestHandler'; -import { schemaRequestHandler, workspaceContext } from '../../src/languageservice/services/schemaRequestHandler'; -import { YAMLServerInit } from '../../src/yamlServerInit'; -import { SettingsState } from '../../src/yamlSettings'; -import { TestTelemetry } from './testsTypes'; +import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node.js'; +import { createConnection } from 'vscode-languageserver/node.js'; +import type { LanguageService, LanguageSettings } from '../../src/index.js'; +import type { LanguageHandlers } from '../../src/languageserver/handlers/languageHandlers.js'; +import type { ValidationHandler } from '../../src/languageserver/handlers/validationHandlers.js'; +import type { JSONSchema } from '../../src/languageservice/jsonSchema.js'; +import { yamlDocumentsCache } from '../../src/languageservice/parser/yaml-documents.js'; +import type { FileSystem } from '../../src/languageservice/services/schemaRequestHandler.js'; +import { schemaRequestHandler, workspaceContext } from '../../src/languageservice/services/schemaRequestHandler.js'; +import { YAMLServerInit } from '../../src/yamlServerInit.js'; +import { SettingsState } from '../../src/yamlSettings.js'; +import { TestTelemetry } from './testsTypes.js'; import * as path from 'path'; export function toFsPath(str: unknown): string { @@ -85,14 +86,13 @@ export function setupLanguageService(languageSettings: LanguageSettings): TestLa const schemaRequestService = schemaRequestHandlerWrapper.bind(this, connection); const telemetry = new TestTelemetry(connection); const serverInit = new YAMLServerInit(connection, yamlSettings, workspaceContext, schemaRequestService, telemetry); - const __dirname = path.resolve(path.dirname(__filename), '..'); serverInit.connectionInitialized({ processId: null, capabilities: ClientCapabilities.LATEST as LSPClientCapabilities, rootUri: null, workspaceFolders: null, initializationOptions: { - l10nPath: path.join(__dirname, '../l10n'), + l10nPath: path.join(process.cwd(), 'l10n'), }, locale: 'en', }); diff --git a/test/utils/testsTypes.ts b/test/utils/testsTypes.ts index b580f9a45..cf874775a 100644 --- a/test/utils/testsTypes.ts +++ b/test/utils/testsTypes.ts @@ -18,8 +18,8 @@ import type { ServerCapabilities, } from 'vscode-languageserver-protocol'; import type { Connection, RemoteWorkspace } from 'vscode-languageserver'; -import { TelemetryImpl } from '../../src/languageserver/telemetry'; -import type { TelemetryEvent } from '../../src/languageservice/telemetry'; +import { TelemetryImpl } from '../../src/languageserver/telemetry.js'; +import type { TelemetryEvent } from '../../src/languageservice/telemetry.js'; /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ diff --git a/test/utils/verifyError.ts b/test/utils/verifyError.ts index ef0f10cb9..ee54f2732 100644 --- a/test/utils/verifyError.ts +++ b/test/utils/verifyError.ts @@ -11,7 +11,7 @@ import type { SymbolInformation, } from 'vscode-languageserver-types'; import { Diagnostic, DiagnosticSeverity, DiagnosticTag, DocumentSymbol, Range } from 'vscode-languageserver-types'; -import { ErrorCode } from '../../src/languageservice/jsonLanguageTypes'; +import { ErrorCode } from '../../src/languageservice/jsonLanguageTypes.js'; export function createExpectedError( message: string, diff --git a/test/yaml-documents.test.ts b/test/yaml-documents.test.ts index 2c3a80c9a..9688f4028 100644 --- a/test/yaml-documents.test.ts +++ b/test/yaml-documents.test.ts @@ -3,26 +3,29 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import type { SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { YamlDocuments } from '../src/languageservice/parser/yaml-documents'; -import { setupTextDocument } from './utils/testHelper'; -import * as yamlParser from '../src/languageservice/parser/yamlParser07'; +import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; +import { setupTextDocument } from './utils/testHelper.js'; +import type { ParserOptions } from '../src/languageservice/parser/yamlParser07.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml'; import { isMap, isScalar, isSeq } from 'yaml'; -import { TextBuffer } from '../src/languageservice/utils/textBuffer'; +import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; const expect = chai.expect; chai.use(sinonChai); describe('YAML Documents', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); describe('YAML Documents Cache Tests', () => { - let parseStub: sinon.SinonStub; + let parseStub: SinonStub; beforeEach(() => { - parseStub = sandbox.stub(yamlParser, 'parse'); + parseStub = sandbox.stub(); }); afterEach(() => { @@ -30,7 +33,7 @@ describe('YAML Documents', () => { }); it('should cache parsed document', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.returns({}); @@ -42,7 +45,7 @@ describe('YAML Documents', () => { }); it('should re parse document if document changed', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.onFirstCall().returns({}); @@ -57,7 +60,7 @@ describe('YAML Documents', () => { }); it('should invalidate cache if custom tags provided', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.onFirstCall().returns({}); parseStub.onSecondCall().returns({ foo: 'bar' }); @@ -70,7 +73,7 @@ describe('YAML Documents', () => { }); it('should use cache if custom tags are same', () => { - const cache = new YamlDocuments(); + const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); parseStub.onFirstCall().returns({}); parseStub.onSecondCall().returns({ foo: 'bar' }); @@ -249,6 +252,6 @@ objB: }); }); -function getParserOptions(customTags: string[]): yamlParser.ParserOptions { +function getParserOptions(customTags: string[]): ParserOptions { return { customTags, yamlVersion: '1.2' }; } diff --git a/test/yamlCodeActions.test.ts b/test/yamlCodeActions.test.ts index 675ac1758..5f1753330 100644 --- a/test/yamlCodeActions.test.ts +++ b/test/yamlCodeActions.test.ts @@ -3,10 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions'; +import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions.js'; import { CodeAction, CodeActionContext, @@ -19,11 +21,11 @@ import { WorkspaceEdit, } from 'vscode-languageserver-types'; import type { ClientCapabilities, CodeActionParams } from 'vscode-languageserver'; -import { setupTextDocument, TEST_URI } from './utils/testHelper'; -import { createDiagnosticWithData, createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError'; -import { YamlCommands } from '../src/commands'; -import type { LanguageSettings } from '../src'; -import { ErrorCode } from '../src/languageservice/jsonLanguageTypes'; +import { setupTextDocument, TEST_URI } from './utils/testHelper.js'; +import { createDiagnosticWithData, createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError.js'; +import { YamlCommands } from '../src/commands.js'; +import type { LanguageSettings } from '../src/index.js'; +import { ErrorCode } from '../src/languageservice/jsonLanguageTypes.js'; const expect = chai.expect; chai.use(sinonChai); @@ -32,7 +34,7 @@ const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; const JSON_SCHEMA2_LOCAL = 'file://some/path/schema2.json'; describe('CodeActions Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); let clientCapabilities: ClientCapabilities; beforeEach(() => { diff --git a/test/yamlCodeLens.test.ts b/test/yamlCodeLens.test.ts index 537b5caef..c7f93b41b 100644 --- a/test/yamlCodeLens.test.ts +++ b/test/yamlCodeLens.test.ts @@ -2,32 +2,35 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import type { SinonStubbedInstance } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { YamlCodeLens } from '../src/languageservice/services/yamlCodeLens'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService'; -import { setupTextDocument } from './utils/testHelper'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; +import { YamlCodeLens } from '../src/languageservice/services/yamlCodeLens.js'; +import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import { setupTextDocument } from './utils/testHelper.js'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; import type { Command } from 'vscode-languageserver-protocol'; import { CodeLens, Range } from 'vscode-languageserver-protocol'; import type { Connection } from 'vscode-languageserver'; -import { YamlCommands } from '../src/commands'; -import { TelemetryImpl } from '../src/languageserver/telemetry'; -import type { Telemetry } from '../src/languageservice/telemetry'; -import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { LanguageService } from '../src/languageservice/yamlLanguageService'; -import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings'; -import type { SingleYAMLDocument } from '../src/languageservice/parser/yaml-documents'; +import { YamlCommands } from '../src/commands.js'; +import { TelemetryImpl } from '../src/languageserver/telemetry.js'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; +import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; +import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; +import type { SingleYAMLDocument } from '../src/languageservice/parser/yaml-documents.js'; const expect = chai.expect; chai.use(sinonChai); describe('YAML CodeLens', () => { - const sandbox = sinon.createSandbox(); - let yamlSchemaService: sinon.SinonStubbedInstance; - let telemetryStub: sinon.SinonStubbedInstance; + const sandbox = createSandbox(); + let yamlSchemaService: SinonStubbedInstance; + let telemetryStub: SinonStubbedInstance; let telemetry: Telemetry; beforeEach(() => { diff --git a/test/yamlCommands.test.ts b/test/yamlCommands.test.ts index ee784e0e9..3e3a90190 100644 --- a/test/yamlCommands.test.ts +++ b/test/yamlCommands.test.ts @@ -3,11 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as sinon from 'sinon'; +import { describe, it, beforeEach, afterEach } from 'node:test'; + +import type { SinonStub } from 'sinon'; +import { createSandbox, match } from 'sinon'; import sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { registerCommands } from '../src/languageservice/services/yamlCommands'; -import { commandExecutor } from '../src/languageserver/commandExecutor'; +import { registerCommands } from '../src/languageservice/services/yamlCommands.js'; +import { commandExecutor } from '../src/languageserver/commandExecutor.js'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; @@ -16,9 +19,9 @@ chai.use(sinonChai); describe('Yaml Commands', () => { const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); - let commandExecutorStub: sinon.SinonStub; + let commandExecutorStub: SinonStub; beforeEach(() => { commandExecutorStub = sandbox.stub(commandExecutor, 'registerCommand'); @@ -30,7 +33,7 @@ describe('Yaml Commands', () => { it('should register handler for "JumpToSchema" command', () => { registerCommands(commandExecutor, {} as Connection); - expect(commandExecutorStub).to.have.been.calledWithMatch(sinon.match('jumpToSchema'), sinon.match.func); + expect(commandExecutorStub).to.have.been.calledWithMatch(match('jumpToSchema'), match.func); }); it('JumpToSchema handler should call "showDocument"', async () => { diff --git a/test/yamlDefinition.test.ts b/test/yamlDefinition.test.ts index 18a7136bb..bd1cdd480 100644 --- a/test/yamlDefinition.test.ts +++ b/test/yamlDefinition.test.ts @@ -3,11 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { setupTextDocument, TEST_URI } from './utils/testHelper'; +import { describe, it } from 'node:test'; + +import { setupTextDocument, TEST_URI } from './utils/testHelper.js'; import { expect } from 'chai'; -import { YamlDefinition } from '../src/languageservice/services/yamlDefinition'; +import { YamlDefinition } from '../src/languageservice/services/yamlDefinition.js'; import { LocationLink, Position, Range } from 'vscode-languageserver-types'; -import type { Telemetry } from '../src/languageservice/telemetry'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; describe('YAML Definition', () => { it('should not provide definition for non anchor node', () => { diff --git a/test/yamlFolding.test.ts b/test/yamlFolding.test.ts index fee416a74..6cc985f47 100644 --- a/test/yamlFolding.test.ts +++ b/test/yamlFolding.test.ts @@ -3,11 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { describe, it } from 'node:test'; + import { expect } from 'chai'; import { FoldingRange } from 'vscode-languageserver-types'; -import { getFoldingRanges } from '../src/languageservice/services/yamlFolding'; -import type { FoldingRangesContext } from '../src/languageservice/yamlTypes'; -import { setupTextDocument, TEST_URI } from './utils/testHelper'; +import { getFoldingRanges } from '../src/languageservice/services/yamlFolding.js'; +import type { FoldingRangesContext } from '../src/languageservice/yamlTypes.js'; +import { setupTextDocument, TEST_URI } from './utils/testHelper.js'; const context: FoldingRangesContext = { rangeLimit: 10_0000 }; diff --git a/test/yamlLanguageService.test.ts b/test/yamlLanguageService.test.ts index 1e31d8db6..143f82909 100644 --- a/test/yamlLanguageService.test.ts +++ b/test/yamlLanguageService.test.ts @@ -2,12 +2,14 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before } from 'node:test'; import { assert } from 'chai'; import type { Position, TextDocument } from 'vscode-languageserver-textdocument'; -import type { LanguageService, SchemaRequestService, WorkspaceContextService } from '../src'; -import { getLanguageService } from '../src'; -import { workspaceContext } from '../src/languageservice/services/schemaRequestHandler'; -import { caretPosition, setupSchemaIDTextDocument } from './utils/testHelper'; +import type { LanguageService, SchemaRequestService, WorkspaceContextService } from '../src/index.js'; +import { getLanguageService } from '../src/index.js'; +import { workspaceContext } from '../src/languageservice/services/schemaRequestHandler.js'; +import { caretPosition, setupSchemaIDTextDocument } from './utils/testHelper.js'; /** * Builds a simple schema request service diff --git a/test/yamlOnTypeFormatting.test.ts b/test/yamlOnTypeFormatting.test.ts index e42ea779e..9ac12fb00 100644 --- a/test/yamlOnTypeFormatting.test.ts +++ b/test/yamlOnTypeFormatting.test.ts @@ -2,11 +2,13 @@ * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from 'node:test'; import { expect } from 'chai'; import type { DocumentOnTypeFormattingParams } from 'vscode-languageserver-protocol'; import { FormattingOptions, Position, Range, TextEdit } from 'vscode-languageserver-types'; -import { doDocumentOnTypeFormatting } from '../src/languageservice/services/yamlOnTypeFormatting'; -import { setupTextDocument } from './utils/testHelper'; +import { doDocumentOnTypeFormatting } from '../src/languageservice/services/yamlOnTypeFormatting.js'; +import { setupTextDocument } from './utils/testHelper.js'; function createParams(position: Position): DocumentOnTypeFormattingParams { return { diff --git a/test/yamlParser.test.ts b/test/yamlParser.test.ts index 940820fc6..ab1f349cb 100644 --- a/test/yamlParser.test.ts +++ b/test/yamlParser.test.ts @@ -2,12 +2,14 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it } from 'node:test'; import assert from 'assert'; import { expect } from 'chai'; -import type { ArrayASTNode, ObjectASTNode, PropertyASTNode } from '../src/languageservice/jsonLanguageTypes'; -import type { YAMLDocument } from './../src/languageservice/parser/yamlParser07'; -import { parse } from './../src/languageservice/parser/yamlParser07'; -import { aliasDepth } from '../src/languageservice/parser/ast-converter'; +import type { ArrayASTNode, ObjectASTNode, PropertyASTNode } from '../src/languageservice/jsonLanguageTypes.js'; +import type { YAMLDocument } from './../src/languageservice/parser/yamlParser07.js'; +import { parse } from './../src/languageservice/parser/yamlParser07.js'; +import { aliasDepth } from '../src/languageservice/parser/ast-converter.js'; describe('YAML parser', () => { describe('YAML parser', function () { diff --git a/test/yamlRename.test.ts b/test/yamlRename.test.ts index 248e1fe2b..36f53908e 100644 --- a/test/yamlRename.test.ts +++ b/test/yamlRename.test.ts @@ -1,7 +1,8 @@ +import { describe, it } from 'node:test'; import { expect } from 'chai'; import type { TextEdit } from 'vscode-languageserver-types'; import { Position } from 'vscode-languageserver-types'; -import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper'; +import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper.js'; import type { TextDocument } from 'vscode-languageserver-textdocument'; function applyEdits(document: TextDocument, edits: TextEdit[]): string { diff --git a/test/yamlSchema.test.ts b/test/yamlSchema.test.ts index 1d3f594df..6a65cc311 100644 --- a/test/yamlSchema.test.ts +++ b/test/yamlSchema.test.ts @@ -2,8 +2,11 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import * as sinon from 'sinon'; + +import { describe, it, beforeEach, afterEach } from 'node:test'; +import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; +import type { SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; import * as chai from 'chai'; import sinonChai from 'sinon-chai'; @@ -17,8 +20,8 @@ const workspaceContext = { }; describe('YAML Schema', () => { - const sandbox = sinon.createSandbox(); - let requestServiceStub: sinon.SinonStub; + const sandbox = createSandbox(); + let requestServiceStub: SinonStub; beforeEach(() => { requestServiceStub = sandbox.stub(); }); diff --git a/test/yamlSchemaService.test.ts b/test/yamlSchemaService.test.ts index f2eb8b7bc..cd24dd7e3 100644 --- a/test/yamlSchemaService.test.ts +++ b/test/yamlSchemaService.test.ts @@ -2,20 +2,23 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, beforeEach, afterEach } from 'node:test'; import * as chai from 'chai'; import * as JSONC from 'jsonc-parser'; import * as path from 'path'; -import * as sinon from 'sinon'; +import type { SinonFakeTimers, SinonSpy, SinonStub } from 'sinon'; +import { createSandbox } from 'sinon'; import sinonChai from 'sinon-chai'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { URI } from 'vscode-uri'; import * as YAML from 'yaml'; -import type { JSONSchema } from '../src/languageservice/jsonSchema'; -import { parse } from '../src/languageservice/parser/yamlParser07'; -import * as SchemaService from '../src/languageservice/services/yamlSchemaService'; -import { DEFAULT_KUBERNETES_SCHEMA_VERSION, getSchemaUrls } from '../src/languageservice/utils/schemaUrls'; -import { SchemaPriority } from '../src/languageservice/yamlLanguageService'; -import { SettingsState } from '../src/yamlSettings'; +import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; +import { parse } from '../src/languageservice/parser/yamlParser07.js'; +import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; +import { DEFAULT_KUBERNETES_SCHEMA_VERSION, getSchemaUrls } from '../src/languageservice/utils/schemaUrls.js'; +import { SchemaPriority } from '../src/languageservice/yamlLanguageService.js'; +import { SettingsState } from '../src/yamlSettings.js'; const BASE_KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/`; const KUBERNETES_SCHEMA_URL = BASE_KUBERNETES_SCHEMA_URL + 'all.json'; @@ -29,13 +32,13 @@ const workspaceContext = { }; describe('YAML Schema Service', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); afterEach(() => { sandbox.restore(); }); describe('Schema for resource', () => { - let requestServiceMock: sinon.SinonSpy; + let requestServiceMock: SinonSpy; beforeEach(() => { requestServiceMock = sandbox.fake.resolves(undefined); @@ -124,7 +127,10 @@ describe('YAML Schema Service', () => { expect(requestServiceMock).calledTwice; if (process.platform === 'win32') { - const driveLetter = path.parse(__dirname).root.split(':')[0].toLowerCase(); + const driveLetter = path + .parse(import.meta.dirname) + .root.split(':')[0] + .toLowerCase(); expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json`); expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json#/definitions/schemaArray`); } else { @@ -138,8 +144,8 @@ describe('YAML Schema Service', () => { it('should resolve encoded characters in a relative modeline schema path', async () => { const content = `# yaml-language-server: $schema=./encoded%20schema.json\nfoo: bar`; const yamlDock = parse(content); - const resource = URI.file(path.join(__dirname, 'test.yaml')).toString(); - const expectedSchemaPath = URI.parse(URI.file(path.join(__dirname, 'encoded schema.json')).toString()).fsPath; + const resource = URI.file(path.join(import.meta.dirname, 'test.yaml')).toString(); + const expectedSchemaPath = URI.parse(URI.file(path.join(import.meta.dirname, 'encoded schema.json')).toString()).fsPath; requestServiceMock = sandbox.fake.resolves( JSON.stringify({ type: 'object', @@ -158,13 +164,13 @@ describe('YAML Schema Service', () => { }); it('should resolve encoded characters in an absolute modeline schema path', async () => { - const rootPath = path.parse(__dirname).root.replace(/\\/g, '/'); + const rootPath = path.parse(import.meta.dirname).root.replace(/\\/g, '/'); const encodedSchemaPath = path.posix.join(rootPath, 'encoded%20schema.json'); const content = `# yaml-language-server: $schema=${encodedSchemaPath}\nfoo: bar`; const yamlDock = parse(content); - const resource = URI.file(path.join(__dirname, 'test.yaml')).toString(); + const resource = URI.file(path.join(import.meta.dirname, 'test.yaml')).toString(); const expectedSchemaPath = URI.parse( - URI.file(path.join(path.parse(__dirname).root, 'encoded schema.json')).toString() + URI.file(path.join(path.parse(import.meta.dirname).root, 'encoded schema.json')).toString() ).fsPath; requestServiceMock = sandbox.fake.resolves( JSON.stringify({ @@ -1578,7 +1584,7 @@ properties: describe('Caching of failed schema loads', () => { const SCHEMA_URI = 'https://example.com/schema.json'; const schemaContent = JSON.stringify({ type: 'object', properties: { foo: { type: 'string' } } }); - let clock: sinon.SinonFakeTimers; + let clock: SinonFakeTimers; beforeEach(() => { clock = sandbox.useFakeTimers({ now: Date.now(), shouldAdvanceTime: false }); @@ -1588,7 +1594,7 @@ properties: clock.restore(); }); - const createService = (requestService: sinon.SinonStub): SchemaService.YAMLSchemaService => { + const createService = (requestService: SinonStub): SchemaService.YAMLSchemaService => { const service = new SchemaService.YAMLSchemaService(requestService, workspaceContext); service.registerExternalSchema(SCHEMA_URI, ['*.yaml']); return service; diff --git a/test/yamlSelectionRanges.test.ts b/test/yamlSelectionRanges.test.ts index 625f82ad8..25f7139a5 100644 --- a/test/yamlSelectionRanges.test.ts +++ b/test/yamlSelectionRanges.test.ts @@ -1,7 +1,8 @@ +import { describe, it } from 'node:test'; import { expect } from 'chai'; import type { Position, Range, SelectionRange } from 'vscode-languageserver-types'; -import { setupTextDocument } from './utils/testHelper'; -import { getSelectionRanges } from '../src/languageservice/services/yamlSelectionRanges'; +import { setupTextDocument } from './utils/testHelper.js'; +import { getSelectionRanges } from '../src/languageservice/services/yamlSelectionRanges.js'; function isRangesEqual(range1: Range, range2: Range): boolean { return ( diff --git a/test/yamlValidation.test.ts b/test/yamlValidation.test.ts index fbf710f48..e0b0ef625 100644 --- a/test/yamlValidation.test.ts +++ b/test/yamlValidation.test.ts @@ -2,16 +2,18 @@ * Copyright (c) Red Hat. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + +import { describe, it, before, afterEach } from 'node:test'; import type { Diagnostic } from 'vscode-languageserver-types'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; -import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers'; -import type { SettingsState } from '../src/yamlSettings'; -import { TextDocumentTestManager } from '../src/yamlSettings'; -import { ServiceSetup } from './utils/serviceSetup'; -import { setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { SettingsState } from '../src/yamlSettings.js'; +import { TextDocumentTestManager } from '../src/yamlSettings.js'; +import { ServiceSetup } from './utils/serviceSetup.js'; +import { setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import { expect } from 'chai'; -import * as sinon from 'sinon'; -import { createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError'; +import { createSandbox } from 'sinon'; +import { createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError.js'; type ValidationHandlerWithConnection = { connection: { @@ -22,7 +24,7 @@ type ValidationHandlerWithConnection = { }; describe('YAML Validation Tests', () => { - const sandbox = sinon.createSandbox(); + const sandbox = createSandbox(); let languageSettingsSetup: ServiceSetup; let validationHandler: ValidationHandler; let yamlSettings: SettingsState; diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index 1499520fb..000000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "lib": ["WebWorker"], - "module": "esnext", - "moduleResolution": "bundler", - "outDir": "./lib/esm", - "rootDir": "./src" - }, - "include": ["src"] -} diff --git a/tsconfig.json b/tsconfig.json index c138cce25..044e1bdb1 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "strictFunctionTypes": false, "strictNullChecks": false, "target": "es2020", - "types": ["mocha", "node"], + "types": ["node"], "useUnknownInCatchVariables": false }, "include": ["src", "test"], diff --git a/tsconfig.umd.json b/tsconfig.umd.json deleted file mode 100644 index 5ad269ac6..000000000 --- a/tsconfig.umd.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "ignoreDeprecations": "6.0", - "lib": ["webworker"], - "module": "umd", - "moduleResolution": "node10", - "outDir": "./lib/umd", - "rootDir": "./src" - }, - "include": ["src"] -} From 1292cc36667b62438d16eafd81b49a078cb18b99 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Mon, 5 Oct 2026 22:53:43 -0400 Subject: [PATCH 14/18] remove ts-node Signed-off-by: Morgan Chang --- test/customTags.test.ts | 1 - test/defaultSnippets.test.ts | 8 +++++--- test/integration.test.ts | 1 - test/multipleDocuments.test.ts | 9 +++++---- test/schema.test.ts | 17 +++++++++++------ 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/test/customTags.test.ts b/test/customTags.test.ts index 947716103..8884b226e 100644 --- a/test/customTags.test.ts +++ b/test/customTags.test.ts @@ -12,7 +12,6 @@ import type { Diagnostic } from 'vscode-languageserver-types'; import type { LanguageService } from '../src/languageservice/yamlLanguageService.js'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; -// Defines a Mocha test describe to group tests of similar kind together describe('Custom Tag tests Tests', () => { let languageSettingsSetup: ServiceSetup; let languageService: LanguageService; diff --git a/test/defaultSnippets.test.ts b/test/defaultSnippets.test.ts index 195046bc0..daa7d3add 100644 --- a/test/defaultSnippets.test.ts +++ b/test/defaultSnippets.test.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { describe, it, before } from 'node:test'; -import { toFsPath, setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper.js'; +import { setupSchemaIDTextDocument, setupLanguageService, caretPosition } from './utils/testHelper.js'; import assert from 'assert'; -import * as path from 'path'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; import type { SettingsState } from '../src/yamlSettings.js'; @@ -14,16 +13,19 @@ import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { CompletionList, TextEdit } from 'vscode-languageserver-types'; import { expect } from 'chai'; +import defaultSnippetsSchema from './fixtures/defaultSnippets.json' with { type: 'json' }; + describe('Default Snippet Tests', () => { let languageHandler: LanguageHandlers; let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(import.meta.dirname, './fixtures/defaultSnippets.json')); + const uri = new URL('./fixtures/defaultSnippets.json', import.meta.url).href; const fileMatch = ['*.yml', '*.yaml']; const languageSettingsSetup = new ServiceSetup().withCompletion().withSchemaFileMatch({ fileMatch, uri, + schema: defaultSnippetsSchema, }); const { languageHandler: langHandler, yamlSettings: settings } = setupLanguageService(languageSettingsSetup.languageSettings); languageHandler = langHandler; diff --git a/test/integration.test.ts b/test/integration.test.ts index 94c9944e9..e84669ca4 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -14,7 +14,6 @@ import type { SettingsState } from '../src/yamlSettings.js'; import { TextDocumentTestManager } from '../src/yamlSettings.js'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; -// Defines a Mocha test describe to group tests of similar kind together describe('Kubernetes Integration Tests', () => { let languageSettingsSetup: ServiceSetup; let languageHandler: LanguageHandlers; diff --git a/test/multipleDocuments.test.ts b/test/multipleDocuments.test.ts index 3476975f9..f921e265d 100644 --- a/test/multipleDocuments.test.ts +++ b/test/multipleDocuments.test.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { describe, it, before } from 'node:test'; -import * as path from 'path'; -import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper.js'; +import { setupLanguageService, setupTextDocument } from './utils/testHelper.js'; import assert from 'assert'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic, Hover } from 'vscode-languageserver-types'; @@ -16,11 +15,12 @@ import type { LanguageService } from '../src/languageservice/yamlLanguageService import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; import type { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; +import multipleDocumentsSchema from './fixtures/customMultipleSchemaSequences.json' with { type: 'json' }; + /** * Setup the schema we are going to use with the language settings */ -// Defines a Mocha test describe to group tests of similar kind together describe('Multiple Documents Validation Tests', () => { let languageSettingsSetup: ServiceSetup; let languageHandler: LanguageHandlers; @@ -29,7 +29,7 @@ describe('Multiple Documents Validation Tests', () => { let yamlSettings: SettingsState; before(() => { - const uri = toFsPath(path.join(import.meta.dirname, './fixtures/customMultipleSchemaSequences.json')); + const uri = new URL('./fixtures/customMultipleSchemaSequences.json', import.meta.url).href; const fileMatch = ['*.yml', '*.yaml']; languageSettingsSetup = new ServiceSetup() .withHover() @@ -38,6 +38,7 @@ describe('Multiple Documents Validation Tests', () => { .withSchemaFileMatch({ fileMatch, uri, + schema: multipleDocumentsSchema, }) .withCustomTags(['!Test', '!Ref sequence']); const { diff --git a/test/schema.test.ts b/test/schema.test.ts index 03d0de987..ac6273e7e 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -3,7 +3,6 @@ import assert from 'assert'; import * as parser from '../src/languageservice/parser/yamlParser07.js'; import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; import type * as JsonSchema from '../src/languageservice/jsonSchema.js'; -import * as path from 'path'; import requestLight from 'request-light'; import type { SchemaDeletions } from '../src/languageservice/services/yamlSchemaService.js'; import { MODIFICATION_ACTIONS } from '../src/languageservice/services/yamlSchemaService.js'; @@ -27,6 +26,9 @@ import schemaStoreSample from './fixtures/sample-schemastore.json' with { type: import schemaSettingsSample from './fixtures/sample-settings.json' with { type: 'json' }; import schemaDefaultSnippetSample from './fixtures/defaultSnippets-const-if-else.json' with { type: 'json' }; +import schemaModelineSample from './fixtures/sample-modeline.json' with { type: 'json' }; +import schemaDollarSample from './fixtures/sample-dollar-schema.json' with { type: 'json' }; + const KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/all.json`; const requestServiceMock = function (uri: string): Promise { @@ -859,13 +861,16 @@ address: }); describe('Test schema priority', function () { - const schemaModelineSample = path.join(import.meta.dirname, './fixtures/sample-modeline.json'); - const schemaDollarSample = path.join(import.meta.dirname, './fixtures/sample-dollar-schema.json'); + const modelineSchemaUri = new URL('./fixtures/sample-modeline.json', import.meta.url).href; + const dollarSchemaUri = new URL('./fixtures/sample-dollar-schema.json', import.meta.url).href; let languageSettingsSetup: ServiceSetup; beforeEach(() => { - languageSettingsSetup = new ServiceSetup().withCompletion(); + languageSettingsSetup = new ServiceSetup() + .withCompletion() + .withSchemaFileMatch({ uri: modelineSchemaUri, fileMatch: [], schema: schemaModelineSample }) + .withSchemaFileMatch({ uri: dollarSchemaUri, fileMatch: [], schema: schemaDollarSample }); }); for (const { description, uri } of [ @@ -923,7 +928,7 @@ address: languageService.configure(languageSettingsSetup.languageSettings); languageService.registerCustomSchemaProvider((uri: string) => Promise.resolve(uri)); const testTextDocument = setupTextDocument( - `# yaml-language-server: $schema=${schemaModelineSample}\n$schema: ${schemaDollarSample}\n\n` + `# yaml-language-server: $schema=${modelineSchemaUri}\n$schema: ${dollarSchemaUri}\n\n` ); const result = await languageService.doComplete(testTextDocument, Position.create(1, 0), false); assert.strictEqual(result.items.length, 1); @@ -952,7 +957,7 @@ address: }); languageService.configure(languageSettingsSetup.languageSettings); languageService.registerCustomSchemaProvider((uri: string) => Promise.resolve(uri)); - const testTextDocument = setupTextDocument(`$schema: ${schemaDollarSample}\n\n`); + const testTextDocument = setupTextDocument(`$schema: ${dollarSchemaUri}\n\n`); const result = await languageService.doComplete(testTextDocument, Position.create(1, 0), false); assert.strictEqual(result.items.length, 1); assert.strictEqual(result.items[0].label, 'dollar-schema'); From 0f12be682582051d3e3f27cce19425b19dd44832 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Tue, 6 Oct 2026 11:26:43 -0400 Subject: [PATCH 15/18] update launch.json and tasks.json Signed-off-by: Morgan Chang --- .vscode/launch.json | 22 +++++++++++++--------- .vscode/tasks.json | 6 ++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e4f816d53..459055101 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,37 +8,41 @@ "request": "attach", "port": 6009, "sourceMaps": true, - "outFiles": ["${workspaceRoot}/out/server/**/*.ts"], + "outFiles": ["${workspaceRoot}/out/server/**/*.js"], "protocol": "inspector", "trace": true, "preLaunchTask": "watch typescript", }, - // A launch configuration that compiles the server and runs mocha unit tests + // A launch configuration that compiles the server and runs tests with Node's test runner { "type": "node", "request": "launch", "name": "Launch Tests", - "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", - "args": ["-u", "bdd", "--timeout", "999999", "--colors", "-r", "ts-node/register", "${workspaceRoot}/test/*.test.ts"], - "preLaunchTask": "watch typescript", + "runtimeArgs": ["--enable-source-maps", "--test"], + "args": ["${workspaceFolder}/out/server/test/*.test.js"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "npm: compile", "resolveSourceMapLocations": [ "${workspaceFolder}/**", "!**/node_modules/**" ], + "console": "integratedTerminal", }, - // A launch configuration that compiles the server and runs mocha unit tests + // A launch configuration that compiles the server and runs the currently open test file { "type": "node", "request": "launch", "name": "Launch Single File Tests", - "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", - "args": ["-u", "bdd", "--timeout", "999999", "--colors", "-r", "ts-node/register", "${workspaceRoot}/${relativeFile}"], - "preLaunchTask": "watch typescript", + "runtimeArgs": ["--enable-source-maps", "--test"], + "args": ["${workspaceFolder}/out/server/test/${fileBasenameNoExtension}.js"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "npm: compile", "sourceMaps": true, "resolveSourceMapLocations": [ "${workspaceFolder}/**", "!**/node_modules/**" ], + "console": "integratedTerminal", } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5c223ea12..46f02e762 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -17,6 +17,12 @@ "isDefault": true } }, + { + "type": "npm", + "script": "compile", + "problemMatcher": ["$tsc"], + "label": "npm: compile" + }, { "type": "npm", "script": "lint", From a5d473b79df4356d12440be637689148c34266a3 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Wed, 7 Oct 2026 13:51:54 -0400 Subject: [PATCH 16/18] upgrade vscode-languageserver and remove sinon and sinon-chai Signed-off-by: Morgan Chang --- package-lock.json | 34 +- package.json | 4 +- .../handlers/schemaSelectionHandlers.ts | 2 +- .../services/yamlCodeActions.ts | 2 +- .../services/yamlValidation.ts | 2 +- src/server.ts | 4 +- src/webworker/yamlServerMain.ts | 2 +- test/bundlel10n.test.ts | 4 +- test/formatter.test.ts | 12 +- test/invalid-metaschema.test.ts | 21 +- test/schema2019Validation.test.ts | 6 +- test/schema2020Validation.test.ts | 14 +- test/schemaRequestHandler.test.ts | 97 ++-- test/schemaSelectionHandlers.test.ts | 47 +- test/schemaValidation.test.ts | 30 +- test/settingsHandlers.test.ts | 392 +++++++++------ test/telemetry.test.ts | 30 +- test/utils/testHelper.ts | 9 +- test/utils/testsTypes.ts | 1 + test/yaml-documents.test.ts | 40 +- test/yamlCodeActions.test.ts | 11 +- test/yamlCodeLens.test.ts | 67 +-- test/yamlCommands.test.ts | 104 ++-- test/yamlSchema.test.ts | 46 +- test/yamlSchemaService.test.ts | 457 +++++++++++------- test/yamlValidation.test.ts | 8 +- 26 files changed, 820 insertions(+), 626 deletions(-) diff --git a/package-lock.json b/package-lock.json index ebb50c191..8a53a44f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,9 +17,9 @@ "picomatch": "^4.0.4", "prettier": "^3.8.1", "request-light": "^0.5.7", - "vscode-languageserver": "^9.0.0", + "vscode-languageserver": "^10.1.2", "vscode-languageserver-textdocument": "^1.0.1", - "vscode-languageserver-types": "~3.17.5", + "vscode-languageserver-types": "^3.18.4", "vscode-uri": "^3.0.2", "yaml": "2.8.3" }, @@ -3523,34 +3523,34 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", - "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-9.0.3.tgz", + "integrity": "sha512-qETYf9PCl1lVfwR+oBmMfc4vP2nqLNA35ABxorw3j06+xlKRgDVxbLgKm4Y/xPL0YWdeDjLoI4ImICIT3nB0zQ==", "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageserver": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz", - "integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-10.1.2.tgz", + "integrity": "sha512-pXPWde3RytdeBVEs6PulOOT5OpeXC5GkWRpcT11f5rNn41jviQsAYPyAqJ/0oVGETQLKPJtYbHNiMPlfLb0NTQ==", "license": "MIT", "dependencies": { - "vscode-languageserver-protocol": "3.17.5" + "vscode-languageserver-protocol": "3.18.4" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz", - "integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==", + "version": "3.18.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.18.4.tgz", + "integrity": "sha512-CCXbyr99dafRJzJH/0Ryk7ly5T8XPmSR0//OuF2w4m+9JiOin7zcAT5iET8GRE7Z9taFBejb3GbM0a0mbjdbrg==", "license": "MIT", "dependencies": { - "vscode-jsonrpc": "8.2.0", - "vscode-languageserver-types": "3.17.5" + "vscode-jsonrpc": "9.0.3", + "vscode-languageserver-types": "3.18.4" } }, "node_modules/vscode-languageserver-textdocument": { @@ -3560,9 +3560,9 @@ "license": "MIT" }, "node_modules/vscode-languageserver-types": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", - "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==", + "version": "3.18.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.18.4.tgz", + "integrity": "sha512-nQsacoiijvl0fRf2q28uFDrAVwRhdCa3QveiF7/CX0r18mLR5FU/1WskSsCKOjmEbtteKUnY8x8Yzxop+k0zwg==", "license": "MIT" }, "node_modules/vscode-uri": { diff --git a/package.json b/package.json index ef35f8c6a..a66ba51f1 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,9 @@ "picomatch": "^4.0.4", "prettier": "^3.8.1", "request-light": "^0.5.7", - "vscode-languageserver": "^9.0.0", + "vscode-languageserver": "^10.1.2", "vscode-languageserver-textdocument": "^1.0.1", - "vscode-languageserver-types": "~3.17.5", + "vscode-languageserver-types": "^3.18.4", "vscode-uri": "^3.0.2", "yaml": "2.8.3" }, diff --git a/src/languageserver/handlers/schemaSelectionHandlers.ts b/src/languageserver/handlers/schemaSelectionHandlers.ts index d721de11e..7ba9c1dbb 100644 --- a/src/languageserver/handlers/schemaSelectionHandlers.ts +++ b/src/languageserver/handlers/schemaSelectionHandlers.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { Connection } from 'vscode-languageserver/node.js'; +import type { Connection } from 'vscode-languageserver/node'; import type { JSONSchema } from '../../languageservice/jsonSchema.js'; import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents.js'; import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService.js'; diff --git a/src/languageservice/services/yamlCodeActions.ts b/src/languageservice/services/yamlCodeActions.ts index eae7dce5a..c96d8991b 100644 --- a/src/languageservice/services/yamlCodeActions.ts +++ b/src/languageservice/services/yamlCodeActions.ts @@ -184,7 +184,7 @@ export class YamlCodeActions { const result = []; const buffer = new TextBuffer(document); for (const diag of diagnostics) { - if (diag.message.startsWith('Unused anchor') && diag.source === YAML_SOURCE) { + if (typeof diag.message === 'string' && diag.message.startsWith('Unused anchor') && diag.source === YAML_SOURCE) { const range = Range.create(diag.range.start, diag.range.end); const actual = buffer.getText(range); const lineContent = buffer.getLineContent(range.end.line); diff --git a/src/languageservice/services/yamlValidation.ts b/src/languageservice/services/yamlValidation.ts index cea31d810..566253243 100644 --- a/src/languageservice/services/yamlValidation.ts +++ b/src/languageservice/services/yamlValidation.ts @@ -150,7 +150,7 @@ export class YAMLValidation { return filterSuppressedDiagnostics( duplicateMessagesRemoved, (d) => d.range.start.line, - (d) => d.message, + (d) => (typeof d.message === 'string' ? d.message : d.message.value), (line) => { if (line < 0 || line >= textBuffer.getLineCount()) { return undefined; diff --git a/src/server.ts b/src/server.ts index 8dcf8f440..0f510378a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -6,8 +6,8 @@ *--------------------------------------------------------------------------------------------*/ import { promises as fs } from 'fs'; -import type { Connection } from 'vscode-languageserver/node.js'; -import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js'; +import type { Connection } from 'vscode-languageserver/node'; +import { createConnection, ProposedFeatures } from 'vscode-languageserver/node'; import { TelemetryImpl } from './languageserver/telemetry.js'; import { schemaRequestHandler, workspaceContext } from './languageservice/services/schemaRequestHandler.js'; import { convertErrorToTelemetryMsg } from './languageservice/utils/objects.js'; diff --git a/src/webworker/yamlServerMain.ts b/src/webworker/yamlServerMain.ts index d7c01965e..fc2a8dd10 100644 --- a/src/webworker/yamlServerMain.ts +++ b/src/webworker/yamlServerMain.ts @@ -6,7 +6,7 @@ import * as l10n from '@vscode/l10n'; import type { Connection } from 'vscode-languageserver'; import { RequestType } from 'vscode-languageserver'; -import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser.js'; +import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'; import { TelemetryImpl } from '../languageserver/telemetry.js'; import { schemaRequestHandler, workspaceContext } from '../languageservice/services/schemaRequestHandler.js'; import { YAMLServerInit } from '../yamlServerInit.js'; diff --git a/test/bundlel10n.test.ts b/test/bundlel10n.test.ts index a92872dce..643e5291e 100644 --- a/test/bundlel10n.test.ts +++ b/test/bundlel10n.test.ts @@ -7,8 +7,8 @@ import { describe, it, before, after } from 'node:test'; import * as l10n from '@vscode/l10n'; import assert from 'assert'; import * as path from 'path'; -import type { Connection } from 'vscode-languageserver/node.js'; -import { createConnection } from 'vscode-languageserver/node.js'; +import type { Connection } from 'vscode-languageserver/node'; +import { createConnection } from 'vscode-languageserver/node'; import { schemaRequestHandler, workspaceContext } from '../src/languageservice/services/schemaRequestHandler.js'; import { setupl10nBundle } from '../src/nodeTranslationSetup.js'; import { YAMLServerInit } from '../src/yamlServerInit.js'; diff --git a/test/formatter.test.ts b/test/formatter.test.ts index f6eb446ff..d0c1579f4 100644 --- a/test/formatter.test.ts +++ b/test/formatter.test.ts @@ -3,9 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, before, afterEach } from 'node:test'; +import { describe, it, before, afterEach, mock } from 'node:test'; import assert from 'assert'; -import { createSandbox } from 'sinon'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { FormattingOptions, TextEdit } from 'vscode-languageserver-types'; import type { CustomFormatterOptions } from '../src/index.js'; @@ -26,12 +25,11 @@ type LanguageHandlerWithConnection = { }; describe('Formatter Tests', () => { - const sandbox = createSandbox(); let languageHandler: LanguageHandlers; let yamlSettings: SettingsState; afterEach(() => { - sandbox.restore(); + mock.reset(); }); before(() => { @@ -72,7 +70,7 @@ describe('Formatter Tests', () => { yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const connection = (languageHandler as unknown as LanguageHandlerWithConnection).connection; - sandbox.stub(connection.workspace, 'getConfiguration').resolves([{}, { 'yaml.format.enable': false }]); + mock.method(connection.workspace, 'getConfiguration', () => Promise.resolve([{}, { 'yaml.format.enable': false }])); yamlSettings.hasConfigurationCapability = true; const edits = await languageHandler.formatterHandler({ options: { tabSize: 2, insertSpaces: true }, @@ -92,7 +90,7 @@ describe('Formatter Tests', () => { yamlSettings.hasConfigurationCapability = true; const connection = (languageHandler as unknown as LanguageHandlerWithConnection).connection; - const getConfiguration = sandbox.stub(connection.workspace, 'getConfiguration').callsFake(async (items) => { + const getConfiguration = mock.method(connection.workspace, 'getConfiguration', async (items) => { assert.ok(Array.isArray(items)); assert.equal(items[0].section, 'yaml.format'); assert.equal(items[1].section, '[yaml]'); @@ -111,7 +109,7 @@ describe('Formatter Tests', () => { assert.equal(singleQuoteEdits[0].newText, "root:\n - child: 'text'\n"); assert.equal(doubleQuoteEdits.length, 0); - assert.equal(getConfiguration.callCount, 2); + assert.equal(getConfiguration.mock.callCount(), 2); }); it('Formatting works with custom tags', async () => { diff --git a/test/invalid-metaschema.test.ts b/test/invalid-metaschema.test.ts index 25d3a9216..cfb9f12ef 100644 --- a/test/invalid-metaschema.test.ts +++ b/test/invalid-metaschema.test.ts @@ -3,32 +3,33 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import { assert } from 'chai'; -import type { SinonSpy } from 'sinon'; -import { createSandbox } from 'sinon'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import assert from 'node:assert/strict'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node'; import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; import { setupSchemaIDTextDocument } from './utils/testHelper.js'; describe('unexpected meta schema', () => { - const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: SinonSpy; + let requestServiceMock: Mock; beforeEach(() => { - requestServiceMock = sandbox.fake.resolves('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }'); + requestServiceMock = mock.fn(() => + Promise.resolve('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }') + ); service = new YAMLSchemaService(requestServiceMock); connection.client = {} as RemoteClient; - const onRequest = sandbox.fake(); + const onRequest = mock.fn(); connection.onRequest = onRequest; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should not throw when a non-standard meta schema is used', async () => { diff --git a/test/schema2019Validation.test.ts b/test/schema2019Validation.test.ts index 2bf767d80..c3f5b7c28 100644 --- a/test/schema2019Validation.test.ts +++ b/test/schema2019Validation.test.ts @@ -5,7 +5,7 @@ import { describe, it, before, beforeEach, afterEach } from 'node:test'; import type { TestCustomSchemaProvider } from './utils/testHelper.js'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, getDiagnosticMessage } from './utils/testHelper.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; @@ -2680,7 +2680,7 @@ unknown: 1 schemaProvider.addSchema(SCHEMA_ID, root); const yaml = `x: A`; const result = await parseSetup(yaml); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2711,7 +2711,7 @@ unknown: 1 schemaProvider.addSchema(SCHEMA_ID, root); const yaml = `address:\n zipCode: "123"`; const result = await parseSetup(yaml); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result[0].message).to.include('String is shorter than the minimum length of 5.'); }); }); diff --git a/test/schema2020Validation.test.ts b/test/schema2020Validation.test.ts index 48363067e..0ce7712e7 100644 --- a/test/schema2020Validation.test.ts +++ b/test/schema2020Validation.test.ts @@ -5,7 +5,7 @@ import { describe, it, before, beforeEach, afterEach } from 'node:test'; import type { TestCustomSchemaProvider } from './utils/testHelper.js'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, getDiagnosticMessage } from './utils/testHelper.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import type { Diagnostic } from 'vscode-languageserver-types'; import { expect } from 'chai'; @@ -2000,8 +2000,10 @@ a: true`); elements: - b: 1`); expect(result).to.have.length(2); - expect(result.some((d) => d.message.includes('Missing property') && d.message.includes('a'))).to.eq(true); - expect(result.some((d) => d.message.includes('Property b is not allowed.'))).to.eq(true); + expect( + result.some((d) => getDiagnosticMessage(d).includes('Missing property') && getDiagnosticMessage(d).includes('a')) + ).to.eq(true); + expect(result.some((d) => getDiagnosticMessage(d).includes('Property b is not allowed.'))).to.eq(true); }); it('correct extended schema', async () => { @@ -2055,8 +2057,10 @@ a: true`); elements: - b: 1`); expect(result).to.have.length(2); - expect(result.some((d) => d.message.includes('Missing property') && d.message.includes('a'))).to.eq(true); - expect(result.some((d) => d.message.includes('Property b is not allowed.'))).to.eq(true); + expect( + result.some((d) => getDiagnosticMessage(d).includes('Missing property') && getDiagnosticMessage(d).includes('a')) + ).to.eq(true); + expect(result.some((d) => getDiagnosticMessage(d).includes('Property b is not allowed.'))).to.eq(true); }); it('correct extended schema', async () => { diff --git a/test/schemaRequestHandler.test.ts b/test/schemaRequestHandler.test.ts index 9d1936226..89f3bef64 100644 --- a/test/schemaRequestHandler.test.ts +++ b/test/schemaRequestHandler.test.ts @@ -3,21 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import { schemaRequestHandler } from '../src/languageservice/services/schemaRequestHandler.js'; import type { SchemaRequestRetryOptions } from '../src/languageservice/services/schemaRequestHandler.js'; -import type { SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; import request from 'request-light'; import type { XHRResponse } from 'request-light'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; import * as chai from 'chai'; -import sinonChai from 'sinon-chai'; const expect = chai.expect; -chai.use(sinonChai); import { testFileSystem } from './utils/testHelper.js'; describe('Schema Request Handler Tests', () => { @@ -69,16 +67,15 @@ describe('Schema Request Handler Tests', () => { }); describe('schemaRequestHandler', () => { - const sandbox = createSandbox(); - let readFileStub: SinonStub; + let readFileStub: Mock; beforeEach(() => { - readFileStub = sandbox.stub(testFileSystem, 'readFile'); - readFileStub.returns(Promise.resolve('{some: "json"}')); + readFileStub = mock.method(testFileSystem, 'readFile', () => undefined); + readFileStub.mock.mockImplementation(() => Promise.resolve('{some: "json"}')); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('Should care Win URI', async () => { const connection = {} as Connection; @@ -91,7 +88,8 @@ describe('Schema Request Handler Tests', () => { testFileSystem, false ); - expect(readFileStub).calledOnceWith('c:\\some\\window\\path\\scheme.json'); + assert.equal(readFileStub.mock.callCount(), 1); + assert.deepEqual(readFileStub.mock.calls[0].arguments.slice(0, 1), ['c:\\some\\window\\path\\scheme.json']); const result = await resultPromise; expect(result).to.be.equal('{some: "json"}'); }); @@ -114,24 +112,26 @@ describe('Schema Request Handler Tests', () => { testFileSystem, false ); - expect(readFileStub).calledOnceWith(URI.file('a:/some/window/path/scheme.json').fsPath); + assert.equal(readFileStub.mock.callCount(), 1); + assert.deepEqual(readFileStub.mock.calls[0].arguments.slice(0, 1), [URI.file('a:/some/window/path/scheme.json').fsPath]); const result = await resultPromise; expect(result).to.be.equal('{some: "json"}'); }); }); describe('HTTP(S) schema requests', () => { - const sandbox = createSandbox(); - let xhrStub: SinonStub; + let xhrStub: Mock; const connection = {} as Connection; beforeEach(() => { - xhrStub = sandbox.stub(request, 'xhr'); - xhrStub.resolves({ responseText: '{"$schema":"http://json-schema.org/draft-07/schema"}', status: 200 } as XHRResponse); + xhrStub = mock.method(request, 'xhr', () => undefined); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ responseText: '{"$schema":"http://json-schema.org/draft-07/schema"}', status: 200 } as XHRResponse) + ); }); afterEach(() => { - sandbox.restore(); + mock.reset(); delete process.env.YAML_LANGUAGE_SERVER_VERSION; }); @@ -139,8 +139,8 @@ describe('Schema Request Handler Tests', () => { process.env.YAML_LANGUAGE_SERVER_VERSION = '1.0.0-test'; await schemaRequestHandler(connection, 'https://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - expect(xhrStub).calledOnce; - const { headers } = xhrStub.firstCall.args[0]; + assert.equal(xhrStub.mock.callCount(), 1); + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['User-Agent']).to.equal( `yaml-language-server/1.0.0-test (RedHat) node/${process.versions.node} (${process.platform})` ); @@ -150,7 +150,7 @@ describe('Schema Request Handler Tests', () => { delete process.env.YAML_LANGUAGE_SERVER_VERSION; await schemaRequestHandler(connection, 'https://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - const { headers } = xhrStub.firstCall.args[0]; + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['User-Agent']).to.match(/^yaml-language-server\/unknown \(RedHat\)/); }); @@ -158,14 +158,14 @@ describe('Schema Request Handler Tests', () => { process.env.YAML_LANGUAGE_SERVER_VERSION = '2.0.0'; await schemaRequestHandler(connection, 'http://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - const { headers } = xhrStub.firstCall.args[0]; + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['User-Agent']).to.match(/^yaml-language-server\/2\.0\.0 \(RedHat\)/); }); it('should preserve Accept-Encoding header alongside User-Agent', async () => { await schemaRequestHandler(connection, 'https://example.com/schema.json', [], URI.parse(''), false, testFileSystem, false); - const { headers } = xhrStub.firstCall.args[0]; + const { headers } = xhrStub.mock.calls[0].arguments[0]; expect(headers['Accept-Encoding']).to.equal('gzip, deflate'); }); @@ -183,7 +183,7 @@ describe('Schema Request Handler Tests', () => { }); it('should reject with responseText on xhr error', async () => { - xhrStub.rejects({ responseText: 'Not Found', status: 404 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Not Found', status: 404 } as XHRResponse)); try { await schemaRequestHandler( connection, @@ -202,8 +202,7 @@ describe('Schema Request Handler Tests', () => { }); describe('HTTP(S) schema request retries', () => { - const sandbox = createSandbox(); - let xhrStub: SinonStub; + let xhrStub: Mock; let delays: number[]; const connection = {} as Connection; @@ -229,35 +228,35 @@ describe('Schema Request Handler Tests', () => { beforeEach(() => { delays = []; - xhrStub = sandbox.stub(request, 'xhr'); + xhrStub = mock.method(request, 'xhr', () => undefined); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should retry a transient status and return the eventual response', async () => { - xhrStub.onFirstCall().rejects({ responseText: '', status: 429 } as XHRResponse); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce(() => Promise.reject({ responseText: '', status: 429 } as XHRResponse), 0); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); const result = await doRequest(); - expect(xhrStub).calledTwice; + assert.equal(xhrStub.mock.callCount(), 2); expect(result).to.equal(success.responseText); }); it('should retry connection level failures', async () => { - xhrStub.onFirstCall().rejects({ code: 'ECONNRESET', message: 'socket hang up' }); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce(() => Promise.reject({ code: 'ECONNRESET', message: 'socket hang up' }), 0); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); const result = await doRequest(); - expect(xhrStub).calledTwice; + assert.equal(xhrStub.mock.callCount(), 2); expect(result).to.equal(success.responseText); }); it('should not retry a permanent status', async () => { - xhrStub.rejects({ responseText: 'Not Found', status: 404 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Not Found', status: 404 } as XHRResponse)); try { await doRequest(); @@ -265,11 +264,11 @@ describe('Schema Request Handler Tests', () => { } catch (err) { expect(err).to.equal('Not Found'); } - expect(xhrStub).calledOnce; + assert.equal(xhrStub.mock.callCount(), 1); }); it('should give up after the retry budget is exhausted', async () => { - xhrStub.rejects({ responseText: 'Service Unavailable', status: 503 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Service Unavailable', status: 503 } as XHRResponse)); try { await doRequest(); @@ -278,14 +277,15 @@ describe('Schema Request Handler Tests', () => { expect(err).to.equal('Service Unavailable'); } // The initial attempt plus the default budget of 2 retries. - expect(xhrStub).calledThrice; + assert.equal(xhrStub.mock.callCount(), 3); }); it('should honour a Retry-After header in preference to backoff', async () => { - xhrStub - .onFirstCall() - .rejects({ responseText: '', status: 429, headers: { 'retry-after': '0.5' } } as unknown as XHRResponse); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce( + () => Promise.reject({ responseText: '', status: 429, headers: { 'retry-after': '0.5' } } as unknown as XHRResponse), + 0 + ); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); await doRequest(); @@ -293,10 +293,11 @@ describe('Schema Request Handler Tests', () => { }); it('should cap an excessive Retry-After value', async () => { - xhrStub - .onFirstCall() - .rejects({ responseText: '', status: 429, headers: { 'retry-after': '600' } } as unknown as XHRResponse); - xhrStub.onSecondCall().resolves(success); + xhrStub.mock.mockImplementationOnce( + () => Promise.reject({ responseText: '', status: 429, headers: { 'retry-after': '600' } } as unknown as XHRResponse), + 0 + ); + xhrStub.mock.mockImplementationOnce(() => Promise.resolve(success), 1); await doRequest(); @@ -304,7 +305,7 @@ describe('Schema Request Handler Tests', () => { }); it('should back off between attempts when no Retry-After is given', async () => { - xhrStub.rejects({ responseText: 'Service Unavailable', status: 503 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Service Unavailable', status: 503 } as XHRResponse)); try { await doRequest(); @@ -320,7 +321,7 @@ describe('Schema Request Handler Tests', () => { }); it('should not retry when the budget is zero', async () => { - xhrStub.rejects({ responseText: 'Too Many Requests', status: 429 } as XHRResponse); + xhrStub.mock.mockImplementation(() => Promise.reject({ responseText: 'Too Many Requests', status: 429 } as XHRResponse)); try { await doRequest({ ...retryOptions, maxRetries: 0 }); @@ -328,7 +329,7 @@ describe('Schema Request Handler Tests', () => { } catch (err) { expect(err).to.equal('Too Many Requests'); } - expect(xhrStub).calledOnce; + assert.equal(xhrStub.mock.callCount(), 1); }); }); }); diff --git a/test/schemaSelectionHandlers.test.ts b/test/schemaSelectionHandlers.test.ts index 757275b08..dbb9b72a6 100644 --- a/test/schemaSelectionHandlers.test.ts +++ b/test/schemaSelectionHandlers.test.ts @@ -3,43 +3,47 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import type { SinonSpy } from 'sinon'; -import { createSandbox } from 'sinon'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import { isDeepStrictEqual } from 'node:util'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; -import sinonChai from 'sinon-chai'; import { JSONSchemaSelection } from '../src/languageserver/handlers/schemaSelectionHandlers.js'; import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; -import type { Connection, RemoteClient } from 'vscode-languageserver/node.js'; +import type { Connection, RemoteClient } from 'vscode-languageserver/node'; import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; import { SchemaSelectionRequests } from '../src/requestTypes.js'; import { SCHEMA_ID, setupSchemaIDTextDocument } from './utils/testHelper.js'; const expect = chai.expect; -chai.use(sinonChai); describe('Schema Selection Handlers', () => { - const sandbox = createSandbox(); const connection: Connection = {} as Connection; let service: YAMLSchemaService; - let requestServiceMock: SinonSpy; + let requestServiceMock: Mock; + let onRequest: Mock; beforeEach(() => { - requestServiceMock = sandbox.fake.resolves(undefined); + requestServiceMock = mock.fn(() => Promise.resolve(undefined)); service = new YAMLSchemaService(requestServiceMock); connection.client = {} as RemoteClient; - const onRequest = sandbox.fake(); + onRequest = mock.fn(); connection.onRequest = onRequest; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('add handler for "getSchema" and "getAllSchemas" requests', () => { new JSONSchemaSelection(service, new SettingsState(), connection); - expect(connection.onRequest).calledWith(SchemaSelectionRequests.getSchema); - expect(connection.onRequest).calledWith(SchemaSelectionRequests.getAllSchemas); + assert.ok( + onRequest.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [SchemaSelectionRequests.getSchema])) + ); + assert.ok( + onRequest.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [SchemaSelectionRequests.getAllSchemas])) + ); }); it('getAllSchemas should return all schemas', async () => { @@ -105,7 +109,7 @@ describe('Schema Selection Handlers', () => { it('getSchemas should return an inline $schema', async () => { const schemaUri = 'https://some.com/inline.json'; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schemaUri) { return Promise.resolve( JSON.stringify({ @@ -143,11 +147,12 @@ describe('Schema Selection Handlers', () => { versions: undefined, }, ]); - expect(requestServiceMock).calledOnceWith(schemaUri); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), [schemaUri]); }); it('getSchemas should not resolve schema references', async () => { - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'https://some.com/some.json') { return Promise.resolve( JSON.stringify({ @@ -180,8 +185,12 @@ describe('Schema Selection Handlers', () => { description: 'Schema description', versions: undefined, }); - expect(requestServiceMock).calledOnceWith('https://some.com/some.json'); - expect(requestServiceMock).not.calledWith('https://some.com/ref.json'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://some.com/some.json']); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), ['https://some.com/ref.json'])), + false + ); }); it('getSchemas should use registered schema metadata without loading schema content', async () => { @@ -212,7 +221,7 @@ describe('Schema Selection Handlers', () => { description: 'Schema description', versions, }); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('getSchemas should handle empty schemas', async () => { diff --git a/test/schemaValidation.test.ts b/test/schemaValidation.test.ts index b540d3008..928885440 100644 --- a/test/schemaValidation.test.ts +++ b/test/schemaValidation.test.ts @@ -5,7 +5,7 @@ import { describe, it, before, after, afterEach } from 'node:test'; import type { TestCustomSchemaProvider } from './utils/testHelper.js'; -import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; +import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument, getDiagnosticMessage } from './utils/testHelper.js'; import { createDiagnosticWithData, createExpectedError } from './utils/verifyError.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import { @@ -474,11 +474,11 @@ describe('Validation Tests', () => { }); const result = await parseSetup('prop: "tes "'); assert.equal(result.length, 1); - assert.ok(result[0].message.startsWith('String does not match the pattern')); + assert.ok(getDiagnosticMessage(result[0]).startsWith('String does not match the pattern')); assert.deepEqual( result[0], createDiagnosticWithData( - result[0].message, + getDiagnosticMessage(result[0]), 0, 6, 0, @@ -1168,7 +1168,7 @@ obj: const content = 'ImageId: !FindInMap [AWSRegionArch2AMI, !Ref "AWS::Region", HVM64]'; const result = await parseSetup(content); assert.equal(result.length, 1); - assert.ok(result[0].message.includes('Incorrect type. Expected "string".')); + assert.ok(getDiagnosticMessage(result[0]).includes('Incorrect type. Expected "string".')); }); }); @@ -2140,7 +2140,7 @@ spec: x: A `; const result = await parseSetup(yaml, 'file:///root.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2169,7 +2169,7 @@ x: A x: A `; const result = await parseSetup(yaml, 'file:///nested-base.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2200,7 +2200,7 @@ x: A x: A `; const result = await parseSetup(yaml, 'file:///embedded-resource.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('String is shorter than the minimum length of 2.'); }); @@ -2225,7 +2225,7 @@ x: A pkg: 123 `; const result = await parseSetup(yaml, 'file:///baseuri-ok.schema.json'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result[0].message).to.include('Incorrect type.'); }); @@ -2244,7 +2244,11 @@ pkg: 123 `; const result = await parseSetup(yaml, 'file:///baseuri-fail.schema.json'); expect(result).to.not.be.empty; - expect(result.some((d) => /Problems loading reference/i.test(d.message) && /No content/i.test(d.message))).to.eq(true); + expect( + result.some( + (d) => /Problems loading reference/i.test(getDiagnosticMessage(d)) && /No content/i.test(getDiagnosticMessage(d)) + ) + ).to.eq(true); }); it('root $id ending in the loaded schema filename should not break embedded resource refs', async () => { @@ -2278,7 +2282,7 @@ option: suboption: 1 `; const result = await parseSetup(yaml, 'file:///validated.yaml'); - expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(d.message))).to.eq(false); + expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('Incorrect type. Expected "string".'); }); @@ -2318,8 +2322,8 @@ option: suboption: 1 `; const result = await parseSetup(yaml, 'file:///validated-local-sibling.yaml'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); - expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); + expect(result.some((d) => /\$ref '\/\$defs\/sub_options'/.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('Incorrect type. Expected "string".'); }); @@ -2357,7 +2361,7 @@ option: option: local `; const result = await parseSetup(yaml, 'file:///validated-embedded-precedence.yaml'); - expect(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false); + expect(result.some((d) => /Problems loading reference/i.test(getDiagnosticMessage(d)))).to.eq(false); expect(result).to.have.length(1); expect(result[0].message).to.include('embedded'); }); diff --git a/test/settingsHandlers.test.ts b/test/settingsHandlers.test.ts index 54e624dd9..e52ec2cc6 100644 --- a/test/settingsHandlers.test.ts +++ b/test/settingsHandlers.test.ts @@ -3,20 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; import request from 'request-light'; -import type { SinonMock, SinonStub, SinonStubbedInstance } from 'sinon'; -import { createSandbox, spy, stub } from 'sinon'; -import sinonChai from 'sinon-chai'; import type { Connection, RemoteClient, RemoteWorkspace } from 'vscode-languageserver'; import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; import type { LanguageService, LanguageSettings, SchemaConfiguration } from '../src/index.js'; import { SchemaPriority } from '../src/index.js'; import { SettingsHandler } from '../src/languageserver/handlers/settingsHandlers.js'; -import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; +import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; import { EMPTY_SCHEMA_URL } from '../src/languageservice/utils/schemaUrls.js'; import type { Telemetry } from '../src/languageservice/telemetry.js'; import { SettingsState } from '../src/yamlSettings.js'; @@ -26,37 +25,36 @@ import { setupSchemaIDTextDocument, setupTextDocument, } from './utils/testHelper.js'; -import { TestWorkspace } from './utils/testsTypes.js'; const expect = chai.expect; -chai.use(sinonChai); describe('Settings Handlers Tests', () => { - const sandbox = createSandbox(); const connection: Connection = {} as Connection; - let workspaceStub: SinonStubbedInstance; + let workspaceStub: { getConfiguration: Mock }; + let register: Mock; let languageService: LanguageService; let settingsState: SettingsState; - let validationHandler: SinonMock; - let xhrStub: SinonStub; + let validationHandler: Pick; + let xhrStub: Mock; beforeEach(() => { - workspaceStub = sandbox.createStubInstance(TestWorkspace); + workspaceStub = { getConfiguration: mock.fn() }; connection.workspace = workspaceStub as unknown as RemoteWorkspace; - connection.onDidChangeConfiguration = sandbox.mock(); + connection.onDidChangeConfiguration = mock.fn(); connection.client = {} as RemoteClient; - connection.client.register = sandbox.mock(); + register = mock.fn(); + connection.client.register = register; const languageServerSetup = setupLanguageService({}); languageService = languageServerSetup.languageService; settingsState = new SettingsState(); - validationHandler = sandbox.mock(ValidationHandler); - xhrStub = sandbox.stub(request, 'xhr'); - const sendRequest = sandbox.fake(); + validationHandler = { validate: mock.fn() }; + xhrStub = mock.method(request, 'xhr', () => undefined); + const sendRequest = mock.fn(); connection.sendRequest = sendRequest; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should not register configuration notification handler if client not supports dynamic handlers', () => { @@ -71,7 +69,7 @@ describe('Settings Handlers Tests', () => { ); settingsHandler.registerHandlers(); - expect(connection.client.register).not.called; + assert.equal(register.mock.callCount(), 0); }); it('should register configuration notification handler only if client supports dynamic handlers', () => { @@ -86,23 +84,28 @@ describe('Settings Handlers Tests', () => { ); settingsHandler.registerHandlers(); - expect(connection.client.register).calledOnce; + assert.equal(register.mock.callCount(), 1); }); it('should request CodeLens refresh after schema settings update if client supports it', async () => { settingsState.hasCodeLensRefreshSupport = true; - const sendRequest = sandbox.stub().resolves(); + const sendRequest = mock.fn(() => Promise.resolve(undefined)); connection.sendRequest = sendRequest; - workspaceStub.getConfiguration.onFirstCall().resolves([{ schemaStore: { enable: false } }, {}, {}, {}, {}]); - workspaceStub.getConfiguration - .onSecondCall() - .resolves([ - { schemas: { 'https://example.com/schema.json': 'test.yaml' }, schemaStore: { enable: false } }, - {}, - {}, - {}, - {}, - ]); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ schemaStore: { enable: false } }, {}, {}, {}, {}]), + 0 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => + Promise.resolve([ + { schemas: { 'https://example.com/schema.json': 'test.yaml' }, schemaStore: { enable: false } }, + {}, + {}, + {}, + {}, + ]), + 1 + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -112,19 +115,23 @@ describe('Settings Handlers Tests', () => { ); await settingsHandler.pullConfiguration(); await settingsHandler.pullConfiguration(); - expect(sendRequest).calledOnceWithExactly(CodeLensRefreshRequest.type); + assert.equal(sendRequest.mock.callCount(), 1); + assert.deepEqual(sendRequest.mock.calls[0].arguments, [CodeLensRefreshRequest.type]); }); it('should not request CodeLens refresh when only non-schema settings update', async () => { settingsState.hasCodeLensRefreshSupport = true; - const sendRequest = sandbox.stub().resolves(); + const sendRequest = mock.fn(() => Promise.resolve(undefined)); connection.sendRequest = sendRequest; const yamlSettings = { schemas: { 'https://example.com/schema.json': 'test.yaml' }, schemaStore: { enable: false }, }; - workspaceStub.getConfiguration.onFirstCall().resolves([yamlSettings, {}, {}, {}, {}]); - workspaceStub.getConfiguration.onSecondCall().resolves([{ ...yamlSettings, keyOrdering: true }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementationOnce(() => Promise.resolve([yamlSettings, {}, {}, {}, {}]), 0); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ ...yamlSettings, keyOrdering: true }, {}, {}, {}, {}]), + 1 + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -134,7 +141,7 @@ describe('Settings Handlers Tests', () => { ); await settingsHandler.pullConfiguration(); await settingsHandler.pullConfiguration(); - expect(sendRequest).not.called; + assert.equal(sendRequest.mock.callCount(), 0); }); describe('Settings for YAML style should ', () => { @@ -146,7 +153,9 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{ style: { flowMapping: 'forbid', flowSequence: 'forbid' } }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ style: { flowMapping: 'forbid', flowSequence: 'forbid' } }, {}, {}, {}, {}]) + ); await settingsHandler.pullConfiguration(); expect(settingsState.style).to.exist; @@ -161,7 +170,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); await settingsHandler.pullConfiguration(); expect(settingsState.style).to.exist; @@ -179,7 +188,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{ keyOrdering: true }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ keyOrdering: true }, {}, {}, {}, {}])); await settingsHandler.pullConfiguration(); expect(settingsState.keyOrdering).to.exist; @@ -193,7 +202,7 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); await settingsHandler.pullConfiguration(); expect(settingsState.style).to.exist; @@ -211,11 +220,14 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); - workspaceStub.getConfiguration - .onFirstCall() - .resolves([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]) - .onSecondCall() - .resolves([{ kubernetesVersion: 'v1.37.2' }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]), + 0 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: 'v1.37.2' }, {}, {}, {}, {}]), + 1 + ); await settingsHandler.pullConfiguration(); expect(settingsState.kubernetesVersion).to.equal('v1.36.1'); @@ -232,13 +244,15 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration - .onFirstCall() - .resolves([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]) - .onSecondCall() - .resolves([{ kubernetesVersion: 'invalid' }, {}, {}, {}, {}]) - .onThirdCall() - .resolves([{}, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: '1.36.1' }, {}, {}, {}, {}]), + 0 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce( + () => Promise.resolve([{ kubernetesVersion: 'invalid' }, {}, {}, {}, {}]), + 1 + ); + workspaceStub.getConfiguration.mock.mockImplementationOnce(() => Promise.resolve([{}, {}, {}, {}, {}]), 2); await settingsHandler.pullConfiguration(); expect(settingsState.kubernetesVersion).to.equal('v1.36.1'); @@ -255,8 +269,12 @@ describe('Settings Handlers Tests', () => { it('should include patterns with nonstandard extensions', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "Butane config schema", "description": "Schema to validate butane files for Fedora CoreOS", @@ -265,7 +283,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/Relativ-IT/Butane-Schemas/Release/Butane-Schema.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -273,10 +292,10 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://raw.githubusercontent.com/Relativ-IT/Butane-Schemas/Release/Butane-Schema.json', fileMatch: ['*.bu'], @@ -289,8 +308,12 @@ describe('Settings Handlers Tests', () => { it('should include extensionless patterns', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "clang-format (.clang-format)", "description": "yaml clang-format config", @@ -299,7 +322,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://www.schemastore.org/clang-format-21.x.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -307,12 +331,12 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://www.schemastore.org/clang-format-21.x.json', fileMatch: ['.clang-format'], @@ -325,8 +349,12 @@ describe('Settings Handlers Tests', () => { it('should exclude JSON file extensions', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "JSON config schema", "description": "Schema to validate JSON config files", @@ -337,7 +365,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://example.com/config.schema.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -345,24 +374,29 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings.some((schema) => schema.uri === 'https://example.com/config.schema.json')).to.be .false; }); it('SettingsHandler should include schemas without file matches as selectable schemas', async () => { const languageServerSetup = setupLanguageService({}); const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": "Traefik v3", "description": "Traefik v3 YAML configuration file", "url": "https://www.schemastore.org/traefik-v3.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -370,10 +404,10 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://www.schemastore.org/traefik-v3.json', fileMatch: [], @@ -390,8 +424,12 @@ describe('Settings Handlers Tests', () => { const languageService = languageServerSetup.languageService; - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -400,7 +438,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const settingsHandler = new SettingsHandler( connection, languageService as unknown as LanguageService, @@ -408,10 +447,10 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); - const configureSpy = stub(languageService, 'configure'); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); + const configureSpy = mock.method(languageService, 'configure', () => undefined); await settingsHandler.pullConfiguration(); - configureSpy.restore(); + configureSpy.mock.restore(); expect(settingsState.schemaStoreSettings).deep.include({ uri: 'https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json', fileMatch: ['.adonisrc.yaml'], @@ -426,7 +465,7 @@ describe('Settings Handlers Tests', () => { const testSchemaFileMatch = ['foo/*.yml']; async function configureSchemaSettingsTest(): Promise { - const telemetry = { send: stub(), sendError: stub() } as unknown as Telemetry; + const telemetry = { send: mock.fn(), sendError: mock.fn() } as unknown as Telemetry; const settingsHandler = new SettingsHandler( connection, languageService, @@ -434,20 +473,20 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, telemetry ); - const configureSpy = spy(languageService, 'configure'); + const configureSpy = mock.method(languageService, 'configure'); await settingsHandler.pullConfiguration(); - configureSpy.restore(); - return configureSpy.args[0][0]; + configureSpy.mock.restore(); + return configureSpy.mock.calls[0].arguments[0]; } it('Schema Settings should normalize absolute local paths', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const absoluteSchemaPath = '/Users/test/schemas/schema.json'; const schemas = {}; schemas[absoluteSchemaPath] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -459,14 +498,14 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should preserve fragments when normalizing absolute local paths', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const absoluteSchemaPath = '/Users/test/schemas/schema.json'; const schemaUri = `${absoluteSchemaPath}#/definitions/foo`; const schemas = {}; schemas[schemaUri] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -478,13 +517,13 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should preserve remote schema URLs', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemaUri = 'https://example.com/schemas/schema.json#/definitions/foo'; const schemas = {}; schemas[schemaUri] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -496,14 +535,14 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should treat direct Kubernetes standalone-strict/all.json URLs as Kubernetes associations', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemaUri = 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.32.9-standalone-strict/all.json'; const schemas = {}; schemas[schemaUri] = ['*.yaml']; - workspaceStub.getConfiguration.resolves([{ schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -516,16 +555,16 @@ describe('Settings Handlers Tests', () => { }); it('Schema Settings should normalize multiple absolute local paths for the same file', async () => { - xhrStub.resolves({ - responseText: '{"schemas":[]}', - }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemaPath1 = '/Users/test/schemas/schema1.json'; const schemaPath2 = '/Users/test/schemas/schema2.json'; const fileMatch = ['asdf.yaml']; const schemas = {}; schemas[schemaPath1] = fileMatch; schemas[schemaPath2] = fileMatch; - workspaceStub.getConfiguration.resolves([{ schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas }, {}, {}, {}])); const configureSpy = await configureSchemaSettingsTest(); expect(configureSpy.schemas).deep.include({ @@ -555,15 +594,19 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - const configureSpy = spy(languageService, 'configure'); + const configureSpy = mock.method(languageService, 'configure'); await settingsHandler.pullConfiguration(); - configureSpy.restore(); - return configureSpy.args[0][0]; + configureSpy.mock.restore(); + return configureSpy.mock.calls[0].arguments[0]; } it('Schema Settings should have a priority', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -572,10 +615,11 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const schemas = {}; schemas[testSchemaURI] = testSchemaFileMatch; - workspaceStub.getConfiguration.resolves([{ schemas: schemas }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{ schemas: schemas }, {}, {}, {}])); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -587,8 +631,12 @@ describe('Settings Handlers Tests', () => { }); it('SchemaDetectionDisabled should have a priority', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -597,9 +645,12 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const disabledSchemaFileMatch = ['foo/*.yml']; - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]) + ); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -611,8 +662,12 @@ describe('Settings Handlers Tests', () => { }); it('SchemaDetectionDisabled should accept a single file match string', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -621,9 +676,12 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); const disabledSchemaFileMatch = 'foo/*.yml'; - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: disabledSchemaFileMatch }, {}, {}, {}, {}]) + ); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -635,8 +693,12 @@ describe('Settings Handlers Tests', () => { }); it('Schema Associations should have a priority when schema association is an array', async () => { - xhrStub.resolves({ - responseText: `{"schemas": [ + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: `{"schemas": [ { "name": ".adonisrc.json", "description": "AdonisJS configuration file", @@ -645,7 +707,8 @@ describe('Settings Handlers Tests', () => { ], "url": "https://raw.githubusercontent.com/adonisjs/application/master/adonisrc.schema.json" }]}`, - }); + }) + ); settingsState.schemaAssociations = [ { fileMatch: testSchemaFileMatch, @@ -653,7 +716,7 @@ describe('Settings Handlers Tests', () => { }, ] as SchemaConfiguration[]; - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -668,7 +731,7 @@ describe('Settings Handlers Tests', () => { settingsState.schemaAssociations = { [testSchemaURI]: testSchemaFileMatch, } as Record; - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); const configureSpy = await configureSchemaPriorityTest(); expect(configureSpy.schemas).deep.include({ @@ -694,10 +757,14 @@ describe('Settings Handlers Tests', () => { const schemaUri = 'file:///schemas/schema-detection-disable-settings.json'; const schemaProvider = TestCustomSchemaProvider.instance(); schemaProvider.addSchemaWithUri('disableSchemaDetection-settings', schemaUri, restrictiveSchema); - xhrStub.resolves({ responseText: '{"schemas":[]}' }); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); const schemas = {}; schemas[schemaUri] = 'test.yaml'; - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: ['test.yaml'], schemas }, {}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: ['test.yaml'], schemas }, {}, {}, {}, {}]) + ); try { await new SettingsHandler( @@ -721,19 +788,26 @@ describe('Settings Handlers Tests', () => { const githubWorkflowFileMatch = ['.github/workflows/*.yml']; const schemaProvider = TestCustomSchemaProvider.instance(); schemaProvider.addSchemaWithUri('disableSchemaDetection-github-actions', schemaUri, restrictiveSchema); - xhrStub.resolves({ - responseText: JSON.stringify({ - schemas: [ - { - name: 'GitHub Workflow', - description: 'GitHub Actions workflow schema', - fileMatch: githubWorkflowFileMatch, - url: schemaUri, - }, - ], - }), - }); - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: githubWorkflowFileMatch }, {}, {}, {}, {}]); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ + status: 200, + headers: {}, + body: undefined, + responseText: JSON.stringify({ + schemas: [ + { + name: 'GitHub Workflow', + description: 'GitHub Actions workflow schema', + fileMatch: githubWorkflowFileMatch, + url: schemaUri, + }, + ], + }), + }) + ); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: githubWorkflowFileMatch }, {}, {}, {}, {}]) + ); try { await new SettingsHandler( @@ -759,8 +833,12 @@ describe('Settings Handlers Tests', () => { const schemaUri = 'file:///schemas/schema-detection-disable-modeline.json'; const schemaProvider = TestCustomSchemaProvider.instance(); schemaProvider.addSchemaWithUri('disableSchemaDetection-modeline', schemaUri, restrictiveSchema); - xhrStub.resolves({ responseText: '{"schemas":[]}' }); - workspaceStub.getConfiguration.resolves([{ disableSchemaDetection: ['test.yaml'] }, {}, {}, {}, {}]); + xhrStub.mock.mockImplementation(() => + Promise.resolve({ status: 200, headers: {}, body: undefined, responseText: '{"schemas":[]}' }) + ); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ disableSchemaDetection: ['test.yaml'] }, {}, {}, {}, {}]) + ); try { await new SettingsHandler( @@ -793,15 +871,13 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => Promise.resolve([{}, {}, {}, {}])); await settingsHandler.pullConfiguration(); - expect(workspaceStub.getConfiguration).calledOnceWith([ - { section: 'yaml' }, - { section: 'http' }, - { section: '[yaml]' }, - { section: 'editor' }, + assert.equal(workspaceStub.getConfiguration.mock.callCount(), 1); + assert.deepEqual(workspaceStub.getConfiguration.mock.calls[0].arguments.slice(0, 1), [ + [{ section: 'yaml' }, { section: 'http' }, { section: '[yaml]' }, { section: 'editor' }], ]); }); it('should set schemaStoreSettings to empty when schemaStore is disabled', async () => { @@ -817,11 +893,13 @@ describe('Settings Handlers Tests', () => { {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{ schemaStore: { enable: false, url: 'http://shouldnot.activate' } }, {}, {}, {}]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{ schemaStore: { enable: false, url: 'http://shouldnot.activate' } }, {}, {}, {}]) + ); // const configureSpy = spy(languageService, 'configure'); await settingsHandler.pullConfiguration(); - // configureSpy.restore(); + // configureSpy.mock.restore(); expect(settingsState.schemaStoreEnabled).to.be.false; expect(settingsState.schemaStoreSettings).to.be.empty; }); @@ -833,14 +911,14 @@ describe('Settings Handlers Tests', () => { validationHandler as unknown as ValidationHandler, {} as Telemetry ); - workspaceStub.getConfiguration.resolves([{}, {}, {}, { tabSize: 4, detectIndentation: false }]); + workspaceStub.getConfiguration.mock.mockImplementation(() => + Promise.resolve([{}, {}, {}, { tabSize: 4, detectIndentation: false }]) + ); await settingsHandler.pullConfiguration(); - expect(workspaceStub.getConfiguration).calledOnceWith([ - { section: 'yaml' }, - { section: 'http' }, - { section: '[yaml]' }, - { section: 'editor' }, + assert.equal(workspaceStub.getConfiguration.mock.callCount(), 1); + assert.deepEqual(workspaceStub.getConfiguration.mock.calls[0].arguments.slice(0, 1), [ + [{ section: 'yaml' }, { section: 'http' }, { section: '[yaml]' }, { section: 'editor' }], ]); }); }); diff --git a/test/telemetry.test.ts b/test/telemetry.test.ts index 87e78f87b..56ac2a725 100644 --- a/test/telemetry.test.ts +++ b/test/telemetry.test.ts @@ -3,41 +3,35 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import type { SinonStubbedInstance } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; -import * as chai from 'chai'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import { checkSchemaURI } from '../src/languageservice/utils/schemaUrls.js'; -import { TelemetryImpl } from '../src/languageserver/telemetry.js'; +import type { Telemetry } from '../src/languageservice/telemetry.js'; import { URI } from 'vscode-uri'; -import type { Connection } from 'vscode-languageserver'; - -const expect = chai.expect; -chai.use(sinonChai); describe('Telemetry Tests', () => { - const sandbox = createSandbox(); - - let telemetry: SinonStubbedInstance; + let telemetry: Telemetry & { send: Mock }; beforeEach(() => { - const telemetryInstance = new TelemetryImpl({} as Connection); - telemetry = sandbox.stub(telemetryInstance); + telemetry = { send: mock.fn(), sendError: mock.fn(), sendTrack: mock.fn() }; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); describe('Kubernetos schema mapping', () => { it('should not report if schema is not k8s', () => { checkSchemaURI([], URI.parse('file:///some/path'), 'file:///some/path/to/schema.json', telemetry); - expect(telemetry.send).not.called; + assert.equal(telemetry.send.mock.callCount(), 0); }); it('should report if schema is k8s', () => { checkSchemaURI([], URI.parse('file:///some/path'), 'kubernetes', telemetry); - expect(telemetry.send).calledOnceWith({ name: 'yaml.schema.configured', properties: { kubernetes: true } }); + assert.equal(telemetry.send.mock.callCount(), 1); + assert.deepEqual(telemetry.send.mock.calls[0].arguments.slice(0, 1), [ + { name: 'yaml.schema.configured', properties: { kubernetes: true } }, + ]); }); }); }); diff --git a/test/utils/testHelper.ts b/test/utils/testHelper.ts index e97e7a326..ed4975d1b 100644 --- a/test/utils/testHelper.ts +++ b/test/utils/testHelper.ts @@ -6,8 +6,8 @@ import { promises as fs } from 'fs'; import { ClientCapabilities } from '../../src/languageservice/jsonLanguageTypes.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; -import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node.js'; -import { createConnection } from 'vscode-languageserver/node.js'; +import type { Connection, ClientCapabilities as LSPClientCapabilities } from 'vscode-languageserver/node'; +import { createConnection } from 'vscode-languageserver/node'; import type { LanguageService, LanguageSettings } from '../../src/index.js'; import type { LanguageHandlers } from '../../src/languageserver/handlers/languageHandlers.js'; import type { ValidationHandler } from '../../src/languageserver/handlers/validationHandlers.js'; @@ -19,6 +19,11 @@ import { YAMLServerInit } from '../../src/yamlServerInit.js'; import { SettingsState } from '../../src/yamlSettings.js'; import { TestTelemetry } from './testsTypes.js'; import * as path from 'path'; +import type { Diagnostic } from 'vscode-languageserver-types'; + +export function getDiagnosticMessage(diagnostic: Diagnostic): string { + return typeof diagnostic.message === 'string' ? diagnostic.message : diagnostic.message.value; +} export function toFsPath(str: unknown): string { if (typeof str !== 'string') { diff --git a/test/utils/testsTypes.ts b/test/utils/testsTypes.ts index cf874775a..1e5ba071a 100644 --- a/test/utils/testsTypes.ts +++ b/test/utils/testsTypes.ts @@ -25,6 +25,7 @@ import type { TelemetryEvent } from '../../src/languageservice/telemetry.js'; /* eslint-disable @typescript-eslint/no-unused-vars */ export class TestWorkspace implements RemoteWorkspace { connection: Connection; + textDocumentContent: RemoteWorkspace['textDocumentContent']; applyEdit(paramOrEdit: ApplyWorkspaceEditParams | WorkspaceEdit): Promise { throw new Error('Method not implemented.'); } diff --git a/test/yaml-documents.test.ts b/test/yaml-documents.test.ts index 9688f4028..1ae4f20a0 100644 --- a/test/yaml-documents.test.ts +++ b/test/yaml-documents.test.ts @@ -3,44 +3,42 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; -import type { SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; import * as chai from 'chai'; import { YamlDocuments } from '../src/languageservice/parser/yaml-documents.js'; import { setupTextDocument } from './utils/testHelper.js'; import type { ParserOptions } from '../src/languageservice/parser/yamlParser07.js'; +import { parse } from '../src/languageservice/parser/yamlParser07.js'; import { TextDocument } from 'vscode-languageserver-textdocument'; import type { Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml'; import { isMap, isScalar, isSeq } from 'yaml'; import { TextBuffer } from '../src/languageservice/utils/textBuffer.js'; const expect = chai.expect; -chai.use(sinonChai); describe('YAML Documents', () => { - const sandbox = createSandbox(); describe('YAML Documents Cache Tests', () => { - let parseStub: SinonStub; + let parseStub: Mock; beforeEach(() => { - parseStub = sandbox.stub(); + parseStub = mock.fn(); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should cache parsed document', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.returns({}); + parseStub.mock.mockImplementation(() => parse('foo: bar')); const result1 = cache.getYamlDocument(doc); const result2 = cache.getYamlDocument(doc); - expect(parseStub).calledOnce; + assert.equal(parseStub.mock.callCount(), 1); expect(result1).to.be.equal(result2); }); @@ -48,40 +46,40 @@ describe('YAML Documents', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.onFirstCall().returns({}); - parseStub.onSecondCall().returns({ foo: 'bar' }); + parseStub.mock.mockImplementationOnce(() => parse('foo: bar'), 0); + parseStub.mock.mockImplementationOnce(() => parse('foo: baz'), 1); const result1 = cache.getYamlDocument(doc); TextDocument.update(doc, [], 2); const result2 = cache.getYamlDocument(doc); - expect(parseStub).calledTwice; + assert.equal(parseStub.mock.callCount(), 2); expect(result1).to.be.not.equal(result2); }); it('should invalidate cache if custom tags provided', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.onFirstCall().returns({}); - parseStub.onSecondCall().returns({ foo: 'bar' }); + parseStub.mock.mockImplementationOnce(() => parse('foo: bar'), 0); + parseStub.mock.mockImplementationOnce(() => parse('foo: baz'), 1); const result1 = cache.getYamlDocument(doc); const result2 = cache.getYamlDocument(doc, getParserOptions(['some'])); - expect(parseStub).calledTwice; + assert.equal(parseStub.mock.callCount(), 2); expect(result1).to.not.equal(result2); }); it('should use cache if custom tags are same', () => { const cache = new YamlDocuments(parseStub); const doc = setupTextDocument('foo: bar'); - parseStub.onFirstCall().returns({}); - parseStub.onSecondCall().returns({ foo: 'bar' }); + parseStub.mock.mockImplementationOnce(() => parse('foo: bar'), 0); + parseStub.mock.mockImplementationOnce(() => parse('foo: baz'), 1); const result1 = cache.getYamlDocument(doc, getParserOptions(['some'])); const result2 = cache.getYamlDocument(doc, getParserOptions(['some'])); - expect(parseStub).calledOnce; + assert.equal(parseStub.mock.callCount(), 1); expect(result1).to.be.equal(result2); }); }); @@ -93,7 +91,7 @@ describe('YAML Documents', () => { }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('Get node from position: key', () => { diff --git a/test/yamlCodeActions.test.ts b/test/yamlCodeActions.test.ts index 5f1753330..b62f85b15 100644 --- a/test/yamlCodeActions.test.ts +++ b/test/yamlCodeActions.test.ts @@ -3,10 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach } from 'node:test'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; import * as chai from 'chai'; import { YamlCodeActions } from '../src/languageservice/services/yamlCodeActions.js'; import { @@ -28,23 +26,16 @@ import type { LanguageSettings } from '../src/index.js'; import { ErrorCode } from '../src/languageservice/jsonLanguageTypes.js'; const expect = chai.expect; -chai.use(sinonChai); const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; const JSON_SCHEMA2_LOCAL = 'file://some/path/schema2.json'; describe('CodeActions Tests', () => { - const sandbox = createSandbox(); - let clientCapabilities: ClientCapabilities; beforeEach(() => { clientCapabilities = {}; }); - afterEach(() => { - sandbox.restore(); - }); - describe('JumpToSchema tests', () => { it('should not provide any actions if there are no diagnostics', () => { const doc = setupTextDocument(''); diff --git a/test/yamlCodeLens.test.ts b/test/yamlCodeLens.test.ts index c7f93b41b..4a8ee8ed4 100644 --- a/test/yamlCodeLens.test.ts +++ b/test/yamlCodeLens.test.ts @@ -3,20 +3,18 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; -import type { SinonStubbedInstance } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; import { YamlCodeLens } from '../src/languageservice/services/yamlCodeLens.js'; -import { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; +import type { YAMLSchemaService } from '../src/languageservice/services/yamlSchemaService.js'; import { setupTextDocument } from './utils/testHelper.js'; import type { JSONSchema } from '../src/languageservice/jsonSchema.js'; import type { Command } from 'vscode-languageserver-protocol'; import { CodeLens, Range } from 'vscode-languageserver-protocol'; import type { Connection } from 'vscode-languageserver'; import { YamlCommands } from '../src/commands.js'; -import { TelemetryImpl } from '../src/languageserver/telemetry.js'; import type { Telemetry } from '../src/languageservice/telemetry.js'; import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers.js'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; @@ -25,22 +23,18 @@ import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings.js'; import type { SingleYAMLDocument } from '../src/languageservice/parser/yaml-documents.js'; const expect = chai.expect; -chai.use(sinonChai); describe('YAML CodeLens', () => { - const sandbox = createSandbox(); - let yamlSchemaService: SinonStubbedInstance; - let telemetryStub: SinonStubbedInstance; + let yamlSchemaService: { getSchemaForResource: Mock }; let telemetry: Telemetry; beforeEach(() => { - yamlSchemaService = sandbox.createStubInstance(YAMLSchemaService); - telemetryStub = sandbox.createStubInstance(TelemetryImpl); - telemetry = telemetryStub; + yamlSchemaService = { getSchemaForResource: mock.fn() }; + telemetry = { send: mock.fn(), sendError: mock.fn(), sendTrack: mock.fn() }; }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); function createCommand(title: string, command: string, arg: string): Command { @@ -66,7 +60,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).is.not.empty; @@ -81,7 +75,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result[0].range).is.deep.equal(Range.create(0, 0, 0, 0)); @@ -102,7 +96,7 @@ describe('YAML CodeLens', () => { resolveConfiguration = resolve; }); - const getCodeLensStub = sandbox.stub().returns([expected]); + const getCodeLensStub = mock.fn(() => [expected]); const languageService = { getCodeLens: getCodeLensStub, } as unknown as LanguageService; @@ -120,11 +114,12 @@ describe('YAML CodeLens', () => { await Promise.resolve(); expect(settled).to.be.false; - expect(getCodeLensStub).not.called; + assert.equal(getCodeLensStub.mock.callCount(), 0); resolveConfiguration(); const result = await response; - expect(getCodeLensStub).calledOnceWithExactly(doc); + assert.equal(getCodeLensStub.mock.callCount(), 1); + assert.deepEqual(getCodeLensStub.mock.calls[0].arguments, [doc]); expect(result).deep.equal([expected]); }); @@ -133,7 +128,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result.length).to.eq(2); @@ -152,7 +147,7 @@ describe('YAML CodeLens', () => { const schema: JSONSchema = { url: 'some://url/to/schema.json', }; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); @@ -168,8 +163,14 @@ describe('YAML CodeLens', () => { const podSchemaUrl = 'https://example.com/v1.36.1-standalone-strict/_definitions.json#/definitions/io.k8s.api.core.v1.Pod'; const policySchemaUrl = 'https://example.com/v1.36.1-standalone-strict/_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingAdmissionPolicy'; - yamlSchemaService.getSchemaForResource.onFirstCall().resolves(createResolvedSchema({ url: podSchemaUrl })); - yamlSchemaService.getSchemaForResource.onSecondCall().resolves(createResolvedSchema({ url: policySchemaUrl })); + yamlSchemaService.getSchemaForResource.mock.mockImplementationOnce( + () => Promise.resolve(createResolvedSchema({ url: podSchemaUrl })), + 0 + ); + yamlSchemaService.getSchemaForResource.mock.mockImplementationOnce( + () => Promise.resolve(createResolvedSchema({ url: policySchemaUrl })), + 1 + ); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); @@ -178,14 +179,16 @@ describe('YAML CodeLens', () => { createCodeLens('Pod (Kubernetes v1.36.1)', YamlCommands.JUMP_TO_SCHEMA, podSchemaUrl), createCodeLens('MutatingAdmissionPolicy (Kubernetes v1.36.1)', YamlCommands.JUMP_TO_SCHEMA, policySchemaUrl, 3), ]); - expect((yamlSchemaService.getSchemaForResource.firstCall.args[1] as SingleYAMLDocument).currentDocIndex).to.eq(0); - expect((yamlSchemaService.getSchemaForResource.secondCall.args[1] as SingleYAMLDocument).currentDocIndex).to.eq(1); + expect((yamlSchemaService.getSchemaForResource.mock.calls[0].arguments[1] as SingleYAMLDocument).currentDocIndex).to.eq(0); + expect((yamlSchemaService.getSchemaForResource.mock.calls[1].arguments[1] as SingleYAMLDocument).currentDocIndex).to.eq(1); }); it('should show the Kubernetes version for the generic all.json schema', async () => { const doc = setupTextDocument('apiVersion: v1\nkind: UnknownCoreResource'); const schemaUrl = 'https://example.com/v1.36.1-standalone-strict/all.json'; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema({ url: schemaUrl })); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => + Promise.resolve(createResolvedSchema({ url: schemaUrl })) + ); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).is.deep.equal([createCodeLens('Kubernetes v1.36.1', YamlCommands.JUMP_TO_SCHEMA, schemaUrl)]); @@ -197,7 +200,7 @@ describe('YAML CodeLens', () => { url: 'some://url/to/schema.json', title: 'fooBar', } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result[0].command).is.deep.equal( @@ -212,7 +215,7 @@ describe('YAML CodeLens', () => { title: 'fooBar', description: 'fooBarDescription', } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result[0].command).is.deep.equal( @@ -226,7 +229,7 @@ describe('YAML CodeLens', () => { url: 'https://json-schema.org/draft/2020-12/schema', title: 'JSON Schema Draft 2020-12', } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); @@ -252,7 +255,7 @@ describe('YAML CodeLens', () => { }, ], } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).has.length(2); @@ -274,7 +277,7 @@ describe('YAML CodeLens', () => { }, ], } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).has.length(2); @@ -296,7 +299,7 @@ describe('YAML CodeLens', () => { }, ], } as JSONSchema; - yamlSchemaService.getSchemaForResource.resolves(createResolvedSchema(schema)); + yamlSchemaService.getSchemaForResource.mock.mockImplementation(() => Promise.resolve(createResolvedSchema(schema))); const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry); const result = await codeLens.getCodeLens(doc); expect(result).has.length(2); diff --git a/test/yamlCommands.test.ts b/test/yamlCommands.test.ts index 3e3a90190..533fa142f 100644 --- a/test/yamlCommands.test.ts +++ b/test/yamlCommands.test.ts @@ -3,42 +3,38 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import { isDeepStrictEqual } from 'node:util'; +import assert from 'node:assert/strict'; -import type { SinonStub } from 'sinon'; -import { createSandbox, match } from 'sinon'; -import sinonChai from 'sinon-chai'; -import * as chai from 'chai'; import { registerCommands } from '../src/languageservice/services/yamlCommands.js'; import { commandExecutor } from '../src/languageserver/commandExecutor.js'; import type { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; -const expect = chai.expect; -chai.use(sinonChai); - describe('Yaml Commands', () => { const JSON_SCHEMA_LOCAL = 'file://some/path/schema.json'; - const sandbox = createSandbox(); - let commandExecutorStub: SinonStub; + let commandExecutorStub: Mock; beforeEach(() => { - commandExecutorStub = sandbox.stub(commandExecutor, 'registerCommand'); + commandExecutorStub = mock.method(commandExecutor, 'registerCommand', () => undefined); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('should register handler for "JumpToSchema" command', () => { registerCommands(commandExecutor, {} as Connection); - expect(commandExecutorStub).to.have.been.calledWithMatch(match('jumpToSchema'), match.func); + assert.equal(commandExecutorStub.mock.calls[0].arguments[0], 'jumpToSchema'); + assert.equal(typeof commandExecutorStub.mock.calls[0].arguments[1], 'function'); }); it('JumpToSchema handler should call "showDocument"', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([])); const connection = { window: { showDocument: showDocumentStub, @@ -47,16 +43,19 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1](JSON_SCHEMA_LOCAL); - expect(showDocumentStub).to.have.been.calledWith({ uri: JSON_SCHEMA_LOCAL, external: false, takeFocus: true }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [{ uri: JSON_SCHEMA_LOCAL, external: false, takeFocus: true }]) + ) + ); }); it('JumpToSchema handler should call "showDocument" with plain win path', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([])); const connection = { window: { showDocument: showDocumentStub, @@ -65,20 +64,25 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1]('a:\\some\\path\\to\\schema.json'); - expect(showDocumentStub).to.have.been.calledWith({ - uri: URI.file('a:\\some\\path\\to\\schema.json').toString(), - external: false, - takeFocus: true, - }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [ + { + uri: URI.file('a:\\some\\path\\to\\schema.json').toString(), + external: false, + takeFocus: true, + }, + ]) + ) + ); }); it('JumpToSchema handler should call "showDocument" with plain POSIX path', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([])); const connection = { window: { showDocument: showDocumentStub, @@ -87,20 +91,25 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1]('/some/path/to/schema.json'); - expect(showDocumentStub).to.have.been.calledWith({ - uri: URI.file('/some/path/to/schema.json').toString(), - external: false, - takeFocus: true, - }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [ + { + uri: URI.file('/some/path/to/schema.json').toString(), + external: false, + takeFocus: true, + }, + ]) + ) + ); }); it('JumpToSchema handler should call "showDocument" with custom web schema', async () => { - const showDocumentStub = sandbox.stub(); - const getWorkspaceFoldersStub = sandbox.stub().returns(Promise.resolve([{ uri: 'vscode-test:///root/' }])); + const showDocumentStub = mock.fn(async () => ({ success: true })); + const getWorkspaceFoldersStub = mock.fn(() => Promise.resolve([{ uri: 'vscode-test:///root/' }])); const connection = { window: { showDocument: showDocumentStub, @@ -109,14 +118,19 @@ describe('Yaml Commands', () => { getWorkspaceFolders: getWorkspaceFoldersStub, }, } as unknown as Connection; - showDocumentStub.resolves(true); registerCommands(commandExecutor, connection); - const arg = commandExecutorStub.args[0]; + const arg = commandExecutorStub.mock.calls[0].arguments; await arg[1]('my-file.json'); - expect(showDocumentStub).to.have.been.calledWith({ - uri: URI.parse('vscode-test:///root/my-file.json').toString(), - external: false, - takeFocus: true, - }); + assert.ok( + showDocumentStub.mock.calls.some((call) => + isDeepStrictEqual(call.arguments.slice(0, 1), [ + { + uri: URI.parse('vscode-test:///root/my-file.json').toString(), + external: false, + takeFocus: true, + }, + ]) + ) + ); }); }); diff --git a/test/yamlSchema.test.ts b/test/yamlSchema.test.ts index 6a65cc311..8ab499822 100644 --- a/test/yamlSchema.test.ts +++ b/test/yamlSchema.test.ts @@ -3,15 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import assert from 'node:assert/strict'; import * as SchemaService from '../src/languageservice/services/yamlSchemaService.js'; -import type { SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; import * as chai from 'chai'; -import sinonChai from 'sinon-chai'; const expect = chai.expect; -chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { @@ -20,18 +19,18 @@ const workspaceContext = { }; describe('YAML Schema', () => { - const sandbox = createSandbox(); - let requestServiceStub: SinonStub; + let requestServiceStub: Mock; beforeEach(() => { - requestServiceStub = sandbox.stub(); + requestServiceStub = mock.fn(); }); afterEach(() => { - sandbox.restore(); + mock.reset(); }); it('Loading yaml scheme', async () => { - requestServiceStub.resolves(`%YAML 1.2 + requestServiceStub.mock.mockImplementation(() => + Promise.resolve(`%YAML 1.2 --- properties: fooBar: @@ -39,10 +38,12 @@ properties: type: string type: array type: object -`); +`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('fooScheme.yaml'); - expect(requestServiceStub.calledOnceWith('fooScheme.yaml')); + assert.equal(requestServiceStub.mock.callCount(), 1); + assert.deepEqual(requestServiceStub.mock.calls[0].arguments.slice(0, 1), ['fooScheme.yaml']); expect(result.schema.properties['fooBar']).eql({ items: { type: 'string' }, type: 'array', @@ -50,7 +51,7 @@ type: object }); it('Error while loading yaml', async () => { - requestServiceStub.rejects(); + requestServiceStub.mock.mockImplementation(() => Promise.reject(new Error())); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('fooScheme.yaml'); expect(result.errors).length(1); @@ -58,7 +59,7 @@ type: object }); it('Error while loading yaml should keep the underlying reason', async () => { - requestServiceStub.rejects(new Error('Request failed with status code 429')); + requestServiceStub.mock.mockImplementation(() => Promise.reject(new Error('Request failed with status code 429'))); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -67,7 +68,7 @@ type: object }); it('Empty response while loading yaml should report no content', async () => { - requestServiceStub.resolves(''); + requestServiceStub.mock.mockImplementation(() => Promise.resolve('')); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -77,7 +78,9 @@ type: object it('Unreachable host should report the connection failure, not an empty reason', async () => { // request-light wraps connection errors as '. Error: ', and for // ECONNREFUSED the underlying message is empty - the reason must not collapse to '' - requestServiceStub.rejects(new Error('Unable to connect to https://example.com/fooScheme.json. Error: ')); + requestServiceStub.mock.mockImplementation(() => + Promise.reject(new Error('Unable to connect to https://example.com/fooScheme.json. Error: ')) + ); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -89,7 +92,7 @@ type: object it('Error with no message should fall back to the error code', async () => { const connectionError = new Error(''); (connectionError as Error & { code: string }).code = 'ECONNREFUSED'; - requestServiceStub.rejects(connectionError); + requestServiceStub.mock.mockImplementation(() => Promise.reject(connectionError)); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -98,7 +101,7 @@ type: object it('Non-Error rejection should still report its reason', async () => { // schemaRequestHandler rethrows the response body as a plain string, not an Error - requestServiceStub.callsFake(() => Promise.reject('Too Many Requests')); + requestServiceStub.mock.mockImplementation(() => Promise.reject('Too Many Requests')); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('https://example.com/fooScheme.json'); expect(result.errors).length(1); @@ -106,10 +109,13 @@ type: object }); it('Error while parsing yaml scheme', async () => { - requestServiceStub.resolves(`%464*&^^&*%@$&^##$`); + requestServiceStub.mock.mockImplementation(() => Promise.resolve(`%464*&^^&*%@$&^##$`)); const service = new SchemaService.YAMLSchemaService(requestServiceStub, workspaceContext); const result = await service.loadSchema('fooScheme.yaml'); - expect(requestServiceStub.calledOnceWith('fooScheme.yaml')); + assert.deepEqual( + requestServiceStub.mock.calls.map((call) => call.arguments), + [['fooScheme.yaml'], ['fooScheme.yaml']] + ); expect(result.errors).length(1); expect(result.errors[0].message).includes('Unable to parse content from'); }); diff --git a/test/yamlSchemaService.test.ts b/test/yamlSchemaService.test.ts index cd24dd7e3..378127940 100644 --- a/test/yamlSchemaService.test.ts +++ b/test/yamlSchemaService.test.ts @@ -3,13 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, beforeEach, afterEach } from 'node:test'; +import { describe, it, beforeEach, afterEach, mock } from 'node:test'; +import type { Mock } from 'node:test'; +import type { SchemaRequestService } from '../src/languageservice/yamlLanguageService.js'; +import { isDeepStrictEqual } from 'node:util'; +import assert from 'node:assert/strict'; import * as chai from 'chai'; import * as JSONC from 'jsonc-parser'; import * as path from 'path'; -import type { SinonFakeTimers, SinonSpy, SinonStub } from 'sinon'; -import { createSandbox } from 'sinon'; -import sinonChai from 'sinon-chai'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { URI } from 'vscode-uri'; import * as YAML from 'yaml'; @@ -19,12 +20,12 @@ import * as SchemaService from '../src/languageservice/services/yamlSchemaServic import { DEFAULT_KUBERNETES_SCHEMA_VERSION, getSchemaUrls } from '../src/languageservice/utils/schemaUrls.js'; import { SchemaPriority } from '../src/languageservice/yamlLanguageService.js'; import { SettingsState } from '../src/yamlSettings.js'; +import { getDiagnosticMessage } from './utils/testHelper.js'; const BASE_KUBERNETES_SCHEMA_URL = `https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/${DEFAULT_KUBERNETES_SCHEMA_VERSION}-standalone-strict/`; const KUBERNETES_SCHEMA_URL = BASE_KUBERNETES_SCHEMA_URL + 'all.json'; const expect = chai.expect; -chai.use(sinonChai); const workspaceContext = { resolveRelativePath: (relativePath: string, resource: string) => { return new URL(relativePath, resource).toString(); @@ -32,16 +33,15 @@ const workspaceContext = { }; describe('YAML Schema Service', () => { - const sandbox = createSandbox(); afterEach(() => { - sandbox.restore(); + mock.reset(); }); describe('Schema for resource', () => { - let requestServiceMock: SinonSpy; + let requestServiceMock: Mock; beforeEach(() => { - requestServiceMock = sandbox.fake.resolves(undefined); + requestServiceMock = mock.fn(() => Promise.resolve(undefined)); }); it('should handle inline schema http url', () => { @@ -52,7 +52,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWith('http://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['http://json-schema.org/draft-07/schema#']); }); it('should handle inline schema https url', () => { @@ -63,25 +64,36 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWith('https://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://json-schema.org/draft-07/schema#']); }); it('should handle url with fragments', async () => { const content = `# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#/definitions/schemaArray\nfoo: bar`; const yamlDock = parse(content); - requestServiceMock = sandbox.fake.resolves(`{"definitions": {"schemaArray": { + requestServiceMock = mock.fn(() => + Promise.resolve(`{"definitions": {"schemaArray": { "type": "array", "minItems": 1, "items": { "$ref": "#" } - }}, "properties": {}}`); + }}, "properties": {}}`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledTwice; - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema'); - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema#/definitions/schemaArray'); + assert.equal(requestServiceMock.mock.callCount(), 2); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema']) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema#/definitions/schemaArray']) + ) + ); expect(schema.schema.type).eqls('array'); }); @@ -90,7 +102,8 @@ describe('YAML Schema Service', () => { const content = `# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#/definitions/schemaArray`; const yamlDock = parse(content); - requestServiceMock = sandbox.fake.resolves(`{"definitions": {"schemaArray": { + requestServiceMock = mock.fn(() => + Promise.resolve(`{"definitions": {"schemaArray": { "type": "array", "minItems": 1, "items": { "$ref": "#" } @@ -98,14 +111,23 @@ describe('YAML Schema Service', () => { "bar": { "type": "string" } - }, "properties": {"foo": {"type": "boolean"}}, "required": ["foo"]}`); + }, "properties": {"foo": {"type": "boolean"}}, "required": ["foo"]}`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledTwice; - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema'); - expect(requestServiceMock).calledWithExactly('https://json-schema.org/draft-07/schema#/definitions/schemaArray'); + assert.equal(requestServiceMock.mock.callCount(), 2); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema']) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['https://json-schema.org/draft-07/schema#/definitions/schemaArray']) + ) + ); expect(schema.schema.type).eqls('array'); expect(schema.schema.required).is.undefined; @@ -116,26 +138,38 @@ describe('YAML Schema Service', () => { const content = `# yaml-language-server: $schema=schema.json#/definitions/schemaArray\nfoo: bar`; const yamlDock = parse(content); - requestServiceMock = sandbox.fake.resolves(`{"definitions": {"schemaArray": { + requestServiceMock = mock.fn(() => + Promise.resolve(`{"definitions": {"schemaArray": { "type": "array", "minItems": 1, "items": { "$ref": "#" } - }}, "properties": {}}`); + }}, "properties": {}}`) + ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledTwice; + assert.equal(requestServiceMock.mock.callCount(), 2); if (process.platform === 'win32') { const driveLetter = path .parse(import.meta.dirname) .root.split(':')[0] .toLowerCase(); - expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json`); - expect(requestServiceMock).calledWithExactly(`file:///${driveLetter}:/schema.json#/definitions/schemaArray`); + assert.ok( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [`file:///${driveLetter}:/schema.json`])) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [`file:///${driveLetter}:/schema.json#/definitions/schemaArray`]) + ) + ); } else { - expect(requestServiceMock).calledWithExactly('file:///schema.json'); - expect(requestServiceMock).calledWithExactly('file:///schema.json#/definitions/schemaArray'); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///schema.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, ['file:///schema.json#/definitions/schemaArray']) + ) + ); } expect(schema.schema.type).eqls('array'); @@ -146,20 +180,22 @@ describe('YAML Schema Service', () => { const yamlDock = parse(content); const resource = URI.file(path.join(import.meta.dirname, 'test.yaml')).toString(); const expectedSchemaPath = URI.parse(URI.file(path.join(import.meta.dirname, 'encoded schema.json')).toString()).fsPath; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - type: 'object', - properties: { - foo: { type: 'string' }, - }, - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + type: 'object', + properties: { + foo: { type: 'string' }, + }, + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource(resource, yamlDock.documents[0]); - expect(requestServiceMock).calledOnce; - expect(URI.parse(requestServiceMock.firstCall.args[0]).fsPath).equals(expectedSchemaPath); + assert.equal(requestServiceMock.mock.callCount(), 1); + expect(URI.parse(requestServiceMock.mock.calls[0].arguments[0]).fsPath).equals(expectedSchemaPath); expect(schema.schema.properties.foo).to.include({ type: 'string' }); }); @@ -172,20 +208,22 @@ describe('YAML Schema Service', () => { const expectedSchemaPath = URI.parse( URI.file(path.join(path.parse(import.meta.dirname).root, 'encoded schema.json')).toString() ).fsPath; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - type: 'object', - properties: { - foo: { type: 'string' }, - }, - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + type: 'object', + properties: { + foo: { type: 'string' }, + }, + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); const schema = await service.getSchemaForResource(resource, yamlDock.documents[0]); - expect(requestServiceMock).calledOnce; - expect(URI.parse(requestServiceMock.firstCall.args[0]).fsPath).equals(expectedSchemaPath); + assert.equal(requestServiceMock.mock.callCount(), 1); + expect(URI.parse(requestServiceMock.mock.calls[0].arguments[0]).fsPath).equals(expectedSchemaPath); expect(schema.schema.properties.foo).to.include({ type: 'string' }); }); @@ -196,20 +234,23 @@ describe('YAML Schema Service', () => { it(`should resolve a schema URI with an ${description}`, async () => { const yamlDock = parse('foo: bar'); const normalizedUri = 'file:///c:/Users/user1/schema.json'; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - type: 'object', - properties: { - foo: { type: 'string' }, - }, - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + type: 'object', + properties: { + foo: { type: 'string' }, + }, + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.registerExternalSchema(uri, ['test.yaml']); const schema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWithExactly(normalizedUri); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments, [normalizedUri]); expect(schema.schema.properties.foo).to.include({ type: 'string' }); }); } @@ -232,7 +273,7 @@ describe('YAML Schema Service', () => { enum: ['dev', 'prod'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -245,7 +286,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///schemas/primary.json'); expect(requestedUris).to.include('file:///schemas/secondary.json'); expect(requestedUris).to.not.include('https://example.com/schemas/secondary.json'); @@ -286,7 +327,7 @@ describe('YAML Schema Service', () => { }, }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/repro_main_schema.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -299,7 +340,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///schemas/repro_main_schema.json'); expect(requestedUris).to.include('file:///schemas/repro_defs.json'); expect(requestedUris).to.not.include('https://example.com/schemas/repro_defs.json'); @@ -331,7 +372,7 @@ describe('YAML Schema Service', () => { oneOf: [{ $ref: 'node.json' }], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/node.json') { return Promise.resolve(JSON.stringify(nodeSchema)); } @@ -385,7 +426,7 @@ describe('YAML Schema Service', () => { }, }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schemaUri) { return Promise.resolve(JSON.stringify(schema3)); } @@ -396,12 +437,13 @@ describe('YAML Schema Service', () => { const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); expect(resolvedSchema.schema._sourceUri).to.equal(schemaUri); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.eql([schemaUri]); expect(resolvedSchema.errors).to.eql([]); expect(resolvedSchema.schema.properties.child).to.deep.include({ type: 'object' }); expect((resolvedSchema.schema.properties.child as JSONSchema).properties.value).to.deep.include({ type: 'integer' }); - expect(requestServiceMock).calledOnceWithExactly(schemaUri); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments, [schemaUri]); }); it('should resolve a relative local sibling-file reference through non-standard schema containers', async () => { @@ -439,7 +481,7 @@ describe('YAML Schema Service', () => { }, }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schema3Uri) { return Promise.resolve(JSON.stringify(schema3)); } @@ -452,7 +494,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.eql([schema3Uri, schema2Uri]); expect(resolvedSchema.errors).to.eql([]); expect(resolvedSchema.schema.properties.child).to.deep.include({ @@ -460,9 +502,9 @@ describe('YAML Schema Service', () => { url: schema2Uri, }); expect((resolvedSchema.schema.properties.child as JSONSchema).properties.value).to.deep.include({ type: 'integer' }); - expect(requestServiceMock).calledWithExactly(schema3Uri); - expect(requestServiceMock).calledWithExactly(schema2Uri); - expect(requestServiceMock).callCount(2); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [schema3Uri]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [schema2Uri]))); + assert.equal(requestServiceMock.mock.callCount(), 2); }); it('should resolve nested local sibling refs relative to the loaded sibling schema file', async () => { @@ -492,7 +534,7 @@ describe('YAML Schema Service', () => { enum: ['ok'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -508,7 +550,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const schema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///schemas/primary.json'); expect(requestedUris).to.include('file:///schemas/secondary.json'); expect(requestedUris).to.include('file:///schemas/third.json'); @@ -539,7 +581,7 @@ describe('YAML Schema Service', () => { required: ['name', 'age'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -552,7 +594,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///dir/primary.json'); expect(requestedUris).to.include('file:///dir/secondary.json'); expect(requestedUris).to.not.include('file:///schemas/secondary.json'); @@ -577,7 +619,7 @@ describe('YAML Schema Service', () => { required: ['name', 'age'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -590,7 +632,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///dir/primary.json'); expect(requestedUris).to.include('file:///dir/secondary.json'); expect(requestedUris).to.include('https://example.com/schemas/secondary.json'); @@ -618,7 +660,7 @@ describe('YAML Schema Service', () => { enum: ['dev', 'prod'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///schemas/primary.json') { return Promise.resolve(JSON.stringify(primarySchema)); } @@ -631,9 +673,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedSecondaryUrisAfterFirstLoad = requestServiceMock - .getCalls() - .map((call) => call.args[0]) + const requestedSecondaryUrisAfterFirstLoad = requestServiceMock.mock.calls + .map((call) => call.arguments[0]) .filter((uri) => uri === 'file:///schemas/secondary.json'); expect(requestedSecondaryUrisAfterFirstLoad).to.have.length(1); @@ -641,9 +682,8 @@ describe('YAML Schema Service', () => { service.onResourceChange('file:///schemas/secondary.json'); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedSecondaryUrisAfterChange = requestServiceMock - .getCalls() - .map((call) => call.args[0]) + const requestedSecondaryUrisAfterChange = requestServiceMock.mock.calls + .map((call) => call.arguments[0]) .filter((uri) => uri === 'file:///schemas/secondary.json'); expect(requestedSecondaryUrisAfterChange).to.have.length(2); }); @@ -672,7 +712,7 @@ describe('YAML Schema Service', () => { required: ['openapi', 'info'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'https://example.com/schemas/openapi-extensions.json') { return Promise.resolve(JSON.stringify(extensionsSchema)); } @@ -685,7 +725,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('https://example.com/schemas/openapi-extensions.json'); expect(requestedUris).to.include('https://example.com/schemas/openapi.v3.1.json'); // _preferLocalBaseForRemoteId should NOT probe for the $id basename as a local sibling @@ -699,7 +739,7 @@ describe('YAML Schema Service', () => { const schemaOneUri = 'file:///Users/test/schemas/schema1.json'; const schemaTwoUri = 'file:///Users/test/schemas/schema2.json'; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === schemaOneUri) { return Promise.resolve(JSON.stringify({ title: 'Schema 1', type: 'object' })); } @@ -715,7 +755,7 @@ describe('YAML Schema Service', () => { const schema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include(schemaOneUri); expect(requestedUris).to.include(schemaTwoUri); expect(requestedUris.some((uri) => uri.startsWith('schemaservice:///'))).to.be.false; @@ -737,7 +777,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('should ignore modeline schema comment using $schema in the middle of file after yaml content', async () => { @@ -748,7 +788,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('should handle modeline schema comment in multiline comments at document header', async () => { @@ -759,7 +799,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).calledOnceWith('https://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://json-schema.org/draft-07/schema#']); }); it('should ignore modeline schema comment in multiline comments after yaml content', async () => { @@ -770,7 +811,7 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); await service.getSchemaForResource('', yamlDock.documents[0]); - expect(requestServiceMock).not.called; + assert.equal(requestServiceMock.mock.callCount(), 0); }); it('should handle modeline schema comment after document separator', () => { @@ -780,7 +821,8 @@ describe('YAML Schema Service', () => { const service = new SchemaService.YAMLSchemaService(requestServiceMock); service.getSchemaForResource('', yamlDock.documents[1]); - expect(requestServiceMock).calledOnceWith('https://json-schema.org/draft-07/schema#'); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments.slice(0, 1), ['https://json-schema.org/draft-07/schema#']); }); it('should handle crd catalog for crd', async () => { @@ -793,15 +835,15 @@ describe('YAML Schema Service', () => { kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { "$ref": "_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook" } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -811,13 +853,17 @@ describe('YAML Schema Service', () => { 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); - expect(requestServiceMock).calledWithExactly( - 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json' + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json', + ]) + ) ); - expect(requestServiceMock).calledThrice; + assert.equal(requestServiceMock.mock.callCount(), 3); }); it('should handle nonstandard location for OpenShift crd', async () => { @@ -836,15 +882,15 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { "$ref": "_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook" } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -854,13 +900,17 @@ spec: 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/openshift/v4.15-strict/route_route.openshift.io_v1.json' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); - expect(requestServiceMock).calledWithExactly( - 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/openshift/v4.15-strict/route_route.openshift.io_v1.json' + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/openshift/v4.15-strict/route_route.openshift.io_v1.json', + ]) + ) ); - expect(requestServiceMock).calledThrice; + assert.equal(requestServiceMock.mock.callCount(), 3); }); it('should not get schema from crd catalog if definition in kubernetes schema', async () => { @@ -873,15 +923,15 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { "$ref": "_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook" } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -890,13 +940,21 @@ spec: BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); - expect(requestServiceMock).calledWithExactly( - BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook' + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.admissionregistration.v1.MutatingWebhook', + ]) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [BASE_KUBERNETES_SCHEMA_URL + '_definitions.json']) + ) ); - expect(requestServiceMock).calledWithExactly(BASE_KUBERNETES_SCHEMA_URL + '_definitions.json'); - expect(requestServiceMock.callCount).equals(4); + expect(requestServiceMock.mock.callCount()).equals(4); }); it('should treat CustomResourceDefinition as a builtin Kubernetes resource', async () => { @@ -912,10 +970,12 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - oneOf: [{ $ref: builtinDefinition }], - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + oneOf: [{ $ref: builtinDefinition }], + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -923,7 +983,10 @@ spec: const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(BASE_KUBERNETES_SCHEMA_URL + builtinDefinition); - expect(requestServiceMock).not.calledWith(crdCatalogURL); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [crdCatalogURL])), + false + ); }); it('should treat an older CustomResourceDefinition version as builtin when present', async () => { @@ -939,10 +1002,12 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - oneOf: [{ $ref: builtinDefinition }], - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + oneOf: [{ $ref: builtinDefinition }], + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -950,7 +1015,10 @@ spec: const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(BASE_KUBERNETES_SCHEMA_URL + builtinDefinition); - expect(requestServiceMock).not.calledWith(crdCatalogURL); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [crdCatalogURL])), + false + ); }); it('should fall back to all.json for an unsupported CustomResourceDefinition version', async () => { @@ -964,14 +1032,17 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves('{"oneOf": []}'); + requestServiceMock = mock.fn(() => Promise.resolve('{"oneOf": []}')); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).not.calledWith(crdCatalogURL); + assert.equal( + requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments.slice(0, 1), [crdCatalogURL])), + false + ); }); it('should still use the CRD catalog for a similarly named custom API group', async () => { @@ -985,14 +1056,16 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - JSON.stringify({ - oneOf: [ - { - $ref: '_definitions.json#/definitions/io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinition', - }, - ], - }) + requestServiceMock = mock.fn(() => + Promise.resolve( + JSON.stringify({ + oneOf: [ + { + $ref: '_definitions.json#/definitions/io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinition', + }, + ], + }) + ) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -1000,21 +1073,22 @@ spec: const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(crdCatalogURL); - expect(requestServiceMock).calledWithExactly(crdCatalogURL); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [crdCatalogURL]))); }); it('should fall back to all.json instead of the CRD catalog for an unknown core resource', async () => { const yamlDock = parse('apiVersion: v1\nkind: UnknownCoreResource'); const settings = new SettingsState(); settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves('{"oneOf": []}'); + requestServiceMock = mock.fn(() => Promise.resolve('{"oneOf": []}')); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); const resolvedSchema = await service.getSchemaForResource('test.yaml', yamlDock.documents[0]); expect(resolvedSchema.schema.url).equals(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledOnceWithExactly(KUBERNETES_SCHEMA_URL); + assert.equal(requestServiceMock.mock.callCount(), 1); + assert.deepEqual(requestServiceMock.mock.calls[0].arguments, [KUBERNETES_SCHEMA_URL]); }); it('should not get schema from crd catalog if definition in kubernetes schema (multiple oneOf)', async () => { @@ -1027,8 +1101,8 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { @@ -1039,7 +1113,7 @@ spec: } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -1048,13 +1122,21 @@ spec: BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.apps.v1.Deployment' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); - expect(requestServiceMock).calledWithExactly( - BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.apps.v1.Deployment' + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.apps.v1.Deployment', + ]) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [BASE_KUBERNETES_SCHEMA_URL + '_definitions.json']) + ) ); - expect(requestServiceMock).calledWithExactly(BASE_KUBERNETES_SCHEMA_URL + '_definitions.json'); - expect(requestServiceMock.callCount).equals(4); + expect(requestServiceMock.mock.callCount()).equals(4); }); it('should not get schema from crd catalog for RBAC-related resources', async () => { @@ -1067,8 +1149,8 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake.resolves( - ` + requestServiceMock = mock.fn(() => + Promise.resolve(` { "oneOf": [ { @@ -1076,7 +1158,7 @@ spec: } ] } - ` + `) ); const service = new SchemaService.YAMLSchemaService(requestServiceMock, undefined, undefined, settings); service.registerExternalSchema(KUBERNETES_SCHEMA_URL, ['*.yaml']); @@ -1085,13 +1167,21 @@ spec: BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.rbac.v1.RoleBinding' ); - expect(requestServiceMock).calledWithExactly(KUBERNETES_SCHEMA_URL); - expect(requestServiceMock).calledWithExactly('file:///_definitions.json'); - expect(requestServiceMock).calledWithExactly( - BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.rbac.v1.RoleBinding' + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, [KUBERNETES_SCHEMA_URL]))); + assert.ok(requestServiceMock.mock.calls.some((call) => isDeepStrictEqual(call.arguments, ['file:///_definitions.json']))); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [ + BASE_KUBERNETES_SCHEMA_URL + '_definitions.json#/definitions/io.k8s.api.rbac.v1.RoleBinding', + ]) + ) + ); + assert.ok( + requestServiceMock.mock.calls.some((call) => + isDeepStrictEqual(call.arguments, [BASE_KUBERNETES_SCHEMA_URL + '_definitions.json']) + ) ); - expect(requestServiceMock).calledWithExactly(BASE_KUBERNETES_SCHEMA_URL + '_definitions.json'); - expect(requestServiceMock.callCount).equals(4); + expect(requestServiceMock.mock.callCount()).equals(4); }); it('should use GVK to get correct schema', async () => { @@ -1123,7 +1213,7 @@ spec: kubernetes: ['*.yaml'], }; settings.kubernetesCRDStoreEnabled = true; - requestServiceMock = sandbox.fake((uri) => { + requestServiceMock = mock.fn((uri) => { if (uri === KUBERNETES_SCHEMA_URL) { return Promise.resolve(` { @@ -1279,7 +1369,7 @@ spec: }, }, }); - requestServiceMock = sandbox.fake((uri) => { + requestServiceMock = mock.fn((uri) => { if (uri === KUBERNETES_SCHEMA_URL) { return Promise.resolve( JSON.stringify({ @@ -1312,7 +1402,7 @@ spec: yamlDock.documents.map((document) => service.getSchemaForResource('templates/policies/foo.yaml', document)) ); const messages = yamlDock.documents.flatMap((document, index) => - document.validate(textDocument, resolvedSchemas[index].schema).map((diagnostic) => diagnostic.message) + document.validate(textDocument, resolvedSchemas[index].schema).map(getDiagnosticMessage) ); return { schemaUrls: resolvedSchemas.map((schema) => schema.schema.url), @@ -1480,7 +1570,7 @@ spec: required: ['name', 'age'], }; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/my-schema.yaml') { return Promise.resolve(YAML.stringify(mySchema)); } @@ -1490,7 +1580,7 @@ spec: const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); expect(requestedUris).to.include('file:///dir/my-schema.yaml'); expect(requestedUris.length).to.equal(1); expect(resolvedSchema.errors.length).to.equal(0); @@ -1559,7 +1649,7 @@ properties: "$ref": "#/$defs/contact" description: Maintainers of the apis.json file`; - requestServiceMock = sandbox.fake((uri: string) => { + requestServiceMock = mock.fn((uri: string) => { if (uri === 'file:///dir/my-schema.yaml') { return Promise.resolve(mySchema); } @@ -1569,7 +1659,7 @@ properties: const service = new SchemaService.YAMLSchemaService(requestServiceMock, workspaceContext); const resolvedSchema = await service.getSchemaForResource('', yamlDock.documents[0]); - const requestedUris = requestServiceMock.getCalls().map((call) => call.args[0]); + const requestedUris = requestServiceMock.mock.calls.map((call) => call.arguments[0]); const errors = []; const parsedSchema = JSONC.parse(mySchema, errors); @@ -1584,17 +1674,14 @@ properties: describe('Caching of failed schema loads', () => { const SCHEMA_URI = 'https://example.com/schema.json'; const schemaContent = JSON.stringify({ type: 'object', properties: { foo: { type: 'string' } } }); - let clock: SinonFakeTimers; + let now: number; beforeEach(() => { - clock = sandbox.useFakeTimers({ now: Date.now(), shouldAdvanceTime: false }); + now = Date.now(); + mock.method(Date, 'now', () => now); }); - afterEach(() => { - clock.restore(); - }); - - const createService = (requestService: SinonStub): SchemaService.YAMLSchemaService => { + const createService = (requestService: SchemaRequestService): SchemaService.YAMLSchemaService => { const service = new SchemaService.YAMLSchemaService(requestService, workspaceContext); service.registerExternalSchema(SCHEMA_URI, ['*.yaml']); return service; @@ -1604,56 +1691,58 @@ properties: service.getSchemaForResource('test.yaml', parse('foo: bar\n').documents[0]); it('should not request a failed schema again within the caching window', async () => { - const requestService = sandbox.stub().rejects(new Error('Request failed with status code 429')); + const requestService = mock.fn(() => + Promise.reject(new Error('Request failed with status code 429')) + ); const service = createService(requestService); await resolveSchema(service); - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS - 1); + now += SchemaService.FAILED_SCHEMA_CACHE_MS - 1; await resolveSchema(service); - expect(requestService).calledOnce; + assert.equal(requestService.mock.callCount(), 1); }); it('should request a failed schema again once the caching window has passed', async () => { - const requestService = sandbox.stub(); - requestService.onFirstCall().rejects(new Error('Request failed with status code 429')); - requestService.resolves(schemaContent); + const requestService = mock.fn(); + requestService.mock.mockImplementationOnce(() => Promise.reject(new Error('Request failed with status code 429')), 0); + requestService.mock.mockImplementation(() => Promise.resolve(schemaContent)); const service = createService(requestService); const failed = await resolveSchema(service); expect(failed.errors).to.not.be.empty; - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS); + now += SchemaService.FAILED_SCHEMA_CACHE_MS; const recovered = await resolveSchema(service); - expect(requestService).calledTwice; + assert.equal(requestService.mock.callCount(), 2); expect(recovered.errors).to.be.empty; expect(recovered.schema.properties).to.have.property('foo'); }); it('should keep caching a successful schema load', async () => { - const requestService = sandbox.stub().resolves(schemaContent); + const requestService = mock.fn(() => Promise.resolve(schemaContent)); const service = createService(requestService); await resolveSchema(service); - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS * 10); + now += SchemaService.FAILED_SCHEMA_CACHE_MS * 10; const second = await resolveSchema(service); - expect(requestService).calledOnce; + assert.equal(requestService.mock.callCount(), 1); expect(second.errors).to.be.empty; }); it('should not serve a stale resolved schema after a cached failure expires', async () => { - const requestService = sandbox.stub(); - requestService.onFirstCall().rejects(new Error('Request failed with status code 429')); - requestService.resolves(schemaContent); + const requestService = mock.fn(); + requestService.mock.mockImplementationOnce(() => Promise.reject(new Error('Request failed with status code 429')), 0); + requestService.mock.mockImplementation(() => Promise.resolve(schemaContent)); const service = createService(requestService); // Resolve first, so a resolved schema built from the failure is cached too. const failed = await resolveSchema(service); expect(failed.errors).to.not.be.empty; - await clock.tickAsync(SchemaService.FAILED_SCHEMA_CACHE_MS); + now += SchemaService.FAILED_SCHEMA_CACHE_MS; const recovered = await resolveSchema(service); expect(recovered.errors).to.be.empty; diff --git a/test/yamlValidation.test.ts b/test/yamlValidation.test.ts index e0b0ef625..c4707fdd5 100644 --- a/test/yamlValidation.test.ts +++ b/test/yamlValidation.test.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { describe, it, before, afterEach } from 'node:test'; +import { describe, it, before, afterEach, mock } from 'node:test'; import type { Diagnostic } from 'vscode-languageserver-types'; import { DiagnosticSeverity } from 'vscode-languageserver-types'; import type { ValidationHandler } from '../src/languageserver/handlers/validationHandlers.js'; @@ -12,7 +12,6 @@ import { TextDocumentTestManager } from '../src/yamlSettings.js'; import { ServiceSetup } from './utils/serviceSetup.js'; import { setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper.js'; import { expect } from 'chai'; -import { createSandbox } from 'sinon'; import { createExpectedError, createUnusedAnchorDiagnostic } from './utils/verifyError.js'; type ValidationHandlerWithConnection = { @@ -24,13 +23,12 @@ type ValidationHandlerWithConnection = { }; describe('YAML Validation Tests', () => { - const sandbox = createSandbox(); let languageSettingsSetup: ServiceSetup; let validationHandler: ValidationHandler; let yamlSettings: SettingsState; afterEach(() => { - sandbox.restore(); + mock.reset(); }); before(() => { @@ -54,7 +52,7 @@ describe('YAML Validation Tests', () => { yamlSettings.documents = new TextDocumentTestManager(); (yamlSettings.documents as TextDocumentTestManager).set(testTextDocument); const connection = (validationHandler as unknown as ValidationHandlerWithConnection).connection; - sandbox.stub(connection.workspace, 'getConfiguration').resolves({ 'yaml.validate': false }); + mock.method(connection.workspace, 'getConfiguration', () => Promise.resolve({ 'yaml.validate': false })); yamlSettings.hasConfigurationCapability = true; const result = await validationHandler.validateTextDocument(testTextDocument); expect(result).to.be.empty; From 5b7830358237c674d2f3c1d1aa8388498e3fda80 Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Wed, 7 Oct 2026 16:34:12 -0400 Subject: [PATCH 17/18] update README.md Signed-off-by: Morgan Chang --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60b722ba2..1d20ed80f 100755 --- a/README.md +++ b/README.md @@ -594,7 +594,7 @@ interface JSONSchemaDescriptionExt extends JSONSchemaDescription { ### Prerequisites -- [Node.js](https://nodejs.org/) v18.18.0 or higher +- [Node.js](https://nodejs.org/) v22.13.0 or higher - npm ### Setup @@ -618,6 +618,14 @@ The main server output is generated in `out/server/src`. Use `npm test` to run tests. +Use `npm run coveralls` to run tests with coverage and generate text and LCOV reports. Coverage uses nyc with pre-instrumented ESM: + +1. Clean and compile the source and tests into `out/server`. +2. Run `npm run coverage:instrument` to create a copy in `out/coverage`, adding coverage counters to the server JavaScript and copying tests and fixtures unchanged. +3. Run the copied tests with `nyc --instrument=false`, collecting the existing counters and mapping coverage back to TypeScript through source maps. + +The instrumented copy is only for coverage; the package entry point remains under `out/server`. + ### Module builds Building YAML Language Server produces [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) and declarations in the `out/server/src` directory. From 4b6de1a2752a6b1060ac1cf3b7e51c53d35e09cc Mon Sep 17 00:00:00 2001 From: Morgan Chang Date: Fri, 9 Oct 2026 14:10:30 -0400 Subject: [PATCH 18/18] update README.md Signed-off-by: Morgan Chang --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 1d20ed80f..bd9e17d75 100755 --- a/README.md +++ b/README.md @@ -618,14 +618,6 @@ The main server output is generated in `out/server/src`. Use `npm test` to run tests. -Use `npm run coveralls` to run tests with coverage and generate text and LCOV reports. Coverage uses nyc with pre-instrumented ESM: - -1. Clean and compile the source and tests into `out/server`. -2. Run `npm run coverage:instrument` to create a copy in `out/coverage`, adding coverage counters to the server JavaScript and copying tests and fixtures unchanged. -3. Run the copied tests with `nyc --instrument=false`, collecting the existing counters and mapping coverage back to TypeScript through source maps. - -The instrumented copy is only for coverage; the package entry point remains under `out/server`. - ### Module builds Building YAML Language Server produces [ES Modules](https://tc39.es/ecma262/#sec-modules) (ESM) and declarations in the `out/server/src` directory.