Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node version validator #12976 pr review 2 #2

Merged
Merged
42 changes: 39 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*'],
Expand All @@ -112,7 +112,7 @@ module.exports = {
},

/**
* files that ARE allowed to use devDepenedncies
* Files that ARE allowed to use devDependencies
*/
{
files: [
Expand All @@ -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: [
Expand Down
1 change: 1 addition & 0 deletions scripts/backport.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require('../src/setup_node_env/node_version_validator');
require('backport');
14 changes: 8 additions & 6 deletions scripts/es.js
Original file line number Diff line number Diff line change
@@ -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;
});
1 change: 1 addition & 0 deletions scripts/generate_plugin.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require('../src/setup_node_env');
require('@kbn/plugin-generator').run(process.argv.slice(2));
2 changes: 0 additions & 2 deletions scripts/jest.js
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 0 additions & 2 deletions scripts/jest_integration.js
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions scripts/kbn.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require('../src/setup_node_env');
require('../packages/kbn-pm/cli');

1 change: 1 addition & 0 deletions scripts/makelogs.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require('../src/setup_node_env/node_version_validator');
require('makelogs');
2 changes: 1 addition & 1 deletion scripts/tslint.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require('../src/babel-register');
require('../src/setup_node_env');
require('../src/dev/tslint').runTslintCli();
4 changes: 2 additions & 2 deletions src/setup_node_env/babel_register/index.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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');
2 changes: 1 addition & 1 deletion src/setup_node_env/babel_register/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
4 changes: 2 additions & 2 deletions src/setup_node_env/babel_register/register.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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\//,

Expand Down
2 changes: 0 additions & 2 deletions src/setup_node_env/node_version_validator.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 0 additions & 2 deletions src/utils/node_version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-var */

var _ = require('lodash');
var semver = require('semver');
var pkg = require('../../package.json');
Expand Down