Skip to content

Commit 758fd1d

Browse files
[8.19] Updated js-yaml to v4 (#190678) (#219852)
# Backport This will backport the following commits from `main` to `8.19`: - [Updated js-yaml to v4 (#190678)](#190678) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Elena Shostak","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-19T10:25:03Z","message":"Updated js-yaml to v4 (#190678)\n\n## Summary\r\nUpdated `js-yaml` to `4.1.0`.\r\n\r\nThis PR also introduces a type override for the `js-yaml` load function\r\nto maintain compatibility across the codebase. Specifically, updated\r\ntype definition of the load function looks as follows:\r\n\r\n```typescript\r\nfunction load<T = any>(str: string, opts?: jsyaml.LoadOptions): T;\r\n```\r\n\r\nThe original type definition of the load function in `js-yaml` changed\r\nfrom `any` to `unknown`. This change would require extensive type\r\nupdates throughout the entire repository to accommodate the `unknown`\r\ntype. To avoid widespread type changes and potential issues in the\r\ncodebase, the type is overriden back to `any` for now.\r\nThis is a temporary measure, we plan to address the necessary type\r\nchanges in subsequent PRs, where teams will gradually update the\r\ncodebase to work with the `unknown` type.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n## Release note\r\nUpdated `js-yaml` to `4.1.0`.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Maxim Palenov <[email protected]>","sha":"28aa274f665b1aff891bf055a592851c8ec53d30","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Security","backport:skip","Team:Fleet","v9.0.0","Team:Obs AI Assistant","ci:project-deploy-observability","Team:obs-ux-infra_services","Team:obs-ux-management","apm:review"],"title":"Updated js-yaml to v4","number":190678,"url":"https://github.com/elastic/kibana/pull/190678","mergeCommit":{"message":"Updated js-yaml to v4 (#190678)\n\n## Summary\r\nUpdated `js-yaml` to `4.1.0`.\r\n\r\nThis PR also introduces a type override for the `js-yaml` load function\r\nto maintain compatibility across the codebase. Specifically, updated\r\ntype definition of the load function looks as follows:\r\n\r\n```typescript\r\nfunction load<T = any>(str: string, opts?: jsyaml.LoadOptions): T;\r\n```\r\n\r\nThe original type definition of the load function in `js-yaml` changed\r\nfrom `any` to `unknown`. This change would require extensive type\r\nupdates throughout the entire repository to accommodate the `unknown`\r\ntype. To avoid widespread type changes and potential issues in the\r\ncodebase, the type is overriden back to `any` for now.\r\nThis is a temporary measure, we plan to address the necessary type\r\nchanges in subsequent PRs, where teams will gradually update the\r\ncodebase to work with the `unknown` type.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n## Release note\r\nUpdated `js-yaml` to `4.1.0`.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Maxim Palenov <[email protected]>","sha":"28aa274f665b1aff891bf055a592851c8ec53d30"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/190678","number":190678,"mergeCommit":{"message":"Updated js-yaml to v4 (#190678)\n\n## Summary\r\nUpdated `js-yaml` to `4.1.0`.\r\n\r\nThis PR also introduces a type override for the `js-yaml` load function\r\nto maintain compatibility across the codebase. Specifically, updated\r\ntype definition of the load function looks as follows:\r\n\r\n```typescript\r\nfunction load<T = any>(str: string, opts?: jsyaml.LoadOptions): T;\r\n```\r\n\r\nThe original type definition of the load function in `js-yaml` changed\r\nfrom `any` to `unknown`. This change would require extensive type\r\nupdates throughout the entire repository to accommodate the `unknown`\r\ntype. To avoid widespread type changes and potential issues in the\r\ncodebase, the type is overriden back to `any` for now.\r\nThis is a temporary measure, we plan to address the necessary type\r\nchanges in subsequent PRs, where teams will gradually update the\r\ncodebase to work with the `unknown` type.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n## Release note\r\nUpdated `js-yaml` to `4.1.0`.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Maxim Palenov <[email protected]>","sha":"28aa274f665b1aff891bf055a592851c8ec53d30"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
1 parent 856b5be commit 758fd1d

File tree

137 files changed

+653
-825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+653
-825
lines changed

.buildkite/pipeline-resource-definitions/scripts/fix-location-collection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ async function main() {
3838

3939
const preamble = locationFileLines.slice(0, 1);
4040

41-
// eslint-disable-next-line @kbn/eslint/no_unsafe_js_yaml
4241
const locationObj = jsYaml.load(
4342
locationFileLines.slice(1).join('\n')
4443
) as BackstageLocationResource;
4544
locationObj.spec.targets = pipelines.map(
4645
(fileName) => `${resourceDefinitionsBaseUrl}/${fileName}`
4746
);
4847

49-
// eslint-disable-next-line @kbn/eslint/no_unsafe_js_yaml
5048
const locationYaml = jsYaml.dump(locationObj, { lineWidth: 400 });
5149

5250
fs.writeFileSync(locationFile, `${preamble.join('\n')}\n${locationYaml}`);

.buildkite/pipeline-utils/agent_images.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
// eslint-disable-next-line @kbn/eslint/no_unsafe_js_yaml
1110
import { dump } from 'js-yaml';
1211
import { BuildkiteClient, BuildkiteAgentTargetingRule } from './buildkite';
1312

.buildkite/pipeline-utils/buildkite/client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import axios, { AxiosInstance } from 'axios';
1111
import { execSync, ExecSyncOptions } from 'child_process';
1212

13-
// eslint-disable-next-line @kbn/eslint/no_unsafe_js_yaml
1413
import { dump } from 'js-yaml';
1514

1615
import { parseLinkHeader } from './parse_link_header';

.buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import * as Fs from 'fs';
1212
import * as globby from 'globby';
1313
import minimatch from 'minimatch';
1414

15-
// eslint-disable-next-line @kbn/eslint/no_unsafe_js_yaml
1615
import { load as loadYaml } from 'js-yaml';
1716

1817
import { BuildkiteClient, BuildkiteStep } from '../buildkite';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@
11771177
"jquery": "^3.7.1",
11781178
"js-search": "^1.4.3",
11791179
"js-sha256": "^0.11.0",
1180-
"js-yaml": "^3.14.1",
1180+
"js-yaml": "^4.1.0",
11811181
"json-schema-to-ts": "^2.9.1",
11821182
"json-stable-stringify": "^1.0.1",
11831183
"json-stringify-pretty-compact": "1.2.0",
@@ -1634,7 +1634,7 @@
16341634
"@types/jest": "^29.5.3",
16351635
"@types/jquery": "^3.5.32",
16361636
"@types/js-search": "^1.4.0",
1637-
"@types/js-yaml": "^3.11.1",
1637+
"@types/js-yaml": "^4.0.9",
16381638
"@types/jsdom": "^20.0.1",
16391639
"@types/json-schema": "^7.0.15",
16401640
"@types/json-stable-stringify": "^1.0.32",

packages/kbn-docs-utils/src/mdx/get_all_doc_file_ids.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function getAllDocFileIds(outputDir: string) {
3838

3939
let fm;
4040
try {
41-
fm = Yaml.safeLoad(fmYaml.slice(0, fmEnd.index));
41+
fm = Yaml.load(fmYaml.slice(0, fmEnd.index));
4242
if (typeof fm !== 'object' || fm === null) {
4343
throw new Error('expected yaml to produce an object');
4444
}

packages/kbn-docs-utils/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"include": [
1111
"**/*.ts",
12+
"../../typings/**/*"
1213
],
1314
"exclude": [
1415
"**/__fixtures__/**",

packages/kbn-eslint-config/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ module.exports = {
323323
'@kbn/eslint/no_constructor_args_in_property_initializers': 'error',
324324
'@kbn/eslint/no_this_in_property_initializers': 'error',
325325
'@kbn/eslint/no_unsafe_console': 'error',
326-
'@kbn/eslint/no_unsafe_js_yaml': 'error',
327326
'@kbn/imports/no_unresolvable_imports': 'error',
328327
'@kbn/imports/uniform_imports': 'error',
329328
'@kbn/imports/no_unused_imports': 'error',

packages/kbn-eslint-plugin-eslint/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ module.exports = {
1919
no_constructor_args_in_property_initializers: require('./rules/no_constructor_args_in_property_initializers'),
2020
no_this_in_property_initializers: require('./rules/no_this_in_property_initializers'),
2121
no_unsafe_console: require('./rules/no_unsafe_console'),
22-
no_unsafe_js_yaml: require('./rules/no_unsafe_js_yaml'),
2322
},
2423
};

packages/kbn-eslint-plugin-eslint/rules/no_unsafe_js_yaml.js

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)