From 8257078086193caceb5b35a2f2bfa1fab93536b5 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Tue, 2 Apr 2019 09:38:07 +0200 Subject: [PATCH] use eslint-import-plugin/no-export-default instead of custom rule (#34285) (#34332) --- .eslintrc.js | 2 +- packages/kbn-eslint-plugin-eslint/index.js | 1 - .../rules/no_default_export.js | 29 ------------------- .../core_plugins/kibana/public/.eslintrc | 2 +- .../field_formats/__tests__/_conformance.js | 2 +- src/legacy/ui/public/.eslintrc | 2 +- .../hierarchical/_collect_branch.js | 2 +- .../agg_types/__tests__/agg_param_writer.js | 2 +- .../agg_types/__tests__/param_types/_json.js | 2 +- .../__tests__/param_types/_string.js | 2 +- .../__tests__/utils/_stub_agg_params.js | 2 +- src/legacy/ui/public/chrome/api/apps.js | 2 +- src/legacy/ui/public/chrome/api/template.js | 2 +- src/legacy/ui/public/chrome/index.js | 2 +- .../route_setup/load_default.js | 2 +- src/legacy/ui/public/routes/index.js | 2 +- src/legacy/ui/public/routes/route_manager.js | 2 +- src/legacy/ui/public/utils/ipv4_address.ts | 2 +- src/legacy/ui/public/utils/mapping_setup.js | 2 +- src/legacy/ui/public/vis/agg_config_result.js | 2 +- src/legacy/ui/public/vislib/index.js | 2 +- .../layout/splits/gauge_chart/chart_split.js | 2 +- .../splits/gauge_chart/chart_title_split.js | 2 +- x-pack/test/functional/config.js | 2 +- 24 files changed, 22 insertions(+), 52 deletions(-) delete mode 100644 packages/kbn-eslint-plugin-eslint/rules/no_default_export.js diff --git a/.eslintrc.js b/.eslintrc.js index b49e073e1fd2d..50f765bb6a4b1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -129,7 +129,7 @@ module.exports = { { files: ['x-pack/test/functional/apps/**/*', 'x-pack/plugins/apm/**/*'], rules: { - '@kbn/eslint/no-default-export': 'off', + 'import/no-default-export': 'off', 'import/no-named-as-default': 'off', }, }, diff --git a/packages/kbn-eslint-plugin-eslint/index.js b/packages/kbn-eslint-plugin-eslint/index.js index 3e1fba9e5dcd4..870b1cccd5c61 100644 --- a/packages/kbn-eslint-plugin-eslint/index.js +++ b/packages/kbn-eslint-plugin-eslint/index.js @@ -21,7 +21,6 @@ module.exports = { rules: { 'require-license-header': require('./rules/require_license_header'), 'disallow-license-headers': require('./rules/disallow_license_headers'), - 'no-default-export': require('./rules/no_default_export'), 'no-restricted-paths': require('./rules/no_restricted_paths'), module_migration: require('./rules/module_migration'), }, diff --git a/packages/kbn-eslint-plugin-eslint/rules/no_default_export.js b/packages/kbn-eslint-plugin-eslint/rules/no_default_export.js deleted file mode 100644 index 660b9f8bb8b3c..0000000000000 --- a/packages/kbn-eslint-plugin-eslint/rules/no_default_export.js +++ /dev/null @@ -1,29 +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. - */ - -module.exports = { - meta: { - schema: [], - }, - create: context => ({ - ExportDefaultDeclaration: node => { - context.report(node, 'Default exports not allowed.'); - }, - }), -}; diff --git a/src/legacy/core_plugins/kibana/public/.eslintrc b/src/legacy/core_plugins/kibana/public/.eslintrc index 95e3757201989..cc44af915ba25 100644 --- a/src/legacy/core_plugins/kibana/public/.eslintrc +++ b/src/legacy/core_plugins/kibana/public/.eslintrc @@ -1,3 +1,3 @@ rules: no-console: 2 - '@kbn/eslint/no-default-export': error + 'import/no-default-export': error diff --git a/src/legacy/core_plugins/kibana/public/field_formats/__tests__/_conformance.js b/src/legacy/core_plugins/kibana/public/field_formats/__tests__/_conformance.js index e84d5e217cf7c..c62c90dbe4c14 100644 --- a/src/legacy/core_plugins/kibana/public/field_formats/__tests__/_conformance.js +++ b/src/legacy/core_plugins/kibana/public/field_formats/__tests__/_conformance.js @@ -43,7 +43,7 @@ const formatIds = [ 'static_lookup' ]; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default describe('conformance', function () { const getConfig = (...args) => config.get(...args); diff --git a/src/legacy/ui/public/.eslintrc b/src/legacy/ui/public/.eslintrc index 95e3757201989..cc44af915ba25 100644 --- a/src/legacy/ui/public/.eslintrc +++ b/src/legacy/ui/public/.eslintrc @@ -1,3 +1,3 @@ rules: no-console: 2 - '@kbn/eslint/no-default-export': error + 'import/no-default-export': error diff --git a/src/legacy/ui/public/agg_response/hierarchical/_collect_branch.js b/src/legacy/ui/public/agg_response/hierarchical/_collect_branch.js index 5339d453a7770..3048208af3135 100644 --- a/src/legacy/ui/public/agg_response/hierarchical/_collect_branch.js +++ b/src/legacy/ui/public/agg_response/hierarchical/_collect_branch.js @@ -17,7 +17,7 @@ * under the License. */ -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function (leaf) { // walk up the branch for each parent function walk(item, memo) { diff --git a/src/legacy/ui/public/agg_types/__tests__/agg_param_writer.js b/src/legacy/ui/public/agg_types/__tests__/agg_param_writer.js index e162f59881376..8d4af8742f61c 100644 --- a/src/legacy/ui/public/agg_types/__tests__/agg_param_writer.js +++ b/src/legacy/ui/public/agg_types/__tests__/agg_param_writer.js @@ -22,7 +22,7 @@ import { VisProvider } from '../../vis'; import { aggTypes } from '..'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function AggParamWriterHelper(Private) { const Vis = Private(VisProvider); const stubbedLogstashIndexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); diff --git a/src/legacy/ui/public/agg_types/__tests__/param_types/_json.js b/src/legacy/ui/public/agg_types/__tests__/param_types/_json.js index efac833cb061b..1876593f52956 100644 --- a/src/legacy/ui/public/agg_types/__tests__/param_types/_json.js +++ b/src/legacy/ui/public/agg_types/__tests__/param_types/_json.js @@ -22,7 +22,7 @@ import expect from '@kbn/expect'; import { BaseParamType } from '../../param_types/base'; import { JsonParamType } from '../../param_types/json'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default describe('JSON', function () { const paramName = 'json_test'; let aggParam; diff --git a/src/legacy/ui/public/agg_types/__tests__/param_types/_string.js b/src/legacy/ui/public/agg_types/__tests__/param_types/_string.js index 261b974279802..10c965a53bab5 100644 --- a/src/legacy/ui/public/agg_types/__tests__/param_types/_string.js +++ b/src/legacy/ui/public/agg_types/__tests__/param_types/_string.js @@ -22,7 +22,7 @@ import expect from '@kbn/expect'; import { BaseParamType } from '../../param_types/base'; import { StringParamType } from '../../param_types/string'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default describe('String', function () { const paramName = 'json_test'; let aggParam; diff --git a/src/legacy/ui/public/agg_types/__tests__/utils/_stub_agg_params.js b/src/legacy/ui/public/agg_types/__tests__/utils/_stub_agg_params.js index a9c46b09b5370..f30572bcc0ed5 100644 --- a/src/legacy/ui/public/agg_types/__tests__/utils/_stub_agg_params.js +++ b/src/legacy/ui/public/agg_types/__tests__/utils/_stub_agg_params.js @@ -46,7 +46,7 @@ function ParamClassStub(parent, body) { * @param {PrivateLoader} Private - The private module loader, inject by passing this function to ngMock.inject() * @return {undefined} */ -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function stubParamClasses(Private) { const BaseAggParam = Private.stub( BaseParamType, diff --git a/src/legacy/ui/public/chrome/api/apps.js b/src/legacy/ui/public/chrome/api/apps.js index 7779b9612b63e..fa41e58a2a644 100644 --- a/src/legacy/ui/public/chrome/api/apps.js +++ b/src/legacy/ui/public/chrome/api/apps.js @@ -20,7 +20,7 @@ import { clone, get } from 'lodash'; import { resolve } from 'url'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function (chrome, internals) { if (get(internals, 'app.navLink.url')) { diff --git a/src/legacy/ui/public/chrome/api/template.js b/src/legacy/ui/public/chrome/api/template.js index 58281c1af6c9d..632d2ecb57aa9 100644 --- a/src/legacy/ui/public/chrome/api/template.js +++ b/src/legacy/ui/public/chrome/api/template.js @@ -17,7 +17,7 @@ * under the License. */ -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function (chrome, internals) { /** diff --git a/src/legacy/ui/public/chrome/index.js b/src/legacy/ui/public/chrome/index.js index a322485b25513..3c6c3d2e74143 100644 --- a/src/legacy/ui/public/chrome/index.js +++ b/src/legacy/ui/public/chrome/index.js @@ -19,5 +19,5 @@ import { chrome } from './chrome'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default chrome; diff --git a/src/legacy/ui/public/index_patterns/route_setup/load_default.js b/src/legacy/ui/public/index_patterns/route_setup/load_default.js index 669b33d731983..83c737332b8e9 100644 --- a/src/legacy/ui/public/index_patterns/route_setup/load_default.js +++ b/src/legacy/ui/public/index_patterns/route_setup/load_default.js @@ -59,7 +59,7 @@ function displayBanner() { }, 15000); } -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function (opts) { opts = opts || {}; const whenMissingRedirectTo = opts.whenMissingRedirectTo || null; diff --git a/src/legacy/ui/public/routes/index.js b/src/legacy/ui/public/routes/index.js index 74e2613c66449..9c826ebee1230 100644 --- a/src/legacy/ui/public/routes/index.js +++ b/src/legacy/ui/public/routes/index.js @@ -19,5 +19,5 @@ import { uiRoutes } from './routes'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default uiRoutes; diff --git a/src/legacy/ui/public/routes/route_manager.js b/src/legacy/ui/public/routes/route_manager.js index 6cedf775cf576..ba48984bb45b9 100644 --- a/src/legacy/ui/public/routes/route_manager.js +++ b/src/legacy/ui/public/routes/route_manager.js @@ -23,7 +23,7 @@ import { wrapRouteWithPrep } from './wrap_route_with_prep'; import { RouteSetupManager } from './route_setup_manager'; import { parsePathToBreadcrumbs } from './breadcrumbs'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function RouteManager() { const self = this; const setup = new RouteSetupManager(); diff --git a/src/legacy/ui/public/utils/ipv4_address.ts b/src/legacy/ui/public/utils/ipv4_address.ts index 5268d1ad97d24..533f2ba6275f0 100644 --- a/src/legacy/ui/public/utils/ipv4_address.ts +++ b/src/legacy/ui/public/utils/ipv4_address.ts @@ -30,7 +30,7 @@ function isIntegerInRange(integer: number, min: number, max: number) { ); } -// eslint-disable-next-line @kbn/eslint/no-default-export +// 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/mapping_setup.js b/src/legacy/ui/public/utils/mapping_setup.js index d02c6ea686b03..b0e123fff94d5 100644 --- a/src/legacy/ui/public/utils/mapping_setup.js +++ b/src/legacy/ui/public/utils/mapping_setup.js @@ -20,7 +20,7 @@ import angular from 'angular'; import _ from 'lodash'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function MappingSetupService() { const mappingSetup = this; diff --git a/src/legacy/ui/public/vis/agg_config_result.js b/src/legacy/ui/public/vis/agg_config_result.js index f82c12585753a..05870d70d26a3 100644 --- a/src/legacy/ui/public/vis/agg_config_result.js +++ b/src/legacy/ui/public/vis/agg_config_result.js @@ -19,7 +19,7 @@ import chrome from '../chrome'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function AggConfigResult(aggConfig, parent, value, key, filters) { this.key = key; this.value = value; diff --git a/src/legacy/ui/public/vislib/index.js b/src/legacy/ui/public/vislib/index.js index 515e5fc9da7f1..b2559c085aeab 100644 --- a/src/legacy/ui/public/vislib/index.js +++ b/src/legacy/ui/public/vislib/index.js @@ -19,5 +19,5 @@ import { VislibProvider } from './vislib'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default VislibProvider; diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js b/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js index 8e87a8be0b52c..f892043ec647f 100644 --- a/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js +++ b/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js @@ -19,7 +19,7 @@ import d3 from 'd3'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function ChartSplitFactory() { /* diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js b/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js index 331a5a60ec4fd..2defc10b0de39 100644 --- a/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js +++ b/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js @@ -19,7 +19,7 @@ import d3 from 'd3'; -// eslint-disable-next-line @kbn/eslint/no-default-export +// eslint-disable-next-line import/no-default-export export default function ChartTitleSplitFactory() { /* diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 82270b7ac00d5..f6326de4d42a1 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -/* eslint-disable @kbn/eslint/no-default-export */ +/* eslint-disable import/no-default-export */ import { resolve } from 'path';