Skip to content

style: validate selector prefix by stylelint (#DS-3497) #709

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

const KEBAB_CASE_PATTERN = '^_?[a-z0-9]+(-[a-z0-9]+)*$';

const ALLOWED_PREFIXES = [
// Default
'kbq-',
// packages/docs-examples
'example-',
// packages/components-dev
'dev-',
// apps/docs
'docs-',
// Angular specific
'cdk-',
// Angular specific
'ng-',
// _layout.scss
'layout-',
// _layout.scss
'flex-'
];

/** @type {import('stylelint').Config} */
const config = {
defaultSeverity: 'error',
Expand Down Expand Up @@ -38,6 +57,12 @@ const config = {
]
}
],
'selector-class-pattern': [
`^_?(${ALLOWED_PREFIXES.join('|')})`,
{
resolveNestedSelectors: true
}
],

// SCSS rules
'scss/operator-no-newline-after': null,
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/src/app/components/navbar/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
gap: var(--kbq-size-xxs);
}

.kbq-button-icon,
.DocSearch-Button {
/* stylelint-disable-next-line selector-class-pattern */
.DocSearch-Button,
.kbq-button-icon {
width: $size-5xl;
height: $size-5xl;
}
Expand Down
1 change: 1 addition & 0 deletions apps/docs/src/styles/_docsearch.scss
Copy link
Contributor Author

Choose a reason for hiding this comment

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

skip .DocSearch selectors

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* stylelint-disable selector-class-pattern */
/* stylelint-disable scss/at-extend-no-missing-placeholder */

@use '@docsearch/css/dist/style';
Expand Down
2 changes: 2 additions & 0 deletions packages/components/code-block/_code-block-theme.scss
Copy link
Contributor Author

Choose a reason for hiding this comment

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

skip .hljs selectors

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* stylelint-disable selector-class-pattern */

@use '../core/styles/common/tokens' as *;

@function kbq-code-block-hljs-attr($attr) {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/code-block/code-block.scss
Copy link
Contributor Author

@artembelik artembelik Apr 28, 2025

Choose a reason for hiding this comment

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

skip .hljs selectors

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* stylelint-disable selector-class-pattern */

@use './code-block-theme' as theme;

.kbq-code-block {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@mixin media-print {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo, unused mixin?

@media print {
/* stylelint-disable-next-line selector-class-pattern */
.hide-print:not(.show-print):not(.show) {
display: none !important;
}
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

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

skip .os selectors

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* stylelint-disable selector-class-pattern */

@use '../core/styles/common/tokens' as *;

@mixin kbq-scrollbar-component-theme() {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/scrollbar/scrollbar.component.scss
Copy link
Contributor Author

Choose a reason for hiding this comment

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

skip .os selectors

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* stylelint-disable selector-class-pattern */

@use '../core/styles/common/tokens' as *;

@use './scrollbar-component-theme' as *;
Expand Down
Loading