@plumeria/eslint-plugin 19.11.0 → 19.12.1
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/bin/oxlint.js +2 -2
- package/dist/guard.d.ts +1 -0
- package/dist/guard.js +8 -7
- package/dist/rules/no-unknown-css-properties.js +2 -69
- package/dist/rules/validate-values.js +161 -49
- package/dist/util/colorData.d.ts +2 -1
- package/dist/util/colorData.js +4 -2
- package/dist/util/cssPropertyData.d.ts +2 -0
- package/dist/util/cssPropertyData.js +1092 -0
- package/dist/util/unitData.js +12 -0
- package/package.json +5 -5
package/bin/oxlint.js
CHANGED
|
@@ -12,7 +12,7 @@ const oxlintBin = path.join(
|
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
const { cliOverrides } = require('../dist/cli.js');
|
|
15
|
-
const { lintConfig, lowerPriority } = require('../dist/guard.js');
|
|
15
|
+
const { lintConfig, lintEnv, lowerPriority } = require('../dist/guard.js');
|
|
16
16
|
|
|
17
17
|
const doubleDashIndex = process.argv.indexOf('--');
|
|
18
18
|
let cliArgs = [];
|
|
@@ -45,7 +45,7 @@ async function startOxlint() {
|
|
|
45
45
|
: ['--threads=2']),
|
|
46
46
|
...rest,
|
|
47
47
|
],
|
|
48
|
-
{ stdio: 'inherit' },
|
|
48
|
+
{ stdio: 'inherit', env: lintEnv() },
|
|
49
49
|
);
|
|
50
50
|
lowerPriority(child.pid);
|
|
51
51
|
if (config !== oxlintConfig) {
|
package/dist/guard.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export interface LintOverrides {
|
|
|
17
17
|
export declare function lintOverrides(options: LintOptions): LintOverrides;
|
|
18
18
|
export declare function lintConfig(overrides: LintOverrides): string;
|
|
19
19
|
export declare function lowerPriority(pid: number | undefined): boolean;
|
|
20
|
+
export declare function lintEnv(): NodeJS.ProcessEnv;
|
|
20
21
|
export declare function startLintGuard(overrides?: LintOverrides): boolean;
|
|
21
22
|
export {};
|
package/dist/guard.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.lintOverrides = lintOverrides;
|
|
37
37
|
exports.lintConfig = lintConfig;
|
|
38
38
|
exports.lowerPriority = lowerPriority;
|
|
39
|
+
exports.lintEnv = lintEnv;
|
|
39
40
|
exports.startLintGuard = startLintGuard;
|
|
40
41
|
const child_process_1 = require("child_process");
|
|
41
42
|
const fs = __importStar(require("fs"));
|
|
@@ -84,6 +85,12 @@ function lowerPriority(pid) {
|
|
|
84
85
|
return false;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
88
|
+
function lintEnv() {
|
|
89
|
+
return {
|
|
90
|
+
NODE_COMPILE_CACHE: path.join(process.cwd(), 'node_modules', '.cache', 'plumeria-lint'),
|
|
91
|
+
...process.env,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
87
94
|
function startLintGuard(overrides = {}) {
|
|
88
95
|
if (process.env[GUARD_ENV])
|
|
89
96
|
return false;
|
|
@@ -96,13 +103,7 @@ function startLintGuard(overrides = {}) {
|
|
|
96
103
|
'--deny-warnings',
|
|
97
104
|
'--no-error-on-unmatched-pattern',
|
|
98
105
|
'--threads=2',
|
|
99
|
-
], {
|
|
100
|
-
stdio: 'inherit',
|
|
101
|
-
env: {
|
|
102
|
-
NODE_COMPILE_CACHE: path.join(process.cwd(), 'node_modules', '.cache', 'plumeria-lint'),
|
|
103
|
-
...process.env,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
+
], { stdio: 'inherit', env: lintEnv() });
|
|
106
107
|
lowerPriority(child.pid);
|
|
107
108
|
const exit = process.exit.bind(process);
|
|
108
109
|
let lintCode = null;
|
|
@@ -1,77 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noUnknownCssProperties = void 0;
|
|
4
|
-
const known_css_properties_1 = require("known-css-properties");
|
|
5
4
|
const zss_engine_1 = require("zss-engine");
|
|
6
5
|
const styleObject_1 = require("../util/styleObject");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
'border-shape',
|
|
10
|
-
'corner-shape',
|
|
11
|
-
'corner-top-shape',
|
|
12
|
-
'corner-right-shape',
|
|
13
|
-
'corner-bottom-shape',
|
|
14
|
-
'corner-left-shape',
|
|
15
|
-
'corner-top-left-shape',
|
|
16
|
-
'corner-top-right-shape',
|
|
17
|
-
'corner-bottom-left-shape',
|
|
18
|
-
'corner-bottom-right-shape',
|
|
19
|
-
'corner-block-start-shape',
|
|
20
|
-
'corner-block-end-shape',
|
|
21
|
-
'corner-inline-start-shape',
|
|
22
|
-
'corner-inline-end-shape',
|
|
23
|
-
'corner-start-start-shape',
|
|
24
|
-
'corner-start-end-shape',
|
|
25
|
-
'corner-end-start-shape',
|
|
26
|
-
'corner-end-end-shape',
|
|
27
|
-
'flex-line-count',
|
|
28
|
-
'flow-tolerance',
|
|
29
|
-
'interest-delay',
|
|
30
|
-
'interest-delay-start',
|
|
31
|
-
'interest-delay-end',
|
|
32
|
-
'rule-inset',
|
|
33
|
-
'rule-inset-start',
|
|
34
|
-
'rule-inset-end',
|
|
35
|
-
'rule-inset-cap',
|
|
36
|
-
'rule-inset-junction',
|
|
37
|
-
'rule-overlap',
|
|
38
|
-
'rule-visibility-items',
|
|
39
|
-
'column-rule-inset',
|
|
40
|
-
'column-rule-inset-start',
|
|
41
|
-
'column-rule-inset-end',
|
|
42
|
-
'column-rule-inset-cap',
|
|
43
|
-
'column-rule-inset-cap-start',
|
|
44
|
-
'column-rule-inset-cap-end',
|
|
45
|
-
'column-rule-inset-junction',
|
|
46
|
-
'column-rule-inset-junction-start',
|
|
47
|
-
'column-rule-inset-junction-end',
|
|
48
|
-
'column-rule-visibility-items',
|
|
49
|
-
'row-rule-inset',
|
|
50
|
-
'row-rule-inset-start',
|
|
51
|
-
'row-rule-inset-end',
|
|
52
|
-
'row-rule-inset-cap',
|
|
53
|
-
'row-rule-inset-cap-start',
|
|
54
|
-
'row-rule-inset-cap-end',
|
|
55
|
-
'row-rule-inset-junction',
|
|
56
|
-
'row-rule-inset-junction-start',
|
|
57
|
-
'row-rule-inset-junction-end',
|
|
58
|
-
'row-rule-visibility-items',
|
|
59
|
-
'scroll-axis-lock',
|
|
60
|
-
'text-decoration-inset',
|
|
61
|
-
'text-fit',
|
|
62
|
-
'timeline-trigger',
|
|
63
|
-
'timeline-trigger-name',
|
|
64
|
-
'timeline-trigger-source',
|
|
65
|
-
'timeline-trigger-activation-range',
|
|
66
|
-
'timeline-trigger-activation-range-start',
|
|
67
|
-
'timeline-trigger-activation-range-end',
|
|
68
|
-
'timeline-trigger-active-range',
|
|
69
|
-
'timeline-trigger-active-range-start',
|
|
70
|
-
'timeline-trigger-active-range-end',
|
|
71
|
-
'trigger-scope',
|
|
72
|
-
'view-transition-scope',
|
|
73
|
-
'window-drag',
|
|
74
|
-
]);
|
|
6
|
+
const cssPropertyData_1 = require("../util/cssPropertyData");
|
|
7
|
+
const knownProperties = new Set(cssPropertyData_1.cssPropertyData);
|
|
75
8
|
exports.noUnknownCssProperties = {
|
|
76
9
|
meta: {
|
|
77
10
|
type: 'problem',
|
|
@@ -224,16 +224,21 @@ const anchorSizeProperties = [
|
|
|
224
224
|
'minInlineSize',
|
|
225
225
|
'maxInlineSize',
|
|
226
226
|
];
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
const quotedString = `"[^"]*"|'[^']*'`;
|
|
228
|
+
const nestedContents = (depth) => depth === 0
|
|
229
|
+
? `(?:[^()"']|${quotedString})*`
|
|
230
|
+
: `(?:[^()"']|${quotedString}|\\(${nestedContents(depth - 1)}\\))*`;
|
|
231
|
+
const mathContentsString = nestedContents(3);
|
|
232
|
+
const fitContentString = `fit-content\\(${mathContentsString}\\)`;
|
|
233
|
+
const minString = `min\\(${mathContentsString}\\)`;
|
|
234
|
+
const maxString = `max\\(${mathContentsString}\\)`;
|
|
235
|
+
const minmaxString = `minmax\\(${mathContentsString}\\)`;
|
|
231
236
|
const dashedIdentString = '--[a-zA-Z_][a-zA-Z0-9_-]*';
|
|
232
237
|
const cssVariablePlaceholder = '\u0001';
|
|
233
238
|
const canonicalCssVariable = (index) => `var(--x${index})`;
|
|
234
239
|
const varString = `(?:var\\(${dashedIdentString}(,\\s*[^\\)]+)?\\)|${cssVariablePlaceholder})`;
|
|
235
240
|
const varRegex = new RegExp(`^(${varString})$`);
|
|
236
|
-
const pureNumber = `(
|
|
241
|
+
const pureNumber = `(-?(?:\\d+(?:\\.\\d+)?|\\.\\d+))`;
|
|
237
242
|
const numberPattern = `(${pureNumber}|${varString})`;
|
|
238
243
|
const percentagePattern = `${pureNumber}%`;
|
|
239
244
|
const pureInteger = `(-?\\d+)`;
|
|
@@ -241,13 +246,14 @@ const integerPattern = `(${pureInteger}|${varString})`;
|
|
|
241
246
|
const lengthPattern = `0|${pureNumber}(?:${unitData_1.unitData.join('|')})`;
|
|
242
247
|
const pureAngle = `${pureNumber}(deg|rad|grad|turn)`;
|
|
243
248
|
const anglePattern = `(${pureAngle}|${varString})`;
|
|
244
|
-
const calcString =
|
|
249
|
+
const calcString = `calc\\(${mathContentsString}\\)`;
|
|
245
250
|
const anchorString = 'anchor\\([^()]*\\)';
|
|
246
251
|
const anchorSizeString = 'anchor-size\\([^()]*\\)';
|
|
247
|
-
const clampString =
|
|
252
|
+
const clampString = `clamp\\(${mathContentsString}\\)`;
|
|
253
|
+
const steppedValueString = `(?:round|mod|rem)\\(${mathContentsString}\\)`;
|
|
254
|
+
const absString = `abs\\(${mathContentsString}\\)`;
|
|
248
255
|
const gradientString = '(?:repeating-)?(?:linear|radial|conic)-gradient\\(.*\\)';
|
|
249
256
|
const urlString = `url\\([^\\)${cssVariablePlaceholder}]+\\)`;
|
|
250
|
-
const imageSetString = 'image-set\\([^\\)]+\\)';
|
|
251
257
|
const attrString = 'attr\\([^\\)]+\\)';
|
|
252
258
|
const addString = `add\\(${integerPattern}\\)`;
|
|
253
259
|
const counterString = 'counter\\([^\\)]+\\)';
|
|
@@ -255,20 +261,122 @@ const countersString = 'counters\\([^\\)]+\\)';
|
|
|
255
261
|
const doubleQuoteString = '"[^"]*"';
|
|
256
262
|
const singleQuoteString = "'[^']*'";
|
|
257
263
|
const stringString = `(?:${doubleQuoteString}|${singleQuoteString})`;
|
|
258
|
-
const functionContentsString =
|
|
264
|
+
const functionContentsString = `(?=[^)]*[^\\s()])${mathContentsString}`;
|
|
259
265
|
const repeatString = `repeat\\(${functionContentsString}\\)`;
|
|
266
|
+
const imageSetString = `image-set\\(${functionContentsString}\\)`;
|
|
260
267
|
const colorSpaces = 'srgb|srgb-linear|display-p3|a98-rgb|prophoto-rgb|rec2020|lab|oklab|xyz|xyz-d50|xyz-d65|hsl|hwb|lch|oklch';
|
|
261
268
|
const hueModifiers = '(?:\\s+(?:shorter|longer|increasing|decreasing)\\s+hue)?';
|
|
262
269
|
const colorSpacePattern = `in\\s+(?:${colorSpaces})${hueModifiers}`;
|
|
263
270
|
const paletteMixString = `palette-mix\\(${colorSpacePattern},\\s*(?:(${dashedIdentString}|${varString}))(?:\\s+(${percentagePattern}|${varString}))?,\\s*(?:(${dashedIdentString}|${varString}))(?:\\s+(${percentagePattern}|${varString}))?\\)`;
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
271
|
+
const colorFunctionPlaceholder = '\u0002';
|
|
272
|
+
const relativeChannel = `(?:[a-z]+|${pureNumber}(?:%|deg|rad|grad|turn)?|${calcString}|${varString})`;
|
|
273
|
+
const relativeChannelsRegex = new RegExp(`^${relativeChannel}(?:\\s+${relativeChannel}){2}(?:\\s*/\\s*${relativeChannel})?$`);
|
|
274
|
+
const relativeColorSpaceRegex = new RegExp(`^(?:${colorData_1.colorSpaces}|${dashedIdentString})$`);
|
|
275
|
+
const colorInterpolationRegex = new RegExp(`^${colorSpacePattern}$`);
|
|
276
|
+
const mixPercentageRegex = new RegExp(`^(?:${percentagePattern}|${varString})$`);
|
|
277
|
+
const colorFunctionSource = '(?<![\\w-])(color-mix|light-dark|rgba?|hsla?|hwb|lab|oklab|lch|oklch|color)\\(';
|
|
278
|
+
const colorRegex = new RegExp(`^(${colorData_1.colorValue}|${varString}|${colorFunctionPlaceholder})$`);
|
|
268
279
|
const colorSource = colorRegex.source.slice(1, -1);
|
|
269
|
-
|
|
280
|
+
function findClosingParenthesis(value, open) {
|
|
281
|
+
let depth = 0;
|
|
282
|
+
let quote = '';
|
|
283
|
+
for (let index = open; index < value.length; index++) {
|
|
284
|
+
const char = value[index];
|
|
285
|
+
if (quote) {
|
|
286
|
+
if (char === quote)
|
|
287
|
+
quote = '';
|
|
288
|
+
}
|
|
289
|
+
else if (char === '"' || char === "'") {
|
|
290
|
+
quote = char;
|
|
291
|
+
}
|
|
292
|
+
else if (char === '(') {
|
|
293
|
+
depth++;
|
|
294
|
+
}
|
|
295
|
+
else if (char === ')') {
|
|
296
|
+
depth--;
|
|
297
|
+
if (depth === 0)
|
|
298
|
+
return index;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return -1;
|
|
302
|
+
}
|
|
303
|
+
function splitTopLevelCommas(value) {
|
|
304
|
+
const parts = [];
|
|
305
|
+
let depth = 0;
|
|
306
|
+
let start = 0;
|
|
307
|
+
for (let index = 0; index < value.length; index++) {
|
|
308
|
+
const char = value[index];
|
|
309
|
+
if (char === '(')
|
|
310
|
+
depth++;
|
|
311
|
+
else if (char === ')')
|
|
312
|
+
depth--;
|
|
313
|
+
else if (char === ',' && depth === 0) {
|
|
314
|
+
parts.push(value.slice(start, index).trim());
|
|
315
|
+
start = index + 1;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
parts.push(value.slice(start).trim());
|
|
319
|
+
return parts;
|
|
320
|
+
}
|
|
321
|
+
function isColor(value) {
|
|
322
|
+
return colorRegex.test(normalizeColorFunctions(value.trim()));
|
|
323
|
+
}
|
|
324
|
+
function isValidMixComponent(value) {
|
|
325
|
+
const parts = splitColorValues(value);
|
|
326
|
+
if (parts.length === 1)
|
|
327
|
+
return isColor(parts[0]);
|
|
328
|
+
if (parts.length !== 2)
|
|
329
|
+
return false;
|
|
330
|
+
if (mixPercentageRegex.test(parts[1]))
|
|
331
|
+
return isColor(parts[0]);
|
|
332
|
+
return mixPercentageRegex.test(parts[0]) && isColor(parts[1]);
|
|
333
|
+
}
|
|
334
|
+
function isValidColorFunction(name, args) {
|
|
335
|
+
if (name === 'color-mix') {
|
|
336
|
+
const parts = splitTopLevelCommas(args);
|
|
337
|
+
return (parts.length === 3 &&
|
|
338
|
+
colorInterpolationRegex.test(parts[0]) &&
|
|
339
|
+
isValidMixComponent(parts[1]) &&
|
|
340
|
+
isValidMixComponent(parts[2]));
|
|
341
|
+
}
|
|
342
|
+
if (name === 'light-dark') {
|
|
343
|
+
const parts = splitTopLevelCommas(args);
|
|
344
|
+
return parts.length === 2 && isColor(parts[0]) && isColor(parts[1]);
|
|
345
|
+
}
|
|
346
|
+
const tokens = splitColorValues(args.trim());
|
|
347
|
+
if (tokens[0] !== 'from' || tokens.length < 3 || !isColor(tokens[1])) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
const channels = tokens.slice(name === 'color' ? 3 : 2);
|
|
351
|
+
if (name === 'color' && !relativeColorSpaceRegex.test(tokens[2]))
|
|
352
|
+
return false;
|
|
353
|
+
return relativeChannelsRegex.test(channels.join(' '));
|
|
354
|
+
}
|
|
355
|
+
function normalizeColorFunctions(value) {
|
|
356
|
+
let normalized = '';
|
|
357
|
+
let cursor = 0;
|
|
358
|
+
const pattern = new RegExp(colorFunctionSource, 'g');
|
|
359
|
+
for (let match = pattern.exec(value); match; match = pattern.exec(value)) {
|
|
360
|
+
const name = match[1];
|
|
361
|
+
const open = match.index + name.length;
|
|
362
|
+
const close = findClosingParenthesis(value, open);
|
|
363
|
+
if (close === -1)
|
|
364
|
+
break;
|
|
365
|
+
const args = value.slice(open + 1, close);
|
|
366
|
+
const isComposite = name === 'color-mix' || name === 'light-dark' || /^\s*from\s/.test(args);
|
|
367
|
+
if (!isComposite)
|
|
368
|
+
continue;
|
|
369
|
+
if (isValidColorFunction(name, args)) {
|
|
370
|
+
normalized += value.slice(cursor, match.index) + colorFunctionPlaceholder;
|
|
371
|
+
cursor = close + 1;
|
|
372
|
+
}
|
|
373
|
+
pattern.lastIndex = close + 1;
|
|
374
|
+
}
|
|
375
|
+
return normalized + value.slice(cursor);
|
|
376
|
+
}
|
|
377
|
+
const imageRegex = new RegExp(`^(${gradientString}|${urlString}|${imageSetString})$`);
|
|
270
378
|
const urlRegex = new RegExp(`^(${urlString})$`);
|
|
271
|
-
const sliceValuePattern = '^(
|
|
379
|
+
const sliceValuePattern = '^(?:-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)%?|fill)(?:\\s+(?:-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)%?|fill)){0,3}$';
|
|
272
380
|
const sliceRegex = new RegExp(`^(${sliceValuePattern})$`);
|
|
273
381
|
const otherGroupProperties = [
|
|
274
382
|
'fontWeight',
|
|
@@ -625,15 +733,15 @@ function isValidMultipleColorValues(value) {
|
|
|
625
733
|
function splitColorValues(value) {
|
|
626
734
|
const colors = [];
|
|
627
735
|
const remaining = value.trim();
|
|
628
|
-
let
|
|
736
|
+
let depth = 0;
|
|
629
737
|
let currentColor = '';
|
|
630
738
|
for (let i = 0; i < remaining.length; i++) {
|
|
631
739
|
const char = remaining[i];
|
|
632
740
|
if (char === '(')
|
|
633
|
-
|
|
741
|
+
depth++;
|
|
634
742
|
else if (char === ')')
|
|
635
|
-
|
|
636
|
-
if (char === ' ' &&
|
|
743
|
+
depth--;
|
|
744
|
+
if (char === ' ' && depth === 0 && currentColor.length > 0) {
|
|
637
745
|
colors.push(currentColor.trim());
|
|
638
746
|
currentColor = '';
|
|
639
747
|
}
|
|
@@ -779,7 +887,7 @@ function getLengthValuePattern(key) {
|
|
|
779
887
|
(isBackgroundSize ? '|cover|contain' : '') +
|
|
780
888
|
(isAnchor ? `|${anchorString}` : '') +
|
|
781
889
|
(isAnchorSize ? `|${anchorSizeString}` : '') +
|
|
782
|
-
`|${calcString}|${clampString}|${minString}|${maxString}|${varString}`);
|
|
890
|
+
`|${calcString}|${clampString}|${minString}|${maxString}|${steppedValueString}|${absString}|${varString}`);
|
|
783
891
|
}
|
|
784
892
|
const validatorCache = new Map();
|
|
785
893
|
const foldedValueCache = new Map();
|
|
@@ -797,27 +905,27 @@ function getValidator(key) {
|
|
|
797
905
|
let validator = null;
|
|
798
906
|
const lvp = getLengthValuePattern(key);
|
|
799
907
|
const getTransformFunctions = () => [
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
908
|
+
`matrix\\(${mathContentsString}\\)`,
|
|
909
|
+
`matrix3d\\(${mathContentsString}\\)`,
|
|
910
|
+
`perspective\\(${mathContentsString}\\)`,
|
|
911
|
+
`rotate\\(${mathContentsString}\\)`,
|
|
912
|
+
`rotate3d\\(${mathContentsString}\\)`,
|
|
913
|
+
`rotateX\\(${mathContentsString}\\)`,
|
|
914
|
+
`rotateY\\(${mathContentsString}\\)`,
|
|
915
|
+
`rotateZ\\(${mathContentsString}\\)`,
|
|
916
|
+
`scale\\(${mathContentsString}\\)`,
|
|
917
|
+
`scale3d\\(${mathContentsString}\\)`,
|
|
918
|
+
`scaleX\\(${mathContentsString}\\)`,
|
|
919
|
+
`scaleY\\(${mathContentsString}\\)`,
|
|
920
|
+
`scaleZ\\(${mathContentsString}\\)`,
|
|
921
|
+
`skew\\(${mathContentsString}\\)`,
|
|
922
|
+
`skewX\\(${mathContentsString}\\)`,
|
|
923
|
+
`skewY\\(${mathContentsString}\\)`,
|
|
924
|
+
`translate\\(${mathContentsString}\\)`,
|
|
925
|
+
`translate3d\\(${mathContentsString}\\)`,
|
|
926
|
+
`translateX\\(${mathContentsString}\\)`,
|
|
927
|
+
`translateY\\(${mathContentsString}\\)`,
|
|
928
|
+
`translateZ\\(${mathContentsString}\\)`,
|
|
821
929
|
].join('|');
|
|
822
930
|
const getGeometryBaseSet = () => 'content-box|padding-box|border-box|fill-box|stroke-box|view-box';
|
|
823
931
|
if (['translate'].includes(key)) {
|
|
@@ -1479,7 +1587,7 @@ function getValidator(key) {
|
|
|
1479
1587
|
const cleanValue = value.replace(/\s+/g, ' ').trim();
|
|
1480
1588
|
if (!cleanValue)
|
|
1481
1589
|
return false;
|
|
1482
|
-
const parts = cleanValue
|
|
1590
|
+
const parts = splitColorValues(cleanValue);
|
|
1483
1591
|
if (parts.length > 3)
|
|
1484
1592
|
return false;
|
|
1485
1593
|
if (parts.length === 1)
|
|
@@ -1498,7 +1606,9 @@ function getValidator(key) {
|
|
|
1498
1606
|
validator = isValidCursor;
|
|
1499
1607
|
}
|
|
1500
1608
|
else if (['content'].includes(key)) {
|
|
1501
|
-
const
|
|
1609
|
+
const contentItem = `${urlString}|${gradientString}|${imageSetString}|${attrString}|${counterString}|${countersString}|${stringString}|open-quote|close-quote|no-open-quote|no-close-quote|${varString}`;
|
|
1610
|
+
const altItem = `${stringString}|${counterString}|${countersString}|${attrString}|${varString}`;
|
|
1611
|
+
const r = new RegExp(`^(?:${contentItem})(?:\\s*(?:${contentItem}))*(?:\\s*/\\s*(?:${altItem})(?:\\s*(?:${altItem}))*)?$`);
|
|
1502
1612
|
validator = (v) => r.test(v);
|
|
1503
1613
|
}
|
|
1504
1614
|
else if (['contain'].includes(key)) {
|
|
@@ -1522,7 +1632,7 @@ function getValidator(key) {
|
|
|
1522
1632
|
else if (['background'].includes(key)) {
|
|
1523
1633
|
const positionPattern = `(?:(?:top|bottom|center|left|right|${varString})(?:\\s+top|bottom|center|left|right|${varString})?)`;
|
|
1524
1634
|
const sizePattern = `(?:\\s*/\\s*(?:cover|contain|(${lvp})( (?!\\s)(${lvp})){0,2}?))?`;
|
|
1525
|
-
const flexibleLayerWithoutColor = `(?:(?:${positionPattern}${sizePattern})?|(?:${urlString}|${gradientString}|${varString}\\s*)?|(?:(?:repeat|space|round|no-repeat|repeatX|repeatY)\\s+)?|(?:scroll|fixed|local|${varString}\\s+)?|(?:border-box|padding-box|content-box|${varString}\\s+)?)`;
|
|
1635
|
+
const flexibleLayerWithoutColor = `(?:(?:${positionPattern}${sizePattern})?|(?:${urlString}|${gradientString}|${imageSetString}|${varString}\\s*)?|(?:(?:repeat|space|round|no-repeat|repeatX|repeatY)\\s+)?|(?:scroll|fixed|local|${varString}\\s+)?|(?:border-box|padding-box|content-box|${varString}\\s+)?)`;
|
|
1526
1636
|
const flexibleLayerWithColor = `(?:${flexibleLayerWithoutColor}\\s*)*(?:\\s*${colorSource})?`;
|
|
1527
1637
|
const r = new RegExp(`^(?!\\s)(?=\\S)${flexibleLayerWithColor}(?:\\s*,\\s*${flexibleLayerWithColor})*$`);
|
|
1528
1638
|
validator = (v) => r.test(v);
|
|
@@ -1555,7 +1665,7 @@ function getValidator(key) {
|
|
|
1555
1665
|
validator = (v) => r.test(v);
|
|
1556
1666
|
}
|
|
1557
1667
|
else if (['backgroundImage'].includes(key)) {
|
|
1558
|
-
const r = new RegExp(`^(${gradientString}|${urlString}|${varString}|none)(\\s*,\\s*(${gradientString}|${urlString}|${varString}|none))*$`);
|
|
1668
|
+
const r = new RegExp(`^(${gradientString}|${urlString}|${imageSetString}|${varString}|none)(\\s*,\\s*(${gradientString}|${urlString}|${imageSetString}|${varString}|none))*$`);
|
|
1559
1669
|
validator = (v) => r.test(v);
|
|
1560
1670
|
}
|
|
1561
1671
|
else if (['backgroundOrigin', 'backgroundClip'].includes(key)) {
|
|
@@ -1573,7 +1683,7 @@ function getValidator(key) {
|
|
|
1573
1683
|
}
|
|
1574
1684
|
else if (['backdropFilter', 'filter'].includes(key)) {
|
|
1575
1685
|
const filterNumPattern = `(?:brightness|contrast|grayscale|invert|opacity|sepia|saturate)\\(\\s*${numberPattern}%?\\s*\\)`;
|
|
1576
|
-
const blurPattern = `blur\\(\\s*(${lengthPattern}|${calcString}|${clampString}|${minString}|${maxString}|${varString})\\s*\\)`;
|
|
1686
|
+
const blurPattern = `blur\\(\\s*(${lengthPattern}|${calcString}|${clampString}|${minString}|${maxString}|${steppedValueString}|${absString}|${varString})\\s*\\)`;
|
|
1577
1687
|
const anglePatternFunc = `hue-rotate\\(\\s*${anglePattern}\\s*\\)`;
|
|
1578
1688
|
const dropShadowPattern = `drop-shadow\\(\\s*(?:${varString}|(?:${colorSource}|${lvp})(?:\\s+(?:${colorSource}|${lvp})){2,3})\\s*\\)`;
|
|
1579
1689
|
const r = new RegExp(`^((?:${filterNumPattern}|${blurPattern}|${anglePatternFunc}|${dropShadowPattern}|(?:${urlString}|${gradientString}|${varString}\\s*)?)\\s*)+$`);
|
|
@@ -1589,10 +1699,10 @@ function getValidator(key) {
|
|
|
1589
1699
|
'step-start',
|
|
1590
1700
|
'step-end',
|
|
1591
1701
|
].join('|');
|
|
1592
|
-
const zeroToOne = '(0
|
|
1702
|
+
const zeroToOne = '(0?\\.\\d+|0|1(\\.0+)?)';
|
|
1593
1703
|
const bezierProgressPattern = `(?:${zeroToOne}|${varString})`;
|
|
1594
1704
|
const cubicBezierPattern = `cubic-bezier\\(\\s*(?:${varString}|${bezierProgressPattern}\\s*,\\s*${numberPattern}\\s*,\\s*${bezierProgressPattern}\\s*,\\s*${numberPattern})\\s*\\)`;
|
|
1595
|
-
const stopLengthPattern = `(
|
|
1705
|
+
const stopLengthPattern = `(?:${percentagePattern}|${varString})`;
|
|
1596
1706
|
const linearStopPattern = `${numberPattern}(?:\\s+${stopLengthPattern}){0,2}`;
|
|
1597
1707
|
const linearPattern = `linear\\(\\s*(?:${varString}|${linearStopPattern}(?:\\s*,\\s*${linearStopPattern})*)\\s*\\)`;
|
|
1598
1708
|
const positiveIntegerPattern = '[1-9]\\d*';
|
|
@@ -1818,7 +1928,9 @@ exports.validateValues = {
|
|
|
1818
1928
|
if (!globalValue)
|
|
1819
1929
|
return;
|
|
1820
1930
|
const validator = getValidator(key);
|
|
1821
|
-
const accepts = (v) => !!validator &&
|
|
1931
|
+
const accepts = (v) => !!validator &&
|
|
1932
|
+
(validator(normalizeColorFunctions(v)) ||
|
|
1933
|
+
validator(normalizeColorFunctions(v.toLowerCase())));
|
|
1822
1934
|
if (validator && (!normalized || !accepts(normalized.value))) {
|
|
1823
1935
|
context.report({
|
|
1824
1936
|
node: property.value,
|
package/dist/util/colorData.d.ts
CHANGED
package/dist/util/colorData.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colorValue = void 0;
|
|
3
|
+
exports.colorSpaces = exports.colorValue = void 0;
|
|
4
4
|
const colorNames = [
|
|
5
5
|
'currentColor',
|
|
6
|
+
'currentcolor',
|
|
6
7
|
'transparent',
|
|
7
8
|
'aliceblue',
|
|
8
9
|
'antiquewhite',
|
|
@@ -153,7 +154,7 @@ const colorNames = [
|
|
|
153
154
|
'yellow',
|
|
154
155
|
'yellowgreen',
|
|
155
156
|
].join('|');
|
|
156
|
-
const numberPattern = '
|
|
157
|
+
const numberPattern = '-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)%?';
|
|
157
158
|
const percentagePattern = `${numberPattern}%`;
|
|
158
159
|
const angleUnit = '(?:deg|grad|rad|turn)?';
|
|
159
160
|
const anglePattern = `${numberPattern}${angleUnit}`;
|
|
@@ -180,6 +181,7 @@ const lchParameters = `\\(\\s*${percentagePattern}(?:\\s+${numberPattern}){2}${a
|
|
|
180
181
|
const lchPattern = `${lchFunctionName}${lchParameters}`;
|
|
181
182
|
const colorFunctionName = 'color';
|
|
182
183
|
const colorSpaces = '(?:srgb|srgb-linear|display-p3|a98-rgb|prophoto-rgb|rec2020|rec2100-pq|rec2100-hlg|rec2100-linear|jzazbz|ictcp|xyz|xyz-d50|xyz-d65)';
|
|
184
|
+
exports.colorSpaces = colorSpaces;
|
|
183
185
|
const colorParameters = `\\(\\s*${colorSpaces}(?:${separator}${numberPattern}){3}${alphaPattern}\\s*\\)`;
|
|
184
186
|
const colorFunctionPattern = `${colorFunctionName}${colorParameters}`;
|
|
185
187
|
const colorValue = `(?:${hexPattern}|${rgbPattern}|${hslPattern}|${hwbPattern}|${labPattern}|${lchPattern}|${colorFunctionPattern}|${colorNames})`;
|