Skip to content

Commit

Permalink
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
Browse files Browse the repository at this point in the history
…-fix'
  • Loading branch information
kibanamachine committed Sep 20, 2024
1 parent 4ce03b7 commit 82f16e7
Show file tree
Hide file tree
Showing 90 changed files with 45 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ async function main() {

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

const locationObj = jsYaml.load(
const locationObj = jsYaml.safeLoad(
locationFileLines.slice(1).join('\n')
) as BackstageLocationResource;
locationObj.spec.targets = pipelines.map(
(fileName) => `${resourceDefinitionsBaseUrl}/${fileName}`
);

const locationYaml = jsYaml.dump(locationObj, { lineWidth: 400 });
const locationYaml = jsYaml.safeDump(locationObj, { lineWidth: 400 });

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

Expand Down
1 change: 0 additions & 1 deletion .buildkite/pipeline-utils/agent_images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* 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
2 changes: 0 additions & 2 deletions .buildkite/pipeline-utils/buildkite/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import axios, { AxiosInstance } from 'axios';
import { execSync, ExecSyncOptions } from 'child_process';

import { dump } from 'js-yaml';

import { parseLinkHeader } from './parse_link_header';
import { Artifact } from './types/artifact';
import { Build, BuildStatus } from './types/build';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as Fs from 'fs';
import * as globby from 'globby';
import minimatch from 'minimatch';

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

import { BuildkiteClient, BuildkiteStep } from '../buildkite';
import { CiStatsClient, TestGroupRunOrderResponse } from './client';
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 { load } from 'js-yaml';

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

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.load(fmYaml.slice(0, fmEnd.index));
fm = Yaml.safeLoad(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 { load as loadYaml } from 'js-yaml';
import { safeLoad as loadYaml } from 'js-yaml';

export const readRolesFromResource = (resourcePath: string) => {
if (!fs.existsSync(resourcePath) || extname(resourcePath) !== '.yml') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

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

/**
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-openapi-bundler/src/utils/read_document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import fs from 'fs/promises';
import { basename, extname } from 'path';
import { load } from 'js-yaml';
import chalk from 'chalk';
import { logger } from '../logger';
import { isPlainObjectType } from './is_plain_object_type';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import fs from 'fs/promises';
import { dump } from 'js-yaml';
import { dirname } from 'path';

export async function writeYamlDocument(filePath: string, document: unknown): Promise<void> {
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-openapi-bundler/tests/bundler/bundle_specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ 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,7 +8,6 @@
*/

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,7 +7,6 @@
* 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: 0 additions & 1 deletion packages/kbn-openapi-bundler/tests/merger/merge_specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ 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.load(yaml) : {};
return yaml ? Yaml.safeLoad(yaml) : {};
}

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

Fs.writeFileSync(limitsPath, Yaml.dump(newLimits));
Fs.writeFileSync(limitsPath, Yaml.safeDump(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.load(
const manifest = JsYaml.safeLoad(
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,7 +15,6 @@ 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: 0 additions & 1 deletion src/cli_encryption_keys/encryption_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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: 0 additions & 1 deletion src/cli_encryption_keys/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* 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: 0 additions & 1 deletion src/cli_encryption_keys/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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: 0 additions & 1 deletion src/dev/build/tasks/fleet/bundle_packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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,7 +9,6 @@

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.load(file);
const doc = yaml.safeLoad(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.dump({ agents: getFullAgentTargetingRule(step.agents.queue) }).split('\n');
return yaml.safeDump({ 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 { load } from 'js-yaml';
import { safeLoad } 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 = load(fs.readFileSync(stylelintPath));
const styleLintConfig = safeLoad(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.dump(
configToWrite = `${existingCommentedConfig}\n\n# This section was automatically generated during setup.\n${yaml.safeDump(
{ ...existingConfig.parsed, ...config },
{ flowLevel: 1 }
)}\n`;
} else {
configToWrite = `${
existingConfig.raw
}\n\n# This section was automatically generated during setup.\n${yaml.dump(config, {
}\n\n# This section was automatically generated during setup.\n${yaml.safeDump(config, {
flowLevel: 1,
})}\n`;
}
Expand Down Expand Up @@ -172,7 +172,7 @@ export class KibanaConfigWriter {

let parsedConfig: Record<string, unknown>;
try {
parsedConfig = getFlattenedObject(yaml.load(rawConfig) ?? {});
parsedConfig = getFlattenedObject(yaml.safeLoad(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,7 +8,6 @@
*/

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.load(data.toString()));
const decodedPartialConfig = PartialConfigRT.decode(yaml.safeLoad(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.load(configuration);
const result = yaml.safeLoad(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.dump(schema);
return yaml.safeDump(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.load(configuration);
const json = yaml.safeLoad(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.load(configuration);
const json = yaml.safeLoad(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.load(configuration);
const json = yaml.safeLoad(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.load(configuration);
const json = yaml.safeLoad(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.load(configuration);
const json = yaml.safeLoad(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.load(configuration);
const json = yaml.safeLoad(configuration);

expect(json.file.selectors).toHaveLength(4);
expect(json.file.selectors[3].name).toEqual(json.file.selectors[0].name + '1');
Expand Down
2 changes: 0 additions & 2 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,8 +5,6 @@
* 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,8 +5,6 @@
* 2.0.
*/

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

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

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

import { load } from 'js-yaml';

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

Expand Down
Loading

0 comments on commit 82f16e7

Please sign in to comment.