Skip to content

no-manual-cleanup does not like require(modulaName) #125

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

Closed
kentcdodds opened this issue May 5, 2020 · 5 comments · Fixed by #128
Closed

no-manual-cleanup does not like require(modulaName) #125

kentcdodds opened this issue May 5, 2020 · 5 comments · Fixed by #128
Labels
bug Something isn't working good first issue Good for newcomers released

Comments

@kentcdodds
Copy link
Member

I've got code like this:

require(moduleName)

and no-manual-cleanup does this:

TypeError: Cannot read property 'match' of undefined
Occurred while linting /Users/kentcdodds/code/kcd-scripts/src/utils.js:39
    at VariableDeclarator (/Users/kentcdodds/code/kcd-scripts/node_modules/eslint-plugin-testing-library/rules/no-manual-cleanup.js:71:73)
    at /Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:634:23)
    at /Users/kentcdodds/code/kcd-scripts/node_modules/eslint/lib/linter/linter.js:936:32
    at Array.forEach (<anonymous>)

This is because of this code:

const value = node.source.value as string;
const testingLibraryWithCleanup = value.match(CLEANUP_LIBRARY_REGEX);

It should check whether value exists before calling match :)

@Belco90
Copy link
Member

Belco90 commented May 6, 2020

Hey Kent! Thanks for open an issue so detailed. This one should be easy to fix, I'll try to take a look at it this weekend if no one else can address it before.

@Belco90
Copy link
Member

Belco90 commented May 8, 2020

🎉 This issue has been resolved in version 3.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Belco90
Copy link
Member

Belco90 commented May 8, 2020

@all-contributors please add @kentcdodds for bugs

@allcontributors
Copy link
Contributor

@Belco90

I've put up a pull request to add @kentcdodds! 🎉

@kentcdodds
Copy link
Member Author

Sweet! Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants