stylelint-gamut 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/package.json +5 -1
- package/.eslintrc.js +0 -15
- package/.github/workflows/test.yml +0 -30
- package/jest.config.js +0 -7
- package/jest.setup.js +0 -5
- package/src/README.md +0 -88
- package/src/index.test.js +0 -129
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# stylelint-gamut
|
|
2
2
|
|
|
3
|
+
[![npm version][npm-version-img]][npm] [![npm downloads last month][npm-downloads-img]][npm]
|
|
4
|
+
|
|
3
5
|
**stylelint-gamut** is a [Stylelint] plugin that helps you to work with different color spaces.
|
|
4
6
|
|
|
5
7
|
Right now it's working with **node version ≥ 16.0.0**.
|
|
@@ -38,3 +40,6 @@ Add `stylelint-gamut` to your Stylelint config `plugins` array, then add rules y
|
|
|
38
40
|
* [`color-no-out-gamut-range`](./src/README.md): Throw warning if color goes out of sRGB color space and is not wrapped in `@media (color-gamut: p3) {}`.
|
|
39
41
|
|
|
40
42
|
[Stylelint]: https://stylelint.io/
|
|
43
|
+
[npm-version-img]: https://img.shields.io/npm/v/stylelint-gamut.svg
|
|
44
|
+
[npm-downloads-img]: https://img.shields.io/npm/dm/stylelint-gamut.svg
|
|
45
|
+
[npm]: https://www.npmjs.com/package/stylelint-gamut
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-gamut",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Stylelint plugin for working with different color spaces",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/fpetrakov/stylelint-gamut.git"
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src/**/*.js",
|
|
18
|
+
"!**/**/*.test.js"
|
|
19
|
+
],
|
|
16
20
|
"keywords": [
|
|
17
21
|
"stylelint",
|
|
18
22
|
"stylelint-plugin",
|
package/.eslintrc.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
pull_request:
|
|
7
|
-
env:
|
|
8
|
-
FORCE_COLOR: 2
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
strategy:
|
|
13
|
-
matrix:
|
|
14
|
-
node-version:
|
|
15
|
-
- 18
|
|
16
|
-
- 16
|
|
17
|
-
name: Node.js Latest Full
|
|
18
|
-
runs-on: ubuntu-latest
|
|
19
|
-
steps:
|
|
20
|
-
- name: Checkout the repository
|
|
21
|
-
uses: actions/checkout@v3
|
|
22
|
-
- name: Install Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@v3
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
cache: npm
|
|
27
|
-
- name: Install dependencies
|
|
28
|
-
run: npm install --ignore-scripts
|
|
29
|
-
- name: Run tests
|
|
30
|
-
run: npm test
|
package/jest.config.js
DELETED
package/jest.setup.js
DELETED
package/src/README.md
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# color-no-out-gamut-range
|
|
2
|
-
|
|
3
|
-
Disallow out of gamut range colors.
|
|
4
|
-
|
|
5
|
-
<!-- prettier-ignore -->
|
|
6
|
-
```css
|
|
7
|
-
a { color: lch(48% 82 283) }
|
|
8
|
-
/** ↑
|
|
9
|
-
* This color is out of sRGB gamut range */
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Colors declared using lch, oklch, lab and oklab functions can move from sRGB to P3 color space, which is not supported by most of screens right now. It can happen by mistake. For instance, by converting colors from one space to another.
|
|
13
|
-
|
|
14
|
-
This rule checks if the color is in sRGB space. If it's not, you should wrap it in media query like this:
|
|
15
|
-
|
|
16
|
-
```css
|
|
17
|
-
@media (color-gamut: p3) {
|
|
18
|
-
a {
|
|
19
|
-
color: lch(48% 82 283);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Please note that conditional imports are not checked, e.g.:
|
|
25
|
-
|
|
26
|
-
```html
|
|
27
|
-
<link href="p3-custom-props.css" rel="stylesheet" media="(color-gamut: p3)" />
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```css
|
|
31
|
-
@import url("p3-custom-props.css") (color-gamut: p3);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Options
|
|
35
|
-
|
|
36
|
-
### `true`
|
|
37
|
-
|
|
38
|
-
The following patterns are considered problems:
|
|
39
|
-
|
|
40
|
-
<!-- prettier-ignore -->
|
|
41
|
-
```css
|
|
42
|
-
a { color: lch(48% 82 283) }
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
<!-- prettier-ignore -->
|
|
46
|
-
```css
|
|
47
|
-
a { color: oklch(48% 82 283) }
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
<!-- prettier-ignore -->
|
|
51
|
-
```css
|
|
52
|
-
a { color: lab(48% 82 283) }
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
<!-- prettier-ignore -->
|
|
56
|
-
```css
|
|
57
|
-
a { color: oklab(48% 82 283) }
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
The following patterns are _not_ considered problems:
|
|
61
|
-
|
|
62
|
-
<!-- prettier-ignore -->
|
|
63
|
-
```css
|
|
64
|
-
@media (color-gamut: p3) {
|
|
65
|
-
a { color: lch(48% 82 283) }
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
<!-- prettier-ignore -->
|
|
70
|
-
```css
|
|
71
|
-
@media (color-gamut: p3) {
|
|
72
|
-
a { color: oklch(48% 82 283) }
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
<!-- prettier-ignore -->
|
|
77
|
-
```css
|
|
78
|
-
@media (color-gamut: p3) {
|
|
79
|
-
a { color: lab(48% 82 283) }
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
<!-- prettier-ignore -->
|
|
84
|
-
```css
|
|
85
|
-
@media (color-gamut: p3) {
|
|
86
|
-
a { color: oklab(48% 82 283) }
|
|
87
|
-
}
|
|
88
|
-
```
|
package/src/index.test.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { rule: { messages, ruleName } } = require('./index.js')
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line no-undef
|
|
6
|
-
testRule({
|
|
7
|
-
ruleName,
|
|
8
|
-
config: [true],
|
|
9
|
-
plugins: ['./index.js'],
|
|
10
|
-
accept: [
|
|
11
|
-
{
|
|
12
|
-
code: '@media (color-gamut:p3) { a { color: lch(48% 82 283); } }',
|
|
13
|
-
description: 'lch out of srgb gamut but wrapped in media query'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
code: '@media (prefers-color-scheme: dark) and (color-gamut: p3) { a { color: lch(48% 82 283); } }',
|
|
17
|
-
description: 'lch out of srgb gamut but wrapped in a long media query'
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
code: '@media (color-gamut: p3) { a { color: oklch(85% 0.1 354 / 73%); } }',
|
|
21
|
-
description:
|
|
22
|
-
'oklch with alpha out of srgb gamut but wrapped in media query'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
code: 'a { color: lch(50% 0 0); }',
|
|
26
|
-
description: 'in srgb gamut'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
code: '.foo { border: 4px solid oklch(100% 0 0); }',
|
|
30
|
-
description: 'in srgb gamut long property'
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
code: '.foo {background-image: linear-gradient(red lch(50% 0 0 )); }',
|
|
34
|
-
description: 'multicolor property in gamut range'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
code: 'a { color: red; }',
|
|
38
|
-
description: 'ignore not lch color declaration'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
code: ':root { --clr: lch(48% 82 283 / 75%) } a { color: var(--clr) }',
|
|
42
|
-
description: 'ignore css variables'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
code: '@myVariable: lch(48% 82 283); a { color: @myVariable; }',
|
|
46
|
-
description: 'ignore Less variable'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
code: ':root { $clr: lch(48% 82 283 / 67%) } a { color: $clr; }',
|
|
50
|
-
description: 'ignore scss variables'
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
|
|
54
|
-
reject: [
|
|
55
|
-
{
|
|
56
|
-
code: 'a { color: lch(48% 82 283); }',
|
|
57
|
-
description: 'lch',
|
|
58
|
-
message: messages.rejected('lch(48% 82 283)'),
|
|
59
|
-
line: 1,
|
|
60
|
-
column: 12,
|
|
61
|
-
endLine: 1,
|
|
62
|
-
endColumn: 27
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
code: '@media (prefers-color-scheme: dark) and (color-gamut: srgb) { a { color: lch(48% 82 283); } }',
|
|
66
|
-
description: 'lch out of srgb gamut and wrapped in a long and wrong media query',
|
|
67
|
-
message: messages.rejected('lch(48% 82 283)'),
|
|
68
|
-
line: 1,
|
|
69
|
-
column: 74,
|
|
70
|
-
endLine: 1,
|
|
71
|
-
endColumn: 89
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
code: '.foo { background: content-box oklch(82.6% 0.087 262.26); }',
|
|
75
|
-
description: 'out of srgb gamut long property',
|
|
76
|
-
message: messages.rejected('oklch(82.6% 0.087 262.26)'),
|
|
77
|
-
line: 1,
|
|
78
|
-
column: 20,
|
|
79
|
-
endLine: 1,
|
|
80
|
-
endColumn: 57
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
code: 'a { color: lch(48% 82 283 / 72%); }',
|
|
84
|
-
description: 'lch with alpha',
|
|
85
|
-
message: messages.rejected('lch(48% 82 283 / 72%)'),
|
|
86
|
-
line: 1,
|
|
87
|
-
column: 12,
|
|
88
|
-
endLine: 1,
|
|
89
|
-
endColumn: 33
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
code: '.foo {background-image: linear-gradient(red lch(48% 82 283)); }',
|
|
93
|
-
description: 'multicolor property out of gamut range',
|
|
94
|
-
message: messages.rejected('lch(48% 82 283)'),
|
|
95
|
-
line: 1,
|
|
96
|
-
column: 25,
|
|
97
|
-
endLine: 1,
|
|
98
|
-
endColumn: 61
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
code: 'a { color: oklch(85% 0.1 354 / 73%); }',
|
|
102
|
-
description: 'oklch',
|
|
103
|
-
message: messages.rejected('oklch(85% 0.1 354 / 73%)'),
|
|
104
|
-
line: 1,
|
|
105
|
-
column: 12,
|
|
106
|
-
endLine: 1,
|
|
107
|
-
endColumn: 36
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
code: 'a { color: lab(98% 49 129); }',
|
|
112
|
-
description: 'lab',
|
|
113
|
-
message: messages.rejected('lab(98% 49 129)'),
|
|
114
|
-
line: 1,
|
|
115
|
-
column: 12,
|
|
116
|
-
endLine: 1,
|
|
117
|
-
endColumn: 27
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
code: 'a { color: oklab(98% 49 129); }',
|
|
121
|
-
description: 'oklab',
|
|
122
|
-
message: messages.rejected('oklab(98% 49 129)'),
|
|
123
|
-
line: 1,
|
|
124
|
-
column: 12,
|
|
125
|
-
endLine: 1,
|
|
126
|
-
endColumn: 29
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
})
|