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

Update postcss-bem-linter to v^4.0.0 #62

Merged
merged 5 commits into from Jun 28, 2023

Conversation

andieelmes
Copy link
Contributor

There is a fix in a new version

@simonsmith
Copy link
Owner

The API to postcss-bem-linter has changed with the postcss 8 update.

I tried the following change:

var bemLinterResult = new Result();
- bemLinter(options)(root, bemLinterResult)
+ bemLinter(options).Once(root, {result: bemLinterResult});
var bemLinterWarnings = bemLinterResult.warnings();

Error is:

TypeError: opts.node.rangeBy is not a function
    at new Warning (/Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss/lib/warning.js:9:29)
    at Result.warn (/Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss/lib/result.js:26:19)
    at /Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss-bem-linter/lib/validate-selectors.js:57:21
    at Array.forEach (<anonymous>)
    at module.exports (/Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss-bem-linter/lib/validate-selectors.js:40:13)
    at checkRule (/Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss-bem-linter/index.js:86:9)
    at /Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss-bem-linter/index.js:53:11
    at Array.forEach (<anonymous>)
    at /Users/simonsmith/Sites/stylelint-selector-bem-pattern/node_modules/postcss-bem-linter/index.js:50:16

I'm not familiar with the changes in postcss 8.

@bjentsch Is there anything obvious here that you could help with? 😄

@andieelmes andieelmes marked this pull request as draft June 27, 2023 21:39
@bjentsch
Copy link

@bjentsch Is there anything obvious here that you could help with? smile

I'll have a look and come back to you ASAP 😘

"postcss-bem-linter": "^4.0.0",
"stylelint": ">=13.13.1"
"stylelint": ">=15.9.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the error opts.node.rangeBy is not a function should be fixed by using a newer postcss version in the plugin and dependencies stylelint/stylelint#5766

@@ -36,6 +36,13 @@
},
"devDependencies": {
"eslint": "^7.31.0",
"stylelint-test-rule-tape": "^0.2.0"
"jest": "^29.5.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But stylelint-test-rule-tape is archived https://github.com/stylelint/stylelint-test-rule-tape and uses an old (6.9.0) stylelint version, which in turn uses an old postcss version (5.0.20)

I thought of just copying stylelint-test-rule-tape code into the project, but it uses old stylelint api createRuleTester https://github.com/stylelint/stylelint-test-rule-tape/blob/master/index.js#L16 that since then has been removed: stylelint/stylelint#4267.

In the removal thread jest-preset-stylelint has been recommended as a replacement: stylelint/stylelint#4267 (comment)

config: null,
skipBasicChecks: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to jest-preset-stylelint has been pretty straightforward.

skipBasicChecks has been removed in older jest-preset-stylelint version https://github.com/stylelint/jest-preset-stylelint/blob/main/CHANGELOG.md#500

@andieelmes andieelmes marked this pull request as ready for review June 28, 2023 10:36
@simonsmith
Copy link
Owner

simonsmith commented Jun 28, 2023

Nice work on this @andieelmes! Thanks

I think you can also remove Node 12 from the CI as it looks like Stylelint dropped support for it

stylelint/stylelint#6311

@simonsmith simonsmith merged commit 27efd40 into simonsmith:master Jun 28, 2023
2 checks passed
@simonsmith
Copy link
Owner

Released - https://www.npmjs.com/package/stylelint-selector-bem-pattern/v/3.0.0

Thanks for the help

@andieelmes
Copy link
Contributor Author

Thank you!

@bjentsch
Copy link

Damn, you guys are fast. Thanks for your work!

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

Successfully merging this pull request may close these issues.

None yet

3 participants