Commit 075a78b3 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 36 files - 31 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 9f4b4de2
...@@ -848,44 +848,6 @@ app/assets/javascripts/snippets/components/snippet_blob_view.vue ...@@ -848,44 +848,6 @@ app/assets/javascripts/snippets/components/snippet_blob_view.vue
app/assets/javascripts/snippets/components/snippet_header.vue app/assets/javascripts/snippets/components/snippet_header.vue
app/assets/javascripts/snippets/mixins/snippets.js app/assets/javascripts/snippets/mixins/snippets.js
## thirsty-mccarthy
app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker.vue
app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker_input.vue
app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker_lib.js
app/assets/javascripts/vue_shared/components/deprecated_modal_2.vue
app/assets/javascripts/vue_shared/components/dismissible_container.vue
app/assets/javascripts/vue_shared/components/file_finder/index.vue
app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_utils.js
app/assets/javascripts/vue_shared/components/filtered_search_bar/store/modules/filters/actions.js
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/author_token.vue
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/branch_token.vue
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/label_token.vue
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue
app/assets/javascripts/vue_shared/components/gfm_autocomplete/gfm_autocomplete.vue
app/assets/javascripts/vue_shared/components/gfm_autocomplete/utils.js
app/assets/javascripts/vue_shared/components/lib/utils/diff_utils.js
app/assets/javascripts/vue_shared/components/markdown/field.vue
app/assets/javascripts/vue_shared/components/markdown/header.vue
app/assets/javascripts/vue_shared/components/markdown/suggestions.vue
app/assets/javascripts/vue_shared/components/modal_copy_button.vue
app/assets/javascripts/vue_shared/components/ordered_layout.vue
app/assets/javascripts/vue_shared/components/paginated_table_with_search_and_tabs/paginated_table_with_search_and_tabs.vue
app/assets/javascripts/vue_shared/components/paginated_table_with_search_and_tabs/utils.js
app/assets/javascripts/vue_shared/components/project_selector/project_list_item.vue
app/assets/javascripts/vue_shared/components/registry/list_item.vue
app/assets/javascripts/vue_shared/components/registry/title_area.vue
app/assets/javascripts/vue_shared/components/rich_content_editor/rich_content_editor.vue
app/assets/javascripts/vue_shared/components/rich_content_editor/services/build_custom_renderer.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/build_html_to_markdown_renderer.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/editor_service.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/build_uneditable_token.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_html_block.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_identifier_instance_text.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_identifier_paragraph.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_softbreak.js
app/assets/javascripts/vue_shared/components/rich_content_editor/services/renderers/render_utils.js
## practical-wozniak ## practical-wozniak
app/assets/javascripts/vue_shared/components/rich_content_editor/services/sanitize_html.js app/assets/javascripts/vue_shared/components/rich_content_editor/services/sanitize_html.js
app/assets/javascripts/vue_shared/components/select2_select.vue app/assets/javascripts/vue_shared/components/select2_select.vue
......
...@@ -202,7 +202,7 @@ export default { ...@@ -202,7 +202,7 @@ export default {
<template> <template>
<tooltip-on-truncate <tooltip-on-truncate
:title="timeWindowText" :title="timeWindowText"
:truncate-target="elem => elem.querySelector('.gl-dropdown-toggle-text')" :truncate-target="(elem) => elem.querySelector('.gl-dropdown-toggle-text')"
placement="top" placement="top"
class="d-inline-block" class="d-inline-block"
> >
......
...@@ -20,12 +20,12 @@ export default { ...@@ -20,12 +20,12 @@ export default {
state: { state: {
default: null, default: null,
required: true, required: true,
validator: prop => typeof prop === 'boolean' || prop === null, validator: (prop) => typeof prop === 'boolean' || prop === null,
}, },
value: { value: {
default: null, default: null,
required: false, required: false,
validator: prop => typeof prop === 'string' || prop === null, validator: (prop) => typeof prop === 'string' || prop === null,
}, },
label: { label: {
type: String, type: String,
......
...@@ -25,7 +25,7 @@ export const defaultTimeRanges = [ ...@@ -25,7 +25,7 @@ export const defaultTimeRanges = [
}, },
]; ];
export const defaultTimeRange = defaultTimeRanges.find(tr => tr.default); export const defaultTimeRange = defaultTimeRanges.find((tr) => tr.default);
export const dateFormats = { export const dateFormats = {
/** /**
...@@ -49,7 +49,7 @@ export const dateFormats = { ...@@ -49,7 +49,7 @@ export const dateFormats = {
* @param {string} value - Value as typed by the user * @param {string} value - Value as typed by the user
* @returns true if the value can be parsed as a valid date, false otherwise * @returns true if the value can be parsed as a valid date, false otherwise
*/ */
export const isValidInputString = value => { export const isValidInputString = (value) => {
try { try {
// dateformat throws error that can be caught. // dateformat throws error that can be caught.
// This is better than using `new Date()` // This is better than using `new Date()`
......
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
type: String, type: String,
required: false, required: false,
default: 'md', default: 'md',
validator: value => sizeVariants.includes(value), validator: (value) => sizeVariants.includes(value),
}, },
headerTitleText: { headerTitleText: {
type: String, type: String,
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
type: String, type: String,
required: false, required: false,
default: 'primary', default: 'primary',
validator: value => buttonVariants.includes(value), validator: (value) => buttonVariants.includes(value),
}, },
footerPrimaryButtonText: { footerPrimaryButtonText: {
type: String, type: String,
......
...@@ -22,7 +22,7 @@ export default { ...@@ -22,7 +22,7 @@ export default {
.post(this.path, { .post(this.path, {
feature_name: this.featureId, feature_name: this.featureId,
}) })
.catch(e => { .catch((e) => {
// eslint-disable-next-line @gitlab/require-i18n-strings, no-console // eslint-disable-next-line @gitlab/require-i18n-strings, no-console
console.error('Failed to dismiss message.', e); console.error('Failed to dismiss message.', e);
}); });
......
...@@ -128,7 +128,7 @@ export default { ...@@ -128,7 +128,7 @@ export default {
this.focusedIndex = 0; this.focusedIndex = 0;
} }
Mousetrap.bind(['t', 'mod+p'], e => { Mousetrap.bind(['t', 'mod+p'], (e) => {
if (e.preventDefault) { if (e.preventDefault) {
e.preventDefault(); e.preventDefault();
} }
......
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
type: String, type: String,
required: false, required: false,
default: '', default: '',
validator: value => value === '' || /(_desc)|(_asc)/g.test(value), validator: (value) => value === '' || /(_desc)|(_asc)/g.test(value),
}, },
showCheckbox: { showCheckbox: {
type: Boolean, type: Boolean,
...@@ -89,7 +89,7 @@ export default { ...@@ -89,7 +89,7 @@ export default {
if (this.initialSortBy) { if (this.initialSortBy) {
selectedSortOption = this.sortOptions selectedSortOption = this.sortOptions
.filter( .filter(
sortBy => (sortBy) =>
sortBy.sortDirection.ascending === this.initialSortBy || sortBy.sortDirection.ascending === this.initialSortBy ||
sortBy.sortDirection.descending === this.initialSortBy, sortBy.sortDirection.descending === this.initialSortBy,
) )
...@@ -204,12 +204,12 @@ export default { ...@@ -204,12 +204,12 @@ export default {
this.recentSearchesStore = new RecentSearchesStore({ this.recentSearchesStore = new RecentSearchesStore({
isLocalStorageAvailable: RecentSearchesService.isAvailable(), isLocalStorageAvailable: RecentSearchesService.isAvailable(),
allowedKeys: this.tokens.map(token => token.type), allowedKeys: this.tokens.map((token) => token.type),
}); });
this.recentSearchesPromise = this.recentSearchesService this.recentSearchesPromise = this.recentSearchesService
.fetch() .fetch()
.catch(error => { .catch((error) => {
if (error.name === 'RecentSearchesServiceError') return undefined; if (error.name === 'RecentSearchesServiceError') return undefined;
createFlash(__('An error occurred while parsing recent searches')); createFlash(__('An error occurred while parsing recent searches'));
...@@ -217,7 +217,7 @@ export default { ...@@ -217,7 +217,7 @@ export default {
// Gracefully fail to empty array // Gracefully fail to empty array
return []; return [];
}) })
.then(searches => { .then((searches) => {
if (!searches) return; if (!searches) return;
// Put any searches that may have come in before // Put any searches that may have come in before
...@@ -250,7 +250,7 @@ export default { ...@@ -250,7 +250,7 @@ export default {
* spaces. * spaces.
*/ */
removeQuotesEnclosure(filters = []) { removeQuotesEnclosure(filters = []) {
return filters.map(filter => { return filters.map((filter) => {
if (typeof filter === 'object') { if (typeof filter === 'object') {
const valueString = filter.value.data; const valueString = filter.value.data;
return { return {
...@@ -305,8 +305,8 @@ export default { ...@@ -305,8 +305,8 @@ export default {
}, },
historyTokenOptionTitle(historyToken) { historyTokenOptionTitle(historyToken) {
const tokenOption = this.tokens const tokenOption = this.tokens
.find(token => token.type === historyToken.type) .find((token) => token.type === historyToken.type)
?.options?.find(option => option.value === historyToken.value.data); ?.options?.find((option) => option.value === historyToken.value.data);
if (!tokenOption?.title) { if (!tokenOption?.title) {
return historyToken.value.data; return historyToken.value.data;
......
...@@ -8,7 +8,7 @@ import { queryToObject } from '~/lib/utils/url_utility'; ...@@ -8,7 +8,7 @@ import { queryToObject } from '~/lib/utils/url_utility';
* *
* @returns {String} String without any enclosure * @returns {String} String without any enclosure
*/ */
export const stripQuotes = value => value.replace(/^('|")(.*)('|")$/, '$2'); export const stripQuotes = (value) => value.replace(/^('|")(.*)('|")$/, '$2');
/** /**
* This method removes duplicate tokens from tokens array. * This method removes duplicate tokens from tokens array.
...@@ -17,7 +17,7 @@ export const stripQuotes = value => value.replace(/^('|")(.*)('|")$/, '$2'); ...@@ -17,7 +17,7 @@ export const stripQuotes = value => value.replace(/^('|")(.*)('|")$/, '$2');
* *
* @returns {Array} Unique array of tokens * @returns {Array} Unique array of tokens
*/ */
export const uniqueTokens = tokens => { export const uniqueTokens = (tokens) => {
const knownTokens = []; const knownTokens = [];
return tokens.reduce((uniques, token) => { return tokens.reduce((uniques, token) => {
if (typeof token === 'object' && token.type !== 'filtered-search-term') { if (typeof token === 'object' && token.type !== 'filtered-search-term') {
...@@ -61,7 +61,7 @@ export function prepareTokens(filters = {}) { ...@@ -61,7 +61,7 @@ export function prepareTokens(filters = {}) {
return memo; return memo;
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
return [...memo, ...value.map(filterValue => createToken(key, filterValue))]; return [...memo, ...value.map((filterValue) => createToken(key, filterValue))];
} }
return [...memo, createToken(key, value)]; return [...memo, createToken(key, value)];
...@@ -99,8 +99,8 @@ export function filterToQueryObject(filters = {}) { ...@@ -99,8 +99,8 @@ export function filterToQueryObject(filters = {}) {
let selected; let selected;
let unselected; let unselected;
if (Array.isArray(filter)) { if (Array.isArray(filter)) {
selected = filter.filter(item => item.operator === '=').map(item => item.value); selected = filter.filter((item) => item.operator === '=').map((item) => item.value);
unselected = filter.filter(item => item.operator === '!=').map(item => item.value); unselected = filter.filter((item) => item.operator === '!=').map((item) => item.value);
} else { } else {
selected = filter?.operator === '=' ? filter.value : null; selected = filter?.operator === '=' ? filter.value : null;
unselected = filter?.operator === '!=' ? filter.value : null; unselected = filter?.operator === '!=' ? filter.value : null;
...@@ -155,7 +155,7 @@ export function urlQueryToFilter(query = '') { ...@@ -155,7 +155,7 @@ export function urlQueryToFilter(query = '') {
previousValues = memo[filterName]; previousValues = memo[filterName];
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
const newAdditions = value.filter(Boolean).map(item => ({ value: item, operator })); const newAdditions = value.filter(Boolean).map((item) => ({ value: item, operator }));
return { ...memo, [filterName]: [...previousValues, ...newAdditions] }; return { ...memo, [filterName]: [...previousValues, ...newAdditions] };
} }
......
...@@ -17,7 +17,7 @@ export function fetchBranches({ commit, state }, search = '') { ...@@ -17,7 +17,7 @@ export function fetchBranches({ commit, state }, search = '') {
commit(types.REQUEST_BRANCHES); commit(types.REQUEST_BRANCHES);
return Api.branches(projectEndpoint, search) return Api.branches(projectEndpoint, search)
.then(response => { .then((response) => {
commit(types.RECEIVE_BRANCHES_SUCCESS, response.data); commit(types.RECEIVE_BRANCHES_SUCCESS, response.data);
return response; return response;
}) })
...@@ -34,7 +34,7 @@ export const fetchMilestones = ({ commit, state }, search_title = '') => { ...@@ -34,7 +34,7 @@ export const fetchMilestones = ({ commit, state }, search_title = '') => {
return axios return axios
.get(milestonesEndpoint, { params: { search_title } }) .get(milestonesEndpoint, { params: { search_title } })
.then(response => { .then((response) => {
commit(types.RECEIVE_MILESTONES_SUCCESS, response.data); commit(types.RECEIVE_MILESTONES_SUCCESS, response.data);
return response; return response;
}) })
...@@ -50,7 +50,7 @@ export const fetchLabels = ({ commit, state }, search = '') => { ...@@ -50,7 +50,7 @@ export const fetchLabels = ({ commit, state }, search = '') => {
return axios return axios
.get(state.labelsEndpoint, { params: { search } }) .get(state.labelsEndpoint, { params: { search } })
.then(response => { .then((response) => {
commit(types.RECEIVE_LABELS_SUCCESS, response.data); commit(types.RECEIVE_LABELS_SUCCESS, response.data);
return response; return response;
}) })
...@@ -67,13 +67,13 @@ function fetchUser(options = {}) { ...@@ -67,13 +67,13 @@ function fetchUser(options = {}) {
let fetchUserPromise; let fetchUserPromise;
if (projectEndpoint) { if (projectEndpoint) {
fetchUserPromise = Api.projectUsers(projectEndpoint, query).then(data => ({ data })); fetchUserPromise = Api.projectUsers(projectEndpoint, query).then((data) => ({ data }));
} else { } else {
fetchUserPromise = Api.groupMembers(groupEndpoint, { query }); fetchUserPromise = Api.groupMembers(groupEndpoint, { query });
} }
return fetchUserPromise return fetchUserPromise
.then(response => { .then((response) => {
commit(`RECEIVE_${action}_SUCCESS`, response.data); commit(`RECEIVE_${action}_SUCCESS`, response.data);
return response; return response;
}) })
......
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
return this.value.data.toLowerCase(); return this.value.data.toLowerCase();
}, },
activeAuthor() { activeAuthor() {
return this.authors.find(author => author.username.toLowerCase() === this.currentValue); return this.authors.find((author) => author.username.toLowerCase() === this.currentValue);
}, },
}, },
watch: { watch: {
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
: this.config.fetchAuthors(searchTerm); : this.config.fetchAuthors(searchTerm);
fetchPromise fetchPromise
.then(res => { .then((res) => {
// We'd want to avoid doing this check but // We'd want to avoid doing this check but
// users.json and /groups/:id/members & /projects/:id/users // users.json and /groups/:id/members & /projects/:id/users
// return response differently. // return response differently.
......
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
return this.value.data.toLowerCase(); return this.value.data.toLowerCase();
}, },
activeBranch() { activeBranch() {
return this.branches.find(branch => branch.name.toLowerCase() === this.currentValue); return this.branches.find((branch) => branch.name.toLowerCase() === this.currentValue);
}, },
}, },
watch: { watch: {
......
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
}, },
activeLabel() { activeLabel() {
return this.labels.find( return this.labels.find(
label => label.title.toLowerCase() === stripQuotes(this.currentValue), (label) => label.title.toLowerCase() === stripQuotes(this.currentValue),
); );
}, },
containerStyle() { containerStyle() {
...@@ -74,7 +74,7 @@ export default { ...@@ -74,7 +74,7 @@ export default {
this.loading = true; this.loading = true;
this.config this.config
.fetchLabels(searchTerm) .fetchLabels(searchTerm)
.then(res => { .then((res) => {
// We'd want to avoid doing this check but // We'd want to avoid doing this check but
// labels.json and /groups/:id/labels & /projects/:id/labels // labels.json and /groups/:id/labels & /projects/:id/labels
// return response differently. // return response differently.
......
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
}, },
activeMilestone() { activeMilestone() {
return this.milestones.find( return this.milestones.find(
milestone => milestone.title.toLowerCase() === stripQuotes(this.currentValue), (milestone) => milestone.title.toLowerCase() === stripQuotes(this.currentValue),
); );
}, },
}, },
......
...@@ -28,7 +28,7 @@ export default { ...@@ -28,7 +28,7 @@ export default {
}, },
computed: { computed: {
config() { config() {
return this.autocompleteTypes.map(type => ({ return this.autocompleteTypes.map((type) => ({
...tributeConfig[type].config, ...tributeConfig[type].config,
loadingItemTemplate: `<span class="gl-spinner gl-vertical-align-text-bottom gl-ml-3 gl-mr-2"></span>${__( loadingItemTemplate: `<span class="gl-spinner gl-vertical-align-text-bottom gl-ml-3 gl-mr-2"></span>${__(
'Loading', 'Loading',
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
if (!this.assignees || !isAssigneesLengthSame) { if (!this.assignees || !isAssigneesLengthSame) {
this.assignees = this.assignees =
SidebarMediator.singleton?.store?.assignees?.map(assignee => assignee.username) || []; SidebarMediator.singleton?.store?.assignees?.map((assignee) => assignee.username) || [];
} }
}, },
filterValues(type) { filterValues(type) {
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
} else if (this.dataSources[type]) { } else if (this.dataSources[type]) {
axios axios
.get(this.dataSources[type]) .get(this.dataSources[type])
.then(response => { .then((response) => {
this.cache[type] = response.data; this.cache[type] = response.data;
processValues(this.filterValues(type)); processValues(this.filterValues(type));
}) })
......
...@@ -27,7 +27,7 @@ export const tributeConfig = { ...@@ -27,7 +27,7 @@ export const tributeConfig = {
[GfmAutocompleteType.Emojis]: { [GfmAutocompleteType.Emojis]: {
config: { config: {
trigger: ':', trigger: ':',
lookup: value => value, lookup: (value) => value,
menuItemTemplate: ({ original }) => `${original} ${Emoji.glEmojiTag(original)}`, menuItemTemplate: ({ original }) => `${original} ${Emoji.glEmojiTag(original)}`,
selectTemplate: ({ original }) => `:${original}:`, selectTemplate: ({ original }) => `:${original}:`,
}, },
...@@ -36,7 +36,7 @@ export const tributeConfig = { ...@@ -36,7 +36,7 @@ export const tributeConfig = {
[GfmAutocompleteType.Issues]: { [GfmAutocompleteType.Issues]: {
config: { config: {
trigger: '#', trigger: '#',
lookup: value => `${value.iid}${value.title}`, lookup: (value) => `${value.iid}${value.title}`,
menuItemTemplate: ({ original }) => menuItemTemplate: ({ original }) =>
`<small>${original.reference || original.iid}</small> ${escape(original.title)}`, `<small>${original.reference || original.iid}</small> ${escape(original.title)}`,
selectTemplate: ({ original }) => original.reference || `#${original.iid}`, selectTemplate: ({ original }) => original.reference || `#${original.iid}`,
...@@ -57,11 +57,11 @@ export const tributeConfig = { ...@@ -57,11 +57,11 @@ export const tributeConfig = {
}, },
filterValues({ collection, fullText, selectionStart }) { filterValues({ collection, fullText, selectionStart }) {
if (doesCurrentLineStartWith('/label', fullText, selectionStart)) { if (doesCurrentLineStartWith('/label', fullText, selectionStart)) {
return collection.filter(label => !label.set); return collection.filter((label) => !label.set);
} }
if (doesCurrentLineStartWith('/unlabel', fullText, selectionStart)) { if (doesCurrentLineStartWith('/unlabel', fullText, selectionStart)) {
return collection.filter(label => label.set); return collection.filter((label) => label.set);
} }
return collection; return collection;
...@@ -72,7 +72,7 @@ export const tributeConfig = { ...@@ -72,7 +72,7 @@ export const tributeConfig = {
config: { config: {
trigger: '@', trigger: '@',
fillAttr: 'username', fillAttr: 'username',
lookup: value => lookup: (value) =>
value.type === groupType ? last(value.name.split(' / ')) : `${value.name}${value.username}`, value.type === groupType ? last(value.name.split(' / ')) : `${value.name}${value.username}`,
menuItemTemplate: ({ original }) => { menuItemTemplate: ({ original }) => {
const commonClasses = 'gl-avatar gl-avatar-s24 gl-flex-shrink-0'; const commonClasses = 'gl-avatar gl-avatar-s24 gl-flex-shrink-0';
...@@ -113,11 +113,11 @@ export const tributeConfig = { ...@@ -113,11 +113,11 @@ export const tributeConfig = {
}, },
filterValues({ assignees, collection, fullText, selectionStart }) { filterValues({ assignees, collection, fullText, selectionStart }) {
if (doesCurrentLineStartWith('/assign', fullText, selectionStart)) { if (doesCurrentLineStartWith('/assign', fullText, selectionStart)) {
return collection.filter(member => !assignees.includes(member.username)); return collection.filter((member) => !assignees.includes(member.username));
} }
if (doesCurrentLineStartWith('/unassign', fullText, selectionStart)) { if (doesCurrentLineStartWith('/unassign', fullText, selectionStart)) {
return collection.filter(member => assignees.includes(member.username)); return collection.filter((member) => assignees.includes(member.username));
} }
return collection; return collection;
...@@ -127,7 +127,7 @@ export const tributeConfig = { ...@@ -127,7 +127,7 @@ export const tributeConfig = {
[GfmAutocompleteType.MergeRequests]: { [GfmAutocompleteType.MergeRequests]: {
config: { config: {
trigger: '!', trigger: '!',
lookup: value => `${value.iid}${value.title}`, lookup: (value) => `${value.iid}${value.title}`,
menuItemTemplate: ({ original }) => menuItemTemplate: ({ original }) =>
`<small>${original.reference || original.iid}</small> ${escape(original.title)}`, `<small>${original.reference || original.iid}</small> ${escape(original.title)}`,
selectTemplate: ({ original }) => original.reference || `!${original.iid}`, selectTemplate: ({ original }) => original.reference || `!${original.iid}`,
...@@ -147,7 +147,7 @@ export const tributeConfig = { ...@@ -147,7 +147,7 @@ export const tributeConfig = {
config: { config: {
trigger: '/', trigger: '/',
fillAttr: 'name', fillAttr: 'name',
lookup: value => `${value.name}${value.aliases.join()}`, lookup: (value) => `${value.name}${value.aliases.join()}`,
menuItemTemplate: ({ original }) => { menuItemTemplate: ({ original }) => {
const aliases = original.aliases.length const aliases = original.aliases.length
? `<small>(or /${original.aliases.join(', /')})</small>` ? `<small>(or /${original.aliases.join(', /')})</small>`
...@@ -175,7 +175,7 @@ export const tributeConfig = { ...@@ -175,7 +175,7 @@ export const tributeConfig = {
config: { config: {
trigger: '$', trigger: '$',
fillAttr: 'id', fillAttr: 'id',
lookup: value => `${value.id}${value.title}`, lookup: (value) => `${value.id}${value.title}`,
menuItemTemplate: ({ original }) => `<small>${original.id}</small> ${escape(original.title)}`, menuItemTemplate: ({ original }) => `<small>${original.id}</small> ${escape(original.title)}`,
}, },
}, },
......
...@@ -15,5 +15,5 @@ function cleanSuggestionLine(line = {}) { ...@@ -15,5 +15,5 @@ function cleanSuggestionLine(line = {}) {
} }
export function selectDiffLines(lines) { export function selectDiffLines(lines) {
return lines.filter(line => line.type !== 'match').map(line => cleanSuggestionLine(line)); return lines.filter((line) => line.type !== 'match').map((line) => cleanSuggestionLine(line));
} }
...@@ -158,7 +158,7 @@ export default { ...@@ -158,7 +158,7 @@ export default {
const mediaInPreview = this.$refs['markdown-preview'].querySelectorAll('video, audio'); const mediaInPreview = this.$refs['markdown-preview'].querySelectorAll('video, audio');
if (mediaInPreview) { if (mediaInPreview) {
mediaInPreview.forEach(media => { mediaInPreview.forEach((media) => {
media.pause(); media.pause();
}); });
} }
...@@ -199,7 +199,7 @@ export default { ...@@ -199,7 +199,7 @@ export default {
this.markdownPreview = __('Loading…'); this.markdownPreview = __('Loading…');
axios axios
.post(this.markdownPreviewPath, { text: this.textareaValue }) .post(this.markdownPreviewPath, { text: this.textareaValue })
.then(response => this.renderMarkdown(response.data)) .then((response) => this.renderMarkdown(response.data))
.catch(() => new Flash(__('Error loading markdown preview'))); .catch(() => new Flash(__('Error loading markdown preview')));
} else { } else {
this.renderMarkdown(); this.renderMarkdown();
......
...@@ -110,7 +110,7 @@ export default { ...@@ -110,7 +110,7 @@ export default {
const area = this.$el.parentNode.querySelector('textarea'); const area = this.$el.parentNode.querySelector('textarea');
CopyAsGFM.nodeToGFM(transformed) CopyAsGFM.nodeToGFM(transformed)
.then(gfm => { .then((gfm) => {
CopyAsGFM.insertPastedText(area, documentFragment.textContent, CopyAsGFM.quoted(gfm)); CopyAsGFM.insertPastedText(area, documentFragment.textContent, CopyAsGFM.quoted(gfm));
}) })
.catch(() => {}); .catch(() => {});
......
...@@ -98,11 +98,11 @@ export default { ...@@ -98,11 +98,11 @@ export default {
this.$emit('applyBatch', { flashContainer: this.$el }); this.$emit('applyBatch', { flashContainer: this.$el });
}); });
suggestionDiff.$on('addToBatch', suggestionId => { suggestionDiff.$on('addToBatch', (suggestionId) => {
this.$emit('addToBatch', suggestionId); this.$emit('addToBatch', suggestionId);
}); });
suggestionDiff.$on('removeFromBatch', suggestionId => { suggestionDiff.$on('removeFromBatch', (suggestionId) => {
this.$emit('removeFromBatch', suggestionId); this.$emit('removeFromBatch', suggestionId);
}); });
......
...@@ -70,14 +70,14 @@ export default { ...@@ -70,14 +70,14 @@ export default {
document.body, document.body,
}); });
this.clipboard this.clipboard
.on('success', e => { .on('success', (e) => {
this.$root.$emit('bv::hide::tooltip', this.id); this.$root.$emit('bv::hide::tooltip', this.id);
this.$emit('success', e); this.$emit('success', e);
// Clear the selection and blur the trigger so it loses its border // Clear the selection and blur the trigger so it loses its border
e.clearSelection(); e.clearSelection();
e.trigger.blur(); e.trigger.blur();
}) })
.on('error', e => this.$emit('error', e)); .on('error', (e) => this.$emit('error', e));
}); });
}, },
destroyed() { destroyed() {
......
...@@ -4,7 +4,7 @@ export default { ...@@ -4,7 +4,7 @@ export default {
render(h, context) { render(h, context) {
const { slotKeys } = context.props; const { slotKeys } = context.props;
const slots = context.slots(); const slots = context.slots();
const children = slotKeys.map(key => slots[key]).filter(x => x); const children = slotKeys.map((key) => slots[key]).filter((x) => x);
return children; return children;
}, },
......
...@@ -203,7 +203,7 @@ export default { ...@@ -203,7 +203,7 @@ export default {
this.resetPagination(); this.resetPagination();
const filterParams = { authorUsername: '', assigneeUsername: '', search: '' }; const filterParams = { authorUsername: '', assigneeUsername: '', search: '' };
filters.forEach(filter => { filters.forEach((filter) => {
if (typeof filter === 'object') { if (typeof filter === 'object') {
switch (filter.type) { switch (filter.type) {
case 'author_username': case 'author_username':
......
...@@ -6,6 +6,6 @@ import { __ } from '~/locale'; ...@@ -6,6 +6,6 @@ import { __ } from '~/locale';
* @param {String} value * @param {String} value
* @returns {String} * @returns {String}
*/ */
export const isAny = value => { export const isAny = (value) => {
return value === __('Any') ? '' : value; return value === __('Any') ? '' : value;
}; };
...@@ -13,7 +13,7 @@ export default { ...@@ -13,7 +13,7 @@ export default {
project: { project: {
type: Object, type: Object,
required: true, required: true,
validator: p => validator: (p) =>
(Number.isFinite(p.id) || isString(p.id)) && (Number.isFinite(p.id) || isString(p.id)) &&
isString(p.name) && isString(p.name) &&
(isString(p.name_with_namespace) || isString(p.nameWithNamespace)), (isString(p.name_with_namespace) || isString(p.nameWithNamespace)),
......
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.detailsSlots = Object.keys(this.$slots).filter(k => k.startsWith('details-')); this.detailsSlots = Object.keys(this.$slots).filter((k) => k.startsWith('details-'));
}, },
methods: { methods: {
toggleDetails() { toggleDetails() {
......
...@@ -38,11 +38,11 @@ export default { ...@@ -38,11 +38,11 @@ export default {
}, },
async mounted() { async mounted() {
const METADATA_PREFIX = 'metadata-'; const METADATA_PREFIX = 'metadata-';
this.metadataSlots = Object.keys(this.$slots).filter(k => k.startsWith(METADATA_PREFIX)); this.metadataSlots = Object.keys(this.$slots).filter((k) => k.startsWith(METADATA_PREFIX));
// we need to wait for next tick to ensure that dynamic names slots are picked up // we need to wait for next tick to ensure that dynamic names slots are picked up
await this.$nextTick(); await this.$nextTick();
this.metadataSlots = Object.keys(this.$slots).filter(k => k.startsWith(METADATA_PREFIX)); this.metadataSlots = Object.keys(this.$slots).filter((k) => k.startsWith(METADATA_PREFIX));
}, },
}; };
</script> </script>
......
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
components: { components: {
ToastEditor: () => ToastEditor: () =>
import(/* webpackChunkName: 'toast_editor' */ '@toast-ui/vue-editor').then( import(/* webpackChunkName: 'toast_editor' */ '@toast-ui/vue-editor').then(
toast => toast.Editor, (toast) => toast.Editor,
), ),
AddImageModal, AddImageModal,
InsertVideoModal, InsertVideoModal,
......
...@@ -17,12 +17,12 @@ const listItemRenderers = [renderListItem]; ...@@ -17,12 +17,12 @@ const listItemRenderers = [renderListItem];
const softbreakRenderers = [renderSoftbreak]; const softbreakRenderers = [renderSoftbreak];
const executeRenderer = (renderers, node, context) => { const executeRenderer = (renderers, node, context) => {
const availableRenderer = renderers.find(renderer => renderer.canRender(node, context)); const availableRenderer = renderers.find((renderer) => renderer.canRender(node, context));
return availableRenderer ? availableRenderer.render(node, context) : context.origin(); return availableRenderer ? availableRenderer.render(node, context) : context.origin();
}; };
const buildCustomHTMLRenderer = customRenderers => { const buildCustomHTMLRenderer = (customRenderers) => {
const renderersByType = { const renderersByType = {
...customRenderers, ...customRenderers,
htmlBlock: union(htmlBlockRenderers, customRenderers?.htmlBlock), htmlBlock: union(htmlBlockRenderers, customRenderers?.htmlBlock),
...@@ -34,7 +34,7 @@ const buildCustomHTMLRenderer = customRenderers => { ...@@ -34,7 +34,7 @@ const buildCustomHTMLRenderer = customRenderers => {
softbreak: union(softbreakRenderers, customRenderers?.softbreak), softbreak: union(softbreakRenderers, customRenderers?.softbreak),
}; };
return mapValues(renderersByType, renderers => { return mapValues(renderersByType, (renderers) => {
return (node, context) => executeRenderer(renderers, node, context); return (node, context) => executeRenderer(renderers, node, context);
}); });
}; };
......
...@@ -9,7 +9,7 @@ const DEFAULTS = { ...@@ -9,7 +9,7 @@ const DEFAULTS = {
emphasis: '_', emphasis: '_',
}; };
const countIndentSpaces = text => { const countIndentSpaces = (text) => {
const matches = text.match(/^\s+/m); const matches = text.match(/^\s+/m);
return matches ? matches[0].length : 0; return matches ? matches[0].length : 0;
...@@ -52,7 +52,7 @@ const buildHTMLToMarkdownRender = (baseRenderer, formattingPreferences = {}) => ...@@ -52,7 +52,7 @@ const buildHTMLToMarkdownRender = (baseRenderer, formattingPreferences = {}) =>
const firstLevelIndentSpacesCount = countIndentSpaces(baseResult) || 1; const firstLevelIndentSpacesCount = countIndentSpaces(baseResult) || 1;
const reindentedList = baseResult const reindentedList = baseResult
.split('\n') .split('\n')
.map(line => { .map((line) => {
const itemIndentSpacesCount = countIndentSpaces(line); const itemIndentSpacesCount = countIndentSpaces(line);
const nestingLevel = Math.ceil(itemIndentSpacesCount / firstLevelIndentSpacesCount); const nestingLevel = Math.ceil(itemIndentSpacesCount / firstLevelIndentSpacesCount);
const indentSpaces = repeat(' ', subListIndentSpaces * nestingLevel); const indentSpaces = repeat(' ', subListIndentSpaces * nestingLevel);
......
...@@ -6,7 +6,7 @@ import buildCustomHTMLRenderer from './build_custom_renderer'; ...@@ -6,7 +6,7 @@ import buildCustomHTMLRenderer from './build_custom_renderer';
import { TOOLBAR_ITEM_CONFIGS, VIDEO_ATTRIBUTES } from '../constants'; import { TOOLBAR_ITEM_CONFIGS, VIDEO_ATTRIBUTES } from '../constants';
import sanitizeHTML from './sanitize_html'; import sanitizeHTML from './sanitize_html';
const buildWrapper = propsData => { const buildWrapper = (propsData) => {
const instance = new Vue({ const instance = new Vue({
render(createElement) { render(createElement) {
return createElement(ToolbarItem, propsData); return createElement(ToolbarItem, propsData);
...@@ -17,7 +17,7 @@ const buildWrapper = propsData => { ...@@ -17,7 +17,7 @@ const buildWrapper = propsData => {
return instance.$el; return instance.$el;
}; };
const buildVideoIframe = src => { const buildVideoIframe = (src) => {
const wrapper = document.createElement('figure'); const wrapper = document.createElement('figure');
const iframe = document.createElement('iframe'); const iframe = document.createElement('iframe');
const videoAttributes = { ...VIDEO_ATTRIBUTES, src }; const videoAttributes = { ...VIDEO_ATTRIBUTES, src };
...@@ -48,7 +48,7 @@ const buildImg = (alt, originalSrc, file) => { ...@@ -48,7 +48,7 @@ const buildImg = (alt, originalSrc, file) => {
return img; return img;
}; };
export const generateToolbarItem = config => { export const generateToolbarItem = (config) => {
const { icon, classes, event, command, tooltip, isDivider } = config; const { icon, classes, event, command, tooltip, isDivider } = config;
if (isDivider) { if (isDivider) {
...@@ -92,14 +92,14 @@ export const insertVideo = ({ editor }, url) => { ...@@ -92,14 +92,14 @@ export const insertVideo = ({ editor }, url) => {
} }
}; };
export const getMarkdown = editorInstance => editorInstance.invoke('getMarkdown'); export const getMarkdown = (editorInstance) => editorInstance.invoke('getMarkdown');
/** /**
* This function allow us to extend Toast UI HTML to Markdown renderer. It is * This function allow us to extend Toast UI HTML to Markdown renderer. It is
* a temporary measure because Toast UI does not provide an API * a temporary measure because Toast UI does not provide an API
* to achieve this goal. * to achieve this goal.
*/ */
export const registerHTMLToMarkdownRenderer = editorApi => { export const registerHTMLToMarkdownRenderer = (editorApi) => {
const { renderer } = editorApi.toMarkOptions; const { renderer } = editorApi.toMarkOptions;
Object.assign(editorApi.toMarkOptions, { Object.assign(editorApi.toMarkOptions, {
...@@ -107,10 +107,10 @@ export const registerHTMLToMarkdownRenderer = editorApi => { ...@@ -107,10 +107,10 @@ export const registerHTMLToMarkdownRenderer = editorApi => {
}); });
}; };
export const getEditorOptions = externalOptions => { export const getEditorOptions = (externalOptions) => {
return defaults({ return defaults({
customHTMLRenderer: buildCustomHTMLRenderer(externalOptions?.customRenderers), customHTMLRenderer: buildCustomHTMLRenderer(externalOptions?.customRenderers),
toolbarItems: TOOLBAR_ITEM_CONFIGS.map(toolbarItem => generateToolbarItem(toolbarItem)), toolbarItems: TOOLBAR_ITEM_CONFIGS.map((toolbarItem) => generateToolbarItem(toolbarItem)),
customHTMLSanitizer: html => sanitizeHTML(html), customHTMLSanitizer: (html) => sanitizeHTML(html),
}); });
}; };
...@@ -32,20 +32,20 @@ export const buildUneditableCloseTokens = (token, tagType = TAG_TYPES.block) => ...@@ -32,20 +32,20 @@ export const buildUneditableCloseTokens = (token, tagType = TAG_TYPES.block) =>
// Complete helpers (open plus close) // Complete helpers (open plus close)
export const buildTextToken = content => buildToken('text', null, { content }); export const buildTextToken = (content) => buildToken('text', null, { content });
export const buildUneditableBlockTokens = token => { export const buildUneditableBlockTokens = (token) => {
return [...buildUneditableOpenTokens(token), buildUneditableCloseToken()]; return [...buildUneditableOpenTokens(token), buildUneditableCloseToken()];
}; };
export const buildUneditableInlineTokens = token => { export const buildUneditableInlineTokens = (token) => {
return [ return [
...buildUneditableOpenTokens(token, TAG_TYPES.inline), ...buildUneditableOpenTokens(token, TAG_TYPES.inline),
buildUneditableCloseToken(TAG_TYPES.inline), buildUneditableCloseToken(TAG_TYPES.inline),
]; ];
}; };
export const buildUneditableHtmlAsTextTokens = node => { export const buildUneditableHtmlAsTextTokens = (node) => {
/* /*
Toast UI internally appends ' data-tomark-pass ' attribute flags so it can target certain Toast UI internally appends ' data-tomark-pass ' attribute flags so it can target certain
nested nodes for internal use during Markdown <=> WYSIWYG conversions. In our case, we want nested nodes for internal use during Markdown <=> WYSIWYG conversions. In our case, we want
......
...@@ -2,7 +2,7 @@ import { buildUneditableHtmlAsTextTokens } from './build_uneditable_token'; ...@@ -2,7 +2,7 @@ import { buildUneditableHtmlAsTextTokens } from './build_uneditable_token';
import { ALLOWED_VIDEO_ORIGINS } from '../../constants'; import { ALLOWED_VIDEO_ORIGINS } from '../../constants';
import { getURLOrigin } from '~/lib/utils/url_utility'; import { getURLOrigin } from '~/lib/utils/url_utility';
const isVideoFrame = html => { const isVideoFrame = (html) => {
const parser = new DOMParser(); const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html'); const doc = parser.parseFromString(html, 'text/html');
const { const {
...@@ -18,6 +18,6 @@ const canRender = ({ type, literal }) => { ...@@ -18,6 +18,6 @@ const canRender = ({ type, literal }) => {
return type === 'htmlBlock' && !isVideoFrame(literal); return type === 'htmlBlock' && !isVideoFrame(literal);
}; };
const render = node => buildUneditableHtmlAsTextTokens(node); const render = (node) => buildUneditableHtmlAsTextTokens(node);
export default { canRender, render }; export default { canRender, render };
...@@ -17,7 +17,7 @@ Regexp notes: ...@@ -17,7 +17,7 @@ Regexp notes:
*/ */
const identifierInstanceRegex = /((?:\[.+?\]){1}(?:\[\]|\[.+?\])?(?!:))/g; const identifierInstanceRegex = /((?:\[.+?\]){1}(?:\[\]|\[.+?\])?(?!:))/g;
const isIdentifierInstance = literal => { const isIdentifierInstance = (literal) => {
// Reset lastIndex as global flag in regexp are stateful (https://stackoverflow.com/a/11477448) // Reset lastIndex as global flag in regexp are stateful (https://stackoverflow.com/a/11477448)
identifierInstanceRegex.lastIndex = 0; identifierInstanceRegex.lastIndex = 0;
return identifierInstanceRegex.test(literal); return identifierInstanceRegex.test(literal);
...@@ -25,9 +25,9 @@ const isIdentifierInstance = literal => { ...@@ -25,9 +25,9 @@ const isIdentifierInstance = literal => {
const canRender = ({ literal }) => isIdentifierInstance(literal); const canRender = ({ literal }) => isIdentifierInstance(literal);
const tokenize = text => { const tokenize = (text) => {
const matches = text.split(identifierInstanceRegex); const matches = text.split(identifierInstanceRegex);
const tokens = matches.map(match => { const tokens = matches.map((match) => {
const token = buildTextToken(match); const token = buildTextToken(match);
return isIdentifierInstance(match) ? buildUneditableInlineTokens(token) : token; return isIdentifierInstance(match) ? buildUneditableInlineTokens(token) : token;
}); });
......
const identifierRegex = /(^\[.+\]: .+)/; const identifierRegex = /(^\[.+\]: .+)/;
const isIdentifier = text => { const isIdentifier = (text) => {
return identifierRegex.test(text); return identifierRegex.test(text);
}; };
......
const canRender = node => ['emph', 'strong'].includes(node.parent?.type); const canRender = (node) => ['emph', 'strong'].includes(node.parent?.type);
const render = () => ({ const render = () => ({
type: 'text', type: 'text',
content: ' ', content: ' ',
......
...@@ -11,9 +11,9 @@ export const renderUneditableBranch = (_, { entering, origin }) => ...@@ -11,9 +11,9 @@ export const renderUneditableBranch = (_, { entering, origin }) =>
const attributeDefinitionRegexp = /(^{:.+}$)/; const attributeDefinitionRegexp = /(^{:.+}$)/;
export const isAttributeDefinition = text => attributeDefinitionRegexp.test(text); export const isAttributeDefinition = (text) => attributeDefinitionRegexp.test(text);
const findAttributeDefinition = node => { const findAttributeDefinition = (node) => {
const literal = const literal =
node?.next?.firstChild?.literal || node?.firstChild?.firstChild?.next?.next?.literal; // for headings // for list items; node?.next?.firstChild?.literal || node?.firstChild?.firstChild?.next?.next?.literal; // for headings // for list items;
......
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