diff --git a/.eslintignore b/.eslintignore index 8d43ffd8191c3d..de3a2d1c5dac44 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,6 +2,7 @@ node_modules bower_components /data /build +/target /.es /plugins /optimize diff --git a/.eslintrc.js b/.eslintrc.js index 50f765bb6a4b1f..f1f2b34fae2fc1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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, }, diff --git a/TYPESCRIPT.md b/TYPESCRIPT.md index 66b2fd0e77c680..058b1dca67f56a 100644 --- a/TYPESCRIPT.md +++ b/TYPESCRIPT.md @@ -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 diff --git a/kibana.d.ts b/kibana.d.ts index 74890f1d70f4b5..45cf4405a8edc0 100644 --- a/kibana.d.ts +++ b/kibana.d.ts @@ -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; diff --git a/package.json b/package.json index f34f599c98ac5f..8dd7a2de2a0c17 100644 --- a/package.json +++ b/package.json @@ -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", @@ -323,6 +322,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", @@ -340,11 +341,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", @@ -408,10 +410,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", diff --git a/packages/elastic-datemath/src/index.d.ts b/packages/elastic-datemath/src/index.d.ts index 528b1620bc1a45..ea63dadd81156c 100644 --- a/packages/elastic-datemath/src/index.d.ts +++ b/packages/elastic-datemath/src/index.d.ts @@ -47,4 +47,5 @@ declare const datemath: { ): moment.Moment | undefined; }; +// eslint-disable-next-line import/no-default-export export default datemath; diff --git a/packages/eslint-config-kibana/.eslintrc.js b/packages/eslint-config-kibana/.eslintrc.js index 0b509d81c5795b..6d39eb98ddb4bc 100644 --- a/packages/eslint-config-kibana/.eslintrc.js +++ b/packages/eslint-config-kibana/.eslintrc.js @@ -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', + }, + ], + ], } -} +}; diff --git a/packages/eslint-config-kibana/javascript.js b/packages/eslint-config-kibana/javascript.js new file mode 100644 index 00000000000000..a5433fa6b5d97d --- /dev/null +++ b/packages/eslint-config-kibana/javascript.js @@ -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', + } + }, + ] +}; diff --git a/packages/eslint-config-kibana/jest.js b/packages/eslint-config-kibana/jest.js index c28a9c48c68268..93393cf542b549 100644 --- a/packages/eslint-config-kibana/jest.js +++ b/packages/eslint-config-kibana/jest.js @@ -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' }, } ] diff --git a/packages/eslint-config-kibana/package.json b/packages/eslint-config-kibana/package.json index 4be75ca2bcbe58..5902b3c9fcad4f 100644 --- a/packages/eslint-config-kibana/package.json +++ b/packages/eslint-config-kibana/package.json @@ -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", diff --git a/packages/eslint-config-kibana/typescript.js b/packages/eslint-config-kibana/typescript.js new file mode 100644 index 00000000000000..b4f73185a0d925 --- /dev/null +++ b/packages/eslint-config-kibana/typescript.js @@ -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 + ) + }, + ] +}; diff --git a/packages/kbn-dev-utils/src/tooling_log/tooling_log.d.ts b/packages/kbn-dev-utils/src/tooling_log/tooling_log.d.ts index e59524edbe0d94..672de893236c68 100644 --- a/packages/kbn-dev-utils/src/tooling_log/tooling_log.d.ts +++ b/packages/kbn-dev-utils/src/tooling_log/tooling_log.d.ts @@ -17,7 +17,7 @@ * under the License. */ -// tslint:disable max-classes-per-file +// eslint-disable max-classes-per-file import * as Rx from 'rxjs'; diff --git a/packages/kbn-es-query/src/kuery/ast/ast.d.ts b/packages/kbn-es-query/src/kuery/ast/ast.d.ts index df81c8651c4cb6..484abac809bcd3 100644 --- a/packages/kbn-es-query/src/kuery/ast/ast.d.ts +++ b/packages/kbn-es-query/src/kuery/ast/ast.d.ts @@ -38,6 +38,7 @@ interface JsonObject { [key: string]: JsonValue; } +// eslint-disable-next-line @typescript-eslint/no-empty-interface interface JsonArray extends Array {} export function fromKueryExpression( diff --git a/packages/kbn-eslint-plugin-eslint/rules/module_migration.js b/packages/kbn-eslint-plugin-eslint/rules/module_migration.js index 4f4f1b0f31c963..c5f2aff9bfdcfc 100644 --- a/packages/kbn-eslint-plugin-eslint/rules/module_migration.js +++ b/packages/kbn-eslint-plugin-eslint/rules/module_migration.js @@ -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: [], diff --git a/packages/kbn-expect/expect.js.d.ts b/packages/kbn-expect/expect.js.d.ts index 9e0b069499030b..2062dea686500f 100644 --- a/packages/kbn-expect/expect.js.d.ts +++ b/packages/kbn-expect/expect.js.d.ts @@ -1,4 +1,4 @@ -// tslint:disable +/* eslint-disable */ // Type definitions for expect.js 0.3.1 // Project: https://github.com/Automattic/expect.js diff --git a/packages/kbn-i18n/src/core/helper.test.ts b/packages/kbn-i18n/src/core/helper.test.ts index ee2202dca7f0c6..6031a3d9914ad9 100644 --- a/packages/kbn-i18n/src/core/helper.test.ts +++ b/packages/kbn-i18n/src/core/helper.test.ts @@ -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); }); diff --git a/packages/kbn-i18n/src/core/i18n.test.ts b/packages/kbn-i18n/src/core/i18n.test.ts index a8ee59cd87f6d6..f52771d9bb04e0 100644 --- a/packages/kbn-i18n/src/core/i18n.test.ts +++ b/packages/kbn-i18n/src/core/i18n.test.ts @@ -17,6 +17,8 @@ * under the License. */ +/* eslint-disable @typescript-eslint/no-var-requires */ + import * as i18nModule from './i18n'; describe('I18n engine', () => { diff --git a/packages/kbn-i18n/tslint.yml b/packages/kbn-i18n/tslint.yml deleted file mode 100644 index e470d241339a77..00000000000000 --- a/packages/kbn-i18n/tslint.yml +++ /dev/null @@ -1,2 +0,0 @@ -extends: - - ../../tslint.yaml diff --git a/packages/kbn-plugin-generator/sao_template/template/package_template.json b/packages/kbn-plugin-generator/sao_template/template/package_template.json index da38b249d9b689..4b6629fa902685 100644 --- a/packages/kbn-plugin-generator/sao_template/template/package_template.json +++ b/packages/kbn-plugin-generator/sao_template/template/package_template.json @@ -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", diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 808f72116f8151..a920d451813ee7 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -4136,7 +4136,7 @@ const log = { * @param ...args */ write(...args) { - // tslint:disable no-console + // eslint-disable-next-line no-console console.log(...args); } diff --git a/packages/kbn-pm/src/utils/link_project_executables.test.ts b/packages/kbn-pm/src/utils/link_project_executables.test.ts index ac0b69d01f798e..a6334ec850860e 100644 --- a/packages/kbn-pm/src/utils/link_project_executables.test.ts +++ b/packages/kbn-pm/src/utils/link_project_executables.test.ts @@ -17,6 +17,8 @@ * under the License. */ +/* eslint-disable @typescript-eslint/no-var-requires */ + jest.mock('./fs'); import { resolve } from 'path'; diff --git a/packages/kbn-pm/src/utils/log.ts b/packages/kbn-pm/src/utils/log.ts index 8e81e8592af47e..45ad08b8a24a06 100644 --- a/packages/kbn-pm/src/utils/log.ts +++ b/packages/kbn-pm/src/utils/log.ts @@ -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); }, }; diff --git a/packages/kbn-pm/src/utils/projects_tree.ts b/packages/kbn-pm/src/utils/projects_tree.ts index 61e997d021a17e..c7a13ce2de3480 100644 --- a/packages/kbn-pm/src/utils/projects_tree.ts +++ b/packages/kbn-pm/src/utils/projects_tree.ts @@ -33,10 +33,12 @@ interface ITree { name?: string; children?: ITreeChildren; } +// eslint-disable-next-line @typescript-eslint/no-empty-interface interface ITreeChildren extends Array {} type DirOrProjectName = string | typeof projectKey; +// eslint-disable-next-line @typescript-eslint/no-empty-interface interface IProjectsTree extends Map {} function treeToString(tree: ITree) { diff --git a/packages/kbn-test-subj-selector/index.d.ts b/packages/kbn-test-subj-selector/index.d.ts index 91eda37f1e8445..7a3a681e585e1c 100644 --- a/packages/kbn-test-subj-selector/index.d.ts +++ b/packages/kbn-test-subj-selector/index.d.ts @@ -17,4 +17,5 @@ * under the License. */ +// eslint-disable-next-line import/no-default-export export default function(selector: string): string; diff --git a/scripts/tslint.js b/scripts/tslint.js deleted file mode 100644 index 0ec8ce7dd632a3..00000000000000 --- a/scripts/tslint.js +++ /dev/null @@ -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(); diff --git a/src/core/public/core_system.ts b/src/core/public/core_system.ts index 0a8b93b6581569..106c55c91e09c8 100644 --- a/src/core/public/core_system.ts +++ b/src/core/public/core_system.ts @@ -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 {} /** diff --git a/src/core/public/fatal_errors/fatal_errors_screen.tsx b/src/core/public/fatal_errors/fatal_errors_screen.tsx index a139e501e44aaf..551e54d3003e43 100644 --- a/src/core/public/fatal_errors/fatal_errors_screen.tsx +++ b/src/core/public/fatal_errors/fatal_errors_screen.tsx @@ -72,7 +72,7 @@ export class FatalErrorsScreen extends React.Component { ) ).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); }, }); diff --git a/src/core/public/fatal_errors/fatal_errors_service.tsx b/src/core/public/fatal_errors/fatal_errors_service.tsx index d0e9e11b3581f0..5506fb24a281c8 100644 --- a/src/core/public/fatal_errors/fatal_errors_service.tsx +++ b/src/core/public/fatal_errors/fatal_errors_service.tsx @@ -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); } diff --git a/src/core/public/injected_metadata/deep_freeze.ts b/src/core/public/injected_metadata/deep_freeze.ts index f172c5de6a9aab..60aa60440e379b 100644 --- a/src/core/public/injected_metadata/deep_freeze.ts +++ b/src/core/public/injected_metadata/deep_freeze.ts @@ -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 extends Array> {} type RecursiveReadonly = T extends any[] diff --git a/src/core/public/plugins/plugin_context.ts b/src/core/public/plugins/plugin_context.ts index b14a3335fd5a56..6d75d450dd7d0a 100644 --- a/src/core/public/plugins/plugin_context.ts +++ b/src/core/public/plugins/plugin_context.ts @@ -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 {} /** diff --git a/src/core/public/ui_settings/ui_settings_service.test.mocks.ts b/src/core/public/ui_settings/ui_settings_service.test.mocks.ts index 458a9efdea4694..b94401c5928df0 100644 --- a/src/core/public/ui_settings/ui_settings_service.test.mocks.ts +++ b/src/core/public/ui_settings/ui_settings_service.test.mocks.ts @@ -19,7 +19,7 @@ function mockClass( 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[]) { diff --git a/src/core/public/ui_settings/ui_settings_service.ts b/src/core/public/ui_settings/ui_settings_service.ts index 8162da7e1f0c5e..f3a43a4f4a0f03 100644 --- a/src/core/public/ui_settings/ui_settings_service.ts +++ b/src/core/public/ui_settings/ui_settings_service.ts @@ -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; diff --git a/src/core/server/bootstrap.ts b/src/core/server/bootstrap.ts index 766eb09032a9e6..25ac744790e79e 100644 --- a/src/core/server/bootstrap.ts +++ b/src/core/server/bootstrap.ts @@ -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`); } diff --git a/src/core/server/config/config_service.test.ts b/src/core/server/config/config_service.test.ts index a054786c80f7d0..fd03554e9209d5 100644 --- a/src/core/server/config/config_service.test.ts +++ b/src/core/server/config/config_service.test.ts @@ -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'; diff --git a/src/core/server/config/env.ts b/src/core/server/config/env.ts index 4ee7a778e9c8f6..d67880171a69f0 100644 --- a/src/core/server/config/env.ts +++ b/src/core/server/config/env.ts @@ -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 { diff --git a/src/core/server/http/https_redirect_server.test.ts b/src/core/server/http/https_redirect_server.test.ts index dc11d5212d93e0..e7cd653bb9eec7 100644 --- a/src/core/server/http/https_redirect_server.test.ts +++ b/src/core/server/http/https_redirect_server.test.ts @@ -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' }; }); diff --git a/src/core/server/http/ssl_config.ts b/src/core/server/http/ssl_config.ts index c9b41b493c0043..7db0a95ca77601 100644 --- a/src/core/server/http/ssl_config.ts +++ b/src/core/server/http/ssl_config.ts @@ -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); } diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts index 8d85516f29aa74..3a24ef03ccf6a8 100644 --- a/src/core/server/legacy/legacy_service.ts +++ b/src/core/server/legacy/legacy_service.ts @@ -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 diff --git a/src/core/server/logging/appenders/appenders.test.mocks.ts b/src/core/server/logging/appenders/appenders.test.mocks.ts index 551a4ac1bedc34..400dd33df4cfe6 100644 --- a/src/core/server/logging/appenders/appenders.test.mocks.ts +++ b/src/core/server/logging/appenders/appenders.test.mocks.ts @@ -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: { diff --git a/src/core/server/logging/appenders/console/console_appender.test.ts b/src/core/server/logging/appenders/console/console_appender.test.ts index 9763ebe19ef29c..364f0be7fadc34 100644 --- a/src/core/server/logging/appenders/console/console_appender.test.ts +++ b/src/core/server/logging/appenders/console/console_appender.test.ts @@ -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); }); diff --git a/src/core/server/logging/appenders/console/console_appender.ts b/src/core/server/logging/appenders/console/console_appender.ts index 67d0ea4d1837aa..b4420c12a23cab 100644 --- a/src/core/server/logging/appenders/console/console_appender.ts +++ b/src/core/server/logging/appenders/console/console_appender.ts @@ -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)); } diff --git a/src/core/server/logging/appenders/file/file_appender.test.mocks.ts b/src/core/server/logging/appenders/file/file_appender.test.mocks.ts index a4e4532882f520..cbddeb5b3a5bda 100644 --- a/src/core/server/logging/appenders/file/file_appender.test.mocks.ts +++ b/src/core/server/logging/appenders/file/file_appender.test.mocks.ts @@ -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: { diff --git a/src/core/server/plugins/plugin.ts b/src/core/server/plugins/plugin.ts index 68afc715263671..8669f8353b71f7 100644 --- a/src/core/server/plugins/plugin.ts +++ b/src/core/server/plugins/plugin.ts @@ -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}).`); diff --git a/src/core/server/root/index.ts b/src/core/server/root/index.ts index 3734d7533297e4..00c77550326ef6 100644 --- a/src/core/server/root/index.ts +++ b/src/core/server/root/index.ts @@ -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; diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index 6951aa1b461c4b..43ae889904dd74 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -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 diff --git a/src/dev/run_eslint.js b/src/dev/run_eslint.js index d6763769dec64e..3bfbb9cc876e06 100644 --- a/src/dev/run_eslint.js +++ b/src/dev/run_eslint.js @@ -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'); diff --git a/src/dev/run_precommit_hook.js b/src/dev/run_precommit_hook.js index b1cd2f13846fac..1b925beb577cb9 100644 --- a/src/dev/run_precommit_hook.js +++ b/src/dev/run_precommit_hook.js @@ -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 { diff --git a/src/dev/tslint/index.ts b/src/dev/tslint/index.ts deleted file mode 100644 index ff349a93354dda..00000000000000 --- a/src/dev/tslint/index.ts +++ /dev/null @@ -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'; diff --git a/src/dev/tslint/lint_files.ts b/src/dev/tslint/lint_files.ts deleted file mode 100644 index fe22bf90e66d02..00000000000000 --- a/src/dev/tslint/lint_files.ts +++ /dev/null @@ -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 = 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} 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); - } - } -} diff --git a/src/dev/tslint/pick_files_to_lint.ts b/src/dev/tslint/pick_files_to_lint.ts deleted file mode 100644 index 7dc27c6a4d130c..00000000000000 --- a/src/dev/tslint/pick_files_to_lint.ts +++ /dev/null @@ -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()); -} diff --git a/src/dev/tslint/rules/disallowLicenseHeaderRule.js b/src/dev/tslint/rules/disallowLicenseHeaderRule.js deleted file mode 100644 index 09995c47ff7410..00000000000000 --- a/src/dev/tslint/rules/disallowLicenseHeaderRule.js +++ /dev/null @@ -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, '') - ) - ]; - } -}; diff --git a/src/dev/tslint/rules/moduleMigrationRule.js b/src/dev/tslint/rules/moduleMigrationRule.js deleted file mode 100644 index 24d81274b79fe6..00000000000000 --- a/src/dev/tslint/rules/moduleMigrationRule.js +++ /dev/null @@ -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())); - } -}; diff --git a/src/dev/tslint/rules/requireLicenseHeaderRule.js b/src/dev/tslint/rules/requireLicenseHeaderRule.js deleted file mode 100644 index 91db7a49795d35..00000000000000 --- a/src/dev/tslint/rules/requireLicenseHeaderRule.js +++ /dev/null @@ -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`) - ) - ]; - } -}; diff --git a/src/dev/tslint/run_tslint_cli.ts b/src/dev/tslint/run_tslint_cli.ts deleted file mode 100644 index 28840e45d54a4d..00000000000000 --- a/src/dev/tslint/run_tslint_cli.ts +++ /dev/null @@ -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); -} diff --git a/src/legacy/core_plugins/elasticsearch/index.d.ts b/src/legacy/core_plugins/elasticsearch/index.d.ts index f0d895d6825706..9a524ab06e7bf3 100644 --- a/src/legacy/core_plugins/elasticsearch/index.d.ts +++ b/src/legacy/core_plugins/elasticsearch/index.d.ts @@ -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; (request: Request, endpoint: 'clearScroll', params: ClearScrollParams, options?: CallClusterOptions): ReturnType; (request: Request, endpoint: 'count', params: CountParams, options?: CallClusterOptions): ReturnType; @@ -345,7 +345,6 @@ export interface CallClusterWithRequest { (request: Request, endpoint: 'tasks.cancel', params: TasksCancelParams, options?: CallClusterOptions): ReturnType; (request: Request, endpoint: 'tasks.get', params: TasksGetParams, options?: CallClusterOptions): ReturnType; (request: Request, endpoint: 'tasks.list', params: TasksListParams, options?: CallClusterOptions): ReturnType; - /* tslint:enable */ // other APIs accessed via transport.request ( @@ -368,10 +367,11 @@ export interface CallClusterWithRequest { clientParams?: any, options?: CallClusterOptions ): Promise; + /* eslint-enable */ } export interface CallCluster { - /* tslint:disable */ + /* eslint-disable */ (endpoint: 'bulk', params: BulkIndexDocumentsParams, options?: CallClusterOptions): ReturnType; (endpoint: 'clearScroll', params: ClearScrollParams, options?: CallClusterOptions): ReturnType; (endpoint: 'count', params: CountParams, options?: CallClusterOptions): ReturnType; @@ -507,7 +507,6 @@ export interface CallCluster { (endpoint: 'tasks.cancel', params: TasksCancelParams, options?: CallClusterOptions): ReturnType; (endpoint: 'tasks.get', params: TasksGetParams, options?: CallClusterOptions): ReturnType; (endpoint: 'tasks.list', params: TasksListParams, options?: CallClusterOptions): ReturnType; - /* 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 (endpoint: string, clientParams?: any, options?: CallClusterOptions): Promise; + /* eslint-enable */ } export interface ElasticsearchPlugin { diff --git a/src/legacy/core_plugins/interpreter/index.ts b/src/legacy/core_plugins/interpreter/index.ts index bd637295c91c7c..a86bfd833837c5 100644 --- a/src/legacy/core_plugins/interpreter/index.ts +++ b/src/legacy/core_plugins/interpreter/index.ts @@ -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', diff --git a/src/legacy/core_plugins/interpreter/init.ts b/src/legacy/core_plugins/interpreter/init.ts index 0cb3f590d37c7f..74f003774cb28a 100644 --- a/src/legacy/core_plugins/interpreter/init.ts +++ b/src/legacy/core_plugins/interpreter/init.ts @@ -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, diff --git a/src/legacy/core_plugins/kibana/public/dashboard/actions/embeddables.ts b/src/legacy/core_plugins/kibana/public/dashboard/actions/embeddables.ts index 02fc2e8b32f9b2..21fd2baee21b7b 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/actions/embeddables.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/actions/embeddables.ts @@ -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 { diff --git a/src/legacy/core_plugins/kibana/public/dashboard/actions/metadata.ts b/src/legacy/core_plugins/kibana/public/dashboard/actions/metadata.ts index 05466c9b8a0818..6b2236ea04dca5 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/actions/metadata.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/actions/metadata.ts @@ -17,6 +17,8 @@ * under the License. */ +/* eslint-disable @typescript-eslint/no-empty-interface */ + import { createAction } from 'redux-actions'; import { KibanaAction } from '../../selectors/types'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/actions/panels.ts b/src/legacy/core_plugins/kibana/public/dashboard/actions/panels.ts index 51069bcfd3ff3f..d29e8da9e2eca6 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/actions/panels.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/actions/panels.ts @@ -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, PanelState, PanelStateMap } from '../selectors'; @@ -24,8 +26,8 @@ import { PanelId, PanelState, PanelStateMap } 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 {} export interface ResetPanelTitleAction - extends KibanaAction {} + extends KibanaAction {} export interface SetPanelTitleActionPayload { panelId: PanelId; @@ -48,7 +50,7 @@ export interface SetPanelTitleActionPayload { } export interface SetPanelTitleAction - extends KibanaAction {} + extends KibanaAction {} export interface SetPanelsAction extends KibanaAction {} @@ -63,9 +65,9 @@ export type PanelActions = export const deletePanel = createAction(PanelActionTypeKeys.DELETE_PANEL); export const updatePanel = createAction(PanelActionTypeKeys.UPDATE_PANEL); -export const resetPanelTitle = createAction(PanelActionTypeKeys.RESET_PANEl_TITLE); +export const resetPanelTitle = createAction(PanelActionTypeKeys.RESET_PANEL_TITLE); export const setPanelTitle = createAction( - PanelActionTypeKeys.SET_PANEl_TITLE + PanelActionTypeKeys.SET_PANEL_TITLE ); export const updatePanels = createAction(PanelActionTypeKeys.UPDATE_PANELS); export const setPanels = createAction(PanelActionTypeKeys.SET_PANELS); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/actions/view.ts b/src/legacy/core_plugins/kibana/public/dashboard/actions/view.ts index 1b84df22f8df13..6b2bbc5fefaadc 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/actions/view.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/actions/view.ts @@ -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 {} export interface MaximizePanelAction - extends KibanaAction {} + extends KibanaAction {} export interface MinimizePanelAction extends KibanaAction {} @@ -92,7 +94,7 @@ export const closeContextMenu = createAction(ViewActionTypeKeys.CLOSE_CONTEXT_ME export const setVisibleContextMenuPanelId = createAction( ViewActionTypeKeys.SET_VISIBLE_CONTEXT_MENU_PANEL_ID ); -export const maximizePanel = createAction(ViewActionTypeKeys.MAXIMIZE_PANEl); +export const maximizePanel = createAction(ViewActionTypeKeys.MAXIMIZE_PANEL); export const minimizePanel = createAction(ViewActionTypeKeys.MINIMIZE_PANEL); export const updateIsFullScreenMode = createAction( ViewActionTypeKeys.UPDATE_IS_FULL_SCREEN_MODE diff --git a/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts b/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts index 478c59847fe3a4..6b537a2a2c405a 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_header/panel_options_menu_container.ts @@ -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(); }; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_utils.ts b/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_utils.ts index c4ea15eac5374f..b74fbe68f00a09 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_utils.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/panel/panel_utils.ts @@ -35,6 +35,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: any): PanelState { ['col', 'row'].forEach(key => { if (!_.has(panel, key)) { @@ -69,6 +70,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: GridData; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/reducers/panels.ts b/src/legacy/core_plugins/kibana/public/dashboard/reducers/panels.ts index f4961a61c01b80..b9db8f6bc22b44 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/reducers/panels.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/reducers/panels.ts @@ -67,9 +67,9 @@ export const panelsReducer: Reducer = (panels = {}, action): Pane 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); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/reducers/view.ts b/src/legacy/core_plugins/kibana/public/dashboard/reducers/view.ts index 3792203bcb2312..4f1d060d991266 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/reducers/view.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/reducers/view.ts @@ -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 = ( 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); diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts index ef1debdb218e90..8b5a53353d82ed 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.ts @@ -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'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx index ae2e54dc21fdb3..491fde48ce2cf9 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx @@ -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; diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/type_selection.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/type_selection.tsx index 471e067a572ea3..ae1615a0c5a5a8 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/type_selection.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/type_selection.tsx @@ -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; } diff --git a/src/legacy/server/kbn_server.d.ts b/src/legacy/server/kbn_server.d.ts index 3bb885dbee756d..bf85cf3ab860bf 100644 --- a/src/legacy/server/kbn_server.d.ts +++ b/src/legacy/server/kbn_server.d.ts @@ -60,6 +60,7 @@ declare module 'hapi' { type KbnMixinFunc = (kbnServer: KbnServer, server: Server, config: any) => Promise | void; type Unpromise = T extends Promise ? U : T; +// eslint-disable-next-line import/no-default-export export default class KbnServer { public readonly newPlatform: { setup: { diff --git a/src/legacy/server/saved_objects/migrations/core/call_cluster.ts b/src/legacy/server/saved_objects/migrations/core/call_cluster.ts index 8ce9ace5f0b1cb..961961597855a8 100644 --- a/src/legacy/server/saved_objects/migrations/core/call_cluster.ts +++ b/src/legacy/server/saved_objects/migrations/core/call_cluster.ts @@ -25,6 +25,7 @@ import { IndexMapping } from '../../../mappings'; +/* eslint-disable @typescript-eslint/unified-signatures */ export interface CallCluster { (path: 'bulk', opts: { body: object[] }): Promise; (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 diff --git a/src/legacy/server/saved_objects/migrations/core/migration_coordinator.test.ts b/src/legacy/server/saved_objects/migrations/core/migration_coordinator.test.ts index 906a7311a0f643..818ca73b371892 100644 --- a/src/legacy/server/saved_objects/migrations/core/migration_coordinator.test.ts +++ b/src/legacy/server/saved_objects/migrations/core/migration_coordinator.test.ts @@ -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(); diff --git a/src/legacy/server/saved_objects/serialization/index.ts b/src/legacy/server/saved_objects/serialization/index.ts index 00a9e81e5c1c36..997c5d38b69db2 100644 --- a/src/legacy/server/saved_objects/serialization/index.ts +++ b/src/legacy/server/saved_objects/serialization/index.ts @@ -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'; diff --git a/src/legacy/ui/public/ajax_stream/ajax_stream.test.ts b/src/legacy/ui/public/ajax_stream/ajax_stream.test.ts index 755473d1ee2373..243c766206d2de 100644 --- a/src/legacy/ui/public/ajax_stream/ajax_stream.test.ts +++ b/src/legacy/ui/public/ajax_stream/ajax_stream.test.ts @@ -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', () => { diff --git a/src/legacy/ui/public/chrome/directives/header_global_nav/components/header.tsx b/src/legacy/ui/public/chrome/directives/header_global_nav/components/header.tsx index 2c78e8b79f6ce7..98e176fdc704f0 100644 --- a/src/legacy/ui/public/chrome/directives/header_global_nav/components/header.tsx +++ b/src/legacy/ui/public/chrome/directives/header_global_nav/components/header.tsx @@ -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'; diff --git a/src/legacy/ui/public/chrome/directives/header_global_nav/components/header_help_menu.tsx b/src/legacy/ui/public/chrome/directives/header_global_nav/components/header_help_menu.tsx index 43fbe1323f0b24..65a4db537d9a2a 100644 --- a/src/legacy/ui/public/chrome/directives/header_global_nav/components/header_help_menu.tsx +++ b/src/legacy/ui/public/chrome/directives/header_global_nav/components/header_help_menu.tsx @@ -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'; diff --git a/src/legacy/ui/public/chrome/index.d.ts b/src/legacy/ui/public/chrome/index.d.ts index 8ae0d489ed568d..e76cfe52f61930 100644 --- a/src/legacy/ui/public/chrome/index.d.ts +++ b/src/legacy/ui/public/chrome/index.d.ts @@ -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'; diff --git a/src/legacy/ui/public/query_bar/components/__snapshots__/query_bar.test.tsx.snap b/src/legacy/ui/public/query_bar/components/__snapshots__/query_bar.test.tsx.snap index fb5aad7e16e89d..74b5183ba64789 100644 --- a/src/legacy/ui/public/query_bar/components/__snapshots__/query_bar.test.tsx.snap +++ b/src/legacy/ui/public/query_bar/components/__snapshots__/query_bar.test.tsx.snap @@ -24,7 +24,6 @@ exports[`QueryBar Should disable autoFocus on EuiFieldText when disableAutoFocus >
{ aria-owns="kbnTypeahead__items" aria-controls="kbnTypeahead__items" > - +
= props => { return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/interactive-supports-focus
extends IndexedArray {} interface UIRegistrySpec extends IndexedArrayConfig { diff --git a/src/legacy/ui/public/routes/index.d.ts b/src/legacy/ui/public/routes/index.d.ts index 9e1a3bbd534eea..84e17b0a69452d 100644 --- a/src/legacy/ui/public/routes/index.d.ts +++ b/src/legacy/ui/public/routes/index.d.ts @@ -19,5 +19,6 @@ import { uiRoutes, UIRoutes } from 'ui/routes/routes'; +// eslint-disable-next-line import/no-default-export export default uiRoutes; export { UIRoutes }; diff --git a/src/legacy/ui/public/routes/route_manager.d.ts b/src/legacy/ui/public/routes/route_manager.d.ts index 8503696202b085..10bdf9100182ff 100644 --- a/src/legacy/ui/public/routes/route_manager.d.ts +++ b/src/legacy/ui/public/routes/route_manager.d.ts @@ -38,4 +38,5 @@ interface RouteManager { defaults(path: string | RegExp, defaults: RouteConfiguration): RouteManager; } +// eslint-disable-next-line import/no-default-export export default RouteManager; diff --git a/src/legacy/ui/public/saved_objects/simple_saved_object.ts b/src/legacy/ui/public/saved_objects/simple_saved_object.ts index 0d271d88162930..4bb20efdf43fa3 100644 --- a/src/legacy/ui/public/saved_objects/simple_saved_object.ts +++ b/src/legacy/ui/public/saved_objects/simple_saved_object.ts @@ -34,7 +34,8 @@ import { SavedObjectsClient } from './saved_objects_client'; */ export class SimpleSavedObject { 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['version']; public id: SavedObjectType['id']; public type: SavedObjectType['type']; diff --git a/src/legacy/ui/public/search_bar/components/search_bar.tsx b/src/legacy/ui/public/search_bar/components/search_bar.tsx index da6dec7906e2e1..54225862618604 100644 --- a/src/legacy/ui/public/search_bar/components/search_bar.tsx +++ b/src/legacy/ui/public/search_bar/components/search_bar.tsx @@ -92,9 +92,9 @@ class SearchBarUI extends Component { }; // 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({ diff --git a/src/legacy/ui/public/share/components/url_panel_content.tsx b/src/legacy/ui/public/share/components/url_panel_content.tsx index e7d719b5ba694c..c579def221effb 100644 --- a/src/legacy/ui/public/share/components/url_panel_content.tsx +++ b/src/legacy/ui/public/share/components/url_panel_content.tsx @@ -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; diff --git a/src/legacy/ui/public/share/show_share_context_menu.tsx b/src/legacy/ui/public/share/show_share_context_menu.tsx index 4dae2005da75e6..dcc685b0dbdf7d 100644 --- a/src/legacy/ui/public/share/show_share_context_menu.tsx +++ b/src/legacy/ui/public/share/show_share_context_menu.tsx @@ -20,12 +20,10 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { ShareContextMenu } from './components/share_context_menu'; -import { ShareActionProvider } from './share_action'; - import { EuiWrappingPopover } from '@elastic/eui'; - import { I18nContext } from 'ui/i18n'; +import { ShareContextMenu } from './components/share_context_menu'; +import { ShareActionProvider } from './share_action'; let isOpen = false; diff --git a/src/legacy/ui/public/timefilter/get_time.ts b/src/legacy/ui/public/timefilter/get_time.ts index 515942f2688df8..8fdbd2a133349a 100644 --- a/src/legacy/ui/public/timefilter/get_time.ts +++ b/src/legacy/ui/public/timefilter/get_time.ts @@ -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(); diff --git a/src/legacy/ui/public/utils/cidr_mask.ts b/src/legacy/ui/public/utils/cidr_mask.ts index 531b5ae5412be5..8dee0ab4e0c128 100644 --- a/src/legacy/ui/public/utils/cidr_mask.ts +++ b/src/legacy/ui/public/utils/cidr_mask.ts @@ -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 { diff --git a/src/legacy/ui/public/utils/decode_geo_hash.ts b/src/legacy/ui/public/utils/decode_geo_hash.ts index 3a6a427b4b2765..e6ab7121038a15 100644 --- a/src/legacy/ui/public/utils/decode_geo_hash.ts +++ b/src/legacy/ui/public/utils/decode_geo_hash.ts @@ -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; diff --git a/src/legacy/ui/public/utils/ipv4_address.ts b/src/legacy/ui/public/utils/ipv4_address.ts index 533f2ba6275f0d..f0afe858e15562 100644 --- a/src/legacy/ui/public/utils/ipv4_address.ts +++ b/src/legacy/ui/public/utils/ipv4_address.ts @@ -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; diff --git a/src/legacy/ui/public/utils/memoize.ts b/src/legacy/ui/public/utils/memoize.ts index cf9258538bf60c..fea1b892620810 100644 --- a/src/legacy/ui/public/utils/memoize.ts +++ b/src/legacy/ui/public/utils/memoize.ts @@ -35,7 +35,6 @@ function memoizeLast 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 && diff --git a/src/legacy/ui/public/utils/subscribe_with_scope.test.ts b/src/legacy/ui/public/utils/subscribe_with_scope.test.ts index 077875c5ac6e5b..be5462593e38be 100644 --- a/src/legacy/ui/public/utils/subscribe_with_scope.test.ts +++ b/src/legacy/ui/public/utils/subscribe_with_scope.test.ts @@ -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 { diff --git a/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts b/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts index 9b346860c632c5..4d167bcb2002cd 100644 --- a/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts +++ b/src/legacy/ui/public/visualize/loader/embedded_visualize_handler.ts @@ -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; diff --git a/src/legacy/ui/public/visualize/loader/visualize_data_loader.ts b/src/legacy/ui/public/visualize/loader/visualize_data_loader.ts index 63d64bf4c0b1c0..589b5f2723112c 100644 --- a/src/legacy/ui/public/visualize/loader/visualize_data_loader.ts +++ b/src/legacy/ui/public/visualize/loader/visualize_data_loader.ts @@ -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( from: Array<{ name: string; handler: T }>, type: string | T diff --git a/src/legacy/utils/package_json.ts b/src/legacy/utils/package_json.ts index 750dd7e2e1040b..7cc67b413922a3 100644 --- a/src/legacy/utils/package_json.ts +++ b/src/legacy/utils/package_json.ts @@ -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'), }; diff --git a/src/legacy/utils/streams/index.d.ts b/src/legacy/utils/streams/index.d.ts index c306000306c32c..b8d4c67050b2da 100644 --- a/src/legacy/utils/streams/index.d.ts +++ b/src/legacy/utils/streams/index.d.ts @@ -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(splitChunk: T): Transform; export function createListStream(items: any[]): Readable; export function createReduceStream(reducer: (value: any, chunk: T, enc: string) => T): Transform; -export function createPromiseFromStreams([first, ...rest]: [Readable, ...Writable[]]): Promise; +export function createPromiseFromStreams([first, ...rest]: [Readable, ...Writable[]]): Promise< + T +>; export function createConcatStream(initial: any): Transform; export function createMapStream(fn: (value: T, i: number) => void): Transform; export function createReplaceStream(toReplace: string, replacement: string | Buffer): Transform; diff --git a/src/plugins/testbed/public/plugin.ts b/src/plugins/testbed/public/plugin.ts index d574d2734a4f95..d682acceb4b326 100644 --- a/src/plugins/testbed/public/plugin.ts +++ b/src/plugins/testbed/public/plugin.ts @@ -21,7 +21,7 @@ import { Plugin, PluginSetupContext } from 'kibana/public'; export class TestbedPlugin implements Plugin { public setup(core: PluginSetupContext, deps: {}) { - // tslint:disable-next-line no-console + // eslint-disable-next-line no-console console.log(`Testbed plugin loaded`); } } diff --git a/tasks/config/run.js b/tasks/config/run.js index a521e300a62939..609f164369783d 100644 --- a/tasks/config/run.js +++ b/tasks/config/run.js @@ -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: [ diff --git a/tasks/jenkins.js b/tasks/jenkins.js index 62b0ba0b4ac07a..61fbbad24392d2 100644 --- a/tasks/jenkins.js +++ b/tasks/jenkins.js @@ -24,7 +24,6 @@ module.exports = function (grunt) { grunt.registerTask('jenkins:unit', [ 'run:eslint', - 'run:tslint', 'run:sasslint', 'run:checkTsProjects', 'run:checkCoreApiChanges', diff --git a/tasks/test.js b/tasks/test.js index f82ec7a7fd70c1..9cca61ddbc85f7 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -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', diff --git a/test/functional/apps/console/_console.ts b/test/functional/apps/console/_console.ts index 1fda35f2bf1ae5..92e6021eebf476 100644 --- a/test/functional/apps/console/_console.ts +++ b/test/functional/apps/console/_console.ts @@ -31,7 +31,7 @@ GET _search `.trim(); -// tslint:disable-next-line no-default-export +// eslint-disable-next-line import/no-default-export export default function({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const log = getService('log'); diff --git a/test/functional/apps/visualize/_tsvb_chart.ts b/test/functional/apps/visualize/_tsvb_chart.ts index 65978161a8da4e..c89c5f7d04598b 100644 --- a/test/functional/apps/visualize/_tsvb_chart.ts +++ b/test/functional/apps/visualize/_tsvb_chart.ts @@ -20,7 +20,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; -// tslint:disable-next-line:no-default-export +// eslint-disable-next-line import/no-default-export export default function({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const log = getService('log'); diff --git a/test/functional/apps/visualize/_tsvb_markdown.ts b/test/functional/apps/visualize/_tsvb_markdown.ts index 3e62eba78a528f..f8834f4e6f2bb6 100644 --- a/test/functional/apps/visualize/_tsvb_markdown.ts +++ b/test/functional/apps/visualize/_tsvb_markdown.ts @@ -20,7 +20,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; -// tslint:disable-next-line:no-default-export +// eslint-disable-next-line import/no-default-export export default function({ getPageObjects }: FtrProviderContext) { const { visualBuilder, timePicker } = getPageObjects([ 'visualBuilder', diff --git a/test/functional/apps/visualize/index.ts b/test/functional/apps/visualize/index.ts index fc75dcec6f4f06..a736e91570556f 100644 --- a/test/functional/apps/visualize/index.ts +++ b/test/functional/apps/visualize/index.ts @@ -19,7 +19,7 @@ import { FtrProviderContext } from '../../ftr_provider_context.d'; -// tslint:disable-next-line: no-default-export +// eslint-disable-next-line @typescript-eslint/no-namespace, import/no-default-export export default function({ getService, loadTestFile }: FtrProviderContext) { const browser = getService('browser'); const log = getService('log'); diff --git a/test/types/mocha_decorations.d.ts b/test/types/mocha_decorations.d.ts index 9d9d72784b863d..4645faf3d5fe84 100644 --- a/test/types/mocha_decorations.d.ts +++ b/test/types/mocha_decorations.d.ts @@ -33,7 +33,8 @@ type Tags = | 'ciGroup11' | 'ciGroup12'; -// tslint:disable-next-line:no-namespace We need to use the namespace here to match the Mocha definition +// We need to use the namespace here to match the Mocha definition +// eslint-disable-next-line @typescript-eslint/no-namespace declare module 'mocha' { interface Suite { /** diff --git a/tslint.yaml b/tslint.yaml deleted file mode 100644 index 15d012a677e1de..00000000000000 --- a/tslint.yaml +++ /dev/null @@ -1,75 +0,0 @@ -extends: - - tslint:recommended - - tslint-config-prettier - - -rulesDirectory: - - tslint-plugin-prettier - - src/dev/tslint/rules - - node_modules/tslint-microsoft-contrib - -rules: - prettier: true - object-literal-sort-keys: false - interface-name: false - no-default-export: true - react-a11y-anchors: true - react-a11y-aria-unsupported-elements: true - react-a11y-event-has-role: true - react-a11y-image-button-has-alt: true - react-a11y-img-has-alt: true - react-a11y-input-elements: true - react-a11y-lang: true - react-a11y-meta: true - react-a11y-no-onchange: true - react-a11y-props: true - react-a11y-proptypes: true - react-a11y-required: true - react-a11y-role-has-required-aria-props: true - react-a11y-role-supports-aria-props: true - react-a11y-role: true - react-a11y-tabindex-no-positive: true - react-a11y-titles: true - ban: - - true - - name: [describe, only] - message: No exclusive suites. - - name: [it, only] - message: No exclusive tests. - - name: [test, only] - message: No exclusive tests. - require-license-header: - - true - - |- - /* - * 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. - */ - disallow-license-header: - - true - - |- - /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - module-migration: - - true - - from: expect.js - to: '@kbn/expect' - - from: 'x-pack' - toRelative: 'x-pack' diff --git a/typings/index.d.ts b/typings/index.d.ts index f4ccecec011180..42c62edf805aba 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -19,6 +19,7 @@ declare module '*.html' { const template: string; + // eslint-disable-next-line import/no-default-export export default template; } diff --git a/typings/lodash.topath/index.d.ts b/typings/lodash.topath/index.d.ts index 9bd4b895251d77..3630a13f72c284 100644 --- a/typings/lodash.topath/index.d.ts +++ b/typings/lodash.topath/index.d.ts @@ -17,8 +17,7 @@ * under the License. */ - declare module 'lodash/internal/toPath' { - function toPath(value: string | string[]): string[] + function toPath(value: string | string[]): string[]; export = toPath; } diff --git a/x-pack/common/eui_styled_components/index.ts b/x-pack/common/eui_styled_components/index.ts index 6d5e8a5a326e7c..9d07b540d49743 100644 --- a/x-pack/common/eui_styled_components/index.ts +++ b/x-pack/common/eui_styled_components/index.ts @@ -15,5 +15,6 @@ import { } from './eui_styled_components'; export { css, euiStyled, EuiTheme, EuiThemeProvider, injectGlobal, keyframes, withTheme }; -// tslint:disable-next-line:no-default-export to mimick the styled-components module +// In order to to mimic the styled-components module we need to ignore the following +// eslint-disable-next-line import/no-default-export export default euiStyled; diff --git a/x-pack/plugins/apm/common/idx.ts b/x-pack/plugins/apm/common/idx.ts index 6513f5f86f1dfc..19c4ccf2ddf03a 100644 --- a/x-pack/plugins/apm/common/idx.ts +++ b/x-pack/plugins/apm/common/idx.ts @@ -8,6 +8,7 @@ * DeepRequiredArray * Nested array condition handler */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface interface DeepRequiredArray extends Array> {} /** diff --git a/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx index 5d050331b6c5b0..daf706c66d1c5d 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx @@ -205,7 +205,7 @@ export class WatcherFlyout extends Component< this.addSuccessToast(id); }) .catch(e => { - // tslint:disable-next-line + // eslint-disable-next-line console.error(e); this.addErrorToast(); }); diff --git a/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx index fb3713a9a718e0..2f56a3a11c6bfc 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx @@ -30,7 +30,7 @@ describe('Service Overview -> View', () => { }); // Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769 - /* tslint:disable:no-console */ + /* eslint-disable no-console */ const originalError = console.error; beforeAll(() => { console.error = jest.fn(); diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx index 304453db76ce96..5c8972c51484e4 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx @@ -6,6 +6,9 @@ import React, { Fragment } from 'react'; import styled from 'styled-components'; + +import { EuiSpacer, EuiTitle } from '@elastic/eui'; +import theme from '@elastic/eui/dist/eui_theme_light.json'; import { borderRadius, fontFamilyCode, @@ -14,9 +17,6 @@ import { unit, units } from '../../../../../../../style/variables'; - -import { EuiSpacer, EuiTitle } from '@elastic/eui'; -import theme from '@elastic/eui/dist/eui_theme_light.json'; import { idx } from '../../../../../../../../common/idx'; import { Span } from '../../../../../../../../typings/es_schemas/ui/Span'; diff --git a/x-pack/plugins/apm/public/hooks/useFetcher.integration.test.tsx b/x-pack/plugins/apm/public/hooks/useFetcher.integration.test.tsx index 6d4d0557bc27a0..fac172388d4c81 100644 --- a/x-pack/plugins/apm/public/hooks/useFetcher.integration.test.tsx +++ b/x-pack/plugins/apm/public/hooks/useFetcher.integration.test.tsx @@ -10,7 +10,7 @@ import { delay, tick } from '../utils/testHelpers'; import { useFetcher } from './useFetcher'; // Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769 -/* tslint:disable:no-console */ +/* eslint-disable no-console */ const originalError = console.error; beforeAll(() => { console.error = jest.fn(); diff --git a/x-pack/plugins/apm/public/hooks/useFetcher.test.tsx b/x-pack/plugins/apm/public/hooks/useFetcher.test.tsx index 87722ce3c02755..6d722b128953fc 100644 --- a/x-pack/plugins/apm/public/hooks/useFetcher.test.tsx +++ b/x-pack/plugins/apm/public/hooks/useFetcher.test.tsx @@ -11,7 +11,7 @@ import { useFetcher } from './useFetcher'; afterEach(cleanup); // Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769 -/* tslint:disable:no-console */ +/* eslint-disable no-console */ const originalError = console.error; beforeAll(() => { console.error = jest.fn(); diff --git a/x-pack/plugins/apm/readme.md b/x-pack/plugins/apm/readme.md index 2eb425d0b82660..d82fd0050340c8 100644 --- a/x-pack/plugins/apm/readme.md +++ b/x-pack/plugins/apm/readme.md @@ -26,11 +26,6 @@ yarn prettier "./x-pack/plugins/apm/**/*.{tsx,ts,js}" --write yarn eslint ./x-pack/plugins/apm --fix ``` -### TSLint -``` -yarn tslint ./x-pack/plugins/apm/**/*.{ts,tsx} --fix -``` - ### Ensure everything from master has been backported to 6.x ``` git fetch origin && git checkout 6.x && git diff origin/6.x..origin/master ./plugins/apm | git apply diff --git a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts index 1a44bb7c3d022a..6b83a1dbcceece 100644 --- a/x-pack/plugins/apm/server/lib/helpers/setup_request.ts +++ b/x-pack/plugins/apm/server/lib/helpers/setup_request.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -/* tslint:disable no-console */ +/* eslint-disable no-console */ import { AggregationSearchResponse, ESFilter, diff --git a/x-pack/plugins/apm/server/routes/errors.ts b/x-pack/plugins/apm/server/routes/errors.ts index 7db8ae4e6d84da..b8a30c007be5b7 100644 --- a/x-pack/plugins/apm/server/routes/errors.ts +++ b/x-pack/plugins/apm/server/routes/errors.ts @@ -16,7 +16,7 @@ import { setupRequest } from '../lib/helpers/setup_request'; const ROOT = '/api/apm/services/{serviceName}/errors'; const defaultErrorHandler = (err: Error) => { - // tslint:disable-next-line + // eslint-disable-next-line console.error(err.stack); throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/server/routes/metrics.ts b/x-pack/plugins/apm/server/routes/metrics.ts index f6f0161d00d477..76ba0a40077e44 100644 --- a/x-pack/plugins/apm/server/routes/metrics.ts +++ b/x-pack/plugins/apm/server/routes/metrics.ts @@ -11,7 +11,7 @@ import { setupRequest } from '../lib/helpers/setup_request'; import { getAllMetricsChartData } from '../lib/metrics/get_all_metrics_chart_data'; const defaultErrorHandler = (err: Error) => { - // tslint:disable-next-line + // eslint-disable-next-line console.error(err.stack); throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services.ts index d5402bb7c807ba..07255d41cc88d6 100644 --- a/x-pack/plugins/apm/server/routes/services.ts +++ b/x-pack/plugins/apm/server/routes/services.ts @@ -15,7 +15,7 @@ import { getServices } from '../lib/services/get_services'; const ROOT = '/api/apm/services'; const defaultErrorHandler = (err: Error) => { - // tslint:disable-next-line + // eslint-disable-next-line console.error(err.stack); throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/server/routes/traces.ts b/x-pack/plugins/apm/server/routes/traces.ts index 7677d711f9ec63..81dbf741f925e3 100644 --- a/x-pack/plugins/apm/server/routes/traces.ts +++ b/x-pack/plugins/apm/server/routes/traces.ts @@ -13,7 +13,7 @@ import { getTrace } from '../lib/traces/get_trace'; const ROOT = '/api/apm/traces'; const defaultErrorHandler = (err: Error) => { - // tslint:disable-next-line + // eslint-disable-next-line console.error(err.stack); throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/server/routes/transaction_groups.ts b/x-pack/plugins/apm/server/routes/transaction_groups.ts index 60216b0460f658..74b8f3dc6b58a4 100644 --- a/x-pack/plugins/apm/server/routes/transaction_groups.ts +++ b/x-pack/plugins/apm/server/routes/transaction_groups.ts @@ -14,7 +14,7 @@ import { getDistribution } from '../lib/transactions/distribution'; import { getTopTransactions } from '../lib/transactions/get_top_transactions'; const defaultErrorHandler = (err: Error) => { - // tslint:disable-next-line + // eslint-disable-next-line console.error(err.stack); throw Boom.boomify(err, { statusCode: 400 }); }; diff --git a/x-pack/plugins/apm/typings/global_types.d.ts b/x-pack/plugins/apm/typings/global_types.d.ts index ba1e9e998727fc..fdc9c38897c62b 100644 --- a/x-pack/plugins/apm/typings/global_types.d.ts +++ b/x-pack/plugins/apm/typings/global_types.d.ts @@ -4,10 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -// allow JSON files to be imported directly without TSLint errors +// allow JSON files to be imported directly without lint errors // see: https://github.com/palantir/tslint/issues/1264#issuecomment-228433367 // and: https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#arbitrary-expressions-are-forbidden-in-export-assignments-in-ambient-contexts declare module '*.json' { const json: any; + // eslint-disable-next-line import/no-default-export export default json; } diff --git a/x-pack/plugins/apm/typings/numeral.d.ts b/x-pack/plugins/apm/typings/numeral.d.ts index da2d84662a09fa..a8ac5081ed28db 100644 --- a/x-pack/plugins/apm/typings/numeral.d.ts +++ b/x-pack/plugins/apm/typings/numeral.d.ts @@ -10,6 +10,7 @@ interface Numeral { unformat: (pattern: string) => number; } +// eslint-disable-next-line no-var declare var numeral: Numeral; declare module '@elastic/numeral' { diff --git a/x-pack/plugins/beats_management/common/io_ts_types.ts b/x-pack/plugins/beats_management/common/io_ts_types.ts index bc298710c72b16..51ab838ddd6c2b 100644 --- a/x-pack/plugins/beats_management/common/io_ts_types.ts +++ b/x-pack/plugins/beats_management/common/io_ts_types.ts @@ -7,7 +7,7 @@ import * as t from 'io-ts'; export class DateFromStringType extends t.Type { - // tslint:disable-next-line + // eslint-disable-next-line public readonly _tag: 'DateFromISOStringType' = 'DateFromISOStringType'; constructor() { super( @@ -27,7 +27,7 @@ export class DateFromStringType extends t.Type { ); } } -// tslint:disable-next-line +// eslint-disable-next-line export interface DateFromString extends DateFromStringType {} export const DateFromString: DateFromString = new DateFromStringType(); diff --git a/x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx b/x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx index 92707d3a1f3522..e81b0f4e5e657d 100644 --- a/x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx +++ b/x-pack/plugins/beats_management/public/components/tag/tag_edit.tsx @@ -147,7 +147,7 @@ export class TagEdit extends React.PureComponent {
{ if (action === 'delete') { this.props.onConfigRemoved(block); diff --git a/x-pack/plugins/beats_management/public/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/beats_management/public/lib/adapters/framework/adapter_types.ts index 0d2d21e42507ba..baadb812614827 100644 --- a/x-pack/plugins/beats_management/public/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/beats_management/public/lib/adapters/framework/adapter_types.ts @@ -3,6 +3,9 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + +/* eslint-disable @typescript-eslint/no-empty-interface */ + import * as t from 'io-ts'; import { LICENSES } from './../../../../common/constants/security'; diff --git a/x-pack/plugins/beats_management/public/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/beats_management/public/lib/adapters/framework/kibana_framework_adapter.ts index f291988605f146..e2e00a4dea8192 100644 --- a/x-pack/plugins/beats_management/public/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/beats_management/public/lib/adapters/framework/kibana_framework_adapter.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +/* eslint-disable max-classes-per-file */ import { IScope } from 'angular'; import { PathReporter } from 'io-ts/lib/PathReporter'; import * as React from 'react'; @@ -130,7 +131,7 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
`, - // tslint:disable-next-line: max-classes-per-file + // eslint-disable-next-line max-classes-per-file controller: ($scope: any, $route: any) => { try { $scope.$$postDigest(() => { @@ -220,7 +221,6 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter { } } -// tslint:disable-next-line: max-classes-per-file class KibanaAdapterServiceProvider { public serviceRefs: KibanaAdapterServiceRefs | null = null; public bufferedCalls: Array> = []; diff --git a/x-pack/plugins/beats_management/public/lib/types.ts b/x-pack/plugins/beats_management/public/lib/types.ts index 7887d7eadc3db2..bef611733720ae 100644 --- a/x-pack/plugins/beats_management/public/lib/types.ts +++ b/x-pack/plugins/beats_management/public/lib/types.ts @@ -22,9 +22,7 @@ export interface FrontendLibs { configBlocks: ConfigBlocksLib; } -export interface FramworkAdapterConstructable { - new (uiModule: IModule): FrameworkAdapter; -} +export type FramworkAdapterConstructable = new (uiModule: IModule) => FrameworkAdapter; // FIXME: replace AxiosRequestConfig with something more defined export type RequestConfig = AxiosRequestConfig; diff --git a/x-pack/plugins/beats_management/public/pages/tag/edit.tsx b/x-pack/plugins/beats_management/public/pages/tag/edit.tsx index 87a9b72585084d..cb2cb771956e7f 100644 --- a/x-pack/plugins/beats_management/public/pages/tag/edit.tsx +++ b/x-pack/plugins/beats_management/public/pages/tag/edit.tsx @@ -103,7 +103,7 @@ class TagEditPageComponent extends React.PureComponent< this.props.libs.configBlocks .upsert([{ ...block, tag: this.state.tag.id }]) .catch((e: any) => { - // tslint:disable-next-line + // eslint-disable-next-line console.error('Error upseting config block', e); }) .then(() => { @@ -117,7 +117,7 @@ class TagEditPageComponent extends React.PureComponent< alert( 'Error removing block, please check your browsers console logs for more details' ); - // tslint:disable-next-line + // eslint-disable-next-line console.error(`Error removing block ${block.id}`, e); }) .then(() => { diff --git a/x-pack/plugins/beats_management/scripts/fake_env.ts b/x-pack/plugins/beats_management/scripts/fake_env.ts index ad092d3c252bc4..e2e31a218943a0 100644 --- a/x-pack/plugins/beats_management/scripts/fake_env.ts +++ b/x-pack/plugins/beats_management/scripts/fake_env.ts @@ -46,7 +46,7 @@ const enroll = async (kibanaURL: string, token: string) => { (error: any, response: any, body: any) => { const res = JSON.parse(body); if (res.message) { - // tslint:disable-next-line + // eslint-disable-next-line console.log(res.message); } } @@ -61,7 +61,7 @@ const start = async ( ) => { try { const libs = compose(kibanaURL); - // tslint:disable-next-line + // eslint-disable-next-line console.error(`Enrolling ${numberOfBeats} fake beats...`); const enrollmentTokens = await libs.tokens.createEnrollmentTokens(numberOfBeats); @@ -81,11 +81,11 @@ const start = async ( process.stdout.write('\n'); await sleep(2000); - // tslint:disable-next-line + // eslint-disable-next-line console.error(`${numberOfBeats} fake beats are enrolled`); const beats = await libs.beats.getAll(); - // tslint:disable-next-line + // eslint-disable-next-line console.error(`Creating tags, configs, and assigning them...`); process.stdout.write(`creating tags/configs for beat... 0 of ${numberOfBeats}`); count = 0; @@ -137,16 +137,16 @@ Duo Reges: constructio interrete. Itaque his sapiens semper vacabit.`.substring( } } catch (e) { if (e.response && e.response.data && e.response.message) { - // tslint:disable-next-line + // eslint-disable-next-line console.error(e.response.data.message); } else if (e.response && e.response.data && e.response.reason) { - // tslint:disable-next-line + // eslint-disable-next-line console.error(e.response.data.reason); } else if (e.code) { - // tslint:disable-next-line + // eslint-disable-next-line console.error(e.code); } else { - // tslint:disable-next-line + // eslint-disable-next-line console.error(e); } } diff --git a/x-pack/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.ts b/x-pack/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.ts index 05e61e80c3d9f0..62759ce0f5215e 100644 --- a/x-pack/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.ts +++ b/x-pack/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.ts @@ -13,7 +13,7 @@ export class ElasticsearchBeatEventsAdapter implements BeatEventsAdapter { // @ts-ignore constructor(private readonly database: DatabaseAdapter) {} - // tslint:disable-next-line + // eslint-disable-next-line public bulkInsert = async (user: FrameworkUser, beatId: string, events: BeatEvent[]) => { // await this.database.putTemplate(INDEX_NAMES.EVENTS_TODAY, beatsIndexTemplate); }; diff --git a/x-pack/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts index b428e21c1fcc83..1a875ea0e5c4c6 100644 --- a/x-pack/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts @@ -3,6 +3,9 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + +/* eslint-disable @typescript-eslint/no-empty-interface */ + import { Lifecycle, ResponseToolkit } from 'hapi'; import * as t from 'io-ts'; import { LicenseType } from '../../../../common/constants/security'; diff --git a/x-pack/plugins/beats_management/server/lib/beat_events.ts b/x-pack/plugins/beats_management/server/lib/beat_events.ts index c8a7e1b17baf57..9a3047a2f76e3a 100644 --- a/x-pack/plugins/beats_management/server/lib/beat_events.ts +++ b/x-pack/plugins/beats_management/server/lib/beat_events.ts @@ -30,7 +30,7 @@ export class BeatEventsLib { }, }) .catch(e => { - // tslint:disable-next-line + // eslint-disable-next-line console.error('Error inserting event into beats log.', e); }); } @@ -48,7 +48,7 @@ export class BeatEventsLib { }, }) .catch(e => { - // tslint:disable-next-line + // eslint-disable-next-line console.error('Error inserting event into beats log.', e); }); } diff --git a/x-pack/plugins/beats_management/server/lib/beats.ts b/x-pack/plugins/beats_management/server/lib/beats.ts index 4f78cc2a294fdd..ca1e07bfab573e 100644 --- a/x-pack/plugins/beats_management/server/lib/beats.ts +++ b/x-pack/plugins/beats_management/server/lib/beats.ts @@ -95,6 +95,7 @@ export class CMBeatsDomain { beat: Partial ): Promise<{ status: string; accessToken?: string }> { const { token, expires_on } = await this.tokens.getEnrollmentToken(enrollmentToken); + // eslint-disable-next-line @typescript-eslint/camelcase if (expires_on && moment(expires_on).isBefore(moment())) { return { status: BeatEnrollmentStatus.ExpiredEnrollmentToken }; } diff --git a/x-pack/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts b/x-pack/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts index 73a16da179d2fb..bb0376ab87d290 100644 --- a/x-pack/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts +++ b/x-pack/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts @@ -54,9 +54,7 @@ describe('assign_tags_to_beats', () => { expect(result.results).toEqual([{ success: true, result: { message: 'updated' } }]); - let beat; - - beat = await serverLibs.beats.getById( + const beat = await serverLibs.beats.getById( { kind: 'internal', }, diff --git a/x-pack/plugins/beats_management/server/rest_api/beats/configuration.ts b/x-pack/plugins/beats_management/server/rest_api/beats/configuration.ts index aceba95461a797..f279a51b2bc1b5 100644 --- a/x-pack/plugins/beats_management/server/rest_api/beats/configuration.ts +++ b/x-pack/plugins/beats_management/server/rest_api/beats/configuration.ts @@ -26,9 +26,8 @@ export const createGetBeatConfigurationRoute = (libs: CMServerLibs) => ({ const beatId = request.params.beatId; const accessToken = request.headers['kbn-beats-access-token']; - let beat; let configurationBlocks: ConfigurationBlock[]; - beat = await libs.beats.getById(libs.framework.internalUser, beatId); + const beat = await libs.beats.getById(libs.framework.internalUser, beatId); if (beat === null) { return { error: { message: `Beat "${beatId}" not found`, code: 404 }, success: false }; } diff --git a/x-pack/plugins/beats_management/server/rest_api/tags/assignable.ts b/x-pack/plugins/beats_management/server/rest_api/tags/assignable.ts index 5cb4d2c445e417..8495d648b85d05 100644 --- a/x-pack/plugins/beats_management/server/rest_api/tags/assignable.ts +++ b/x-pack/plugins/beats_management/server/rest_api/tags/assignable.ts @@ -20,9 +20,8 @@ export const createAssignableTagsRoute = (libs: CMServerLibs) => ({ const beatIdString: string = request.params.beatIds; const beatIds = beatIdString.split(',').filter((id: string) => id.length > 0); - let tags: BeatTag[]; const beats = await libs.beats.getByIds(request.user, beatIds); - tags = await libs.tags.getNonConflictingTags( + const tags = await libs.tags.getNonConflictingTags( request.user, flatten(beats.map(beat => beat.tags)) ); diff --git a/x-pack/plugins/beats_management/server/rest_api/tags/delete.ts b/x-pack/plugins/beats_management/server/rest_api/tags/delete.ts index ab94d31296936b..3e65f271c0fb00 100644 --- a/x-pack/plugins/beats_management/server/rest_api/tags/delete.ts +++ b/x-pack/plugins/beats_management/server/rest_api/tags/delete.ts @@ -18,8 +18,7 @@ export const createDeleteTagsWithIdsRoute = (libs: CMServerLibs) => ({ const tagIdString: string = request.params.tagIds; const tagIds = tagIdString.split(',').filter((id: string) => id.length > 0); - let success: boolean; - success = await libs.tags.delete(request.user, tagIds); + const success = await libs.tags.delete(request.user, tagIds); return { results: tagIds.map(() => ({ diff --git a/x-pack/plugins/beats_management/server/rest_api/tags/get.ts b/x-pack/plugins/beats_management/server/rest_api/tags/get.ts index c20c576f4672d2..37f8e1169fa6ca 100644 --- a/x-pack/plugins/beats_management/server/rest_api/tags/get.ts +++ b/x-pack/plugins/beats_management/server/rest_api/tags/get.ts @@ -19,8 +19,7 @@ export const createGetTagsWithIdsRoute = (libs: CMServerLibs) => ({ const tagIdString: string = request.params.tagIds; const tagIds = tagIdString.split(',').filter((id: string) => id.length > 0); - let tags: BeatTag[]; - tags = await libs.tags.getWithIds(request.user, tagIds); + const tags = await libs.tags.getWithIds(request.user, tagIds); return { items: tags, diff --git a/x-pack/plugins/beats_management/server/rest_api/tags/list.ts b/x-pack/plugins/beats_management/server/rest_api/tags/list.ts index 1025728d55eb6e..eb5570273960f0 100644 --- a/x-pack/plugins/beats_management/server/rest_api/tags/list.ts +++ b/x-pack/plugins/beats_management/server/rest_api/tags/list.ts @@ -27,8 +27,7 @@ export const createListTagsRoute = (libs: CMServerLibs) => ({ }), }, handler: async (request: FrameworkRequest): Promise> => { - let tags: BeatTag[]; - tags = await libs.tags.getAll( + const tags = await libs.tags.getAll( request.user, request.query && request.query.ESQuery ? JSON.parse(request.query.ESQuery) : undefined ); diff --git a/x-pack/plugins/beats_management/types/formsy.d.ts b/x-pack/plugins/beats_management/types/formsy.d.ts index f153e80d13e53a..fbe81194a7d6b4 100644 --- a/x-pack/plugins/beats_management/types/formsy.d.ts +++ b/x-pack/plugins/beats_management/types/formsy.d.ts @@ -24,6 +24,7 @@ declare module 'formsy-react' { showRequired(): boolean; } + // eslint-disable-next-line import/no-default-export export default Formsy; export type FormData = { [fieldName in keyof FormShape]: string }; export type FieldValue = string | null | undefined; diff --git a/x-pack/plugins/canvas/public/components/color_manager/__examples__/color_manager.examples.tsx b/x-pack/plugins/canvas/public/components/color_manager/__examples__/color_manager.examples.tsx index 9b87c596b1a798..a33e14a0292fb3 100644 --- a/x-pack/plugins/canvas/public/components/color_manager/__examples__/color_manager.examples.tsx +++ b/x-pack/plugins/canvas/public/components/color_manager/__examples__/color_manager.examples.tsx @@ -27,7 +27,7 @@ class Interactive extends React.Component<{}, { hasButtons: boolean; value: stri />