@@ -89,7 +89,7 @@ retrieving CSS selectors(document symbols such as classes, IDs, and other select
8989
9090### Methods
9191
92- #### ` getAllSymbols(text, cssMode, filePath) `
92+ ### ` getAllSymbols(text, cssMode, filePath) `
9393
9494Retrieves all CSS selectors from the provided CSS text as an array of strings.
9595
@@ -111,6 +111,52 @@ const selectors = CSSLanguageService.getAllSymbols(cssText, CSSLanguageService.C
111111console .log (selectors); // Output: [".class", "#id"]
112112```
113113
114+ ### ` validateCSS(text, cssMode, filePath, lintSettings) `
115+
116+ Validates CSS code using specified settings and returns an array of diagnostic messages.
117+
118+ ** Parameters:**
119+
120+ - ` text ` (string): The CSS code to be validated.
121+ - ` cssMode ` (string): The CSS mode used for parsing the code.
122+ - ` filePath ` (string): The path of the CSS file being validated.
123+ - ` lintSettings ` (object): The lint settings to be used for validation.
124+
125+ Possible keys and their descriptions:
126+ - ` compatibleVendorPrefixes ` : Unnecessary vendor prefixes checker.
127+ - ` vendorPrefix ` : Warns on missing vendor prefixes.
128+ - ` duplicateProperties ` : Flags duplicated CSS properties.
129+ - ` emptyRules ` : Detects CSS rules that have no properties.
130+ - ` importStatement ` : Flags the use of @import within CSS files.
131+ - ` boxModel ` : Warns if CSS box model is potentially misused.
132+ - ` universalSelector ` : Warns against the use of the universal selector (* ).
133+ - ` zeroUnits ` : Warns when units specification for zero values is unnecessary.
134+ - ` fontFaceProperties ` : Ensures necessary properties are included in @font-face declarations.
135+ - ` hexColorLength ` : Enforces consistency in hex color definitions.
136+ - ` argumentsInColorFunction ` : Validates arguments within color functions.
137+ - ` unknownProperties ` : Warns on unrecognized or mistyped CSS properties.
138+ - ` ieHack ` : Warns about CSS hacks for older versions of Internet Explorer.
139+ - ` unknownVendorSpecificProperties ` : Flags vendor-specific properties that might not be universally recognized.
140+ - ` propertyIgnoredDueToDisplay ` : Notifies when CSS properties are ignored due to the ` display ` setting of an element.
141+ - ` important ` : Warns against the excessive use of ` !important ` .
142+ - ` float ` : Advises on the use of ` float ` , recommending modern layout alternatives.
143+ - ` idSelector ` : Advises against using ID selectors for styling.
144+
145+ Each key's value can be "warning" or "error".
146+
147+ ** Return Value:**
148+
149+ Returns an ` Array ` of objects with the following properties:
150+ - ` code ` (string)
151+ - ` source ` (string)
152+ - ` message ` (string)
153+ - ` severity ` (number)
154+ - ` range ` (object) which includes:
155+ - ` start ` (object): contains ` line ` (number) and ` character ` (number)
156+ - ` end ` (object): contains ` line ` (number) and ` character ` (number)
157+
158+ These objects represent the diagnostic messages produced during validation.
159+
114160### Constants
115161
116162#### ` CSSLanguageService.CSS_MODES `
0 commit comments