Skip to content

Commit a37687e

Browse files
committed
Add fix for multple props on first line
fix referenced from GovTechSG's fork
1 parent 0aeb95c commit a37687e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/rules/jsx-first-prop-new-line.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
(configuration === 'multiline-multiprop' && isMultilineJSX(node) && node.attributes.length > 1) ||
3737
(configuration === 'always')
3838
) {
39-
node.attributes.forEach(function(decl) {
39+
node.attributes.some(function(decl) {
4040
if (decl.loc.start.line === node.loc.start.line) {
4141
context.report({
4242
node: decl,
@@ -46,6 +46,7 @@ module.exports = {
4646
}
4747
});
4848
}
49+
return true;
4950
});
5051
} else if (configuration === 'never' && node.attributes.length > 0) {
5152
var firstNode = node.attributes[0];

tests/lib/rules/jsx-first-prop-new-line.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
152152

153153
invalid: [
154154
{
155-
code: '<Foo prop="one" />',
155+
code: '<Foo propOne="one" propTwo="two" />',
156156
output: [
157157
'<Foo',
158-
'prop="one" />'
158+
'propOne="one" propTwo="two" />'
159159
].join('\n'),
160160
options: ['always'],
161161
errors: [{message: 'Property should be placed on a new line'}],

0 commit comments

Comments
 (0)