Skip to content

Commit 22992bb

Browse files
committed
feat: add lightness-notation rule
1 parent 5c80fb7 commit 22992bb

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"conventional-changelog-cli": "^4.1.0",
6666
"eslint": "^8.56.0",
6767
"stylelint": "^16.2.1",
68-
"stylelint-define-config": "file:.",
6968
"tsup": "^8.0.2",
7069
"typescript": "^5.3.3"
7170
}

src/rules/stylelint/index.d.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ import type { UnitDisallowedListOptions } from './unit-disallowed-list'
123123
import type { UnitNoUnknownOptions } from './unit-no-unknown'
124124
import type { ValueKeywordCaseOptions } from './value-keyword-case'
125125
import type { ValueNoVendorPrefixOptions } from './value-no-vendor-prefix'
126+
import type { LightnessNotationOptions } from './lightness-notation'
126127

127128
/**
128129
* Rules determine what the linter looks for and complains about.
@@ -1386,6 +1387,28 @@ export interface StyleLintRules {
13861387
*/
13871388
'length-zero-no-unit': LengthZeroNoUnitOptions
13881389

1390+
/**
1391+
* Specify number or percentage notation for lightness.
1392+
*
1393+
* ```scss
1394+
* a { color: oklch(85% 0.17 88) }
1395+
* // ^^^
1396+
* // This notation
1397+
* ```
1398+
*
1399+
* This rule supports `oklch`, `oklab`, `lch` and `lab` functions.
1400+
*
1401+
* ### Primary Options
1402+
*
1403+
* string: `"percentage"|"number"`
1404+
*
1405+
* - `"percentage"`: Lightness must always use the percentage notation.
1406+
* - `"number"`: Lightness must always use the number notation.
1407+
*
1408+
* @see [lightness-notation](https://stylelint.io/user-guide/rules/lightness-notation)
1409+
*/
1410+
'lightness-notation': LightnessNotationOptions
1411+
13891412
/**
13901413
* Limit the depth of nesting.
13911414
*
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 LightnessNotationOptions = RuleConfig<
4+
'percentage' | 'number',
5+
{
6+
message?: string | ((unfixed: string, fixed: string) => string)
7+
}
8+
>

0 commit comments

Comments
 (0)