diff --git a/.eslintrc.json b/.eslintrc.json
index 12355ac34..237650932 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -7,51 +7,53 @@
"parserOptions": {
"ecmaVersion": 2017
},
+ "plugins": [
+ "promise",
+ "json"
+ ],
"rules": {
"indent": ["error",
2
],
- "no-console": [
- 0
- ],
+ "no-console": "off",
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
- "no-template-curly-in-string": [1],
- "no-unsafe-negation": [1],
- "array-callback-return": [1],
+ "no-template-curly-in-string": "warn",
+ "no-unsafe-negation": "warn",
+ "array-callback-return": "warn",
"arrow-parens": ["warn", "always"],
"template-curly-spacing": "warn",
- "eqeqeq": [2, "smart"],
- "no-eval": [2],
- "no-global-assign": [2],
- "no-implied-eval": [2],
+ "eqeqeq": ["error", "smart"],
+ "no-eval": "error",
+ "no-global-assign": "error",
+ "no-implied-eval": "error",
"lines-around-comment": ["warn", {"beforeLineComment": true}],
"spaced-comment": ["warn", "always", { "line": { "exceptions": ["-", "="] } }],
- "no-script-url": [2],
- "no-throw-literal": [2],
- "yoda": [1],
- "no-path-concat": [2],
- "eol-last": [1],
- "no-nested-ternary": [1],
- "no-tabs": [2],
- "no-unneeded-ternary": [1],
- "object-curly-spacing": [1],
+ "no-script-url": "error",
+ "no-throw-literal": "error",
+ "yoda": "warn",
+ "no-path-concat": "error",
+ "eol-last": "warn",
+ "no-nested-ternary": "warn",
+ "no-tabs": "error",
+ "no-unneeded-ternary": "warn",
+ "object-curly-spacing": "warn",
"space-infix-ops": ["error"],
"space-in-parens": ["error", "never"],
"space-unary-ops": ["error", {
"words": true,
"nonwords": false
}],
- "no-const-assign": [2],
- "no-duplicate-imports": [2],
- "prefer-template": [1],
+ "no-const-assign": "error",
+ "no-duplicate-imports": "error",
+ "prefer-template": "warn",
"comma-spacing": ["error", {
"after": true
}],
- "no-var": [2],
- "no-lonely-if": [2],
- "curly": [2],
+ "no-var": "error",
+ "no-lonely-if": "error",
+ "curly": "error",
"no-unused-vars": ["error", {
"argsIgnorePattern": "^_|next",
"varsIgnorePattern": "^_"
@@ -61,6 +63,13 @@
}],
"newline-per-chained-call": ["error", {
"ignoreChainWithDepth": 2
- }]
+ }],
+ "promise/no-return-wrap": "error",
+ "promise/param-names": "error",
+ "promise/catch-or-return": "error",
+ "promise/no-native": "off",
+ "promise/no-nesting": "warn",
+ "promise/no-promise-in-callback": "warn",
+ "promise/no-callback-in-promise": "warn"
}
}
diff --git a/bin/cli-jobs b/bin/cli-jobs
index f22e1068b..c5aefc518 100755
--- a/bin/cli-jobs
+++ b/bin/cli-jobs
@@ -78,18 +78,23 @@ function rangeJobsByState(state = 'complete', limit) {
/**
* Cleans up the jobs that are in the queue.
*/
-function cleanupJobs(options) {
+async function cleanupJobs(options) {
const n = 100;
- Promise.all([
- rangeJobsByState('complete', n),
- options.stuck ? rangeJobsByState('failed', n) : false
- ])
- .then((joblists) => joblists.filter((jobs) => jobs).map(removeJobs))
- .then(() => {
+ try {
+ const joblists = await Promise.all([
+ rangeJobsByState('complete', n),
+ options.stuck ? rangeJobsByState('failed', n) : false
+ ]);
+
+ await joblists.filter((jobs) => jobs).map(removeJobs);
+
util.shutdown();
console.log('Removed old jobs');
- });
+ } catch (err) {
+ console.error(err);
+ util.shutdown(1);
+ }
}
//==============================================================================
diff --git a/bin/cli-plugins b/bin/cli-plugins
index 1de1c97d4..b7e301fce 100755
--- a/bin/cli-plugins
+++ b/bin/cli-plugins
@@ -53,7 +53,7 @@ function versionMatch(name, version) {
}
}
-const EXTERNAL = /^\w[a-z\-0-9\.]+$/; // Match "react", "path", "fs", "lodash.random", etc.
+const EXTERNAL = /^\w[a-z\-0-9.]+$/; // Match "react", "path", "fs", "lodash.random", etc.
function reconcilePackages({quiet = false, upgradeRemote = false}) {
const fetchable = [];
diff --git a/bin/cli-users b/bin/cli-users
index 057c0a806..c6555ab28 100755
--- a/bin/cli-users
+++ b/bin/cli-users
@@ -98,39 +98,32 @@ function getUserCreateAnswers(options) {
/**
* Prompts for input and registers a user based on those.
*/
-function createUser(options) {
- getUserCreateAnswers(options)
- .then((answers) => {
- if (answers.password !== answers.confirmPassword) {
- return Promise.reject(new Error('Passwords do not match'));
- }
+async function createUser(options) {
+ try {
+ const answers = await getUserCreateAnswers(options);
+ if (answers.password !== answers.confirmPassword) {
+ throw new Error('Passwords do not match');
+ }
- return answers;
- })
- .then((answers) => {
- return UsersService
- .createLocalUser(answers.email.trim(), answers.password.trim(), answers.username.trim())
- .then((user) => {
- console.log(`Created user ${user.id}.`);
+ const user = await UsersService.createLocalUser(answers.email.trim(), answers.password.trim(), answers.username.trim());
+ console.log(`Created user ${user.id}.`);
- if (answers.roles.length > 0) {
- return Promise.all(answers.roles.map((role) => {
- return UsersService
- .addRoleToUser(user.id, role)
- .then(() => {
- console.log(`Added the role ${role} to User ${user.id}.`);
- });
- }));
- }
- });
- })
- .then(() => {
- util.shutdown();
- })
- .catch((err) => {
- console.error(err);
- util.shutdown();
- });
+ if (answers.roles.length > 0) {
+ return Promise.all(answers.roles.map((role) => {
+ return UsersService
+ .addRoleToUser(user.id, role)
+ .then(() => {
+ console.log(`Added the role ${role} to User ${user.id}.`);
+ });
+ }));
+ }
+
+ util.shutdown();
+
+ } catch (err) {
+ console.error(err);
+ util.shutdown();
+ }
}
/**
@@ -169,21 +162,21 @@ function passwd(userID) {
validate: validateRequired('Confirm Password is required')
}
])
- .then((answers) => {
- if (answers.password !== answers.confirmPassword) {
- return Promise.reject(new Error('Password mismatch'));
- }
+ .then((answers) => {
+ if (answers.password !== answers.confirmPassword) {
+ throw new Error('Password mismatch');
+ }
- return UsersService.changePassword(userID, answers.password);
- })
- .then(() => {
- console.log('Password changed.');
- util.shutdown();
- })
- .catch((err) => {
- console.error(err);
- util.shutdown(1);
- });
+ return UsersService.changePassword(userID, answers.password);
+ })
+ .then(() => {
+ console.log('Password changed.');
+ util.shutdown();
+ })
+ .catch((err) => {
+ console.error(err);
+ util.shutdown(1);
+ });
}
/**
diff --git a/bin/verifications/database/comments.js b/bin/verifications/database/comments.js
index f7dd4d397..231badabb 100644
--- a/bin/verifications/database/comments.js
+++ b/bin/verifications/database/comments.js
@@ -125,7 +125,7 @@ module.exports = async ({fix, limit, batch}) => {
// Check that the action summaries match the cached counts.
if (!comment.action_counts || !(ACTION_COUNT_FIELD in comment.action_counts) || comment.action_counts[ACTION_COUNT_FIELD] !== count) {
- // Batch updates for those changes.
+ // Batch updates for those changes.
commentOperations.push({
[`action_counts.${ACTION_COUNT_FIELD}`]: count,
});
diff --git a/client/.eslintrc.json b/client/.eslintrc.json
index 5735a91a1..cde3942fa 100644
--- a/client/.eslintrc.json
+++ b/client/.eslintrc.json
@@ -4,6 +4,7 @@
"es6": true,
"mocha": true
},
+ "extends": "../.eslintrc.json",
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
diff --git a/client/coral-admin/src/actions/community.js b/client/coral-admin/src/actions/community.js
index 402a32e5d..890d834b4 100644
--- a/client/coral-admin/src/actions/community.js
+++ b/client/coral-admin/src/actions/community.js
@@ -52,16 +52,16 @@ export const newPage = () => ({
export const setRole = (id, role) => (dispatch, _, {rest}) => {
return rest(`/users/${id}/role`, {method: 'POST', body: {role}})
- .then(() => {
- return dispatch({type: SET_ROLE, id, role});
- });
+ .then(() => {
+ return dispatch({type: SET_ROLE, id, role});
+ });
};
export const setCommenterStatus = (id, status) => (dispatch, _, {rest}) => {
return rest(`/users/${id}/status`, {method: 'POST', body: {status}})
- .then(() => {
- return dispatch({type: SET_COMMENTER_STATUS, id, status});
- });
+ .then(() => {
+ return dispatch({type: SET_COMMENTER_STATUS, id, status});
+ });
};
// Ban User Dialog
diff --git a/client/coral-admin/src/actions/install.js b/client/coral-admin/src/actions/install.js
index d7210782a..d6b27115a 100644
--- a/client/coral-admin/src/actions/install.js
+++ b/client/coral-admin/src/actions/install.js
@@ -26,19 +26,19 @@ const validation = (formData, dispatch, next) => {
// Required Validation
const empty = validKeys
- .filter((name) => {
- const cond = !formData[name].length;
+ .filter((name) => {
+ const cond = !formData[name].length;
- if (cond) {
+ if (cond) {
- // Adding Error
- dispatch(addError(name, 'This field is required.'));
- } else {
- dispatch(addError(name, ''));
- }
+ // Adding Error
+ dispatch(addError(name, 'This field is required.'));
+ } else {
+ dispatch(addError(name, ''));
+ }
- return cond;
- });
+ return cond;
+ });
if (empty.length) {
dispatch(hasError());
diff --git a/client/coral-admin/src/components/AdminLogin.js b/client/coral-admin/src/components/AdminLogin.js
index e75e66d23..014773a1b 100644
--- a/client/coral-admin/src/components/AdminLogin.js
+++ b/client/coral-admin/src/components/AdminLogin.js
@@ -69,23 +69,23 @@ class AdminLogin extends React.Component {
);
const requestPasswordForm = (
this.props.passwordRequestSuccess
- ?
{
- location.href = location.href;
- }}>
+ ?
{
+ location.href = location.href;
+ }}>
{this.props.passwordRequestSuccess} Sign in
- :
+ :
);
return (
diff --git a/client/coral-admin/src/components/SuspendUserDialog.js b/client/coral-admin/src/components/SuspendUserDialog.js
index d2ef23891..0ed947506 100644
--- a/client/coral-admin/src/components/SuspendUserDialog.js
+++ b/client/coral-admin/src/components/SuspendUserDialog.js
@@ -65,7 +65,7 @@ class SuspendUserDialog extends React.Component {
{t('suspenduser.title_suspend')}
- {t('suspenduser.description_suspend', username)}
+ {t('suspenduser.description_suspend', username)}