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

chore: remove unneeded conditions #594

Merged
merged 1 commit into from Jul 31, 2020
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
7 changes: 0 additions & 7 deletions src/rules/no-test-callback.ts
Expand Up @@ -63,13 +63,6 @@ export default createRule({
fix(fixer) {
const { body } = callback;

/* istanbul ignore if https://github.com/typescript-eslint/typescript-eslint/issues/734 */
if (!body) {
throw new Error(
`Unexpected null when attempting to fix ${context.getFilename()} - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`,
);
}

const sourceCode = context.getSourceCode();
const firstBodyToken = sourceCode.getFirstToken(body);
const lastBodyToken = sourceCode.getLastToken(body);
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-test-return-statement.ts
Expand Up @@ -15,7 +15,6 @@ const getBody = (args: TSESTree.Expression[]) => {
if (
secondArg &&
isFunction(secondArg) &&
secondArg.body &&
secondArg.body.type === AST_NODE_TYPES.BlockStatement
) {
return secondArg.body.body;
Expand Down
11 changes: 1 addition & 10 deletions src/rules/prefer-todo.ts
Expand Up @@ -19,17 +19,8 @@ function isEmptyFunction(node: TSESTree.Expression) {
return false;
}

/* istanbul ignore if https://github.com/typescript-eslint/typescript-eslint/issues/734 */
if (!node.body) {
throw new Error(
`Unexpected null while performing prefer-todo - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`,
);
}

return (
node.body.type === AST_NODE_TYPES.BlockStatement &&
node.body.body &&
!node.body.body.length
node.body.type === AST_NODE_TYPES.BlockStatement && !node.body.body.length
);
}

Expand Down
5 changes: 1 addition & 4 deletions src/rules/valid-describe.ts
Expand Up @@ -92,10 +92,7 @@ export default createRule({
});
}

if (
callback.body &&
callback.body.type === AST_NODE_TYPES.BlockStatement
) {
if (callback.body.type === AST_NODE_TYPES.BlockStatement) {
callback.body.body.forEach(node => {
if (node.type === AST_NODE_TYPES.ReturnStatement) {
context.report({
Expand Down
14 changes: 1 addition & 13 deletions src/rules/valid-expect-in-promise.ts
Expand Up @@ -132,14 +132,9 @@ const verifyExpectWithReturn = (
testFunctionBody: TSESTree.Statement[],
) => {
promiseCallbacks.some(promiseCallback => {
if (
promiseCallback &&
isFunction(promiseCallback) &&
promiseCallback.body
) {
if (promiseCallback && isFunction(promiseCallback)) {
if (
isExpectCallPresentInFunction(promiseCallback.body) &&
node.parent &&
node.parent.parent &&
!isParentThenOrPromiseReturned(node.parent.parent, testFunctionBody)
) {
Expand Down Expand Up @@ -187,13 +182,6 @@ export default createRule<unknown[], MessageIds>({
if (testFunction && !isHavingAsyncCallBackParam(testFunction)) {
const { body } = testFunction;

/* istanbul ignore if https://github.com/typescript-eslint/typescript-eslint/issues/734 */
if (!body) {
throw new Error(
`Unexpected null when attempting to fix ${context.getFilename()} - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`,
);
}

if (body.type !== AST_NODE_TYPES.BlockStatement) {
return;
}
Expand Down