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

Stylelint could not find "stylelint-use-nesting" #18

Closed
tomekpiwowar opened this issue Mar 5, 2024 · 5 comments
Closed

Stylelint could not find "stylelint-use-nesting" #18

tomekpiwowar opened this issue Mar 5, 2024 · 5 comments

Comments

@tomekpiwowar
Copy link

I've installed the latest version of plugin (5.1.0), expecting it to solve the problem described in this PR #17 , however now I got an error after running yarn stylelint:

Error: Could not find "stylelint-use-nesting". Do you need to install the package or use the "configBasedir" option?

@romainmenke
Copy link
Member

romainmenke commented Mar 6, 2024

Maybe because the rule name is csstools/use-nesting?

https://github.com/csstools/stylelint-use-nesting/blame/49b77d11bb466eebd94fad1d4e31dc1ad988eeb3/src/index.js#L10

Can you share your config?

@tomekpiwowar
Copy link
Author

tomekpiwowar commented Mar 6, 2024

My .stylelintrc.json:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-prettier/recommended"
  ],
  "plugins": [
    "stylelint-declaration-strict-value",
    "stylelint-value-no-unknown-custom-properties",
    "stylelint-media-use-custom-media",
    "stylelint-use-nesting",
    "stylelint-order",
  ],
  "rules": {
    {some rules...}
    "csstools/media-use-custom-media": "always",
    "csstools/use-nesting": "always",
    {some rules...}
  }
}

I don't think it's about the rule name because as you can see stylelint-media-use-custom-media and its rule csstools/media-use-custom-media has same naming convention and it's working well.

I found that the error disappears and plugin starts working after refactoring "exports" in the plugin package.json from this:

"exports": {
    ".": {
      "import": "./index.mjs"
    }
  },

to this:
"exports": "./index.mjs",

I think the exports might be unnecessarily conditional because:

  • it might enforce the ES Modules support in whole project (which I think is the reason of the error in my case), but it doesn't has to
  • the plugin and the stylelint 16+ itself supports ES Modules only anyway.

@romainmenke
Copy link
Member

Good catch!

I'll fix that later today
Thank you

@romainmenke
Copy link
Member

@tomekpiwowar I've completely remove the exports field.
This also seems to work if I set up a fresh project:

Screenshot 2024-03-06 at 17 46 50

Can you verify that everything is now fixed on your end?

@tomekpiwowar
Copy link
Author

@romainmenke I just tested the package after your update and everything works properly. Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants