Skip to content

Commit

Permalink
Don't use .reverse()
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 19, 2021
1 parent c63e594 commit 63f52ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rules/no-array-for-each.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function getFixFunction(callExpression, sourceCode, functionInfo) {
const {returnStatements} = functionInfo.get(callback);

const getForOfLoopHeadText = () => {
const parametersText = parameters.map(parameter => sourceCode.getText(parameter));
const [elementText, indexText] = parameters.map(parameter => sourceCode.getText(parameter));
const useEntries = parameters.length === 2;

let text = 'for (const ';
text += useEntries ? `[${parametersText.reverse().join(', ')}]` : parametersText[0];
text += useEntries ? `[${indexText}, ${elementText}]` : elementText;

text += ' of ';

Expand Down

0 comments on commit 63f52ef

Please sign in to comment.