Giter Site home page Giter Site logo

doiuse's Introduction

Build Status Release Notes

doiuse

Lint CSS for browser support against Can I use database.

Install

npm install -g doiuse

Usage Examples

Command Line

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,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.

JS

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)

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.

Refer to the data in /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

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:

{
  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:

{
  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

/* 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)

  • for following lines in file

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.

License

MIT

NOTE: Many of the files in test/cases are from autoprefixer-core, Copyright 2013 Andrey Sitnik [email protected]. Please see https://github.com/postcss/autoprefixer-core.

doiuse's People

Contributors

a-korzun avatar ai avatar alanhussey avatar alrik avatar anandthakker avatar arcanemagus avatar billyjanitsch avatar clshortfuse avatar damienrobert avatar deiwin avatar dkrnl avatar edg2s avatar egidijusja avatar engelfrost avatar fogrew avatar groovecoder avatar ismamz avatar jackhowa avatar jimmybrawn avatar komlev avatar marekdedic avatar neezer avatar nezed avatar onigoetz avatar pkuczynski avatar rincedd avatar rjwadley avatar sebastienbarre avatar severeoverfl0w avatar stefanschwartze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doiuse's Issues

Update postcss plugin docs?

The docs suggest I should use doiuse as a postcss plugin like this?

          postcss(doiuse({onFeatureUsage:function(usageInfo){
            alert(usageInfo.message);
          }})).process(styleSheetContent)

But, I had to use it this way:

          postcss([doiuse]).process(styleSheetContent).then(function(result) {
            alert(result);
          });

?

False positive for viewport-units with base64 encoded data

Getting false positives with base64 encoded PNG for background image:

Viewport units: vw, vh, vmin, vmax not supported by: IE (9,10,11), iOS Safari (6.0-6.1,7.0-7.1), Android Browser (3,4,2.3,4.1,4.2-4.3), IE Mobile (10,11)

Actual CSS:

.icon {
    background-image: url('data:image/png;base64,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');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 45px 45px;
    height: 45px;
    width: 45px;
}

Segnet multi-gpu

Hello!
I am sorry that I am not writing on the topic. I sent you a message via e-mail, but you have not answered me.

I saw that you had success in segnet work using several gpu. I went to https://github.com/developmentseed/caffe/tree/segnet-multi-gp and made this assembly (cafe). I used three out of four tesla m2090 (5gb ram). But I didn't see any performance improvement.

| NVIDIA-SMI 352.39 Driver Version: 352.39 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla M2090 Off | 0000:19:00.0 Off | 0 |
| N/A 59C P12 30W / 225W | 10MiB / 5375MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 Tesla M2090 Off | 0000:1A:00.0 Off | 0 |
| N/A 59C P1 139W / 225W | 4812MiB / 5375MiB | 87% Default |
+-------------------------------+----------------------+----------------------+
| 2 Tesla M2090 Off | 0000:1E:00.0 Off | 0 |
| N/A 59C P0 159W / 225W | 4457MiB / 5375MiB | 19% Default |
+-------------------------------+----------------------+----------------------+
| 3 Tesla M2090 Off | 0000:1F:00.0 Off | 0 |
| N/A 59C P0 141W / 225W | 4457MiB / 5375MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

I used three gpu. But the learning rate didn't change. 20 iterations took over 40 seconds, as if I use one gpu.

I tried to change batch size in segnet_train.prototxt to value 2 or 3 (on m2090 segnet works only if batch size is 1, because I have 5 gb ram only). But I received the message "Out of memory". Please tell me if I can increase the learning rate if I use two or more gpu. If so, what should I do? Can I increase the value of upsample layer in segnet_train.prototxt?

layer {
name: "upsample5"
type: "Upsample"
bottom: "pool5"
top: "pool5_D"
bottom: "pool5_mask"
upsample_param {
scale: 2
upsample_w: 30
upsample_h: 23
}
}

I wan to change the values to upsample_w : 45, upsample_h : 45 in order to enable neural network to accept images 720*720 as an input parameter. Could it be possible using two or more gpu?

Thank you in advance.

Add Severity Levels To Warnings

Upstream issue originally reported in groovecoder/discord#34.

Quoting the first comment:

It's be nice not to moderate the tone of the comments when a user is using good progressive enhancement techniques. For example: a box-radius that isn't supported is probably not going to be a problem but lack of support for display: flex could be pretty catastrophic.

Question about partial support

Very cool project. I have a quick question.

It says right there in the README that box-sizing isn't supported by IE8+ and I believe that's not entirely accurate.

If we check the caniuse db we'll see that IE8+ has partial support, meaning that they do support box-sizing but only when the values content-box (the default) and border-box are used.

Is the tool considering partial support when it makes a decision about a warning?

Thanks!

Wrong version reported

When running the following in part of a gulp build

            .pipe(postcss([doiuse({
                browsers: [
                    'ie 11'
                ],
                onFeatureUsage: function (usageInfo) {
                    console.log(usageInfo.message)
                }
            })]))

I get output such as index.css:3:81579: CSS3 2D Transforms not supported by: IE (8), Opera Mini (5.0-8.0) (transforms2d) despite specifying ie 11.

Any ideas?

Ignore a file based on name

Would it be possible to ask doiuse to ignore a file based on name? I have Normalize.css being imported via postcss-import, and as it has a lot of browser-specific fixes in there, it's upsetting doiuse.

I have seen that you've slowed down on development, and would be happy to open a PR if you think it's relatively feasible within the codebase.

Do not look for browserslist manually

Hi. I am author of PostCSS and Browserslist. Thanks for you project, it is really important for PostCSS.

It is great that you use Browserslist — common configs make our ecosystem stronger.

But I found that you use Browserslist with wrong API. You pass only browsers query and didn’t pass path option with input file. As result Browserslist doesn’t look for it config. You try to solve it by looking for browserslist config manually. But you parse it in wrong way, forget about comments.

As result, I have issue reports like this: browserslist/browserslist#135

But all this problems is very easy to solve — just pass path option to Browserslist and remove own code to find config. Less code is always better for maintenance. As result you will support many new features from Browserslist (config in package.json for instance).

@anandthakker say if you need PR for it

/cc @ch2ch3

`appearance: none` triggers a warning even though it's supported

Unexpected browser feature "css-appearance" is not supported by IE 11 and only partially
supported by Firefox 52,54, Chrome 49,58,59, Safari 10.1, Opera 46, iOS Safari 10.3, Chrome for
Android 59, Samsung Internet 4

appearance is not supported, but it's oftenly used as -webkit-appearance: none to disable browser's styles.

Is there any way to ignore appearance with this particular value none, but warn on other values?

GNU message format

PostCSS and many other tools use GNU error format: file:line:col, so them print

/projects/website/main.css:5:3: CSS3 Box-sizing not supported

instead of:

/projects/website/main.css: line 5, col 3 - CSS3 Box-sizing not supported

ignoreFiles crashes on atRule

Using ignoreFiles i get a crash with an atRule. Here's the usage object at https://github.com/anandthakker/doiuse/blob/v2.2.1/src/doiuse.js#L29 just before the crash:

{ usage: 
   AtRule {
     raws: { before: '\n\n' },
     name: 'font-face',
     type: 'atrule',
     nodes: [ [Object], [Object], [Object], [Object] ],
     parent: 
      Root {
        raws: [Object],
        type: 'root',
        nodes: [Object],
        source: [Object],
        lastEach: 35,
        indexes: [Object],
        rawCache: [Object],
        _autoprefixerDisabled: false,
        _autoprefixerPrefix: false },
     lastEach: 25,
     indexes: {},
     _autoprefixerDisabled: false },
  feature: 'font-unicode-range' }

and here's the shortened traceback:

events.js:141
      throw er; // Unhandled 'error' event
      ^
TypeError: Cannot read property 'input' of undefined
    at /home/cwygoda/Workspace/wygoda.net/node_modules/doiuse/lib/doiuse.js:46:51
    at Detector.atrule (/home/cwygoda/Workspace/wygoda.net/node_modules/doiuse/lib/detect-feature-use.js:86:13)
    at /home/cwygoda/Workspace/wygoda.net/node_modules/doiuse/lib/detect-feature-use.js:106:18
    at Root.each (/home/cwygoda/Workspace/sixbrick/node_modules/postcss/lib/container.js:60:22)
    at Detector.process (/home/cwygoda/Workspace/wygoda.net/node_modules/doiuse/lib/detect-feature-use.js:97:12)
    at postcss (/home/cwygoda/Workspace/wygoda.net/node_modules/doiuse/lib/doiuse.js:34:23)
    at LazyResult.run (/home/cwygoda/Workspace/sixbrick/node_modules/postcss/lib/lazy-result.js:206:20)

Here's my doiuse config:

{
    browsers: [
        'ie >= 10',
        '> 10%'
    ],
    ignore: [
        'rem'
    ],
    ignoreFiles: [
        '**/normalize.css'
    ]
}

