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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

node/no-unpublished-import inconsistency #337

Open
2 tasks done
electriquo opened this issue Aug 12, 2022 · 3 comments
Open
2 tasks done

node/no-unpublished-import inconsistency #337

electriquo opened this issue Aug 12, 2022 · 3 comments

Comments

@electriquo
Copy link

My package works when running locally and it include files which are being reported as node/no-unpublished-import.

Looking at the rule details

## 馃摉 Rule Details
If a source code file satisfies all of the following conditions, the file is \*published\*.
- `"files"` field of `package.json` includes the file or `"files"` field of `package.json` does not exist.
- `.npmignore` does not include the file.
Then this rule warns `import` declarations in \*published\* files if the `import` declaration imports \*unpublished\* files or the packages of `devDependencies`.
all conditions are met:

  • "files" field of package.json does not exist.
  • .npmignore does not include the file. (npm pack include it)

Here are more details:

$ npm pack
npm notice
npm notice 馃摝  foo@1.0.0
npm notice === Tarball Contents ===
npm notice 707B  README.md
npm notice 2.2kB package.json
npm notice 1.8kB src/app.js
npm notice 441B  src/index.js
npm notice 1.2kB src/next/run.js
npm notice 585B  src/settings.js
npm notice === Tarball Details ===
npm notice name:          foo
npm notice version:       1.0.0
npm notice filename:      foo-1.0.0.tgz
npm notice package size:  3.0 kB
npm notice unpacked size: 6.9 kB
npm notice shasum:        40e557584dd512a827d79bffb1ce1e80f112d152
npm notice integrity:     sha512-vhLLIZAFkvhyo[...]19wv3Ehyuigeg==
npm notice total files:   6
npm notice
foo-1.0.0.tgz

$ npx eslint --env-info
Environment Info:

Node version: v16.16.0
npm version: v8.14.0
Local ESLint version: v8.21.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 21.6.0

$ npx eslint .
/foo/bar/prj/src/app.js
  5:22  error  "./settings.js" is not published  node/no-unpublished-import
  6:24  error  "./next/run.js" is not published  node/no-unpublished-import

$ cat /foo/bar/prj/src/app.js | head -n 5 | tail -n 1
import settings from "./settings.js";

$ cat package.json | jq '.files'
null

It is a bug or am I missing something?

@siva-444
Copy link

+1

@electriquo
Copy link
Author

electriquo commented Jul 22, 2023

@mysticatea Is the project is still alive and maintained?
maybe related to #77

@voxpelli
Copy link

eslint-plugin-n is the maintained version of this module.

We switched to it in eg. eslint-config-standard / standard and it is maintained by me and other members of the official ESLint community organization.

Try that module out and if it isn't fixed there, then open a new issue in that project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants