chore(NA): merge and solve conflicts with 7.x (#34645)

This commit is contained in:
Tiago Costa 2019-04-05 19:14:26 +01:00 committed by GitHub
parent d6a9de54f5
commit f062c97302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
259 changed files with 1003 additions and 1221 deletions

View file

@ -2,6 +2,7 @@ node_modules
bower_components
/data
/build
/target
/.es
/plugins
/optimize

View file

@ -1,7 +1,5 @@
const { resolve } = require('path');
const { readdirSync } = require('fs');
const restrictedModules = { paths: ['gulp-util'] };
const { resolve } = require('path');
const APACHE_2_0_LICENSE_HEADER = `
/*
@ -33,62 +31,7 @@ const ELASTIC_LICENSE_HEADER = `
`;
module.exports = {
extends: ['@elastic/eslint-config-kibana', '@elastic/eslint-config-kibana/jest'],
plugins: ['@kbn/eslint-plugin-eslint'],
settings: {
'import/resolver': {
'@kbn/eslint-import-resolver-kibana': {
forceNode: true,
},
},
},
rules: {
'no-restricted-imports': [2, restrictedModules],
'no-restricted-modules': [2, restrictedModules],
'@kbn/eslint/no-restricted-paths': [
'error',
{
basePath: __dirname,
zones: [
{
target: [
'src/legacy/**/*',
'x-pack/**/*',
'!x-pack/**/*.test.*',
'src/plugins/**/(public|server)/**/*',
'src/core/(public|server)/**/*',
],
from: [
'src/core/public/**/*',
'!src/core/public/index*',
'!src/core/public/utils/**/*',
'src/core/server/**/*',
'!src/core/server/index*',
'src/plugins/**/public/**/*',
'!src/plugins/**/public/index*',
'src/plugins/**/server/**/*',
'!src/plugins/**/server/index*',
],
allowSameFolder: true,
},
],
},
],
'@kbn/eslint/module_migration': [
'error',
[
{
from: 'expect.js',
to: '@kbn/expect',
},
],
],
},
extends: ['@elastic/eslint-config-kibana'],
overrides: [
/**
@ -112,6 +55,7 @@ module.exports = {
'src/legacy/server/saved_objects/**/*',
'x-pack/plugins/apm/**/*',
'x-pack/plugins/canvas/**/*',
'**/*.{ts,tsx}',
],
plugins: ['prettier'],
rules: Object.assign(
@ -123,11 +67,96 @@ module.exports = {
),
},
/**
* Files that require Apache 2.0 headers, settings
* are overridden below for files that require Elastic
* Licence headers
*/
{
files: ['**/*.{js,ts,tsx}'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: APACHE_2_0_LICENSE_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [ELASTIC_LICENSE_HEADER],
},
],
},
},
/**
* Files that require Elastic license headers instead of Apache 2.0 header
*/
{
files: ['x-pack/**/*.{js,ts,tsx}'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: ELASTIC_LICENSE_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [APACHE_2_0_LICENSE_HEADER],
},
],
},
},
/**
* Restricted paths
*/
{
files: ['**/*.{js,ts,tsx}'],
rules: {
'@kbn/eslint/no-restricted-paths': [
'error',
{
basePath: __dirname,
zones: [
{
target: [
'src/legacy/**/*',
'x-pack/**/*',
'!x-pack/**/*.test.*',
'src/plugins/**/(public|server)/**/*',
'src/core/(public|server)/**/*',
],
from: [
'src/core/public/**/*',
'!src/core/public/index*',
'!src/core/public/utils/**/*',
'src/core/server/**/*',
'!src/core/server/index*',
'src/plugins/**/public/**/*',
'!src/plugins/**/public/index*',
'src/plugins/**/server/**/*',
'!src/plugins/**/server/index*',
],
allowSameFolder: true,
},
],
},
],
},
},
/**
* Allow default exports
*/
{
files: ['x-pack/test/functional/apps/**/*', 'x-pack/plugins/apm/**/*'],
files: ['x-pack/test/functional/apps/**/*.js', 'x-pack/plugins/apm/**/*.js'],
rules: {
'import/no-default-export': 'off',
'import/no-named-as-default': 'off',
@ -139,10 +168,10 @@ module.exports = {
*/
{
files: [
'**/public/**',
'**/webpackShims/**',
'packages/kbn-ui-framework/doc_site/src/**',
'src/fixtures/**', // TODO: this directory needs to be more obviously "public" (or go away)
'**/public/**/*.js',
'**/webpackShims/**/*.js',
'packages/kbn-ui-framework/doc_site/src/**/*.js',
'src/fixtures/**/*.js', // TODO: this directory needs to be more obviously "public" (or go away)
],
settings: {
// instructs import/no-extraneous-dependencies to treat modules
@ -170,7 +199,11 @@ module.exports = {
* Files that ARE NOT allowed to use devDependencies
*/
{
files: ['packages/kbn-ui-framework/**/*', 'x-pack/**/*', 'packages/kbn-interpreter/**/*'],
files: [
'packages/kbn-ui-framework/**/*.js',
'x-pack/**/*.js',
'packages/kbn-interpreter/**/*.js',
],
rules: {
'import/no-extraneous-dependencies': [
'error',
@ -188,14 +221,14 @@ module.exports = {
{
files: [
'packages/kbn-ui-framework/**/*.test.js',
'packages/kbn-ui-framework/doc_site/**/*',
'packages/kbn-ui-framework/generator-kui/**/*',
'packages/kbn-ui-framework/doc_site/**/*.js',
'packages/kbn-ui-framework/generator-kui/**/*.js',
'packages/kbn-ui-framework/Gruntfile.js',
'packages/kbn-es/src/**/*',
'packages/kbn-interpreter/tasks/**/*',
'packages/kbn-interpreter/src/plugin/**/*',
'x-pack/{dev-tools,tasks,scripts,test,build_chromium}/**/*',
'x-pack/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__}/**/*',
'packages/kbn-es/src/**/*.js',
'packages/kbn-interpreter/tasks/**/*.js',
'packages/kbn-interpreter/src/plugin/**/*.js',
'x-pack/{dev-tools,tasks,scripts,test,build_chromium}/**/*.js',
'x-pack/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__}/**/*.js',
'x-pack/**/*.test.js',
'x-pack/test_utils/**/*',
'x-pack/gulpfile.js',
@ -216,7 +249,7 @@ module.exports = {
* Files that run BEFORE node version check
*/
{
files: ['scripts/**/*', 'src/setup_node_env/**/*'],
files: ['scripts/**/*.js', 'src/setup_node_env/**/*.js'],
rules: {
'import/no-commonjs': 'off',
'prefer-object-spread/prefer-object-spread': 'off',
@ -249,7 +282,7 @@ module.exports = {
{
files: [
'test/functional/services/lib/web_element_wrapper/scroll_into_view_if_necessary.js',
'**/browser_exec_scripts/**/*',
'**/browser_exec_scripts/**/*.js',
],
rules: {
'prefer-object-spread/prefer-object-spread': 'off',
@ -280,14 +313,14 @@ module.exports = {
{
files: [
'.eslintrc.js',
'**/webpackShims/**/*',
'packages/kbn-plugin-generator/**/*',
'packages/kbn-plugin-helpers/**/*',
'packages/kbn-eslint-import-resolver-kibana/**/*',
'**/webpackShims/**/*.js',
'packages/kbn-plugin-generator/**/*.js',
'packages/kbn-plugin-helpers/**/*.js',
'packages/kbn-eslint-import-resolver-kibana/**/*.js',
'packages/kbn-eslint-plugin-eslint/**/*',
'x-pack/gulpfile.js',
'x-pack/dev-tools/mocha/setup_mocha.js',
'x-pack/scripts/*',
'x-pack/scripts/*.js',
],
rules: {
'import/no-commonjs': 'off',
@ -302,55 +335,11 @@ module.exports = {
},
},
/**
* Files that require Apache 2.0 headers, settings
* are overridden below for files that require Elastic
* Licence headers
*/
{
files: ['**/*.js'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: APACHE_2_0_LICENSE_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [ELASTIC_LICENSE_HEADER],
},
],
},
},
/**
* Files that require Elastic license headers instead of Apache 2.0 header
*/
{
files: ['x-pack/**/*.js'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: ELASTIC_LICENSE_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [APACHE_2_0_LICENSE_HEADER],
},
],
},
},
/**
* APM overrides
*/
{
files: ['x-pack/plugins/apm/**/*'],
files: ['x-pack/plugins/apm/**/*.js'],
rules: {
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
'no-console': ['warn', { allow: ['error'] }],
@ -361,7 +350,7 @@ module.exports = {
* GIS overrides
*/
{
files: ['x-pack/plugins/maps/**/*'],
files: ['x-pack/plugins/maps/**/*.js'],
rules: {
'react/prefer-stateless-function': [0, { ignorePureComponents: false }],
},
@ -371,7 +360,7 @@ module.exports = {
* Graph overrides
*/
{
files: ['x-pack/plugins/graph/**/*'],
files: ['x-pack/plugins/graph/**/*.js'],
globals: {
angular: true,
$: true,
@ -394,7 +383,7 @@ module.exports = {
* ML overrides
*/
{
files: ['x-pack/plugins/ml/**/*'],
files: ['x-pack/plugins/ml/**/*.js'],
rules: {
'no-shadow': 'error',
},
@ -404,7 +393,7 @@ module.exports = {
* disable jsx-a11y for kbn-ui-framework
*/
{
files: ['packages/kbn-ui-framework/**'],
files: ['packages/kbn-ui-framework/**/*.js'],
rules: {
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/anchor-has-content': 'off',
@ -418,7 +407,7 @@ module.exports = {
* Monitoring overrides
*/
{
files: ['x-pack/plugins/monitoring/**/*'],
files: ['x-pack/plugins/monitoring/**/*.js'],
rules: {
'block-spacing': ['error', 'always'],
curly: ['error', 'all'],
@ -427,7 +416,7 @@ module.exports = {
},
},
{
files: ['x-pack/plugins/monitoring/public/**/*'],
files: ['x-pack/plugins/monitoring/public/**/*.js'],
env: { browser: true },
},
@ -435,7 +424,7 @@ module.exports = {
* Canvas overrides
*/
{
files: ['x-pack/plugins/canvas/**/*'],
files: ['x-pack/plugins/canvas/**/*.js'],
rules: {
radix: 'error',
curly: ['error', 'all'],
@ -485,8 +474,8 @@ module.exports = {
'x-pack/plugins/canvas/scripts/*.js',
'x-pack/plugins/canvas/tasks/*.js',
'x-pack/plugins/canvas/tasks/**/*.js',
'x-pack/plugins/canvas/__tests__/**/*',
'x-pack/plugins/canvas/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__}/**/*',
'x-pack/plugins/canvas/__tests__/**/*.js',
'x-pack/plugins/canvas/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__}/**/*.js',
],
rules: {
'import/no-extraneous-dependencies': [
@ -499,7 +488,7 @@ module.exports = {
},
},
{
files: ['x-pack/plugins/canvas/canvas_plugin_src/**/*'],
files: ['x-pack/plugins/canvas/canvas_plugin_src/**/*.js'],
globals: { canvas: true, $: true },
rules: {
'import/no-unresolved': [
@ -511,13 +500,13 @@ module.exports = {
},
},
{
files: ['x-pack/plugins/canvas/public/**/*'],
files: ['x-pack/plugins/canvas/public/**/*.js'],
env: {
browser: true,
},
},
{
files: ['x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts/**/*'],
files: ['x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts/**/*.js'],
env: {
jquery: true,
},

View file

@ -4,8 +4,8 @@
To convert existing code over to TypeScript:
1. rename the file from `.js` to either `.ts` (if there is no html or jsx in the file) or `.tsx` (if there is).
2. Ensure tslint is running and installed in the IDE of your choice. There will usually be some linter errors after the file rename.
3. Auto-fix what you can. This will save you a lot of time! VSCode can be set to auto fix tslint errors when files are saved.
2. Ensure eslint is running and installed in the IDE of your choice. There will usually be some linter errors after the file rename.
3. Auto-fix what you can. This will save you a lot of time! VSCode can be set to auto fix eslint errors when files are saved.
### How to fix common TypeScript errors

2
kibana.d.ts vendored
View file

@ -35,7 +35,7 @@ import * as LegacyKibanaServer from './src/legacy/server/kbn_server';
/**
* Re-export legacy types under a namespace.
*/
// tslint:disable:no-namespace
// eslint-disable-next-line @typescript/eslint-no-namespace
export namespace Legacy {
export type IndexPatternsService = LegacyKibanaServer.IndexPatternsService;
export type KibanaConfig = LegacyKibanaServer.KibanaConfig;

View file

@ -57,9 +57,8 @@
"debug-break": "node --nolazy --inspect-brk scripts/kibana --dev",
"precommit": "node scripts/precommit_hook",
"karma": "karma start",
"lint": "yarn run lint:es && yarn run lint:ts && yarn run lint:sass",
"lint": "yarn run lint:es && yarn run lint:sass",
"lint:es": "node scripts/eslint",
"lint:ts": "node scripts/tslint",
"lint:sass": "node scripts/sasslint",
"makelogs": "node scripts/makelogs",
"mocha": "node scripts/mocha",
@ -322,6 +321,8 @@
"@types/type-detect": "^4.0.1",
"@types/uuid": "^3.4.4",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"angular-mocks": "1.4.7",
"archiver": "^3.0.0",
"babel-eslint": "^10.0.1",
@ -339,11 +340,12 @@
"enzyme-adapter-react-16": "^1.9.0",
"enzyme-adapter-utils": "^1.10.0",
"enzyme-to-json": "^3.3.4",
"eslint": "^5.15.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-ban": "^1.2.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.3.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
@ -407,10 +409,6 @@
"supertest": "^3.1.0",
"supertest-as-promised": "^4.0.2",
"tree-kill": "^1.1.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-microsoft-contrib": "^6.0.0",
"tslint-plugin-prettier": "^2.0.0",
"typescript": "^3.3.3333",
"typings-tester": "^0.3.2",
"vinyl-fs": "^3.0.2",

View file

@ -47,4 +47,5 @@ declare const datemath: {
): moment.Moment | undefined;
};
// eslint-disable-next-line import/no-default-export
export default datemath;

View file

@ -1,183 +1,32 @@
const semver = require('semver');
const PKG = require('../../package.json');
const RESTRICTED_GLOBALS = require('./restricted_globals');
module.exports = {
parser: 'babel-eslint',
plugins: [
'mocha',
'babel',
'react',
'react-hooks',
'import',
'no-unsanitized',
'prefer-object-spread',
'jsx-a11y',
extends: [
'./javascript.js',
'./typescript.js',
'./jest.js',
],
plugins: ['@kbn/eslint-plugin-eslint'],
settings: {
react: {
version: semver.valid(semver.coerce(PKG.dependencies.react)),
},
parserOptions: {
ecmaVersion: 6
},
env: {
es6: true,
node: true,
mocha: true,
browser: true,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
ecmaFeatures: { experimentalObjectRestSpread: true },
es6: true
},
rules: {
'block-scoped-var': 'error',
camelcase: [ 'error', { properties: 'never' } ],
'comma-dangle': 'off',
'comma-spacing': ['error', { before: false, after: true }],
'comma-style': [ 'error', 'last' ],
'consistent-return': 'off',
curly: [ 'error', 'multi-line' ],
'dot-location': [ 'error', 'property' ],
'dot-notation': [ 'error', { allowKeywords: true } ],
eqeqeq: [ 'error', 'allow-null' ],
'guard-for-in': 'error',
indent: [ 'error', 2, { SwitchCase: 1 } ],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'max-len': [ 'error', 140, 2, { ignoreComments: true, ignoreUrls: true } ],
'new-cap': [ 'error', { capIsNewExceptions: [ 'Private' ] } ],
'no-bitwise': 'off',
'no-caller': 'error',
'no-cond-assign': 'off',
'no-const-assign': 'error',
'no-debugger': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-parens': 'off',
'no-extra-semi': [ 'error' ],
'no-global-assign': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-loop-func': 'error',
'no-multi-spaces': 'off',
'no-multi-str': 'off',
'no-nested-ternary': 'error',
'no-new': 'off',
'no-path-concat': 'off',
'no-proto': 'error',
'no-redeclare': 'error',
'no-restricted-globals': ['error', ...RESTRICTED_GLOBALS],
'no-return-assign': 'off',
'no-script-url': 'error',
'no-sequences': 'error',
'no-shadow': 'off',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-underscore-dangle': 'off',
'no-unsanitized/method': 'error',
'no-unsanitized/property': 'error',
'no-unused-expressions': 'off',
'no-unused-vars': [ 'error' ],
'no-use-before-define': [ 'error', 'nofunc' ],
'no-var': 'error',
'no-with': 'error',
'one-var': [ 'error', 'never' ],
'prefer-const': 'error',
quotes: [ 'error', 'single', { allowTemplateLiterals: true } ],
'semi-spacing': [ 'error', { before: false, after: true } ],
semi: [ 'error', 'always' ],
'space-before-blocks': [ 'error', 'always' ],
'space-before-function-paren': [ 'error', { anonymous: 'always', named: 'never' } ],
'space-in-parens': [ 'error', 'never' ],
'space-infix-ops': [ 'error', { int32Hint: false } ],
'space-unary-ops': [ 'error' ],
strict: [ 'error', 'never' ],
'valid-typeof': 'error',
'wrap-iife': [ 'error', 'outside' ],
'eol-last': ['error', 'always'],
yoda: 'off',
'object-curly-spacing': 'off', // overridden with babel/object-curly-spacing
'babel/object-curly-spacing': [ 'error', 'always' ],
'jsx-quotes': ['error', 'prefer-double'],
'react/jsx-uses-react': 'error',
'react/react-in-jsx-scope': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-pascal-case': 'error',
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
'react/jsx-closing-tag-location': 'error',
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
'react/jsx-indent-props': ['error', 2],
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
'react/no-danger': 'error',
'react/self-closing-comp': 'error',
'react/jsx-wrap-multilines': ['error', {
declaration: true,
assignment: true,
return: true,
arrow: true,
}],
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
'jsx-a11y/accessible-emoji': 'error',
'jsx-a11y/alt-text': 'error',
'jsx-a11y/anchor-has-content': 'error',
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-role': 'error',
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/heading-has-content': 'error',
'jsx-a11y/html-has-lang': 'error',
'jsx-a11y/iframe-has-title': 'error',
'jsx-a11y/interactive-supports-focus': 'error',
'jsx-a11y/media-has-caption': 'error',
'jsx-a11y/mouse-events-have-key-events': 'error',
'jsx-a11y/no-access-key': 'error',
'jsx-a11y/no-distracting-elements': 'error',
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
'jsx-a11y/no-noninteractive-element-interactions': 'error',
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
'jsx-a11y/no-redundant-roles': 'error',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
'jsx-a11y/scope': 'error',
'jsx-a11y/tabindex-no-positive': 'error',
'jsx-a11y/label-has-associated-control': 'error',
'react/jsx-equals-spacing': ['error', 'never'],
'react/jsx-indent': ['error', 2],
'react/no-will-update-set-state': 'error',
'react/no-is-mounted': 'error',
'react/no-multi-comp': ['error', { ignoreStateless: true }],
'react/no-unknown-property': 'error',
'react/prefer-es6-class': ['error', 'always'],
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
'react/no-unescaped-entities': 'error',
'mocha/handle-done-callback': 'error',
'mocha/no-exclusive-tests': 'error',
'import/no-unresolved': [ 'error', { 'amd': true, 'commonjs': true } ],
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-duplicates': 'error',
'import/no-dynamic-require': 'error',
'prefer-object-spread/prefer-object-spread': 'error',
'@kbn/eslint/module_migration': [
'error',
[
{
from: 'expect.js',
to: '@kbn/expect',
},
{
from: 'x-pack',
toRelative: 'x-pack',
},
],
],
}
}
};

View file

@ -0,0 +1,199 @@
const semver = require('semver');
const { readdirSync } = require('fs');
const PKG = require('../../package.json');
const RESTRICTED_GLOBALS = require('./restricted_globals');
const RESTRICTED_MODULES = { paths: ['gulp-util'] };
module.exports = {
overrides: [
/**
* Main JS configuration
*/
{
files: ['**/*.js'],
parser: 'babel-eslint',
plugins: [
'mocha',
'babel',
'react',
'react-hooks',
'import',
'no-unsanitized',
'prefer-object-spread',
'jsx-a11y',
],
settings: {
react: {
version: semver.valid(semver.coerce(PKG.dependencies.react)),
},
'import/resolver': {
'@kbn/eslint-import-resolver-kibana': {
forceNode: true,
},
},
},
env: {
es6: true,
node: true,
mocha: true,
browser: true,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
ecmaFeatures: { experimentalObjectRestSpread: true },
},
rules: {
'block-scoped-var': 'error',
camelcase: [ 'error', { properties: 'never' } ],
'comma-dangle': 'off',
'comma-spacing': ['error', { before: false, after: true }],
'comma-style': [ 'error', 'last' ],
'consistent-return': 'off',
curly: [ 'error', 'multi-line' ],
'dot-location': [ 'error', 'property' ],
'dot-notation': [ 'error', { allowKeywords: true } ],
eqeqeq: [ 'error', 'allow-null' ],
'guard-for-in': 'error',
indent: [ 'error', 2, { SwitchCase: 1 } ],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'max-len': [ 'error', 140, 2, { ignoreComments: true, ignoreUrls: true } ],
'new-cap': [ 'error', { capIsNewExceptions: [ 'Private' ] } ],
'no-bitwise': 'off',
'no-caller': 'error',
'no-cond-assign': 'off',
'no-const-assign': 'error',
'no-debugger': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-parens': 'off',
'no-extra-semi': [ 'error' ],
'no-global-assign': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-loop-func': 'error',
'no-multi-spaces': 'off',
'no-multi-str': 'off',
'no-nested-ternary': 'error',
'no-new': 'off',
'no-path-concat': 'off',
'no-proto': 'error',
'no-redeclare': 'error',
'no-restricted-globals': ['error', ...RESTRICTED_GLOBALS],
'no-restricted-imports': [2, RESTRICTED_MODULES],
'no-restricted-modules': [2, RESTRICTED_MODULES],
'no-return-assign': 'off',
'no-script-url': 'error',
'no-sequences': 'error',
'no-shadow': 'off',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-underscore-dangle': 'off',
'no-unsanitized/method': 'error',
'no-unsanitized/property': 'error',
'no-unused-expressions': 'off',
'no-unused-vars': [ 'error' ],
'no-use-before-define': [ 'error', 'nofunc' ],
'no-var': 'error',
'no-with': 'error',
'one-var': [ 'error', 'never' ],
'prefer-const': 'error',
quotes: [ 'error', 'single', { allowTemplateLiterals: true } ],
'semi-spacing': [ 'error', { before: false, after: true } ],
semi: [ 'error', 'always' ],
'space-before-blocks': [ 'error', 'always' ],
'space-before-function-paren': [ 'error', { anonymous: 'always', named: 'never' } ],
'space-in-parens': [ 'error', 'never' ],
'space-infix-ops': [ 'error', { int32Hint: false } ],
'space-unary-ops': [ 'error' ],
strict: [ 'error', 'never' ],
'valid-typeof': 'error',
'wrap-iife': [ 'error', 'outside' ],
'eol-last': ['error', 'always'],
yoda: 'off',
'object-curly-spacing': 'off', // overridden with babel/object-curly-spacing
'babel/object-curly-spacing': [ 'error', 'always' ],
'jsx-quotes': ['error', 'prefer-double'],
'react/jsx-uses-react': 'error',
'react/react-in-jsx-scope': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-pascal-case': 'error',
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
'react/jsx-closing-tag-location': 'error',
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
'react/jsx-indent-props': ['error', 2],
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
'react/no-danger': 'error',
'react/self-closing-comp': 'error',
'react/jsx-wrap-multilines': ['error', {
declaration: true,
assignment: true,
return: true,
arrow: true,
}],
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
'jsx-a11y/accessible-emoji': 'error',
'jsx-a11y/alt-text': 'error',
'jsx-a11y/anchor-has-content': 'error',
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-role': 'error',
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/heading-has-content': 'error',
'jsx-a11y/html-has-lang': 'error',
'jsx-a11y/iframe-has-title': 'error',
'jsx-a11y/interactive-supports-focus': 'error',
'jsx-a11y/media-has-caption': 'error',
'jsx-a11y/mouse-events-have-key-events': 'error',
'jsx-a11y/no-access-key': 'error',
'jsx-a11y/no-distracting-elements': 'error',
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
'jsx-a11y/no-noninteractive-element-interactions': 'error',
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
'jsx-a11y/no-redundant-roles': 'error',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
'jsx-a11y/scope': 'error',
'jsx-a11y/tabindex-no-positive': 'error',
'jsx-a11y/label-has-associated-control': 'error',
'react/jsx-equals-spacing': ['error', 'never'],
'react/jsx-indent': ['error', 2],
'react/no-will-update-set-state': 'error',
'react/no-is-mounted': 'error',
'react/no-multi-comp': ['error', { ignoreStateless: true }],
'react/no-unknown-property': 'error',
'react/prefer-es6-class': ['error', 'always'],
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
'react/no-unescaped-entities': 'error',
'mocha/handle-done-callback': 'error',
'mocha/no-exclusive-tests': 'error',
'import/no-unresolved': [ 'error', { 'amd': true, 'commonjs': true } ],
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-duplicates': 'error',
'import/no-dynamic-require': 'error',
'prefer-object-spread/prefer-object-spread': 'error',
}
},
]
};

View file

@ -1,7 +1,9 @@
module.exports = {
overrides: [
{
files: ['**/*.test.js'],
files: [
'**/*.{test,test.mocks,mock}.{js,ts,tsx}',
],
plugins: [
'jest',
],
@ -13,6 +15,7 @@ module.exports = {
rules: {
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'import/order': 'off'
},
}
]

View file

@ -15,12 +15,15 @@
},
"homepage": "https://github.com/elastic/eslint-config-kibana#readme",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.14.1",
"eslint": "^5.16.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-ban": "^1.2.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.3.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",

View file

@ -0,0 +1,191 @@
// NOTE: This is the configuration to apply the typescript eslint parser
// in order to lint typescript files with eslint.
// Some IDEs could not be running eslint with the correct extensions yet
// as this package was moved from typescript-eslint-parser to @typescript-eslint/parser
const semver = require('semver');
const PKG = require('../../package.json');
const eslintConfigPrettierTypescriptEslintRules = require('eslint-config-prettier/@typescript-eslint').rules;
module.exports = {
overrides: [
{
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'ban',
'import',
'jsx-a11y',
'prefer-object-spread',
],
settings: {
react: {
version: semver.valid(semver.coerce(PKG.dependencies.react)),
},
},
env: {
es6: true,
node: true,
mocha: true,
browser: true,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true
},
// NOTE: That is to avoid a known performance issue related with the `ts.Program` used by
// typescript eslint. As we are not using rules that need types information, we can safely
// disabling that feature setting the project to undefined. That issue is being addressed
// by the typescript eslint team. More info could be found here:
// https://github.com/typescript-eslint/typescript-eslint/issues/389
// https://github.com/typescript-eslint/typescript-eslint/issues/243
// https://github.com/typescript-eslint/typescript-eslint/pull/361
project: undefined
},
// NOTE: we can't override the extends option here to apply
// all the recommend rules as it is not allowed yet
// more info on: https://github.com/eslint/rfcs/pull/13 and
// https://github.com/eslint/eslint/issues/8813
//
// For now we are using an workaround to create
// those extended rules arrays
rules: Object.assign(
{
// Most of the ports were done according
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md
//
// Old recommended tslint rules
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': ['error', 'array-simple'],
'@typescript-eslint/ban-types': 'error',
'camelcase': 'off',
'@typescript-eslint/camelcase': ['error', {
'properties': 'never',
'ignoreDestructuring': true,
'allow': ['^[A-Z0-9_]+$']
}],
'@typescript-eslint/class-name-casing': 'error',
// TODO: disable this rule until a PR with more options to configure
// get merged and we can then reproduce the old behaviour
// https://github.com/typescript-eslint/typescript-eslint/pull/322
// '@typescript-eslint/explicit-member-accessibility': 'error',
'indent': 'off',
'@typescript-eslint/indent': [ 'error', 2, { SwitchCase: 1 } ],
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-interface': 'error',
'@typescript-eslint/member-ordering': ['error', {
'default': ['public-static-field', 'static-field', 'instance-field']
}],
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-triple-slash-reference': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unified-signatures': 'error',
'arrow-body-style': 'error',
'arrow-parens': 'error',
'comma-dangle': ['error', 'always-multiline'],
'constructor-super': 'error',
'curly': 'error',
'dot-notation': 'error',
'eol-last': 'error',
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
'guard-for-in': 'error',
'import/order': ['error', {
'groups': [
['external', 'builtin'],
'internal',
['parent', 'sibling', 'index'],
],
}],
'max-classes-per-file': ['error', 1],
'max-len': [ 'error', { code: 120, ignoreComments: true, ignoreUrls: true } ],
'new-parens': 'error',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': 'error',
'no-debugger': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-multiple-empty-lines': 'error',
'no-new-wrappers': 'error',
'no-shadow': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef-init': 'error',
'no-unsafe-finally': 'error',
'no-unused-expressions': 'error',
'no-unused-labels': 'error',
'no-var': 'error',
'object-curly-spacing': 'error',
'object-shorthand': 'error',
'prefer-const': 'error',
'quotes': ['error', 'double', { 'avoidEscape': true }],
'quote-props': ['error', 'consistent-as-needed'],
'radix': 'error',
'semi': 'error',
'space-before-function-paren': ['error', {
'anonymous': 'never',
'named': 'never',
'asyncArrow': 'always'
}],
'spaced-comment': ["error", "always", {
"exceptions": ["/"]
}],
'use-isnan': 'error',
// Old tslint yml override or defined rules
'ban/ban': [
2,
{'name': ['describe', 'only'], 'message': 'No exclusive suites.'},
{'name': ['it', 'only'], 'message': 'No exclusive tests.'},
{'name': ['test', 'only'], 'message': 'No exclusive tests.'},
],
'jsx-a11y/accessible-emoji': 'error',
'jsx-a11y/alt-text': 'error',
'jsx-a11y/anchor-has-content': 'error',
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-role': 'error',
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/click-events-have-key-events': 'error',
'jsx-a11y/heading-has-content': 'error',
'jsx-a11y/html-has-lang': 'error',
'jsx-a11y/iframe-has-title': 'error',
'jsx-a11y/interactive-supports-focus': 'error',
'jsx-a11y/media-has-caption': 'error',
'jsx-a11y/mouse-events-have-key-events': 'error',
'jsx-a11y/no-access-key': 'error',
'jsx-a11y/no-distracting-elements': 'error',
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
'jsx-a11y/no-noninteractive-element-interactions': 'error',
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
'jsx-a11y/no-onchange': 'error',
'jsx-a11y/no-redundant-roles': 'error',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
'jsx-a11y/scope': 'error',
'jsx-a11y/tabindex-no-positive': 'error',
'jsx-a11y/label-has-associated-control': 'error',
'import/no-default-export': 'error',
},
eslintConfigPrettierTypescriptEslintRules
)
},
]
};

View file

@ -17,7 +17,7 @@
* under the License.
*/
// tslint:disable max-classes-per-file
// eslint-disable max-classes-per-file
import * as Rx from 'rxjs';

View file

@ -38,6 +38,7 @@ interface JsonObject {
[key: string]: JsonValue;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface JsonArray extends Array<JsonValue> {}
export function fromKueryExpression(

View file

@ -17,16 +17,33 @@
* under the License.
*/
const path = require('path');
const KIBANA_ROOT = path.resolve(__dirname, '../../..');
function checkModuleNameNode(context, mappings, node) {
const mapping = mappings.find(
mapping => mapping.from === node.value || mapping.from.startsWith(node.value + '/')
mapping => mapping.from === node.value || node.value.startsWith(`${mapping.from}/`)
);
if (!mapping) {
return;
}
const newSource = node.value.replace(mapping.from, mapping.to);
let newSource;
// support for toRelative added to migrate away from X-Pack being bundled
// within node modules. after that migration, this can be removed.
if (mapping.toRelative) {
const sourceDirectory = path.dirname(context.getFilename());
const localModulePath = node.value.replace(new RegExp(`^${mapping.from}\/`), '');
const modulePath = path.resolve(KIBANA_ROOT, mapping.toRelative, localModulePath);
const relativePath = path.relative(sourceDirectory, modulePath);
newSource = relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
} else {
newSource = node.value.replace(mapping.from, mapping.to);
}
context.report({
message: `Imported module "${node.value}" should be "${newSource}"`,
loc: node.loc,
@ -51,8 +68,18 @@ module.exports = {
to: {
type: 'string',
},
toRelative: {
type: 'string',
},
},
required: ['from', 'to'],
anyOf: [
{
required: ['from', 'to'],
},
{
required: ['from', 'toRelative'],
},
],
additionalProperties: false,
},
default: [],

View file

@ -1,4 +1,4 @@
// tslint:disable
/* eslint-disable */
// Type definitions for expect.js 0.3.1
// Project: https://github.com/Automattic/expect.js

View file

@ -26,7 +26,7 @@ describe('I18n helper', () => {
});
test('should return false for string object', () => {
// tslint:disable-next-line:no-construct
// eslint-disable-next-line no-new-wrappers
expect(isString(new String('test'))).toBe(false);
});

View file

@ -17,6 +17,8 @@
* under the License.
*/
/* eslint-disable @typescript-eslint/no-var-requires */
import * as i18nModule from './i18n';
describe('I18n engine', () => {

View file

@ -1,2 +0,0 @@
extends:
- ../../tslint.yaml

View file

@ -28,10 +28,10 @@
"@kbn/expect": "link:../../packages/kbn-expect",
"@kbn/plugin-helpers": "link:../../packages/kbn-plugin-helpers",
"babel-eslint": "^10.0.1",
"eslint": "^5.14.1",
"eslint": "^5.16.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.3.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-no-unsanitized": "^3.0.2",

View file

@ -4136,7 +4136,7 @@ const log = {
* @param ...args
*/
write(...args) {
// tslint:disable no-console
// eslint-disable-next-line no-console
console.log(...args);
}

View file

@ -17,6 +17,8 @@
* under the License.
*/
/* eslint-disable @typescript-eslint/no-var-requires */
jest.mock('./fs');
import { resolve } from 'path';

View file

@ -24,7 +24,7 @@ export const log = {
* @param ...args
*/
write(...args: any[]) {
// tslint:disable no-console
// eslint-disable-next-line no-console
console.log(...args);
},
};

View file

@ -33,10 +33,12 @@ interface ITree {
name?: string;
children?: ITreeChildren;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ITreeChildren extends Array<ITree> {}
type DirOrProjectName = string | typeof projectKey;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface IProjectsTree extends Map<DirOrProjectName, string | IProjectsTree> {}
function treeToString(tree: ITree) {

View file

@ -17,4 +17,5 @@
* under the License.
*/
// eslint-disable-next-line import/no-default-export
export default function(selector: string): string;

View file

@ -1,21 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
require('../src/setup_node_env');
require('../src/dev/tslint').runTslintCli();

View file

@ -42,7 +42,7 @@ interface Params {
}
/** @internal */
// tslint:disable-next-line no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CoreContext {}
/**

View file

@ -72,7 +72,7 @@ export class FatalErrorsScreen extends React.Component<Props, State> {
)
).subscribe({
error(error) {
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.error('Uncaught error in fatal error screen internals', error);
},
});

View file

@ -50,7 +50,7 @@ export class FatalErrorsService {
)
.subscribe({
error: error => {
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.error('Uncaught error in fatal error screen internals', error);
},
});
@ -63,7 +63,7 @@ export class FatalErrorsService {
if (error instanceof Error) {
// make stack traces clickable by putting whole error in the console
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.error(error);
}

View file

@ -20,6 +20,7 @@
type Freezable = { [k: string]: any } | any[];
// if we define this inside RecursiveReadonly TypeScript complains
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface RecursiveReadonlyArray<T> extends Array<RecursiveReadonly<T>> {}
type RecursiveReadonly<T> = T extends any[]

View file

@ -33,7 +33,7 @@ import { PluginsServiceSetupDeps } from './plugins_service';
*
* @public
*/
// tslint:disable-next-line no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface PluginInitializerContext {}
/**

View file

@ -19,7 +19,7 @@
function mockClass<T>(
module: string,
Class: { new (...args: any[]): T },
Class: new (...args: any[]) => T,
setup: (instance: any, args: any[]) => void
) {
const MockClass = jest.fn(function(this: any, ...args: any[]) {

View file

@ -17,6 +17,7 @@
* under the License.
*/
import { i18n } from '@kbn/i18n';
import { BasePathSetup } from '../base_path';
import { HttpSetup } from '../http';
import { InjectedMetadataSetup } from '../injected_metadata';
@ -25,8 +26,6 @@ import { NotificationsSetup } from '../notifications';
import { UiSettingsApi } from './ui_settings_api';
import { UiSettingsClient } from './ui_settings_client';
import { i18n } from '@kbn/i18n';
interface UiSettingsServiceDeps {
notifications: NotificationsSetup;
http: HttpSetup;

View file

@ -116,7 +116,7 @@ function onRootShutdown(reason?: any) {
// There is a chance that logger wasn't configured properly and error that
// that forced root to shut down could go unnoticed. To prevent this we always
// mirror such fatal errors in standard output with `console.error`.
// tslint:disable no-console
// eslint-disable-next-line
console.error(`\n${chalk.white.bgRed(' FATAL ')} ${reason}\n`);
}

View file

@ -17,7 +17,7 @@
* under the License.
*/
/* tslint:disable max-classes-per-file */
/* eslint-disable max-classes-per-file */
import { BehaviorSubject } from 'rxjs';
import { first } from 'rxjs/operators';

View file

@ -21,7 +21,7 @@ import { resolve } from 'path';
import process from 'process';
// `require` is necessary for this to work inside x-pack code as well
// tslint:disable no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../../../../package.json');
export interface PackageInfo {

View file

@ -80,6 +80,7 @@ test('throws if [redirectHttpFromPort] is not specified', async () => {
test('throws if [redirectHttpFromPort] is in use', async () => {
const mockListen = jest.spyOn(Server.prototype, 'listen').mockImplementation(() => {
// eslint-disable-next-line no-throw-literal
throw { code: 'EADDRINUSE' };
});

View file

@ -105,10 +105,9 @@ export class SslConfig {
return Array.from(protocolMap).reduce((secureOptions, [protocolAlias, secureOption]) => {
// `secureOption` is the option that turns *off* support for a particular protocol,
// so if protocol is supported, we should not enable this option.
// tslint:disable no-bitwise
return supportedProtocols.includes(protocolAlias)
? secureOptions
: secureOptions | secureOption;
: secureOptions | secureOption; // eslint-disable-line no-bitwise
}, 0);
}

View file

@ -132,6 +132,7 @@ export class LegacyService implements CoreService {
}
private async createKbnServer(config: Config, { elasticsearch, http, plugins }: SetupDeps) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const KbnServer = require('../../../legacy/server/kbn_server');
const kbnServer: LegacyKbnServer = new KbnServer(getLegacyRawConfig(config), {
// If core HTTP service is run we'll receive internal server reference and

View file

@ -19,6 +19,7 @@
export const mockCreateLayout = jest.fn();
jest.mock('../layouts/layouts', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { schema } = require('@kbn/config-schema');
return {
Layouts: {

View file

@ -18,6 +18,7 @@
*/
jest.mock('../../layouts/layouts', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { schema } = require('@kbn/config-schema');
return {
Layouts: {
@ -82,10 +83,10 @@ test('`append()` correctly formats records and pushes them to console.', () => {
for (const record of records) {
appender.append(record);
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
expect(console.log).toHaveBeenCalledWith(`mock-${JSON.stringify(record)}`);
}
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
expect(console.log).toHaveBeenCalledTimes(records.length);
});

View file

@ -46,7 +46,7 @@ export class ConsoleAppender implements DisposableAppender {
* @param record `LogRecord` instance to be logged.
*/
public append(record: LogRecord) {
// tslint:disable no-console
// eslint-disable-next-line no-console
console.log(this.layout.format(record));
}

View file

@ -18,6 +18,7 @@
*/
jest.mock('../../layouts/layouts', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { schema } = require('@kbn/config-schema');
return {
Layouts: {

View file

@ -204,6 +204,7 @@ export class Plugin<
private createPluginInstance() {
this.log.debug('Initializing plugin');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pluginDefinition = require(join(this.path, 'server'));
if (!('plugin' in pluginDefinition)) {
throw new Error(`Plugin "${this.name}" does not export "plugin" definition (${this.path}).`);

View file

@ -93,7 +93,7 @@ export class Root {
switchMap(() => this.configService.atPath('logging', LoggingConfig)),
map(config => this.loggingService.upgrade(config)),
// This specifically console.logs because we were not able to configure the logger.
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
tap({ error: err => console.error('Configuring logger failed:', err) }),
publishReplay(1)
) as ConnectableObservable<void>;

View file

@ -41,7 +41,6 @@ export const IGNORE_FILE_GLOBS = [
'**/.*',
'**/{webpackShims,__mocks__}/**/*',
'x-pack/docs/**/*',
'src/dev/tslint/rules/*',
'src/legacy/ui/public/assets/fonts/**/*',
// filename must match language code which requires capital letters

View file

@ -30,5 +30,9 @@ if (!process.argv.includes('--no-cache')) {
process.argv.push('--cache');
}
if (!process.argv.includes('--ext')) {
process.argv.push('--ext', '.js,.ts,.tsx');
}
// common-js is required so that logic before this executes before loading eslint
require('eslint/bin/eslint');

View file

@ -19,7 +19,6 @@
import { run, combineErrors } from './run';
import * as Eslint from './eslint';
import * as Tslint from './tslint';
import * as Sasslint from './sasslint';
import { getFilesForCommit, checkFileCasing } from './precommit_hook';
@ -33,7 +32,7 @@ run(async ({ log }) => {
errors.push(error);
}
for (const Linter of [Eslint, Tslint, Sasslint]) {
for (const Linter of [Eslint, Sasslint]) {
const filesToLint = Linter.pickFilesToLint(log, files);
if (filesToLint.length > 0) {
try {

View file

@ -1,22 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export { runTslintCli } from './run_tslint_cli';
export { lintFiles } from './lint_files';
export { pickFilesToLint } from './pick_files_to_lint';

View file

@ -1,78 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { run } from 'tslint/lib/runner';
import { ToolingLog } from '@kbn/dev-utils';
import { File } from '../file';
import { createFailError } from '../run';
import { getTsProjectForAbsolutePath, Project } from '../typescript';
function groupFilesByProject(files: File[]) {
const filesByProject: Map<Project, File[]> = new Map();
files.forEach(file => {
const project = getTsProjectForAbsolutePath(file.getAbsolutePath());
const filesForProject = filesByProject.get(project);
if (!filesForProject) {
filesByProject.set(project, [file]);
} else {
filesForProject.push(file);
}
});
return filesByProject;
}
/**
* Lints a list of files with tslint. tslint reports are written to the log
* and a FailError is thrown when linting errors occur.
*
* @param {ToolingLog} log
* @param {Array<File>} files
* @return {undefined}
*/
export async function lintFiles(log: ToolingLog, files: File[]) {
for (const [project, filesInProject] of groupFilesByProject(files)) {
const exitCode = await run(
{
exclude: [],
files: filesInProject.map(f => f.getAbsolutePath()),
fix: false,
format: 'stylish',
project: project.tsConfigPath,
},
{
log(m: string) {
log.write(m);
},
error(m: string) {
log.error(m);
},
}
);
if (exitCode > 0) {
throw createFailError(`[tslint] failure`);
} else {
log.success('[tslint/%s] %d files linted successfully', project.name, filesInProject.length);
}
}
}

View file

@ -1,26 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { ToolingLog } from '@kbn/dev-utils';
import { File } from '../file';
export function pickFilesToLint(log: ToolingLog, files: File[]) {
return files.filter(file => file.isTypescript() && !file.isFixture());
}

View file

@ -1,51 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const Lint = require('tslint');
const FAILURE_STRING = 'This license header is not allowed in this file.';
const RULE_NAME = 'disallow-license-header';
exports.Rule = class extends Lint.Rules.AbstractRule {
apply(sourceFile) {
const [headerText] = this.getOptions().ruleArguments;
if (!headerText) {
throw new Error(`${RULE_NAME} requires a single argument containing the header text`);
}
if (!sourceFile.text.includes(headerText)) {
return [];
}
const start = sourceFile.text.indexOf(headerText);
const end = start + headerText.length;
return [
new Lint.RuleFailure(
sourceFile,
start,
end,
FAILURE_STRING,
RULE_NAME,
new Lint.Replacement(start, headerText.length, '')
)
];
}
};

View file

@ -1,75 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const path = require('path');
const Lint = require('tslint');
const KIBANA_ROOT = path.resolve(__dirname, '../../../..');
class ModuleMigrationWalker extends Lint.RuleWalker {
visitImportDeclaration(node) {
const moduleId = node.moduleSpecifier.text;
const mapping = this.options.find(
mapping => mapping.from === moduleId || moduleId.startsWith(`${mapping.from}/`)
);
if (!mapping) {
return;
}
let newSource;
// support for toRelative added to migrate away from X-Pack being bundled
// within node modules. after that migration, this can be removed.
if (mapping.toRelative) {
const sourceDirectory = path.dirname(this.getSourceFile().originalFileName);
const localModulePath = moduleId.replace(new RegExp(`^${mapping.from}\/`), '');
const modulePath = path.resolve(KIBANA_ROOT, mapping.toRelative, localModulePath);
const relativePath = path.relative(sourceDirectory, modulePath);
newSource = relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
} else {
newSource = moduleId.replace(mapping.from, mapping.to);
}
const start = node.moduleSpecifier.getStart();
const width = node.moduleSpecifier.getWidth();
this.addFailure(
this.createFailure(
start,
width,
`Imported module "${moduleId}" should be "${newSource}"`,
this.createReplacement(
start,
width,
`'${newSource}'`
)
)
);
super.visitImportDeclaration(node);
}
}
exports.Rule = class extends Lint.Rules.AbstractRule {
apply(sourceFile) {
return this.applyWithWalker(new ModuleMigrationWalker(sourceFile, this.getOptions()));
}
};

View file

@ -1,48 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const Lint = require('tslint');
const FAILURE_STRING = 'File must start with a license header';
const RULE_NAME = 'require-license-header';
exports.Rule = class extends Lint.Rules.AbstractRule {
apply(sourceFile) {
const [headerText] = this.getOptions().ruleArguments;
if (!headerText) {
throw new Error(`${RULE_NAME} requires a single argument containing the header text`);
}
if (sourceFile.text.startsWith(headerText)) {
return [];
}
return [
new Lint.RuleFailure(
sourceFile,
0,
0,
FAILURE_STRING,
RULE_NAME,
new Lint.Replacement(0, 0, `${headerText}\n\n`)
)
];
}
};

View file

@ -1,49 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { ToolingLog } from '@kbn/dev-utils';
import getopts from 'getopts';
import { execInProjects, filterProjectsByFlag, Project } from '../typescript';
export function runTslintCliOnTsConfigPaths(tsConfigPaths: string[]) {
runTslintCli(tsConfigPaths.map(tsConfigPath => new Project(tsConfigPath)));
}
export function runTslintCli(projects?: Project[]) {
const log = new ToolingLog({
level: 'info',
writeTo: process.stdout,
});
const opts = getopts(process.argv.slice(2));
projects = projects || filterProjectsByFlag(opts.project);
if (!opts.format) {
process.argv.push('--format', 'stylish');
}
const getProjectArgs = (project: Project) => [
...process.argv.slice(2),
'--project',
project.tsConfigPath,
];
execInProjects(log, projects, 'tslint', getProjectArgs);
}

View file

@ -17,7 +17,7 @@
* under the License.
*/
/* tslint:disable */
/* eslint-disable */
import {
Client as ESClient,
GenericParams,
@ -145,7 +145,7 @@ import {
TasksGetParams,
TasksListParams,
} from 'elasticsearch';
/* tslint:enable */
/* eslint-enable */
export class Cluster {
public callWithRequest: CallClusterWithRequest;
@ -209,7 +209,7 @@ export interface CallClusterOptions {
}
export interface CallClusterWithRequest {
/* tslint:disable */
/* eslint-disable */
(request: Request, endpoint: 'bulk', params: BulkIndexDocumentsParams, options?: CallClusterOptions): ReturnType<ESClient['bulk']>;
(request: Request, endpoint: 'clearScroll', params: ClearScrollParams, options?: CallClusterOptions): ReturnType<ESClient['clearScroll']>;
(request: Request, endpoint: 'count', params: CountParams, options?: CallClusterOptions): ReturnType<ESClient['count']>;
@ -345,7 +345,6 @@ export interface CallClusterWithRequest {
(request: Request, endpoint: 'tasks.cancel', params: TasksCancelParams, options?: CallClusterOptions): ReturnType<ESClient['tasks']['cancel']>;
(request: Request, endpoint: 'tasks.get', params: TasksGetParams, options?: CallClusterOptions): ReturnType<ESClient['tasks']['get']>;
(request: Request, endpoint: 'tasks.list', params: TasksListParams, options?: CallClusterOptions): ReturnType<ESClient['tasks']['list']>;
/* tslint:enable */
// other APIs accessed via transport.request
(
@ -368,10 +367,11 @@ export interface CallClusterWithRequest {
clientParams?: any,
options?: CallClusterOptions
): Promise<T>;
/* eslint-enable */
}
export interface CallCluster {
/* tslint:disable */
/* eslint-disable */
(endpoint: 'bulk', params: BulkIndexDocumentsParams, options?: CallClusterOptions): ReturnType<ESClient['bulk']>;
(endpoint: 'clearScroll', params: ClearScrollParams, options?: CallClusterOptions): ReturnType<ESClient['clearScroll']>;
(endpoint: 'count', params: CountParams, options?: CallClusterOptions): ReturnType<ESClient['count']>;
@ -507,7 +507,6 @@ export interface CallCluster {
(endpoint: 'tasks.cancel', params: TasksCancelParams, options?: CallClusterOptions): ReturnType<ESClient['tasks']['cancel']>;
(endpoint: 'tasks.get', params: TasksGetParams, options?: CallClusterOptions): ReturnType<ESClient['tasks']['get']>;
(endpoint: 'tasks.list', params: TasksListParams, options?: CallClusterOptions): ReturnType<ESClient['tasks']['list']>;
/* tslint:enable */
// other APIs accessed via transport.request
(endpoint: 'transport.request', clientParams: AssistantAPIClientParams, options?: {}): Promise<
@ -519,6 +518,7 @@ export interface CallCluster {
// Catch-all definition
<T = any>(endpoint: string, clientParams?: any, options?: CallClusterOptions): Promise<T>;
/* eslint-enable */
}
export interface ElasticsearchPlugin {

View file

@ -21,7 +21,7 @@ import { resolve } from 'path';
import { Legacy } from '../../../../kibana';
import { init } from './init';
// tslint:disable-next-line
// eslint-disable-next-line
export default function InterpreterPlugin(kibana: any) {
const config: Legacy.PluginSpecOptions = {
id: 'interpreter',

View file

@ -37,7 +37,7 @@ export const registries = {
serverFunctions: new FunctionsRegistry(),
};
export async function init(server: Legacy.Server /*options*/) {
export async function init(server: Legacy.Server /* options */) {
server.injectUiAppVars('canvas', () => {
register(registries, {
types,

View file

@ -17,13 +17,15 @@
* under the License.
*/
/* eslint-disable @typescript-eslint/no-empty-interface */
import _ from 'lodash';
import { createAction } from 'redux-actions';
import { EmbeddableMetadata, EmbeddableState } from 'ui/embeddable';
import { getEmbeddableCustomization, getPanel } from '../../selectors';
import { PanelId, PanelState } from '../selectors';
import { updatePanel } from './panels';
import { EmbeddableMetadata, EmbeddableState } from 'ui/embeddable';
import { KibanaAction, KibanaThunk } from '../../selectors/types';
export enum EmbeddableActionTypeKeys {

View file

@ -17,6 +17,8 @@
* under the License.
*/
/* eslint-disable @typescript-eslint/no-empty-interface */
import { createAction } from 'redux-actions';
import { KibanaAction } from '../../selectors/types';

View file

@ -17,6 +17,8 @@
* under the License.
*/
/* eslint-disable @typescript-eslint/no-empty-interface */
import { createAction } from 'redux-actions';
import { KibanaAction } from '../../selectors/types';
import { PanelId, PanelsMap, PanelState } from '../selectors';
@ -24,8 +26,8 @@ import { PanelId, PanelsMap, PanelState } from '../selectors';
export enum PanelActionTypeKeys {
DELETE_PANEL = 'DELETE_PANEL',
UPDATE_PANEL = 'UPDATE_PANEL',
RESET_PANEl_TITLE = 'RESET_PANEl_TITLE',
SET_PANEl_TITLE = 'SET_PANEl_TITLE',
RESET_PANEL_TITLE = 'RESET_PANEL_TITLE',
SET_PANEL_TITLE = 'SET_PANEL_TITLE',
UPDATE_PANELS = 'UPDATE_PANELS',
SET_PANELS = 'SET_PANELS',
}
@ -40,7 +42,7 @@ export interface UpdatePanelsAction
extends KibanaAction<PanelActionTypeKeys.UPDATE_PANELS, PanelsMap> {}
export interface ResetPanelTitleAction
extends KibanaAction<PanelActionTypeKeys.RESET_PANEl_TITLE, PanelId> {}
extends KibanaAction<PanelActionTypeKeys.RESET_PANEL_TITLE, PanelId> {}
export interface SetPanelTitleActionPayload {
panelId: PanelId;
@ -48,7 +50,7 @@ export interface SetPanelTitleActionPayload {
}
export interface SetPanelTitleAction
extends KibanaAction<PanelActionTypeKeys.SET_PANEl_TITLE, SetPanelTitleActionPayload> {}
extends KibanaAction<PanelActionTypeKeys.SET_PANEL_TITLE, SetPanelTitleActionPayload> {}
export interface SetPanelsAction extends KibanaAction<PanelActionTypeKeys.SET_PANELS, PanelsMap> {}
@ -62,9 +64,9 @@ export type PanelActions =
export const deletePanel = createAction<PanelId>(PanelActionTypeKeys.DELETE_PANEL);
export const updatePanel = createAction<PanelState>(PanelActionTypeKeys.UPDATE_PANEL);
export const resetPanelTitle = createAction<PanelId>(PanelActionTypeKeys.RESET_PANEl_TITLE);
export const resetPanelTitle = createAction<PanelId>(PanelActionTypeKeys.RESET_PANEL_TITLE);
export const setPanelTitle = createAction<SetPanelTitleActionPayload>(
PanelActionTypeKeys.SET_PANEl_TITLE
PanelActionTypeKeys.SET_PANEL_TITLE
);
export const updatePanels = createAction<PanelsMap>(PanelActionTypeKeys.UPDATE_PANELS);
export const setPanels = createAction<PanelsMap>(PanelActionTypeKeys.SET_PANELS);

View file

@ -17,6 +17,8 @@
* under the License.
*/
/* eslint-disable @typescript-eslint/no-empty-interface */
import { createAction } from 'redux-actions';
import { Filters, Query, RefreshConfig, TimeRange } from 'ui/embeddable';
import { KibanaAction } from '../../selectors/types';
@ -26,7 +28,7 @@ import { PanelId } from '../selectors';
export enum ViewActionTypeKeys {
UPDATE_VIEW_MODE = 'UPDATE_VIEW_MODE',
SET_VISIBLE_CONTEXT_MENU_PANEL_ID = 'SET_VISIBLE_CONTEXT_MENU_PANEL_ID',
MAXIMIZE_PANEl = 'MAXIMIZE_PANEl',
MAXIMIZE_PANEL = 'MAXIMIZE_PANEL',
MINIMIZE_PANEL = 'MINIMIZE_PANEL',
UPDATE_IS_FULL_SCREEN_MODE = 'UPDATE_IS_FULL_SCREEN_MODE',
UPDATE_USE_MARGINS = 'UPDATE_USE_MARGINS',
@ -48,7 +50,7 @@ export interface CloseContextMenuAction
extends KibanaAction<ViewActionTypeKeys.CLOSE_CONTEXT_MENU, undefined> {}
export interface MaximizePanelAction
extends KibanaAction<ViewActionTypeKeys.MAXIMIZE_PANEl, PanelId> {}
extends KibanaAction<ViewActionTypeKeys.MAXIMIZE_PANEL, PanelId> {}
export interface MinimizePanelAction
extends KibanaAction<ViewActionTypeKeys.MINIMIZE_PANEL, undefined> {}
@ -92,7 +94,7 @@ export const closeContextMenu = createAction(ViewActionTypeKeys.CLOSE_CONTEXT_ME
export const setVisibleContextMenuPanelId = createAction<PanelId>(
ViewActionTypeKeys.SET_VISIBLE_CONTEXT_MENU_PANEL_ID
);
export const maximizePanel = createAction<PanelId>(ViewActionTypeKeys.MAXIMIZE_PANEl);
export const maximizePanel = createAction<PanelId>(ViewActionTypeKeys.MAXIMIZE_PANEL);
export const minimizePanel = createAction(ViewActionTypeKeys.MINIMIZE_PANEL);
export const updateIsFullScreenMode = createAction<boolean>(
ViewActionTypeKeys.UPDATE_IS_FULL_SCREEN_MODE

View file

@ -26,6 +26,7 @@ import {
ContextMenuPanel,
Embeddable,
} from 'ui/embeddable';
import { Dispatch } from 'redux';
import { panelActionsStore } from '../../store/panel_actions_store';
import {
getCustomizePanelAction,
@ -46,7 +47,6 @@ import {
setVisibleContextMenuPanelId,
} from '../../actions';
import { Dispatch } from 'redux';
import { CoreKibanaState } from '../../../selectors';
import { DashboardViewMode } from '../../dashboard_view_mode';
import {
@ -158,6 +158,7 @@ const mergeProps = (
};
const toggleExpandedPanel = () => {
// eslint-disable-next-line no-unused-expressions
isExpanded ? onMinimizePanel() : onMaximizePanel();
closeMyContextMenuPanel();
};

View file

@ -34,6 +34,7 @@ export interface SemanticVersion {
export class PanelUtils {
// 6.1 switched from gridster to react grid. React grid uses different variables for tracking layout
// eslint-disable-next-line @typescript-eslint/camelcase
public static convertPanelDataPre_6_1(panel: {
panelIndex: any; // earlier versions allowed panelIndex to be a number or a string
gridData: GridData;
@ -76,6 +77,7 @@ export class PanelUtils {
// 1) decrease column height from 100 to 20.
// 2) increase rows from 12 to 48
// Need to scale pre 6.3 panels so they maintain the same layout
// eslint-disable-next-line @typescript-eslint/camelcase
public static convertPanelDataPre_6_3(
panel: {
gridData: { w: number; x: number; h: number; y: number };

View file

@ -67,9 +67,9 @@ export const panelsReducer: Reducer<PanelsMap> = (panels = {}, action): PanelsMa
return updatePanel(panels, action.payload);
case PanelActionTypeKeys.UPDATE_PANELS:
return updatePanels(panels, action.payload);
case PanelActionTypeKeys.RESET_PANEl_TITLE:
case PanelActionTypeKeys.RESET_PANEL_TITLE:
return resetPanelTitle(panels, action.payload);
case PanelActionTypeKeys.SET_PANEl_TITLE:
case PanelActionTypeKeys.SET_PANEL_TITLE:
return setPanelTitle(panels, action.payload);
case PanelActionTypeKeys.SET_PANELS:
return setPanels(panels, action.payload);

View file

@ -19,10 +19,10 @@
import { cloneDeep } from 'lodash';
import { Reducer } from 'redux';
import { ViewActions, ViewActionTypeKeys } from '../actions';
import { Filters, Query, RefreshConfig, TimeRange } from 'ui/embeddable';
import { QueryLanguageType } from 'ui/embeddable/types';
import { ViewActions, ViewActionTypeKeys } from '../actions';
import { DashboardViewMode } from '../dashboard_view_mode';
import { PanelId, ViewState } from '../selectors';
@ -102,7 +102,7 @@ export const viewReducer: Reducer<ViewState> = (
switch ((action as ViewActions).type) {
case ViewActionTypeKeys.MINIMIZE_PANEL:
return minimizePanel(view);
case ViewActionTypeKeys.MAXIMIZE_PANEl:
case ViewActionTypeKeys.MAXIMIZE_PANEL:
return maximizePanel(view, action.payload);
case ViewActionTypeKeys.SET_VISIBLE_CONTEXT_MENU_PANEL_ID:
return setVisibleContextMenuPanelId(view, action.payload);

View file

@ -21,7 +21,6 @@ import { i18n } from '@kbn/i18n';
import chrome from 'ui/chrome';
import { EmbeddableFactory } from 'ui/embeddable';
import { getVisualizeLoader } from 'ui/visualize/loader';
import { VisualizeEmbeddable } from './visualize_embeddable';
import { Legacy } from 'kibana';
import {
@ -29,6 +28,7 @@ import {
OnEmbeddableStateChanged,
} from 'ui/embeddable/embeddable_factory';
import { VisTypesRegistry } from 'ui/registry/vis_types';
import { VisualizeEmbeddable } from './visualize_embeddable';
import { VisualizationAttributes } from '../../../../../server/saved_objects/service/saved_objects_client';
import { SavedVisualizations } from '../types';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';

View file

@ -22,14 +22,13 @@ import React from 'react';
import { EuiModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import chrome from 'ui/chrome';
import { VisType } from 'ui/vis';
import { VisualizeConstants } from '../visualize_constants';
import { SearchSelection } from './search_selection';
import { TypeSelection } from './type_selection';
import chrome from 'ui/chrome';
import { VisType } from 'ui/vis';
interface TypeSelectionProps {
isOpen: boolean;
onClose: () => void;

View file

@ -34,13 +34,12 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { memoizeLast } from 'ui/utils/memoize';
import { VisType } from 'ui/vis';
import { NewVisHelp } from './new_vis_help';
import { VisHelpText } from './vis_help_text';
import { VisTypeIcon } from './vis_type_icon';
import { memoizeLast } from 'ui/utils/memoize';
import { VisType } from 'ui/vis';
interface VisTypeListEntry extends VisType {
highlighted: boolean;
}

View file

@ -60,6 +60,7 @@ declare module 'hapi' {
type KbnMixinFunc = (kbnServer: KbnServer, server: Server, config: any) => Promise<any> | void;
type Unpromise<T> = T extends Promise<infer U> ? U : T;
// eslint-disable-next-line import/no-default-export
export default class KbnServer {
public readonly newPlatform: {
setup: {

View file

@ -25,6 +25,7 @@
import { IndexMapping } from '../../../mappings';
/* eslint-disable @typescript-eslint/unified-signatures */
export interface CallCluster {
(path: 'bulk', opts: { body: object[] }): Promise<BulkResult>;
(path: 'count', opts: CountOpts): Promise<{ count: number; _shards: ShardsInfo }>;
@ -48,6 +49,7 @@ export interface CallCluster {
error?: ErrorResponse;
}>;
}
/* eslint-enable @typescript-eslint/unified-signatures */
///////////////////////////////////////////////////////////////////
// callCluster argument type definitions

View file

@ -30,6 +30,7 @@ describe('coordinateMigration', () => {
test('waits for isMigrated, if there is an index conflict', async () => {
const pollInterval = 1;
const runMigration = jest.fn(() => {
// eslint-disable-next-line no-throw-literal
throw { body: { error: { index: '.foo', type: 'resource_already_exists_exception' } } };
});
const isMigrated = jest.fn();

View file

@ -22,6 +22,8 @@
* the raw document format as stored in ElasticSearch.
*/
/* eslint-disable @typescript-eslint/camelcase */
import uuid from 'uuid';
import { SavedObjectsSchema } from '../schema';
import { decodeVersion, encodeVersion } from '../version';

View file

@ -19,7 +19,7 @@
import { ajaxStream, XMLHttpRequestLike } from './ajax_stream';
// tslint:disable-next-line:no-empty
// eslint-disable-next-line no-empty
function noop() {}
describe('ajaxStream', () => {

View file

@ -50,10 +50,6 @@ import {
EuiShowFor,
} from '@elastic/eui';
import { HeaderBreadcrumbs } from './header_breadcrumbs';
import { HeaderHelpMenu } from './header_help_menu';
import { HeaderNavControls } from './header_nav_controls';
import { i18n } from '@kbn/i18n';
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import chrome, { NavLink } from 'ui/chrome';
@ -61,6 +57,11 @@ import { HelpExtension } from 'ui/chrome';
import { RecentlyAccessedHistoryItem } from 'ui/persisted_log';
import { ChromeHeaderNavControlsRegistry } from 'ui/registry/chrome_header_nav_controls';
import { relativeToAbsolute } from 'ui/url/relative_to_absolute';
import { HeaderBreadcrumbs } from './header_breadcrumbs';
import { HeaderHelpMenu } from './header_help_menu';
import { HeaderNavControls } from './header_nav_controls';
import { NavControlSide } from '../';
import { ChromeBreadcrumb } from '../../../../../../../core/public';

View file

@ -21,9 +21,6 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
import * as Rx from 'rxjs';
import { documentationLinks } from '../../../../documentation_links';
import { metadata } from '../../../../metadata';
import {
// TODO: add type annotations
// @ts-ignore
@ -42,6 +39,8 @@ import {
} from '@elastic/eui';
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { HelpExtension } from 'ui/chrome';
import { metadata } from '../../../../metadata';
import { documentationLinks } from '../../../../documentation_links';
import { HeaderExtension } from './header_extension';

View file

@ -49,6 +49,7 @@ declare interface Chrome extends ChromeNavLinks {
declare const chrome: Chrome;
// eslint-disable-next-line import/no-default-export
export default chrome;
export { Breadcrumb } from './api/breadcrumbs';
export { NavLink } from './api/nav';

View file

@ -24,7 +24,6 @@ exports[`QueryBar Should disable autoFocus on EuiFieldText when disableAutoFocus
>
<form
name="queryBarForm"
role="form"
>
<div
role="search"
@ -112,7 +111,6 @@ exports[`QueryBar Should pass the query language to the language switcher 1`] =
>
<form
name="queryBarForm"
role="form"
>
<div
role="search"
@ -200,7 +198,6 @@ exports[`QueryBar Should render the given query 1`] = `
>
<form
name="queryBarForm"
role="form"
>
<div
role="search"

View file

@ -28,15 +28,6 @@ import { kfetch } from 'ui/kfetch';
import { PersistedLog } from 'ui/persisted_log';
import { Storage } from 'ui/storage';
import { timeHistory } from 'ui/timefilter/time_history';
import {
AutocompleteSuggestion,
AutocompleteSuggestionType,
getAutocompleteProvider,
} from '../../autocomplete_providers';
import chrome from '../../chrome';
import { fromUser, matchPairs, toUser } from '../lib';
import { QueryLanguageSwitcher } from './language_switcher';
import { SuggestionsComponent } from './typeahead/suggestions_component';
import {
EuiButton,
@ -55,6 +46,16 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { documentationLinks } from 'ui/documentation_links';
import { Toast, toastNotifications } from 'ui/notify';
import {
AutocompleteSuggestion,
AutocompleteSuggestionType,
getAutocompleteProvider,
} from '../../autocomplete_providers';
import chrome from '../../chrome';
import { fromUser, matchPairs, toUser } from '../lib';
import { QueryLanguageSwitcher } from './language_switcher';
import { SuggestionsComponent } from './typeahead/suggestions_component';
const KEY_CODES = {
LEFT: 37,
UP: 38,
@ -577,7 +578,7 @@ export class QueryBarUI extends Component<Props, State> {
aria-owns="kbnTypeahead__items"
aria-controls="kbnTypeahead__items"
>
<form role="form" name="queryBarForm">
<form name="queryBarForm">
<div role="search">
<div className="kuiLocalSearchAssistedInput">
<EuiFieldText

View file

@ -50,6 +50,7 @@ interface Props {
export const SuggestionComponent: SFC<Props> = props => {
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus
<div
className={classNames({
kbnTypeahead__item: true,

View file

@ -19,6 +19,7 @@
import { IndexedArray, IndexedArrayConfig } from '../indexed_array';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface UIRegistry<T> extends IndexedArray<T> {}
interface UIRegistrySpec<T> extends IndexedArrayConfig<T> {

View file

@ -19,5 +19,6 @@
import { uiRoutes, UIRoutes } from 'ui/routes/routes';
// eslint-disable-next-line import/no-default-export
export default uiRoutes;
export { UIRoutes };

View file

@ -38,4 +38,5 @@ interface RouteManager {
defaults(path: string | RegExp, defaults: RouteConfiguration): RouteManager;
}
// eslint-disable-next-line import/no-default-export
export default RouteManager;

View file

@ -34,7 +34,8 @@ import { SavedObjectsClient } from './saved_objects_client';
*/
export class SimpleSavedObject<T extends SavedObjectAttributes> {
public attributes: T;
// tslint:disable-next-line variable-name We want to use the same interface this class had in JS
// We want to use the same interface this class had in JS
// eslint-disable-next-line variable-name
public _version?: SavedObjectType<T>['version'];
public id: SavedObjectType<T>['id'];
public type: SavedObjectType<T>['type'];

View file

@ -92,9 +92,9 @@ class SearchBarUI extends Component<Props, State> {
};
// member-ordering rules conflict with use-before-declaration rules
/* tslint:disable */
/* eslint-disable */
public ro = new ResizeObserver(this.setFilterBarHeight);
/* tslint:enable */
/* eslint-enable */
public toggleFiltersVisible = () => {
this.setState({

View file

@ -34,11 +34,10 @@ import {
import { format as formatUrl, parse as parseUrl } from 'url';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { unhashUrl } from '../../state_management/state_hashing';
import { shortenUrl } from '../lib/url_shortener';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
// TODO: Remove once EuiIconTip supports "content" prop
const FixedEuiIconTip = EuiIconTip as React.SFC<any>;

View file

@ -20,13 +20,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { EuiWrappingPopover } from '@elastic/eui';
import { I18nContext } from 'ui/i18n';
import { ShareContextMenu } from './components/share_context_menu';
import { ShareActionProvider } from './share_action';
import { EuiWrappingPopover } from '@elastic/eui';
import { I18nContext } from 'ui/i18n';
let isOpen = false;
const container = document.createElement('div');

View file

@ -56,7 +56,6 @@ export function getTime(
return;
}
let filter: Filter;
const timefield: Field | undefined = indexPattern.fields.find(
field => field.name === indexPattern.timeFieldName
);
@ -69,7 +68,7 @@ export function getTime(
if (!bounds) {
return;
}
filter = { range: { [timefield.name]: { format: 'strict_date_optional_time' } } };
const filter: Filter = { range: { [timefield.name]: { format: 'strict_date_optional_time' } } };
if (bounds.min) {
filter.range[timefield.name].gte = bounds.min.toISOString();

View file

@ -42,7 +42,7 @@ export class CidrMask {
public getRange() {
const variableBits = NUM_BITS - this.prefixLength;
// tslint:disable-next-line:no-bitwise
// eslint-disable-next-line no-bitwise
const fromAddress = ((this.initialAddress.valueOf() >> variableBits) << variableBits) >>> 0; // >>> 0 coerces to unsigned
const numAddresses = Math.pow(2, variableBits);
return {

View file

@ -41,10 +41,10 @@ export function decodeGeoHash(geohash: number[]): Coordinates {
const mask: number = BITS[j];
if (isEven) {
lonErr = lonErr /= 2;
refine_interval(lon, cd, mask);
refineInterval(lon, cd, mask);
} else {
latErr = latErr /= 2;
refine_interval(lat, cd, mask);
refineInterval(lat, cd, mask);
}
isEven = !isEven;
}
@ -57,8 +57,8 @@ export function decodeGeoHash(geohash: number[]): Coordinates {
} as Coordinates;
}
function refine_interval(interval: number[], cd: number, mask: number) {
if (cd & mask) { /* tslint:disable-line */
function refineInterval(interval: number[], cd: number, mask: number) {
if (cd & mask) { /* eslint-disable-line */
interval[0] = (interval[0] + interval[1]) / 2;
} else {
interval[1] = (interval[0] + interval[1]) / 2;
@ -75,7 +75,7 @@ function refine_interval(interval: number[], cd: number, mask: number) {
function geohashCells(precision: number, axis: number) {
let cells = 1;
for (let i = 1; i <= precision; i += 1) {
/*On odd precisions, rows divide by 4 and columns by 8. Vice-versa on even precisions */
/* On odd precisions, rows divide by 4 and columns by 8. Vice-versa on even precisions */
cells *= i % 2 === axis ? 4 : 8;
}
return cells;

View file

@ -31,7 +31,6 @@ function isIntegerInRange(integer: number, min: number, max: number) {
}
// eslint-disable-next-line import/no-default-export
// tslint:disable:no-default-export
export default class Ipv4Address {
private value: number;

View file

@ -35,7 +35,6 @@ function memoizeLast<T extends (...args: any[]) => any>(func: T): T {
let prevCall: MemoizedCall | NeverCalled = neverCalled;
// We need to use a `function` here for proper this passing.
// tslint:disable-next-line:only-arrow-functions
const memoizedFunction = function(this: any, ...args: any[]) {
if (
prevCall !== neverCalled &&

View file

@ -21,6 +21,7 @@ import { mockFatalError } from './subscribe_with_scope.test.mocks';
import * as Rx from 'rxjs';
import { subscribeWithScope } from './subscribe_with_scope';
// eslint-disable-next-line prefer-const
let $rootScope: Scope;
class Scope {

View file

@ -21,6 +21,8 @@ import { EventEmitter } from 'events';
import { debounce, forEach, get } from 'lodash';
import * as Rx from 'rxjs';
import { share } from 'rxjs/operators';
import { i18n } from '@kbn/i18n';
import { toastNotifications } from 'ui/notify';
// @ts-ignore untyped dependency
import { registries } from '../../../../core_plugins/interpreter/public/registries';
import { Inspector } from '../../inspector';
@ -46,9 +48,6 @@ import {
} from './types';
import { queryGeohashBounds } from './utils';
import { i18n } from '@kbn/i18n';
import { toastNotifications } from 'ui/notify';
interface EmbeddedVisualizeHandlerParams extends VisualizeLoaderParams {
Private: IPrivate;
queryFilter: any;

View file

@ -18,6 +18,7 @@
*/
import { isEqual } from 'lodash';
import { getVisParams } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
import { VisRequestHandlersRegistryProvider as RequestHandlersProvider } from '../../registry/vis_request_handlers';
import { VisResponseHandlersRegistryProvider as ResponseHandlerProvider } from '../../registry/vis_response_handlers';
@ -33,8 +34,6 @@ import {
import { VisResponseData } from './types';
import { getVisParams } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
function getHandler<T extends RequestHandler | ResponseHandler>(
from: Array<{ name: string; handler: T }>,
type: string | T

View file

@ -22,6 +22,6 @@ import { dirname } from 'path';
export const pkg = {
__filename: require.resolve('../../../package.json'),
__dirname: dirname(require.resolve('../../../package.json')),
// tslint:disable no-var-requires
// eslint-disable no-var-requires
...require('../../../package.json'),
};

View file

@ -19,12 +19,17 @@
import { Readable, Transform, Writable, TransformOptions } from 'stream';
export function concatStreamProviders(sourceProviders: Readable[], options: TransformOptions): Transform;
export function concatStreamProviders(
sourceProviders: Readable[],
options: TransformOptions
): Transform;
export function createIntersperseStream(intersperseChunk: string | Buffer): Transform;
export function createSplitStream<T>(splitChunk: T): Transform;
export function createListStream(items: any[]): Readable;
export function createReduceStream<T>(reducer: (value: any, chunk: T, enc: string) => T): Transform;
export function createPromiseFromStreams<T>([first, ...rest]: [Readable, ...Writable[]]): Promise<T>;
export function createPromiseFromStreams<T>([first, ...rest]: [Readable, ...Writable[]]): Promise<
T
>;
export function createConcatStream(initial: any): Transform;
export function createMapStream<T>(fn: (value: T, i: number) => void): Transform;
export function createReplaceStream(toReplace: string, replacement: string | Buffer): Transform;

View file

@ -21,7 +21,7 @@ import { Plugin, PluginSetupContext } from 'kibana/public';
export class TestbedPlugin implements Plugin<TestbedPluginSetup> {
public setup(core: PluginSetupContext, deps: {}) {
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.log(`Testbed plugin loaded`);
}
}

View file

@ -100,16 +100,7 @@ module.exports = function (grunt) {
},
// used by the test and jenkins:unit tasks
// runs the tslint script to check for Typescript linting errors
tslint: {
cmd: process.execPath,
args: [
require.resolve('../../scripts/tslint')
]
},
// used by the test and jenkins:unit tasks
// runs the tslint script to check for Typescript linting errors
// runs the typecheck script to check for Typescript type errors
typeCheck: {
cmd: process.execPath,
args: [

View file

@ -24,7 +24,6 @@ module.exports = function (grunt) {
grunt.registerTask('jenkins:unit', [
'run:eslint',
'run:tslint',
'run:sasslint',
'run:checkTsProjects',
'run:checkCoreApiChanges',

View file

@ -70,7 +70,6 @@ module.exports = function (grunt) {
grunt.task.run(
_.compact([
!grunt.option('quick') && 'run:eslint',
!grunt.option('quick') && 'run:tslint',
!grunt.option('quick') && 'run:sasslint',
!grunt.option('quick') && 'run:checkTsProjects',
!grunt.option('quick') && 'run:checkCoreApiChanges',

Some files were not shown because too many files have changed in this diff Show more