Coder Social home page Coder Social logo

Comments (6)

fasttime avatar fasttime commented on May 18, 2024 1

No problem :) For usage questions around ESLint there is also a Discord chat, they are usually quick to respond. Good luck!

from eslint.

fasttime avatar fasttime commented on May 18, 2024

Thanks for the issue @JeremyLoy. I don't think that ESLint can support this feature in a core rule because it's about a Node.js-specific API. Also note that the no-restricted-imports rule is designed to work without knowledge of the file system. It even works in a browser because it expects a list of import specifiers to be provided by the user, without checking if those imports correspond to existing or accessible modules.

That said, eslint-plugin-n has a rule called n/no-missing-import that should report a problem in this case (I tried it with your repro and it does, although there's another plugin in your config that doesn't recognize the subpath export and reports a problem).

from eslint.

JeremyLoy avatar JeremyLoy commented on May 18, 2024

Thanks for the response @fasttime, I appreciate it. I'll close this since it makes sense to not have Node only concepts in ESLint proper.

Also, thank you for pointing me towards eslint-plugin-n, I hadn't seen it before.

Is that the de-facto plugin for all things NodeJS specific nowadays? I see it referenced a few times in this repo next to deprecated rules

from eslint.

JeremyLoy avatar JeremyLoy commented on May 18, 2024

hey @fasttime - I updated my repo with eslint-plugin-n, but I'm still not seeing the lint error like you said.

Do you mind taking a look and seeing what I have misconfigured?

from eslint.

fasttime avatar fasttime commented on May 18, 2024

Hm, your npm "lint" script in the package.json file looks incomplete if you are running npm run lint. It should be along the lines of "eslint --ext .mjs .".

In the eslintrc config system, no files are linted by default, and only .js files are linted if a directory is specified. To lint a directory of .mjs files, one would pass both a directory name (. for the current directory) and the file extension with --ext .mjs on the command line. When using the flat config system, which will become the default in ESLint 9, neither is required.

from eslint.

JeremyLoy avatar JeremyLoy commented on May 18, 2024

@fasttime thanks 🤦 Can't believe I forgot to do that. Its been a while since I set up a project from scratch.

My PoC is working now, correctly failing the impossible import. But now its also failing to find the local workspace module. Unless you think thats an issue with eslint specifically, I'll start a conversation over at eslint-plugin-n.

Thanks again for your help!

from eslint.

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.