-
-
Notifications
You must be signed in to change notification settings - Fork 45
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-unpublished-require/no-unpublished-bin false positives #122
Comments
This looks to be the same as #99 I will see if I can find some time this week to look |
🤔 So, you can avoid this by simply changing the regex at https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/util/get-npmignore.js#L15
This is a simple solution, but I think a better solution would be to use path.normalize: Something like this: const body = path
.normalize(file.replace(/^!/u, ''))
.replace(/\/+$/u, '') 🏗️ 🩹 Git Patchdiff --git a/lib/util/get-npmignore.js b/lib/util/get-npmignore.js
index a818075..4483308 100644
--- a/lib/util/get-npmignore.js
+++ b/lib/util/get-npmignore.js
@@ -12,7 +12,6 @@ const exists = require("./exists")
const getPackageJson = require("./get-package-json")
const cache = new Cache()
-const SLASH_AT_BEGIN_AND_END = /^!?\/+|^!|\/+$/gu
const PARENT_RELATIVE_PATH = /^\.\./u
const NEVER_IGNORED =
/^(?:readme\.[^.]*|(?:licen[cs]e|changes|changelog|history)(?:\.[^.]*)?)$/iu
@@ -90,7 +89,10 @@ function parseWhiteList(files) {
for (const file of files) {
if (typeof file === "string" && file) {
- const body = file.replace(SLASH_AT_BEGIN_AND_END, "")
+ const body = path
+ .normalize(file.replace(/^!/u, ''))
+ .replace(/\/+$/u, '')
+
if (file.startsWith("!")) {
igN.add(`${body}`)
igN.add(`${body}/**`) This is because we can handle more things in the files array, (eg most of this silly) for no extra cost:
|
In published
bin
files in npm packages, there are false positive for theno-unpublished-require
andno-unpublished-bin
rules when a path is included in the package.jsonfiles
array relative to.
.For example, with package.json:
The following
./bin/foo.js
does not show anyno-unpublished-require
errors:If the package.json is changed to:
then
./bin/foo.js
shows ano-unpublished-require
error for bothrequire
s. This seems to only occur inbin
files. For example, if./lib/bar.js
includes arequire('../') it doe snot show a
no-unpublished-require` error. The required files are, however, published.Similarly, if the
files
entrybin/
is changed to./bin/
, then the entire./bin/foo.js
file shows ano-unpublished-bin
error (it seems related).There's an example at https://github.com/aarongoldenthal/eslint-n-require-false-positive.
The text was updated successfully, but these errors were encountered: