Skip to content

Commit

Permalink
Remove indentation arg
Browse files Browse the repository at this point in the history
  • Loading branch information
snowypowers committed Nov 2, 2016
1 parent a7764f7 commit 2507f37
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions lib/rules/jsx-first-prop-new-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,10 @@ module.exports = {
schema: [{
enum: ['always', 'never', 'multiline', 'multiline-multiprop']
}]

},

create: function (context) {
var configuration = context.options[0];
var indentType = 'space';
var indentSize = 2;
var sourceCode = context.getSourceCode();

if (context.options.length > 1) {
if (context.options[1] === 'tab') {
indentSize = 1;
indentType = 'tab';
} else if (typeof context.options[1] === 'number') {
indentSize = context.options[1];
indentType = 'space';
}
}

function getNodeIndent(node) {
var src = sourceCode.getText(node, node.loc.start.column).split('\n')[0];
var regExp;
if (indentType === 'space') {
regExp = new RegExp('^[ ]+');
} else {
regExp = new RegExp('^[\t' + ']+');
}
var indent = regExp.exec(src);
return indent ? indent[0].length : 0;
}

function isMultilineJSX(jsxNode) {
return jsxNode.loc.start.line < jsxNode.loc.end.line;
Expand All @@ -68,9 +42,7 @@ module.exports = {
node: decl,
message: 'Property should be placed on a new line',
fix: function(fixer) {
var neededIndent = getNodeIndent(node) + indentSize;
var insert = '\n' + Array(neededIndent + 1).join(indentType === 'space' ? ' ' : '\t');
return fixer.replaceTextRange([node.name.end, decl.start], insert);
return fixer.replaceTextRange([node.name.end, decl.start], '\n');
}
});
}
Expand Down

0 comments on commit 2507f37

Please sign in to comment.