Skip to content

Commit

Permalink
Merge e17905a into 1e9adab
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] committed Aug 19, 2019
2 parents 1e9adab + e17905a commit d90488a
Show file tree
Hide file tree
Showing 22 changed files with 279 additions and 324 deletions.
5 changes: 3 additions & 2 deletions jest.integration.config.js
@@ -1,5 +1,6 @@
const config = require('./jest.config');

module.exports = Object.assign({}, config, {
module.exports = {
...config,
testMatch: ['<rootDir>/**/integration(*).js?(x)'],
});
};
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -97,7 +97,7 @@
"comment-json": "2.1.0",
"coveralls": "3.0.6",
"doctoc": "1.4.0",
"eslint-config-amo": "1.18.0",
"eslint-config-amo": "1.19.1",
"eslint-config-prettier": "6.0.0",
"eslint-plugin-async-await": "0.0.0",
"eslint-plugin-jest": "22.15.1",
Expand Down
28 changes: 13 additions & 15 deletions src/const.js
Expand Up @@ -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';
Expand Down
73 changes: 34 additions & 39 deletions src/linter.js
Expand Up @@ -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],
Expand Down Expand Up @@ -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,
});
}
});

Expand Down Expand Up @@ -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,
});
}
})
);
Expand Down Expand Up @@ -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);
Expand All @@ -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,
});
}
});

Expand All @@ -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],
});
}
});
}
Expand Down
10 changes: 6 additions & 4 deletions src/parsers/json.js
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
56 changes: 23 additions & 33 deletions src/parsers/locale-messagesjson.js
Expand Up @@ -54,7 +54,7 @@ export default class LocaleMessagesJSONParser extends JSONParser {
}
}

return Object.assign({}, baseObject, overrides);
return { ...baseObject, ...overrides };
}

getLowercasePlaceholders(message) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/manifestjson.js
Expand Up @@ -235,7 +235,7 @@ export default class ManifestJSONParser extends JSONParser {
"${error.data}" at ${match[2]}.`;
}

return Object.assign({}, baseObject, overrides);
return { ...baseObject, ...overrides };
}

_validate() {
Expand Down
15 changes: 7 additions & 8 deletions src/rules/css/invalidNesting.js
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit d90488a

Please sign in to comment.