Skip to content

Commit ef8984d

Browse files
committed
feat: add layer-name-pattern rule
1 parent 21e7ba3 commit ef8984d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/rules/stylelint/index.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import type { KeyframeBlockNoDuplicateSelectorsOptions } from './keyframe-block-
6060
import type { KeyframeDeclarationNoImportantOptions } from './keyframe-declaration-no-important'
6161
import type { KeyframeSelectorNotationOptions } from './keyframe-selector-notation'
6262
import type { KeyframesNamePatternOptions } from './keyframes-name-pattern'
63+
import type { LayerNamePatternOptions } from './layer-name-pattern'
6364
import type { LengthZeroNoUnitOptions } from './length-zero-no-unit'
6465
import type { LightnessNotationOptions } from './lightness-notation'
6566
import type { MaxNestingDepthOptions } from './max-nesting-depth'
@@ -1457,6 +1458,26 @@ export interface StyleLintRules {
14571458
*/
14581459
'keyframes-name-pattern': KeyframesNamePatternOptions
14591460

1461+
/**
1462+
* Specify a pattern for layer names.
1463+
*
1464+
* >```scss
1465+
* >@layer foo {}
1466+
* >// ^^^
1467+
* >// This layer name
1468+
* >```
1469+
*
1470+
* ### Primary Options
1471+
* `string | RegExp`
1472+
*
1473+
* A string will be translated into a RegExp like so new RegExp(yourString) — so be sure to escape properly.
1474+
*
1475+
* Given the string: `"^[a-z][a-z0-9.-]*$"`
1476+
*
1477+
* @see [layer-name-pattern](https://stylelint.io/user-guide/rules/layer-name-pattern)
1478+
*/
1479+
'layer-name-pattern': LayerNamePatternOptions
1480+
14601481
/**
14611482
* Disallow units for zero lengths.
14621483
*
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { RuleConfig } from '../rule-config'
2+
3+
export type LayerNamePatternOptions = RuleConfig<string | RegExp>

0 commit comments

Comments
 (0)