Skip to content

Commit 572aab2

Browse files
committed
style: validate selector prefix by stylelint (#DS-3497)
1 parent 5fa40df commit 572aab2

File tree

8 files changed

+38
-2
lines changed

8 files changed

+38
-2
lines changed

.stylelintrc.js

+25
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

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

5+
const ALLOWED_PREFIXES = [
6+
// Default
7+
'kbq-',
8+
// packages/docs-examples
9+
'example-',
10+
// packages/components-dev
11+
'dev-',
12+
// apps/docs
13+
'docs-',
14+
// Angular specific
15+
'cdk-',
16+
// Angular specific
17+
'ng-',
18+
// _layout.scss
19+
'layout-',
20+
// _layout.scss
21+
'flex-'
22+
];
23+
524
/** @type {import('stylelint').Config} */
625
const config = {
726
defaultSeverity: 'error',
@@ -38,6 +57,12 @@ const config = {
3857
]
3958
}
4059
],
60+
'selector-class-pattern': [
61+
`^_?(${ALLOWED_PREFIXES.join('|')})`,
62+
{
63+
resolveNestedSelectors: true
64+
}
65+
],
4166

4267
// SCSS rules
4368
'scss/operator-no-newline-after': null,

apps/docs/src/app/components/navbar/navbar.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
gap: var(--kbq-size-xxs);
6363
}
6464

65-
.kbq-button-icon,
66-
.DocSearch-Button {
65+
/* stylelint-disable-next-line selector-class-pattern */
66+
.DocSearch-Button,
67+
.kbq-button-icon {
6768
width: $size-5xl;
6869
height: $size-5xl;
6970
}

apps/docs/src/styles/_docsearch.scss

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

34
@use '@docsearch/css/dist/style';

packages/components/code-block/_code-block-theme.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* stylelint-disable selector-class-pattern */
2+
13
@use '../core/styles/common/tokens' as *;
24

35
@function kbq-code-block-hljs-attr($attr) {

packages/components/code-block/code-block.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* stylelint-disable selector-class-pattern */
2+
13
@use './code-block-theme' as theme;
24

35
.kbq-code-block {

packages/components/core/styles/visual/_layout-media.scss

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@mixin media-print {
22
@media print {
3+
/* stylelint-disable-next-line selector-class-pattern */
34
.hide-print:not(.show-print):not(.show) {
45
display: none !important;
56
}

packages/components/scrollbar/_scrollbar-component-theme.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* stylelint-disable selector-class-pattern */
2+
13
@use '../core/styles/common/tokens' as *;
24

35
@mixin kbq-scrollbar-component-theme() {

packages/components/scrollbar/scrollbar.component.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* stylelint-disable selector-class-pattern */
2+
13
@use '../core/styles/common/tokens' as *;
24

35
@use './scrollbar-component-theme' as *;

0 commit comments

Comments
 (0)