solidjs-community / eslint-plugin-solid

Solid-specific linting rules for ESLint.
MIT License
206 stars 24 forks source link

Flat Configuration example is not work #118

Closed noriapi closed 6 months ago

noriapi commented 6 months ago

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):

Additional context

uncenter commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

Like this:

  "exports": {
    ".": "./dist/index.js",
    "./configs/typescript": "./dist/configs/typescript.js",
  }
joshwilsonvu commented 6 months ago

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 commented 6 months ago

Ah okay, gotcha.

ESLint plugins are meant to be used with CJS require

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

joshwilsonvu commented 6 months ago

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

uncenter commented 6 months ago

Awesome thanks!

magne4000 commented 2 months ago

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 commented 2 months ago

@joshwilsonvu exports field is still no present in 0.14.0.