mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Introduce a custom kibana estlint rule for no default exports Turn it on only at the level of /kibana/src/core_plugins/public/ for now, just to keep the PR sizes manageable. * Don't call functions directly on the import * Create a packages dir and move the custom rule in there * Remove copied package.json portions, use minimal info necessary
This commit is contained in:
parent
3c4cb1faf2
commit
76671175cd
32 changed files with 58 additions and 44 deletions
|
@ -217,6 +217,7 @@
|
|||
"eslint": "3.11.1",
|
||||
"eslint-plugin-babel": "4.0.0",
|
||||
"eslint-plugin-jest": "19.0.1",
|
||||
"eslint-plugin-kibana-custom": "file:packages/custom-eslint-rules",
|
||||
"eslint-plugin-mocha": "4.7.0",
|
||||
"eslint-plugin-react": "6.10.3",
|
||||
"event-stream": "3.3.2",
|
||||
|
|
7
packages/custom-eslint-rules/index.js
Normal file
7
packages/custom-eslint-rules/index.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports.rules = {
|
||||
'no-default-export': context => ({
|
||||
ExportDefaultDeclaration: (node) => {
|
||||
context.report(node, 'Default exports not allowed.');
|
||||
}
|
||||
})
|
||||
};
|
5
packages/custom-eslint-rules/package.json
Normal file
5
packages/custom-eslint-rules/package.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "eslint-plugin-kibana-custom",
|
||||
"version": "1.0.0",
|
||||
"description": "Custom ESLint rules for Kibana"
|
||||
}
|
|
@ -1,2 +1,7 @@
|
|||
|
||||
plugins: [
|
||||
'kibana-custom'
|
||||
]
|
||||
rules:
|
||||
no-console: 2
|
||||
kibana-custom/no-default-export: error
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'plugins/kibana/dashboard/panel/get_object_loaders_for_dashboard';
|
|||
import FilterManagerProvider from 'ui/filter_manager';
|
||||
import uiModules from 'ui/modules';
|
||||
import panelTemplate from 'plugins/kibana/dashboard/panel/panel.html';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
import { getPersistedStateId } from 'plugins/kibana/dashboard/panel/panel_state';
|
||||
import { loadSavedObject } from 'plugins/kibana/dashboard/panel/load_saved_object';
|
||||
import { DashboardViewMode } from '../dashboard_view_mode';
|
||||
|
@ -15,7 +16,7 @@ uiModules
|
|||
.directive('dashboardPanel', function (savedVisualizations, savedSearches, Notifier, Private, $injector, getObjectLoadersForDashboard) {
|
||||
const filterManager = Private(FilterManagerProvider);
|
||||
|
||||
const services = require('plugins/kibana/management/saved_object_registry').all().map(function (serviceObj) {
|
||||
const services = savedObjectManagementRegistry.all().map(function (serviceObj) {
|
||||
const service = $injector.get(serviceObj.service);
|
||||
return {
|
||||
type: service.type,
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import 'plugins/kibana/dashboard/saved_dashboard/saved_dashboard';
|
||||
import uiModules from 'ui/modules';
|
||||
import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
|
||||
const module = uiModules.get('app/dashboard');
|
||||
|
||||
// bring in the factory
|
||||
|
||||
|
||||
// Register this service with the saved object registry so it can be
|
||||
// edited by the object editor.
|
||||
require('plugins/kibana/management/saved_object_registry').register({
|
||||
savedObjectManagementRegistry.register({
|
||||
service: 'savedDashboards',
|
||||
title: 'dashboards'
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import ngMock from 'ng_mock';
|
||||
import fieldCalculator from 'plugins/kibana/discover/components/field_chooser/lib/field_calculator';
|
||||
import { fieldCalculator } from 'plugins/kibana/discover/components/field_chooser/lib/field_calculator';
|
||||
import expect from 'expect.js';
|
||||
import 'ui/private';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'angular-ui-select';
|
|||
import _ from 'lodash';
|
||||
import $ from 'jquery';
|
||||
import rison from 'rison-node';
|
||||
import fieldCalculator from 'plugins/kibana/discover/components/field_chooser/lib/field_calculator';
|
||||
import { fieldCalculator } from 'plugins/kibana/discover/components/field_chooser/lib/field_calculator';
|
||||
import IndexPatternsFieldListProvider from 'ui/index_patterns/_field_list';
|
||||
import uiModules from 'ui/modules';
|
||||
import fieldChooserTemplate from 'plugins/kibana/discover/components/field_chooser/field_chooser.html';
|
||||
|
|
|
@ -94,7 +94,7 @@ function _groupValues(allValues, params) {
|
|||
return groups;
|
||||
}
|
||||
|
||||
export default {
|
||||
export const fieldCalculator = {
|
||||
_groupValues: _groupValues,
|
||||
_countMissing: _countMissing,
|
||||
getFieldValues: getFieldValues,
|
||||
|
|
|
@ -7,6 +7,6 @@ import 'plugins/kibana/discover/controllers/discover';
|
|||
import 'plugins/kibana/discover/styles/main.less';
|
||||
import 'ui/doc_table/components/table_row';
|
||||
import savedObjectRegistry from 'ui/saved_objects/saved_object_registry';
|
||||
import savedSearchProvider from 'plugins/kibana/discover/saved_searches/saved_search_register';
|
||||
import { savedSearchProvider } from 'plugins/kibana/discover/saved_searches/saved_search_register';
|
||||
|
||||
savedObjectRegistry.register(savedSearchProvider);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export default function savedSearchObjectFn(savedSearches) {
|
||||
export function savedSearchProvider(savedSearches) {
|
||||
return savedSearches;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@ import 'plugins/kibana/discover/saved_searches/_saved_search';
|
|||
import 'ui/notify';
|
||||
import uiModules from 'ui/modules';
|
||||
import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
const module = uiModules.get('discover/saved_searches', [
|
||||
'kibana/notify'
|
||||
]);
|
||||
|
||||
// Register this service with the saved object registry so it can be
|
||||
// edited by the object editor.
|
||||
require('plugins/kibana/management/saved_object_registry').register({
|
||||
savedObjectManagementRegistry.register({
|
||||
service: 'savedSearches',
|
||||
title: 'searches'
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
const registry = [];
|
||||
export default {
|
||||
export const savedObjectManagementRegistry = {
|
||||
register: function (service) {
|
||||
registry.push(service);
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ import _ from 'lodash';
|
|||
import { IndexPatternMissingIndices } from 'ui/errors';
|
||||
import 'ui/directives/validate_index_name';
|
||||
import 'ui/directives/auto_select_if_only_one';
|
||||
import RefreshKibanaIndex from 'plugins/kibana/management/sections/indices/_refresh_kibana_index';
|
||||
import { RefreshKibanaIndex } from 'plugins/kibana/management/sections/indices/_refresh_kibana_index';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiModules from 'ui/modules';
|
||||
import createTemplate from 'plugins/kibana/management/sections/indices/_create.html';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
export default function (indexPattern) {
|
||||
export function dateScripts(indexPattern) {
|
||||
const dateScripts = {};
|
||||
const scripts = {
|
||||
__dayOfMonth: 'dayOfMonth',
|
||||
|
|
|
@ -3,9 +3,9 @@ import 'plugins/kibana/management/sections/indices/_indexed_fields';
|
|||
import 'plugins/kibana/management/sections/indices/_scripted_fields';
|
||||
import 'plugins/kibana/management/sections/indices/source_filters/source_filters';
|
||||
import 'plugins/kibana/management/sections/indices/_index_header';
|
||||
import RefreshKibanaIndex from 'plugins/kibana/management/sections/indices/_refresh_kibana_index';
|
||||
import { RefreshKibanaIndex } from 'plugins/kibana/management/sections/indices/_refresh_kibana_index';
|
||||
import UrlProvider from 'ui/url';
|
||||
import IndicesEditSectionsProvider from 'plugins/kibana/management/sections/indices/_edit_sections';
|
||||
import { IndicesEditSectionsProvider } from 'plugins/kibana/management/sections/indices/_edit_sections';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiModules from 'ui/modules';
|
||||
import editTemplate from 'plugins/kibana/management/sections/indices/_edit.html';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
export default function GetFieldTypes() {
|
||||
|
||||
export function IndicesEditSectionsProvider() {
|
||||
|
||||
return function (indexPattern) {
|
||||
const fieldCount = _.countBy(indexPattern.fields, function (field) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default function RefreshKibanaIndexFn(esAdmin, kbnIndex) {
|
||||
export function RefreshKibanaIndex(esAdmin, kbnIndex) {
|
||||
return function () {
|
||||
return esAdmin.indices.refresh({
|
||||
index: kbnIndex
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import 'ui/paginated_table';
|
||||
import controlsHtml from 'plugins/kibana/management/sections/indices/_field_controls.html';
|
||||
import dateScripts from 'plugins/kibana/management/sections/indices/_date_scripts';
|
||||
import { dateScripts } from 'plugins/kibana/management/sections/indices/_date_scripts';
|
||||
import uiModules from 'ui/modules';
|
||||
import scriptedFieldsTemplate from 'plugins/kibana/management/sections/indices/_scripted_fields.html';
|
||||
import { getSupportedScriptingLangs } from 'ui/scripting_langs';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { saveAs } from '@spalger/filesaver';
|
||||
import { extend, find, flattenDeep, partialRight, pick, pluck, sortBy } from 'lodash';
|
||||
import angular from 'angular';
|
||||
import registry from 'plugins/kibana/management/saved_object_registry';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
import objectIndexHTML from 'plugins/kibana/management/sections/objects/_objects.html';
|
||||
import 'ui/directives/file_upload';
|
||||
import uiRoutes from 'ui/routes';
|
||||
|
@ -38,7 +38,7 @@ uiModules.get('apps/management')
|
|||
};
|
||||
|
||||
const getData = function (filter) {
|
||||
const services = registry.all().map(function (obj) {
|
||||
const services = savedObjectManagementRegistry.all().map(function (obj) {
|
||||
const service = $injector.get(obj.service);
|
||||
return service.find(filter).then(function (data) {
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import rison from 'rison-node';
|
||||
import registry from 'plugins/kibana/management/saved_object_registry';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
import objectViewHTML from 'plugins/kibana/management/sections/objects/_view.html';
|
||||
import IndexPatternsCastMappingTypeProvider from 'ui/index_patterns/_cast_mapping_type';
|
||||
import uiRoutes from 'ui/routes';
|
||||
|
@ -19,7 +19,7 @@ uiModules.get('apps/management')
|
|||
controller: function ($scope, $injector, $routeParams, $location, $window, $rootScope, esAdmin, Private) {
|
||||
const notify = new Notifier({ location: 'SavedObject view' });
|
||||
const castMappingType = Private(IndexPatternsCastMappingTypeProvider);
|
||||
const serviceObj = registry.get($routeParams.service);
|
||||
const serviceObj = savedObjectManagementRegistry.get($routeParams.service);
|
||||
const service = $injector.get(serviceObj.service);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import toEditableConfig from 'plugins/kibana/management/sections/settings/lib/to_editable_config';
|
||||
import { toEditableConfig } from 'plugins/kibana/management/sections/settings/lib/to_editable_config';
|
||||
import 'plugins/kibana/management/sections/settings/advanced_row';
|
||||
import management from 'ui/management';
|
||||
import uiRoutes from 'ui/routes';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import getEditorType from 'plugins/kibana/management/sections/settings/lib/get_editor_type';
|
||||
import { getEditorType } from 'plugins/kibana/management/sections/settings/lib/get_editor_type';
|
||||
import expect from 'expect.js';
|
||||
|
||||
describe('Settings', function () {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import getValType from 'plugins/kibana/management/sections/settings/lib/get_val_type';
|
||||
import { getValType } from 'plugins/kibana/management/sections/settings/lib/get_val_type';
|
||||
import expect from 'expect.js';
|
||||
|
||||
describe('Settings', function () {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import toEditableConfig from 'plugins/kibana/management/sections/settings/lib/to_editable_config';
|
||||
import { toEditableConfig } from 'plugins/kibana/management/sections/settings/lib/to_editable_config';
|
||||
import expect from 'expect.js';
|
||||
|
||||
describe('Settings', function () {
|
||||
|
|
|
@ -7,9 +7,7 @@ const NORMAL_EDITOR = ['number', 'string', 'null', 'undefined'];
|
|||
* @param {object} advanced setting configuration object
|
||||
* @returns {string} the editor type to use when editing value
|
||||
*/
|
||||
function getEditorType(conf) {
|
||||
export function getEditorType(conf) {
|
||||
if (_.contains(NAMED_EDITORS, conf.type)) return conf.type;
|
||||
if (_.contains(NORMAL_EDITOR, conf.type)) return 'normal';
|
||||
}
|
||||
|
||||
export default getEditorType;
|
||||
|
|
|
@ -5,7 +5,7 @@ import _ from 'lodash';
|
|||
* @param {?} current value of the setting
|
||||
* @returns {string} the type to use for determining the display and editor
|
||||
*/
|
||||
function getValType(def, value) {
|
||||
export function getValType(def, value) {
|
||||
if (def.type) {
|
||||
return def.type;
|
||||
}
|
||||
|
@ -16,5 +16,3 @@ function getValType(def, value) {
|
|||
|
||||
return (def.value != null ? typeof def.value : typeof value);
|
||||
}
|
||||
|
||||
export default getValType;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import getValType from './get_val_type';
|
||||
import getEditorType from './get_editor_type';
|
||||
import { getValType } from './get_val_type';
|
||||
import { getEditorType } from './get_editor_type';
|
||||
|
||||
/**
|
||||
* @param {object} advanced setting definition object
|
||||
|
@ -7,7 +7,7 @@ import getEditorType from './get_editor_type';
|
|||
* @param {object} current value of setting
|
||||
* @returns {object} the editable config object
|
||||
*/
|
||||
function toEditableConfig({ def, name, value, isCustom }) {
|
||||
export function toEditableConfig({ def, name, value, isCustom }) {
|
||||
if (!def) {
|
||||
def = {};
|
||||
}
|
||||
|
@ -33,5 +33,3 @@ function toEditableConfig({ def, name, value, isCustom }) {
|
|||
|
||||
return conf;
|
||||
}
|
||||
|
||||
export default toEditableConfig;
|
||||
|
|
|
@ -21,7 +21,7 @@ import visualizeListingTemplate from './listing/visualize_listing.html';
|
|||
import { VisualizeListingController } from './listing/visualize_listing';
|
||||
import { VisualizeConstants } from './visualize_constants';
|
||||
import savedObjectRegistry from 'ui/saved_objects/saved_object_registry';
|
||||
import savedVisusalizationProvider from 'plugins/kibana/visualize/saved_visualizations/saved_visualization_register';
|
||||
import { savedVisualizationProvider } from 'plugins/kibana/visualize/saved_visualizations/saved_visualization_register';
|
||||
|
||||
uiRoutes
|
||||
.defaults(/visualize/, {
|
||||
|
@ -35,4 +35,4 @@ uiRoutes
|
|||
|
||||
// preloading
|
||||
|
||||
savedObjectRegistry.register(savedVisusalizationProvider);
|
||||
savedObjectRegistry.register(savedVisualizationProvider);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export default function savedVisualizationFn(savedVisualizations) {
|
||||
export function savedVisualizationProvider(savedVisualizations) {
|
||||
return savedVisualizations;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ import 'plugins/kibana/visualize/saved_visualizations/_saved_vis';
|
|||
import RegistryVisTypesProvider from 'ui/registry/vis_types';
|
||||
import uiModules from 'ui/modules';
|
||||
import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
|
||||
const app = uiModules.get('app/visualize');
|
||||
|
||||
|
||||
// Register this service with the saved object registry so it can be
|
||||
// edited by the object editor.
|
||||
require('plugins/kibana/management/saved_object_registry').register({
|
||||
savedObjectManagementRegistry.register({
|
||||
service: 'savedVisualizations',
|
||||
title: 'visualizations'
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
|
||||
define(function (require) {
|
||||
const module = require('ui/modules').get('app/sheet');
|
||||
|
@ -8,7 +9,7 @@ define(function (require) {
|
|||
|
||||
// Register this service with the saved object registry so it can be
|
||||
// edited by the object editor.
|
||||
require('plugins/kibana/management/saved_object_registry').register({
|
||||
savedObjectManagementRegistry.register({
|
||||
service: 'savedSheets',
|
||||
title: 'sheets'
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue