Gathering detailed insights and metrics for doiuse
Gathering detailed insights and metrics for doiuse
Gathering detailed insights and metrics for doiuse
Gathering detailed insights and metrics for doiuse
@jsx-email/doiuse-email
Lint CSS for email support against caniemail database.
stylelint-no-unsupported-browser-features
Disallow features that are unsupported by the browsers that you are targeting
stylelint-browser-compat
Yet another linter rule to detect compatibility of CSS features.
doiuse-email
Lint CSS for email support against caniemail database.
💣 Lint CSS for browser support against caniuse database.
npm install doiuse
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,257 Stars
355 Commits
51 Forks
18 Watching
4 Branches
34 Contributors
Updated on 27 Nov 2024
JavaScript (56.5%)
CSS (43.49%)
Shell (0.02%)
Cumulative downloads
Total Downloads
Last day
12.9%
71,141
Compared to previous day
Last week
9.4%
374,323
Compared to previous week
Last month
17.6%
1,473,194
Compared to previous month
Last year
47.1%
14,550,396
Compared to previous year
22
Lint CSS for browser support against Can I use database.
1npm install -g doiuse
1doiuse --browsers "ie >= 9, > 1%, last 2 versions" main.css 2# or 3cat 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,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)
/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)
/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,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)
/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)
/projects/website/main.css:32:3: CSS3 Transforms not supported by: IE (8)
Use --json
to get output as (newline-delimited) JSON objects.
1import postcss from 'postcss'; 2import DoIUse from 'doiuse/lib/DoIUse.js'; 3 4postcss(new DoIUse({ 5 browsers:['ie >= 6', '> 1%'], 6 ignore: ['rem'], // an optional array of features to ignore 7 ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore 8 onFeatureUsage: (usageInfo) => { 9 console.log(usageInfo.message); 10 } 11})).process("a { background-size: cover; }")
CommonJS syntax is still supported if using var doiuse = require('doiuse')
.
1var gulp = require('gulp') 2var postcss = require('postcss') 3var doiuse = require('doiuse') 4 5gulp.src(src, { cwd: process.cwd() }) 6.pipe(gulp.postcss([ 7 doiuse({ 8 browsers: [ 9 'ie >= 8', 10 '> 1%' 11 ], 12 ignore: ['rem'], // an optional array of features to ignore 13 ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore 14 onFeatureUsage: function (usageInfo) { 15 console.log(usageInfo.message) 16 } 17 }) 18]))
In particular, the approach to detecting features usage is currently quite naive.
Refer to the data in /data/features.js.
properties
, we just use those
properties for regex/substring matches against the properties used in the input CSS.values
, then we also require that the associated
value matches one of those values.1var doiuse = require('doiuse/stream'); 2 3process.stdin 4 .pipe(doiuse({ browsers: ['ie >= 8', '> 1%'], ignore: ['rem'] })) 5 .on('data', function (usageInfo) { 6 console.log(JSON.stringify(usageInfo)) 7 })
Yields UsageInfo
objects as described below.
postcss(new DoIUse(opts)).process(css)
, where opts
is:
1{ 2 browsers: ['ie >= 8', '> 1%'], // an autoprefixer-like array of browsers. 3 ignore: ['rem'], // an optional array of features to ignore 4 ignoreFiles: ['**/normalize.css'], // an optional array of file globs to match against original source file path, to ignore 5 onFeatureUsage: function(usageInfo) { } // a callback for usages of features not supported by the selected browsers 6}
And usageInfo
looks like this:
1{ 2 message: '<input source>: line <l>, col <c> - CSS3 Gradients not supported by: IE (8)', 3 feature: 'css-gradients', // slug identifying a caniuse-db feature 4 featureData: { 5 title: 'CSS Gradients', 6 missing: "IE (8)", // string of browsers missing support for this feature. 7 missingData: { 8 // map of browser -> version -> (lack of)support code 9 ie: { '8': 'n' } 10 }, 11 caniuseData: { // data from caniuse-db/features-json/[feature].json } 12 }, 13 usage: {} //the postcss node where that feature is being used. 14}
Called once for each usage of each css feature not supported by the selected browsers.
For disabling some checks you can use just-in-place comments
/* doiuse-disable */
Disables checks of all features
/* doiuse-disable feature */
Disables checks of specified feature(s) (can be comma separated list)
/* doiuse-enable */
Re-enables checks of all features
/* doiuse-enable feature */
Enables checks of specified feature(s) (can be comma separated list)
doiuse is an OPEN Open Source 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.
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.
No vulnerabilities found.
Reason
13 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 6/19 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More