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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check node argument is defined before use #285

Merged
merged 4 commits into from Jun 22, 2019
Merged
Changes from 2 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
14 changes: 9 additions & 5 deletions src/rules/util.js
Expand Up @@ -125,18 +125,22 @@ const isTestCase = node =>
testCaseNames[getNodeName(node.callee)];

const isDescribe = node =>
node.type === 'CallExpression' && describeAliases[getNodeName(node.callee)];
node &&
node.type === 'CallExpression' &&
describeAliases[getNodeName(node.callee)];

const isFunction = node =>
node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression';
(node && node.type === 'FunctionExpression') ||
node.type === 'ArrowFunctionExpression';

const isString = node =>
(node.type === 'Literal' && typeof node.value === 'string') ||
(node && (node.type === 'Literal' && typeof node.value === 'string')) ||
G-Rath marked this conversation as resolved.
Show resolved Hide resolved
isTemplateLiteral(node);

const isTemplateLiteral = node => node.type === 'TemplateLiteral';
const isTemplateLiteral = node => node && node.type === 'TemplateLiteral';

const hasExpressions = node => node.expressions && node.expressions.length > 0;
const hasExpressions = node =>
node && node.expressions && node.expressions.length > 0;

const getStringValue = arg =>
isTemplateLiteral(arg) ? arg.quasis[0].value.raw : arg.value;
Expand Down