Skip to content

Commit

Permalink
autofix all violations
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Dec 14, 2019
1 parent a07fa9f commit c2c1253
Show file tree
Hide file tree
Showing 4,245 changed files with 87,646 additions and 82,815 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

require('./src/setup_node_env');

module.exports = function (grunt) {
module.exports = function(grunt) {
// set the config once before calling load-grunt-config
// and once during so that we have access to it via
// grunt.config.get() within the config files
Expand All @@ -35,8 +35,8 @@ module.exports = function (grunt) {
init: true,
config: config,
loadGruntTasks: {
pattern: ['grunt-*', '@*/grunt-*', 'gruntify-*', '@*/gruntify-*']
}
pattern: ['grunt-*', '@*/grunt-*', 'gruntify-*', '@*/gruntify-*'],
},
});

// load task definitions
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-analytics/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
plugins: ['@babel/plugin-proposal-class-properties'],
env: {
web: {
presets: ['@kbn/babel-preset/webpack_preset']
presets: ['@kbn/babel-preset/webpack_preset'],
},
node: {
presets: ['@kbn/babel-preset/node_preset'],
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-babel-code-parser/src/can_require.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function canRequire(entry, cwd = require.resolve.paths(entry) || []) {
// looking recursively as normal starting
// from those locations.
return require.resolve(entry, {
paths: [].concat(cwd)
paths: [].concat(cwd),
});
} catch (e) {
return false;
Expand Down
6 changes: 4 additions & 2 deletions packages/kbn-babel-code-parser/src/code_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function parseEntries(cwd, entries, strategy, results, wasParsed =
// Test each entry against canRequire function
const entriesQueue = entries.map(entry => canRequire(entry));

while(entriesQueue.length) {
while (entriesQueue.length) {
// Get the first element in the queue as
// select it as our current entry to parse
const mainEntry = entriesQueue.shift();
Expand All @@ -93,7 +93,9 @@ export async function parseEntries(cwd, entries, strategy, results, wasParsed =
}

// Find new entries and adds them to the end of the queue
entriesQueue.push(...(await strategy(sanitizedCwd, parseSingleFile, mainEntry, wasParsed, results)));
entriesQueue.push(
...(await strategy(sanitizedCwd, parseSingleFile, mainEntry, wasParsed, results))
);

// Mark the current main entry as already parsed
wasParsed[mainEntry] = true;
Expand Down
22 changes: 17 additions & 5 deletions packages/kbn-babel-code-parser/src/strategies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { parseSingleFile } from './code_parser';
import { _calculateTopLevelDependency, dependenciesParseStrategy } from './strategies';

jest.mock('./can_require', () => ({
canRequire: jest.fn()
canRequire: jest.fn(),
}));

jest.mock('fs', () => ({
readFile: jest.fn()
readFile: jest.fn(),
}));

const mockCwd = '/tmp/project/dir/';
Expand Down Expand Up @@ -69,7 +69,13 @@ describe('Code Parser Strategies', () => {
}
});

const results = await dependenciesParseStrategy(mockCwd, parseSingleFile, 'dep1/file.js', {}, {});
const results = await dependenciesParseStrategy(
mockCwd,
parseSingleFile,
'dep1/file.js',
{},
{}
);
expect(results[0]).toBe(`${mockCwd}node_modules/dep_from_node_modules/index.js`);
});

Expand All @@ -78,15 +84,21 @@ describe('Code Parser Strategies', () => {
cb(null, `require('./relative_dep')`);
});

canRequire.mockImplementation((entry) => {
canRequire.mockImplementation(entry => {
if (entry === `${mockCwd}dep1/relative_dep`) {
return `${entry}/index.js`;
}

return false;
});

const results = await dependenciesParseStrategy(mockCwd, parseSingleFile, 'dep1/file.js', {}, {});
const results = await dependenciesParseStrategy(
mockCwd,
parseSingleFile,
'dep1/file.js',
{},
{}
);
expect(results[0]).toBe(`${mockCwd}dep1/relative_dep/index.js`);
});

Expand Down
36 changes: 18 additions & 18 deletions packages/kbn-babel-code-parser/src/visitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
// raw values on require + require.resolve
CallExpression: ({ node }) => {
// AST check for require expressions
const isRequire = (node) => {
const isRequire = node => {
return matches({
callee: {
type: 'Identifier',
name: 'require'
}
name: 'require',
},
})(node);
};

// AST check for require.resolve expressions
const isRequireResolve = (node) => {
const isRequireResolve = node => {
return matches({
callee: {
type: 'MemberExpression',
object: {
type: 'Identifier',
name: 'require'
name: 'require',
},
property: {
type: 'Identifier',
name: 'resolve'
}
}
name: 'resolve',
},
},
})(node);
};

Expand All @@ -66,12 +66,12 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
// raw values on import
ImportDeclaration: ({ node }) => {
// AST check for supported import expressions
const isImport = (node) => {
const isImport = node => {
return matches({
type: 'ImportDeclaration',
source: {
type: 'StringLiteral'
}
type: 'StringLiteral',
},
})(node);
};

Expand All @@ -85,12 +85,12 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
// raw values on export from
ExportNamedDeclaration: ({ node }) => {
// AST check for supported export from expressions
const isExportFrom = (node) => {
const isExportFrom = node => {
return matches({
type: 'ExportNamedDeclaration',
source: {
type: 'StringLiteral'
}
type: 'StringLiteral',
},
})(node);
};

Expand All @@ -104,12 +104,12 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
// raw values on export * from
ExportAllDeclaration: ({ node }) => {
// AST check for supported export * from expressions
const isExportAllFrom = (node) => {
const isExportAllFrom = node => {
return matches({
type: 'ExportAllDeclaration',
source: {
type: 'StringLiteral'
}
type: 'StringLiteral',
},
})(node);
};

Expand All @@ -118,7 +118,7 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
const exportAllFromSource = node.source;
dependenciesAcc.push(exportAllFromSource.value);
}
}
},
};
})();
}
4 changes: 2 additions & 2 deletions packages/kbn-babel-code-parser/src/visitors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import * as parser from '@babel/parser';
import traverse from '@babel/traverse';
import { dependenciesVisitorsGenerator } from './visitors';

