Eslint fails on node-no-missing-require and node/no-unpublished-require
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?
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 https://github.com/mysticatea/eslint-plugin-node/issues/314). Most of eslint plugins do not play well yet with exports maps (which ava 4.x uses)
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.
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"
]
}
]
}
}
}
@NickColley I had the same thoughts and that's indeed a popular request in the eslint-plugin-node repo: https://github.com/mysticatea/eslint-plugin-node/issues/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.
Seems like this is already discussed then, thank you for your time.