I am not sure if this is an bug with the atRule object or the ignoreFiles code.

Add option to supress output via postcss warn

Hey,

i am using doiuse within a custom gulp based building system and it would be great to be able to supress any output from doiuse.

Would you accept a pull requestr for this?

cheers
Chris

Gulp not working

I have this simple task :

var postcss = require('gulp-postcss');
var doiuse = require('doiuse');

//Not working :(
gulp.task('doiuse', function(){
  return gulp.src("./src/css/**/*.css")
      .pipe(postcss([
          doiuse({
              browsers: [
                  'ie >= 8',
                  '> 1%'
              ],
              onFeatureUsage: function (usageInfo) {
                  console.log(usageInfo.message);
              }
          })
      ]));
});

and get the following error :

Error: Cannot find module 'postcss/lib/list'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (E:\Workspace\templates\corporate1\node_modules\doiuse\data\features.js:1:74)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

node v4.4.5
npm v2.15.5
gulp v3.9.1
gulp-postcss v6.1.1

Make doiuse to work with gulp

I have defined the following task:

var gulp = require("gulp");
var gulpPostCss = require('gulp-postcss');
var doiuse = require('doiuse');

gulp.task("doiuse", function () {
    gulp.src("./css/**/*.css")
        .pipe(gulpPostCss([
            doiuse({
                browsers: [
                    'ie >= 8',
                    '> 1%'
                ],
                onFeatureUsage: function (usageInfo) {
                    console.log(usageInfo.message);
                }
            })
        ]));
});

