Skip to content

Commit

Permalink
chore: remove unneeded conditions (#594)
Browse files Browse the repository at this point in the history
These are not needed with `@typescript-eslint@3`
  • Loading branch information
G-Rath authored and SimenB committed Aug 31, 2020
1 parent d04c75d commit ea192e3
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 35 deletions.
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

0 comments on commit ea192e3

Please sign in to comment.