GithubHelp home page GithubHelp logo

Comments (12)

aladdin-add avatar aladdin-add commented on July 21, 2024 1

seems it's working as expected - as said in the node.js docs:

"default" - the generic fallback that always matches. Can be a CommonJS or ES module file. This condition should always come last.

https://nodejs.org/docs/latest/api/packages.html#conditional-exports

the next steps:

  1. it should report the exact error message in the rule, than just ignoring. (will be fixed by #231)
  2. fix @humanwhocodes/retry to put the default to last.

from eslint-plugin-n.

aladdin-add avatar aladdin-add commented on July 21, 2024 1

maybe (I'm not a native English speaker). but it's also saying:

Within the "exports" object, key order is significant. During condition matching, earlier entries have higher priority and take precedence over later entries. The general rule is that conditions should be from most specific to least specific in object order.

generally, it should be a best practice to put it in the last.

from eslint-plugin-n.

scagood avatar scagood commented on July 21, 2024 1

Fair point! Notes for next time include to read the source! 😅

from eslint-plugin-n.

scagood avatar scagood commented on July 21, 2024 1

Agreed, I think I will do point two:

Pr enhanced resolve to allow the error to be ignored via an option

It may also be worth seeing if we can add a rule to eslint-plugin-package-json too specifically about this if there is not one already 🤔

from eslint-plugin-n.

scagood avatar scagood commented on July 21, 2024

After some looking, this is related to: #182

The error is that the exports are the wrong way around:
https://github.com/humanwhocodes/retry/blob/8f8af13/package.json#L10-L13

Therefore this error is getting triggered:
https://github.com/webpack/enhanced-resolve/blob/main/lib/util/entrypoints.js#L475

from eslint-plugin-n.

voxpelli avatar voxpelli commented on July 21, 2024

For context: Sounds like this regression is caused by #139 then

@scagood Want help to look into it?

from eslint-plugin-n.

scagood avatar scagood commented on July 21, 2024

Yeah, I would tend to agree. I am thinking about what the best course here is.

We could:

  1. Ignore the error (but then not have a path)
  2. Pr enhanced resolve to allow the error to be ignored via an option (I don't understand why it throws as opposed to just accepting the default as default)

from eslint-plugin-n.

scagood avatar scagood commented on July 21, 2024

The think that is in in the back of my head is related to this:

This condition should always come last.

I interpret this as should always be checked last, not should always appear last in the object's properties

I do know that as of es2020 property ordering is expected (eg in for-in). But before that I don't think there was any guarantee of order 🤔

from eslint-plugin-n.

voxpelli avatar voxpelli commented on July 21, 2024

Note that the "types" condition should always come first in "exports".

Taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-also supports this

from eslint-plugin-n.

scagood avatar scagood commented on July 21, 2024

I think we should then close this and proceed with #182 (My first attempt to make that more verbose is here: #231)

from eslint-plugin-n.

voxpelli avatar voxpelli commented on July 21, 2024

Well, if node.js can resolve the module and the issue this plugin finds isn’t within the project that runs the linting but rather in one of its dependencies, then I think the linting shouldn’t fail as it’s kind of a false alarm?

Such a failed linting should happen in the project that published the incorrect fields instead.

from eslint-plugin-n.

nzakas avatar nzakas commented on July 21, 2024

Well, if node.js can resolve the module and the issue this plugin finds isn’t within the project that runs the linting but rather in one of its dependencies, then I think the linting shouldn’t fail as it’s kind of a false alarm?

Such a failed linting should happen in the project that published the incorrect fields instead.

I agree with this. The current setup for the retry package works fine in Node.js so I don't think it should be considered a problem. This seems more like something that other tooling is trying to enforce rather than an actual problem with the package.

That said, I can update the package to swap the order of exports.

from eslint-plugin-n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.