Skip to content

Commit c854e1d

Browse files
committed
Remove unused code
1 parent a6d4df5 commit c854e1d

File tree

1 file changed

+16
-37
lines changed

1 file changed

+16
-37
lines changed

lib/rules/jsx-indent-props.js

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -81,62 +81,41 @@ module.exports = {
8181
* @param {ASTNode} node Node violating the indent rule
8282
* @param {Number} needed Expected indentation character count
8383
* @param {Number} gotten Indentation character count in the actual node/code
84-
* @param {Object=} loc Error line and column location
8584
*/
86-
function report(node, needed, gotten, loc) {
85+
function report(node, needed, gotten) {
8786
const msgContext = {
8887
needed: needed,
8988
type: indentType,
9089
characters: needed === 1 ? 'character' : 'characters',
9190
gotten: gotten
9291
};
9392

94-
if (loc) {
95-
context.report({
96-
node: node,
97-
loc: loc,
98-
message: MESSAGE,
99-
data: msgContext
100-
});
101-
} else {
102-
context.report({
103-
node: node,
104-
message: MESSAGE,
105-
data: msgContext,
106-
fix: function(fixer) {
107-
return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]],
108-
Array(needed + 1).join(indentType === 'space' ? ' ' : '\t'));
109-
}
110-
});
111-
}
93+
context.report({
94+
node: node,
95+
message: MESSAGE,
96+
data: msgContext,
97+
fix: function(fixer) {
98+
return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]],
99+
Array(needed + 1).join(indentType === 'space' ? ' ' : '\t'));
100+
}
101+
});
112102
}
113103

114104
/**
115105
* Get node indent
116106
* @param {ASTNode} node Node to examine
117-
* @param {Boolean} byLastLine get indent of node's last line
118-
* @param {Boolean} excludeCommas skip comma on start of line
119107
* @return {Number} Indent
120108
*/
121-
function getNodeIndent(node, byLastLine, excludeCommas) {
122-
byLastLine = byLastLine || false;
123-
excludeCommas = excludeCommas || false;
124-
109+
function getNodeIndent(node) {
125110
let src = sourceCode.getText(node, node.loc.start.column + extraColumnStart);
126111
const lines = src.split('\n');
127-
if (byLastLine) {
128-
src = lines[lines.length - 1];
129-
} else {
130-
src = lines[0];
131-
}
132-
133-
const skip = excludeCommas ? ',' : '';
112+
src = lines[0];
134113

135114
let regExp;
136115
if (indentType === 'space') {
137-
regExp = new RegExp(`^[ ${skip}]+`);
116+
regExp = /^[ ]+/;
138117
} else {
139-
regExp = new RegExp(`^[\t${skip}]+`);
118+
regExp = /^[\t]+/;
140119
}
141120

142121
const indent = regExp.exec(src);
@@ -149,9 +128,9 @@ module.exports = {
149128
* @param {Number} indent needed indent
150129
* @param {Boolean} excludeCommas skip comma on start of line
151130
*/
152-
function checkNodesIndent(nodes, indent, excludeCommas) {
131+
function checkNodesIndent(nodes, indent) {
153132
nodes.forEach(node => {
154-
const nodeIndent = getNodeIndent(node, false, excludeCommas);
133+
const nodeIndent = getNodeIndent(node);
155134
if (
156135
node.type !== 'ArrayExpression' && node.type !== 'ObjectExpression' &&
157136
nodeIndent !== indent && astUtil.isNodeFirstInLine(context, node)

0 commit comments

Comments
 (0)