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

broken with stylelint 16.10: TypeError: Cannot read properties of undefined (reading 'config') #32

Closed
MiniDigger opened this issue Oct 17, 2024 · 2 comments · Fixed by #33

Comments

@MiniDigger
Copy link
Contributor

Type of issue

  • Bug report

Environment

Node.js v22.2.0
win32 10.0.19045

Expected behavior

stuff works

Current behavior

    TypeError: Cannot read properties of undefined (reading 'config')
        at Object.validateOptions (C:\Gothaer\Projects\stylelint-bem\node_modules\stylelint\lib\utils\validateOptions.cjs:22:40)
        at C:\Gothaer\Projects\stylelint-bem\index.js:181:40
        at file:///C:/Gothaer/Projects/stylelint-bem/node_modules/stylelint/lib/lintPostcssResult.mjs:113:60
        at Array.map (<anonymous>)
        at lintPostcssResult (file:///C:/Gothaer/Projects/stylelint-bem/node_modules/stylelint/lib/lintPostcssResult.mjs:112:18)
        at async lintSource (file:///C:/Gothaer/Projects/stylelint-bem/node_modules/stylelint/lib/lintSource.mjs:108:2)
        at async standalone (file:///C:/Gothaer/Projects/stylelint-bem/node_modules/stylelint/lib/standalone.mjs:143:26)
        at async C:\Gothaer\Projects\stylelint-bem\node_modules\jest-preset-stylelint\getTestRule.js:73:30

Steps to reproduce the behavior

  • clone the repo
  • update stylelint to 16.10
  • run the tests

Explanation

so this is a fun one. I thought I was going insane for a bit, but managed to track it down.
this package is calling stylelint's validateOptions with an invalid method signature!
it passes an object:

stylelint-bem/index.js

Lines 181 to 185 in 41ee842

const validOptions = stylelint.utils.validateOptions({
ruleName,
result,
actual: options,
});

when stylelint expects multiple params: https://github.com/stylelint/stylelint/blob/1b03662ecb05cc6ed323b4e3b0946fb20870b287/lib/utils/validateOptions.cjs#L20-L22

this never surfaced, since validateOptions basically does nothing if the 3rd param is empty. At least it used to do nothing. in stylelint 16.10 there is a new option that actually checks stuff on the first param, and since stylelint-bem passes a malformed param, the error occurs. commit adding the option: stylelint/stylelint@8643754#diff-a9078006ea40b10e08ed8dd13f68bb5a9585641b76e827cef5bc80216d1aa877R18 )

ill submit a PR fixing it after lunch....

@ernscht
Copy link
Member

ernscht commented Oct 17, 2024

Great!
Thank you very much for your finding and your work.

But I won't be able to look at it until tomorrow at the earliest.

ernscht added a commit that referenced this issue Oct 19, 2024
fix: call stylelint.validateOptions with the right arg, closes #32
@ernscht
Copy link
Member

ernscht commented Oct 21, 2024

Fix is published as v10.1.0

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

Successfully merging a pull request may close this issue.

2 participants