Skip to content

no-import-test-files incorrectly flags modules that end in .js #215

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
mearns opened this issue Feb 25, 2019 · 4 comments · Fixed by #226
Closed

no-import-test-files incorrectly flags modules that end in .js #215

mearns opened this issue Feb 25, 2019 · 4 comments · Fixed by #226
Labels
bug 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted

Comments

@mearns
Copy link

mearns commented Feb 25, 2019

Issuehunt badges

Using all the default options, the following line in a test file is incorrectly flagged as violating the no-import-test-files rule:

var highlight = require('highlight.js')

It appears that any module name ending in .js will similarly be flagged as a violation. However, the semantics for node's require function will only look for local files if they start with a dot, so this will always be importing a module, not a test file.

gmartigny earned $30.00 by resolving this issue!

@IssueHuntBot
Copy link

@IssueHunt has funded $30.00 to this issue.


Manu1400 added a commit to Manu1400/eslint-plugin-ava that referenced this issue Mar 24, 2019
Manu1400 added a commit to Manu1400/eslint-plugin-ava that referenced this issue Mar 24, 2019
@GMartigny
Copy link
Contributor

Hi @mearns,

I cannot reproduce your issue. Could you tell which version of eslint and eslint-plugin-ava you're using ? Could you maybe provide a simple repo showing the configuration you are using ?

Thanks

@mearns
Copy link
Author

mearns commented Mar 28, 2019

Sure, you can clone this repo and checkout the "eslint-plugin-ava-215" branch: https://github.com/mearns/lowlight/tree/eslint-plugin-ava-215, then run "npm run format". It runs xo which runs eslint with the ava/no-import-test-files rule, and gives the following violation:

  test/index.js:3:17
  ✖  3:17  Test files should not be imported  ava/no-import-test-files

  1 error

Note that this is with eslint-plugin-ava version 5.1.1

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 10, 2019
@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels May 14, 2019
@IssueHuntBot
Copy link

@sindresorhus has rewarded $27.00 to @GMartigny. See it on IssueHunt

  • 💰 Total deposit: $30.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $3.00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Projects
None yet
4 participants