const visitorsApplier = (code) => {
const visitorsApplier = code => {
const result = [];
traverse(
parser.parse(code, {
sourceType: 'unambiguous',
plugins: ['exportDefaultFrom']
plugins: ['exportDefaultFrom'],
}),
dependenciesVisitorsGenerator(result)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-babel-preset/common_babel_parser_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ module.exports = {
'exportDefaultFrom',
'exportNamespaceFrom',
'objectRestSpread',
'throwExpressions'
'throwExpressions',
],
};
24 changes: 11 additions & 13 deletions packages/kbn-babel-preset/node_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@
module.exports = (_, options = {}) => {
const overrides = [];
if (!process.env.ALLOW_PERFORMANCE_HOOKS_IN_TASK_MANAGER) {
overrides.push(
{
test: [/x-pack[\/\\]legacy[\/\\]plugins[\/\\]task_manager/],
plugins: [
[
require.resolve('babel-plugin-filter-imports'),
{
imports: {
perf_hooks: ['performance'],
},
overrides.push({
test: [/x-pack[\/\\]legacy[\/\\]plugins[\/\\]task_manager/],
plugins: [
[
require.resolve('babel-plugin-filter-imports'),
{
imports: {
perf_hooks: ['performance'],
},
],
},
],
}
);
],
});
}

return {
Expand Down
5 changes: 4 additions & 1 deletion packages/kbn-interpreter/src/common/lib/get_by_alias.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('getByAlias', () => {
bar: { name: 'bar', aliases: ['b'] },
};

const fnsArray = [{ name: 'foo', aliases: ['f'] }, { name: 'bar', aliases: ['b'] }];
const fnsArray = [
{ name: 'foo', aliases: ['f'] },
{ name: 'bar', aliases: ['b'] },
];

it('returns the function by name', () => {
expect(getByAlias(fnsObject, 'foo')).toBe(fnsObject.foo);
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-interpreter/src/common/registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/


/**
* Add a new set of registries to an existing set of registries.
*
Expand Down
30 changes: 12 additions & 18 deletions packages/kbn-interpreter/tasks/build/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,19 @@ const del = require('del');
const supportsColor = require('supports-color');
const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-utils');

const {
ROOT_DIR,
BUILD_DIR,
} = require('./paths');
const { ROOT_DIR, BUILD_DIR } = require('./paths');

const unknownFlags = [];
const flags = getopts(process.argv, {
boolean: [
'watch',
'dev',
'help',
'debug'
],
boolean: ['watch', 'dev', 'help', 'debug'],
unknown(name) {
unknownFlags.push(name);
}
},
});

const log = new ToolingLog({
level: pickLevelFromFlags(flags),
writeTo: process.stdout
writeTo: process.stdout,
});

if (unknownFlags.length) {
Expand All @@ -64,7 +56,7 @@ if (flags.help) {
process.exit();
}

withProcRunner(log, async (proc) => {
withProcRunner(log, async proc => {
log.info('Deleting old output');
await del(BUILD_DIR);

Expand All @@ -80,20 +72,22 @@ withProcRunner(log, async (proc) => {
cmd: 'babel',
args: [
'src',
'--ignore', `*.test.js`,
'--out-dir', relative(cwd, BUILD_DIR),
'--ignore',
`*.test.js`,
'--out-dir',
relative(cwd, BUILD_DIR),
'--copy-files',
...(flags.dev ? ['--source-maps', 'inline'] : []),
...(flags.watch ? ['--watch'] : ['--quiet'])
...(flags.watch ? ['--watch'] : ['--quiet']),
],
wait: true,
env,
cwd
cwd,
}),
]);

log.success('Complete');
}).catch((error) => {
}).catch(error => {
log.error(error);
process.exit(1);
});
1 change: 0 additions & 1 deletion packages/kbn-interpreter/tasks/build/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ exports.SOURCE_DIR = resolve(exports.ROOT_DIR, 'src');
exports.BUILD_DIR = resolve(exports.ROOT_DIR, 'target');

exports.BABEL_PRESET_PATH = require.resolve('@kbn/babel-preset/webpack_preset');

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { extname } = require('path');

const { transform } = require('@babel/core');

exports.createServerCodeTransformer = (sourceMaps) => {
exports.createServerCodeTransformer = sourceMaps => {
return (content, path) => {
switch (extname(path)) {
case '.js':
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-spec-to-console/bin/spec_to_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/


const fs = require('fs');
const path = require('path');
const program = require('commander');
Expand Down Expand Up @@ -48,7 +47,7 @@ files.forEach(file => {
try {
fs.mkdirSync(program.directory, { recursive: true });
fs.writeFileSync(outputPath, output + '\n');
} catch(e) {
} catch (e) {
console.log('Cannot write file ', e);
}
} else {
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-spec-to-console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
* under the License.
*/


const convert = require('./lib/convert');
module.exports = convert;
1 change: 0 additions & 1 deletion packages/kbn-spec-to-console/lib/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/


const convert = require('./convert');

const clusterHealthSpec = require('../test/fixtures/cluster_health_spec');
Expand Down
Loading

0 comments on commit c2c1253

Please sign in to comment.