Skip to content

node/no-unpublished-import inconsistency #337

@electriquo

Description

@electriquo

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 📦  [email protected]
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions