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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flat Configuration example is not work #118

Closed
1 task
noriapi opened this issue Dec 30, 2023 · 10 comments
Closed
1 task

Flat Configuration example is not work #118

noriapi opened this issue Dec 30, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@noriapi
Copy link

noriapi commented Dec 30, 2023

Describe the bug
Using this Flat Configuration example will result in the following error:

Oops! Something went wrong! :(

ESLint: 8.56.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/runner/work/eslint-plugin-solid-module-not-found/eslint-plugin-solid-module-not-found/node_modules/eslint-plugin-solid/configs/recommended' imported from /home/runner/work/eslint-plugin-solid-module-not-found/eslint-plugin-solid-module-not-found/eslint.config.js
    at finalizeResolution (node:internal/modules/esm/resolve:255:11)
    at moduleResolve (node:internal/modules/esm/resolve:908:10)
    at defaultResolve (node:internal/modules/esm/resolve:1121:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36)
Error: Process completed with exit code 2.

To Reproduce
see this repo

Expected behavior
no error

Environment (please complete the following information):

  • OS: Ubuntu 20.04 on WSL2
  • Node version (v20.10.0):
  • eslint-plugin-solid version (0.13.0):
  • eslint version (8.56.0):

Additional context

  • I would be willing to contribute a PR to fix this issue
@noriapi noriapi added the bug Something isn't working label Dec 30, 2023
@uncenter
Copy link

Yeah I have this too. Try this:

import solid from 'eslint-plugin-solid/dist/configs/typescript.js';

If they want us to be able to do 'eslint-plugin-solid/configs/typescript' they need to set an exports field in the package.json...

@joshwilsonvu
Copy link
Collaborator

Thanks for the issue. I think the problem is that package.json is missing the configs directory under the "files" key, so it's not getting bundled with the package.

One of those things that works fine when testing locally but breaks on publish.

Should be a quick fix!

@uncenter
Copy link

uncenter commented Dec 30, 2023

It is getting bundled though:

(https://www.npmjs.com/package/eslint-plugin-solid?activeTab=code)

Screenshot 2023-12-30 at 10 22 43 (Arc)

The issue is you have to add an exports field I think.

@uncenter
Copy link

Like this:

  "exports": {
    ".": "./dist/index.js",
    "./configs/typescript": "./dist/configs/typescript.js",
  }

@joshwilsonvu
Copy link
Collaborator

Thanks for checking! dist/configs is getting packaged, yes, but not configs (which just re-exports from dist/configs to make the example import path work.

I've been hesitant to add "exports", since it's a breaking change and ESLint plugins are meant to be used with CJS require, but I'll consider it. I just think that's a different issue 🙂

@uncenter
Copy link

Ah okay, gotcha.

ESLint plugins are meant to be used with CJS require

Hopefully not for long! FlatConfig w/ ESM is the way! 😁

joshwilsonvu added a commit that referenced this issue Dec 30, 2023
Fix flat imports example by adding configs dir to files field, for #118.
@joshwilsonvu
Copy link
Collaborator

Absolutely, fully support the move to ESM! Just following ESLint's lead 😄 will ship this fix in the next release!

@uncenter
Copy link

Awesome thanks!

@magne4000
Copy link

I see this has been closed but the exports field is still no present in current version (0.13.2), so this is still an ongoing issue.

@YogiLiu
Copy link

YogiLiu commented May 4, 2024

@joshwilsonvu exports field is still no present in 0.14.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants