Skip to content
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

no-import-test-files considers test/helpers/index.js a test file #311

Open
fregante opened this issue Sep 25, 2020 · 1 comment
Open

no-import-test-files considers test/helpers/index.js a test file #311

fregante opened this issue Sep 25, 2020 · 1 comment

Comments

@fregante
Copy link
Contributor

fregante commented Sep 25, 2020

From my understanding, `/helpers/ are not test files: https://github.com/avajs/ava/blob/1222ce9538e4890c20af695e558e3ee490f5a41b/docs/05-command-line.md#cli

And should pass: https://github.com/avajs/eslint-plugin-ava/blob/7542453058c30ebbc79c7bfeb689492fce226d8f/docs/rules/no-import-test-files.md

But they don't:

Setup

node/14.4.0
npm/6.14.5

repro.zip

{
  "private": true,
  "scripts": {
    "test": "xo && ava"
  },
  "devDependencies": {
    "ava": "^3.12.1",
    "xo": "^0.33.1"
  }
}
// test/helpers/index.js;
exports.USER = { login: "current-user" };
// test/index.js
const test = require("ava");
const { USER } = require("./helpers");

test.cb("Help me help you", (t) => {
  console.log(USER);
  t.end();
});

Output

❯ xo

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

  1 error
@novemberborn
Copy link
Member

Yea that looks like a bug.

Our plugin should be using the installed AVA version to classify the imports. That should end up in this function:

https://github.com/avajs/ava/blob/512454704d981d06e97276c6568b615f79c0b8ad/eslint-plugin-helper.js#L67-L75

@fregante fregante changed the title Unable to satisfy no-import-test-files no-import-test-files considers test/helpers/index.js to be a test file Sep 29, 2020
@fregante fregante changed the title no-import-test-files considers test/helpers/index.js to be a test file no-import-test-files considers test/helpers/index.js a test file Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants