@salesforce-ux/eslint-plugin-slds 0.5.2 → 1.0.0-internal-alpha.0
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/build/index.js +2309 -50
- package/build/index.js.map +4 -4
- package/build/rules/enforce-bem-usage.js +325 -85
- package/build/rules/enforce-bem-usage.js.map +4 -4
- package/build/rules/modal-close-button-issue.js +324 -179
- package/build/rules/modal-close-button-issue.js.map +4 -4
- package/build/rules/no-deprecated-classes-slds2.js +247 -53
- package/build/rules/no-deprecated-classes-slds2.js.map +4 -4
- package/build/rules/v9/enforce-bem-usage.js +236 -0
- package/build/rules/v9/enforce-bem-usage.js.map +7 -0
- package/build/rules/v9/enforce-component-hook-naming-convention.js +262 -0
- package/build/rules/v9/enforce-component-hook-naming-convention.js.map +7 -0
- package/build/rules/v9/enforce-sds-to-slds-hooks.js +260 -0
- package/build/rules/v9/enforce-sds-to-slds-hooks.js.map +7 -0
- package/build/rules/v9/lwc-token-to-slds-hook.js +330 -0
- package/build/rules/v9/lwc-token-to-slds-hook.js.map +7 -0
- package/build/rules/v9/no-deprecated-slds-classes.js +227 -0
- package/build/rules/v9/no-deprecated-slds-classes.js.map +7 -0
- package/build/rules/v9/no-deprecated-tokens-slds1.js +270 -0
- package/build/rules/v9/no-deprecated-tokens-slds1.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js +339 -0
- package/build/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js +348 -0
- package/build/rules/v9/no-hardcoded-values/handlers/colorHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js +344 -0
- package/build/rules/v9/no-hardcoded-values/handlers/densityHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js +388 -0
- package/build/rules/v9/no-hardcoded-values/handlers/fontHandler.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/handlers/index.js +834 -0
- package/build/rules/v9/no-hardcoded-values/handlers/index.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js +1112 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js +1112 -0
- package/build/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.js.map +7 -0
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js +945 -0
- package/build/rules/v9/no-hardcoded-values/noHardcodedValueRule.js.map +7 -0
- package/build/rules/v9/no-slds-class-overrides.js +233 -0
- package/build/rules/v9/no-slds-class-overrides.js.map +7 -0
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js +250 -0
- package/build/rules/v9/no-slds-namespace-for-custom-hooks.js.map +7 -0
- package/build/rules/v9/no-slds-private-var.js +230 -0
- package/build/rules/v9/no-slds-private-var.js.map +7 -0
- package/build/rules/v9/no-slds-var-without-fallback.js +253 -0
- package/build/rules/v9/no-slds-var-without-fallback.js.map +7 -0
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js +253 -0
- package/build/rules/v9/no-sldshook-fallback-for-lwctoken.js.map +7 -0
- package/build/rules/v9/no-unsupported-hooks-slds2.js +243 -0
- package/build/rules/v9/no-unsupported-hooks-slds2.js.map +7 -0
- package/build/rules/v9/reduce-annotations.js +234 -0
- package/build/rules/v9/reduce-annotations.js.map +7 -0
- package/build/src/rules/enforce-bem-usage.d.ts +17 -0
- package/build/{rules → src/rules}/modal-close-button-issue.d.ts +2 -1
- package/build/{rules → src/rules}/no-deprecated-classes-slds2.d.ts +2 -1
- package/build/src/rules/v9/enforce-bem-usage.d.ts +3 -0
- package/build/src/rules/v9/enforce-component-hook-naming-convention.d.ts +3 -0
- package/build/src/rules/v9/enforce-sds-to-slds-hooks.d.ts +3 -0
- package/build/src/rules/v9/lwc-token-to-slds-hook.d.ts +3 -0
- package/build/src/rules/v9/no-deprecated-slds-classes.d.ts +3 -0
- package/build/src/rules/v9/no-deprecated-tokens-slds1.d.ts +3 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/boxShadowHandler.d.ts +5 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/colorHandler.d.ts +7 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/densityHandler.d.ts +7 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/fontHandler.d.ts +6 -0
- package/build/src/rules/v9/no-hardcoded-values/handlers/index.d.ts +8 -0
- package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds1.d.ts +3 -0
- package/build/src/rules/v9/no-hardcoded-values/no-hardcoded-values-slds2.d.ts +3 -0
- package/build/src/rules/v9/no-hardcoded-values/noHardcodedValueRule.d.ts +9 -0
- package/build/src/rules/v9/no-slds-class-overrides.d.ts +8 -0
- package/build/src/rules/v9/no-slds-namespace-for-custom-hooks.d.ts +3 -0
- package/build/src/rules/v9/no-slds-private-var.d.ts +3 -0
- package/build/src/rules/v9/no-slds-var-without-fallback.d.ts +3 -0
- package/build/src/rules/v9/no-sldshook-fallback-for-lwctoken.d.ts +3 -0
- package/build/src/rules/v9/no-unsupported-hooks-slds2.d.ts +3 -0
- package/build/src/rules/v9/reduce-annotations.d.ts +3 -0
- package/build/src/types/index.d.ts +26 -0
- package/build/src/utils/boxShadowValueParser.d.ts +17 -0
- package/build/src/utils/color-lib-utils.d.ts +18 -0
- package/build/src/utils/css-functions.d.ts +7 -0
- package/build/src/utils/css-utils.d.ts +7 -0
- package/build/src/utils/hardcoded-shared-utils.d.ts +60 -0
- package/build/src/utils/property-matcher.d.ts +23 -0
- package/build/src/utils/styling-hook-utils.d.ts +7 -0
- package/build/src/utils/value-utils.d.ts +40 -0
- package/build/types/index.js +18 -0
- package/build/types/index.js.map +7 -0
- package/build/types/yaml.d.js +1 -0
- package/build/types/yaml.d.js.map +7 -0
- package/build/utils/boxShadowValueParser.js +197 -0
- package/build/utils/boxShadowValueParser.js.map +7 -0
- package/build/utils/color-lib-utils.js +160 -0
- package/build/utils/color-lib-utils.js.map +7 -0
- package/build/utils/css-functions.js +68 -0
- package/build/utils/css-functions.js.map +7 -0
- package/build/utils/css-utils.js +33 -0
- package/build/utils/css-utils.js.map +7 -0
- package/build/utils/hardcoded-shared-utils.js +300 -0
- package/build/utils/hardcoded-shared-utils.js.map +7 -0
- package/build/utils/node.js +158 -0
- package/build/{rules/utils → utils}/node.js.map +2 -2
- package/build/utils/property-matcher.js +159 -0
- package/build/utils/property-matcher.js.map +7 -0
- package/build/utils/styling-hook-utils.js +80 -0
- package/build/utils/styling-hook-utils.js.map +7 -0
- package/build/utils/value-utils.js +65 -0
- package/build/utils/value-utils.js.map +7 -0
- package/package.json +9 -4
- package/src/config/rule-messages.yml +143 -0
- package/build/rules/enforce-bem-usage.d.ts +0 -28
- package/build/rules/utils/node.js +0 -197
- package/build/rules/utils/rule.d.ts +0 -7
- package/build/rules/utils/rule.js +0 -10
- package/build/rules/utils/rule.js.map +0 -7
- /package/build/{index.d.ts → src/index.d.ts} +0 -0
- /package/build/{rules → src}/utils/node.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeclarationHandler } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Handle color declarations using CSS tree parsing
|
|
4
|
+
* Supports shorthand properties like background, border, etc.
|
|
5
|
+
* Uses css-tree for reliable AST-based parsing + chroma-js validation
|
|
6
|
+
*/
|
|
7
|
+
export declare const handleColorDeclaration: DeclarationHandler;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeclarationHandler } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Handle density/sizing declarations using CSS tree parsing
|
|
4
|
+
* Supports shorthand properties like padding, margin, etc.
|
|
5
|
+
* Uses css-tree for reliable AST-based parsing
|
|
6
|
+
*/
|
|
7
|
+
export declare const handleDensityDeclaration: DeclarationHandler;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized export for core handlers
|
|
3
|
+
* Comprehensive implementation covering color, density, font, and box-shadow cases
|
|
4
|
+
*/
|
|
5
|
+
export { handleColorDeclaration } from './colorHandler';
|
|
6
|
+
export { handleDensityDeclaration } from './densityHandler';
|
|
7
|
+
export { handleFontDeclaration } from './fontHandler';
|
|
8
|
+
export { handleBoxShadowDeclaration } from './boxShadowHandler';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import type { RuleConfig } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the shared no-hardcoded-value rule implementation for ESLint v9
|
|
5
|
+
* Supports color, density, and font properties including font shorthand
|
|
6
|
+
* Uses property-matcher.ts to ensure comprehensive coverage without missing properties
|
|
7
|
+
* Complex cases like box-shadow will be handled in future iterations
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineNoHardcodedValueRule(config: RuleConfig): Rule.RuleModule;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Rule to disallow overriding SLDS CSS classes
|
|
3
|
+
* Compatible with @eslint/css parser for ESLint v9
|
|
4
|
+
* Maintains full parity with stylelint version behavior
|
|
5
|
+
*/
|
|
6
|
+
import { Rule } from 'eslint';
|
|
7
|
+
declare const _default: Rule.RuleModule;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import type { ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata';
|
|
3
|
+
/**
|
|
4
|
+
* Context interface for handlers to access necessary dependencies
|
|
5
|
+
*/
|
|
6
|
+
export interface HandlerContext {
|
|
7
|
+
valueToStylinghook: ValueToStylingHooksMapping;
|
|
8
|
+
context: Rule.RuleContext;
|
|
9
|
+
sourceCode: any;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for creating the rule
|
|
13
|
+
*/
|
|
14
|
+
export interface RuleConfig {
|
|
15
|
+
ruleConfig: {
|
|
16
|
+
type: 'problem' | 'suggestion' | 'layout';
|
|
17
|
+
description: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
messages: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
valueToStylinghook: ValueToStylingHooksMapping;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Handler function signature for CSS declarations
|
|
25
|
+
*/
|
|
26
|
+
export type DeclarationHandler = (node: any, context: HandlerContext) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface BoxShadowValue {
|
|
2
|
+
offsetX?: string;
|
|
3
|
+
offsetY?: string;
|
|
4
|
+
blurRadius?: string;
|
|
5
|
+
spreadRadius?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
inset?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parse box-shadow value into structured format
|
|
11
|
+
* Simplified version for ESLint v9 compatibility
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseBoxShadowValue(value: string): BoxShadowValue[];
|
|
14
|
+
/**
|
|
15
|
+
* Check if two parsed box-shadow values match
|
|
16
|
+
*/
|
|
17
|
+
export declare function isBoxShadowMatch(parsedCssValue: BoxShadowValue[], parsedValueHook: BoxShadowValue[]): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata';
|
|
2
|
+
declare const isHardCodedColor: (color: string) => boolean;
|
|
3
|
+
declare const isHexCode: (color: string) => boolean;
|
|
4
|
+
declare const convertToHex: (color: string) => string | null;
|
|
5
|
+
declare const findClosestColorHook: (color: string, supportedColors: ValueToStylingHooksMapping, cssProperty: string) => string[];
|
|
6
|
+
/**
|
|
7
|
+
* This method is usefull to identify all possible css color values.
|
|
8
|
+
* - names colors
|
|
9
|
+
* - 6,8 digit hex
|
|
10
|
+
* - rgb and rgba
|
|
11
|
+
* - hsl and hsla
|
|
12
|
+
*/
|
|
13
|
+
declare const isValidColor: (val: string) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Extract color value from CSS AST node
|
|
16
|
+
*/
|
|
17
|
+
declare const extractColorValue: (node: any) => string | null;
|
|
18
|
+
export { findClosestColorHook, convertToHex, isHexCode, isHardCodedColor, isValidColor, extractColorValue };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function containsCssFunction(value: string): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is exactly a CSS function name
|
|
4
|
+
*/
|
|
5
|
+
export declare function isCssFunction(value: string): boolean;
|
|
6
|
+
export declare function isCssMathFunction(value: string): boolean;
|
|
7
|
+
export declare function isCssColorFunction(value: string): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a CSS property should be targeted for linting based on prefixes or explicit targets
|
|
3
|
+
* @param property - The CSS property name to check
|
|
4
|
+
* @param propertyTargets - Array of specific properties to target (empty means target all)
|
|
5
|
+
* @returns true if the property should be targeted
|
|
6
|
+
*/
|
|
7
|
+
export declare function isTargetProperty(property: string, propertyTargets?: string[]): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { HandlerContext } from '../types';
|
|
2
|
+
import type { ParsedUnitValue } from './value-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Common replacement data structure used by both color and density handlers
|
|
5
|
+
*/
|
|
6
|
+
export interface ReplacementInfo {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
replacement: string;
|
|
10
|
+
displayValue: string;
|
|
11
|
+
hasHook: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Position information from CSS tree parsing
|
|
15
|
+
*/
|
|
16
|
+
export interface PositionInfo {
|
|
17
|
+
start?: {
|
|
18
|
+
offset: number;
|
|
19
|
+
line: number;
|
|
20
|
+
column: number;
|
|
21
|
+
};
|
|
22
|
+
end?: {
|
|
23
|
+
offset: number;
|
|
24
|
+
line: number;
|
|
25
|
+
column: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generic callback for processing values with position information
|
|
30
|
+
*/
|
|
31
|
+
export type ValueCallback<T> = (value: T, positionInfo?: PositionInfo) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a value is a known font-weight
|
|
34
|
+
*/
|
|
35
|
+
export declare function isKnownFontWeight(value: string | number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Generic shorthand auto-fix handler
|
|
38
|
+
* Handles the common logic for reconstructing shorthand values with replacements
|
|
39
|
+
*/
|
|
40
|
+
export declare function handleShorthandAutoFix(declarationNode: any, context: HandlerContext, valueText: string, replacements: ReplacementInfo[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Generic CSS tree traversal with position tracking
|
|
43
|
+
* Always provides position information since both handlers need it
|
|
44
|
+
*/
|
|
45
|
+
export declare function forEachValue<T>(valueText: string, extractValue: (node: any) => T | null, shouldSkipNode: (node: any) => boolean, callback: (value: T, positionInfo: PositionInfo) => void): void;
|
|
46
|
+
/**
|
|
47
|
+
* Specialized color value traversal
|
|
48
|
+
* Handles color-specific extraction and skipping logic
|
|
49
|
+
*/
|
|
50
|
+
export declare function forEachColorValue(valueText: string, callback: (colorValue: string, positionInfo: PositionInfo) => void): void;
|
|
51
|
+
/**
|
|
52
|
+
* Specialized density value traversal
|
|
53
|
+
* Handles dimension-specific extraction and skipping logic
|
|
54
|
+
*/
|
|
55
|
+
export declare function forEachDensityValue(valueText: string, cssProperty: string, callback: (parsedDimension: ParsedUnitValue, positionInfo: PositionInfo) => void): void;
|
|
56
|
+
/**
|
|
57
|
+
* Specialized font value traversal
|
|
58
|
+
* Handles font-specific extraction and skipping logic
|
|
59
|
+
*/
|
|
60
|
+
export declare function forEachFontValue(valueText: string, callback: (fontValue: ParsedUnitValue, positionInfo: PositionInfo) => void): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if any of the hook properties match the provided cssProperty using wildcard matching.
|
|
3
|
+
* @param hookProperties - Array of property patterns (can contain wildcards like `*`)
|
|
4
|
+
* @param cssProperty - The CSS property to be checked
|
|
5
|
+
* @returns true if a match is found, otherwise false
|
|
6
|
+
*/
|
|
7
|
+
export declare function matchesCssProperty(hookProperties: string[], cssProperty: string): boolean;
|
|
8
|
+
export declare function isBorderColorProperty(cssProperty: string): boolean;
|
|
9
|
+
export declare function isBorderWidthProperty(cssProperty: string): boolean;
|
|
10
|
+
export declare function isMarginProperty(cssProperty: string): boolean;
|
|
11
|
+
export declare function isPaddingProperty(cssProperty: string): boolean;
|
|
12
|
+
export declare function isBorderRadius(cssProperty: string): boolean;
|
|
13
|
+
export declare function isDimensionProperty(cssProperty: string): boolean;
|
|
14
|
+
export declare function isInsetProperty(cssProperty: string): boolean;
|
|
15
|
+
export declare const fontProperties: string[];
|
|
16
|
+
export declare const colorProperties: string[];
|
|
17
|
+
export declare const densificationProperties: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Convert property patterns to CSS AST selector patterns
|
|
20
|
+
* Handles wildcards (*) and creates proper ESLint CSS selector syntax
|
|
21
|
+
*/
|
|
22
|
+
export declare function toSelector(properties: string[]): string;
|
|
23
|
+
export declare function resolvePropertyToMatch(cssProperty: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata';
|
|
2
|
+
import { ParsedUnitValue } from './value-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Get styling hooks for a density value using structured data from CSS AST
|
|
5
|
+
* Eliminates regex parsing by accepting pre-parsed dimension data
|
|
6
|
+
*/
|
|
7
|
+
export declare function getStylingHooksForDensityValue(parsedValue: ParsedUnitValue, supportedStylinghooks: ValueToStylingHooksMapping, cssProperty: string): string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a CSS global value.
|
|
3
|
+
*
|
|
4
|
+
* CSS global values are special keywords that can be used for any CSS property and have a universal meaning:
|
|
5
|
+
* - initial: Resets the property to its initial value as defined by the CSS specification.
|
|
6
|
+
* - inherit: Inherits the value from the parent element.
|
|
7
|
+
* - unset: Acts as inherit if the property is inheritable, otherwise acts as initial.
|
|
8
|
+
* - revert: Rolls back the property to the value established by the user-agent or user styles.
|
|
9
|
+
* - revert-layer: Rolls back the property to the value established by the previous cascade layer.
|
|
10
|
+
*
|
|
11
|
+
* All CSS properties accept these global values, including but not limited to:
|
|
12
|
+
* - color
|
|
13
|
+
* - background
|
|
14
|
+
* - font-size
|
|
15
|
+
* - margin
|
|
16
|
+
* - padding
|
|
17
|
+
* - border
|
|
18
|
+
* - display
|
|
19
|
+
* - position
|
|
20
|
+
* - z-index
|
|
21
|
+
* - and many more
|
|
22
|
+
*
|
|
23
|
+
* These values are part of the CSS standard and are not considered violations, even if a rule would otherwise flag a value as invalid or non-design-token. They are always allowed for any property.
|
|
24
|
+
*
|
|
25
|
+
* @param value The CSS value to check.
|
|
26
|
+
* @returns True if the value is a CSS global value, false otherwise.
|
|
27
|
+
*
|
|
28
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
|
29
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
|
|
30
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/unset
|
|
31
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert
|
|
32
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert-layer
|
|
33
|
+
*/
|
|
34
|
+
export declare function isGlobalValue(value: string): boolean;
|
|
35
|
+
export type ParsedUnitValue = {
|
|
36
|
+
unit: 'px' | 'rem' | '%' | null;
|
|
37
|
+
number: number;
|
|
38
|
+
} | null;
|
|
39
|
+
export declare function parseUnitValue(value: string): ParsedUnitValue;
|
|
40
|
+
export declare function toAlternateUnitValue(numberVal: number, unitType: 'px' | 'rem' | '%' | null): ParsedUnitValue;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/types/index.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { Rule } from 'eslint';\nimport type { ValueToStylingHooksMapping } from '@salesforce-ux/sds-metadata/next';\n\n/**\n * Context interface for handlers to access necessary dependencies\n */\nexport interface HandlerContext {\n valueToStylinghook: ValueToStylingHooksMapping;\n context: Rule.RuleContext;\n sourceCode: any;\n}\n\n\n\n/**\n * Configuration for creating the rule\n */\nexport interface RuleConfig {\n ruleConfig: {\n type: 'problem' | 'suggestion' | 'layout';\n description: string;\n url?: string;\n messages: Record<string, string>;\n };\n valueToStylinghook: ValueToStylingHooksMapping;\n}\n\n/**\n * Handler function signature for CSS declarations\n */\nexport type DeclarationHandler = (node: any, context: HandlerContext) => void;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=yaml.d.js.map
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/utils/boxShadowValueParser.ts
|
|
30
|
+
var boxShadowValueParser_exports = {};
|
|
31
|
+
__export(boxShadowValueParser_exports, {
|
|
32
|
+
isBoxShadowMatch: () => isBoxShadowMatch,
|
|
33
|
+
parseBoxShadowValue: () => parseBoxShadowValue
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(boxShadowValueParser_exports);
|
|
36
|
+
var import_css_tree2 = require("@eslint/css-tree");
|
|
37
|
+
|
|
38
|
+
// src/utils/color-lib-utils.ts
|
|
39
|
+
var import_chroma_js = __toESM(require("chroma-js"));
|
|
40
|
+
var import_css_tree = require("@eslint/css-tree");
|
|
41
|
+
|
|
42
|
+
// src/utils/css-functions.ts
|
|
43
|
+
var CSS_FUNCTIONS = [
|
|
44
|
+
"attr",
|
|
45
|
+
"calc",
|
|
46
|
+
"color-mix",
|
|
47
|
+
"conic-gradient",
|
|
48
|
+
"counter",
|
|
49
|
+
"cubic-bezier",
|
|
50
|
+
"linear-gradient",
|
|
51
|
+
"max",
|
|
52
|
+
"min",
|
|
53
|
+
"radial-gradient",
|
|
54
|
+
"repeating-conic-gradient",
|
|
55
|
+
"repeating-linear-gradient",
|
|
56
|
+
"repeating-radial-gradient",
|
|
57
|
+
"var"
|
|
58
|
+
];
|
|
59
|
+
var CSS_MATH_FUNCTIONS = ["calc", "min", "max"];
|
|
60
|
+
var RGB_COLOR_FUNCTIONS = ["rgb", "rgba", "hsl", "hsla"];
|
|
61
|
+
var cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join("|")})`);
|
|
62
|
+
var cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join("|")})$`);
|
|
63
|
+
var cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join("|")})$`);
|
|
64
|
+
function isCssColorFunction(value) {
|
|
65
|
+
return RGB_COLOR_FUNCTIONS.includes(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/utils/color-lib-utils.ts
|
|
69
|
+
var isValidColor = (val) => import_chroma_js.default.valid(val);
|
|
70
|
+
|
|
71
|
+
// src/utils/value-utils.ts
|
|
72
|
+
function parseUnitValue(value) {
|
|
73
|
+
if (!value) return null;
|
|
74
|
+
const match = value.match(/^(-?\d*\.?\d+)(px|rem|%)?$/);
|
|
75
|
+
if (!match) return null;
|
|
76
|
+
const number = parseFloat(match[1]);
|
|
77
|
+
const unit = match[2] ? match[2] : null;
|
|
78
|
+
if (isNaN(number)) return null;
|
|
79
|
+
return { number, unit };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/utils/boxShadowValueParser.ts
|
|
83
|
+
function isColorValue(node) {
|
|
84
|
+
if (!node) return false;
|
|
85
|
+
switch (node.type) {
|
|
86
|
+
case "Hash":
|
|
87
|
+
return true;
|
|
88
|
+
// #hex colors
|
|
89
|
+
case "Identifier":
|
|
90
|
+
return isValidColor(node.name);
|
|
91
|
+
case "Function":
|
|
92
|
+
return isCssColorFunction(node.name.toLowerCase());
|
|
93
|
+
default:
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function isLengthValue(node) {
|
|
98
|
+
if (!node) return false;
|
|
99
|
+
switch (node.type) {
|
|
100
|
+
case "Dimension":
|
|
101
|
+
const dimensionStr = `${node.value}${node.unit}`;
|
|
102
|
+
return parseUnitValue(dimensionStr) !== null;
|
|
103
|
+
case "Number":
|
|
104
|
+
return Number(node.value) === 0;
|
|
105
|
+
default:
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function isInsetKeyword(node) {
|
|
110
|
+
return node?.type === "Identifier" && node.name.toLowerCase() === "inset";
|
|
111
|
+
}
|
|
112
|
+
function extractShadowParts(valueText) {
|
|
113
|
+
const shadows = [];
|
|
114
|
+
let currentShadow = {
|
|
115
|
+
lengthParts: [],
|
|
116
|
+
colorParts: [],
|
|
117
|
+
inset: false
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
const ast = (0, import_css_tree2.parse)(valueText, { context: "value" });
|
|
121
|
+
(0, import_css_tree2.walk)(ast, {
|
|
122
|
+
enter(node) {
|
|
123
|
+
if (node.type === "Function") {
|
|
124
|
+
return this.skip;
|
|
125
|
+
}
|
|
126
|
+
if (isInsetKeyword(node)) {
|
|
127
|
+
currentShadow.inset = true;
|
|
128
|
+
} else if (isLengthValue(node)) {
|
|
129
|
+
currentShadow.lengthParts.push((0, import_css_tree2.generate)(node));
|
|
130
|
+
} else if (isColorValue(node)) {
|
|
131
|
+
currentShadow.colorParts.push((0, import_css_tree2.generate)(node));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset) {
|
|
136
|
+
shadows.push(currentShadow);
|
|
137
|
+
}
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
return shadows;
|
|
142
|
+
}
|
|
143
|
+
function parseBoxShadowValue(value) {
|
|
144
|
+
const shadowStrings = value.split(",").map((s) => s.trim());
|
|
145
|
+
const allShadows = [];
|
|
146
|
+
for (const shadowString of shadowStrings) {
|
|
147
|
+
const shadows = extractShadowParts(shadowString);
|
|
148
|
+
const parsedShadows = shadows.map((shadow) => {
|
|
149
|
+
const shadowValue = {};
|
|
150
|
+
const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
|
|
151
|
+
lengthProps.forEach((prop, index) => {
|
|
152
|
+
if (shadow.lengthParts.length > index) {
|
|
153
|
+
shadowValue[prop] = shadow.lengthParts[index];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (shadow.colorParts.length > 0) {
|
|
157
|
+
shadowValue.color = shadow.colorParts[0];
|
|
158
|
+
}
|
|
159
|
+
if (shadow.inset) {
|
|
160
|
+
shadowValue.inset = true;
|
|
161
|
+
}
|
|
162
|
+
return shadowValue;
|
|
163
|
+
});
|
|
164
|
+
allShadows.push(...parsedShadows);
|
|
165
|
+
}
|
|
166
|
+
return allShadows;
|
|
167
|
+
}
|
|
168
|
+
function normalizeLengthValue(value) {
|
|
169
|
+
if (!value) return "0px";
|
|
170
|
+
if (value === "0") return "0px";
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
function isBoxShadowMatch(parsedCssValue, parsedValueHook) {
|
|
174
|
+
if (parsedCssValue.length !== parsedValueHook.length) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
for (let i = 0; i < parsedCssValue.length; i++) {
|
|
178
|
+
const cssShadow = parsedCssValue[i];
|
|
179
|
+
const hookShadow = parsedValueHook[i];
|
|
180
|
+
if (cssShadow.color !== hookShadow.color || cssShadow.inset !== hookShadow.inset) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
const lengthProps = ["offsetX", "offsetY", "blurRadius", "spreadRadius"];
|
|
184
|
+
for (const prop of lengthProps) {
|
|
185
|
+
if (normalizeLengthValue(cssShadow[prop]) !== normalizeLengthValue(hookShadow[prop])) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
193
|
+
0 && (module.exports = {
|
|
194
|
+
isBoxShadowMatch,
|
|
195
|
+
parseBoxShadowValue
|
|
196
|
+
});
|
|
197
|
+
//# sourceMappingURL=boxShadowValueParser.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/boxShadowValueParser.ts", "../../src/utils/color-lib-utils.ts", "../../src/utils/css-functions.ts", "../../src/utils/value-utils.ts"],
|
|
4
|
+
"sourcesContent": ["import { parse, walk, generate } from '@eslint/css-tree';\nimport { isValidColor } from './color-lib-utils';\nimport { parseUnitValue, type ParsedUnitValue } from './value-utils';\nimport { isCssColorFunction } from './css-functions';\n\nexport interface BoxShadowValue {\n offsetX?: string;\n offsetY?: string;\n blurRadius?: string;\n spreadRadius?: string;\n color?: string;\n inset?: boolean;\n}\n\ninterface ShadowParts {\n lengthParts: string[];\n colorParts: string[];\n inset: boolean;\n}\n\n/**\n * Check if a CSS tree node represents a color value\n */\nfunction isColorValue(node: any): boolean {\n if (!node) return false;\n \n switch (node.type) {\n case 'Hash':\n return true; // #hex colors\n case 'Identifier':\n return isValidColor(node.name);\n case 'Function':\n return isCssColorFunction(node.name.toLowerCase());\n default:\n return false;\n }\n}\n\n/**\n * Check if a CSS tree node represents a length value\n */\nfunction isLengthValue(node: any): boolean {\n if (!node) return false;\n \n switch (node.type) {\n case 'Dimension':\n // Use existing unit parsing to validate the unit\n const dimensionStr = `${node.value}${node.unit}`;\n return parseUnitValue(dimensionStr) !== null;\n case 'Number':\n // Zero values without units are valid lengths\n return Number(node.value) === 0;\n default:\n return false;\n }\n}\n\n/**\n * Check if a CSS tree node represents the 'inset' keyword\n */\nfunction isInsetKeyword(node: any): boolean {\n return node?.type === 'Identifier' && node.name.toLowerCase() === 'inset';\n}\n\n/**\n * Extract shadow parts from CSS tree nodes\n */\nfunction extractShadowParts(valueText: string): ShadowParts[] {\n const shadows: ShadowParts[] = [];\n let currentShadow: ShadowParts = {\n lengthParts: [],\n colorParts: [],\n inset: false\n };\n\n try {\n const ast = parse(valueText, { context: 'value' as const });\n \n walk(ast, {\n enter(node: any) {\n // Skip nested function content for now\n if (node.type === 'Function') {\n return this.skip;\n }\n \n if (isInsetKeyword(node)) {\n currentShadow.inset = true;\n } else if (isLengthValue(node)) {\n currentShadow.lengthParts.push(generate(node));\n } else if (isColorValue(node)) {\n currentShadow.colorParts.push(generate(node));\n }\n }\n });\n \n // Add the current shadow if it has any content\n if (currentShadow.lengthParts.length > 0 || currentShadow.colorParts.length > 0 || currentShadow.inset) {\n shadows.push(currentShadow);\n }\n \n } catch (error) {\n return [];\n }\n\n return shadows;\n}\n\n/**\n * Parse box-shadow value into structured format\n * Simplified version for ESLint v9 compatibility\n */\nexport function parseBoxShadowValue(value: string): BoxShadowValue[] {\n // Handle multiple shadows separated by commas\n const shadowStrings = value.split(',').map(s => s.trim());\n const allShadows: BoxShadowValue[] = [];\n \n for (const shadowString of shadowStrings) {\n const shadows = extractShadowParts(shadowString);\n \n const parsedShadows = shadows.map((shadow) => {\n /**\n * Box-shadow syntax:\n * Two, three, or four <length> values:\n * - offset-x offset-y [blur-radius] [spread-radius]\n * Optionally: inset keyword and color value\n */\n const shadowValue: BoxShadowValue = {};\n \n // Map length parts to shadow properties\n const lengthProps = ['offsetX', 'offsetY', 'blurRadius', 'spreadRadius'] as const;\n lengthProps.forEach((prop, index) => {\n if (shadow.lengthParts.length > index) {\n shadowValue[prop] = shadow.lengthParts[index];\n }\n });\n \n // Add color if present\n if (shadow.colorParts.length > 0) {\n shadowValue.color = shadow.colorParts[0];\n }\n \n // Add inset flag if present\n if (shadow.inset) {\n shadowValue.inset = true;\n }\n \n return shadowValue;\n });\n \n allShadows.push(...parsedShadows);\n }\n \n return allShadows;\n}\n\n/**\n * Normalize length value for comparison\n */\nfunction normalizeLengthValue(value: string | undefined): string {\n if (!value) return '0px';\n if (value === '0') return '0px';\n return value;\n}\n\n/**\n * Check if two parsed box-shadow values match\n */\nexport function isBoxShadowMatch(parsedCssValue: BoxShadowValue[], parsedValueHook: BoxShadowValue[]): boolean {\n // If the number of shadows doesn't match, they're not equal\n if (parsedCssValue.length !== parsedValueHook.length) {\n return false;\n }\n\n // Compare each shadow in the array\n for (let i = 0; i < parsedCssValue.length; i++) {\n const cssShadow = parsedCssValue[i];\n const hookShadow = parsedValueHook[i];\n\n // Compare color and inset properties\n if (cssShadow.color !== hookShadow.color || cssShadow.inset !== hookShadow.inset) {\n return false;\n }\n\n // Compare length properties\n const lengthProps = ['offsetX', 'offsetY', 'blurRadius', 'spreadRadius'] as const;\n for (const prop of lengthProps) {\n if (normalizeLengthValue(cssShadow[prop]) !== normalizeLengthValue(hookShadow[prop])) {\n return false;\n }\n }\n }\n\n return true;\n}\n", "//stylelint-sds/packages/stylelint-plugin-slds/src/utils/color-lib-utils.ts\nimport { ValueToStylingHooksMapping, ValueToStylingHookEntry } from '@salesforce-ux/sds-metadata/next';\nimport chroma from 'chroma-js';\nimport { generate } from '@eslint/css-tree';\nimport { isCssColorFunction } from './css-functions';\n\nconst LAB_THRESHOLD = 25; // Adjust this to set how strict the matching should be\n\nconst isHardCodedColor = (color: string): boolean => {\n const colorRegex =\n /\\b(rgb|rgba)\\((\\s*\\d{1,3}\\s*,\\s*){2,3}\\s*(0|1|0?\\.\\d+)\\s*\\)|#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\\b|[a-zA-Z]+/g;\n return colorRegex.test(color);\n};\n\nconst isHexCode = (color: string): boolean => {\n const hexPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/; // Pattern for #RGB or #RRGGBB\n return hexPattern.test(color);\n};\n\n// Convert a named color or hex code into a hex format using chroma-js\nconst convertToHex = (color: string): string | null => {\n try {\n // Try converting the color using chroma-js, which handles both named and hex colors\n return chroma(color).hex();\n } catch (e) {\n // If chroma can't process the color, it's likely invalid\n return null;\n }\n};\n\n// Find the closest color hook using LAB distance\nconst findClosestColorHook = (\n color: string,\n supportedColors:ValueToStylingHooksMapping,\n cssProperty: string\n): string[] => {\n const returnStylingHooks: string[] = [];\n const closestHooksWithSameProperty: { name: string; distance: number }[] = [];\n const closestHooksWithoutSameProperty: { name: string; distance: number }[] =\n [];\n const closestHooksWithAllProperty: { name: string; distance: number }[] =\n [];\n const labColor = chroma(color).lab();\n\n Object.entries(supportedColors).forEach(([sldsValue, data]) => {\n if (sldsValue && isHexCode(sldsValue)) {\n const hooks = data as ValueToStylingHookEntry[]; // Get the hooks for the sldsValue\n\n hooks.forEach((hook) => {\n const labSupportedColor = chroma(sldsValue).lab();\n const distance = (JSON.stringify(labColor) === JSON.stringify(labSupportedColor)) ? 0\n : chroma.distance(chroma.lab(...labColor), chroma.lab(...labSupportedColor), \"lab\");\n // Check if the hook has the same property\n if (hook.properties.includes(cssProperty)) {\n // Add to same property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithSameProperty.push({ name: hook.name, distance });\n }\n } \n // Check for the universal selector\n else if ( hook.properties.includes(\"*\") ){\n // Add to same property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithAllProperty.push({ name: hook.name, distance });\n }\n }\n else {\n // Add to different property hooks if within threshold\n if (distance <= LAB_THRESHOLD) {\n closestHooksWithoutSameProperty.push({ name: hook.name, distance });\n }\n }\n });\n }\n });\n\n// Group hooks by their priority\nconst closesthookGroups = [\n { hooks: closestHooksWithSameProperty, distance: 0 },\n { hooks: closestHooksWithAllProperty, distance: 0 },\n { hooks: closestHooksWithSameProperty, distance: Infinity }, // For hooks with distance > 0\n { hooks: closestHooksWithAllProperty, distance: Infinity },\n { hooks: closestHooksWithoutSameProperty, distance: Infinity },\n];\n\nfor (const group of closesthookGroups) {\n // Filter hooks based on the distance condition\n const filteredHooks = group.hooks.filter(h => \n group.distance === 0 ? h.distance === 0 : h.distance > 0\n );\n\n if (returnStylingHooks.length < 1 && filteredHooks.length > 0) {\n filteredHooks.sort((a, b) => a.distance - b.distance);\n returnStylingHooks.push(...filteredHooks.slice(0, 5).map((h) => h.name));\n }\n}\n\n\n return Array.from(new Set(returnStylingHooks));\n};\n\n/**\n * This method is usefull to identify all possible css color values.\n * - names colors\n * - 6,8 digit hex\n * - rgb and rgba\n * - hsl and hsla\n */\nconst isValidColor = (val:string):boolean => chroma.valid(val);\n\n/**\n * Extract color value from CSS AST node\n */\nconst extractColorValue = (node: any): string | null => {\n let colorValue: string | null = null;\n \n switch (node.type) {\n case 'Hash':\n colorValue = `#${node.value}`;\n break;\n case 'Identifier':\n colorValue = node.name;\n break;\n case 'Function':\n // Only extract color functions\n if (isCssColorFunction(node.name)) {\n colorValue = generate(node);\n }\n break;\n }\n \n return colorValue && isValidColor(colorValue) ? colorValue : null;\n};\n\nexport { findClosestColorHook, convertToHex, isHexCode, isHardCodedColor, isValidColor, extractColorValue };\n", "//stylelint-sds/packages/stylelint-plugin-slds/src/utils/css-functions.ts\n/**\n * Complete list of CSS functions that should be preserved/recognized\n */\nconst CSS_FUNCTIONS = [\n 'attr',\n 'calc',\n 'color-mix',\n 'conic-gradient',\n 'counter',\n 'cubic-bezier',\n 'linear-gradient',\n 'max',\n 'min',\n 'radial-gradient',\n 'repeating-conic-gradient',\n 'repeating-linear-gradient',\n 'repeating-radial-gradient',\n 'var'\n ];\n \n \n const CSS_MATH_FUNCTIONS = ['calc', 'min', 'max'];\n \n \n const RGB_COLOR_FUNCTIONS = ['rgb', 'rgba', 'hsl', 'hsla'];\n \n /**\n * Regex for matching any CSS function (for general detection)\n * Matches function names within other text\n */\n const cssFunctionsRegex = new RegExp(`(?:${CSS_FUNCTIONS.join('|')})`);\n \n \n const cssFunctionsExactRegex = new RegExp(`^(?:${CSS_FUNCTIONS.join('|')})$`);\n \n \n const cssMathFunctionsRegex = new RegExp(`^(?:${CSS_MATH_FUNCTIONS.join('|')})$`);\n \n export function containsCssFunction(value: string): boolean {\n return cssFunctionsRegex.test(value);\n }\n \n /**\n * Check if a value is exactly a CSS function name\n */\n export function isCssFunction(value: string): boolean {\n return cssFunctionsExactRegex.test(value);\n }\n \n export function isCssMathFunction(value: string): boolean {\n return cssMathFunctionsRegex.test(value);\n }\n \n export function isCssColorFunction(value: string): boolean {\n return RGB_COLOR_FUNCTIONS.includes(value);\n }", "// Simplified value parsing\n\n/**\n * Checks if a value is a CSS global value.\n *\n * CSS global values are special keywords that can be used for any CSS property and have a universal meaning:\n * - initial: Resets the property to its initial value as defined by the CSS specification.\n * - inherit: Inherits the value from the parent element.\n * - unset: Acts as inherit if the property is inheritable, otherwise acts as initial.\n * - revert: Rolls back the property to the value established by the user-agent or user styles.\n * - revert-layer: Rolls back the property to the value established by the previous cascade layer.\n *\n * All CSS properties accept these global values, including but not limited to:\n * - color\n * - background\n * - font-size\n * - margin\n * - padding\n * - border\n * - display\n * - position\n * - z-index\n * - and many more\n *\n * These values are part of the CSS standard and are not considered violations, even if a rule would otherwise flag a value as invalid or non-design-token. They are always allowed for any property.\n *\n * @param value The CSS value to check.\n * @returns True if the value is a CSS global value, false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/unset\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/revert-layer\n */\nexport function isGlobalValue(value: string): boolean {\n return value === 'initial' || value === 'inherit' || value === 'unset' || value === 'revert' || value === 'revert-layer';\n }\n\nexport type ParsedUnitValue = {\n unit: 'px' | 'rem' | '%' | null;\n number: number;\n} | null;\n\nexport function parseUnitValue(value: string): ParsedUnitValue {\n if (!value) return null;\n \n // Simple regex to parse number and unit\n const match = value.match(/^(-?\\d*\\.?\\d+)(px|rem|%)?$/);\n if (!match) return null;\n \n const number = parseFloat(match[1]);\n const unit = match[2] ? (match[2] as 'px' | 'rem' | '%') : null; // Keep unitless values as null\n \n if (isNaN(number)) return null;\n \n return { number, unit };\n}\n\nexport function toAlternateUnitValue(numberVal: number, unitType: 'px' | 'rem' | '%' | null): ParsedUnitValue {\n if (unitType === 'px') {\n let floatValue = parseFloat(`${numberVal / 16}`);\n if (!isNaN(floatValue)) {\n return {\n unit: 'rem',\n number: parseFloat(floatValue.toFixed(4))\n }\n }\n } else if (unitType === 'rem') {\n const intValue = parseInt(`${numberVal * 16}`);\n if (!isNaN(intValue)) {\n return {\n unit: 'px',\n number: intValue\n }\n }\n }\n // For unitless values (font-weight, etc.), no alternate unit conversion\n return null;\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAsC;;;ACEtC,uBAAmB;AACnB,sBAAyB;;;ACCzB,IAAM,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;A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