forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
The rule n/no-unpublished-require
sometimes throws a TypeError
when require(".")
or require("./")
occurs in the code.
This only happens under certain circumstances:
- The
node
environment is set - The file that contains the
require
is included in thefiles
field in package.json. - There is no file named index.js, or if package.json defines a different file in the
main
field, that file does not exist.
The smallest repro I've come up with:
package.json
{
"files": [
"*.js"
],
"devDependencies": {
"eslint": "latest",
"eslint-plugin-n": "latest"
}
}
.eslintrc
{
"env": {
"node": true
},
"plugins": [
"n"
],
"rules": {
"n/no-unpublished-require": "error"
}
}
foo.js
require('.');
Running npm install
and then npx eslint .
in the project folder prints an error message like this:
Oops! Something went wrong! :(
ESLint: 8.22.0
TypeError: path must not be empty
Occurred while linting /home/user/my-project/foo.js:1
Rule: "n/no-unpublished-require"
I could try to fix this if desired.
Metadata
Metadata
Assignees
Labels
No labels