Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Pass through --fix to stylelint options
Browse files Browse the repository at this point in the history
Fixes #91
  • Loading branch information
edg2s committed Aug 3, 2020
1 parent d86ff77 commit 91e2e4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ grunt.initConfig( {
failOnError: true,
outputFile: '',
reportNeedlessDisables: false,
fix: false,
syntax: ''
},
src: [
Expand Down Expand Up @@ -104,6 +105,12 @@ Default value: `true`

Whether to fail if stylelint detects an error.

#### syntax
Type: `boolean`
Default value: `false`

Automatically fix, where possible, violations reported by rules. If `grunt` is run with `--fix` and this is not explicitly set, it will be set to `true`.

#### syntax
Type: `string`
Values: `"scss"`|`"less"`|`"sugarss"`
Expand Down
8 changes: 6 additions & 2 deletions tasks/grunt-stylelint.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ module.exports = function ( grunt ) {
const options = this.options(),
done = this.async(),
styleLint = require( 'stylelint' ),
verbose = !!grunt.option( 'verbose' );
verbose = !!grunt.option( 'verbose' ),
fix = !!grunt.option( 'fix' );

options.failOnError = ( typeof options.failOnError !== 'undefined' ) ? options.failOnError : true;
options.failOnError = options.failOnError !== undefined ? options.failOnError : true;

options.fix = options.fix !== undefined ? options.fix : fix;

options.files = this.filesSrc.filter( function ( file ) {
return grunt.file.isFile( file );
} );

options.formatter = options.formatter || ( verbose ? 'verbose' : 'string' );

// Explicitly allow no files, as otherwise stylelint itself throws an error.
Expand Down

0 comments on commit 91e2e4a

Please sign in to comment.