Commit 81e82875 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 15 files - 4 of 73

Part of our prettier migration; changing the arrow-parens style.
parent dc6c2412
......@@ -10,23 +10,6 @@ doc/api/graphql/reference/gitlab_schema.graphql
*.scss
*.md
## boring-bohr
jest.config.base.js
jest.config.js
scripts/frontend/block_dependencies.js
scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
scripts/frontend/extract_gettext_all.js
scripts/frontend/file_test_coverage.js
scripts/frontend/frontend_script_utils.js
scripts/frontend/merge_coverage_frontend.js
scripts/frontend/prettier.js
scripts/frontend/stylelint/stylelint-utility-map.js
scripts/frontend/stylelint/stylelint-utils.js
app/assets/javascripts/access_tokens/index.js
app/assets/javascripts/activities.js
app/assets/javascripts/add_context_commits_modal/components/add_context_commits_modal_wrapper.vue
app/assets/javascripts/add_context_commits_modal/store/actions.js
## interesting-kepler
app/assets/javascripts/add_context_commits_modal/utils.js
app/assets/javascripts/admin/application_settings/setup_metrics_and_profiling.js
......
import Vue from 'vue';
import ExpiresAtField from './components/expires_at_field.vue';
const getInputAttrs = el => {
const getInputAttrs = (el) => {
const input = el.querySelector('input');
return {
......
......@@ -9,9 +9,9 @@ export default class Activities {
constructor(container = '') {
this.container = container;
Pager.init(20, true, false, data => data, this.updateTooltips, this.container);
Pager.init(20, true, false, (data) => data, this.updateTooltips, this.container);
$('.event-filter-link').on('click', e => {
$('.event-filter-link').on('click', (e) => {
e.preventDefault();
this.toggleFilter(e.currentTarget);
this.reloadActivities();
......@@ -24,7 +24,7 @@ export default class Activities {
reloadActivities() {
$('.content_list').html('');
Pager.init(20, true, false, data => data, this.updateTooltips, this.container);
Pager.init(20, true, false, (data) => data, this.updateTooltips, this.container);
}
toggleFilter(sender) {
......
......@@ -61,14 +61,14 @@ export default {
},
},
selectedCommitsCount() {
return this.selectedCommits.filter(selectedCommit => selectedCommit.isSelected).length;
return this.selectedCommits.filter((selectedCommit) => selectedCommit.isSelected).length;
},
shouldPurge() {
return this.selectedCommitsCount !== this.selectedCommits.length;
},
uniqueCommits() {
return this.selectedCommits.filter(
selectedCommit =>
(selectedCommit) =>
selectedCommit.isSelected &&
findCommitIndex(this.contextCommits, selectedCommit.short_id) === -1,
);
......@@ -126,7 +126,7 @@ export default {
this.focusSearch();
if (this.shouldPurge) {
this.setSelectedCommits(
[...this.commits, ...this.selectedCommits].filter(commit => commit.isSelected),
[...this.commits, ...this.selectedCommits].filter((commit) => commit.isSelected),
);
}
}
......@@ -178,7 +178,7 @@ export default {
this.setCommits({ commits: tempCommits });
this.setSelectedCommits([
...tempSelectedCommits,
...tempCommits.filter(commit => commit.isSelected),
...tempCommits.filter((commit) => commit.isSelected),
]);
},
handleCreateContextCommits() {
......@@ -186,7 +186,7 @@ export default {
return Promise.all([
this.createContextCommits({ commits: this.uniqueCommits }),
this.removeContextCommits(),
]).then(values => {
]).then((values) => {
if (values[0] || values[1]) {
window.location.reload();
}
......
......@@ -27,10 +27,10 @@ export const searchCommits = ({ dispatch, commit, state }, searchText) => {
return axios
.get(state.contextCommitsPath, params)
.then(({ data }) => {
let commits = data.map(o => ({ ...o, isSelected: false }));
commits = commits.map(c => {
let commits = data.map((o) => ({ ...o, isSelected: false }));
commits = commits.map((c) => {
const isPresent = state.selectedCommits.find(
selectedCommit => selectedCommit.short_id === c.short_id && selectedCommit.isSelected,
(selectedCommit) => selectedCommit.short_id === c.short_id && selectedCommit.isSelected,
);
if (isPresent) {
return { ...c, isSelected: true };
......@@ -50,7 +50,7 @@ export const searchCommits = ({ dispatch, commit, state }, searchText) => {
export const setCommits = ({ commit }, { commits: data, silentAddition = false }) => {
let commits = _.uniqBy(data, 'short_id');
commits = _.orderBy(data, c => new Date(c.committed_date), ['desc']);
commits = _.orderBy(data, (c) => new Date(c.committed_date), ['desc']);
if (silentAddition) {
commit(types.SET_COMMITS_SILENT, commits);
} else {
......@@ -60,7 +60,7 @@ export const setCommits = ({ commit }, { commits: data, silentAddition = false }
export const createContextCommits = ({ state }, { commits, forceReload = false }) =>
Api.createContextCommits(state.projectId, state.mergeRequestIid, {
commits: commits.map(commit => commit.short_id),
commits: commits.map((commit) => commit.short_id),
})
.then(() => {
if (forceReload) {
......@@ -81,7 +81,7 @@ export const fetchContextCommits = ({ dispatch, commit, state }) => {
commit(types.FETCH_CONTEXT_COMMITS);
return Api.allContextCommits(state.projectId, state.mergeRequestIid)
.then(({ data }) => {
const contextCommits = data.map(o => ({ ...o, isSelected: true }));
const contextCommits = data.map((o) => ({ ...o, isSelected: true }));
dispatch('setContextCommits', contextCommits);
dispatch('setCommits', {
commits: [...state.commits, ...contextCommits],
......@@ -121,7 +121,7 @@ export const setSelectedCommits = ({ commit }, selected) => {
let selectedCommits = _.uniqBy(selected, 'short_id');
selectedCommits = _.orderBy(
selectedCommits,
selectedCommit => new Date(selectedCommit.committed_date),
(selectedCommit) => new Date(selectedCommit.committed_date),
['desc'],
);
commit(types.SET_SELECTED_COMMITS, selectedCommits);
......
const IS_EE = require('./config/helpers/is_ee_env');
const isESLint = require('./config/helpers/is_eslint');
module.exports = path => {
module.exports = (path) => {
const reporters = ['default'];
// To have consistent date time parsing both in local and CI environments we set
......@@ -27,7 +27,7 @@ module.exports = path => {
// workaround for eslint-import-resolver-jest only resolving in test files
// see https://github.com/JoinColony/eslint-import-resolver-jest#note
if (isESLint(module)) {
testMatch = testMatch.map(path => path.replace('_spec.js', ''));
testMatch = testMatch.map((path) => path.replace('_spec.js', ''));
}
const TEST_FIXTURES_PATTERN = 'test_fixtures(/.*)$';
......
......@@ -4,7 +4,7 @@ module.exports = {
...baseConfig('spec/frontend'),
};
const karmaTestFile = process.argv.find(arg => arg.includes('spec/javascripts/'));
const karmaTestFile = process.argv.find((arg) => arg.includes('spec/javascripts/'));
if (karmaTestFile) {
console.error(`
Files in spec/javascripts/ and ee/spec/javascripts need to be run with Karma.
......
......@@ -5,13 +5,13 @@ const dependencies = packageJson.dependencies;
const devDependencies = packageJson.devDependencies;
const blockedDependenciesNames = Object.keys(blockedDependencies);
const blockedDependenciesFound = blockedDependenciesNames.filter(
blockedDependency => dependencies[blockedDependency] || devDependencies[blockedDependency],
(blockedDependency) => dependencies[blockedDependency] || devDependencies[blockedDependency],
);
if (blockedDependenciesFound.length) {
console.log('The following package.json dependencies are not allowed:');
blockedDependenciesFound.forEach(blockedDependency => {
blockedDependenciesFound.forEach((blockedDependency) => {
const infoLink = blockedDependencies[blockedDependency];
console.log(`- ${blockedDependency}: See ${infoLink} for more information.`);
......
......@@ -27,7 +27,7 @@ const file = fs.readFileSync(paths[0], 'utf-8');
const parsed = pjs.parse(file);
if (parsed.nodes.every(node => ['comment', 'atrule'].includes(node.type))) {
if (parsed.nodes.every((node) => ['comment', 'atrule'].includes(node.type))) {
console.log('The file does not introduce any side effects, we are all good.');
process.exit(0);
}
......
......@@ -45,7 +45,7 @@ function printJson() {
text += `\u0000${message.textPlural}`;
}
message.references.forEach(reference => {
message.references.forEach((reference) => {
const filename = reference.replace(/:\d+$/, '');
if (!Array.isArray(result[filename])) {
......
......@@ -17,11 +17,11 @@ const sourceDirectories = ['app/assets/javascripts'];
const testDirectories = ['spec/javascripts', 'spec/frontend'];
if (fs.existsSync('ee')) {
sourceDirectories.forEach(dir => {
sourceDirectories.forEach((dir) => {
sourceDirectories.push(`ee/${dir}`);
});
testDirectories.forEach(dir => {
testDirectories.forEach((dir) => {
testDirectories.push(`ee/${dir}`);
});
}
......@@ -29,10 +29,10 @@ if (fs.existsSync('ee')) {
let numSourceFiles = 0;
let numTestFiles = 0;
const isVerbose = process.argv.some(arg => arg === '-v');
const isVerbose = process.argv.some((arg) => arg === '-v');
const countSourceFiles = path =>
forEachFileIn(path, fileName => {
const countSourceFiles = (path) =>
forEachFileIn(path, (fileName) => {
if (fileName.endsWith('.vue') || fileName.endsWith('.js')) {
if (isVerbose) {
console.log(`source file: ${fileName}`);
......@@ -42,8 +42,8 @@ const countSourceFiles = path =>
}
});
const countTestFiles = path =>
forEachFileIn(path, fileName => {
const countTestFiles = (path) =>
forEachFileIn(path, (fileName) => {
if (fileName.endsWith('_spec.js')) {
if (isVerbose) {
console.log(`test file: ${fileName}`);
......@@ -63,7 +63,7 @@ function forEachFileIn(dirPath, callback) {
return;
}
files.forEach(fileName => {
files.forEach((fileName) => {
const absolutePath = path.join(dirPath, fileName);
const stats = fs.statSync(absolutePath);
if (stats.isFile()) {
......
......@@ -9,10 +9,10 @@ const exec = (command, args) => {
return execFileSync(command, args, options);
};
const execGitCmd = args => exec('git', args).trim().toString().split('\n').filter(Boolean);
const execGitCmd = (args) => exec('git', args).trim().toString().split('\n').filter(Boolean);
module.exports = {
getStagedFiles: fileExtensionFilter => {
getStagedFiles: (fileExtensionFilter) => {
const gitOptions = ['diff', '--name-only', '--cached', '--diff-filter=ACMRTUB'];
if (fileExtensionFilter) gitOptions.push(...fileExtensionFilter);
return execGitCmd(gitOptions);
......
......@@ -11,7 +11,7 @@ const reportFiles = sync(`${coverageDir}/*/coverage-final.json`);
// Normalize coverage report generated by jest that has additional "data" key
// https://github.com/facebook/jest/issues/2418#issuecomment-423806659
const normalizeReport = report => {
const normalizeReport = (report) => {
const normalizedReport = Object.assign({}, report);
Object.entries(normalizedReport).forEach(([k, v]) => {
if (v.data) normalizedReport[k] = v.data;
......@@ -20,12 +20,12 @@ const normalizeReport = report => {
};
reportFiles
.map(reportFile => require(reportFile))
.map((reportFile) => require(reportFile))
.map(normalizeReport)
.forEach(report => coverageMap.merge(report));
.forEach((report) => coverageMap.merge(report));
const context = createContext({ coverageMap: coverageMap, dir: 'coverage-frontend' });
['json', 'lcov', 'text-summary', 'clover', 'cobertura'].forEach(reporter => {
['json', 'lcov', 'text-summary', 'clover', 'cobertura'].forEach((reporter) => {
create(reporter, {}).execute(context);
});
......@@ -35,7 +35,7 @@ console.log(
`Loading all ${allFiles ? '' : 'staged '}files ${globDir ? `within ${globDir} ` : ''}...`,
);
const globPatterns = matchExtensions.map(ext => `${globDir}**/*.${ext}`);
const globPatterns = matchExtensions.map((ext) => `${globDir}**/*.${ext}`);
const matchedFiles = allFiles
? glob.sync(`{${globPatterns.join(',')}}`, { ignore: globIgnore })
: getStagedFiles(globPatterns);
......@@ -62,7 +62,7 @@ Please format each file listed below or run "${fixCommand}"
`;
const checkFileWithOptions = (filePath, options) =>
readFileAsync(filePath, 'utf8').then(input => {
readFileAsync(filePath, 'utf8').then((input) => {
if (shouldSave) {
const output = prettier.format(input, options);
if (input === output) {
......@@ -92,7 +92,7 @@ const checkFileWithOptions = (filePath, options) =>
}
});
const checkFileWithPrettierConfig = filePath =>
const checkFileWithPrettierConfig = (filePath) =>
prettier
.getFileInfo(filePath, { ignorePath: '.prettierignore' })
.then(({ ignored, inferredParser }) => {
......@@ -100,7 +100,7 @@ const checkFileWithPrettierConfig = filePath =>
ignoredCount += 1;
return;
}
return prettier.resolveConfig(filePath).then(fileOptions => {
return prettier.resolveConfig(filePath).then((fileOptions) => {
const options = { ...fileOptions, parser: inferredParser };
return checkFileWithOptions(filePath, options);
});
......@@ -115,7 +115,7 @@ Promise.all(matchedFiles.map(checkFileWithPrettierConfig))
if (didWarn) process.exit(1);
})
.catch(e => {
.catch((e) => {
console.log(`\nAn error occurred while processing files with prettier: ${e.message}\n`);
process.exit(1);
});
......@@ -32,7 +32,7 @@ sass.render(
// This suppresses a postcss warning
from: undefined,
})
.then(result => {
.then((result) => {
const selectorGroups = {};
utils.createPropertiesHashmap(result.root, result, null, null, selectorGroups, true);
......
......@@ -9,7 +9,7 @@ module.exports.createPropertiesHashmap = (
selectorGroups,
addSelectors,
) => {
ruleRoot.walkRules(rule => {
ruleRoot.walkRules((rule) => {
const selector = rule.selector.replace(/(?:\r\n|\r|\n)/g, ' ');
if (
......
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