Registry / testing / csshint

csshint

JSON →
library0.3.4jsnpmunverified

CSSHint is a Node.js-based CSS code review tool that lints CSS files for style consistency and errors. Current stable version 0.3.4, with an unknown release cadence (last update appears sporadic). It is built on PostCSS and supports rules from the ecomfe CSS style spec as well as CSSLint rules. Key differentiators: integration with global counters for project-wide consistency checks (hex color case, font-family case), and a promise-based API for file content checking.

npm install csshint
INSTALL
IMPORT
SIG · CSSHINT
C
csshint
testingjavascriptv0.3.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import csshint from 'csshint'
const csshint = require('csshint')
Package does not declare a default export. Use named export 'checkString' or 'check'.
checkString
import { checkString } from 'csshint'
import checkString from 'csshint'
Must use named import; default import is undefined.
check
import { check } from 'csshint'
const { check } = require('csshint')
CJS require with destructuring works, but ESM named import is preferred.

Demonstrates how to lint a CSS string using the checkString function, handling the promise result with warning messages.

import { checkString } from 'csshint'; const cssCode = `div { color: #fff; }`; const config = {}; // optional custom config object checkString(cssCode, config) .then(result => { console.log('Path:', result.path); result.messages.forEach(msg => { console.log(`${msg.ruleName}: ${msg.message} (line ${msg.line}, col ${msg.col})`); }); }) .catch(err => { console.error('Error reading file:', err); });
csshint --version
Debug
Known issues
gotchaThe package modifies global objects (CSSHINT_INVALID_ALL_COUNT, CSSHINT_HEXCOLOR_CASE_FLAG, CSSHINT_FONTFAMILY_CASE_FLAG) which can cause side effects across multiple lint runs.
fix
Avoid concurrent lint operations; reset globals between runs if needed.
affects: >=0.0.0
deprecatedThe CLI interface may be unstable; documentation lacks clear CLI command support beyond basic usage.
fix
Use the Node.js API instead of CLI for consistent behavior.
affects: >=0.3.0
Errors
Common errors & fixes
TypeError: csshint is not a function
Importing default export incorrectly, as the package only exports named functions.
fix
Use import { checkString } from 'csshint' instead of import csshint from 'csshint'.
Cannot find module 'postcss'
PostCSS is a peer dependency of csshint and must be installed manually if not auto-installed.
fix
Run npm install postcss as a dependency of your project.
Upgrade
Version history
0.3.4latest on npm
Audit
Dependencies
postcssrequiredCSS parser and plugin framework
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
csshint — npm install csshint · libregistry