Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Aug 20, 2023
1 parent fe77e87 commit 2f9127b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/rules/no-promise-executor-return.js
Expand Up @@ -74,7 +74,7 @@ function expressionIsVoid(node) {
* @param {Object} sourceCode context given by context.sourceCode
* @param {ASTNode} node The node to fix.
* @param {Object} fixer The fixer object provided by ESLint.
* @returns {Array<Object>|Object} - An array of fix objects or fix to apply to the node.
* @returns {Array<Object>} - An array of fix objects to apply to the node.
*/
function voidPrependFixer(sourceCode, node, fixer) {

Expand All @@ -100,10 +100,10 @@ function voidPrependFixer(sourceCode, node, fixer) {

const prependSpace =

// is return token, as => allows ( to be adjacent
// is return token, as => allows void to be adjacent
returnOrArrowToken.value === "return" &&

// If two tokens (return and ")") are adjacent
// If two tokens (return and "(") are adjacent
returnOrArrowToken.range[1] === firstToken.range[0];

return [
Expand All @@ -117,11 +117,11 @@ function voidPrependFixer(sourceCode, node, fixer) {
* @param {Object} sourceCode context given by context.sourceCode
* @param {ASTNode} node The node to fix.
* @param {Object} fixer The fixer object provided by ESLint.
* @returns {Array<Object>} - An array of fix objects or fix to apply to the node.
* @returns {Array<Object>} - An array of fix objects to apply to the node.
*/
function curlyWrapFixer(sourceCode, node, fixer) {

// @mdjermanovic https://github.com/eslint/eslint/pull/17282#issuecomment-1592795923
// https://github.com/eslint/eslint/pull/17282#issuecomment-1592795923
const arrowToken = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
const firstToken = sourceCode.getTokenAfter(arrowToken);
const lastToken = sourceCode.getLastToken(node);
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/rules/no-promise-executor-return.js
Expand Up @@ -172,8 +172,8 @@ ruleTester.run("no-promise-executor-return", rule, {
},

/*
* void
* arrow functions + void return is allowed
* allowVoid: true
* `=> void` and `return void` are allowed
*/
{
code: "new Promise((r) => void cbf(r));",
Expand Down Expand Up @@ -475,7 +475,7 @@ ruleTester.run("no-promise-executor-return", rule, {
errors: [eReturnsValue()]
},

// void return is not allowed unless arrow function expression
// `return void` is not allowed without `allowVoid: true`
{
code: "new Promise(() => { return void 1; })",
errors: [eReturnsValue()]
Expand Down

0 comments on commit 2f9127b

Please sign in to comment.