Skip to content

Commit 27e94ba

Browse files
committed
[Refactor] jsx-indent: clean up the fixer function
1 parent f8b4aa3 commit 27e94ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/rules/jsx-indent.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,17 @@ module.exports = {
104104
* @private
105105
*/
106106
function getFixerFunction(node, needed) {
107-
return function fix(fixer) {
108-
const indent = Array(needed + 1).join(indentChar);
109-
if (node.type === 'JSXText' || node.type === 'Literal') {
107+
const indent = Array(needed + 1).join(indentChar);
108+
109+
if (node.type === 'JSXText' || node.type === 'Literal') {
110+
return function fix(fixer) {
110111
const regExp = /\n[\t ]*(\S)/g;
111112
const fixedText = node.raw.replace(regExp, (match, p1) => `\n${indent}${p1}`);
112113
return fixer.replaceText(node, fixedText);
113-
}
114+
};
115+
}
116+
117+
return function fix(fixer) {
114118
return fixer.replaceTextRange(
115119
[node.range[0] - node.loc.start.column, node.range[0]],
116120
indent

0 commit comments

Comments
 (0)