From 8715216a9f84c488cb8602b767d3e4a5353cce2e Mon Sep 17 00:00:00 2001 From: Andreas Opferkuch Date: Wed, 6 Sep 2017 18:18:14 +0200 Subject: [PATCH] Added tests for jsx-curly-spacing that deal with comments in children. See also: https://github.com/yannickcr/eslint-plugin-react/issues/648#issuecomment-327519650 --- tests/lib/rules/jsx-curly-spacing.js | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/tests/lib/rules/jsx-curly-spacing.js b/tests/lib/rules/jsx-curly-spacing.js index 17fbcf1e94..593aeab3c0 100644 --- a/tests/lib/rules/jsx-curly-spacing.js +++ b/tests/lib/rules/jsx-curly-spacing.js @@ -2118,5 +2118,81 @@ ruleTester.run('jsx-curly-spacing', rule, { }, { message: 'A space is required before \'}\'' }] + }, { + code: [ + '', + '{ /* comment */ }', + ';' + ].join('\n'), + output: [ + '', + '{/* comment */}', + ';' + ].join('\n'), + options: [{when: 'never', children: true}], + errors: [{ + message: 'There should be no space after \'{\'' + }, { + message: 'There should be no space before \'}\'' + }] + }, { + code: [ + '', + '{/* comment */}', + ';' + ].join('\n'), + output: [ + '', + '{ /* comment */ }', + ';' + ].join('\n'), + options: [{when: 'always', children: true}], + errors: [{ + message: 'A space is required after \'{\'' + }, { + message: 'A space is required before \'}\'' + }] + }, { + code: [ + '{ /* comment */', + 'bar', + '} {', + 'baz', + '/* comment */ };' + ].join('\n'), + output: [ + '{/* comment */', + 'bar', + '} {', + 'baz', + '/* comment */};' + ].join('\n'), + options: [{when: 'never', children: true}], + errors: [{ + message: 'There should be no space after \'{\'' + }, { + message: 'There should be no space before \'}\'' + }] + }, { + code: [ + '{/* comment */', + 'bar', + '} {', + 'baz', + '/* comment */};' + ].join('\n'), + output: [ + '{ /* comment */', + 'bar', + '} {', + 'baz', + '/* comment */ };' + ].join('\n'), + options: [{when: 'always', children: true}], + errors: [{ + message: 'A space is required after \'{\'' + }, { + message: 'A space is required before \'}\'' + }] }] });