Registry / serialization / csscomb-core

csscomb-core

JSON →
library3.0.6jsnpmunverified

CSScomb Core is a foundational framework designed for building custom CSS postprocessors. It provides a robust set of features, including a powerful parser that supports various CSS preprocessor syntaxes (CSS, Less, Sass, SCSS), an API for defining and managing processing options, and utilities for applying these processes to files, directories, or strings. The current stable version, 3.0.6, continues to focus on providing a modular and extensible architecture for linting and transforming CSS code programmatically. Its key differentiators lie in its flexible plugin system, allowing developers to create highly specific styling rules and formatting logic, and its ability to handle different CSS-like syntaxes through a unified interface. While a specific release cadence isn't published, it appears to be maintained as a core component for CSS processing tasks.

npm install csscomb-core
INSTALL
IMPORT
SIG · CSSCOMB-CORE
C
csscomb-core
serializationjavascriptv3.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Comb
const Comb = require('csscomb-core');
import Comb from 'csscomb-core';
CSScomb Core v3.x is primarily a CommonJS package. Direct ESM `import` statements may require specific Node.js loader configurations or bundler setups for correct interoperation.

Demonstrates how to import CSScomb Core, configure it with rules, and then use it to process and lint a CSS string asynchronously.

const Comb = require('csscomb-core'); const fs = require('fs'); const path = require('path'); async function processCssString() { // Define a configuration object. In a real application, this would typically // be loaded from a .csscomb.json file or similar. const config = { 'always-semicolon': true, 'color-case': 'lower', 'leading-zero': false, 'space-before-colon': 'zero', 'space-after-colon': 'one', 'selector-separator-newline': true }; // Instantiate the Comb processor. The first parameter is typically an array // of plugin instances if you're dynamically loading them, or an empty array. // The second parameter specifies the default syntax. const comb = new Comb([], 'css'); // Load the desired configuration into the comb instance. comb.configure(config); const rawCss = ` .my-class { color: #FF0000; font-size: 16px } a {display :block ; padding: 10px} div{border: 1px solid #CCC;} `; try { console.log('Original CSS:\n', rawCss); // Process the string, applying the configured rules. const processedCss = await comb.processString(rawCss, { filename: 'example.css', syntax: 'css' }); console.log('\nProcessed CSS:\n', processedCss); // You can also lint the string to find issues without modifying it. const lintErrors = await comb.lintString(rawCss, { filename: 'example.css', syntax: 'css' }); if (lintErrors.length > 0) { console.log('\nLinting Errors Found:'); lintErrors.forEach(error => console.log(`- [${error.line}:${error.column}] ${error.message}`)); } else { console.log('\nNo linting errors found.'); } } catch (error) { console.error('Error processing CSS:', error); } } processCssString();
Debug
Known issues
gotchaThe package primarily documents and supports CommonJS `require()` syntax. While Node.js has ESM support, directly using `import Comb from 'csscomb-core'` might lead to unexpected behavior or require specific Node.js loader configurations, especially in older environments or bundlers not configured for CJS interop.
fix
Always use `const Comb = require('csscomb-core');` for reliable integration in both CommonJS and environments that support CJS interop.
affects: >=3.0.0
gotchaAll core processing and linting methods (`processString`, `lintFile`, `processDirectory`, etc.) return Promises. Failing to `await` these calls or handle their resolutions can lead to `UnhandledPromiseRejectionWarning` or incorrect program flow where subsequent operations execute before processing is complete.
fix
Always use `await` with these methods within an `async` function, or chain `.then()` and `.catch()` handlers explicitly to manage asynchronous operations.
affects: >=3.0.0
gotchaThe `new Comb(options, syntax)` constructor's `options` parameter is for an array of plugin instances or an initial configuration object, which can be confusing given the separate `comb.configure(config)` method. Misunderstanding this parameter's purpose can lead to an unconfigured or improperly initialized processor instance.
fix
For clearer configuration management, it's recommended to instantiate with `new Comb([], syntax)` and then load your configuration explicitly using `comb.configure(yourConfigObject)`.
affects: >=3.0.0
gotchaCSScomb Core's parsing and processing are highly dependent on the specified `syntax` (e.g., 'css', 'less', 'sass', 'scss'). Providing an unsupported or incorrect syntax string to the constructor or the `processString`/`lintString` options will result in parsing failures or unexpected output.
fix
Ensure the `syntax` parameter is one of the explicitly supported values ('css', 'less', 'sass', 'scss') and accurately matches the input content being processed.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: Comb is not a constructor
Attempting to call `Comb` as a constructor without using the `new` keyword, or if `require('csscomb-core')` did not correctly return the constructor function.
fix
Ensure `const Comb = require('csscomb-core');` is correctly placed and use `new Comb([], 'css');` to create an instance.
TypeError: comb.processString is not a function
The `comb` instance was not created successfully, or the `Comb` object itself was not correctly imported/required, leading to `comb` being undefined or not the expected instance.
fix
Verify the `Comb` import and instance creation: `const comb = new Comb([], 'css');`.
UnhandledPromiseRejectionWarning: Promise { <pending> }
An asynchronous method like `processString` or `lintFile` was called without `await` in an `async` context, or without `.then()` and `.catch()` handlers to explicitly manage its resolution.
fix
Add `await` before the promise-returning call, or handle the Promise explicitly: `await comb.processString(...)` or `comb.processString(...).then(...).catch(...)`.
Error: Syntax 'invalid' is not supported
An unrecognized or unsupported string was passed as the `syntax` parameter to the `Comb` constructor or within the options object for `processString`/`lintString`.
fix
Use one of the officially supported syntaxes: `'css'`, `'less'`, `'sass'`, or `'scss'`.
Upgrade
Version history
3.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
csscomb-core — npm install csscomb-core · libregistry