-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
Fix false positives for functional pseudo-classes in no-descending-specificity #4010
Comments
no-descending-specificity
with css module pre-sudo functions selectors works is not expected
@vegawong Thanks for the report and for using the template. It looks like the rule struggles with functional pseudo-classes. I can reproduce this with:
As the issue has been labelled "help wanted", please consider contributing a fix. |
@jeddy3 , Thanks for reply! I am tring to understand how to calculate the specificity by stylelint. I found that the specificity calculate result was not equal to the |
Hey guys! Maybe i had found the problem.
In this line of code, :global is treated as a pseudo selector so that all the last nodes that use :global are treated as the same comparisonContext. Right?:global and :local are predefined keywords in css-module. I suggest adding these words to keywordSets.pseudoElements to compare them as separate items in comparisonContext .
|
@import '../../variable.less';
@imgSize: 32px;
@gutter: (@menu-collapsed-width - @imgSize) / 2;
.sider,
.logo,
.logo h1 {
transition: all 0.2s;
}
.sider {
padding-top: @layout-header-height;
position: fixed;
height: 100%;
left: 0;
top: 0;
:global(.ant-layout-sider-children) {
padding-right: 20px;
width: calc(~'100% + 20px');
height: calc(~'100vh - @{layout-header-height}');
overflow-x: hidden;
overflow-y: auto;
-ms-overflow-style: none; // overflow: -moz-scrollbars-none;
&::-webkit-scrollbar {
display: none;
}
}
}
.logo {
position: fixed;
top: 0;
left: 0;
height: @layout-header-height;
line-height: @layout-header-height;
padding-left: @gutter;
background: @header-background;
width: 200px;
color: @header-color;
overflow: hidden;
z-index: 1;
img,
h1 {
display: inline-block;
vertical-align: middle;
}
img {
height: @imgSize;
}
h1 {
color: #fff;
font-size: 20px;
font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif;
font-weight: 600;
margin: 0 0 0 @gutter;
}
}
.siderCollapsed {
.logo {
padding-left: 24px;
padding-right: 24px;
width: auto;
h1 {
display: none;
}
}
// here
// `Expected selector ".siderCollapsed :global(.ant-menu-item-group-title)" to come before selector ".sider :global(.ant-layout-sider-children)::-webkit-scrollbar" (no-descending-specificity)stylelint(no-descending-specificity)`
:global(.ant-menu-item-group-title) {
text-align: center;
}
}
|
same problem |
The
The false positive reported by the issue appears still on the demo, but I doubt if it's a false positive. 🤔 const parser = require('postcss-selector-parser');
const { selectorSpecificity } = require('@csstools/selector-specificity');
console.log(selectorSpecificity(parser().astSync('.componentName :global(.ant-modal) :global(.ant-btn)')));
//=> { a: 0, b: 3, c: 0 }
console.log(selectorSpecificity(parser().astSync('.componentName :global(.ant-menu)')));
//=> { a: 0, b: 2, c: 0 } See also the What do you think? |
I agree. Let's close. |
Same error for me, How should fix it ? |
@richex-cn Could you reproduce an error on the demo and paste the demo URL here, please? |
@ybiquitous Sure, It's demo. |
@richex-cn Thanks. I'll look into it. 👍🏼 |
There are some error tips in my selectors was not expected..
It flagged an error about rule
no-descending-specificity
when i use css-module presudo function like:global()
with a selector.Thought the selectors had not any relations ,it always flagged an error.
If i rewrite the same selectors without
:global
, then it works.no-descending-specificity
e.g.
9.10.1
CLI with
stylelint "**/*.css" --config .stylelintrc.js
Yes, it's related to css module pre-sudo function like
:global()
No warnings to be flagged.
The following warnings were flagged:
The text was updated successfully, but these errors were encountered: