Skip to content

Commit

Permalink
Changing autoremoved imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kc13greiner committed Sep 20, 2024
1 parent 427e451 commit ff6e90f
Show file tree
Hide file tree
Showing 87 changed files with 117 additions and 46 deletions.
1 change: 1 addition & 0 deletions .buildkite/pipeline-utils/agent_images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { dump } from 'js-yaml';
import { BuildkiteClient, BuildkiteCommandStep } from './buildkite';

type AgentImageConfig = BuildkiteCommandStep['agents'];
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-apm-config-loader/src/utils/read_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import { readFileSync } from 'fs';

import { set } from '@kbn/safer-lodash-set';
import { ensureDeepObject } from '@kbn/std';
import { isPlainObject } from 'lodash';
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-config/src/raw/read_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { readFileSync } from 'fs';
import { load } from 'js-yaml';
import { set } from '@kbn/safer-lodash-set';
import { isPlainObject } from 'lodash';
import { ensureValidObjectPath } from '@kbn/std';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-docs-utils/src/mdx/get_all_doc_file_ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getAllDocFileIds(outputDir: string) {

let fm;
try {
fm = Yaml.safeLoad(fmYaml.slice(0, fmEnd.index));
fm = Yaml.load(fmYaml.slice(0, fmEnd.index));
if (typeof fm !== 'object' || fm === null) {
throw new Error('expected yaml to produce an object');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es/src/utils/read_roles_from_resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import fs from 'fs';
import { extname } from 'path';
import { safeLoad as loadYaml } from 'js-yaml';
import { load as loadYaml } from 'js-yaml';

export const readRolesFromResource = (resourcePath: string) => {
if (!fs.existsSync(resourcePath) || extname(resourcePath) !== '.yml') {
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-eslint-config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ module.exports = {
'@kbn/eslint/no_constructor_args_in_property_initializers': 'error',
'@kbn/eslint/no_this_in_property_initializers': 'error',
'@kbn/eslint/no_unsafe_console': 'error',
'@kbn/eslint/no_unsafe_js_yaml': 'error',
'@kbn/eslint/no_unsafe_hash': 'error',
'@kbn/imports/no_unresolvable_imports': 'error',
'@kbn/imports/uniform_imports': 'error',
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-eslint-plugin-eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = {
no_constructor_args_in_property_initializers: require('./rules/no_constructor_args_in_property_initializers'),
no_this_in_property_initializers: require('./rules/no_this_in_property_initializers'),
no_unsafe_console: require('./rules/no_unsafe_console'),
no_unsafe_js_yaml: require('./rules/no_unsafe_js_yaml'),
no_unsafe_hash: require('./rules/no_unsafe_hash'),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import chalk from 'chalk';
import { dump } from 'js-yaml';
import { isPlainObjectType } from './is_plain_object_type';

/**
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-openapi-bundler/tests/bundler/bundle_specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
unlinkSync,
writeFileSync,
} from 'fs';
import { dump, load } from 'js-yaml';
import { OpenAPIV3 } from 'openapi-types';
import { bundle, BundlerConfig } from '../../src/openapi_bundler';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { readFileSync } from 'fs';
import { load } from 'js-yaml';
import { join } from 'path';
import { bundleFolder, readBundledSpecs } from './bundle_specs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { dump } from 'js-yaml';
import { OpenAPIV3 } from 'openapi-types';
import { bundleSpecs } from './bundle_specs';
import { createOASDocument } from '../create_oas_document';
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-openapi-bundler/tests/merger/merge_specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
unlinkSync,
writeFileSync,
} from 'fs';
import { dump, load } from 'js-yaml';
import { OpenAPIV3 } from 'openapi-types';
import { merge, MergerConfig } from '../../src/openapi_merger';

Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/src/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function readLimits(path: string): Limits {
}
}

return yaml ? Yaml.safeLoad(yaml) : {};
return yaml ? Yaml.load(yaml) : {};
}

export function validateLimitsForAllBundles(
Expand Down Expand Up @@ -136,6 +136,6 @@ export function updateBundleLimits({
pageLoadAssetSize,
};

Fs.writeFileSync(limitsPath, Yaml.safeDump(newLimits));
Fs.writeFileSync(limitsPath, Yaml.dump(newLimits));
log.success(`wrote updated limits to ${limitsPath}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getAllFtrConfigsAndManifests = () => {
const allFtrConfigs: string[] = [];

for (const manifestRelPath of manifestPaths.all) {
const manifest = JsYaml.safeLoad(
const manifest = JsYaml.load(
Fs.readFileSync(Path.resolve(REPO_ROOT, manifestRelPath), 'utf8')
) as FtrConfigsManifest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Del from 'del';

import * as Rx from 'rxjs';
import { map, filter, take } from 'rxjs';
import { dump } from 'js-yaml';
import { getConfigFromFiles } from '@kbn/config';

const configFileLogConsole = follow(
Expand Down
1 change: 1 addition & 0 deletions src/cli_encryption_keys/encryption_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import crypto from 'crypto';
import { join } from 'path';
import { get } from 'lodash';
import { readFileSync } from 'fs';
import { load } from 'js-yaml';

import { getConfigDirectory } from '@kbn/utils';

Expand Down
1 change: 1 addition & 0 deletions src/cli_encryption_keys/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { dump } from 'js-yaml';
import { isEmpty } from 'lodash';
import { interactive } from './interactive';
import { Logger } from '../cli/logger';
Expand Down
1 change: 1 addition & 0 deletions src/cli_encryption_keys/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { writeFileSync } from 'fs';
import { join } from 'path';
import { confirm, question } from '../cli/keystore/utils';
import { getConfigDirectory } from '@kbn/utils';
import { dump } from 'js-yaml';

export async function interactive(keys, docs, logger) {
const settings = Object.keys(keys);
Expand Down
1 change: 1 addition & 0 deletions src/dev/build/tasks/fleet/bundle_packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Fsp from 'fs/promises';
import Path from 'path';

import JSON5 from 'json5';
import { load, dump } from 'js-yaml';
import { asyncForEach } from '@kbn/std';
import { ToolingLog } from '@kbn/tooling-log';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { dump } from 'js-yaml';
import { Build, Config, mkdirp } from '../../lib';

export async function createOSPackageKibanaYML(config: Config, build: Build) {
Expand Down
4 changes: 2 additions & 2 deletions src/dev/buildkite_migration/rewrite_buildkite_agent_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async function rewriteFile(ymlPath: string, log: ToolingLog) {
let file = await readFile(resolve(REPO_ROOT, ymlPath), 'utf-8');

log.info('Loading: ' + ymlPath);
const doc = yaml.safeLoad(file);
const doc = yaml.load(file);

if (!doc.steps) {
log.info('No steps, skipping: ' + ymlPath);
Expand All @@ -153,7 +153,7 @@ async function rewriteFile(ymlPath: string, log: ToolingLog) {
if (isQueueTargetingRule(step) && !step.agents.queue.startsWith('kb-static')) {
log.info('Rewriting: ' + ymlPath, step);
file = editYmlInPlace(file, ['agents:', `queue: ${step.agents.queue}`], () => {
return yaml.safeDump({ agents: getFullAgentTargetingRule(step.agents.queue) }).split('\n');
return yaml.dump({ agents: getFullAgentTargetingRule(step.agents.queue) }).split('\n');
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/dev/stylelint/lint_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import stylelint from 'stylelint';
import path from 'path';
import { safeLoad } from 'js-yaml';
import { load } from 'js-yaml';
import fs from 'fs';
import { createFailError } from '@kbn/dev-cli-errors';

// load the include globs from .stylelintrc and convert them to regular expressions for filtering files
const stylelintPath = path.resolve(__dirname, '..', '..', '..', '.stylelintrc');
const styleLintConfig = safeLoad(fs.readFileSync(stylelintPath));
const styleLintConfig = load(fs.readFileSync(stylelintPath));

/**
* Lints a list of files with eslint. eslint reports are written to the log
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/interactive_setup/server/kibana_config_writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ export class KibanaConfigWriter {
);

const existingCommentedConfig = KibanaConfigWriter.commentOutKibanaConfig(existingConfig.raw);
configToWrite = `${existingCommentedConfig}\n\n# This section was automatically generated during setup.\n${yaml.safeDump(
configToWrite = `${existingCommentedConfig}\n\n# This section was automatically generated during setup.\n${yaml.dump(
{ ...existingConfig.parsed, ...config },
{ flowLevel: 1 }
)}\n`;
} else {
configToWrite = `${
existingConfig.raw
}\n\n# This section was automatically generated during setup.\n${yaml.safeDump(config, {
}\n\n# This section was automatically generated during setup.\n${yaml.dump(config, {
flowLevel: 1,
})}\n`;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ export class KibanaConfigWriter {

let parsedConfig: Record<string, unknown>;
try {
parsedConfig = getFlattenedObject(yaml.safeLoad(rawConfig) ?? {});
parsedConfig = getFlattenedObject(yaml.load(rawConfig) ?? {});
} catch (err) {
this.logger.error(`Failed to parse configuration file: ${getDetailedErrorMessage(err)}.`);
throw err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { accessSync, constants, readFileSync, statSync } from 'fs';
import { load } from 'js-yaml';
import { dirname, join } from 'path';
import { Observable, firstValueFrom } from 'rxjs';
import { ensureDeepObject } from '@kbn/std';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/packages/kbn-data-forge/src/lib/create_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DEFAULTS } from '../constants';

export async function readConfig(filePath: string): Promise<PartialConfig> {
const data = await promises.readFile(filePath);
const decodedPartialConfig = PartialConfigRT.decode(yaml.safeLoad(data.toString()));
const decodedPartialConfig = PartialConfigRT.decode(yaml.load(data.toString()));
if (isLeft(decodedPartialConfig)) {
throw new Error(
`Could not validate config: ${PathReporter.report(decodedPartialConfig).join('\n')}`
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/cloud_defend/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function getSelectorsAndResponsesFromYaml(configuration: string): {
let responses: Response[] = [];

try {
const result = yaml.safeLoad(configuration);
const result = yaml.load(configuration);

if (result) {
// iterate selector/response types
Expand Down Expand Up @@ -107,5 +107,5 @@ export function getYamlFromSelectorsAndResponses(selectors: Selector[], response
return current;
}, schema);

return yaml.safeDump(schema);
return yaml.dump(schema);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('<ControlGeneralView />', () => {
const configuration = input?.vars?.configuration?.value;

try {
const json = yaml.safeLoad(configuration);
const json = yaml.load(configuration);

expect(json.file.selectors.length).toBe(getAllByTestId('cloud-defend-selector').length);
expect(json.file.responses.length).toBe(getAllByTestId('cloud-defend-file-response').length);
Expand All @@ -69,7 +69,7 @@ describe('<ControlGeneralView />', () => {
const configuration = input?.vars?.configuration?.value;

try {
const json = yaml.safeLoad(configuration);
const json = yaml.load(configuration);

expect(json.file.selectors.length).toBe(getAllByTestId('cloud-defend-selector').length);
} catch (err) {
Expand All @@ -91,7 +91,7 @@ describe('<ControlGeneralView />', () => {
const configuration = input?.vars?.configuration?.value;

try {
const json = yaml.safeLoad(configuration);
const json = yaml.load(configuration);

expect(json.file.responses.length).toBe(getAllByTestId('cloud-defend-file-response').length);
} catch (err) {
Expand All @@ -113,7 +113,7 @@ describe('<ControlGeneralView />', () => {
const configuration = input?.vars?.configuration?.value;

try {
const json = yaml.safeLoad(configuration);
const json = yaml.load(configuration);

expect(json.process.responses.length).toBe(
getAllByTestId('cloud-defend-process-response').length
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('<ControlGeneralView />', () => {
const configuration = input?.vars?.configuration?.value;

try {
const json = yaml.safeLoad(configuration);
const json = yaml.load(configuration);

expect(json.file.responses[0].match).toHaveLength(1);
} catch (err) {
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('<ControlGeneralView />', () => {
const configuration = input?.vars?.configuration?.value;

try {
const json = yaml.safeLoad(configuration);
const json = yaml.load(configuration);

expect(json.file.selectors).toHaveLength(4);
expect(json.file.selectors[3].name).toEqual(json.file.selectors[0].name + '1');
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/common/services/agent_cm_to_yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import type { dump } from 'js-yaml';

import type { FullAgentConfigMap } from '../types/models/agent_cm';

const CM_KEYS_ORDER = ['apiVersion', 'kind', 'metadata', 'data'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import type { dump } from 'js-yaml';

import type { FullAgentPolicy } from '../types';

const POLICY_KEYS_ORDER = [
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/common/services/output_helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { load } from 'js-yaml';

import {
getAllowedOutputTypeForPolicy,
outputYmlIncludesReservedPerformanceKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { load } from 'js-yaml';

import { installationStatuses } from '../constants';
import type { PackageInfo, NewPackagePolicy, RegistryPolicyTemplate } from '../types';

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/cypress/tasks/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const loginViaConfig = () => {

// read the login details from `kibana.dev.yaml`
cy.readFile(KIBANA_DEV_YML_PATH).then((kibanaDevYml) => {
const config = yaml.safeLoad(kibanaDevYml);
const config = yaml.load(kibanaDevYml);

// programmatically authenticate without interacting with the Kibana login page
request({
Expand Down Expand Up @@ -278,7 +278,7 @@ export const getEnvAuth = (): User => {
} else {
let user: User = { username: '', password: '' };
cy.readFile(KIBANA_DEV_YML_PATH).then((devYml) => {
const config = yaml.safeLoad(devYml);
const config = yaml.load(devYml);
user = { username: config.elasticsearch.username, password: config.elasticsearch.password };
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React, { memo } from 'react';
import styled from 'styled-components';
import { FormattedMessage } from '@kbn/i18n-react';
import { dump } from 'js-yaml';
import {
EuiCodeBlock,
EuiFlexGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import { act, fireEvent, waitFor } from '@testing-library/react';
import { load } from 'js-yaml';

import type { TestRenderer } from '../../../../../../../mock';
import { createFleetTestRendererMock } from '../../../../../../../mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React, { useCallback, useState, useEffect, useMemo } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiSpacer, EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } from '@elastic/eui';
import { load } from 'js-yaml';

import { i18n } from '@kbn/i18n';

Expand Down
Loading

0 comments on commit ff6e90f

Please sign in to comment.