{"id":13394185,"url":"https://github.com/anandthakker/doiuse","last_synced_at":"2025-05-13T15:11:37.302Z","repository":{"id":23186477,"uuid":"26542739","full_name":"anandthakker/doiuse","owner":"anandthakker","description":":bomb: Lint CSS for browser support against caniuse database.","archived":false,"fork":false,"pushed_at":"2025-01-13T17:28:52.000Z","size":905,"stargazers_count":1277,"open_issues_count":41,"forks_count":53,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-23T18:56:53.811Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anandthakker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-12T15:37:16.000Z","updated_at":"2025-04-04T17:56:26.000Z","dependencies_parsed_at":"2024-01-13T22:22:52.697Z","dependency_job_id":"d2cc1fab-57a5-4405-bcee-466adb9f95dd","html_url":"https://github.com/anandthakker/doiuse","commit_stats":{"total_commits":237,"total_committers":31,"mean_commits":7.645161290322581,"dds":0.4092827004219409,"last_synced_commit":"b4685e99507b22bebb638d36dea92e5a09782ca3"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandthakker%2Fdoiuse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandthakker%2Fdoiuse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandthakker%2Fdoiuse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anandthakker%2Fdoiuse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anandthakker","download_url":"https://codeload.github.com/anandthakker/doiuse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969260,"owners_count":21992263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:11.768Z","updated_at":"2025-05-13T15:11:32.289Z","avatar_url":"https://github.com/anandthakker.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Testing \u0026 Optimization","🤖 AI \u0026 Machine Learning"],"sub_categories":["Linters"],"readme":"[![Build Status](https://travis-ci.org/anandthakker/doiuse.svg?branch=master)](https://travis-ci.org/anandthakker/doiuse)\n[![Release Notes](https://release-notes.com/badges/v2.svg)](https://release-notes.com/@open-source-community/anandthakker-doiuse)\n\n# doiuse\n\nLint CSS for browser support against [Can I use](http://caniuse.com) database.\n\n## Install\n\n```sh\nnpm install -g doiuse\n```\n\n## Usage Examples\n\n### Command Line\n\n```bash\ndoiuse --browsers \"ie \u003e= 9, \u003e 1%, last 2 versions\" main.css\n# or\ncat main.css | doiuse --browsers \"ie \u003e= 9, \u003e 1%, last 2 versions\"\n```\n\n**Sample output:**\n```\n/projects/website/main.css:5:3: CSS3 Box-sizing not supported by: IE (8,9,10,11), Chrome (36,37,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)\n/projects/website/main.css:6:3: CSS3 Box-sizing not supported by: IE (8,9,10,11), Chrome (36,37,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)\n/projects/website/main.css:8:3: CSS user-select: none not supported by: IE (8,9)\n/projects/website/main.css:9:3: CSS user-select: none not supported by: IE (8,9)\n/projects/website/main.css:10:3: CSS user-select: none not supported by: IE (8,9)\n/projects/website/main.css:11:3: CSS user-select: none not supported by: IE (8,9)\n/projects/website/main.css:12:3: CSS user-select: none not supported by: IE (8,9)\n/projects/website/main.css:13:3: Pointer events not supported by: IE (8,9,10), Firefox (32,33), Chrome (36,37,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)\n/projects/website/main.css:14:3: Pointer events not supported by: IE (8,9,10), Firefox (32,33), Chrome (36,37,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)\n/projects/website/main.css:32:3: CSS3 Transforms not supported by: IE (8)\n```\n\nUse `--json` to get output as (newline-delimited) JSON objects.\n\n### JS\n\n```javascript\nimport postcss from 'postcss';\nimport DoIUse from 'doiuse/lib/DoIUse.js';\n\npostcss(new DoIUse({\n  browsers:['ie \u003e= 6', '\u003e 1%'],\n  ignore: ['rem'], // an optional array of features to ignore\n  ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore\n  onFeatureUsage: (usageInfo) =\u003e {\n    console.log(usageInfo.message);\n  }\n})).process(\"a { background-size: cover; }\")\n```\n\nCommonJS syntax is still supported if using `var doiuse = require('doiuse')`.\n\n### Gulp (CommonJS)\n\n```javascript\nvar gulp = require('gulp')\nvar postcss = require('postcss')\nvar doiuse = require('doiuse')\n\ngulp.src(src, { cwd: process.cwd() })\n.pipe(gulp.postcss([\n  doiuse({\n    browsers: [\n      'ie \u003e= 8',\n      '\u003e 1%'\n    ],\n    ignore: ['rem'], // an optional array of features to ignore\n    ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore\n    onFeatureUsage: function (usageInfo) {\n      console.log(usageInfo.message)\n    }\n  })\n]))\n```\n\n## How it works\n\nIn particular, the approach to detecting features usage is currently quite naive.\n\n\u003ca name=\"features-list\"\u003e\u003c/a\u003eRefer to the data in [/data/features.js](data/features.js).\n\n- If a feature in that dataset only specifies `properties`, we just use those\n  properties for regex/substring matches against the properties used in the input CSS.\n- If a feature also specifies `values`, then we also require that the associated\n  value matches one of those values.\n\n## API Details\n\n### As a transform stream\n\n```javascript\nvar doiuse = require('doiuse/stream');\n\nprocess.stdin\n  .pipe(doiuse({ browsers: ['ie \u003e= 8', '\u003e 1%'], ignore: ['rem'] }))\n  .on('data', function (usageInfo) {\n    console.log(JSON.stringify(usageInfo))\n  })\n```\n\nYields `UsageInfo` objects as described below.\n\n### As a postcss plugin\n\n`postcss(new DoIUse(opts)).process(css)`, where `opts` is:\n```javascript\n{\n  browsers: ['ie \u003e= 8', '\u003e 1%'], // an autoprefixer-like array of browsers.\n  ignore: ['rem'], // an optional array of features to ignore\n  ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore\n  onFeatureUsage: function(usageInfo) { } // a callback for usages of features not supported by the selected browsers\n}\n```\n\nAnd `usageInfo` looks like this:\n\n```javascript\n{\n  message: '\u003cinput source\u003e: line \u003cl\u003e, col \u003cc\u003e - CSS3 Gradients not supported by: IE (8)',\n  feature: 'css-gradients', // slug identifying a caniuse-db feature\n  featureData: {\n    title: 'CSS Gradients',\n    missing: \"IE (8)\", // string of browsers missing support for this feature.\n    missingData: {\n      // map of browser -\u003e version -\u003e (lack of)support code\n      ie: { '8': 'n' }\n    },\n    caniuseData: { // data from caniuse-db/features-json/[feature].json }\n  },\n  usage: {} //the postcss node where that feature is being used.\n}\n```\n\nCalled once for each usage of each css feature not supported by the selected browsers.\n\n### Ignoring file-specific rules\n\nFor disabling some checks you can use just-in-place comments\n\n##### `/* doiuse-disable */`\n\nDisables checks of _all [features](#features-list)_\n\n##### `/* doiuse-disable feature */`\n\nDisables checks of _specified [feature(s)](#features-list)_ (can be comma separated list)\n\n##### `/* doiuse-enable */`\n\nRe-enables checks of _all [features](#features-list)_\n\n##### `/* doiuse-enable feature */`\n\nEnables checks of _specified [feature(s)](#features-list)_  (can be comma separated list)\n - for following lines in file\n\n## [Contributing](CONTRIBUTING.md)\n\ndoiuse is an [OPEN Open Source](http://openopensource.org/) Project.\n\nThis 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.\n\n## License\n\nMIT\n\n**NOTE:** Many of the files in test/cases are from autoprefixer-core, Copyright 2013 Andrey Sitnik \u003candrey@sitnik.ru\u003e.  Please see https://github.com/postcss/autoprefixer-core.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanandthakker%2Fdoiuse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanandthakker%2Fdoiuse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanandthakker%2Fdoiuse/lists"}