mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Prefer Object spread * Add eslint rules for Object spread * no slice
This commit is contained in:
parent
75dcbf123c
commit
e080851ea7
22 changed files with 107 additions and 70 deletions
|
@ -7,12 +7,16 @@ import { WildcardMatcher } from './wildcard_matcher';
|
|||
|
||||
export class ProxyConfig {
|
||||
constructor(config) {
|
||||
config = Object.assign({}, config);
|
||||
config = {
|
||||
...config
|
||||
};
|
||||
|
||||
// -----
|
||||
// read "match" info
|
||||
// -----
|
||||
const rawMatches = Object.assign({}, config.match);
|
||||
const rawMatches = {
|
||||
...config.match
|
||||
};
|
||||
this.id = formatUrl({
|
||||
protocol: rawMatches.protocol,
|
||||
hostname: rawMatches.host,
|
||||
|
|
|
@ -92,7 +92,12 @@ describe('plugins/elasticsearch', function () {
|
|||
|
||||
it('passes only whitelisted headers', () => {
|
||||
const headers = { authorization: 'Basic TEST' };
|
||||
const request = { headers: Object.assign({}, headers, { foo: 'Foo' }) };
|
||||
const request = {
|
||||
headers: {
|
||||
...headers,
|
||||
foo: 'Foo'
|
||||
}
|
||||
};
|
||||
|
||||
cluster.callWithRequest(request, 'nodes.info');
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ import { parseConfig } from './parse_config';
|
|||
|
||||
export class Cluster {
|
||||
constructor(config) {
|
||||
this._config = Object.assign({}, config);
|
||||
this._config = {
|
||||
...config
|
||||
};
|
||||
this.errors = elasticsearch.errors;
|
||||
|
||||
this._client = this.createClient();
|
||||
|
@ -53,7 +55,10 @@ export class Cluster {
|
|||
}
|
||||
|
||||
createClient = configOverrides => {
|
||||
const config = Object.assign({}, this._getClientConfig(), configOverrides);
|
||||
const config = {
|
||||
...this._getClientConfig(),
|
||||
...configOverrides
|
||||
};
|
||||
return new elasticsearch.Client(parseConfig(config));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ export function createAdminCluster(server) {
|
|||
|
||||
const adminCluster = server.plugins.elasticsearch.createCluster(
|
||||
'admin',
|
||||
Object.assign({ log: AdminClientLogging }, config.get('elasticsearch'))
|
||||
{
|
||||
log: AdminClientLogging,
|
||||
...config.get('elasticsearch')
|
||||
}
|
||||
);
|
||||
|
||||
server.on('close', bindKey(adminCluster, 'close'));
|
||||
|
|
|
@ -20,7 +20,10 @@ export function createDataCluster(server) {
|
|||
|
||||
const dataCluster = server.plugins.elasticsearch.createCluster(
|
||||
'data',
|
||||
Object.assign({ log: DataClientLogging }, getConfig())
|
||||
{
|
||||
log: DataClientLogging,
|
||||
...getConfig()
|
||||
}
|
||||
);
|
||||
|
||||
server.on('close', bindKey(dataCluster, 'close'));
|
||||
|
|
|
@ -7,12 +7,13 @@ import Bluebird from 'bluebird';
|
|||
const readFile = (file) => readFileSync(file, 'utf8');
|
||||
|
||||
export function parseConfig(serverConfig = {}) {
|
||||
const config = Object.assign({
|
||||
keepAlive: true
|
||||
}, pick(serverConfig, [
|
||||
'plugins', 'apiVersion', 'keepAlive', 'pingTimeout',
|
||||
'requestTimeout', 'log', 'logQueries'
|
||||
]));
|
||||
const config = {
|
||||
keepAlive: true,
|
||||
...pick(serverConfig, [
|
||||
'plugins', 'apiVersion', 'keepAlive', 'pingTimeout',
|
||||
'requestTimeout', 'log', 'logQueries'
|
||||
])
|
||||
};
|
||||
|
||||
const uri = url.parse(serverConfig.url);
|
||||
config.host = {
|
||||
|
|
|
@ -30,13 +30,10 @@ function fetchAnchorProvider(courier, Private) {
|
|||
throw new Error('Failed to load anchor document.');
|
||||
}
|
||||
|
||||
return Object.assign(
|
||||
{},
|
||||
_.get(response, ['hits', 'hits', 0]),
|
||||
{
|
||||
$$_isAnchor: true,
|
||||
},
|
||||
);
|
||||
return {
|
||||
..._.get(response, ['hits', 'hits', 0]),
|
||||
$$_isAnchor: true,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -59,11 +59,10 @@ function ContextAppController($scope, config, Private, timefilter) {
|
|||
this.discoverUrl,
|
||||
);
|
||||
|
||||
this.actions = _.mapValues(Object.assign(
|
||||
{},
|
||||
queryParameterActions,
|
||||
queryActions,
|
||||
), (action) => (...args) => action(this.state)(...args));
|
||||
this.actions = _.mapValues({
|
||||
...queryParameterActions,
|
||||
...queryActions,
|
||||
}, (action) => (...args) => action(this.state)(...args));
|
||||
|
||||
this.constants = {
|
||||
FAILURE_REASONS,
|
||||
|
|
|
@ -122,7 +122,7 @@ export class DashboardState {
|
|||
// in place in order for it to affect the visualizations.
|
||||
this.stateDefaults.query = this.lastSavedDashboardFilters.query;
|
||||
// Need to make a copy to ensure they are not overwritten.
|
||||
this.stateDefaults.filters = Object.assign(new Array(), this.getLastSavedFilterBars());
|
||||
this.stateDefaults.filters = [...this.getLastSavedFilterBars()];
|
||||
|
||||
this.isDirty = false;
|
||||
this.appState.setDefaults(this.stateDefaults);
|
||||
|
|
|
@ -214,17 +214,15 @@ app.directive('discFieldChooser', function ($location, globalState, config, $rou
|
|||
|
||||
$scope.computeDetails = function (field, recompute) {
|
||||
if (_.isUndefined(field.details) || recompute) {
|
||||
field.details = Object.assign(
|
||||
{
|
||||
visualizeUrl: field.visualizable ? getVisualizeUrl(field) : null,
|
||||
},
|
||||
fieldCalculator.getFieldValueCounts({
|
||||
field.details = {
|
||||
visualizeUrl: field.visualizable ? getVisualizeUrl(field) : null,
|
||||
...fieldCalculator.getFieldValueCounts({
|
||||
hits: $scope.hits,
|
||||
field: field,
|
||||
count: 5,
|
||||
grouped: false
|
||||
}),
|
||||
);
|
||||
};
|
||||
_.each(field.details.buckets, function (bucket) {
|
||||
bucket.display = field.format.convert(bucket.value);
|
||||
});
|
||||
|
|
|
@ -9,7 +9,10 @@ function Agg(props) {
|
|||
if (!Component) {
|
||||
Component = StdAgg;
|
||||
}
|
||||
const style = Object.assign({ cursor: 'default' }, props.style);
|
||||
const style = {
|
||||
cursor: 'default',
|
||||
...props.style
|
||||
};
|
||||
return (
|
||||
<div
|
||||
className={props.className}
|
||||
|
|
|
@ -26,14 +26,13 @@ describe('Saved Object', function () {
|
|||
* @returns {{attributes: {}, type: string, id: *, _version: integer}}
|
||||
*/
|
||||
function getMockedDocResponse(indexPatternId, additionalOptions = {}) {
|
||||
return Object.assign(
|
||||
{
|
||||
type: 'dashboard',
|
||||
id: indexPatternId,
|
||||
_version: 2,
|
||||
attributes: {}
|
||||
},
|
||||
additionalOptions);
|
||||
return {
|
||||
type: 'dashboard',
|
||||
id: indexPatternId,
|
||||
_version: 2,
|
||||
attributes: {},
|
||||
...additionalOptions
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -481,10 +480,11 @@ describe('Saved Object', function () {
|
|||
describe('defaults', function () {
|
||||
|
||||
function getTestDefaultConfig(extraOptions) {
|
||||
return Object.assign({
|
||||
return {
|
||||
defaults: { testDefault: 'hi' },
|
||||
type: 'dashboard'
|
||||
}, extraOptions);
|
||||
type: 'dashboard',
|
||||
...extraOptions
|
||||
};
|
||||
}
|
||||
|
||||
function expectDefaultApplied(config) {
|
||||
|
|
|
@ -5,12 +5,13 @@ export function buildQueryFromKuery(indexPattern, queries) {
|
|||
const queryASTs = _.map(queries, query => fromKueryExpression(query.query));
|
||||
const compoundQueryAST = nodeTypes.function.buildNode('and', queryASTs);
|
||||
const kueryQuery = toElasticsearchQuery(compoundQueryAST, indexPattern);
|
||||
return Object.assign({
|
||||
return {
|
||||
must: [],
|
||||
filter: [],
|
||||
should: [],
|
||||
must_not: [],
|
||||
}, kueryQuery.bool);
|
||||
...kueryQuery.bool
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,12 +68,13 @@ export function KbnTopNavControllerProvider($compile) {
|
|||
}
|
||||
// apply the defaults to individual options
|
||||
_applyOptDefault(opt = {}) {
|
||||
const defaultedOpt = Object.assign({
|
||||
const defaultedOpt = {
|
||||
label: capitalize(opt.key),
|
||||
hasFunction: !!opt.run,
|
||||
description: opt.run ? opt.key : `Toggle ${opt.key} view`,
|
||||
run: (item) => this.toggle(item.key)
|
||||
}, opt);
|
||||
run: (item) => this.toggle(item.key),
|
||||
...opt
|
||||
};
|
||||
|
||||
defaultedOpt.hideButton = isFunction(opt.hideButton) ? opt.hideButton : () => !!opt.hideButton;
|
||||
defaultedOpt.disableButton = isFunction(opt.disableButton) ? opt.disableButton : () => !!opt.disableButton;
|
||||
|
|
|
@ -10,7 +10,10 @@ export function fromKueryExpression(expression, parseOptions = {}) {
|
|||
throw new Error('expression must be a string, got undefined instead');
|
||||
}
|
||||
|
||||
parseOptions = Object.assign({}, parseOptions, { helpers: { nodeTypes } });
|
||||
parseOptions = {
|
||||
...parseOptions,
|
||||
helpers: { nodeTypes }
|
||||
};
|
||||
|
||||
return kueryParser.parse(expression, parseOptions);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,9 @@ module.directive('queryBar', function () {
|
|||
};
|
||||
|
||||
$scope.$watch('queryBar.query', (newQuery) => {
|
||||
this.localQuery = Object.assign({}, newQuery);
|
||||
this.localQuery = {
|
||||
...newQuery
|
||||
};
|
||||
}, true);
|
||||
})
|
||||
};
|
||||
|
|
|
@ -31,7 +31,10 @@ const hashStatesInQuery = (states, query) => {
|
|||
}, {});
|
||||
|
||||
|
||||
return Object.assign({}, query, hashedQuery);
|
||||
return {
|
||||
...query,
|
||||
...hashedQuery
|
||||
};
|
||||
};
|
||||
|
||||
export const hashUrl = (states, redirectUrl) => {
|
||||
|
|
|
@ -37,10 +37,11 @@ export default (grunt) => {
|
|||
rpm.filePath,
|
||||
'-r', 'external-1'
|
||||
], {
|
||||
env: Object.assign({}, {
|
||||
env: {
|
||||
'AWS_ACCESS_KEY': rpm.awsKey,
|
||||
'AWS_SECRET_KEY': rpm.awsSecret
|
||||
}, process.env)
|
||||
'AWS_SECRET_KEY': rpm.awsSecret,
|
||||
...process.env
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,11 @@ export function CommonPageProvider({ getService, getPageObjects }) {
|
|||
* @param {string} subUrl The route after the hash (#)
|
||||
*/
|
||||
navigateToUrl(appName, subUrl) {
|
||||
const appConfig = Object.assign({}, config.get(['apps', appName]), {
|
||||
const appConfig = {
|
||||
...config.get(['apps', appName]),
|
||||
// Overwrite the default hash with the URL we really want.
|
||||
hash: `${appName}/${subUrl}`,
|
||||
});
|
||||
};
|
||||
|
||||
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);
|
||||
return remote.get(appUrl);
|
||||
|
|
|
@ -10,7 +10,9 @@ export default function creatExample(examples) {
|
|||
}
|
||||
}
|
||||
|
||||
Example.propTypes = Object.assign({}, GuideExample.propTypes);
|
||||
Example.propTypes = {
|
||||
...GuideExample.propTypes
|
||||
};
|
||||
|
||||
return Example;
|
||||
}
|
||||
|
|
|
@ -16,26 +16,29 @@ export default function codeViewerReducer(state = defaultState, action) {
|
|||
|
||||
if (state.code === source) {
|
||||
// If we are opening the existing code, then close the viewer.
|
||||
return Object.assign({}, state, {
|
||||
return {
|
||||
...state,
|
||||
isOpen: false,
|
||||
source: undefined,
|
||||
title: undefined,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return Object.assign({}, state, {
|
||||
return {
|
||||
...state,
|
||||
isOpen: true,
|
||||
source,
|
||||
title,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
case LOCATION_CHANGE: // Close Code Viewer when we navigate somewhere.
|
||||
case ActionTypes.CLOSE_CODE_VIEWER: {
|
||||
return Object.assign({}, state, {
|
||||
return {
|
||||
...state,
|
||||
isOpen: false,
|
||||
source: undefined,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -13,9 +13,10 @@ export default function sectionsReducer(state = defaultState, action) {
|
|||
name: action.name,
|
||||
});
|
||||
|
||||
return Object.assign({}, state, {
|
||||
sections,
|
||||
});
|
||||
return {
|
||||
...state,
|
||||
sections: sections,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionTypes.UNREGISTER_SECTION: {
|
||||
|
@ -23,9 +24,10 @@ export default function sectionsReducer(state = defaultState, action) {
|
|||
const index = sections.findIndex(section => section.id === action.id);
|
||||
sections.splice(index, 1);
|
||||
|
||||
return Object.assign({}, state, {
|
||||
sections,
|
||||
});
|
||||
return {
|
||||
...state,
|
||||
sections: sections,
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue