From 5a2fd8557fc73651bdcc39f4c48ea59dad5859ca Mon Sep 17 00:00:00 2001 From: Juned Kazi <juned.kazi@bigcommerce.com> Date: Thu, 6 Feb 2020 10:27:48 -0800 Subject: [PATCH] feat(dependencies): update eslint to the latest and fix lint errors --- .editorconfig | 2 + .eslintrc | 13 ++++-- bin/stencil-bundle.spec.js | 2 +- commitlint.config.js | 2 +- constants.js | 2 +- gulpfile.js | 2 +- lib/bundle-validator.js | 46 ++----------------- lib/bundle-validator.spec.js | 6 +-- lib/json-lint.spec.js | 2 +- lib/release/questions.js | 2 +- lib/release/release.js | 2 +- lib/stencil-bundle.js | 18 ++++---- lib/stencil-init.js | 2 +- lib/stencil-pull.utils.js | 12 ++--- lib/stencil-push.spec.js | 2 +- lib/stencil-push.utils.js | 12 ++--- lib/stencil-push.utils.spec.js | 8 ++-- lib/template-assembler.js | 2 +- lib/theme-api-client.js | 4 +- lib/theme-api-client.spec.js | 18 ++++---- lib/theme-config.js | 12 ++--- lib/version-check.js | 2 +- package.json | 4 +- server/plugins/renderer/renderer.module.js | 10 ++-- .../plugins/renderer/renderer.module.spec.js | 22 ++++----- .../renderer/responses/pencil-response.js | 4 +- .../renderer/responses/raw-response.js | 2 +- server/plugins/router/router.module.js | 4 +- server/plugins/router/router.module.spec.js | 2 +- .../stencil-editor/stencil-editor.module.js | 2 +- tasks/changelog/changelog-generator.spec.js | 10 ++-- tasks/changelog/command-executor.js | 2 +- tasks/changelog/command-executor.spec.js | 16 +++---- 33 files changed, 109 insertions(+), 142 deletions(-) diff --git a/.editorconfig b/.editorconfig index fd9c40ec..49235a56 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,5 @@ insert_final_newline = true trim_trailing_whitespace = false [*.json] indent_size = 2 +[.eslintrc] +indent_size = 2 diff --git a/.eslintrc b/.eslintrc index 4e92ac80..fa6232d8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,9 +1,10 @@ { "parserOptions": { - "ecmaVersion": 8 - }, - "ecmaFeatures": { - "modules": true + "ecmaVersion": 8, + "sourceType": "module", + "ecmaFeatures": { + "impliedStrict": true + } }, "env": { "es6": true, @@ -20,6 +21,8 @@ "dot-notation": 0, "no-debugger": 2, "no-undef": 2, - "no-unused-vars": 2 + "no-unused-vars": 2, + "semi": 2, + "arrow-parens": [2, "as-needed"] } } diff --git a/bin/stencil-bundle.spec.js b/bin/stencil-bundle.spec.js index 9e185129..6188f26e 100644 --- a/bin/stencil-bundle.spec.js +++ b/bin/stencil-bundle.spec.js @@ -177,7 +177,7 @@ describe('Stencil Bundle', () => { expect(err.message).to.contain('no such file or directory'); done(); }); - }) + }); function getThemeConfigStub() { const rawConfig = { diff --git a/commitlint.config.js b/commitlint.config.js index 28fe5c5b..3347cb96 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -module.exports = {extends: ['@commitlint/config-conventional']} +module.exports = {extends: ['@commitlint/config-conventional']}; diff --git a/constants.js b/constants.js index e190b0bb..78742051 100644 --- a/constants.js +++ b/constants.js @@ -2,4 +2,4 @@ const path = require('path'); const packagePath = path.join(process.cwd(), 'package.json'); const packageInfo = require(packagePath); -module.exports = { packageInfo } +module.exports = { packageInfo }; diff --git a/gulpfile.js b/gulpfile.js index 972db2ae..2b8eaf3f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -130,7 +130,7 @@ function logError(err) { gulp.task('install-private-dependencies', installPrivateDependencies); gulp.task('bump', bumpTask); gulp.task('deploy-webpack', deployWebpack); -gulp.task('changelog', (done) => changelog.changelogTask({}, done)); +gulp.task('changelog', done => changelog.changelogTask({}, done)); gulp.task('uninstall-private-dependencies', uninstallPrivateDependencies); gulp.task('push', pushTask); gulp.task('release', gulp.series('install-private-dependencies', 'bump', 'deploy-webpack', 'changelog', 'uninstall-private-dependencies', 'push')); diff --git a/lib/bundle-validator.js b/lib/bundle-validator.js index a8d2e480..3b2d54d7 100644 --- a/lib/bundle-validator.js +++ b/lib/bundle-validator.js @@ -14,7 +14,6 @@ var OBJECTS_TO_VALIDATE = [ var _ = require('lodash'); var Async = require('async'); -var Eslint = require('eslint').CLIEngine; var Fs = require('fs'); var sizeOf = require('image-size'); var Path = require('path'); @@ -41,10 +40,6 @@ function BundleValidator(themePath, themeConfig, isPrivate) { if (!this.isPrivate) { this.validationTasks.push(validateMetaImages.bind(this)); } - - if (existsSync(Path.join(this.themePath, '.eslintrc'))) { - this.validationTasks.push(runLintTask); - } } /** @@ -54,7 +49,7 @@ function BundleValidator(themePath, themeConfig, isPrivate) { BundleValidator.prototype.validateTheme = function (callback) { Async.series(this.validationTasks, function (error, result) { return callback(error, result); - }) + }); }; /** @@ -79,7 +74,7 @@ function validateThemeConfiguration(callback) { if (!this.themeConfig.configExists()) { return callback( - new Error('You must have a '.red + 'config.json'.cyan + ' file in your top level theme directory.') + new Error('You must have a '.red + 'config.json'.cyan + ' file in your top level theme directory.'), ); } @@ -89,7 +84,7 @@ function validateThemeConfiguration(callback) { // Validate against the theme registry config schema if (this.isPrivate) { - validationSchema = './privateThemeConfig.schema.json' + validationSchema = './privateThemeConfig.schema.json'; } validation = v.validate(this.themeConfig.getRawConfig(), require(validationSchema)); @@ -144,7 +139,7 @@ function validateMetaImages(callback) { + '\r\nValid types ('.red + VALID_IMAGE_TYPES.join(', ').red + ')'.red)); } else if (!Fs.existsSync(imagePath)) { return callback( - new Error('The path you specified for your "meta.composed_image" does not exist.'.red) + new Error('The path you specified for your "meta.composed_image" does not exist.'.red), ); } else { (function (path) { @@ -248,37 +243,6 @@ function isValidImageType(imagePath) { return _.includes(VALID_IMAGE_TYPES, ext); } -function runLintTask(callback) { - console.log('Running ESLint...'); - var options = { - ignorePattern: [ - 'assets/js/**/*.spec.js', - 'assets/js/dependency-bundle.js', - ], - }; - - var cli = new Eslint(options); - var report = cli.executeOnFiles([Path.join(process.cwd(), 'assets', 'js')]); - var formatter = cli.getFormatter(); - - console.log(formatter(report.results)); - - if (report.errorCount !== 0) { - callback(new Error('Please fix the above Javascript errors.')); - } - - callback(null, true); -} - -function existsSync(file) { - try { - Fs.accessSync(file); - return true; - } catch (e) { - return false; - } -} - function validateImage(path, width, height, cb) { var MAX_SIZE_COMPOSED = 1048576 * 2; //2MB var MAX_SIZE_MOBILE = 1048576; //1MB @@ -312,7 +276,7 @@ function validateImage(path, width, height, cb) { + 'is greater than allowed size ' + MAX_SIZE_MOBILE + '\n'; } - if (imageWidth !== width || imageHeight != height) { + if (imageWidth !== width || imageHeight !== height) { failureMessage += 'Image at (' + path + ') has incorrect dimensions (' + imageWidth + 'x' + imageHeight + ') should be' + '(' + width + 'x' + height + ')'; return cb(new Error(failureMessage)); diff --git a/lib/bundle-validator.spec.js b/lib/bundle-validator.spec.js index 218f48d2..d491a7e8 100644 --- a/lib/bundle-validator.spec.js +++ b/lib/bundle-validator.spec.js @@ -32,7 +32,7 @@ describe('BundleValidator', function () { sizeOfSpy.restore(); done(); - }) + }); }); @@ -46,7 +46,7 @@ describe('BundleValidator', function () { sizeOfSpy.restore(); done(); - }) + }); }); it ('should validate returned objects exist in templates', function (done) { @@ -99,5 +99,5 @@ describe('BundleValidator', function () { expect(err.message).to.equal('Missing required objects/properties: footer.scripts'); done(); }); - }) + }); }); diff --git a/lib/json-lint.spec.js b/lib/json-lint.spec.js index bdab6db1..9d5307af 100644 --- a/lib/json-lint.spec.js +++ b/lib/json-lint.spec.js @@ -28,5 +28,5 @@ describe('json-lint', function () { expect(throws).throw(Error, !file); done(); - }) + }); }); diff --git a/lib/release/questions.js b/lib/release/questions.js index 46ba84c8..96b8fe0f 100644 --- a/lib/release/questions.js +++ b/lib/release/questions.js @@ -11,7 +11,7 @@ const dateFormatOptions = { function askQuestions(themeConfig, githubToken, remotes, callback) { const remoteChoices = remotes.map(remote => { return { value: remote, name: `${remote.name}: ${remote.url}` }; - }) + }); const currentVersion = themeConfig.getVersion(); diff --git a/lib/release/release.js b/lib/release/release.js index 553d42e3..d3b25a63 100644 --- a/lib/release/release.js +++ b/lib/release/release.js @@ -45,7 +45,7 @@ module.exports = () => { saveGithubToken(answers.githubToken); - doRelease(answers, (err) => { + doRelease(answers, err => { if (err) { return printError(err.message); } diff --git a/lib/stencil-bundle.js b/lib/stencil-bundle.js index f6722068..c8ddd5c1 100644 --- a/lib/stencil-bundle.js +++ b/lib/stencil-bundle.js @@ -1,6 +1,6 @@ 'use strict'; -const MEGABYTE = 1048576 -const MAX_SIZE_BUNDLE = MEGABYTE * 50; +const MEGABYTE = 1048576; +const MAX_SIZE_BUNDLE = MEGABYTE * 50; const PATHS_TO_ZIP = [ 'assets/**/*', '!assets/cdn/**', @@ -69,7 +69,7 @@ function Bundle(themePath, themeConfig, rawConfig, options) { console.log('ok'.green + ' -- Theme task Finished'); callback(); }); - } + }; } this.tasks = tasks; @@ -110,7 +110,7 @@ Bundle.prototype.getCssAssembleTask = function (compiler) { console.log('%s Parsing Started...', compiler.toUpperCase()); Fs.readdir(basePath, (err, files) => { - const filterFiles = files.filter((file) => { + const filterFiles = files.filter(file => { return file.substr(-(compiler.length + 1)) === '.' + compiler; }); Async.map(filterFiles, (file, mapCallback) => { @@ -140,7 +140,7 @@ Bundle.prototype.assembleTemplatesTask = function (callback) { return callback(err); } - const partials = files.map((file) => { + const partials = files.map(file => { return Upath.toUnix(file.replace(this.templatesPath + Path.sep, '').replace(/\.html$/, '')); }); @@ -222,7 +222,7 @@ Bundle.prototype.getJspmBundleTask = function (jspmConfig) { }).catch(err => { callback(err); }); - } + }; }; Bundle.prototype.generateManifest = function (taskResults, callback) { @@ -263,7 +263,7 @@ function detectCycles(results, callback) { new Cycles(results).detect(); callback(); } catch (err) { - callback(err) + callback(err); } } @@ -343,7 +343,7 @@ function bundleThemeFiles(archive, themePath, configuration) { if (configuration.jspm) { archive.append( Fs.createReadStream(configuration.jspm.tmpBundleFile), - { name: configuration.jspm.bundle_location } + { name: configuration.jspm.bundle_location }, ); } @@ -363,7 +363,7 @@ function bundleThemeFiles(archive, themePath, configuration) { function bundleParsedFiles(archive, taskResults) { const archiveJsonFile = (data, name) => { archive.append(JSON.stringify(data, null, 2), { name }); - } + }; const failedTemplates = []; for (let task in taskResults) { let data = taskResults[task]; diff --git a/lib/stencil-init.js b/lib/stencil-init.js index f5515050..2a5530a1 100644 --- a/lib/stencil-init.js +++ b/lib/stencil-init.js @@ -41,7 +41,7 @@ internals.parseAnswers = function(JspmAssembler, ThemeConfig, dotStencilFile, do 'jspm.jspm_packages_path'.cyan + ' setting in your theme\'s '.red + 'config.json'.cyan + - ' file to make sure it\'s correct.'.red + ' file to make sure it\'s correct.'.red, ); } diff --git a/lib/stencil-pull.utils.js b/lib/stencil-pull.utils.js index 60b8686a..d80d7038 100644 --- a/lib/stencil-pull.utils.js +++ b/lib/stencil-pull.utils.js @@ -47,7 +47,7 @@ utils.downloadThemeConfig = (options, callback) => { request(options.downloadUrl) .pipe(fs.createWriteStream(tempThemePath)) .on('finish', () => resolve(tempThemePath)) - .on('error', reject) + .on('error', reject), ) ) .then(tempThemePath => @@ -81,8 +81,8 @@ utils.downloadThemeConfig = (options, callback) => { }); }); }); - }) - ) + }), + ), ) .then( liveStencilConfig => @@ -94,13 +94,13 @@ utils.downloadThemeConfig = (options, callback) => { } resolve(); - }) - ) + }), + ), ) .then(() => { cleanupCallback(); callback(null, options); }) .catch(callback); - }) + }); }; diff --git a/lib/stencil-push.spec.js b/lib/stencil-push.spec.js index 86a0a33f..4e20c00c 100644 --- a/lib/stencil-push.spec.js +++ b/lib/stencil-push.spec.js @@ -18,7 +18,7 @@ const mockDb = { set data(data) { this._data = data; }, -} +}; describe('stencil push', () => { let sandbox; diff --git a/lib/stencil-push.utils.js b/lib/stencil-push.utils.js index 79c1e168..aad05a9f 100644 --- a/lib/stencil-push.utils.js +++ b/lib/stencil-push.utils.js @@ -158,7 +158,7 @@ utils.promptUserToDeleteThemesIfNecessary = (options, callback) => { const oldestTheme = options.themes .filter(theme => theme.is_private && !theme.is_active) .map(theme => ({ uuid: theme.uuid, updated_at: new Date(theme.updated_at).valueOf() })) - .reduce((prev, current) => prev.updated_at < current.updated_at ? prev : current) + .reduce((prev, current) => prev.updated_at < current.updated_at ? prev : current); return callback(null, Object.assign({}, options, { themeIdsToDelete: [oldestTheme.uuid] })); } @@ -171,7 +171,7 @@ utils.promptUserToDeleteThemesIfNecessary = (options, callback) => { message: 'Which theme(s) would you like to delete?', name: 'themeIdsToDelete', type: 'checkbox', - validate: (val) => { + validate: val => { if (val.length > 0) { return true; } else { @@ -180,7 +180,7 @@ utils.promptUserToDeleteThemesIfNecessary = (options, callback) => { }, }]; - Inquirer.prompt(questions, (answers) => { + Inquirer.prompt(questions, answers => { callback(null, Object.assign({}, options, answers)); }); }; @@ -201,7 +201,7 @@ utils.deleteThemesIfNecessary = (options, callback) => { storeHash: options.storeHash, themeId, }, options), cb); - } + }; }), err => { if (err) { err.name = 'ThemeDeletionError'; @@ -209,7 +209,7 @@ utils.deleteThemesIfNecessary = (options, callback) => { } callback(null, options); - }) + }); }; utils.uploadBundleAgainIfNecessary = (options, callback) => { @@ -319,7 +319,7 @@ utils.getVariations = (options, callback) => { utils.promptUserForVariation = (options, callback) => { if (!options.applyTheme) { - return async.nextTick(callback.bind(null, null, options)) + return async.nextTick(callback.bind(null, null, options)); } if (options.variationId) { diff --git a/lib/stencil-push.utils.spec.js b/lib/stencil-push.utils.spec.js index 2b073399..2aff914f 100644 --- a/lib/stencil-push.utils.spec.js +++ b/lib/stencil-push.utils.spec.js @@ -18,10 +18,10 @@ const mockDb = { set data(data) { this._data = data; }, -} +}; describe('stencil push utils', () => { - lab.beforeEach((done) => { + lab.beforeEach(done => { this.wreckReqStub = sinon.stub(Wreck, 'request').callsFake((method, url, options, callback) => { callback(null, mockDb.data); }); @@ -31,7 +31,7 @@ describe('stencil push utils', () => { done(); }); - lab.afterEach((done) => { + lab.afterEach(done => { this.wreckReqStub.restore(); this.wreckReadStub.restore(); done(); @@ -41,7 +41,7 @@ describe('stencil push utils', () => { mockDb.data = { store_hash: 'abc123', statusCode: 200, - } + }; it('should get the store hash', done => { utils.getStoreHash({ config: mockConfig }, (err, result) => { diff --git a/lib/template-assembler.js b/lib/template-assembler.js index 79f69fdf..906a5993 100644 --- a/lib/template-assembler.js +++ b/lib/template-assembler.js @@ -91,7 +91,7 @@ function getTemplatePaths(templatesFolder, templates, options, callback) { if (missingTemplates.length > 0) { return callback(new Error( - 'The following template(s) are/is missing: \n' + missingTemplates.join('\n') + 'The following template(s) are/is missing: \n' + missingTemplates.join('\n'), )); } if (options.bundle) { diff --git a/lib/theme-api-client.js b/lib/theme-api-client.js index cf2c3f6a..f7810db4 100644 --- a/lib/theme-api-client.js +++ b/lib/theme-api-client.js @@ -102,7 +102,7 @@ function getJob(options, callback) { function printErrorMessages(errors_array) { if (!Array.isArray(errors_array)) { console.log("unknown error".red); - return false + return false; } for (var i = 0; i < errors_array.length; i++) { @@ -114,7 +114,7 @@ function printErrorMessages(errors_array) { } console.log('Please visit the troubleshooting page https://developer.bigcommerce.com/stencil-docs/deploying-a-theme/troubleshooting-theme-uploads'); - return true + return true; } function getThemes(options, callback) { diff --git a/lib/theme-api-client.spec.js b/lib/theme-api-client.spec.js index 78406396..7bf28c3a 100644 --- a/lib/theme-api-client.spec.js +++ b/lib/theme-api-client.spec.js @@ -10,18 +10,18 @@ const it = lab.it; const sinon = require('sinon'); describe('theme-api-client', () => { - describe('printErrorMessages()', () => { - var consoleLogStub; + describe('printErrorMessages()', () => { + let consoleLogStub; - lab.before(done => { + lab.before(done => { consoleLogStub = sinon.stub(console, 'log'); done(); }); - lab.after((done) => { + lab.after(done => { console.log.restore(); done(); - }); + }); it('should log unknown error and return if input is not an array', done => { expect(themeApiClient.printErrorMessages("string")).to.be.equal(false); @@ -37,16 +37,16 @@ describe('theme-api-client', () => { it('should log error message for each error in the array', done => { consoleLogStub.resetHistory(); - var arrayInput = [{ "message": "first_error" }, { "message": "2nd_error" }]; - expect(themeApiClient.printErrorMessages(arrayInput)).to.be.equal(true); + const arrayInput = [{"message": "first_error"}, {"message": "2nd_error"}]; + expect(themeApiClient.printErrorMessages(arrayInput)).to.be.equal(true); expect(consoleLogStub.calledThrice).to.be.equal(true); done(); }); it('should skip non object elements in the input array', done => { consoleLogStub.resetHistory(); - var arrayInput = [{ "message": "first_error" }, "string", { "message": "2nd_error" }]; - expect(themeApiClient.printErrorMessages(arrayInput)).to.be.equal(true); + const arrayInput = [{"message": "first_error"}, "string", {"message": "2nd_error"}]; + expect(themeApiClient.printErrorMessages(arrayInput)).to.be.equal(true); expect(consoleLogStub.calledThrice).to.be.equal(true); done(); }); diff --git a/lib/theme-config.js b/lib/theme-config.js index c08a15eb..f8429beb 100644 --- a/lib/theme-config.js +++ b/lib/theme-config.js @@ -177,7 +177,7 @@ ThemeConfig.prototype.setVariationByName = function (variationName) { throw new Error( 'Variation: ' + variationName + - ' is not defined in the theme\'s config.json' + ' is not defined in the theme\'s config.json', ); } } @@ -280,7 +280,7 @@ ThemeConfig.prototype.getDemoUrl = function () { */ ThemeConfig.prototype.configExists = function () { return fileExists(this.configPath); -} +}; /** * Check if the schema.json file exists @@ -288,7 +288,7 @@ ThemeConfig.prototype.configExists = function () { */ ThemeConfig.prototype.schemaExists = function () { return fileExists(this.schemaPath); -} +}; /** * Scans the theme template directory for theme settings that need force reload @@ -338,7 +338,7 @@ ThemeConfig.prototype.getSchema = function (callback) { if (forceReloadIds[item.id]) { item['force_reload'] = true; } - }) + }); }); return callback(null, themeSchema); @@ -391,7 +391,7 @@ function getVariation(config, variationIndex) { if (! _.isArray(config.variations) || config.variations.length === 0) { throw new Error( - 'Your theme must have at least one variation in the config.json file.' + 'Your theme must have at least one variation in the config.json file.', ); } @@ -402,7 +402,7 @@ function getVariation(config, variationIndex) { if (! variation) { throw new Error( - 'Variation index: ' + variationIndex + ' not found theme\'s config.json' + 'Variation index: ' + variationIndex + ' not found theme\'s config.json', ); } } diff --git a/lib/version-check.js b/lib/version-check.js index 00af5dc1..dbdb6d47 100644 --- a/lib/version-check.js +++ b/lib/version-check.js @@ -9,4 +9,4 @@ module.exports = function () { } return satisfies; -} +}; diff --git a/package.json b/package.json index a3f7f2e1..d02c73be 100644 --- a/package.json +++ b/package.json @@ -42,15 +42,13 @@ "accept-language-parser": "^1.0.2", "archiver": "^0.14.4", "async": "^2.4.0", - "babel-eslint": "^7.1.1", "boom": "^2.7.0", "browser-sync": "^2.26.7", "cheerio": "^0.19.0", "colors": "^1.4.0", "commander": "^2.7.1", "confidence": "^1.0.0", - "eslint": "^2.2.0", - "eslint-config-airbnb": "^6.0.2", + "eslint": "^6.8.0", "front-matter": "^1.0.0", "github": "^8.1.0", "glob": "^5.0.14", diff --git a/server/plugins/renderer/renderer.module.js b/server/plugins/renderer/renderer.module.js index 239d3259..37116439 100644 --- a/server/plugins/renderer/renderer.module.js +++ b/server/plugins/renderer/renderer.module.js @@ -87,7 +87,7 @@ internals.getResponse = function (request, callback) { // Convert QueryParams with array values to php compatible names (brackets []) urlObject.query = _.mapKeys(urlObject.query, function (value, key) { if (_.isArray(value)) { - return key + '[]' + return key + '[]'; } return key; @@ -187,7 +187,7 @@ internals.parseResponse = function (bcAppData, request, response, responseArgs, return callback(null, new Responses.RawResponse( bcAppData, response.headers, - response.statusCode + response.statusCode, )); } @@ -330,7 +330,7 @@ internals.redirect = function (response, request, callback) { return callback(null, new Responses.RedirectResponse( response.headers.location, response.headers, - response.statusCode + response.statusCode, )); }; @@ -474,7 +474,7 @@ internals.themeAssembler = { } return resolve(processor(templates)); }); - }) + }); }, getTranslations: () => { return new Promise((resolve, reject) => { @@ -484,7 +484,7 @@ internals.themeAssembler = { } return resolve(_.mapValues(translations, locales => JSON.parse(locales))); }); - }) + }); }, }; diff --git a/server/plugins/renderer/renderer.module.spec.js b/server/plugins/renderer/renderer.module.spec.js index c8cc2279..2ea0a3d2 100644 --- a/server/plugins/renderer/renderer.module.spec.js +++ b/server/plugins/renderer/renderer.module.spec.js @@ -15,7 +15,7 @@ lab.describe('Renderer Plugin', () => { let wreckRequestStub; let wreckReadStub; - lab.before((done) => { + lab.before(done => { const options = { dotStencilFile: { storeUrl: "https://store-abc123.mybigcommerce.com", @@ -44,21 +44,21 @@ lab.describe('Renderer Plugin', () => { }); }); - lab.beforeEach((done) => { + lab.beforeEach(done => { wreckRequestStub = sinon.stub(Wreck, 'request'); wreckReadStub = sinon.stub(Wreck, 'read'); done(); }); - lab.afterEach((done) => { + lab.afterEach(done => { wreckRequestStub.restore(); wreckReadStub.restore(); server.stop(done); }); - it('should handle fatal errors in the BCApp request', (done) => { + it('should handle fatal errors in the BCApp request', done => { var options = { method: "GET", url: "/test", @@ -66,14 +66,14 @@ lab.describe('Renderer Plugin', () => { wreckRequestStub.callsArgWith(3, new Error('failure')); - server.inject(options, (response) => { + server.inject(options, response => { expect(response.statusCode).to.equal(500); done(); }); }); - it('should handle responses of a 500 in the BCApp request', (done) => { + it('should handle responses of a 500 in the BCApp request', done => { var options = { method: "GET", url: "/", @@ -83,14 +83,14 @@ lab.describe('Renderer Plugin', () => { statusCode: 500, }); - server.inject(options, (response) => { + server.inject(options, response => { expect(response.statusCode).to.equal(500); done(); }); }); - it('should handle redirects in the BCApp request', (done) => { + it('should handle redirects in the BCApp request', done => { var options = { method: "GET", url: "/", @@ -103,7 +103,7 @@ lab.describe('Renderer Plugin', () => { }, }); - server.inject(options, (response) => { + server.inject(options, response => { expect(response.statusCode).to.equal(301); expect(response.headers.location).to.equal('http://www.example.com/'); @@ -111,7 +111,7 @@ lab.describe('Renderer Plugin', () => { }); }); - it('should handle unauthorized in the Stapler Request', (done) => { + it('should handle unauthorized in the Stapler Request', done => { var options = { method: "GET", url: "/", @@ -124,7 +124,7 @@ lab.describe('Renderer Plugin', () => { }, }); - server.inject(options, (response) => { + server.inject(options, response => { expect(response.statusCode).to.equal(401); done(); diff --git a/server/plugins/renderer/responses/pencil-response.js b/server/plugins/renderer/responses/pencil-response.js index 9fa953d6..fd0f3a97 100644 --- a/server/plugins/renderer/responses/pencil-response.js +++ b/server/plugins/renderer/responses/pencil-response.js @@ -91,7 +91,7 @@ internals.makeDecorator = function (request, context) { } return content; - } + }; }; /** @@ -106,7 +106,7 @@ internals.escapeHtml = function (html) { }; return html.replace(/[&<>"]/g, tag => charsToReplace[tag] || tag); -} +}; /** * Scape special characters for regular expression diff --git a/server/plugins/renderer/responses/raw-response.js b/server/plugins/renderer/responses/raw-response.js index ff03867d..0bc40326 100644 --- a/server/plugins/renderer/responses/raw-response.js +++ b/server/plugins/renderer/responses/raw-response.js @@ -27,7 +27,7 @@ function RawResponse(data, headers, statusCode) { payload = payload.toString('utf8') .replace( /http[s]?:\/\/.*?\/optimized-checkout.css/, - `/stencil/${internals.stubActiveVersion}/${internals.stubActiveConfig}/css/optimized-checkout.css` + `/stencil/${internals.stubActiveVersion}/${internals.stubActiveConfig}/css/optimized-checkout.css`, ); } diff --git a/server/plugins/router/router.module.js b/server/plugins/router/router.module.js index 2d854ef5..6b8ee121 100644 --- a/server/plugins/router/router.module.js +++ b/server/plugins/router/router.module.js @@ -165,8 +165,8 @@ internals.registerRoutes = function(server, next) { { origin: internals.options.storeUrl, host: internals.options.storeUrl.replace(/http[s]?:\/\//, ''), - } - ) + }, + ), ); }, passThrough: true, diff --git a/server/plugins/router/router.module.spec.js b/server/plugins/router/router.module.spec.js index e787c245..bae39905 100644 --- a/server/plugins/router/router.module.spec.js +++ b/server/plugins/router/router.module.spec.js @@ -101,7 +101,7 @@ describe('Router', () => { authorization: 'abc123', origin: 'https://store-abc123.mybigcommerce.com', host: 'store-abc123.mybigcommerce.com', - } + }, ); done(); }); diff --git a/server/plugins/stencil-editor/stencil-editor.module.js b/server/plugins/stencil-editor/stencil-editor.module.js index 9bc149c8..6070a499 100644 --- a/server/plugins/stencil-editor/stencil-editor.module.js +++ b/server/plugins/stencil-editor/stencil-editor.module.js @@ -49,7 +49,7 @@ module.exports.register = (server, options, next) => { config: routesConfig, handler: (request, reply) => { const params = querystring.stringify(request.query); - reply.redirect(`/theme-editor/theme/${variationId}/${configurationId}?${params}`) + reply.redirect(`/theme-editor/theme/${variationId}/${configurationId}?${params}`); }, }, { diff --git a/tasks/changelog/changelog-generator.spec.js b/tasks/changelog/changelog-generator.spec.js index bed93f46..29822bae 100644 --- a/tasks/changelog/changelog-generator.spec.js +++ b/tasks/changelog/changelog-generator.spec.js @@ -17,7 +17,7 @@ describe('ChangelogGenerator', () => { lab.beforeEach( done => { fs = { - statSync: function() { return true }, + statSync: function() { return true; }, }; commandExecutor = new CommandExecutor(require('child_process')); @@ -37,7 +37,7 @@ describe('ChangelogGenerator', () => { config: path.join(__dirname, 'default-config.js'), infile: path.join('/src', 'CHANGELOG.md'), sameFile: true, - } + }, )).to.equal(true); done(); @@ -55,7 +55,7 @@ describe('ChangelogGenerator', () => { infile: path.join('/src', 'CHANGELOG.md'), preset: 'angular', sameFile: true, - } + }, )).to.equal(true); done(); @@ -75,9 +75,9 @@ describe('ChangelogGenerator', () => { infile: path.join('/src', 'CHANGELOG.md'), releaseCount: 0, sameFile: true, - } + }, )).to.equal(true); - + done(); }); }); diff --git a/tasks/changelog/command-executor.js b/tasks/changelog/command-executor.js index 50016765..3f6fafa2 100644 --- a/tasks/changelog/command-executor.js +++ b/tasks/changelog/command-executor.js @@ -17,7 +17,7 @@ function CommandExecutor(childProcess) { const command = createCommand(executable, argv, options); childProcess.spawn(command.executable, command.args, command.options) - .on('close', (code) => { + .on('close', code => { done(code ? new Error(`Exit code: ${code}`) : undefined); }); } diff --git a/tasks/changelog/command-executor.spec.js b/tasks/changelog/command-executor.spec.js index d29381ce..f0029ea3 100644 --- a/tasks/changelog/command-executor.spec.js +++ b/tasks/changelog/command-executor.spec.js @@ -19,12 +19,12 @@ describe('CommandExecutor', () => { childProcess = require('child_process'); spawnSpy = sinon.spy(childProcess, "spawn"); commandExecutor = new CommandExecutor(childProcess); - + commandExecutor.executeCommand('jest', ['xyz.js'], { config: 'config.js' }, () => { expect(spawnSpy.calledWith( require('npm-which')(__dirname).sync('jest'), ['--config', 'config.js', 'xyz.js'], - { stdio: 'inherit' } + { stdio: 'inherit' }, )).to.equal(true); done(); @@ -33,10 +33,10 @@ describe('CommandExecutor', () => { it('returns undefined if the process exits with a successful exit code', done => { processMock = { - on: function(event, callback) { return callback(0) }, + on: function(event, callback) { return callback(0); }, }; - spawn = function() { return processMock }; + spawn = function() { return processMock; }; doneCallBack = sinon.fake(); commandExecutor = new CommandExecutor({ spawn }); @@ -49,15 +49,15 @@ describe('CommandExecutor', () => { it('returns error if the process exits with an unsuccessful exit code', done => { processMock = { - on: function(event, callback) { return callback(1) }, + on: function(event, callback) { return callback(1); }, }; - spawn = function() { return processMock }; - + spawn = function() { return processMock; }; + doneCallBack = sinon.fake(); commandExecutor = new CommandExecutor({ spawn }); commandExecutor.executeCommand('jest', ['xyz.js'], { config: 'config.js' }, doneCallBack); - + expect(doneCallBack.calledWith(undefined)).to.equal(false); done();