Skip to content

Commit c3bdb5d

Browse files
committed
feat: add nesting-selector-no-missing-scoping-root rule
1 parent ab2ca61 commit c3bdb5d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/rules/stylelint/index.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import type { MediaFeatureRangeNotationOptions } from './media-feature-range-not
7878
import type { MediaQueryNoInvalidOptions } from './media-query-no-invalid'
7979
import type { MediaTypeNoDeprecatedOptions } from './media-type-no-deprecated'
8080
import type { NamedGridAreasNoInvalidOptions } from './named-grid-areas-no-invalid'
81+
import type { NestingSelectorNoMissingScopingRootOptions } from './nesting-selector-no-missing-scoping-root'
8182
import type { NoDescendingSpecificityOptions } from './no-descending-specificity'
8283
import type { NoDuplicateAtImportRulesOptions } from './no-duplicate-at-import-rules'
8384
import type { NoDuplicateSelectorsOptions } from './no-duplicate-selectors'
@@ -1845,6 +1846,23 @@ export interface StyleLintRules {
18451846
*/
18461847
'named-grid-areas-no-invalid': NamedGridAreasNoInvalidOptions
18471848

1849+
/**
1850+
* Disallow missing scoping root for nesting selectors.
1851+
*
1852+
* ```scss
1853+
* & {}
1854+
* // ^
1855+
* // This nesting selector
1856+
* ```
1857+
*
1858+
* CSS nesting selectors (`&`) represent the parent selector in nested CSS.
1859+
* When used at the top level or within certain at-rules without a scoping root,
1860+
* they can cause unexpected behavior or indicate a mistake in the CSS structure.
1861+
*
1862+
* @see [nesting-selector-no-missing-scoping-root](https://stylelint.io/user-guide/rules/nesting-selector-no-missing-scoping-root)
1863+
*/
1864+
'nesting-selector-no-missing-scoping-root': NestingSelectorNoMissingScopingRootOptions
1865+
18481866
/**
18491867
* Disallow selectors of lower specificity from coming after overriding selectors of higher specificity.
18501868
*
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { RuleConfig } from '../rule-config'
2+
3+
export type NestingSelectorNoMissingScopingRootOptions = RuleConfig<true, {
4+
/**
5+
* Ignore nesting selectors within specified at-rules.
6+
*/
7+
ignoreAtRules?: (string | RegExp)[]
8+
}>

0 commit comments

Comments
 (0)