Skip to content

Commit

Permalink
Add fix for multple props on first line
Browse files Browse the repository at this point in the history
fix referenced from GovTechSG's fork
  • Loading branch information
snowypowers committed Nov 2, 2016
1 parent 0aeb95c commit a37687e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/rules/jsx-first-prop-new-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
(configuration === 'multiline-multiprop' && isMultilineJSX(node) && node.attributes.length > 1) ||
(configuration === 'always')
) {
node.attributes.forEach(function(decl) {
node.attributes.some(function(decl) {
if (decl.loc.start.line === node.loc.start.line) {
context.report({
node: decl,
Expand All @@ -46,6 +46,7 @@ module.exports = {
}
});
}
return true;
});
} else if (configuration === 'never' && node.attributes.length > 0) {
var firstNode = node.attributes[0];
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/jsx-first-prop-new-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ ruleTester.run('jsx-first-prop-new-line', rule, {

invalid: [
{
code: '<Foo prop="one" />',
code: '<Foo propOne="one" propTwo="two" />',
output: [
'<Foo',
'prop="one" />'
'propOne="one" propTwo="two" />'
].join('\n'),
options: ['always'],
errors: [{message: 'Property should be placed on a new line'}],
Expand Down

0 comments on commit a37687e

Please sign in to comment.