summaryrefslogtreecommitdiff
path: root/scripts/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/frontend')
-rw-r--r--scripts/frontend/block_dependencies.js4
-rwxr-xr-xscripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js2
-rw-r--r--scripts/frontend/extract_gettext_all.js2
-rwxr-xr-xscripts/frontend/file_test_coverage.js16
-rw-r--r--scripts/frontend/frontend_script_utils.js9
-rw-r--r--scripts/frontend/merge_coverage_frontend.js8
-rw-r--r--scripts/frontend/prettier.js16
-rw-r--r--scripts/frontend/stylelint/stylelint-duplicate-selectors.js4
-rw-r--r--scripts/frontend/stylelint/stylelint-utility-classes.js4
-rw-r--r--scripts/frontend/stylelint/stylelint-utility-map.js4
-rw-r--r--scripts/frontend/stylelint/stylelint-utils.js4
-rwxr-xr-xscripts/frontend/webpack_dev_server.js6
12 files changed, 37 insertions, 42 deletions
diff --git a/scripts/frontend/block_dependencies.js b/scripts/frontend/block_dependencies.js
index c9257c9f72b..a1ff8d5ee36 100644
--- a/scripts/frontend/block_dependencies.js
+++ b/scripts/frontend/block_dependencies.js
@@ -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.`);
diff --git a/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js b/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
index a2bb9f56d84..34e939e3ceb 100755
--- a/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
+++ b/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
@@ -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);
}
diff --git a/scripts/frontend/extract_gettext_all.js b/scripts/frontend/extract_gettext_all.js
index 725522a3540..c34c9a0233d 100644
--- a/scripts/frontend/extract_gettext_all.js
+++ b/scripts/frontend/extract_gettext_all.js
@@ -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])) {
diff --git a/scripts/frontend/file_test_coverage.js b/scripts/frontend/file_test_coverage.js
index 7d1eb45d4bc..ec6ec4a1e9d 100755
--- a/scripts/frontend/file_test_coverage.js
+++ b/scripts/frontend/file_test_coverage.js
@@ -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()) {
diff --git a/scripts/frontend/frontend_script_utils.js b/scripts/frontend/frontend_script_utils.js
index e3d357b4a40..43016dce6a4 100644
--- a/scripts/frontend/frontend_script_utils.js
+++ b/scripts/frontend/frontend_script_utils.js
@@ -9,15 +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);
diff --git a/scripts/frontend/merge_coverage_frontend.js b/scripts/frontend/merge_coverage_frontend.js
index 99034176b29..0c45a38b9b5 100644
--- a/scripts/frontend/merge_coverage_frontend.js
+++ b/scripts/frontend/merge_coverage_frontend.js
@@ -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);
});
diff --git a/scripts/frontend/prettier.js b/scripts/frontend/prettier.js
index 7772f80c233..f721e46f36b 100644
--- a/scripts/frontend/prettier.js
+++ b/scripts/frontend/prettier.js
@@ -7,11 +7,11 @@ const matchExtensions = ['js', 'vue', 'graphql'];
// This will improve glob performance by excluding certain directories.
// The .prettierignore file will also be respected, but after the glob has executed.
-const globIgnore = ['**/node_modules/**', 'vendor/**', 'public/**'];
+const globIgnore = ['**/node_modules/**', 'vendor/**', 'public/**', 'fixtures/**'];
const readFileAsync = (file, options) =>
new Promise((resolve, reject) => {
- fs.readFile(file, options, function(err, data) {
+ fs.readFile(file, options, function (err, data) {
if (err) reject(err);
else resolve(data);
});
@@ -19,7 +19,7 @@ const readFileAsync = (file, options) =>
const writeFileAsync = (file, data, options) =>
new Promise((resolve, reject) => {
- fs.writeFile(file, data, options, function(err) {
+ fs.writeFile(file, data, options, function (err) {
if (err) reject(err);
else resolve();
});
@@ -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);
});
diff --git a/scripts/frontend/stylelint/stylelint-duplicate-selectors.js b/scripts/frontend/stylelint/stylelint-duplicate-selectors.js
index 4b46ee21a7a..89242158157 100644
--- a/scripts/frontend/stylelint/stylelint-duplicate-selectors.js
+++ b/scripts/frontend/stylelint/stylelint-duplicate-selectors.js
@@ -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) {
return;
}
- return function(root, result) {
+ return function (root, result) {
const selectorGroups = {};
utils.createPropertiesHashmap(root, result, ruleName, messages, selectorGroups, true);
};
diff --git a/scripts/frontend/stylelint/stylelint-utility-classes.js b/scripts/frontend/stylelint/stylelint-utility-classes.js
index 8a1cfdbf302..1b266fc31c9 100644
--- a/scripts/frontend/stylelint/stylelint-utility-classes.js
+++ b/scripts/frontend/stylelint/stylelint-utility-classes.js
@@ -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) {
return;
}
- return function(root, result) {
+ return function (root, result) {
utils.createPropertiesHashmap(root, result, ruleName, messages, utilityClasses, false);
};
});
diff --git a/scripts/frontend/stylelint/stylelint-utility-map.js b/scripts/frontend/stylelint/stylelint-utility-map.js
index 941198e82a4..bf8ee362740 100644
--- a/scripts/frontend/stylelint/stylelint-utility-map.js
+++ b/scripts/frontend/stylelint/stylelint-utility-map.js
@@ -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);
@@ -42,7 +42,7 @@ sass.render(
prettierOptions,
);
- fs.writeFile(hashMapPath, prettyHashmap, function(err) {
+ fs.writeFile(hashMapPath, prettyHashmap, function (err) {
if (err) {
return console.log(err);
}
diff --git a/scripts/frontend/stylelint/stylelint-utils.js b/scripts/frontend/stylelint/stylelint-utils.js
index 2d931c1c4c2..e7452b0cdb2 100644
--- a/scripts/frontend/stylelint/stylelint-utils.js
+++ b/scripts/frontend/stylelint/stylelint-utils.js
@@ -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 (
@@ -25,7 +25,7 @@ module.exports.createPropertiesHashmap = (
)
) {
let cssArray = [];
- rule.nodes.forEach(function(property) {
+ rule.nodes.forEach(function (property) {
const { prop, value } = property;
if (property && value) {
const propval = `${prop}${value}${property.important ? '!important' : ''}`;
diff --git a/scripts/frontend/webpack_dev_server.js b/scripts/frontend/webpack_dev_server.js
index 8026a8d47e2..fbb80c9617d 100755
--- a/scripts/frontend/webpack_dev_server.js
+++ b/scripts/frontend/webpack_dev_server.js
@@ -51,7 +51,7 @@ else {
// print useful messages for nodemon events
nodemon
- .on('start', function() {
+ .on('start', function () {
console.log(`Starting webpack webserver on http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`);
if (STATIC_MODE) {
console.log('You are starting webpack in compile-once mode');
@@ -59,10 +59,10 @@ nodemon
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');
process.exit();
})
- .on('restart', function(files) {
+ .on('restart', function (files) {
console.log('Restarting webpack process due to: ', files);
});