Commit a6788c1a authored by Kushal Pandya's avatar Kushal Pandya

Run through Prettier and remove ESLint disables

Formats the file to match Prettier rules
Removes all blacklisted ESLint rules
parent 02ccbb0a
/* eslint-disable no-new, no-unused-vars, consistent-return, no-else-return */
/* global GitLab */
import $ from 'jquery';
import Pikaday from 'pikaday';
import Autosave from './autosave';
......@@ -19,9 +16,11 @@ export default class IssuableForm {
this.handleSubmit = this.handleSubmit.bind(this);
this.wipRegex = /^\s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+\s*/i;
new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources).setup();
new UsersSelect();
new ZenMode();
this.gfmAutoComplete = new GfmAutoComplete(
gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources,
).setup();
this.usersSelect = new UsersSelect();
this.zenMode = new ZenMode();
this.titleField = this.form.find('input[name*="[title]"]');
this.descriptionField = this.form.find('textarea[name*="[description]"]');
......@@ -57,8 +56,16 @@ export default class IssuableForm {
}
initAutosave() {
new Autosave(this.titleField, [document.location.pathname, document.location.search, 'title']);
return new Autosave(this.descriptionField, [document.location.pathname, document.location.search, 'description']);
this.autosave = new Autosave(this.titleField, [
document.location.pathname,
document.location.search,
'title',
]);
return new Autosave(this.descriptionField, [
document.location.pathname,
document.location.search,
'description',
]);
}
handleSubmit() {
......@@ -74,7 +81,7 @@ export default class IssuableForm {
this.$wipExplanation = this.form.find('.js-wip-explanation');
this.$noWipExplanation = this.form.find('.js-no-wip-explanation');
if (!(this.$wipExplanation.length && this.$noWipExplanation.length)) {
return;
return undefined;
}
this.form.on('click', '.js-toggle-wip', this.toggleWip);
this.titleField.on('keyup blur', this.renderWipExplanation);
......@@ -89,11 +96,10 @@ export default class IssuableForm {
if (this.workInProgress()) {
this.$wipExplanation.show();
return this.$noWipExplanation.hide();
} else {
}
this.$wipExplanation.hide();
return this.$noWipExplanation.show();
}
}
toggleWip(event) {
event.preventDefault();
......@@ -110,7 +116,7 @@ export default class IssuableForm {
}
addWip() {
this.titleField.val(`WIP: ${(this.titleField.val())}`);
this.titleField.val(`WIP: ${this.titleField.val()}`);
}
initTargetBranchDropdown() {
......
......@@ -79,7 +79,8 @@ let timeagoInstance;
*/
export const getTimeago = () => {
if (!timeagoInstance) {
const localeRemaining = (number, index) => [
const localeRemaining = (number, index) =>
[
[s__('Timeago|just now'), s__('Timeago|right now')],
[s__('Timeago|%s seconds ago'), s__('Timeago|%s seconds remaining')],
[s__('Timeago|1 minute ago'), s__('Timeago|1 minute remaining')],
......@@ -96,7 +97,8 @@ export const getTimeago = () => {
[s__('Timeago|%s years ago'), s__('Timeago|%s years remaining')],
][index];
const locale = (number, index) => [
const locale = (number, index) =>
[
[s__('Timeago|just now'), s__('Timeago|right now')],
[s__('Timeago|%s seconds ago'), s__('Timeago|in %s seconds')],
[s__('Timeago|1 minute ago'), s__('Timeago|in 1 minute')],
......@@ -119,7 +121,7 @@ export const getTimeago = () => {
}
return timeagoInstance;
}
};
/**
* For the given element, renders a timeago instance.
......@@ -184,7 +186,7 @@ export const getDayDifference = (a, b) => {
* @param {Number} seconds
* @return {String}
*/
export const timeIntervalInWords = (intervalInSeconds) => {
export const timeIntervalInWords = intervalInSeconds => {
const secondsInteger = parseInt(intervalInSeconds, 10);
const minutes = Math.floor(secondsInteger / 60);
const seconds = secondsInteger - minutes * 60;
......@@ -196,7 +198,7 @@ export const timeIntervalInWords = (intervalInSeconds) => {
text = `${seconds} ${pluralize('second', seconds)}`;
}
return text;
}
};
export const dateInWords = (date, abbreviated = false, hideYear = false) => {
if (!date) return date;
......@@ -240,7 +242,7 @@ export const dateInWords = (date, abbreviated = false, hideYear = false) => {
}
return `${monthName} ${date.getDate()}, ${year}`;
}
};
/**
* Returns month name based on provided date.
......@@ -447,13 +449,13 @@ export const parseSeconds = (seconds, { daysPerWeek = 5, hoursPerDay = 8 } = {})
return periodCount;
});
}
};
/**
* Accepts a timeObject (see parseSeconds) and returns a condensed string representation of it
* (e.g. '1w 2d 3h 1m' or '1h 30m'). Zero value units are not included.
*/
export const stringifyTime = (timeObject) => {
export const stringifyTime = timeObject => {
const reducedTime = _.reduce(
timeObject,
(memo, unitValue, unitName) => {
......@@ -463,10 +465,11 @@ export const stringifyTime = (timeObject) => {
'',
).trim();
return reducedTime.length ? reducedTime : '0m';
}
};
/**
* Accepts a time string of any size (e.g. '1w 2d 3h 5m' or '1w 2d') and returns
* the first non-zero unit/value pair.
*/
export const abbreviateTime = (timeStr) => timeStr.split(' ').filter(unitStr => unitStr.charAt(0) !== '0')[0];
export const abbreviateTime = timeStr =>
timeStr.split(' ').filter(unitStr => unitStr.charAt(0) !== '0')[0];
<script>
import { __, sprintf } from '~/locale';
import { abbreviateTime } from '~/lib/utils/datetime_utility';
import icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
import { __, sprintf } from '~/locale';
import { abbreviateTime } from '~/lib/utils/datetime_utility';
import icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';
export default {
export default {
name: 'TimeTrackingCollapsedState',
components: {
icon,
......@@ -94,7 +94,7 @@
title = __('Time spent');
}
return sprintf('%{title}: %{text}', ({ title, text: this.text }));
return sprintf('%{title}: %{text}', { title, text: this.text });
},
tooltipText() {
return this.showNoTimeTrackingState ? __('Time tracking') : this.timeTrackedTooltipText;
......@@ -105,7 +105,7 @@
return abbreviateTime(timeStr);
},
},
};
};
</script>
<template>
......
......@@ -225,7 +225,7 @@ describe('prettyTime methods', () => {
expect(obj.hours).toBe(hours);
expect(obj.days).toBe(days);
expect(obj.weeks).toBe(weeks);
}
};
describe('parseSeconds', () => {
it('should correctly parse a negative value', () => {
......
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