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

Eslint fails on node-no-missing-require and node/no-unpublished-require #3088

Closed
NickColley opened this issue Aug 18, 2022 · 5 comments
Closed

Comments

@NickColley
Copy link

const test = require("ava");

test("should be true", async (assert) => {
  assert.true(true);
});

With eslint node/recommended I get:

error  "ava" is not found (node/no-missing-require)
error  "ava" is not published (node/no-unpublished-require)

Is there something missing from my configuration or ava's published package.json?

@jonathansamines
Copy link
Contributor

Hey @NickColley you'll probably need to adjust the allowModules plugin setting to exclude ava. I had to do a similar thing for eslint-plugin-import (see mysticatea/eslint-plugin-node#314). Most of eslint plugins do not play well yet with exports maps (which ava 4.x uses)

@Windvis
Copy link

Windvis commented Oct 13, 2022

I ran into the no-unpublished-require rule as well and the docs explain it pretty good: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-unpublished-require.md#-rule-details

In my case it was triggered because ava is a devDependency but I didn't make use of files and the test files weren't added to .npmignore yet so they would have actually been published to npm.

@NickColley
Copy link
Author

NickColley commented Oct 22, 2022

I wonder given my repository has "private" set to true so it can never be published if these rules could automatically relax?

Here's the config I ended up going with:

{
  "eslintConfig": {
    "rules": {
      "node/no-unpublished-import": "off",
      "node/no-missing-import": [
        "error",
        {
          "allowModules": [
            "ava"
          ]
        }
      ]
    }
  }
}

@Windvis
Copy link

Windvis commented Oct 23, 2022

@NickColley I had the same thoughts and that's indeed a popular request in the eslint-plugin-node repo: mysticatea/eslint-plugin-node#77 Sadly that projects is kind of unmaintained at the moment.

I did however create a PR in the community fork but that still needs to be reviewed.

@NickColley
Copy link
Author

Seems like this is already discussed then, thank you for your time.

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

3 participants