Commit 06ee932e authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 35 files - 13 of 73

Part of our prettier migration; changing the arrow-parens style.
parent b3ece842
......@@ -162,43 +162,6 @@ app/assets/javascripts/ci_variable_list/ci_variable_list.js
app/assets/javascripts/ci_variable_list/components/ci_environments_dropdown.vue
app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue
## modest-mayer
app/assets/javascripts/experimental_flags.js
app/assets/javascripts/feature_flags/components/edit_feature_flag.vue
app/assets/javascripts/feature_flags/components/feature_flags.vue
app/assets/javascripts/feature_flags/components/feature_flags_table.vue
app/assets/javascripts/feature_flags/components/form.vue
app/assets/javascripts/feature_flags/components/new_feature_flag.vue
app/assets/javascripts/feature_flags/store/edit/actions.js
app/assets/javascripts/feature_flags/store/edit/index.js
app/assets/javascripts/feature_flags/store/gitlab_user_list/actions.js
app/assets/javascripts/feature_flags/store/gitlab_user_list/index.js
app/assets/javascripts/feature_flags/store/helpers.js
app/assets/javascripts/feature_flags/store/index/actions.js
app/assets/javascripts/feature_flags/store/index/index.js
app/assets/javascripts/feature_flags/store/index/mutations.js
app/assets/javascripts/feature_flags/store/new/actions.js
app/assets/javascripts/feature_flags/store/new/index.js
app/assets/javascripts/feature_flags/utils.js
app/assets/javascripts/feature_highlight/feature_highlight.js
app/assets/javascripts/feature_highlight/feature_highlight_helper.js
app/assets/javascripts/file_pickers.js
app/assets/javascripts/files_comment_button.js
app/assets/javascripts/filterable_list.js
app/assets/javascripts/filtered_search/available_dropdown_mappings.js
app/assets/javascripts/filtered_search/components/recent_searches_dropdown_content.vue
app/assets/javascripts/filtered_search/dropdown_ajax_filter.js
app/assets/javascripts/filtered_search/dropdown_emoji.js
app/assets/javascripts/filtered_search/dropdown_hint.js
app/assets/javascripts/filtered_search/dropdown_non_user.js
app/assets/javascripts/filtered_search/dropdown_utils.js
app/assets/javascripts/filtered_search/filtered_search_dropdown.js
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
app/assets/javascripts/filtered_search/filtered_search_manager.js
app/assets/javascripts/filtered_search/filtered_search_token_keys.js
app/assets/javascripts/filtered_search/filtered_search_visual_tokens.js
app/assets/javascripts/filtered_search/issuable_filtered_search_token_keys.js
## stoic-merkle
app/assets/javascripts/filtered_search/stores/recent_searches_store.js
app/assets/javascripts/filtered_search/visual_token_value.js
......
......@@ -2,7 +2,7 @@ import $ from 'jquery';
import Cookies from 'js-cookie';
export default () => {
$('.js-experiment-feature-toggle').on('change', e => {
$('.js-experiment-feature-toggle').on('change', (e) => {
const el = e.target;
Cookies.set(el.name, el.value, {
......
......@@ -122,7 +122,7 @@ export default {
:submit-text="__('Save changes')"
:active="active"
:version="version"
@handleSubmit="data => updateFeatureFlag(data)"
@handleSubmit="(data) => updateFeatureFlag(data)"
/>
</template>
</div>
......
......@@ -133,7 +133,7 @@ export default {
},
updateFeatureFlagOptions(parameters) {
const queryString = Object.keys(parameters)
.map(parameter => {
.map((parameter) => {
const value = parameters[parameter];
return `${parameter}=${encodeURIComponent(value)}`;
})
......
......@@ -100,7 +100,7 @@ export default {
return featureFlag.iid ? `^${featureFlag.iid}` : '';
},
canDeleteFlag(flag) {
return !this.permissions || (flag.scopes || []).every(scope => scope.can_update);
return !this.permissions || (flag.scopes || []).every((scope) => scope.can_update);
},
setDeleteModalData(featureFlag) {
this.deleteFeatureFlagUrl = featureFlag.destroy_path;
......
......@@ -117,7 +117,7 @@ export default {
formDescription: this.description,
// operate on a clone to avoid mutating props
formScopes: this.scopes.map(s => ({ ...s })),
formScopes: this.scopes.map((s) => ({ ...s })),
formStrategies: cloneDeep(this.strategies),
newScope: '',
......@@ -125,13 +125,13 @@ export default {
},
computed: {
filteredScopes() {
return this.formScopes.filter(scope => !scope.shouldBeDestroyed);
return this.formScopes.filter((scope) => !scope.shouldBeDestroyed);
},
filteredStrategies() {
return this.formStrategies.filter(s => !s.shouldBeDestroyed);
return this.formStrategies.filter((s) => !s.shouldBeDestroyed);
},
canUpdateFlag() {
return !this.permissionsFlag || (this.formScopes || []).every(scope => scope.canUpdate);
return !this.permissionsFlag || (this.formScopes || []).every((scope) => scope.canUpdate);
},
permissionsFlag() {
return this.glFeatures.featureFlagPermissions;
......@@ -167,7 +167,7 @@ export default {
if (isNumber(s.id)) {
Vue.set(s, 'shouldBeDestroyed', true);
} else {
this.formStrategies = this.formStrategies.filter(strategy => strategy !== s);
this.formStrategies = this.formStrategies.filter((strategy) => strategy !== s);
}
},
......@@ -188,7 +188,7 @@ export default {
*/
removeScope(scope) {
if (isString(scope.id) && scope.id.startsWith(INTERNAL_ID_PREFIX)) {
this.formScopes = this.formScopes.filter(s => s !== scope);
this.formScopes = this.formScopes.filter((s) => s !== scope);
} else {
Vue.set(scope, 'shouldBeDestroyed', true);
}
......@@ -387,9 +387,9 @@ export default {
class="col-12"
:value="scope.environmentScope"
:disabled="!canUpdateScope(scope) || scope.environmentScope !== ''"
@selectEnvironment="env => (scope.environmentScope = env)"
@createClicked="env => (scope.environmentScope = env)"
@clearInput="env => (scope.environmentScope = '')"
@selectEnvironment="(env) => (scope.environmentScope = env)"
@createClicked="(env) => (scope.environmentScope = env)"
@clearInput="(env) => (scope.environmentScope = '')"
/>
<gl-badge v-if="permissionsFlag && scope.protected" variant="success">
......@@ -406,7 +406,7 @@ export default {
<toggle-button
:value="scope.active"
:disabled-input="!active || !canUpdateScope(scope)"
@change="status => (scope.active = status)"
@change="(status) => (scope.active = status)"
/>
</div>
</div>
......@@ -524,8 +524,8 @@ export default {
<environments-dropdown
class="js-new-scope-name col-12"
:value="newScope"
@selectEnvironment="env => createNewScope({ environmentScope: env })"
@createClicked="env => createNewScope({ environmentScope: env })"
@selectEnvironment="(env) => createNewScope({ environmentScope: env })"
@createClicked="(env) => createNewScope({ environmentScope: env })"
/>
</div>
</div>
......
......@@ -71,7 +71,7 @@ export default {
:scopes="scopes"
:strategies="strategies"
:version="version"
@handleSubmit="data => createFeatureFlag(data)"
@handleSubmit="(data) => createFeatureFlag(data)"
/>
</div>
</template>
......@@ -29,7 +29,7 @@ export const updateFeatureFlag = ({ state, dispatch }, params) => {
dispatch('receiveUpdateFeatureFlagSuccess');
visitUrl(state.path);
})
.catch(error => dispatch('receiveUpdateFeatureFlagError', error.response.data));
.catch((error) => dispatch('receiveUpdateFeatureFlagError', error.response.data));
};
export const requestUpdateFeatureFlag = ({ commit }) => commit(types.REQUEST_UPDATE_FEATURE_FLAG);
......
......@@ -4,7 +4,7 @@ import state from './state';
import * as actions from './actions';
import mutations from './mutations';
export default data =>
export default (data) =>
new Vuex.Store({
actions,
mutations,
......
import Api from '~/api';
import * as types from './mutation_types';
const getErrorMessages = error => [].concat(error?.response?.data?.message ?? error.message);
const getErrorMessages = (error) => [].concat(error?.response?.data?.message ?? error.message);
export const fetchUserLists = ({ commit, state: { filter, projectId } }) => {
commit(types.FETCH_USER_LISTS);
return Api.searchFeatureFlagUserLists(projectId, filter)
.then(({ data }) => commit(types.RECEIVE_USER_LISTS_SUCCESS, data))
.catch(error => commit(types.RECEIVE_USER_LISTS_ERROR, getErrorMessages(error)));
.catch((error) => commit(types.RECEIVE_USER_LISTS_ERROR, getErrorMessages(error)));
};
export const setFilter = ({ commit, dispatch }, filter) => {
......
......@@ -3,7 +3,7 @@ import mutations from './mutations';
import * as actions from './actions';
import * as getters from './getters';
export default data => ({
export default (data) => ({
state: state(data),
actions,
getters,
......
......@@ -17,16 +17,16 @@ import {
* objects that is easier/nicer to bind to in Vue.
* @param {Array} scopesFromRails An array of scope objects fetched from the API
*/
export const mapToScopesViewModel = scopesFromRails =>
(scopesFromRails || []).map(s => {
export const mapToScopesViewModel = (scopesFromRails) =>
(scopesFromRails || []).map((s) => {
const percentStrategy = (s.strategies || []).find(
strat => strat.name === ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
(strat) => strat.name === ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
);
const rolloutPercentage = fetchPercentageParams(percentStrategy) || DEFAULT_PERCENT_ROLLOUT;
const userStrategy = (s.strategies || []).find(
strat => strat.name === ROLLOUT_STRATEGY_USER_ID,
(strat) => strat.name === ROLLOUT_STRATEGY_USER_ID,
);
const rolloutStrategy =
......@@ -36,7 +36,7 @@ export const mapToScopesViewModel = scopesFromRails =>
const rolloutUserIds = (fetchUserIdParams(userStrategy) || '')
.split(',')
.filter(id => id)
.filter((id) => id)
.join(', ');
return {
......@@ -59,8 +59,8 @@ export const mapToScopesViewModel = scopesFromRails =>
* the shape that the Rails API expects.
* @param {Array} scopesFromVue An array of scope objects from the Vue component
*/
export const mapFromScopesViewModel = params => {
const scopes = (params.scopes || []).map(s => {
export const mapFromScopesViewModel = (params) => {
const scopes = (params.scopes || []).map((s) => {
const parameters = {};
if (s.rolloutStrategy === ROLLOUT_STRATEGY_PERCENT_ROLLOUT) {
parameters.groupId = PERCENT_ROLLOUT_GROUP_ID;
......@@ -145,32 +145,32 @@ export const createNewEnvironmentScope = (overrides = {}, featureFlagPermissions
return newScope;
};
const mapStrategyScopesToRails = scopes =>
const mapStrategyScopesToRails = (scopes) =>
scopes.length === 0
? [{ environment_scope: '*' }]
: scopes.map(s => ({
: scopes.map((s) => ({
id: s.id,
_destroy: s.shouldBeDestroyed,
environment_scope: s.environmentScope,
}));
const mapStrategyScopesToView = scopes =>
scopes.map(s => ({
const mapStrategyScopesToView = (scopes) =>
scopes.map((s) => ({
id: s.id,
// eslint-disable-next-line no-underscore-dangle
shouldBeDestroyed: Boolean(s._destroy),
environmentScope: s.environment_scope,
}));
const mapStrategiesParametersToViewModel = params => {
const mapStrategiesParametersToViewModel = (params) => {
if (params.userIds) {
return { ...params, userIds: params.userIds.split(',').join(', ') };
}
return params;
};
export const mapStrategiesToViewModel = strategiesFromRails =>
(strategiesFromRails || []).map(s => ({
export const mapStrategiesToViewModel = (strategiesFromRails) =>
(strategiesFromRails || []).map((s) => ({
id: s.id,
name: s.name,
parameters: mapStrategiesParametersToViewModel(s.parameters),
......@@ -180,14 +180,14 @@ export const mapStrategiesToViewModel = strategiesFromRails =>
scopes: mapStrategyScopesToView(s.scopes),
}));
const mapStrategiesParametersToRails = params => {
const mapStrategiesParametersToRails = (params) => {
if (params.userIds) {
return { ...params, userIds: params.userIds.replace(/\s*,\s*/g, ',') };
}
return params;
};
const mapStrategyToRails = strategy => {
const mapStrategyToRails = (strategy) => {
const mappedStrategy = {
id: strategy.id,
name: strategy.name,
......@@ -202,7 +202,7 @@ const mapStrategyToRails = strategy => {
return mappedStrategy;
};
export const mapStrategiesToRails = params => ({
export const mapStrategiesToRails = (params) => ({
operations_feature_flag: {
name: params.name,
description: params.description,
......
......@@ -12,7 +12,7 @@ export const fetchFeatureFlags = ({ state, dispatch }) => {
.get(state.endpoint, {
params: state.options,
})
.then(response =>
.then((response) =>
dispatch('receiveFeatureFlagsSuccess', {
data: response.data || {},
headers: response.headers,
......@@ -46,7 +46,7 @@ export const toggleFeatureFlag = ({ dispatch }, flag) => {
.put(flag.update_path, {
operations_feature_flag: flag,
})
.then(response => dispatch('receiveUpdateFeatureFlagSuccess', response.data))
.then((response) => dispatch('receiveUpdateFeatureFlagSuccess', response.data))
.catch(() => dispatch('receiveUpdateFeatureFlagError', flag.id));
};
......@@ -62,7 +62,7 @@ export const deleteUserList = ({ state, dispatch }, list) => {
return Api.deleteFeatureFlagUserList(state.projectId, list.iid)
.then(() => dispatch('fetchUserLists'))
.catch(error =>
.catch((error) =>
dispatch('receiveDeleteUserListError', {
list,
error: error?.response?.data ?? error,
......
......@@ -3,7 +3,7 @@ import state from './state';
import * as actions from './actions';
import mutations from './mutations';
export default data =>
export default (data) =>
new Vuex.Store({
actions,
mutations,
......
......@@ -4,7 +4,7 @@ import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import { FEATURE_FLAG_SCOPE, USER_LIST_SCOPE } from '../../constants';
import { mapToScopesViewModel } from '../helpers';
const mapFlag = flag => ({ ...flag, scopes: mapToScopesViewModel(flag.scopes || []) });
const mapFlag = (flag) => ({ ...flag, scopes: mapToScopesViewModel(flag.scopes || []) });
const updateFlag = (state, flag) => {
const index = state[FEATURE_FLAG_SCOPE].findIndex(({ id }) => id === flag.id);
......@@ -94,7 +94,7 @@ export default {
updateFlag(state, { ...flag, active: !flag.active });
},
[types.REQUEST_DELETE_USER_LIST](state, list) {
state.userLists = state.userLists.filter(l => l !== list);
state.userLists = state.userLists.filter((l) => l !== list);
},
[types.RECEIVE_DELETE_USER_LIST_ERROR](state, { error, list }) {
state.isLoading = false;
......
......@@ -27,7 +27,7 @@ export const createFeatureFlag = ({ state, dispatch }, params) => {
dispatch('receiveCreateFeatureFlagSuccess');
visitUrl(state.path);
})
.catch(error => dispatch('receiveCreateFeatureFlagError', error.response.data));
.catch((error) => dispatch('receiveCreateFeatureFlagError', error.response.data));
};
export const requestCreateFeatureFlag = ({ commit }) => commit(types.REQUEST_CREATE_FEATURE_FLAG);
......
......@@ -4,7 +4,7 @@ import state from './state';
import * as actions from './actions';
import mutations from './mutations';
export default data =>
export default (data) =>
new Vuex.Store({
actions,
mutations,
......
......@@ -48,7 +48,7 @@ const badgeTextByType = {
const scopeName = ({ environment_scope: scope }) =>
scope === ALL_ENVIRONMENTS_NAME ? s__('FeatureFlags|All Environments') : scope;
export const labelForStrategy = strategy => {
export const labelForStrategy = (strategy) => {
const { name, parameters } = badgeTextByType[strategy.name];
if (parameters) {
......
......@@ -31,7 +31,7 @@ export function setupFeatureHighlightPopover(id, debounceTimeout = 300) {
.removeAttr('disabled');
}
const getPriority = e => parseInt(e.dataset.highlightPriority, 10) || 0;
const getPriority = (e) => parseInt(e.dataset.highlightPriority, 10) || 0;
export function findHighestPriorityFeature() {
let priorityFeature;
......
......@@ -5,7 +5,7 @@ import { deprecatedCreateFlash as Flash } from '../flash';
import LazyLoader from '../lazy_loader';
import { togglePopover } from '../shared/popover';
export const getSelector = highlightId => `.js-feature-highlight[data-highlight=${highlightId}]`;
export const getSelector = (highlightId) => `.js-feature-highlight[data-highlight=${highlightId}]`;
export function dismiss(highlightId) {
axios
......
export default function initFilePickers() {
const filePickers = document.querySelectorAll('.js-filepicker');
filePickers.forEach(filePicker => {
filePickers.forEach((filePicker) => {
const button = filePicker.querySelector('.js-filepicker-button');
button.addEventListener('click', () => {
......
......@@ -33,8 +33,8 @@ export default {
if (this.userCanCreateNote) {
$diffFile
.on('mouseover', LINE_COLUMN_CLASSES, e => this.showButton(this.isParallelView, e))
.on('mouseleave', LINE_COLUMN_CLASSES, e => this.hideButton(this.isParallelView, e));
.on('mouseover', LINE_COLUMN_CLASSES, (e) => this.showButton(this.isParallelView, e))
.on('mouseleave', LINE_COLUMN_CLASSES, (e) => this.hideButton(this.isParallelView, e));
}
},
......
......@@ -72,7 +72,7 @@ export default class FilterableList {
.get(this.getFilterEndpoint(), {
params,
})
.then(res => {
.then((res) => {
this.onFilterSuccess(res, params);
this.onFilterComplete();
})
......
......@@ -50,7 +50,7 @@ export default class AvailableDropdownMappings {
},
};
supportedTokens.forEach(type => {
supportedTokens.forEach((type) => {
if (availableMappings[type]) {
allowedMappings[type] = availableMappings[type];
}
......@@ -99,7 +99,7 @@ export default class AvailableDropdownMappings {
// The DropdownNonUser class is hardcoded to look for and display a
// "title" property, so we need to add this property to each release object
preprocessing: releases => releases.map(r => ({ ...r, title: r.tag })),
preprocessing: (releases) => releases.map((r) => ({ ...r, title: r.tag })),
},
element: this.container.querySelector('#js-dropdown-release'),
},
......@@ -162,7 +162,7 @@ export default class AvailableDropdownMappings {
extraArguments: {
endpoint: this.getEnvironmentsEndpoint(),
symbol: '',
preprocessing: data => data.map(env => ({ title: env })),
preprocessing: (data) => data.map((env) => ({ title: env })),
},
element: this.container.querySelector('#js-dropdown-environment'),
},
......
......@@ -28,16 +28,16 @@ export default {
* fix by ignoring non-string recents while in Epic page.
*/
compatibleItems() {
return this.items.filter(item => typeof item === 'string');
return this.items.filter((item) => typeof item === 'string');
},
processedItems() {
return this.compatibleItems.map(item => {
return this.compatibleItems.map((item) => {
const { tokens, searchToken } = FilteredSearchTokenizer.processTokens(
item,
this.allowedKeys,
);
const resultantTokens = tokens.map(token => ({
const resultantTokens = tokens.map((token) => ({
prefix: `${token.key}:`,
operator: token.operator,
suffix: `${token.symbol}${token.value}`,
......
......@@ -33,7 +33,7 @@ export default class DropdownAjaxFilter extends FilteredSearchDropdown {
}
itemClicked(e) {
super.itemClicked(e, selected => {
super.itemClicked(e, (selected) => {
const title = selected.querySelector('.dropdown-light-content').innerText.trim();
return DropdownUtils.getEscapedText(title);
......
......@@ -53,7 +53,7 @@ export default class DropdownEmoji extends FilteredSearchDropdown {
}
itemClicked(e) {
super.itemClicked(e, selected => {
super.itemClicked(e, (selected) => {
const name = selected.querySelector('.js-data-value').innerText.trim();
return DropdownUtils.getEscapedText(name);
});
......@@ -69,7 +69,7 @@ export default class DropdownEmoji extends FilteredSearchDropdown {
// Replace empty gl-emoji tag to real content
const dropdownItems = [...this.dropdown.querySelectorAll('.filter-dropdown-item')];
dropdownItems.forEach(dropdownItem => {
dropdownItems.forEach((dropdownItem) => {
const valueElement = dropdownItem.querySelector('.js-data-value');
if (valueElement !== null) {
const name = valueElement.innerText;
......
......@@ -83,7 +83,7 @@ export default class DropdownHint extends FilteredSearchDropdown {
const dropdownData = this.tokenKeys
.get()
.map(tokenKey => ({
.map((tokenKey) => ({
icon: `${gon.sprite_icons}#${tokenKey.icon}`,
hint: tokenKey.key,
tag: `:${tokenKey.tag}`,
......
......@@ -30,7 +30,7 @@ export default class DropdownNonUser extends FilteredSearchDropdown {
}
itemClicked(e) {
super.itemClicked(e, selected => {
super.itemClicked(e, (selected) => {
const title = selected.querySelector('.js-data-value').innerText.trim();
return `${this.symbol}${DropdownUtils.getEscapedText(title)}`;
});
......
......@@ -61,7 +61,7 @@ export default class DropdownUtils {
const { lastToken, tokens } = FilteredSearchTokenizer.processTokens(searchInput, allowedKeys);
const lastKey = lastToken.key || lastToken || '';
const allowMultiple = item.type === 'array';
const itemInExistingTokens = tokens.some(t => t.key === item.hint);
const itemInExistingTokens = tokens.some((t) => t.key === item.hint);
const isSearchItem = updatedItem.hint === 'search';
if (isSearchItem) {
......@@ -77,7 +77,7 @@ export default class DropdownUtils {
const tokenName = last(split[0].split(' '));
const match = isSearchItem
? allowedKeys.some(key => key.startsWith(tokenName.toLowerCase()))
? allowedKeys.some((key) => key.startsWith(tokenName.toLowerCase()))
: updatedItem.hint.indexOf(tokenName.toLowerCase()) === -1;
updatedItem.droplab_hidden = tokenName ? match : false;
......@@ -129,12 +129,12 @@ export default class DropdownUtils {
const values = [];
if (untilInput) {
const inputIndex = tokens.findIndex(t => t.classList.contains('input-token'));
const inputIndex = tokens.findIndex((t) => t.classList.contains('input-token'));
// Add one to include input-token to the tokens array
tokens.splice(inputIndex + 1);
}
tokens.forEach(token => {
tokens.forEach((token) => {
if (token.classList.contains('js-visual-token')) {
const name = token.querySelector('.name');
const operatorContainer = token.querySelector('.operator');
......@@ -176,7 +176,7 @@ export default class DropdownUtils {
}
});
return values.map(value => value.trim()).join(' ');
return values.map((value) => value.trim()).join(' ');
}
static getSearchInput(filteredSearchInput) {
......@@ -192,7 +192,7 @@ export default class DropdownUtils {
// Replace all spaces inside quote marks with underscores
// (will continue to match entire string until an end quote is found if any)
// This helps with matching the beginning & end of a token:key
inputValue = inputValue.replace(/(('[^']*'{0,1})|("[^"]*"{0,1})|:\s+)/g, str =>
inputValue = inputValue.replace(/(('[^']*'{0,1})|("[^"]*"{0,1})|:\s+)/g, (str) =>
str.replace(/\s/g, '_'),
);
......
......@@ -28,7 +28,7 @@ export default class FilteredSearchDropdown {
}
getCurrentHook() {
return this.droplab.hooks.filter(h => h.id === this.hookId)[0] || null;
return this.droplab.hooks.filter((h) => h.id === this.hookId)[0] || null;
}
itemClicked(e, getValueFunction) {
......@@ -134,7 +134,7 @@ export default class FilteredSearchDropdown {
if (!data) return;
const results = data.map(o => {
const results = data.map((o) => {
const updated = o;
updated.droplab_hidden = false;
return updated;
......@@ -157,7 +157,7 @@ export default class FilteredSearchDropdown {
// Iterate over all the static dropdown values,
// then hide `None` and `Any` items.
Array.from(dropdownEl.querySelectorAll('li[data-value]')).forEach(itemEl => {
Array.from(dropdownEl.querySelectorAll('li[data-value]')).forEach((itemEl) => {
const {
dataset: { value },
} = itemEl;
......
......@@ -23,7 +23,7 @@ export default class FilteredSearchDropdownManager {
isGroupDecendent,
filteredSearchTokenKeys,
}) {
const removeTrailingSlash = url => url.replace(/\/$/, '');
const removeTrailingSlash = (url) => url.replace(/\/$/, '');
this.container = FilteredSearchContainer.container;
this.runnerTagsEndpoint = removeTrailingSlash(runnerTagsEndpoint);
......
......@@ -90,14 +90,14 @@ export default class FilteredSearchManager {
// Fetch recent searches from localStorage
this.fetchingRecentSearchesPromise = this.recentSearchesService
.fetch()
.catch(error => {
.catch((error) => {
if (error.name === 'RecentSearchesServiceError') return undefined;
// eslint-disable-next-line no-new
new Flash(__('An error occurred while parsing recent searches'));
// Gracefully fail to empty array
return [];
})
.then(searches => {
.then((searches) => {
if (!searches) {
return;
}
......@@ -169,7 +169,7 @@ export default class FilteredSearchManager {
if (this.stateFilters) {
this.searchStateWrapper = this.searchState.bind(this);
this.applyToStateFilters(filterEl => {
this.applyToStateFilters((filterEl) => {
filterEl.addEventListener('click', this.searchStateWrapper);
});
}
......@@ -177,14 +177,14 @@ export default class FilteredSearchManager {
unbindStateEvents() {
if (this.stateFilters) {
this.applyToStateFilters(filterEl => {
this.applyToStateFilters((filterEl) => {
filterEl.removeEventListener('click', this.searchStateWrapper);
});
}
}
applyToStateFilters(callback) {
this.stateFilters.querySelectorAll('a[data-state]').forEach(filterEl => {
this.stateFilters.querySelectorAll('a[data-state]').forEach((filterEl) => {
if (this.states.indexOf(filterEl.dataset.state) > -1) {
callback(filterEl);
}
......@@ -263,7 +263,7 @@ export default class FilteredSearchManager {
let backspaceCount = 0;
// closure for keeping track of the number of backspace keystrokes
return e => {
return (e) => {
// 8 = Backspace Key
// 46 = Delete Key
// Handled by respective backspace-combination check functions
......@@ -447,7 +447,7 @@ export default class FilteredSearchManager {
const removeElements = [];
[].forEach.call(this.tokensContainer.children, t => {
[].forEach.call(this.tokensContainer.children, (t) => {
let canClearToken = t.classList.contains('js-visual-token');
if (canClearToken) {
......@@ -460,7 +460,7 @@ export default class FilteredSearchManager {
}
});
removeElements.forEach(el => {
removeElements.forEach((el) => {
el.parentElement.removeChild(el);
});
......@@ -488,7 +488,7 @@ export default class FilteredSearchManager {
const { isLastVisualTokenValid } = FilteredSearchVisualTokens.getLastVisualTokenBeforeInput();
if (isLastVisualTokenValid) {
tokens.forEach(t => {
tokens.forEach((t) => {
input.value = input.value.replace(`${t.key}:${t.operator}${t.symbol}${t.value}`, '');
FilteredSearchVisualTokens.addFilterVisualToken(
......@@ -585,7 +585,7 @@ export default class FilteredSearchManager {
*/
const notKeyValueRegex = new RegExp(/not\[(\w+)\]\[?\]?=(.*)/);
return params.map(query => {
return params.map((query) => {
// Check if there are matches for `not` operator
const matches = query.match(notKeyValueRegex);
if (matches && matches.length === 3) {
......@@ -624,7 +624,7 @@ export default class FilteredSearchManager {
const usernameParams = this.getUsernameParams();
let hasFilteredSearch = false;
params.forEach(p => {
params.forEach((p) => {
const split = p.split('=');
const keyParam = decodeURIComponent(split[0]);
const value = split[1];
......@@ -746,7 +746,7 @@ export default class FilteredSearchManager {
paths.push(`state=${currentState}`);
}
tokens.forEach(token => {
tokens.forEach((token) => {
const condition = this.filteredSearchTokenKeys.searchByConditionKeyValue(
token.key,
token.operator,
......@@ -795,7 +795,7 @@ export default class FilteredSearchManager {
if (searchToken) {
const sanitized = searchToken
.split(' ')
.map(t => encodeURIComponent(t))
.map((t) => encodeURIComponent(t))
.join('+');
paths.push(`search=${sanitized}`);
}
......@@ -817,7 +817,7 @@ export default class FilteredSearchManager {
const usernamesById = {};
try {
const attribute = this.filteredSearchInput.getAttribute('data-username-params');
JSON.parse(attribute).forEach(user => {
JSON.parse(attribute).forEach((user) => {
usernamesById[user.id] = user.username;
});
} catch (e) {
......
......@@ -14,7 +14,7 @@ export default class FilteredSearchTokenKeys {
}
getKeys() {
return this.tokenKeys.map(i => i.key);
return this.tokenKeys.map((i) => i.key);
}
getAlternatives() {
......@@ -36,16 +36,16 @@ export default class FilteredSearchTokenKeys {
}
searchByKey(key) {
return this.tokenKeys.find(tokenKey => tokenKey.key === key) || null;
return this.tokenKeys.find((tokenKey) => tokenKey.key === key) || null;
}
searchBySymbol(symbol) {
return this.tokenKeys.find(tokenKey => tokenKey.symbol === symbol) || null;
return this.tokenKeys.find((tokenKey) => tokenKey.symbol === symbol) || null;
}
searchByKeyParam(keyParam) {
return (
this.tokenKeysWithAlternative.find(tokenKey => {
this.tokenKeysWithAlternative.find((tokenKey) => {
let tokenKeyParam = tokenKey.key;
// Replace hyphen with underscore to compare keyParam with tokenKeyParam
......@@ -62,13 +62,13 @@ export default class FilteredSearchTokenKeys {
}
searchByConditionUrl(url) {
return this.conditions.find(condition => condition.url === url) || null;
return this.conditions.find((condition) => condition.url === url) || null;
}
searchByConditionKeyValue(key, operator, value) {
return (
this.conditions.find(
condition =>
(condition) =>
condition.tokenKey === key &&
condition.operator === operator &&
condition.value.toLowerCase() === value.toLowerCase(),
......
......@@ -8,7 +8,7 @@ export default class FilteredSearchVisualTokens {
static getOperatorToken(value) {
let token = null;
FilteredSearchVisualTokens.permissibleOperatorValues.forEach(operatorToken => {
FilteredSearchVisualTokens.permissibleOperatorValues.forEach((operatorToken) => {
if (value.startsWith(operatorToken)) {
token = operatorToken;
}
......@@ -20,7 +20,7 @@ export default class FilteredSearchVisualTokens {
static getValueToken(value) {
let newValue = value;
FilteredSearchVisualTokens.permissibleOperatorValues.forEach(operatorToken => {
FilteredSearchVisualTokens.permissibleOperatorValues.forEach((operatorToken) => {
if (value.startsWith(operatorToken)) {
newValue = value.slice(operatorToken.length);
}
......@@ -48,7 +48,7 @@ export default class FilteredSearchVisualTokens {
const otherTokens = FilteredSearchContainer.container.querySelectorAll(
'.js-visual-token .selectable.selected',
);
[].forEach.call(otherTokens, t => t.classList.remove('selected'));
[].forEach.call(otherTokens, (t) => t.classList.remove('selected'));
}
static selectToken(tokenButton, forceSelection = false) {
......
......@@ -150,7 +150,7 @@ export const conditions = flattenDeep(
tokenKey: 'my-reaction',
value: __('Any'),
},
].map(condition => {
].map((condition) => {
const [keyPart, valuePart] = condition.url.split('=');
const hasBrackets = keyPart.includes('[]');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment