# doiuse

> Lint CSS for browser support against caniuse database

Latest version **6.0.6** (published 2025-12-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install doiuse
pnpm add doiuse
yarn add doiuse
bun add doiuse
```

Provides the command `doiuse`.

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 6.0.6 |
| Published | 2025-12-13 |
| First published | 2014-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 8 |
| Unpacked size | 385.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1301 |
| Author | Carlos Lopez Jr. |
| Maintainers | anandthakker, ai, pkuczynski, shortfuse |
| Keywords | lint, css, browser, support, caniuse, stylelint |

## Links

- npm: https://www.npmjs.com/package/doiuse
- Repository: https://github.com/anandthakker/doiuse
- Issues: https://github.com/anandthakker/doiuse/issues
- npm.io page: https://npm.io/package/doiuse

## Dependencies (8)

- [yargs](https://npm.io/package/yargs.md) ^17.7.2
- [postcss](https://npm.io/package/postcss.md) ^8.5.6
- [duplexify](https://npm.io/package/duplexify.md) ^4.1.3
- [multimatch](https://npm.io/package/multimatch.md) ^5.0.0
- [source-map](https://npm.io/package/source-map.md) ^0.7.6
- [browserslist](https://npm.io/package/browserslist.md) ^4.28.1
- [caniuse-lite](https://npm.io/package/caniuse-lite.md) ^1.0.30001760
- [css-tokenize](https://npm.io/package/css-tokenize.md) ^1.0.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 6.0.6 (latest) — 2025-12-13
- 6.0.3-1 (test) — 2023-07-17
- 6.0.5 — 2024-10-21
- 6.0.4 — 2024-10-21
- 6.0.3 — 2024-09-20
- 6.0.3-0 — 2023-07-17
- 6.0.2 — 2023-07-07
- 6.0.1 — 2023-07-05
- 6.0.0 — 2023-07-03
- 4.4.1 — 2021-01-26
- 4.4.0 — 2020-11-10
- 4.3.1 — 2020-10-29
- 4.3.0 — 2020-10-29
- 4.2.0 — 2018-09-27
- 4.1.0 — 2018-03-23
- … 43 more at https://npm.io/package/doiuse/versions

## README

[![Build Status](https://github.com/anandthakker/doiuse/actions/workflows/test.yml/badge.svg)](https://github.com/anandthakker/doiuse/actions/workflows/test.yml)

# doiuse

Lint CSS for browser support against [Can I use](http://caniuse.com) database.

## Install

```sh
npm install -g doiuse
```

## Usage Examples

### Command Line

```bash
doiuse --browsers "ie >= 9, > 1%, last 2 versions" main.css
# or
cat main.css | doiuse --browsers "ie >= 9, > 1%, last 2 versions"
```

**Sample output:**
```
/projects/website/main.css:5:3: CSS3 Box-sizing not supported by: IE (8-11), Chrome (36-38), Safari (8,7.1), Opera (24-25), iOS Safari (8,7.1,8.1), Android Browser (4.1,4.4,4.4.4), IE Mobile (10-11)
/projects/website/main.css:6:3: CSS3 Box-sizing not supported by: IE (8-11), Chrome (36-38), Safari (8,7.1), Opera (24-25), iOS Safari (8,7.1,8.1), Android Browser (4.1,4.4,4.4.4), IE Mobile (10-11)
/projects/website/main.css:8:3: CSS user-select: none not supported by: IE (8-9)
/projects/website/main.css:9:3: CSS user-select: none not supported by: IE (8-9)
/projects/website/main.css:10:3: CSS user-select: none not supported by: IE (8-9)
/projects/website/main.css:11:3: CSS user-select: none not supported by: IE (8-9)
/projects/website/main.css:12:3: CSS user-select: none not supported by: IE (8-9)
/projects/website/main.css:13:3: Pointer events not supported by: IE (8-10), Firefox (32-33), Chrome (36-38), Safari (8,7.1), Opera (24-25), iOS Safari (8,7.1,8.1), Android Browser (4.1,4.4,4.4.4), IE Mobile (10)
/projects/website/main.css:14:3: Pointer events not supported by: IE (8-10), Firefox (32-33), Chrome (36-38), Safari (8,7.1), Opera (24-25), iOS Safari (8,7.1,8.1), Android Browser (4.1,4.4,4.4.4), IE Mobile (10)
/projects/website/main.css:32:3: CSS3 Transforms not supported by: IE (8)
```

Use `--json` to get output as (newline-delimited) JSON objects.

### JS

```javascript
import postcss from 'postcss';
import DoIUse from 'doiuse/lib/DoIUse.js';

postcss(new DoIUse({
  browsers:['ie >= 6', '> 1%'],
  ignore: ['rem'], // an optional array of features to ignore
  ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore
  onFeatureUsage: (usageInfo) => {
    console.log(usageInfo.message);
  }
})).process("a { background-size: cover; }")
```

CommonJS syntax is still supported if using `var doiuse = require('doiuse')`.

### Gulp (CommonJS)

```javascript
var gulp = require('gulp')
var postcss = require('postcss')
var doiuse = require('doiuse')

gulp.src(src, { cwd: process.cwd() })
.pipe(gulp.postcss([
  doiuse({
    browsers: [
      'ie >= 8',
      '> 1%'
    ],
    ignore: ['rem'], // an optional array of features to ignore
    ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore
    onFeatureUsage: function (usageInfo) {
      console.log(usageInfo.message)
    }
  })
]))
```

## How it works

In particular, the approach to detecting features usage is currently quite naive.

<a name="features-list"></a>Refer to the data in [/data/features.js](data/features.js).

- If a feature in that dataset only specifies `properties`, we just use those
  properties for regex/substring matches against the properties used in the input CSS.
- If a feature also specifies `values`, then we also require that the associated
  value matches one of those values.

## API Details

### As a transform stream

```javascript
var doiuse = require('doiuse/stream');

process.stdin
  .pipe(doiuse({ browsers: ['ie >= 8', '> 1%'], ignore: ['rem'] }))
  .on('data', function (usageInfo) {
    console.log(JSON.stringify(usageInfo))
  })
```

Yields `UsageInfo` objects as described below.

### As a postcss plugin

`postcss(new DoIUse(opts)).process(css)`, where `opts` is:
```javascript
{
  browsers: ['ie >= 8', '> 1%'], // an autoprefixer-like array of browsers.
  ignore: ['rem'], // an optional array of features to ignore
  ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore
  onFeatureUsage: function(usageInfo) { } // a callback for usages of features not supported by the selected browsers
}
```

And `usageInfo` looks like this:

```javascript
{
  message: '<input source>: line <l>, col <c> - CSS3 Gradients not supported by: IE (8)',
  feature: 'css-gradients', // slug identifying a caniuse-db feature
  featureData: {
    title: 'CSS Gradients',
    missing: "IE (8)", // string of browsers missing support for this feature.
    missingData: {
      // map of browser -> version -> (lack of)support code
      ie: { '8': 'n' }
    },
    caniuseData: { // data from caniuse-db/features-json/[feature].json }
  },
  usage: {} //the postcss node where that feature is being used.
}
```

Called once for each usage of each css feature not supported by the selected browsers.

### Ignoring file-specific rules

For disabling some checks you can use just-in-place comments

##### `/* doiuse-disable */`

Disables checks of _all [features](#features-list)_

##### `/* doiuse-disable feature */`

Disables checks of _specified [feature(s)](#features-list)_ (can be comma separated list)

##### `/* doiuse-enable */`

Re-enables checks of _all [features](#features-list)_

##### `/* doiuse-enable feature */`

Enables checks of _specified [feature(s)](#features-list)_  (can be comma separated list)
 - for following lines in file

## [Contributing](CONTRIBUTING.md)

doiuse is an [OPEN Open Source](http://openopensource.org/) Project.

This means that individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

## License

MIT

**NOTE:** Many of the files in test/cases are from autoprefixer-core, Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>.  Please see https://github.com/postcss/autoprefixer-core.

---
_Source: https://npm.io/package/doiuse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
