sonarjs/prefer-promise-shorthand
eslint-plugin-sonarjs
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/prefer-promise-shorthand": "error",
},
},
];let fulfilledPromise = new Promise(resolve => resolve(42));
let rejectedPromise = new Promise(function(resolve, reject) {
reject('fail');
});let fulfilledPromise = Promise.resolve(42);
let rejectedPromise = Promise.reject('fail');Examples from the ESLint documentation.
sonarjs/prefer-promise-shorthand
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/prefer-promise-shorthand": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Native APIs should be preferred over Lodash and Underscore.js methods
Native APIs should be preferred over jQuery utility methods
"RegExp.exec()" should be preferred over "String.match()"
Native APIs should be preferred over Axios utility methods
Return of boolean expressions should not be wrapped into an "if-then-else" statement