Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(plugins): build no failed, if plugin warnings #26

Open
Kristinita opened this issue Feb 17, 2019 · 0 comments
Open

bug(plugins): build no failed, if plugin warnings #26

Kristinita opened this issue Feb 17, 2019 · 0 comments

Comments

@Kristinita
Copy link
Contributor

1. Summary

Docs says:

By default, if any of your PostCSS plugins raise a warning it will be displayed using console.error. You can override this behavior by passing a function as the second argument to PostStylus.

But if PostCSS doiuse plugin show warnings, build no failed.

2. Environment

  • Operating system:

    • Windows 10 Enterprise LTSB 64-bit EN (local)
    • Ubuntu 14.04.5 LTS (Travis CI)
  • package.json:

{
  "devDependencies": {
    "doiuse": "^4.2.0",
    "grunt": "^1.0.3",
    "grunt-contrib-stylus": "^1.2.0",
    "grunt-postcss": "^0.9.0",
    "poststylus": "^1.0.0"
  }
}

3. MCVE

3.1. Live demo

3.2. Data

  • Gruntfile.coffee:
# [INFO] Passing plugins arguments:
# https://www.npmjs.com/package/poststylus#passing-arguments-to-plugins
doiuse = require('doiuse')

# [INFO] PostStylus Grunt usage:
# https://www.npmjs.com/package/poststylus#grunt
postcss = ->
    require('poststylus') [
        # [INFO] doiuse options:
        # https://www.npmjs.com/package/doiuse#as-a-postcss-plugin
        doiuse(browsers: ['last 1 version'])
    ]

module.exports = (grunt) ->
    grunt.initConfig
        stylus:
            lint:
                options:
                    use: [postcss]
                files: 'KiraGoddess.css': 'KiraGoddess.styl'
        # [INFO] PostCSS equivalent
        postcss:
            lint:
                options:
                    failOnError: true
                    map: false
                    processors: [
                        require('doiuse')(browsers: ['last 1 version'])
                    ]
                files: 'KiraGoddess.css': 'KiraGoddess.css'

    grunt.loadNpmTasks 'grunt-contrib-stylus'
    grunt.loadNpmTasks 'grunt-postcss'
    return
  • KiraGoddess.styl:
.KiraClass
    tab-size 4
  • KiraGoddess.css:
.KiraClass {
    tab-size: 4
}

3.3. Steps to reproduce

grunt stylus --verbose
grunt postcss --verbose

4. Expected behavior

For PostCSS equivalent command build failed:

Running "postcss:lint" (postcss) task
Verifying property postcss.lint exists in config…OK
Files: KiraGoddess.css -> KiraGoddess.css
Options: processors=[{}], map=false, diff=false, safe=false, failOnError, writeDest
Reading KiraGoddess.css…OK
>> doiuse: /home/travis/build/Kristinita/SashaGruntDebugging/KiraGoddess.css:1:12: CSS3 tab-size not supported by: IE (11), Edge (18), IE Mobile (11) and only partially supported by: Safari (12), iOS Safari (12.0-12.1), Opera Mini (all), Blackberry Browser (10) (css3-tabsize)
Writing KiraGoddess.css…OK
File KiraGoddess.css created.
>> 1 processed stylesheet created.
>> 1 issue found.
Warning: Task "postcss:lint" failed. Use --force to continue.

Aborted due to warnings.
The command "grunt postcss --verbose" exited with 3.

5. Actual behavior

For PostStylus command build passed:

Running "stylus:lint" (stylus) task
Verifying property stylus.lint exists in config…OK
Files: KiraGoddess.styl -> KiraGoddess.css
Options: banner="", compress, use=[null]
Reading KiraGoddess.styl…OK
Warning {
  type: 'warning',
  text:
   'CSS3 tab-size not supported by: IE (11), Edge (18), IE Mobile (11) and only partially supported by: Safari (12), iOS Safari (12.0-12.1), Opera Mini (all), Blackberry Browser (10) (css3-tabsize)',
  line: 1,
  column: 12,
  node:
   Declaration {
     raws: { before: '', between: ':' },
     type: 'decl',
     parent:
      Rule {
        raws: [Object],
        type: 'rule',
        nodes: [Array],
        parent: [Root],
        source: [Object],
        selector: '.KiraClass',
        lastEach: 2,
        indexes: {} },
     source: { start: [Object], input: [Input], end: [Object] },
     prop: 'tab-size',
     value: '4' },
  plugin: 'doiuse' } 0 [ Warning {
    type: 'warning',
    text:
     'CSS3 tab-size not supported by: IE (11), Edge (18), IE Mobile (11) and only partially supported by: Safari (12), iOS Safari (12.0-12.1), Opera Mini (all), Blackberry Browser (10) (css3-tabsize)',
    line: 1,
    column: 12,
    node:
     Declaration {
       raws: [Object],
       type: 'decl',
       parent: [Rule],
       source: [Object],
       prop: 'tab-size',
       value: '4' },
    plugin: 'doiuse' } ]
Writing KiraGoddess.css…OK
File KiraGoddess.css created.
>> 1 file created.
Done.
The command "grunt stylus --verbose" exited with 0.

6. Not helped

6.1. failOnError: true

I didn't find in PostStylus documentation setting, similar as failOnError: true of Grunt PostCSS. For example, this configuration doesn't solve the problem.

doiuse = require('doiuse')

postcss = ->
    require('poststylus') [
        doiuse(browsers:['last 1 version'],
                failOnError: true,
                options:
                    failOnError: true)
    ]

module.exports = (grunt) ->
    grunt.initConfig
        stylus:
            lint:
                options:
                    use: [postcss]
                    failOnError: true
                files: 'KiraGoddess.css': 'Kira.styl'

    grunt.loadNpmTasks 'grunt-contrib-stylus'
    return

6.2. Warning Handler

console.error in examples as below also doesn't solve the problem.

doiuse = require('doiuse')

postcss = ->
    require('poststylus') [
        doiuse(browsers:['last 1 version'])
        (message) ->
            console.error message
            return
    ]

module.exports = (grunt) ->
    grunt.initConfig
        stylus:
            lint:
                options:
                    use: [postcss]
                files: 'KiraGoddess.css': 'KiraGoddess.styl'

    grunt.loadNpmTasks 'grunt-contrib-stylus'
    return

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant