Skip to content

Commit

Permalink
[Tests] jsx-no-useless-fragment, jsx-fragments, `function-compone…
Browse files Browse the repository at this point in the history
…nt-definition`: use `output: null` to assert no autofix
  • Loading branch information
mdjermanovic authored and ljharb committed May 20, 2024
1 parent 3533e26 commit fbb1e0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
26 changes: 4 additions & 22 deletions tests/lib/rules/function-component-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,7 @@ ruleTester.run('function-component-definition', rule, {
return <div/>;
}
`,
output: `
var Hello: React.FC<Test> = function(props) {
return <div/>;
}
`,
output: null,
options: [{ namedComponents: 'function-declaration' }],
errors: [{ messageId: 'function-declaration' }],
features: ['types'],
Expand All @@ -822,11 +818,7 @@ ruleTester.run('function-component-definition', rule, {
return <div/>;
};
`,
output: `
var Hello: React.FC<Test> = (props) => {
return <div/>;
};
`,
output: null,
options: [{ namedComponents: 'function-declaration' }],
errors: [{ messageId: 'function-declaration' }],
features: ['types'],
Expand All @@ -852,11 +844,7 @@ ruleTester.run('function-component-definition', rule, {
return <div/>;
}
`,
output: `
function Hello<Test>(props: Test) {
return <div/>;
}
`,
output: null,
options: [{ namedComponents: 'arrow-function' }],
errors: [{ messageId: 'arrow-function' }],
features: ['types'],
Expand Down Expand Up @@ -963,13 +951,7 @@ ruleTester.run('function-component-definition', rule, {
}
}
`,
output: `
function wrap(Component) {
return function<Test>(props) {
return <div><Component {...props}/></div>
}
}
`,
output: null,
errors: [{ messageId: 'arrow-function' }],
options: [{ unnamedComponents: 'arrow-function' }],
features: ['types'],
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/jsx-fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ruleTester.run('jsx-fragments', rule, {
},
{
code: '<><Foo /></>',
output: '<><Foo /></>', // should get '<Act.Frag><Foo /></Act.Frag>', but the old TS parser lacks opening/closing Fragment info
output: null, // should get '<Act.Frag><Foo /></Act.Frag>', but the old TS parser lacks opening/closing Fragment info
features: ['fragment', 'no-babel', 'ts', 'no-ts-new'],
options: ['element'],
settings,
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/jsx-no-useless-fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
},
{
code: '<div><>{"a"}{"b"}</></div>',
output: '<div><>{"a"}{"b"}</></div>',
output: null,
errors: [{ messageId: 'ChildOfHtmlElement', type: 'JSXFragment' }],
features: ['fragment', 'ts-old', 'no-ts-new', 'no-babel', 'no-default'],
},
Expand Down

0 comments on commit fbb1e0f

Please sign in to comment.