Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

methodName: ensure method(node) returns truthy before trying to use return #358

Merged
merged 4 commits into from Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rules/__tests__/prefer-to-be-null.test.js
Expand Up @@ -17,6 +17,7 @@ ruleTester.run('prefer-to-be-null', rule, {
'expect("a string").not.toMatchSnapshot();',
"expect(something).toEqual('a string');",
'expect(null).toBe',
'expect("something");',
],

invalid: [
Expand Down
1 change: 1 addition & 0 deletions src/rules/__tests__/prefer-to-be-undefined.test.js
Expand Up @@ -14,6 +14,7 @@ ruleTester.run('prefer-to-be-undefined', rule, {
'expect(something).not.toBe(somethingElse)',
'expect(something).not.toEqual(somethingElse)',
'expect(undefined).toBe',
'expect("something");',
],

invalid: [
Expand Down
4 changes: 2 additions & 2 deletions src/rules/util.js
Expand Up @@ -87,9 +87,9 @@ export const method = node => node.parent.property;

export const method2 = node => node.parent.parent.property;

const methodName = node => method(node).name;
const methodName = node => method(node) && method(node).name;

const methodName2 = node => method2(node).name;
const methodName2 = node => method2(node) && method2(node).name;

export const argument = node =>
node.parent.parent.arguments && node.parent.parent.arguments[0];
Expand Down