Paddy
Paddy

Reputation: 3630

How to continue if grunt-contrib-csslint throws error and how to exclude some files?


I tried specifying force: true for grunt-contrib-csslint to continue even if error occurs as follows, but it does not seem to work, kindly help.

module.exports = function (grunt) {
    grunt.initConfig({

    // define source files and their destinations
    csslint:{
       options: {
           force: true,
           absoluteFilePathsForFormatters: true,
           formatters: [
               {id: 'compact', dest: 'quality/report/css/compact.xml'}
           ]
       },
       strict:{
           options:{
               force: true,
               import:2,
               "box-model":false,
           },
           src:['src/main/webapp/public/css/*.css'],
       },
       lax: {
            options: {
                import: false
            },
       src: ['src/main/webapp/public/css/ng-grid.css']
      }
   }
   });
   // load plugins
   grunt.loadNpmTasks('grunt-contrib-csslint');

       // register at least this one task
       grunt.registerTask('default', [ 'csslint' ]);
       };
       }};

The 'lax' property also does not seem to work and it still picks the files specified there? Kindly point out the problem with this also.

Thanks,
Paddy

Upvotes: 2

Views: 2978

Answers (4)

jsmik14
jsmik14

Reputation: 61

There is a npm package for running a specific task with force mode, so you don't have to use the force option globally.

It's called 'grunt-force-task' and can be found here: https://github.com/floriangosse/grunt-force-task

A solution for the csslint-question would look like this:

grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.registerTask('default', [ 'force:csslint' ]);

Besides that running a specific task with force flag is in discussion in the grunt main repository atm. Maybe there will be some changes to grunt itself in the future. See: https://github.com/gruntjs/grunt/issues/810

Upvotes: 0

l3x
l3x

Reputation: 31236

You can exclude certain files using "!" in the csslint:check:src array as follows:

    csslint: {
        options: {
            csslintrc: '.csslintrc'
        },
        check: {
            src: [
                '<%= yeoman.app %>/css/**/*.css',
                '!<%= yeoman.app %>/_scss/**/*.scss'
            ]
        }
    },

In the case above (from the Grunfile.js file) we're telling grunt to process .css files, but to ignore .scss files.

Upvotes: 0

mpon
mpon

Reputation: 106

To insert the following code in registerTask. You cannot set force option for csslint but you can set force option for grunt.

// set the grunt force option
grunt.option("force", true);

// register at least this one task
grunt.registerTask('default', [ 'csslint' ]);

Upvotes: 4

Ludder
Ludder

Reputation: 2733

To just run the lax option try:

grunt.registerTask('default', [ 'csslint:lax' ]);

If you want Grunt to continue on errors, run:

grunt --force

Upvotes: 0

Related Questions