diff --git a/eslintrc.json b/eslintrc.json index ccabc5a..68a43dd 100644 --- a/eslintrc.json +++ b/eslintrc.json @@ -20,7 +20,10 @@ "react/jsx-indent-props": ["error", 2], "react/jsx-no-duplicate-props": "error", "react/jsx-no-undef": "error", - "react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }], + "react/jsx-tag-spacing": ["error", { + "beforeSelfClosing": "always", + "beforeClosing": "never" + }], "react/jsx-uses-react": "error", "react/jsx-uses-vars": "error", "react/self-closing-comp": "error" diff --git a/test/validate-config.js b/test/validate-config.js index b72e625..ff80671 100644 --- a/test/validate-config.js +++ b/test/validate-config.js @@ -14,3 +14,57 @@ test('load config in eslint to validate all rule syntax is correct', function (t t.equal(cli.executeOnText(code).errorCount, 0) t.end() }) + +test('space before an opening tag\'s closing bracket should not be allowed', t => { + const CLIEngine = eslint.CLIEngine + + const cli = new CLIEngine({ + useEslintrc: false, + configFile: 'eslintrc.json' + }) + + const shouldPass = { + selfClosing: `
`, + withChildren: ` +
+ test +
+ `, + withChildrenWithPropsMultiLine: ` +
+ test +
+ ` + } + + const shouldFail = { + selfClosing: `
`, + openingTag: ` +
+ test +
+ `, + closingTag: ` +
+ test +
+ ` + } + + const testPlansCount = Object.keys(shouldPass).length + Object.keys(shouldFail).length + + t.plan(testPlansCount) + + for (const testCase in shouldPass) { + const { errorCount } = cli.executeOnText(shouldPass[testCase]) + t.equal(errorCount, 0) + } + + for (const testCase in shouldFail) { + const { errorCount } = cli.executeOnText(shouldFail[testCase]) + t.true(errorCount > 0) + } +})