CodeVetter · Repo Unpack · Extension points
stylelint/stylelint
Stylelint exposes extension interfaces for rules, syntaxes, configuration, reporting, and reference loading. Core rules and formatters use explicit registries, while configured plugin definitions are normalized into lookup tables. Most extension behavior converges on PostCSS roots and the shared reporting utility.
- New core rules plug into ruleNames in lib/rules/index.mjs; enumerable getters resolve each rule's index.mjs through a cached import promise.
- createPlugin returns {ruleName, rule}; plugin augmentation accepts a single definition or array, requires names containing '/', and installs functions into config._pluginFunctions.
- Rule factories receive primary settings, secondary options, and context, returning callbacks invoked with root and result; promise aggregation accommodates asynchronous callbacks.
- Public plugin utilities include report, ruleMessages, validateOptions, and checkAgainstRule; report integrates severity, disable ranges, fix callbacks, and edit information.
- Custom syntaxes can supply parse/stringify objects or modules; extension-language configs can select syntax through overrides and disable incompatible core rules.
- Custom formatters implement formatter(results, returnValue); API selection accepts functions/promises or existing file paths, and the CLI separately imports --custom-formatter modules.
- Configured processors are factories returning name and postprocess; augmentation validates both fields, stores callbacks by name, and standalone invokes them on each converted result and its root.
- referenceFiles entries accept files, customSyntax, and loader; loaders can be imported modules or supplied PostCSS plugins and are installed into a dedicated reference-file processor.