diff --git a/.eslintrc.js b/.eslintrc.js index 81685cf797be6..281c1cf4e498e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -96,7 +96,7 @@ module.exports = { }, /** - * files that ARE NOT allowed to use devDepenedncies + * Files that ARE NOT allowed to use devDependencies */ { files: ['packages/kbn-ui-framework/**/*', 'x-pack/**/*'], @@ -112,7 +112,7 @@ module.exports = { }, /** - * files that ARE allowed to use devDepenedncies + * Files that ARE allowed to use devDependencies */ { files: [ @@ -138,7 +138,43 @@ module.exports = { }, /** - * Files that are not transpiled with babel + * Files that run BEFORE node version check + */ + { + files: [ + 'scripts/**/*', + 'src/setup_node_env/**/*', + 'src/utils/node_version.js', + ], + rules: { + 'import/no-commonjs': 'off', + 'prefer-object-spread/prefer-object-spread': 'off', + 'no-var': 'off', + 'prefer-const': 'off', + 'prefer-destructuring': 'off', + 'no-restricted-syntax': [ + 'error', + 'ImportDeclaration', + 'ExportNamedDeclaration', + 'ExportDefaultDeclaration', + 'ExportAllDeclaration', + 'ArrowFunctionExpression', + 'AwaitExpression', + 'ClassDeclaration', + 'RestElement', + 'SpreadElement', + 'YieldExpression', + 'VariableDeclaration[kind="const"]', + 'VariableDeclaration[kind="let"]', + 'VariableDeclarator[id.type="ArrayPattern"]', + 'VariableDeclarator[id.type="ObjectPattern"]', + ], + }, + }, + + /** + * Files that run AFTER node version check + * and are not also transpiled with babel */ { files: [ diff --git a/scripts/backport.js b/scripts/backport.js index 52546548ae8af..34d54d6589c37 100755 --- a/scripts/backport.js +++ b/scripts/backport.js @@ -1 +1,2 @@ +require('../src/setup_node_env/node_version_validator'); require('backport'); diff --git a/scripts/es.js b/scripts/es.js index 556714c51a777..8959dc218cc51 100644 --- a/scripts/es.js +++ b/scripts/es.js @@ -1,16 +1,18 @@ -const path = require('path'); -const pkg = require('../package.json'); -const kbnEs = require('@kbn/es'); +var resolve = require('path').resolve; +var pkg = require('../package.json'); +var kbnEs = require('@kbn/es'); + +require('../src/setup_node_env'); kbnEs .run({ license: 'basic', password: 'changeme', version: pkg.version, - 'source-path': path.resolve(__dirname, '../../elasticsearch'), - 'base-path': path.resolve(__dirname, '../.es'), + 'source-path': resolve(__dirname, '../../elasticsearch'), + 'base-path': resolve(__dirname, '../.es'), }) - .catch(e => { + .catch(function (e) { console.error(e); process.exitCode = 1; }); diff --git a/scripts/generate_plugin.js b/scripts/generate_plugin.js index cb9f2c8cf1f6a..6161e11f99214 100644 --- a/scripts/generate_plugin.js +++ b/scripts/generate_plugin.js @@ -1 +1,2 @@ +require('../src/setup_node_env'); require('@kbn/plugin-generator').run(process.argv.slice(2)); diff --git a/scripts/jest.js b/scripts/jest.js index 65e4fb754394e..d4d6c47d47159 100755 --- a/scripts/jest.js +++ b/scripts/jest.js @@ -1,5 +1,3 @@ -/* eslint-disable no-var */ - // # Run Jest tests // // All args will be forwarded directly to Jest, e.g. to watch tests run: diff --git a/scripts/jest_integration.js b/scripts/jest_integration.js index a8c83fc16b181..143148f903266 100755 --- a/scripts/jest_integration.js +++ b/scripts/jest_integration.js @@ -1,5 +1,3 @@ -/* eslint-disable no-var */ - // # Run Jest integration tests // // All args will be forwarded directly to Jest, e.g. to watch tests run: diff --git a/scripts/kbn.js b/scripts/kbn.js index b4aa213f017df..750e51a66e4d7 100644 --- a/scripts/kbn.js +++ b/scripts/kbn.js @@ -1,2 +1,3 @@ +require('../src/setup_node_env'); require('../packages/kbn-pm/cli'); diff --git a/scripts/makelogs.js b/scripts/makelogs.js index b1cc91bfb0e73..aed9d77ec3754 100644 --- a/scripts/makelogs.js +++ b/scripts/makelogs.js @@ -1 +1,2 @@ +require('../src/setup_node_env/node_version_validator'); require('makelogs'); diff --git a/scripts/tslint.js b/scripts/tslint.js index 74613741b9119..5b96e8e17b48b 100644 --- a/scripts/tslint.js +++ b/scripts/tslint.js @@ -1,2 +1,2 @@ -require('../src/babel-register'); +require('../src/setup_node_env'); require('../src/dev/tslint').runTslintCli(); diff --git a/src/setup_node_env/babel_register/index.js b/src/setup_node_env/babel_register/index.js index 0f503322ebe68..2827283e204a7 100644 --- a/src/setup_node_env/babel_register/index.js +++ b/src/setup_node_env/babel_register/index.js @@ -1,7 +1,7 @@ // unless we are running a prebuilt/distributable version of // kibana, automatically transpile typescript to js before babel if (!global.__BUILT_WITH_BABEL__) { - const { resolve } = require('path'); + var resolve = require('path').resolve; require('ts-node').register({ transpileOnly: true, cacheDirectory: resolve(__dirname, '../../../optimize/.cache/ts-node') @@ -10,6 +10,6 @@ if (!global.__BUILT_WITH_BABEL__) { // register and polyfill need to happen in this // order and in separate files. Checkout each file -// for a much more detailed explaination +// for a much more detailed explanation require('./register'); require('./polyfill'); diff --git a/src/setup_node_env/babel_register/polyfill.js b/src/setup_node_env/babel_register/polyfill.js index fedca3745ba87..e1879af99bc1a 100644 --- a/src/setup_node_env/babel_register/polyfill.js +++ b/src/setup_node_env/babel_register/polyfill.js @@ -7,4 +7,4 @@ // // This is why we have this single statement in it's own file and require // it from ./index.js -import 'babel-polyfill'; +require('babel-polyfill'); diff --git a/src/setup_node_env/babel_register/register.js b/src/setup_node_env/babel_register/register.js index 9f7be83bba41d..23f63a87eac41 100644 --- a/src/setup_node_env/babel_register/register.js +++ b/src/setup_node_env/babel_register/register.js @@ -1,4 +1,4 @@ -const { resolve } = require('path'); +var resolve = require('path').resolve; // this must happen before `require('babel-register')` and can't be changed // once the module has been loaded @@ -7,7 +7,7 @@ if (!process.env.BABEL_CACHE_PATH) { } // paths that babel-register should ignore -const ignore = [ +var ignore = [ /\/bower_components\//, /\/kbn-pm\/dist\//, diff --git a/src/setup_node_env/node_version_validator.js b/src/setup_node_env/node_version_validator.js index a0013062a491e..6762b19d208c2 100644 --- a/src/setup_node_env/node_version_validator.js +++ b/src/setup_node_env/node_version_validator.js @@ -1,5 +1,3 @@ -/* eslint-disable no-var */ - // Note: This is written in ES5 so we can run this before anything else // and gives support for older NodeJS versions var NodeVersion = require('../utils/node_version'); diff --git a/src/utils/node_version.js b/src/utils/node_version.js index 335e151f6d80f..975477c145836 100644 --- a/src/utils/node_version.js +++ b/src/utils/node_version.js @@ -1,5 +1,3 @@ -/* eslint-disable no-var */ - var _ = require('lodash'); var semver = require('semver'); var pkg = require('../../package.json');