Skip to content

v4 #322

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

Merged
merged 116 commits into from
Apr 11, 2021
Merged

v4 #322

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
58d72d5
feat: recommend prefer-screen-queries (#169)
nickserv Jun 17, 2020
d8a2ac6
feat: recommend no-wait-for-empty-callback (#168)
nickserv Jun 17, 2020
094f53c
feat(no-container): setup new rule on index
Jun 18, 2020
da88a9d
refactor(no-container): set rules
Jun 18, 2020
ee369e5
test(no-container): define scenarios
Jun 18, 2020
5d02426
refactor(no-debug): extract auxiliary functions
Jun 19, 2020
0205374
refactor(no-container): add conditional
Jun 19, 2020
d8e555e
docs(no-container): add new and update README
Jun 19, 2020
497a5b6
refactor(no-container): allow custom render
Jun 19, 2020
4ab2305
test(no-container): add custom render function
Jun 19, 2020
c11fcd6
docs(no-container): update further reading topics
Jun 19, 2020
ac2d7ac
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jun 19, 2020
1d8077c
Merge branch 'v4' of https://github.com/thebinaryfelix/eslint-plugin-…
Jun 19, 2020
d624bfe
Merge branch 'v4' into no-container
thebinaryfelix Jun 19, 2020
1c59122
docs(no-container): update
Jun 19, 2020
52f5995
test(no-container): add scenarios
Jun 19, 2020
4eb5381
refactor(no-container): adjust to new scenarios
Jun 19, 2020
3943f45
docs(no-container): add incorrect use cases
Jun 19, 2020
8e2cdcc
refactor(no-container): remove wrong use case
thebinaryfelix Jun 20, 2020
78fdfe7
refactor(no-container): add scenario
thebinaryfelix Jun 20, 2020
9812cf4
refactor(no-container): rename function
thebinaryfelix Jun 20, 2020
e63968f
refactor(no-container): remove condition
thebinaryfelix Jun 20, 2020
5aa3a80
refactor(no-container): update error message
thebinaryfelix Jun 20, 2020
63f2db4
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jun 21, 2020
a4cc8d8
feat(no-promise-in-fire-event): add new no-promise-in-fire-event rule…
timdeschryver Jun 21, 2020
9d44911
Merge branch 'v4' into no-container
thebinaryfelix Jun 21, 2020
86f9c84
feat: add no-container rule #177
gndelia Jun 21, 2020
9db40ee
refactor: rename recommended config to dom (#184)
Belco90 Jun 22, 2020
11d67b2
feat: add rule no-multiple-assertions-wait-for (#189)
renatoagds Jun 30, 2020
b2ef721
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jun 30, 2020
9d4c1e4
feat: add no-node-access rule (#190)
thebinaryfelix Jul 15, 2020
9aa6730
feat: add prefer-user-event rule (#192)
gndelia Jul 20, 2020
17e3cfe
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jul 20, 2020
3b9d5b5
feat: add render-result-naming-convention rule (#200)
Belco90 Jul 27, 2020
8ad0184
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jul 27, 2020
91200b7
feat: add no-side-effects-wait-for rule (#196)
renatoagds Jul 28, 2020
2ac6b81
Merge v4 with develop
Belco90 Aug 15, 2020
44de9fc
chore: lint and format on pre-commit and ci (#216)
gndelia Aug 17, 2020
4b7300e
chore: merge master into v4 (#233)
MichaelDeBoey Sep 20, 2020
9c2072d
chore: update dependencies + run prettier on codebase (#234)
MichaelDeBoey Sep 21, 2020
3a0d125
Merge remote-tracking branch 'origin/master' into v4
Belco90 Oct 18, 2020
1dbb513
style: apply prettier after merge
Belco90 Oct 18, 2020
ce4770f
refactor(no-node-access): use new testing library rule maker (#237)
Belco90 Oct 20, 2020
63c9d7b
refactor: improve logic to detect if testing librar imported (#239)
Belco90 Oct 25, 2020
6abb4ee
feat: new setting for reported filename pattern (#244)
Belco90 Nov 1, 2020
d1f0388
Merge remote-tracking branch 'origin/master' into v4
Belco90 Nov 1, 2020
5a6644f
refactor(no-dom-import): use createTestingLibraryRule (#247)
Belco90 Nov 1, 2020
eb17456
docs(consistent-data-testid): add clarification about rule creation (…
Belco90 Nov 3, 2020
287ca77
refactor(no-manual-cleanup): use custom rule creator (#249)
Belco90 Nov 4, 2020
c880f2f
refactor(prefer-user-event): use new custom rule creator (#251)
gndelia Nov 9, 2020
b48b286
refactor(prefer-presence-queries): use custom rule creator (#252)
Belco90 Nov 10, 2020
6018dd1
refactor: detection helpers tweaks (#254)
Belco90 Nov 10, 2020
ae3eac7
refactor(ast-utils): migrate custom node-utils to ASTUtils (#256)
Nov 17, 2020
8b66b52
chore: decrease node-utils coverage threshold
Belco90 Nov 17, 2020
727a966
refactor(prefer-wait-for): use new custom rule creator (#255)
gndelia Nov 19, 2020
5ce0ba0
Merge remote-tracking branch 'origin/master' into v4
Belco90 Nov 23, 2020
dcc0693
refactor: use custom rule creator for promise-queries rules (#260)
Belco90 Nov 28, 2020
9062040
refactor(await-async-utils): use custom rule creator (#263)
Belco90 Dec 6, 2020
668a1bf
refactor(await-fire-event): use custom rule creator (#265)
Belco90 Dec 7, 2020
6f506ee
refactor(no-promise-in-fire-event): use custom rule creator (#266)
Belco90 Dec 7, 2020
d0c76d4
refactor(no-wait-for-snapshot) migrate to v4 (#271)
gndelia Dec 13, 2020
bd60704
refactor(prefer-find-by) migrate to v4 (#270)
gndelia Dec 13, 2020
af32b0c
refactor(prefer-explicit-assert): use new utils and remove custom que…
Dec 29, 2020
ca2910b
Merge remote-tracking branch 'origin/main' into v4
Belco90 Jan 24, 2021
ed09979
fix(no-await-sync-query): avoid reporting queries if not within calle…
Belco90 Jan 30, 2021
b1355ad
refactor: remove duplicated param type
Belco90 Jan 30, 2021
5a5881e
refactor: rename helpers for determining query variants
Belco90 Jan 30, 2021
4e9e585
refactor(render-result-naming-convention): migrate to v4 (#280)
Belco90 Mar 3, 2021
192a37e
refactor: second round of tweaks (#281)
Belco90 Mar 8, 2021
50727e6
refactor(render-result-naming-convention): refine checks to decide if…
Belco90 Mar 14, 2021
f740836
ci: update pipeline with v4 changes (#289)
Belco90 Mar 16, 2021
b0b8c48
Merge remote-tracking branch 'origin/main' into v4
Belco90 Mar 16, 2021
6d90153
refactor(prefer-screen-queries): migrate to v4 (#285)
Belco90 Mar 16, 2021
dd30d02
chore: update dependencies (#290)
MichaelDeBoey Mar 16, 2021
ea62638
refactor(no-wait-for-empty-callback): migrate to v4 (#284)
Belco90 Mar 16, 2021
9bcf595
refactor(refactor no-debug): migrate to v4 (#293)
Belco90 Mar 20, 2021
65028a5
refactor(no-container): migrate to v4 (#295)
Belco90 Mar 20, 2021
2588602
Merge remote-tracking branch 'origin/main' into v4
Belco90 Mar 21, 2021
461809f
Merge remote-tracking branch 'origin/v4' into v4
Belco90 Mar 21, 2021
69d5bbe
refactor: remove mechanism to match files to be reported (#297)
Belco90 Mar 23, 2021
b1b8b25
refactor(no-render-in-setup): migrate to v4 (#299)
Belco90 Mar 25, 2021
3b785c2
Merge remote-tracking branch 'origin/main' into v4
Belco90 Mar 25, 2021
15fd7c4
refacto(no-wait-for-side-effects): migrate to v4 (#300)
Belco90 Mar 27, 2021
9386773
refactor(no-wait-for-multiple-assertions): migrate to v4 (#301)
Belco90 Mar 27, 2021
a6eea4d
refactor(no-await-sync-events): migrate to v4 (#302)
Belco90 Mar 28, 2021
82ace49
refactor: cleanup after migrating all rules to v4 (#303)
Belco90 Mar 28, 2021
a8c1fe4
fix(await-async-utils): reference correct node name
Belco90 Mar 30, 2021
82124af
fix(prefer-find-by): simplify error message
Belco90 Mar 30, 2021
cac6670
fix(no-await-sync-query): avoid false positive from parent func
Belco90 Mar 31, 2021
06b437c
test(no-await-sync-query): increase code coverage up to 100%
Belco90 Apr 1, 2021
98448bb
feat(no-wait-for-multiple-assertions): report assertions
Belco90 Apr 1, 2021
592c128
test(no-wait-for-multiple-assertions): increase code coverage up to 100%
Belco90 Apr 1, 2021
93b81f5
fix(no-wait-for-side-effects): report on each side effect node
Belco90 Apr 2, 2021
c801b1d
test(no-await-sync-query): include extra case for disappearance
Belco90 Apr 2, 2021
c176c2a
fix: guard against null deepest identifier node
Belco90 Apr 2, 2021
83f27d8
fix: guard against null property identifier node
Belco90 Apr 2, 2021
91abe97
ci: decrease coverage threshold
Belco90 Apr 2, 2021
7e9d5c5
fix: first round of bugfixes for v4
Belco90 Apr 3, 2021
abfe5e8
fix: enable TS strict mode
Belco90 Apr 3, 2021
751889b
fix: remove closing comment leftover
Belco90 Apr 3, 2021
8ceb80f
refactor: declare test cases typings as expected
Belco90 Apr 3, 2021
c20dbb9
fix: remove wrong boolean check for detection
Belco90 Apr 3, 2021
cc040a5
Merge "main" branch into "306_null-identifiers"
Belco90 Apr 3, 2021
eaca948
Merge pull request #309 from testing-library/306_null-identifiers
Belco90 Apr 3, 2021
fd81fc5
fix(prefer-user-event): format list of userEvent methods correctly (…
Belco90 Apr 4, 2021
66df731
fix: second round of bugfixes for v4 (#314)
Belco90 Apr 5, 2021
f4b5958
docs: add guide for migrating to v4 (#312)
Belco90 Apr 5, 2021
9365bf1
docs: update README for v4 (#317)
Belco90 Apr 8, 2021
ce38144
chore: update dependencies (#319)
MichaelDeBoey Apr 10, 2021
20027f4
fix: third round of bug fixes (#320)
Belco90 Apr 10, 2021
025f23d
docs: update contributing guidelines to v4 (#321)
Belco90 Apr 11, 2021
b150663
ci: remove unnecessary quote marks for node versions
Belco90 Apr 11, 2021
b5b93a4
Revert "ci: remove unnecessary quote marks for node versions"
Belco90 Apr 11, 2021
8f2e0a5
chore: revert node 10.22.1 as minimum version
Belco90 Apr 11, 2021
511986c
ci: include 12.0 in node versions matrix
Belco90 Apr 11, 2021
22387d5
ci: wrap matrix values within quotes
Belco90 Apr 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refacto(no-wait-for-side-effects): migrate to v4 (#300)
* test: improve errors location asserts

* refactor: use new rule creator

* refactor: improve error reported location

* refactor: use new helpers for detection

* test: add more cases

* feat: detect properly if fireEvent and userEvent should be reported

* test: add cases for increasing coverage up to 100%

* refactor: rename rule for consistency

* docs: remove duplicated no-wait-for-snapshot row

* fix: get identifier node simpler
  • Loading branch information
Belco90 authored Mar 27, 2021
commit 15fd7c4f6931df8562f7049f95b8f37762f5a7b2
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
[![Tweet][tweet-badge]][tweet-url]

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-36-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

## Installation
Expand Down Expand Up @@ -139,9 +141,8 @@ To enable this configuration use the `extends` property in your
| [no-node-access](docs/rules/no-node-access.md) | Disallow direct Node access | ![angular-badge][] ![react-badge][] ![vue-badge][] | |
| [no-promise-in-fire-event](docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | | |
| [no-render-in-setup](docs/rules/no-render-in-setup.md) | Disallow the use of `render` in setup functions | | |
| [no-side-effects-wait-for](docs/rules/no-side-effects-wait-for.md) | Disallow the use of side effects inside `waitFor` | | |
| [no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | |
| [no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | |
| [no-wait-for-side-effects](docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects inside `waitFor` | | |
| [no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | |
| [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than just `getBy*` queries | | |
| [prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Side effects inside `waitFor` are not preferred (no-side-effects-wait-for)
# Side effects inside `waitFor` are not preferred (no-wait-for-side-effects)

## Rule Details

Expand Down
143 changes: 96 additions & 47 deletions lib/detect-testing-library-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export interface DetectionHelpers {
isQuery: IsQueryFn;
isCustomQuery: IsCustomQueryFn;
isAsyncUtil: IsAsyncUtilFn;
isFireEventUtil: (node: TSESTree.Identifier) => boolean;
isUserEventUtil: (node: TSESTree.Identifier) => boolean;
isFireEventMethod: IsFireEventMethodFn;
isRenderUtil: IsRenderUtilFn;
isRenderVariableDeclarator: IsRenderVariableDeclaratorFn;
Expand All @@ -107,7 +109,6 @@ export interface DetectionHelpers {
isNodeComingFromTestingLibrary: IsNodeComingFromTestingLibraryFn;
}

const FIRE_EVENT_NAME = 'fireEvent';
const RENDER_NAME = 'render';

/**
Expand Down Expand Up @@ -173,6 +174,69 @@ export function detectTestingLibraryUtils<
return isNodeComingFromTestingLibrary(referenceNodeIdentifier);
}

/**
* Determines whether a given node is a simulate event util related to
* Testing Library or not.
*
* In order to determine this, the node must match:
* - indicated simulate event name: fireEvent or userEvent
* - imported from valid Testing Library module (depends on Aggressive
* Reporting)
*
*/
function isTestingLibrarySimulateEventUtil(
node: TSESTree.Identifier,
utilName: 'fireEvent' | 'userEvent'
): boolean {
const simulateEventUtil = findImportedUtilSpecifier(utilName);
let simulateEventUtilName: string | undefined;

if (simulateEventUtil) {
simulateEventUtilName = ASTUtils.isIdentifier(simulateEventUtil)
? simulateEventUtil.name
: simulateEventUtil.local.name;
} else if (isAggressiveModuleReportingEnabled()) {
simulateEventUtilName = utilName;
}

if (!simulateEventUtilName) {
return false;
}

const parentMemberExpression:
| TSESTree.MemberExpression
| undefined = isMemberExpression(node.parent) ? node.parent : undefined;

if (!parentMemberExpression) {
return false;
}

// make sure that given node it's not fireEvent/userEvent object itself
if (
[simulateEventUtilName, utilName].includes(node.name) ||
(ASTUtils.isIdentifier(parentMemberExpression.object) &&
parentMemberExpression.object.name === node.name)
) {
return false;
}

// check fireEvent.click()/userEvent.click() usage
const regularCall =
ASTUtils.isIdentifier(parentMemberExpression.object) &&
parentMemberExpression.object.name === simulateEventUtilName;

// check testingLibraryUtils.fireEvent.click() or
// testingLibraryUtils.userEvent.click() usage
const wildcardCall =
isMemberExpression(parentMemberExpression.object) &&
ASTUtils.isIdentifier(parentMemberExpression.object.object) &&
parentMemberExpression.object.object.name === simulateEventUtilName &&
ASTUtils.isIdentifier(parentMemberExpression.object.property) &&
parentMemberExpression.object.property.name === utilName;

return regularCall || wildcardCall;
}

/**
* Determines whether aggressive module reporting is enabled or not.
*
Expand Down Expand Up @@ -308,55 +372,38 @@ export function detectTestingLibraryUtils<
};

/**
* Determines whether a given node is fireEvent method or not
* Determines whether a given node is fireEvent util itself or not.
*
* Not to be confused with {@link isFireEventMethod}
*/
const isFireEventMethod: IsFireEventMethodFn = (node) => {
const fireEventUtil = findImportedUtilSpecifier(FIRE_EVENT_NAME);
let fireEventUtilName: string | undefined;

if (fireEventUtil) {
fireEventUtilName = ASTUtils.isIdentifier(fireEventUtil)
? fireEventUtil.name
: fireEventUtil.local.name;
} else if (isAggressiveModuleReportingEnabled()) {
fireEventUtilName = FIRE_EVENT_NAME;
}

if (!fireEventUtilName) {
return false;
}

const parentMemberExpression:
| TSESTree.MemberExpression
| undefined = isMemberExpression(node.parent) ? node.parent : undefined;

if (!parentMemberExpression) {
return false;
}

// make sure that given node it's not fireEvent object itself
if (
[fireEventUtilName, FIRE_EVENT_NAME].includes(node.name) ||
(ASTUtils.isIdentifier(parentMemberExpression.object) &&
parentMemberExpression.object.name === node.name)
) {
return false;
}

// check fireEvent.click() usage
const regularCall =
ASTUtils.isIdentifier(parentMemberExpression.object) &&
parentMemberExpression.object.name === fireEventUtilName;
const isFireEventUtil = (node: TSESTree.Identifier): boolean => {
return isTestingLibraryUtil(
node,
(identifierNodeName, originalNodeName) => {
return [identifierNodeName, originalNodeName].includes('fireEvent');
}
);
};

// check testingLibraryUtils.fireEvent.click() usage
const wildcardCall =
isMemberExpression(parentMemberExpression.object) &&
ASTUtils.isIdentifier(parentMemberExpression.object.object) &&
parentMemberExpression.object.object.name === fireEventUtilName &&
ASTUtils.isIdentifier(parentMemberExpression.object.property) &&
parentMemberExpression.object.property.name === FIRE_EVENT_NAME;
/**
* Determines whether a given node is userEvent util itself or not.
*
* Not to be confused with {@link isUserEventMethod}
*/
const isUserEventUtil = (node: TSESTree.Identifier): boolean => {
return isTestingLibraryUtil(
node,
(identifierNodeName, originalNodeName) => {
return [identifierNodeName, originalNodeName].includes('userEvent');
}
);
};

return regularCall || wildcardCall;
/**
* Determines whether a given node is fireEvent method or not
*/
const isFireEventMethod: IsFireEventMethodFn = (node) => {
return isTestingLibrarySimulateEventUtil(node, 'fireEvent');
};

/**
Expand Down Expand Up @@ -557,6 +604,8 @@ export function detectTestingLibraryUtils<
isQuery,
isCustomQuery,
isAsyncUtil,
isFireEventUtil,
isUserEventUtil,
isFireEventMethod,
isRenderUtil,
isRenderVariableDeclarator,
Expand Down
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import preferUserEvent from './rules/prefer-user-event';
import preferWaitFor from './rules/prefer-wait-for';
import noMultipleAssertionsWaitFor from './rules/no-multiple-assertions-wait-for';
import preferFindBy from './rules/prefer-find-by';
import noSideEffectsWaitFor from './rules/no-side-effects-wait-for';
import noWaitForSideEffects from './rules/no-wait-for-side-effects';
import renderResultNamingConvention from './rules/render-result-naming-convention';

const rules = {
Expand All @@ -38,8 +38,8 @@ const rules = {
'no-node-access': noNodeAccess,
'no-promise-in-fire-event': noPromiseInFireEvent,
'no-render-in-setup': noRenderInSetup,
'no-side-effects-wait-for': noSideEffectsWaitFor,
'no-wait-for-empty-callback': noWaitForEmptyCallback,
'no-wait-for-side-effects': noWaitForSideEffects,
'no-wait-for-snapshot': noWaitForSnapshot,
'prefer-explicit-assert': preferExplicitAssert,
'prefer-find-by': preferFindBy,
Expand Down
10 changes: 10 additions & 0 deletions lib/node-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ export function isJSXAttribute(
return node?.type === AST_NODE_TYPES.JSXAttribute;
}

export function isExpressionStatement(
node: TSESTree.Node
): node is TSESTree.ExpressionStatement {
return node?.type === AST_NODE_TYPES.ExpressionStatement;
}

/**
* Finds the closest CallExpression node for a given node.
* @param node
Expand Down Expand Up @@ -388,6 +394,10 @@ export function getPropertyIdentifierNode(
return getPropertyIdentifierNode(node.callee);
}

if (isExpressionStatement(node)) {
return getPropertyIdentifierNode(node.expression);
}

return null;
}

Expand Down
78 changes: 0 additions & 78 deletions lib/rules/no-side-effects-wait-for.ts

This file was deleted.

67 changes: 67 additions & 0 deletions lib/rules/no-wait-for-side-effects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { TSESTree } from '@typescript-eslint/experimental-utils';
import { getPropertyIdentifierNode } from '../node-utils';
import { createTestingLibraryRule } from '../create-testing-library-rule';

export const RULE_NAME = 'no-wait-for-side-effects';
export type MessageIds = 'noSideEffectsWaitFor';
type Options = [];

export default createTestingLibraryRule<Options, MessageIds>({
name: RULE_NAME,
meta: {
type: 'suggestion',
docs: {
description: "It's preferred to avoid side effects in `waitFor`",
category: 'Best Practices',
recommended: false,
},
messages: {
noSideEffectsWaitFor:
'Avoid using side effects within `waitFor` callback',
},
fixable: null,
schema: [],
},
defaultOptions: [],
create: function (context, _, helpers) {
function hasSideEffects(body: Array<TSESTree.Node>): boolean {
return body.some((node: TSESTree.ExpressionStatement) => {
const expressionIdentifier = getPropertyIdentifierNode(node);

if (!expressionIdentifier) {
return false;
}

return (
helpers.isFireEventUtil(expressionIdentifier) ||
helpers.isUserEventUtil(expressionIdentifier)
);
});
}

function reportSideEffects(node: TSESTree.BlockStatement) {
const callExpressionNode = node.parent.parent as TSESTree.CallExpression;
const callExpressionIdentifier = getPropertyIdentifierNode(
callExpressionNode
);

if (!helpers.isAsyncUtil(callExpressionIdentifier, ['waitFor'])) {
return;
}

if (!hasSideEffects(node.body)) {
return;
}

context.report({
node: callExpressionNode,
messageId: 'noSideEffectsWaitFor',
});
}

return {
'CallExpression > ArrowFunctionExpression > BlockStatement': reportSideEffects,
'CallExpression > FunctionExpression > BlockStatement': reportSideEffects,
};
},
});
Loading