Skip to content

Commit 2a3af4e

Browse files
G-RathSimenB
authored andcommitted
chore: remove unneeded conditions (#594)
These are not needed with `@typescript-eslint@3`
1 parent 8c2b511 commit 2a3af4e

5 files changed

+3
-35
lines changed

src/rules/no-test-callback.ts

-7
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ export default createRule({
6363
fix(fixer) {
6464
const { body } = callback;
6565

66-
/* istanbul ignore if https://github.com/typescript-eslint/typescript-eslint/issues/734 */
67-
if (!body) {
68-
throw new Error(
69-
`Unexpected null when attempting to fix ${context.getFilename()} - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`,
70-
);
71-
}
72-
7366
const sourceCode = context.getSourceCode();
7467
const firstBodyToken = sourceCode.getFirstToken(body);
7568
const lastBodyToken = sourceCode.getLastToken(body);

src/rules/no-test-return-statement.ts

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const getBody = (args: TSESTree.Expression[]) => {
1515
if (
1616
secondArg &&
1717
isFunction(secondArg) &&
18-
secondArg.body &&
1918
secondArg.body.type === AST_NODE_TYPES.BlockStatement
2019
) {
2120
return secondArg.body.body;

src/rules/prefer-todo.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,8 @@ function isEmptyFunction(node: TSESTree.Expression) {
1919
return false;
2020
}
2121

22-
/* istanbul ignore if https://github.com/typescript-eslint/typescript-eslint/issues/734 */
23-
if (!node.body) {
24-
throw new Error(
25-
`Unexpected null while performing prefer-todo - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`,
26-
);
27-
}
28-
2922
return (
30-
node.body.type === AST_NODE_TYPES.BlockStatement &&
31-
node.body.body &&
32-
!node.body.body.length
23+
node.body.type === AST_NODE_TYPES.BlockStatement && !node.body.body.length
3324
);
3425
}
3526

src/rules/valid-describe.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ export default createRule({
9292
});
9393
}
9494

95-
if (
96-
callback.body &&
97-
callback.body.type === AST_NODE_TYPES.BlockStatement
98-
) {
95+
if (callback.body.type === AST_NODE_TYPES.BlockStatement) {
9996
callback.body.body.forEach(node => {
10097
if (node.type === AST_NODE_TYPES.ReturnStatement) {
10198
context.report({

src/rules/valid-expect-in-promise.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,9 @@ const verifyExpectWithReturn = (
132132
testFunctionBody: TSESTree.Statement[],
133133
) => {
134134
promiseCallbacks.some(promiseCallback => {
135-
if (
136-
promiseCallback &&
137-
isFunction(promiseCallback) &&
138-
promiseCallback.body
139-
) {
135+
if (promiseCallback && isFunction(promiseCallback)) {
140136
if (
141137
isExpectCallPresentInFunction(promiseCallback.body) &&
142-
node.parent &&
143138
node.parent.parent &&
144139
!isParentThenOrPromiseReturned(node.parent.parent, testFunctionBody)
145140
) {
@@ -187,13 +182,6 @@ export default createRule<unknown[], MessageIds>({
187182
if (testFunction && !isHavingAsyncCallBackParam(testFunction)) {
188183
const { body } = testFunction;
189184

190-
/* istanbul ignore if https://github.com/typescript-eslint/typescript-eslint/issues/734 */
191-
if (!body) {
192-
throw new Error(
193-
`Unexpected null when attempting to fix ${context.getFilename()} - please file a github issue at https://github.com/jest-community/eslint-plugin-jest`,
194-
);
195-
}
196-
197185
if (body.type !== AST_NODE_TYPES.BlockStatement) {
198186
return;
199187
}

0 commit comments

Comments
 (0)