And when i run it i have the following result:

events.js:141
throw er; // Unhandled 'error' event
^
TypeError: css.prevMap.consumer is not a function
at __MY_DIR__\node_modules\doiuse\lib\doiuse.js:38:30
at Detector.decl (__MY_DIR__\node_modules\doiuse\lib\detect-feature-use.js:61:13)
at __MY_DIR__\node_modules\doiuse\lib\detect-feature-use.js:103:18
at Rule.each (__MY_DIR__\node_modules\gulp-postcss\node_modules\postcss\lib\container.js:59:22)
at Detector.process (__MY_DIR__\node_modules\doiuse\lib\detect-feature-use.js:97:12)
at Detector.rule (__MY_DIR__\node_modules\doiuse\lib\detect-feature-use.js:76:12)
at __MY_DIR__\node_modules\doiuse\lib\detect-feature-use.js:100:18
at Root.each (__MY_DIR__\node_modules\gulp-postcss\node_modules\postcss\lib\container.js:59:22)
at Detector.process (__MY_DIR__\node_modules\doiuse\lib\detect-feature-use.js:97:12)
at postcss (__MY_DIR__\node_modules\doiuse\lib\doiuse.js:32:23)

Process finished with exit code 1

Software versions:

node -v
v4.1.2

npm -v
3.3.5

running the API against multiple files

Hey again.

