Skip to content

Commit

Permalink
Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods committed Dec 16, 2023
1 parent 846cc4b commit 40e8658
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 51 deletions.
1 change: 0 additions & 1 deletion configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = Object.assign({}, all, {
languageOptions: all.languageOptions,
rules: {
'react/display-name': 2,
'react/forward-ref-uses-ref': 2,
'react/jsx-key': 2,
'react/jsx-no-comment-textnodes': 2,
'react/jsx-no-duplicate-props': 2,
Expand Down
8 changes: 3 additions & 5 deletions lib/rules/forward-ref-uses-ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const getMessageData = require('../util/message');
// ------------------------------------------------------------------------------

const messages = {
missingRefParameter:
'forwardRef is used with this component but no ref parameter is set',
missingRefParameter: 'forwardRef is used with this component but no ref parameter is set',
addRefParameter: 'Add a ref parameter',
removeForwardRef: 'Remove forwardRef wrapper',
};
Expand All @@ -25,7 +24,7 @@ module.exports = {
docs: {
description: 'Require all forwardRef components include a ref parameter',
category: 'Possible Errors',
recommended: true,
recommended: false,
url: docsUrl('forward-ref-uses-ref'),
},
messages,
Expand All @@ -52,8 +51,7 @@ module.exports = {
return (
node.type === 'CallExpression'
&& (isForwardRefIdentifier(node.callee)
|| (node.callee.type === 'MemberExpression'
&& isForwardRefIdentifier(node.callee.property)))
|| (node.callee.type === 'MemberExpression' && isForwardRefIdentifier(node.callee.property)))
);
}

Expand Down
86 changes: 41 additions & 45 deletions tests/lib/rules/forward-ref-uses-ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,68 +30,68 @@ const tests = {
code: `
import { forwardRef } from 'react'
forwardRef((props, ref) => {
return null
})
return null;
});
`,
},
{
code: `
import { forwardRef } from 'react'
forwardRef((props, ref) => null)
forwardRef((props, ref) => null);
`,
},
{
code: `
import { forwardRef } from 'react'
forwardRef(function (props, ref) {
return null
})
return null;
});
`,
},
{
code: `
import { forwardRef } from 'react'
forwardRef(function Component(props, ref) {
return null
})
return null;
});
`,
},
{
code: `
import * as React from 'react'
React.forwardRef((props, ref) => {
return null
})
return null;
});
`,
},
{
code: `
import * as React from 'react'
React.forwardRef((props, ref) => null)
React.forwardRef((props, ref) => null);
`,
},
{
code: `
import * as React from 'react'
React.forwardRef(function (props, ref) {
return null
})
return null;
});
`,
},
{
code: `
import * as React from 'react'
React.forwardRef(function Component(props, ref) {
return null
})
return null;
});
`,
},
{
code: `
import * as React from 'react'
function Component(props) {
return null
}
return null;
};
`,
},
]),
Expand All @@ -100,30 +100,29 @@ const tests = {
code: `
import { forwardRef } from 'react'
forwardRef((props) => {
return null
})
return null;
});
`,
errors: [
{
message:
'forwardRef is used with this component but no ref parameter is set',
message: 'forwardRef is used with this component but no ref parameter is set',
suggestions: [
{
messageId: 'addRefParameter',
output: `
import { forwardRef } from 'react'
forwardRef((props, ref) => {
return null
})
return null;
});
`,
},
{
messageId: 'removeForwardRef',
output: `
import { forwardRef } from 'react'
(props) => {
return null
}
return null;
};
`,
},
],
Expand All @@ -133,25 +132,24 @@ const tests = {
{
code: `
import * as React from 'react'
React.forwardRef((props) => null)
React.forwardRef((props) => null);
`,
errors: [
{
message:
'forwardRef is used with this component but no ref parameter is set',
message: 'forwardRef is used with this component but no ref parameter is set',
suggestions: [
{
messageId: 'addRefParameter',
output: `
import * as React from 'react'
React.forwardRef((props, ref) => null)
React.forwardRef((props, ref) => null);
`,
},
{
messageId: 'removeForwardRef',
output: `
import * as React from 'react'
(props) => null
(props) => null;
`,
},
],
Expand All @@ -162,30 +160,29 @@ const tests = {
code: `
import { forwardRef } from 'react'
forwardRef(function (props) {
return null
})
return null;
});
`,
errors: [
{
message:
'forwardRef is used with this component but no ref parameter is set',
message: 'forwardRef is used with this component but no ref parameter is set',
suggestions: [
{
messageId: 'addRefParameter',
output: `
import { forwardRef } from 'react'
forwardRef(function (props, ref) {
return null
})
return null;
});
`,
},
{
messageId: 'removeForwardRef',
output: `
import { forwardRef } from 'react'
function (props) {
return null
}
return null;
};
`,
},
],
Expand All @@ -196,30 +193,29 @@ const tests = {
code: `
import * as React from 'react'
React.forwardRef(function Component(props) {
return null
})
return null;
});
`,
errors: [
{
message:
'forwardRef is used with this component but no ref parameter is set',
message: 'forwardRef is used with this component but no ref parameter is set',
suggestions: [
{
messageId: 'addRefParameter',
output: `
import * as React from 'react'
React.forwardRef(function Component(props, ref) {
return null
})
return null;
});
`,
},
{
messageId: 'removeForwardRef',
output: `
import * as React from 'react'
function Component(props) {
return null
}
return null;
};
`,
},
],
Expand Down

0 comments on commit 40e8658

Please sign in to comment.