Skip to content

Commit c0dde94

Browse files
authored
Feature/code inspections (#1350)
1 parent d9a21d4 commit c0dde94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+875
-600
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ config.js
33
diff.js
44
diverged.js
55
divergedWorker.js
6+
**/examples/**
7+
**/old_splash_page_v2.0/**
8+
**/dist/**
9+
**/angular.min.js
10+
**/js/vendor/**

capture/backstopTools.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = (target) => {
1313
if (typeof window._backstopTools._consoleLogger !== 'string') {
1414
window._backstopTools._consoleLogger = '';
1515
}
16-
var log = window.console.log.bind(console);
16+
const log = window.console.log.bind(console);
1717
window.console.log = function () {
1818
window._backstopTools._consoleLogger += Array.from(arguments).join('\n');
1919
log.apply(this, arguments);
@@ -38,14 +38,14 @@ module.exports = (target) => {
3838
if (selector === 'document') {
3939
return acc.concat(['document']);
4040
}
41-
var qResult = document.querySelectorAll(selector);
41+
const qResult = document.querySelectorAll(selector);
4242

4343
// pass-through any selectors that don't match any DOM elements
4444
if (!qResult.length) {
4545
return acc.concat(selector);
4646
}
4747

48-
var expandedSelector = [].slice.call(qResult)
48+
const expandedSelector = [].slice.call(qResult)
4949
.map(function (element, expandedIndex) {
5050
if (element.classList.contains('__86d')) {
5151
return '';
@@ -56,7 +56,7 @@ module.exports = (target) => {
5656
return selector;
5757
}
5858
// create index partial
59-
var indexPartial = '__n' + expandedIndex;
59+
const indexPartial = '__n' + expandedIndex;
6060
// update all matching selectors with additional indexPartial class
6161
element.classList.add(indexPartial);
6262
// return array of fully-qualified classnames

cli/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env node
22

3-
var parseArgs = require('minimist');
4-
var usage = require('./usage');
5-
var version = require('../package.json').version;
6-
var runner = require('../core/runner');
3+
const parseArgs = require('minimist');
4+
const usage = require('./usage');
5+
const version = require('../package.json').version;
6+
const runner = require('../core/runner');
77

88
main();
99

1010
function main () {
11-
var argsOptions = parseArgs(process.argv.slice(2), {
11+
const argsOptions = parseArgs(process.argv.slice(2), {
1212
boolean: ['h', 'help', 'v', 'version', 'i', 'docker'],
1313
string: ['config'],
1414
default: {
@@ -31,7 +31,7 @@ function main () {
3131
return;
3232
}
3333

34-
var commandName = argsOptions['_'][0];
34+
const commandName = argsOptions['_'][0];
3535

3636
if (!commandName) {
3737
console.log(usage);

cli/usage.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var version = require('../package.json').version;
2-
var makeSpaces = require('../core/util/makeSpaces');
1+
const version = require('../package.json').version;
2+
const makeSpaces = require('../core/util/makeSpaces');
33

4-
var commandsDescription = {
4+
const commandsDescription = {
55
test: 'Create test screenshots and compare against the set you previously approved/referenced.',
66
approve: 'Promotes all test bitmaps from last test run to reference bitmaps.',
77
reference: 'Creates new reference screenshots. Deletes all existing reference files.',
@@ -10,7 +10,7 @@ var commandsDescription = {
1010
openReport: 'View the last test report in your browser.'
1111
};
1212

13-
var optionsDescription = {
13+
const optionsDescription = {
1414
'--config': 'Path to config file name',
1515
'--filter': 'A RegEx string used to filter by scenario labels when running "test", "reference", or "approve" commands',
1616
'-h, --help': 'Display usage',
@@ -26,12 +26,8 @@ function makeDescription (descriptions) {
2626
.join('\n');
2727
}
2828

29-
function spacesBetweenCommandAndDescription (commandName) {
30-
return makeSpaces(2 + leftPaddingOfDescription - commandName.length);
31-
}
32-
3329
// Number of spaces to echo before writing description
34-
var leftPaddingOfDescription = Object.keys(commandsDescription)
30+
const leftPaddingOfDescription = Object.keys(commandsDescription)
3531
.concat(Object.keys(optionsDescription))
3632
.map(function (string) {
3733
return string.length;
@@ -40,7 +36,11 @@ var leftPaddingOfDescription = Object.keys(commandsDescription)
4036
return Math.max(max, length);
4137
}, 0);
4238

43-
var usage = '\
39+
function spacesBetweenCommandAndDescription (commandName) {
40+
return makeSpaces(2 + leftPaddingOfDescription - commandName.length);
41+
}
42+
43+
const usage = '\
4444
Welcome to BackstopJS ' + version + ' CLI\n\
4545
\n\
4646
Commands:\n\

core/command/approve.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var fs = require('../util/fs');
2-
var path = require('path');
3-
var map = require('p-map');
1+
const fs = require('../util/fs');
2+
const path = require('path');
3+
const map = require('p-map');
44

5-
var FAILED_DIFF_RE = /^failed_diff_/;
6-
var FILTER_DEFAULT = /\w+/;
5+
const FAILED_DIFF_RE = /^failed_diff_/;
6+
const FILTER_DEFAULT = /\w+/;
77

88
// This task will copy ALL test bitmap files (from the most recent test directory) to the reference directory overwriting any existing files.
99
module.exports = {
@@ -16,7 +16,7 @@ module.exports = {
1616
console.log(err.stack);
1717
reject(err);
1818
}
19-
var src = path.join(config.bitmaps_test, list[list.length - 1]);
19+
const src = path.join(config.bitmaps_test, list[list.length - 1]);
2020
return fs.readdir(src, (err, files) => {
2121
if (err) {
2222
console.log(err.stack);

core/command/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var path = require('path');
2-
var logger = require('../util/logger')('COMMAND');
1+
const path = require('path');
2+
const logger = require('../util/logger')('COMMAND');
33

44
/*
55
* Each file included in this folder (except `index.js`) is a command and must export the following object
@@ -11,7 +11,7 @@ var logger = require('../util/logger')('COMMAND');
1111
*/
1212

1313
/* Each and every command defined, including commands used in before/after */
14-
var commandNames = [
14+
const commandNames = [
1515
'init',
1616
'remote',
1717
'openReport',
@@ -24,7 +24,7 @@ var commandNames = [
2424
];
2525

2626
/* Commands that are only exposed to higher levels */
27-
var exposedCommandNames = [
27+
const exposedCommandNames = [
2828
'init',
2929
'remote',
3030
'reference',
@@ -41,7 +41,7 @@ function toObjectReducer (object, command) {
4141
return object;
4242
}
4343

44-
var commands = commandNames
44+
const commands = commandNames
4545
.map(function requireCommand (commandName) {
4646
return {
4747
name: commandName,
@@ -55,7 +55,7 @@ var commands = commandNames
5555
config.perf[command.name] = { started: new Date() };
5656
logger.info('Executing core for "' + command.name + '"');
5757

58-
var promise = command.commandDefinition.execute(config);
58+
let promise = command.commandDefinition.execute(config);
5959

6060
// If the command didn't return a promise, assume it resolved already
6161
if (!promise) {
@@ -66,7 +66,7 @@ var commands = commandNames
6666
// Do the catch separately or the main runner
6767
// won't be able to catch it a second time
6868
promise.catch(function (error) {
69-
var perf = (new Date() - config.perf[command.name].started) / 1000;
69+
const perf = (new Date() - config.perf[command.name].started) / 1000;
7070
logger.error('Command "' + command.name + '" ended with an error after [' + perf + 's]');
7171
logger.error(error);
7272
});
@@ -75,7 +75,7 @@ var commands = commandNames
7575
if (/openReport/.test(command.name)) {
7676
return;
7777
}
78-
var perf = (new Date() - config.perf[command.name].started) / 1000;
78+
const perf = (new Date() - config.perf[command.name].started) / 1000;
7979
logger.success('Command "' + command.name + '" successfully executed in [' + perf + 's]');
8080
return result;
8181
});
@@ -84,7 +84,7 @@ var commands = commandNames
8484
})
8585
.reduce(toObjectReducer, {});
8686

87-
var exposedCommands = exposedCommandNames
87+
const exposedCommands = exposedCommandNames
8888
.filter(function commandIsDefined (commandName) {
8989
return commands.hasOwnProperty(commandName);
9090
})

core/command/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var fs = require('../util/fs');
2-
var logger = require('../util/logger')('init');
1+
const fs = require('../util/fs');
2+
const logger = require('../util/logger')('init');
33

44
/**
55
* Copies a boilerplate config file to the current config file location.
66
*/
77
module.exports = {
88
execute: function init (config) {
9-
var promises = [];
9+
const promises = [];
1010
if (config.engine_scripts) {
1111
logger.log("Copying '" + config.engine_scripts_default + "' to '" + config.engine_scripts + "'");
1212
promises.push(fs.copy(config.engine_scripts_default, config.engine_scripts));

core/command/reference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
if (shouldRunDocker(config)) {
1010
return runDocker(config, 'reference');
1111
} else {
12-
var firstStep;
12+
let firstStep;
1313
// do not remove reference directory if we are in incremental mode
1414
if (config.args.filter || config.args.i) {
1515
firstStep = Promise.resolve();

0 commit comments

Comments
 (0)