diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js
index ce4733d8fa..c43e7791ce 100644
--- a/tests/lib/rules/jsx-indent.js
+++ b/tests/lib/rules/jsx-indent.js
@@ -45,7 +45,7 @@ ruleTester.run('jsx-indent', rule, {
{
code: `
-
+
`,
},
{
@@ -3001,6 +3001,135 @@ const Component = () => (
},
],
},
+ {
+ code: `
+ const IndexPage = () => (
+
+ {"Hi people"}
+
+
+ );
+ `,
+ output: `
+ const IndexPage = () => (
+
+ {"Hi people"}
+
+
+ );
+ `,
+ options:[2],
+ errors: [
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 12,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 12,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 10,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ ],
+ },
+ // Would be nice to handle in one pass, but multipass works fine.
+ {
+ code: `
+ const IndexPage = () => (
+
+ Hi people
+
+
+ );
+ `,
+
+ output: `
+ const IndexPage = () => (
+
+ Hi people
+
+
+ );
+ `,
+ options:[2],
+ errors: [
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 12,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 12,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 10,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ ],
+ },
+ {
+ code: `
+ const IndexPage = () => (
+
+ Hi people
+
+
+ );
+ `,
+
+ output: `
+ const IndexPage = () => (
+
+ Hi people
+
+
+ );
+ `,
+ options:[2],
+ errors: [
+ {
+ messageId: 'wrongIndent',
+ data: {
+ needed: 12,
+ type: 'space',
+ characters: 'characters',
+ gotten: 8,
+ },
+ },
+ ],
+ },
semver.satisfies(eslintVersion, '> 4') ? {
code: `
import React from 'react';
diff --git a/tests/lib/rules/jsx-one-expression-per-line.js b/tests/lib/rules/jsx-one-expression-per-line.js
index a8ba820d02..e83c2b101f 100644
--- a/tests/lib/rules/jsx-one-expression-per-line.js
+++ b/tests/lib/rules/jsx-one-expression-per-line.js
@@ -1389,5 +1389,185 @@ a
],
parserOptions,
},
+ {
+ // TODO: handle in a single pass
+ code: `
+ const IndexPage = () => (
+ {"Hi people"}
+ );
+ `,
+ output: `
+ const IndexPage = () => (
+
+{"Hi people"}
+ );
+ `,
+ errors: [
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: '{"Hi people"}' },
+ },
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'button' },
+ },
+ ],
+ parserOptions,
+ },
+ {
+ code: `
+ const IndexPage = () => (
+
+{"Hi people"}
+ );
+ `,
+ output: `
+ const IndexPage = () => (
+
+{"Hi people"}
+
+
+ );
+ `,
+ errors: [
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'button' },
+ },
+ ],
+ parserOptions,
+ },
+ // TODO: handle in a single pass (see above)
+ {
+ code: `
+
+ Welcome to your new Gatsby site.
+ Now go build something great.
+ Hi people
+
+ `,
+ output: `
+
+
+Welcome to your new Gatsby site.
+
+
+Now go build something great.
+
+
+Hi people
+
+ `,
+ errors: [
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'Welcome to your new Gatsby site.' },
+ },
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'Now go build something great.' },
+ },
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'Hi people' },
+ },
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'button' },
+ },
+ ],
+ parserOptions,
+ },
+ {
+ code: `
+
+
+Welcome to your new Gatsby site.
+
+
+Now go build something great.
+
+
+Hi people
+
+ `,
+ output: `
+
+
+Welcome to your new Gatsby site.
+
+
+Now go build something great.
+
+
+Hi people
+
+
+
+ `,
+ errors: [
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'button' },
+ },
+ ],
+ parserOptions,
+ },
+ // TODO: handle in a single pass
+ {
+ code: `
+
+
+
+
Go to page 2
+
+ `,
+ output: `
+
+
+
+
+Go to page 2
+
+ `,
+ errors: [
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'Link' },
+ },
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'Go to page 2' },
+ },
+ ],
+ parserOptions,
+ },
+ {
+ code: `
+
+
+
+
+Go to page 2
+
+ `,
+ output: `
+
+
+
+
+
+Go to page 2
+2
+
+ `,
+ errors: [
+ {
+ messageId: 'moveToNewLine',
+ data: { descriptor: 'Go to page 2' },
+ },
+ ],
+ parserOptions,
+ },
]),
});