This commit is contained in:
parent
7b84dbd169
commit
eb58c3909a
|
@ -3629,6 +3629,36 @@ const tests = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: normalizeIndent`
|
||||
function MyComponent(props) {
|
||||
useEffect(() => {}, [props?.attribute.method()]);
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
'React Hook useEffect has a complex expression in the dependency array. ' +
|
||||
'Extract it to a separate variable so it can be statically checked.',
|
||||
suggestions: undefined,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: normalizeIndent`
|
||||
function MyComponent(props) {
|
||||
useEffect(() => {}, [props.method()]);
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
'React Hook useEffect has a complex expression in the dependency array. ' +
|
||||
'Extract it to a separate variable so it can be statically checked.',
|
||||
suggestions: undefined,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: normalizeIndent`
|
||||
function MyComponent() {
|
||||
|
|
|
@ -1656,6 +1656,11 @@ function analyzePropertyChain(node, optionalChains) {
|
|||
return result;
|
||||
} else if (node.type === 'ChainExpression' && !node.computed) {
|
||||
const expression = node.expression;
|
||||
|
||||
if (expression.type === 'CallExpression') {
|
||||
throw new Error(`Unsupported node type: ${expression.type}`);
|
||||
}
|
||||
|
||||
const object = analyzePropertyChain(expression.object, optionalChains);
|
||||
const property = analyzePropertyChain(expression.property, null);
|
||||
const result = `${object}.${property}`;
|
||||
|
|
Loading…
Reference in New Issue