I've been using this excellent library to learn a bit more about streams in node. I set out to create a grunt plugin for this but I'm running into a lot of corners with the stream approach.

Essentially grunt gives us a lot of files in a nested array. Now I work with promises to resolve the callback hell I would otherwise get.

var done = this.async();

this.files.forEach(function targetLoop( files ) {

    //run DoIUse
    var promises = files.src.map(function(file) {
        return new Promise(function(resolve, reject) {

            Fs
                .createReadStream(file)
                .pipe( new Doiuse( OPTIONS.browsers ) )
                .on('data', resolve)
                .on('error', reject);

        });
    });


    Promise
        .all(promises)
        .then(function(usageInfos) {
            console.log("all of them done", usageInfos);

            done(true);
        }, function(err) {
            console.error("(At least) one of them failed", err);

            done(true);
        });

});

This unfortunately returns [css-tokenize] unfinished business [ [ 'root' ] ] and fails.
Any hint on what to archive this? I've been asking on stackoverflow too but I think this might be an issue directly related to your lib.

Feature: Ignore partial support

In my use of doiuse for Foundation, I have a lot of properties that are partially supported.

The most common are:

  • rem and transition by IE9/10
  • box-shadow and background-image options by Android Browser 2.3/3

Currently, there is so much partial support errors that the most important errors can be easily forgotten.

I don't need to have a full support of these old browsers, so the errors that must be shown are only the unsupported properties for these browsers, and the unsupported or partially supported properties for the newer browsers. I think it would be very useful to be able to ignore all partial support errors, or for a specific list of browsers.

For example, with gulp:

var gulp = require('gulp');
var postcss = require('gulp-postcss');
var doiuse = require('doiuse');

var COMPATIBILITY = [
  'last 2 versions',
  'ie >= 9',
  'Android >= 2.3',
  'ios >= 7'
];

var FULL_COMPATIBILITY = [
  'last 2 versions',
  'ie >= 10',
  'Android >= 4.0',
  'ios >= 7'
];

gulp.task('doiuse', function() {
  return gulp.src(['_build/assets/css/foundation.css'])
    .pipe(postcss([doiuse({
      browsers: COMPATIBILITY,
      partialSupport: true,
      partialSupportBrowsers: FULL_COMPATIBILITY,
      onFeatureUsage: function (usageInfo) {
        console.log(usageInfo.message)
      }
    })]))
});

Options:

  • browsers (default: {}): list of browsers used to search for unsupported features.
  • partialSupport (default: true): check for partially supported features.
  • partialSupportBrowsers (default: browsers): list of browsers used to search for partially supported features.

What do you think ?

Remove some browsers

How can I remove some browsers from the list of browsers being checked? For example for me Opera mini is not important so I don't want to get warnings for that.

TypeError: Cannot read property 'browsers' of undefined

        postcss: {
            options: {
                syntax: require('postcss-scss'),
                processors: [
                    require('autoprefixer')({ add: false}),
                    require('doiuse')(),
                ]
            },
            dist: {
                src: 'app/styles/app.css'
            }
        },

Getting an error

    postcss: {
        options: {
            syntax: require('postcss-scss'),
            processors: [
                require('doiuse')(),
            ]
        },
        dist: {
            src: 'app/styles/app.css'
        }
    },

error

❯ grunt postcss
Loading "Gruntfile.js" tasks...ERROR

TypeError: Cannot read property 'browsers' of undefined
No "postcss" targets found.
Warning: Task "postcss" failed. Use --force to continue.

Aborted due to warnings.

Port to ES6

Now that I've found [6to5], there's really no reason to write coffeescript anymore :)

Tag recent releases

Seems that last year releases that were published to npm, were tagged, while for example the latest 0.3.2 is not.

Please tag them releases so it will be easier to see a diff between them

Support source maps

We use stylus to compile to a single css file.
Unfortunately that means we currently get all doiuse warnings without reference to the actual source. (Everything displays like :1:2037: Some warning)

The browser is able to show the correct Stylus line numbers and file names.

