Commit 9b1d8b4c authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 24 files: 8 of 8

Mandatory not to break master. Automatically created with prettier.
parent 57da6321
...@@ -11,11 +11,7 @@ const CACHE_PATHS = [ ...@@ -11,11 +11,7 @@ const CACHE_PATHS = [
const resolvePath = file => path.resolve(__dirname, '../..', file); const resolvePath = file => path.resolve(__dirname, '../..', file);
const readFile = file => fs.readFileSync(file); const readFile = file => fs.readFileSync(file);
const fileHash = buffer => const fileHash = buffer => crypto.createHash('md5').update(buffer).digest('hex');
crypto
.createHash('md5')
.update(buffer)
.digest('hex');
module.exports = () => { module.exports = () => {
const fileBuffers = CACHE_PATHS.map(resolvePath).map(readFile); const fileBuffers = CACHE_PATHS.map(resolvePath).map(readFile);
......
...@@ -104,7 +104,7 @@ if (specFilters.length) { ...@@ -104,7 +104,7 @@ if (specFilters.length) {
} }
// Karma configuration // Karma configuration
module.exports = function(config) { module.exports = function (config) {
process.env.TZ = 'Etc/UTC'; process.env.TZ = 'Etc/UTC';
const fixturesPath = `tmp/tests/frontend/fixtures${IS_EE ? '-ee' : ''}`; const fixturesPath = `tmp/tests/frontend/fixtures${IS_EE ? '-ee' : ''}`;
......
...@@ -344,7 +344,7 @@ module.exports = { ...@@ -344,7 +344,7 @@ module.exports = {
// webpack-rails only needs assetsByChunkName to function properly // webpack-rails only needs assetsByChunkName to function properly
new StatsWriterPlugin({ new StatsWriterPlugin({
filename: 'manifest.json', filename: 'manifest.json',
transform: function(data, opts) { transform: function (data, opts) {
const stats = opts.compiler.getStats().toJson({ const stats = opts.compiler.getStats().toJson({
chunkModules: false, chunkModules: false,
source: false, source: false,
......
...@@ -9,12 +9,7 @@ const exec = (command, args) => { ...@@ -9,12 +9,7 @@ const exec = (command, args) => {
return execFileSync(command, args, options); return execFileSync(command, args, options);
}; };
const execGitCmd = args => const execGitCmd = args => exec('git', args).trim().toString().split('\n').filter(Boolean);
exec('git', args)
.trim()
.toString()
.split('\n')
.filter(Boolean);
module.exports = { module.exports = {
getStagedFiles: fileExtensionFilter => { getStagedFiles: fileExtensionFilter => {
......
...@@ -11,7 +11,7 @@ const globIgnore = ['**/node_modules/**', 'vendor/**', 'public/**']; ...@@ -11,7 +11,7 @@ const globIgnore = ['**/node_modules/**', 'vendor/**', 'public/**'];
const readFileAsync = (file, options) => const readFileAsync = (file, options) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
fs.readFile(file, options, function(err, data) { fs.readFile(file, options, function (err, data) {
if (err) reject(err); if (err) reject(err);
else resolve(data); else resolve(data);
}); });
...@@ -19,7 +19,7 @@ const readFileAsync = (file, options) => ...@@ -19,7 +19,7 @@ const readFileAsync = (file, options) =>
const writeFileAsync = (file, data, options) => const writeFileAsync = (file, data, options) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
fs.writeFile(file, data, options, function(err) { fs.writeFile(file, data, options, function (err) {
if (err) reject(err); if (err) reject(err);
else resolve(); else resolve();
}); });
......
...@@ -8,12 +8,12 @@ const messages = stylelint.utils.ruleMessages(ruleName, { ...@@ -8,12 +8,12 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
}, },
}); });
module.exports = stylelint.createPlugin(ruleName, function(enabled) { module.exports = stylelint.createPlugin(ruleName, function (enabled) {
if (!enabled) { if (!enabled) {
return; return;
} }
return function(root, result) { return function (root, result) {
const selectorGroups = {}; const selectorGroups = {};
utils.createPropertiesHashmap(root, result, ruleName, messages, selectorGroups, true); utils.createPropertiesHashmap(root, result, ruleName, messages, selectorGroups, true);
}; };
......
...@@ -10,12 +10,12 @@ const messages = stylelint.utils.ruleMessages(ruleName, { ...@@ -10,12 +10,12 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
}, },
}); });
module.exports = stylelint.createPlugin(ruleName, function(enabled) { module.exports = stylelint.createPlugin(ruleName, function (enabled) {
if (!enabled) { if (!enabled) {
return; return;
} }
return function(root, result) { return function (root, result) {
utils.createPropertiesHashmap(root, result, ruleName, messages, utilityClasses, false); utils.createPropertiesHashmap(root, result, ruleName, messages, utilityClasses, false);
}; };
}); });
......
...@@ -42,7 +42,7 @@ sass.render( ...@@ -42,7 +42,7 @@ sass.render(
prettierOptions, prettierOptions,
); );
fs.writeFile(hashMapPath, prettyHashmap, function(err) { fs.writeFile(hashMapPath, prettyHashmap, function (err) {
if (err) { if (err) {
return console.log(err); return console.log(err);
} }
......
...@@ -25,7 +25,7 @@ module.exports.createPropertiesHashmap = ( ...@@ -25,7 +25,7 @@ module.exports.createPropertiesHashmap = (
) )
) { ) {
let cssArray = []; let cssArray = [];
rule.nodes.forEach(function(property) { rule.nodes.forEach(function (property) {
const { prop, value } = property; const { prop, value } = property;
if (property && value) { if (property && value) {
const propval = `${prop}${value}${property.important ? '!important' : ''}`; const propval = `${prop}${value}${property.important ? '!important' : ''}`;
......
...@@ -51,7 +51,7 @@ else { ...@@ -51,7 +51,7 @@ else {
// print useful messages for nodemon events // print useful messages for nodemon events
nodemon nodemon
.on('start', function() { .on('start', function () {
console.log(`Starting webpack webserver on http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`); console.log(`Starting webpack webserver on http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`);
if (STATIC_MODE) { if (STATIC_MODE) {
console.log('You are starting webpack in compile-once mode'); console.log('You are starting webpack in compile-once mode');
...@@ -59,10 +59,10 @@ nodemon ...@@ -59,10 +59,10 @@ nodemon
console.log('If you change them often, you might want to unset DEV_SERVER_STATIC'); console.log('If you change them often, you might want to unset DEV_SERVER_STATIC');
} }
}) })
.on('quit', function() { .on('quit', function () {
console.log('Shutting down webpack process'); console.log('Shutting down webpack process');
process.exit(); process.exit();
}) })
.on('restart', function(files) { .on('restart', function (files) {
console.log('Restarting webpack process due to: ', files); console.log('Restarting webpack process due to: ', files);
}); });
...@@ -57,9 +57,7 @@ describe('AwardsHandler', () => { ...@@ -57,9 +57,7 @@ describe('AwardsHandler', () => {
preloadFixtures('snippets/show.html'); preloadFixtures('snippets/show.html');
const openAndWaitForEmojiMenu = (sel = '.js-add-award') => { const openAndWaitForEmojiMenu = (sel = '.js-add-award') => {
$(sel) $(sel).eq(0).click();
.eq(0)
.click();
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
...@@ -337,9 +335,7 @@ describe('AwardsHandler', () => { ...@@ -337,9 +335,7 @@ describe('AwardsHandler', () => {
it('should remove already selected emoji', async () => { it('should remove already selected emoji', async () => {
await openEmojiMenuAndAddEmoji(); await openEmojiMenuAndAddEmoji();
$('.js-add-award') $('.js-add-award').eq(0).click();
.eq(0)
.click();
const $block = $('.js-awards-block'); const $block = $('.js-awards-block');
const $emoji = $('.emoji-menu').find( const $emoji = $('.emoji-menu').find(
`.emoji-menu-list:not(.frequent-emojis) ${emojiSelector}`, `.emoji-menu-list:not(.frequent-emojis) ${emojiSelector}`,
......
...@@ -78,9 +78,7 @@ describe('ConfirmModal', () => { ...@@ -78,9 +78,7 @@ describe('ConfirmModal', () => {
describe('when button clicked', () => { describe('when button clicked', () => {
beforeEach(() => { beforeEach(() => {
initConfirmModal(); initConfirmModal();
findJsHooks() findJsHooks().item(0).click();
.item(0)
.click();
}); });
it('does not replace JsHook with GlModal', () => { it('does not replace JsHook with GlModal', () => {
...@@ -116,9 +114,7 @@ describe('ConfirmModal', () => { ...@@ -116,9 +114,7 @@ describe('ConfirmModal', () => {
`(`when multiple buttons exist`, ({ index }) => { `(`when multiple buttons exist`, ({ index }) => {
beforeEach(() => { beforeEach(() => {
initConfirmModal(); initConfirmModal();
findJsHooks() findJsHooks().item(index).click();
.item(index)
.click();
}); });
it('correct props are passed to gl-modal', () => { it('correct props are passed to gl-modal', () => {
......
...@@ -27,20 +27,14 @@ describe('CreateItemDropdown', () => { ...@@ -27,20 +27,14 @@ describe('CreateItemDropdown', () => {
function createItemAndClearInput(text) { function createItemAndClearInput(text) {
// Filter for the new item // Filter for the new item
$wrapperEl $wrapperEl.find('.dropdown-input-field').val(text).trigger('input');
.find('.dropdown-input-field')
.val(text)
.trigger('input');
// Create the new item // Create the new item
const $createButton = $wrapperEl.find('.js-dropdown-create-new-item'); const $createButton = $wrapperEl.find('.js-dropdown-create-new-item');
$createButton.click(); $createButton.click();
// Clear out the filter // Clear out the filter
$wrapperEl $wrapperEl.find('.dropdown-input-field').val('').trigger('input');
.find('.dropdown-input-field')
.val('')
.trigger('input');
} }
beforeEach(() => { beforeEach(() => {
...@@ -91,10 +85,7 @@ describe('CreateItemDropdown', () => { ...@@ -91,10 +85,7 @@ describe('CreateItemDropdown', () => {
$('.js-dropdown-menu-toggle').click(); $('.js-dropdown-menu-toggle').click();
// Filter for the new item // Filter for the new item
$wrapperEl $wrapperEl.find('.dropdown-input-field').val(NEW_ITEM_TEXT).trigger('input');
.find('.dropdown-input-field')
.val(NEW_ITEM_TEXT)
.trigger('input');
}); });
it('create new item button should include the filter text', () => { it('create new item button should include the filter text', () => {
......
...@@ -230,10 +230,7 @@ describe('deprecatedJQueryDropdown', () => { ...@@ -230,10 +230,7 @@ describe('deprecatedJQueryDropdown', () => {
it('should still have input value on close and restore', () => { it('should still have input value on close and restore', () => {
const $searchInput = $(SEARCH_INPUT_SELECTOR); const $searchInput = $(SEARCH_INPUT_SELECTOR);
initDropDown.call(this, false, true); initDropDown.call(this, false, true);
$searchInput $searchInput.trigger('focus').val('g').trigger('input');
.trigger('focus')
.val('g')
.trigger('input');
expect($searchInput.val()).toEqual('g'); expect($searchInput.val()).toEqual('g');
test.dropdownButtonElement.trigger('hidden.bs.dropdown'); test.dropdownButtonElement.trigger('hidden.bs.dropdown');
......
...@@ -656,10 +656,7 @@ describe('GfmAutoComplete', () => { ...@@ -656,10 +656,7 @@ describe('GfmAutoComplete', () => {
}); });
const triggerDropdown = text => { const triggerDropdown = text => {
$textarea $textarea.trigger('focus').val(text).caret('pos', -1);
.trigger('focus')
.val(text)
.caret('pos', -1);
$textarea.trigger('keyup'); $textarea.trigger('keyup');
return new Promise(window.requestAnimationFrame); return new Promise(window.requestAnimationFrame);
......
...@@ -41,18 +41,9 @@ describe('GL Style Field Errors', () => { ...@@ -41,18 +41,9 @@ describe('GL Style Field Errors', () => {
}); });
it('should not show any errors before submit attempt', () => { it('should not show any errors before submit attempt', () => {
testContext.$form testContext.$form.find('.email').val('not-a-valid-email').keyup();
.find('.email') testContext.$form.find('.text-required').val('').keyup();
.val('not-a-valid-email') testContext.$form.find('.alphanumberic').val('?---*').keyup();
.keyup();
testContext.$form
.find('.text-required')
.val('')
.keyup();
testContext.$form
.find('.alphanumberic')
.val('?---*')
.keyup();
const errorsShown = testContext.$form.find('.gl-field-error-outline'); const errorsShown = testContext.$form.find('.gl-field-error-outline');
...@@ -60,18 +51,9 @@ describe('GL Style Field Errors', () => { ...@@ -60,18 +51,9 @@ describe('GL Style Field Errors', () => {
}); });
it('should show errors when input valid is submitted', () => { it('should show errors when input valid is submitted', () => {
testContext.$form testContext.$form.find('.email').val('not-a-valid-email').keyup();
.find('.email') testContext.$form.find('.text-required').val('').keyup();
.val('not-a-valid-email') testContext.$form.find('.alphanumberic').val('?---*').keyup();
.keyup();
testContext.$form
.find('.text-required')
.val('')
.keyup();
testContext.$form
.find('.alphanumberic')
.val('?---*')
.keyup();
testContext.$form.submit(); testContext.$form.submit();
......
...@@ -88,9 +88,7 @@ describe('LineHighlighter', () => { ...@@ -88,9 +88,7 @@ describe('LineHighlighter', () => {
describe('clickHandler', () => { describe('clickHandler', () => {
it('handles clicking on a child icon element', () => { it('handles clicking on a child icon element', () => {
const spy = jest.spyOn(testContext.class, 'setHash'); const spy = jest.spyOn(testContext.class, 'setHash');
$('#L13 i') $('#L13 i').mousedown().click();
.mousedown()
.click();
expect(spy).toHaveBeenCalledWith(13); expect(spy).toHaveBeenCalledWith(13);
expect($('#LC13')).toHaveClass(testContext.css); expect($('#LC13')).toHaveClass(testContext.css);
......
...@@ -40,10 +40,7 @@ export default { ...@@ -40,10 +40,7 @@ export default {
let clearMatch; let clearMatch;
try { try {
clearReceived = received clearReceived = received.replace(/\s\s+/gm, ' ').replace(/\s\./gm, '.').trim();
.replace(/\s\s+/gm, ' ')
.replace(/\s\./gm, '.')
.trim();
} catch (e) { } catch (e) {
return { actual: received, message: 'The received value is not a string', pass: false }; return { actual: received, message: 'The received value is not a string', pass: false };
} }
......
...@@ -32,10 +32,7 @@ describe('MergeRequest', () => { ...@@ -32,10 +32,7 @@ describe('MergeRequest', () => {
jest.spyOn($, 'ajax').mockImplementation(); jest.spyOn($, 'ajax').mockImplementation();
const changeEvent = document.createEvent('HTMLEvents'); const changeEvent = document.createEvent('HTMLEvents');
changeEvent.initEvent('change', true, true); changeEvent.initEvent('change', true, true);
$('input[type=checkbox]') $('input[type=checkbox]').first().attr('checked', true)[0].dispatchEvent(changeEvent);
.first()
.attr('checked', true)[0]
.dispatchEvent(changeEvent);
setImmediate(() => { setImmediate(() => {
expect($('.js-task-list-field').val()).toBe( expect($('.js-task-list-field').val()).toBe(
'- [x] Task List Item\n- [ ]\n- [ ] Task List Item 2\n', '- [x] Task List Item\n- [ ]\n- [ ] Task List Item 2\n',
...@@ -49,10 +46,7 @@ describe('MergeRequest', () => { ...@@ -49,10 +46,7 @@ describe('MergeRequest', () => {
jest.spyOn($, 'ajax').mockImplementation(); jest.spyOn($, 'ajax').mockImplementation();
const changeEvent = document.createEvent('HTMLEvents'); const changeEvent = document.createEvent('HTMLEvents');
changeEvent.initEvent('change', true, true); changeEvent.initEvent('change', true, true);
$('input[type=checkbox]') $('input[type=checkbox]').last().attr('checked', true)[0].dispatchEvent(changeEvent);
.last()
.attr('checked', true)[0]
.dispatchEvent(changeEvent);
setImmediate(() => { setImmediate(() => {
expect($('.js-task-list-field').val()).toBe( expect($('.js-task-list-field').val()).toBe(
'- [ ] Task List Item\n- [ ]\n- [x] Task List Item 2\n', '- [ ] Task List Item\n- [ ]\n- [x] Task List Item 2\n',
......
...@@ -12,9 +12,7 @@ describe('Branch', () => { ...@@ -12,9 +12,7 @@ describe('Branch', () => {
preloadFixtures('branches/new_branch.html'); preloadFixtures('branches/new_branch.html');
function fillNameWith(value) { function fillNameWith(value) {
$('.js-branch-name') $('.js-branch-name').val(value).trigger('blur');
.val(value)
.trigger('blur');
} }
function expectToHaveError(error) { function expectToHaveError(error) {
......
...@@ -3,9 +3,7 @@ import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me'; ...@@ -3,9 +3,7 @@ import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me';
describe('OAuthRememberMe', () => { describe('OAuthRememberMe', () => {
const findFormAction = selector => { const findFormAction = selector => {
return $(`#oauth-container .oauth-login${selector}`) return $(`#oauth-container .oauth-login${selector}`).parent('form').attr('action');
.parent('form')
.attr('action');
}; };
preloadFixtures('static/oauth_remember_me.html'); preloadFixtures('static/oauth_remember_me.html');
......
...@@ -58,7 +58,10 @@ describe('ProjectFindFile', () => { ...@@ -58,7 +58,10 @@ describe('ProjectFindFile', () => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
element = $(TEMPLATE); element = $(TEMPLATE);
mock.onGet(FILE_FIND_URL).replyOnce(200, files.map(x => x.path)); mock.onGet(FILE_FIND_URL).replyOnce(
200,
files.map(x => x.path),
);
getProjectFindFileInstance(); // This triggers a load / axios call + subsequent render in the constructor getProjectFindFileInstance(); // This triggers a load / axios call + subsequent render in the constructor
setImmediate(done); setImmediate(done);
......
...@@ -13,41 +13,19 @@ describe('setupTransferEdit', () => { ...@@ -13,41 +13,19 @@ describe('setupTransferEdit', () => {
}); });
it('disables submit button on load', () => { it('disables submit button on load', () => {
expect( expect($(formSelector).find(':submit').prop('disabled')).toBe(true);
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBe(true);
}); });
it('enables submit button when selection changes to non-empty value', () => { it('enables submit button when selection changes to non-empty value', () => {
const nonEmptyValue = $(formSelector) const nonEmptyValue = $(formSelector).find(targetSelector).find('option').not(':empty').val();
.find(targetSelector) $(formSelector).find(targetSelector).val(nonEmptyValue).trigger('change');
.find('option')
.not(':empty') expect($(formSelector).find(':submit').prop('disabled')).toBeFalsy();
.val();
$(formSelector)
.find(targetSelector)
.val(nonEmptyValue)
.trigger('change');
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBeFalsy();
}); });
it('disables submit button when selection changes to empty value', () => { it('disables submit button when selection changes to empty value', () => {
$(formSelector) $(formSelector).find(targetSelector).val('').trigger('change');
.find(targetSelector)
.val('') expect($(formSelector).find(':submit').prop('disabled')).toBe(true);
.trigger('change');
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBe(true);
}); });
}); });
...@@ -19,7 +19,7 @@ describe('VersionCheckImage', () => { ...@@ -19,7 +19,7 @@ describe('VersionCheckImage', () => {
it('registers an error event', () => { it('registers an error event', () => {
jest.spyOn($.prototype, 'on').mockImplementation(() => {}); jest.spyOn($.prototype, 'on').mockImplementation(() => {});
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
jest.spyOn($.prototype, 'off').mockImplementation(function() { jest.spyOn($.prototype, 'off').mockImplementation(function () {
return this; return this;
}); });
......
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