Doiuse is a JavaScript library and CLI tool that lints CSS code for browser support issues by comparing features used in the CSS against the Can I use database. It helps developers identify CSS properties and values that are not supported by their target browser list, preventing unexpected rendering problems. The current stable version is 6.0.6, released in early 2024, with maintenance releases occurring as needed to fix bugs and update feature definitions. It integrates well into build pipelines, notably as a PostCSS plugin or a transform stream. A key differentiator is its direct reliance on the `caniuse` database for accurate, up-to-date compatibility data, allowing for highly customizable browser targets using `browserslist` syntax. While it focuses on identifying unsupported features, its "naive" detection approach means it primarily checks for direct property/value matches rather than complex runtime interpretation, offering a fast and focused linting experience.
npm install doiuseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `doiuse` as a PostCSS plugin to lint CSS for browser compatibility, targeting specific browser versions and logging unsupported feature usages to the console.
Upgrade your Node.js environment to version 16 or newer. For projects that cannot upgrade Node.js, remain on `doiuse` v5.x or earlier.
Check the `engines` field in `package.json` for the specific `doiuse` version you are using. Upgrade Node.js or `doiuse` as necessary.
For the PostCSS plugin, use `import DoIUse from 'doiuse/lib/DoIUse.js'` (ESM) or `const DoIUse = require('doiuse/lib/DoIUse');` (CJS). For the stream, use `import doiuse from 'doiuse/stream'` or `const doiuse = require('doiuse/stream');`.Treat `doiuse` as a strong first line of defense for basic property/value support. Supplement its findings with actual browser testing and more advanced linting tools if detailed interaction compatibility is critical. Manually inspect the `data/features.js` file for specifics on how features are detected.
Ensure you are importing from the correct path: `import DoIUse from 'doiuse/lib/DoIUse.js';` for ESM or `const DoIUse = require('doiuse/lib/DoIUse');` for CommonJS.For ESM, ensure your project is configured with `"type": "module"` in `package.json` and use `import` statements. For CommonJS, use `require()` and ensure files are `.js` or `.cjs`. Doiuse v6.x is largely ESM-first, so adjust your imports accordingly.
For programmatic use, ensure you are importing the specific PostCSS plugin or stream entry point: `const doiusePlugin = require('doiuse/lib/DoIUse');` or `const doiuseStream = require('doiuse/stream');`.