mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Removed use of native JS Error objects
closes https://linear.app/tryghost/issue/CORE-54/fix-errors-in-utils-repo-release-utils - The latest ESLint rules forbid use of native JS errors, updated the codebase before bumping the ESLint version
This commit is contained in:
parent
2b82d2afce
commit
be6c8ea390
2 changed files with 11 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
const emojiRegex = require('emoji-regex');
|
||||
const _ = require('lodash');
|
||||
const {IncorrectUsageError} = require('@tryghost/errors');
|
||||
|
||||
const timestamp = /^[0-9]{10} /;
|
||||
const separator = /^\* /;
|
||||
|
@ -16,7 +17,9 @@ const emojiOrder = ['💡', '🐛', '🎨', '💄', '✨', '🔒'];
|
|||
|
||||
module.exports.filterEmojiCommits = (content) => {
|
||||
if (!_.isArray(content)) {
|
||||
throw new Error('Expected array of strings.');
|
||||
throw new IncorrectUsageError({
|
||||
message: 'Expected array of strings.'
|
||||
});
|
||||
}
|
||||
|
||||
return content.reduce((emojiLines, currentLine) => {
|
||||
|
@ -33,7 +36,9 @@ module.exports.filterEmojiCommits = (content) => {
|
|||
|
||||
module.exports.sortByEmoji = (content) => {
|
||||
if (!_.isArray(content)) {
|
||||
throw new Error('Expected array of strings.');
|
||||
throw new IncorrectUsageError({
|
||||
message: 'Expected array of strings.'
|
||||
});
|
||||
}
|
||||
|
||||
content.sort((a, b) => {
|
||||
|
@ -53,6 +58,8 @@ module.exports.checkMissingOptions = (options = {}, ...requiredFields) => {
|
|||
});
|
||||
|
||||
if (missing.length) {
|
||||
throw new Error(`Missing options: ${missing.join(', ')}`);
|
||||
throw new IncorrectUsageError({
|
||||
message: `Missing options: ${missing.join(', ')}`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
"sinon": "11.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tryghost/errors": "^0.2.13",
|
||||
"bluebird": "^3.7.2",
|
||||
"emoji-regex": "^9.2.2",
|
||||
"execa": "^4.1.0",
|
||||
|
|
Loading…
Add table
Reference in a new issue