The CSS file contains the sourcemap starting with

/*# sourceMappingURL=data:application/json;base64,

rem unit not supported but fallback provided

I'm using the pixrem PostCSS plugin, which transforms this:

.sky {
  margin: 2.5rem 2px 3em 100%;
}

into this:

.sky {
  margin: 80px 2px 3em 100%;
  margin: 2.5rem 2px 3em 100%;
}

Unfortunately, doiuse still reports an error, I assume it's not noticing a fallback was provided and choking on the second rule?

rem (root em) units not supported by: IE (8,9,10)

Thanks

doiuse does not report anything when run as stream in a node script

If I run doiuse from the CLI with doiuse --browsers '> 1%' tmp.css it works fine, but when I try running doiuse in a script it reports nothing:

var fs = require('fs');
var doiuse = require('doiuse/stream');

fs.createReadStream('tmp.css')
  .pipe(doiuse(['> 1%']))
  .on('data', function(usageInfo) {
    console.log(usageInfo);
  });

I'm using v1.0.2.

"Invalid non-string/buffer chunk" when using stream API

I'm trying to use doiuse from gulp, but I don't use postcss. So I came up with this:

const doiuse = require("doiuse/stream");

gulp.task("doiuse", [ "sass" ], function() {
  return gulp.src("source/assets/css/main.css")
    .pipe(doiuse({
      browsers: [ "> 1%" ]
    }))
    .on("data", info => console.log(JSON.stringify(info)));
});

It looks like that's what it wants me to do, looking at the documentation. But here's what I get:

[17:06:45] Using gulpfile d:\Klanten\qsdashboard\gulpfile.js
[17:06:45] Starting 'sass'...
[17:06:46] Finished 'sass' after 97 ms
[17:06:46] Starting 'doiuse'...
[17:06:46] 'doiuse' errored after 56 ms
[17:06:46] TypeError: Invalid non-string/buffer chunk
    at validChunk (d:\Klanten\qsdashboard\node_modules\css-tokenize\node_modules\readable-stream\lib\_stream_writable.js:180:14)
    at Tokenize.Writable.write (d:\Klanten\qsdashboard\node_modules\css-tokenize\node_modules\readable-stream\lib\_stream_writable.js:209:12)
    at DuplexWrapper._write (d:\Klanten\qsdashboard\node_modules\duplexer2\index.js:57:18)
    at doWrite (d:\Klanten\qsdashboard\node_modules\duplexer2\node_modules\readable-stream\lib\_stream_writable.js:279:12)
    at writeOrBuffer (d:\Klanten\qsdashboard\node_modules\duplexer2\node_modules\readable-stream\lib\_stream_writable.js:266:5)
    at DuplexWrapper.Writable.write (d:\Klanten\qsdashboard\node_modules\duplexer2\node_modules\readable-stream\lib\_stream_writable.js:211:11)
    at DuplexWrapper._write (d:\Klanten\qsdashboard\node_modules\duplexer2\index.js:57:18)
    at doWrite (d:\Klanten\qsdashboard\node_modules\duplexer2\node_modules\readable-stream\lib\_stream_writable.js:279:12)
    at writeOrBuffer (d:\Klanten\qsdashboard\node_modules\duplexer2\node_modules\readable-stream\lib\_stream_writable.js:266:5)
    at DuplexWrapper.Writable.write (d:\Klanten\qsdashboard\node_modules\duplexer2\node_modules\readable-stream\lib\_stream_writable.js:211:11)
    at write (d:\Klanten\qsdashboard\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:623:24)
    at flow (d:\Klanten\qsdashboard\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (d:\Klanten\qsdashboard\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:664:5)
    at emitNone (events.js:86:13)
    at DestroyableTransform.emit (events.js:188:7)
    at emitReadable_ (d:\Klanten\qsdashboard\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:448:10)

Versions:
Node 7.7.2
NPM 4.1.2
Gulp 3.9.1
Doiuse 2.5.0
Windows 10

Expose more metadata

Firstly, thanks for such a useful tool!

We wrap it in stylelint as the no-unsupported-browser-features rule.

At the moment we pull doiuse's messages apart so we can make them consistent with stylelint's conventions, but this approach is quite fragile.

Would it be possible to expose the browser support results within the doiuse warning? stylehacks (which we wrap as the no-browser-hacks rule) did it like so, and we simply consume this extra metadata like so.

I think something along the lines of the following would be ideal:

result.warn(message, { 
  node: usage, 
  plugin: 'doiuse'
  support: {
    full: [{
      browser: "IE",
      versions: [7, 8, 9]
    }, {
      browser: "Chrome",
      version: [23, 34]
    }],
    partial: [{
      browser: "Opera Mini",
      versions: [1, 2, 3]
    }], 
})

Do you think such a thing would be possible?

Combine report output of prefixed properties to a single line

CSS:

-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;

doiuse 2.0.2 reports the same incompatibilities for each line:

test.css:1:1: CSS Hyphenation not supported by: IE (8,9), Chrome (42,43), Opera (29,30,12.1), Opera Mini (5.0-8.0), Android Browser (4.2-4.3,4.4,4.4.3-4.4.4), Chrome for Android (42), IE Mobile (10,11), UC Browser for Android (9.9)
test.css:2:1: CSS Hyphenation not supported by: IE (8,9), Chrome (42,43), Opera (29,30,12.1), Opera Mini (5.0-8.0), Android Browser (4.2-4.3,4.4,4.4.3-4.4.4), Chrome for Android (42), IE Mobile (10,11), UC Browser for Android (9.9)
test.css:3:1: CSS Hyphenation not supported by: IE (8,9), Chrome (42,43), Opera (29,30,12.1), Opera Mini (5.0-8.0), Android Browser (4.2-4.3,4.4,4.4.3-4.4.4), Chrome for Android (42), IE Mobile (10,11), UC Browser for Android (9.9)
test.css:4:1: CSS Hyphenation not supported by: IE (8,9), Chrome (42,43), Opera (29,30,12.1), Opera Mini (5.0-8.0), Android Browser (4.2-4.3,4.4,4.4.3-4.4.4), Chrome for Android (42), IE Mobile (10,11), UC Browser for Android (9.9)

It would be much better to batch the identical report output to a single line that prints once after the block of prefix properties. So it looks more like this:

test.css:1-4:1: CSS Hyphenation not supported by: IE (8,9), Chrome (42,43), Opera (29,30,12.1), Opera Mini (5.0-8.0), Android Browser (4.2-4.3,4.4,4.4.3-4.4.4), Chrome for Android (42), IE Mobile (10,11), UC Browser for Android (9.9)

on issues the doiuse CLI should exit the process with an exit code > 0

Currently even if the cli finds an issue with your css file it doesn't exit properly making it impossible to track for issues via shell (this should also apply to the postcss processor). Basically the cli's process should exit with an exit code greater than 0 and the postcss processor should notify postcss of the issues so it can exit it's process.

Add link to browserslist docs to readme

I'm missing browser query documentation.

I have no way of knowing what sort of syntax the browser query supports, what browser names it knows, and how to specify which (if any) versions to test against.

So can we please have some documentation on this?

Notice: doiuse.com expiring

My registration of the doiuse.com domain name expires in about a week and a half, and I'm going to allow it to do so. Happy to transfer it, though, if someone else wants it.

Use with scss (sass), aspect of third-party code processed too ..?

Hi.

AMAZING project in concept.

I was just wondering, if i use a preprocessor such as sass for example, I suppose I could lint the produced css, ok.
But what if we include lot of third parties in our scss/sass too , such as whole libraries like Bootstrap which obviously will throw warnings I, as a dev, don't care of ?

Should I necessarly produce "only" my app specific code to some place to lint it ?

Or will features be detected etc. in "native" sass/scss simply without problem in the first place?? Would I obligatory need to use something like postcss-scss to parse it ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.