From e17905a44f07ff1b6389dacd4470c194e1e1c78d Mon Sep 17 00:00:00 2001 From: Andreas Wagner Date: Mon, 19 Aug 2019 15:05:04 +0200 Subject: [PATCH] Fix lint --- jest.integration.config.js | 5 +- src/const.js | 28 ++-- src/linter.js | 73 +++++---- src/parsers/json.js | 10 +- src/parsers/locale-messagesjson.js | 56 +++---- src/parsers/manifestjson.js | 2 +- src/rules/css/invalidNesting.js | 15 +- src/rules/html/warn-on-inline.js | 16 +- src/rules/html/warn-on-remote-script.js | 11 +- src/scanners/binary.js | 11 +- src/scanners/css.js | 30 ++-- src/scanners/filename.js | 55 +++---- tests/integration/run-as-production-env.js | 7 +- tests/unit/helpers.js | 170 +++++++++------------ tests/unit/io/test.crx.js | 15 +- tests/unit/io/test.xpi.js | 25 +-- tests/unit/scanners/test.javascript.js | 5 +- tests/unit/test.linter.js | 1 + tests/unit/test.message.js | 18 +-- webpack.l10n.config.babel.js | 10 +- 20 files changed, 259 insertions(+), 304 deletions(-) diff --git a/jest.integration.config.js b/jest.integration.config.js index a2b6478765b..482124fcf4f 100644 --- a/jest.integration.config.js +++ b/jest.integration.config.js @@ -1,5 +1,6 @@ const config = require('./jest.config'); -module.exports = Object.assign({}, config, { +module.exports = { + ...config, testMatch: ['/**/integration(*).js?(x)'], -}); +}; diff --git a/src/const.js b/src/const.js index e91759b573d..36580344ae6 100644 --- a/src/const.js +++ b/src/const.js @@ -12,21 +12,19 @@ export const EXTERNAL_RULE_MAPPING = { 'no-unsafe-innerhtml/no-unsafe-innerhtml': ESLINT_WARNING, }; -export const ESLINT_RULE_MAPPING = Object.assign( - { - 'deprecated-entities': ESLINT_WARNING, - 'event-listener-fourth': ESLINT_WARNING, - 'global-require-arg': ESLINT_WARNING, - 'opendialog-nonlit-uri': ESLINT_WARNING, - 'opendialog-remote-uri': ESLINT_WARNING, - 'webextension-api': ESLINT_WARNING, - 'webextension-unsupported-api': ESLINT_WARNING, - 'content-scripts-file-absent': ESLINT_ERROR, - 'webextension-api-compat': ESLINT_WARNING, - 'webextension-api-compat-android': ESLINT_WARNING, - }, - EXTERNAL_RULE_MAPPING -); +export const ESLINT_RULE_MAPPING = { + 'deprecated-entities': ESLINT_WARNING, + 'event-listener-fourth': ESLINT_WARNING, + 'global-require-arg': ESLINT_WARNING, + 'opendialog-nonlit-uri': ESLINT_WARNING, + 'opendialog-remote-uri': ESLINT_WARNING, + 'webextension-api': ESLINT_WARNING, + 'webextension-unsupported-api': ESLINT_WARNING, + 'content-scripts-file-absent': ESLINT_ERROR, + 'webextension-api-compat': ESLINT_WARNING, + 'webextension-api-compat-android': ESLINT_WARNING, + ...EXTERNAL_RULE_MAPPING, +}; export const VALIDATION_ERROR = 'error'; export const VALIDATION_NOTICE = 'notice'; diff --git a/src/linter.js b/src/linter.js index 1f1d2df6dfe..28db90574d1 100644 --- a/src/linter.js +++ b/src/linter.js @@ -348,10 +348,11 @@ export default class Linter { const maxSize = 1024 * 1024 * constants.MAX_FILE_SIZE_TO_PARSE_MB; if (ScannerClass !== BinaryScanner && fileSize >= maxSize) { - const filesizeError = Object.assign({}, messages.FILE_TOO_LARGE, { + const filesizeError = { + ...messages.FILE_TOO_LARGE, file: filename, type: constants.VALIDATION_ERROR, - }); + }; scanResult = { linterMessages: [filesizeError], @@ -542,19 +543,17 @@ export default class Linter { _markBannedLibs(addonMetadata, _unadvisedLibraries = UNADVISED_LIBRARIES) { Object.keys(addonMetadata.jsLibs).forEach((pathToFile) => { if (BANNED_LIBRARIES.includes(addonMetadata.jsLibs[pathToFile])) { - this.collector.addError( - Object.assign({}, messages.BANNED_LIBRARY, { - file: pathToFile, - }) - ); + this.collector.addError({ + ...messages.BANNED_LIBRARY, + file: pathToFile, + }); } if (_unadvisedLibraries.includes(addonMetadata.jsLibs[pathToFile])) { - this.collector.addWarning( - Object.assign({}, messages.UNADVISED_LIBRARY, { - file: pathToFile, - }) - ); + this.collector.addWarning({ + ...messages.UNADVISED_LIBRARY, + file: pathToFile, + }); } }); @@ -600,11 +599,10 @@ export default class Linter { log.debug(`${hashResult} detected in ${filename}`); jsLibs[filename] = hashResult; - this.collector.addNotice( - Object.assign({}, messages.KNOWN_LIBRARY, { - file: filename, - }) - ); + this.collector.addNotice({ + ...messages.KNOWN_LIBRARY, + file: filename, + }); } }) ); @@ -643,11 +641,10 @@ export default class Linter { const filenameMatch = filename.match(nameRegex); if (filenameMatch) { - this.collector.addWarning( - Object.assign({}, messages.COINMINER_USAGE_DETECTED, { - file: filename, - }) - ); + this.collector.addWarning({ + ...messages.COINMINER_USAGE_DETECTED, + file: filename, + }); } const fileDataMatch = fileData.match(nameRegex); @@ -657,13 +654,12 @@ export default class Linter { fileDataMatch ); - this.collector.addWarning( - Object.assign({}, messages.COINMINER_USAGE_DETECTED, { - file: filename, - column: matchedColumn, - line: matchedLine, - }) - ); + this.collector.addWarning({ + ...messages.COINMINER_USAGE_DETECTED, + file: filename, + column: matchedColumn, + line: matchedLine, + }); } }); @@ -675,16 +671,15 @@ export default class Linter { match ); - this.collector.addWarning( - Object.assign({}, messages.COINMINER_USAGE_DETECTED, { - file: filename, - line: matchedLine, - column: matchedColumn, - // use dataPath for our actual match to avoid any obvious - // duplicates - dataPath: match[0], - }) - ); + this.collector.addWarning({ + ...messages.COINMINER_USAGE_DETECTED, + file: filename, + line: matchedLine, + column: matchedColumn, + // use dataPath for our actual match to avoid any obvious + // duplicates + dataPath: match[0], + }); } }); } diff --git a/src/parsers/json.js b/src/parsers/json.js index d5b0792d1bc..572ddfa3fdc 100644 --- a/src/parsers/json.js +++ b/src/parsers/json.js @@ -70,10 +70,11 @@ export default class JSONParser { } catch (error) { // There was still an error, so looks like this manifest is actually // invalid. - const errorData = Object.assign({}, messages.JSON_INVALID, { + const errorData = { + ...messages.JSON_INVALID, file: this.filename, description: error.message, - }); + }; this.collector.addError(errorData); this.isValid = false; return; @@ -96,11 +97,12 @@ export default class JSONParser { if (err.warnings && err.warnings.length > 0) { err.warnings.forEach((error) => { if (error.message.startsWith('Duplicate key:')) { - const message = Object.assign({}, messages.JSON_DUPLICATE_KEY, { + const message = { + ...messages.JSON_DUPLICATE_KEY, file: this.filename, line: error.line, description: `${error.message} found in JSON`, - }); + }; this.collector.addError(message); this.isValid = false; } diff --git a/src/parsers/locale-messagesjson.js b/src/parsers/locale-messagesjson.js index 47d0c26e9ce..43cce4b13a7 100644 --- a/src/parsers/locale-messagesjson.js +++ b/src/parsers/locale-messagesjson.js @@ -54,7 +54,7 @@ export default class LocaleMessagesJSONParser extends JSONParser { } } - return Object.assign({}, baseObject, overrides); + return { ...baseObject, ...overrides }; } getLowercasePlaceholders(message) { @@ -97,41 +97,32 @@ export default class LocaleMessagesJSONParser extends JSONParser { if (!visitedLowercaseMessages.includes(message.toLowerCase())) { visitedLowercaseMessages.push(message.toLowerCase()); } else { - this.collector.addError( - Object.assign({}, messages.JSON_DUPLICATE_KEY, { - file: this.filename, - description: `Case-insensitive duplicate message name: ${message} found in JSON`, - dataPath: `/${message}`, - }) - ); + this.collector.addError({ + ...messages.JSON_DUPLICATE_KEY, + file: this.filename, + description: `Case-insensitive duplicate message name: ${message} found in JSON`, + dataPath: `/${message}`, + }); this.isValid = false; } if (message.startsWith('@@')) { - this.collector.addWarning( - Object.assign( - { - file: this.filename, - dataPath: `/${message}`, - }, - messages.PREDEFINED_MESSAGE_NAME - ) - ); + this.collector.addWarning({ + file: this.filename, + dataPath: `/${message}`, + ...messages.PREDEFINED_MESSAGE_NAME, + }); } const messageContent = this.parsedJSON[message].message; let matches = regexp.exec(messageContent); while (matches !== null) { if (!this.hasPlaceholder(message, matches[1])) { - this.collector.addWarning( - Object.assign( - { - file: this.filename, - dataPath: `/${message}/placeholders/${matches[1]}`, - }, - messages.MISSING_PLACEHOLDER - ) - ); + this.collector.addWarning({ + file: this.filename, + dataPath: `/${message}/placeholders/${matches[1]}`, + ...messages.MISSING_PLACEHOLDER, + }); } matches = regexp.exec(messageContent); } @@ -150,13 +141,12 @@ export default class LocaleMessagesJSONParser extends JSONParser { ) { visitedLowercasePlaceholders.push(placeholder.toLowerCase()); } else { - this.collector.addError( - Object.assign({}, messages.JSON_DUPLICATE_KEY, { - file: this.filename, - description: `Case-insensitive duplicate placeholder name: ${placeholder} found in JSON`, - dataPath: `/${message}/placeholders/${placeholder}`, - }) - ); + this.collector.addError({ + ...messages.JSON_DUPLICATE_KEY, + file: this.filename, + description: `Case-insensitive duplicate placeholder name: ${placeholder} found in JSON`, + dataPath: `/${message}/placeholders/${placeholder}`, + }); this.isValid = false; } } diff --git a/src/parsers/manifestjson.js b/src/parsers/manifestjson.js index 7e2ae374467..e9c22527661 100644 --- a/src/parsers/manifestjson.js +++ b/src/parsers/manifestjson.js @@ -235,7 +235,7 @@ export default class ManifestJSONParser extends JSONParser { "${error.data}" at ${match[2]}.`; } - return Object.assign({}, baseObject, overrides); + return { ...baseObject, ...overrides }; } _validate() { diff --git a/src/rules/css/invalidNesting.js b/src/rules/css/invalidNesting.js index d195e40f629..9667249e8cf 100644 --- a/src/rules/css/invalidNesting.js +++ b/src/rules/css/invalidNesting.js @@ -10,14 +10,13 @@ export function invalidNesting( for (let i = 0; i < cssNode.nodes.length; i++) { const node = cssNode.nodes[i]; if (node.type === 'rule') { - messageList.push( - Object.assign({}, messages.INVALID_SELECTOR_NESTING, { - type: 'warning', - line: startLine, - column: startColumn, - file: filename, - }) - ); + messageList.push({ + ...messages.INVALID_SELECTOR_NESTING, + type: 'warning', + line: startLine, + column: startColumn, + file: filename, + }); break; } } diff --git a/src/rules/html/warn-on-inline.js b/src/rules/html/warn-on-inline.js index 94fe4999dc1..9342b3709ef 100644 --- a/src/rules/html/warn-on-inline.js +++ b/src/rules/html/warn-on-inline.js @@ -9,15 +9,13 @@ export async function warnOnInline($, filename) { ($(element).attr('type') === undefined || $(element).attr('type') === 'text/javascript') ) { - linterMessages.push( - Object.assign({}, messages.INLINE_SCRIPT, { - /* This could occur in any HTML file, so let's make it - * a warning in case they've included any other file. - */ - type: VALIDATION_WARNING, - file: filename, - }) - ); + linterMessages.push({ + ...messages.INLINE_SCRIPT, + /* This could occur in any HTML file, so let's make it + * a warning in case they've included any other file. */ + type: VALIDATION_WARNING, + file: filename, + }); } }); diff --git a/src/rules/html/warn-on-remote-script.js b/src/rules/html/warn-on-remote-script.js index f3d7ebae651..6c593978d6e 100644 --- a/src/rules/html/warn-on-remote-script.js +++ b/src/rules/html/warn-on-remote-script.js @@ -9,12 +9,11 @@ export async function warnOnRemoteScript($, filename) { const src = $(element).attr('src'); if (src !== undefined && !isStrictRelativeUrl(src)) { - linterMessages.push( - Object.assign({}, messages.REMOTE_SCRIPT, { - type: VALIDATION_WARNING, - file: filename, - }) - ); + linterMessages.push({ + ...messages.REMOTE_SCRIPT, + type: VALIDATION_WARNING, + file: filename, + }); } }); diff --git a/src/scanners/binary.js b/src/scanners/binary.js index b0db314329e..ac98d017c8b 100644 --- a/src/scanners/binary.js +++ b/src/scanners/binary.js @@ -15,12 +15,11 @@ export default class BinaryScanner extends BaseScanner { if (Object.keys(values).some((v) => values[v] !== buffer[v])) { return; } - this.linterMessages.push( - Object.assign({}, messages.FLAGGED_FILE_TYPE, { - type: constants.VALIDATION_NOTICE, - file: this.filename, - }) - ); + this.linterMessages.push({ + ...messages.FLAGGED_FILE_TYPE, + type: constants.VALIDATION_NOTICE, + file: this.filename, + }); } async scan() { diff --git a/src/scanners/css.js b/src/scanners/css.js index 13358e8192b..4a7292fe54e 100644 --- a/src/scanners/css.js +++ b/src/scanners/css.js @@ -16,10 +16,11 @@ export default class CSSScanner extends BaseScanner { processCode(cssNode, cssInstruction, _rules = this._defaultRules) { const file = this.filename; - const cssOptions = Object.assign({}, this.options, { + const cssOptions = { + ...this.options, startLine: cssNode.source.start.line, startColumn: cssNode.source.start.column, - }); + }; const info = { file, @@ -79,19 +80,18 @@ export default class CSSScanner extends BaseScanner { throw e; } - this.linterMessages.push( - Object.assign({}, CSS_SYNTAX_ERROR, { - type: VALIDATION_WARNING, - // Use the reason for the error as the message. - // e.message includes an absolute path. - message: e.reason, - column: e.column, - line: e.line, - // We use our own ref to the file as postcss outputs - // absolute paths. - file: this.filename, - }) - ); + this.linterMessages.push({ + ...CSS_SYNTAX_ERROR, + type: VALIDATION_WARNING, + // Use the reason for the error as the message. + // e.message includes an absolute path. + message: e.reason, + column: e.column, + line: e.line, + // We use our own ref to the file as postcss outputs + // absolute paths. + file: this.filename, + }); // A syntax error has been encounted so it's game over. return null; diff --git a/src/scanners/filename.js b/src/scanners/filename.js index 966beb38551..c59452e797f 100644 --- a/src/scanners/filename.js +++ b/src/scanners/filename.js @@ -14,40 +14,35 @@ export default class FilenameScanner extends BaseScanner { const filenameWithoutPath = basename(this.filename); if (this.filename.match(constants.ALREADY_SIGNED_REGEX)) { - this.linterMessages.push( - Object.assign({}, messages.ALREADY_SIGNED, { - type: constants.VALIDATION_WARNING, - file: this.filename, - }) - ); + this.linterMessages.push({ + ...messages.ALREADY_SIGNED, + type: constants.VALIDATION_WARNING, + file: this.filename, + }); } else if (this.filename.match(constants.HIDDEN_FILE_REGEX)) { - this.linterMessages.push( - Object.assign({}, messages.HIDDEN_FILE, { - type: constants.VALIDATION_WARNING, - file: this.filename, - }) - ); + this.linterMessages.push({ + ...messages.HIDDEN_FILE, + type: constants.VALIDATION_WARNING, + file: this.filename, + }); } else if (this.filename.match(constants.FLAGGED_FILE_REGEX)) { - this.linterMessages.push( - Object.assign({}, messages.FLAGGED_FILE, { - type: constants.VALIDATION_WARNING, - file: this.filename, - }) - ); + this.linterMessages.push({ + ...messages.FLAGGED_FILE, + type: constants.VALIDATION_WARNING, + file: this.filename, + }); } else if (constants.FLAGGED_FILE_EXTENSIONS.includes(extension)) { - this.linterMessages.push( - Object.assign({}, messages.FLAGGED_FILE_EXTENSION, { - type: constants.VALIDATION_WARNING, - file: this.filename, - }) - ); + this.linterMessages.push({ + ...messages.FLAGGED_FILE_EXTENSION, + type: constants.VALIDATION_WARNING, + file: this.filename, + }); } else if (constants.RESERVED_FILENAMES.includes(filenameWithoutPath)) { - this.linterMessages.push( - Object.assign({}, messages.RESERVED_FILENAME, { - type: constants.VALIDATION_ERROR, - file: this.filename, - }) - ); + this.linterMessages.push({ + ...messages.RESERVED_FILENAME, + type: constants.VALIDATION_ERROR, + file: this.filename, + }); } else { throw new Error(`Filename didn't match a regex: ${this.filename}.`); } diff --git a/tests/integration/run-as-production-env.js b/tests/integration/run-as-production-env.js index 34a7338c56b..2a2e280e7dd 100644 --- a/tests/integration/run-as-production-env.js +++ b/tests/integration/run-as-production-env.js @@ -29,7 +29,7 @@ if (!jestTestsPath) { tmp.setGracefulCleanup(tmpOptions); function spawnWithShell(cmd, args, options) { - return spawn(cmd, args, Object.assign({}, baseSpawnOptions, options)); + return spawn(cmd, args, { ...baseSpawnOptions, ...options }); } function getPackedName() { @@ -113,10 +113,11 @@ function runIntegrationTests(packageDir) { 'npm', ['run', npmScript, '--', jestTestsPath], { - env: Object.assign({}, process.env, { + env: { + ...process.env, PATH: process.env.PATH, TEST_BIN_PATH: path.join(packageDir, 'bin'), - }), + }, } ); diff --git a/tests/unit/helpers.js b/tests/unit/helpers.js index 42d88e359b2..43937188e03 100644 --- a/tests/unit/helpers.js +++ b/tests/unit/helpers.js @@ -113,127 +113,99 @@ export function validHTML(contents = '') { } export function validMetadata(metadata = {}) { - return Object.assign( - {}, - { - type: PACKAGE_EXTENSION, - }, - metadata - ); + return { + type: PACKAGE_EXTENSION, + ...metadata, + }; } export function validManifestJSON(extra) { - return JSON.stringify( - Object.assign( - {}, - { - name: 'my extension', - manifest_version: 2, - applications: { - gecko: { - id: '{daf44bf7-a45e-4450-979c-91cf07434c3d}', - strict_min_version: '48.0.0', - }, - }, - version: '0.1', + return JSON.stringify({ + name: 'my extension', + manifest_version: 2, + applications: { + gecko: { + id: '{daf44bf7-a45e-4450-979c-91cf07434c3d}', + strict_min_version: '48.0.0', }, - extra - ) - ); + }, + version: '0.1', + ...extra, + }); } export function validDictionaryManifestJSON(extra) { - return JSON.stringify( - Object.assign( - {}, - { - manifest_version: 2, - name: 'My French Dictionary', - version: '57.0a1', - dictionaries: { - fr: '/path/to/fr.dic', - }, - applications: { - gecko: { - id: '@my-dictionary', - }, - }, + return JSON.stringify({ + manifest_version: 2, + name: 'My French Dictionary', + version: '57.0a1', + dictionaries: { + fr: '/path/to/fr.dic', + }, + applications: { + gecko: { + id: '@my-dictionary', }, - extra - ) - ); + }, + ...extra, + }); } export function validLangpackManifestJSON(extra) { - return JSON.stringify( - Object.assign( - {}, - { - manifest_version: 2, - name: 'My Language Pack', - version: '57.0', - langpack_id: 'de', - languages: { - de: { - chrome_resources: {}, - version: '57.0a1', - }, - }, + return JSON.stringify({ + manifest_version: 2, + name: 'My Language Pack', + version: '57.0', + langpack_id: 'de', + languages: { + de: { + chrome_resources: {}, + version: '57.0a1', }, - extra - ) - ); + }, + ...extra, + }); } export function validStaticThemeManifestJSON(extra) { - return JSON.stringify( - Object.assign( - {}, - { - manifest_version: 2, - name: 'My Static Theme', - version: '1.0', - theme: { - images: { - theme_frame: 'weta.png', - }, - colors: { - frame: '#adb09f', - tab_background_text: '#000', - background_tab_text: 'rgba(255, 192, 0, 0)', - bookmark_text: 'rgb(255, 255, 255),', - toolbar_field_text: 'hsl(120, 100%, 50%)', - }, - }, + return JSON.stringify({ + manifest_version: 2, + name: 'My Static Theme', + version: '1.0', + theme: { + images: { + theme_frame: 'weta.png', + }, + colors: { + frame: '#adb09f', + tab_background_text: '#000', + background_tab_text: 'rgba(255, 192, 0, 0)', + bookmark_text: 'rgb(255, 255, 255),', + toolbar_field_text: 'hsl(120, 100%, 50%)', }, - extra - ) - ); + }, + ...extra, + }); } export function validLocaleMessagesJSON() { - return JSON.stringify( - Object.assign( - {}, - { + return JSON.stringify({ + foo: { + message: 'bar', + }, + Placeh0lder_Test: { + message: '$foo$ bar $BA2$', + placeholders: { foo: { - message: 'bar', + content: '$1', + example: 'FOO', }, - Placeh0lder_Test: { - message: '$foo$ bar $BA2$', - placeholders: { - foo: { - content: '$1', - example: 'FOO', - }, - BA2: { - content: 'baz', - }, - }, + BA2: { + content: 'baz', }, - } - ) - ); + }, + }, + }); } export function unexpectedSuccess() { diff --git a/tests/unit/io/test.crx.js b/tests/unit/io/test.crx.js index 61d0e720c80..dfcc5e14c02 100644 --- a/tests/unit/io/test.crx.js +++ b/tests/unit/io/test.crx.js @@ -9,23 +9,26 @@ const defaultData = { compressionMethod: DEFLATE_COMPRESSION, }; -const chromeManifestEntry = Object.assign({}, defaultData, { +const chromeManifestEntry = { + ...defaultData, compressedSize: 138, uncompressedSize: 275, fileName: 'chrome.manifest', -}); +}; -const installFileEntry = Object.assign({}, defaultData, { +const installFileEntry = { + ...defaultData, compressedSize: 416, uncompressedSize: 851, fileName: 'manifest.json', -}); +}; -const dupeInstallFileEntry = Object.assign({}, defaultData, { +const dupeInstallFileEntry = { + ...defaultData, compressedSize: 416, uncompressedSize: 851, fileName: 'manifest.json', -}); +}; const chromeContentDir = { compressionMethod: NO_COMPRESSION, diff --git a/tests/unit/io/test.xpi.js b/tests/unit/io/test.xpi.js index 22c2256539f..ad252027a72 100644 --- a/tests/unit/io/test.xpi.js +++ b/tests/unit/io/test.xpi.js @@ -11,35 +11,40 @@ const defaultData = { compressionMethod: DEFLATE_COMPRESSION, }; -const chromeManifestEntry = Object.assign({}, defaultData, { +const chromeManifestEntry = { + ...defaultData, compressedSize: 138, uncompressedSize: 275, fileName: 'chrome.manifest', -}); +}; -const installFileEntry = Object.assign({}, defaultData, { +const installFileEntry = { + ...defaultData, compressedSize: 416, uncompressedSize: 851, fileName: 'manifest.json', -}); +}; -const dupeInstallFileEntry = Object.assign({}, defaultData, { +const dupeInstallFileEntry = { + ...defaultData, compressedSize: 416, uncompressedSize: 851, fileName: 'manifest.json', -}); +}; -const jsMainFileEntry = Object.assign({}, defaultData, { +const jsMainFileEntry = { + ...defaultData, compressedSize: 41, uncompressedSize: 85, fileName: 'main.js', -}); +}; -const jsSecondaryFileEntry = Object.assign({}, defaultData, { +const jsSecondaryFileEntry = { + ...defaultData, compressedSize: 456, uncompressedSize: 851, fileName: 'secondary.js', -}); +}; const chromeContentDir = { compressionMethod: NO_COMPRESSION, diff --git a/tests/unit/scanners/test.javascript.js b/tests/unit/scanners/test.javascript.js index cefebf68bc0..bd4c7843c30 100644 --- a/tests/unit/scanners/test.javascript.js +++ b/tests/unit/scanners/test.javascript.js @@ -268,11 +268,12 @@ describe('JavaScript Scanner', () => { const fakeRules = { 'metadata-not-passed': { create: () => {} } }; const fakeMessages = { - METADATA_NOT_PASSED: Object.assign({}, fakeMessageData, { + METADATA_NOT_PASSED: { + ...fakeMessageData, code: 'METADATA_NOT_PASSED', message: 'Should not happen', description: 'Should not happen', - }), + }, }; const fakeMetadata = { addonMetadata: validMetadata({ guid: 'snowflake' }), diff --git a/tests/unit/test.linter.js b/tests/unit/test.linter.js index 4f02783e168..340a3721474 100644 --- a/tests/unit/test.linter.js +++ b/tests/unit/test.linter.js @@ -1,3 +1,4 @@ +/* eslint-disable max-classes-per-file */ import fs from 'fs'; import { oneLine } from 'common-tags'; diff --git a/tests/unit/test.message.js b/tests/unit/test.message.js index 6c38c87c58d..a784387feb3 100644 --- a/tests/unit/test.message.js +++ b/tests/unit/test.message.js @@ -29,28 +29,22 @@ describe('Message', () => { }); it("shouldn't define random opts", () => { - const MyMessage = new Message( - 'error', - Object.assign({}, fakeMessageData, { random: 'foo' }) - ); + const MyMessage = new Message('error', { + ...fakeMessageData, + random: 'foo', + }); expect(MyMessage.random).not.toEqual('foo'); }); it('should throw on missing required prop', () => { expect(() => { - const MyMessage = new Message( - 'error', - Object.assign({}, { description: 'foo' }) - ); + const MyMessage = new Message('error', { description: 'foo' }); }).toThrow(/Message data object is missing the following props/); }); it('should throw on incorrect file prop filename', () => { expect(() => { - const MyMessage = new Message( - 'error', - Object.assign({}, { filename: 'foo' }) - ); + const MyMessage = new Message('error', { filename: 'foo' }); }).toThrow(/The key for the file is "file"/); }); diff --git a/webpack.l10n.config.babel.js b/webpack.l10n.config.babel.js index a85892f7afb..7da76aa9404 100644 --- a/webpack.l10n.config.babel.js +++ b/webpack.l10n.config.babel.js @@ -48,9 +48,10 @@ const babelL10nPlugins = [ ], ]; -const BABEL_QUERY = Object.assign({}, babelrcObject, { +const BABEL_QUERY = { + ...babelrcObject, plugins: babelPlugins.concat(babelL10nPlugins), -}); +}; const [rule] = webpackConfig.module.rules; rule.loader = 'babel-loader'; @@ -59,7 +60,8 @@ delete rule.use; const rules = [rule]; rules.concat(webpackConfig.module.rules.splice(0)); -module.exports = Object.assign({}, webpackConfig, { +module.exports = { + ...webpackConfig, module: { rules, }, @@ -68,4 +70,4 @@ module.exports = Object.assign({}, webpackConfig, { new webpack.IgnorePlugin(new RegExp(`locale\\/.*\\/messages\\.js$`)), ...webpackConfig.plugins, ], -}); +};