├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .sass-lint.yml ├── .travis.yml ├── Gruntfile.js ├── LICENSE ├── license ├── package.json ├── readme.md ├── tasks └── sass-lint.js └── test ├── fixtures ├── test1.scss └── test2.scss └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [package.json] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | report.xml 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 28 | node_modules 29 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 4, 10 | "newcap": true, 11 | "noarg": true, 12 | "quotmark": "single", 13 | "undef": true, 14 | "unused": "vars", 15 | "strict": true 16 | } 17 | -------------------------------------------------------------------------------- /.sass-lint.yml: -------------------------------------------------------------------------------- 1 | files: 2 | include: '**/*.s+(a|c)ss' 3 | ignore: 4 | rules: 5 | # Consistency Rules 6 | extends-before-mixins: 1 7 | extends-before-declarations: 1 8 | mixins-before-declarations: 1 9 | # Require an empty line between blocks 10 | empty-line-between-blocks: 0 11 | no-empty-rulesets: 1 12 | final-newline: 1 13 | no-ids: 1 14 | indentation: 0 15 | leading-zero: 1 16 | name-format: 0 17 | nesting-depth: 0 18 | placeholder-in-extend: 1 19 | property-sort-order: 1 20 | property-spelling: 0 21 | shorthand: 0 22 | one-declaration-per-line: 1 23 | single-line-per-selector: 1 24 | space-after-comma: 1 25 | # Space surrounding colons 26 | space-before-colon: 1 27 | space-after-colon: 1 28 | 29 | space-before-brace: 1 30 | 31 | space-between-parens: 1 32 | trailing-semicolon: 1 33 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - 'iojs' 5 | - '0.12' 6 | - '0.10' 7 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = function (grunt) { 3 | grunt.initConfig({ 4 | sasslint: { 5 | options: { 6 | configFile: 'config/.sass-lint.yml', 7 | formatter: 'junit', 8 | outputFile: 'report.xml' 9 | }, 10 | test: [ 11 | 'test/fixtures/*.scss' 12 | ] 13 | }, 14 | nodeunit: { 15 | tasks: ['test/test.js'] 16 | } 17 | }); 18 | 19 | grunt.loadTasks('tasks'); 20 | grunt.loadNpmTasks('grunt-contrib-clean'); 21 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 22 | 23 | grunt.registerTask('default', ['sasslint']); 24 | }; 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 sasstools 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 sasstools 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-sass-lint", 3 | "version": "0.2.4", 4 | "description": "Lint your sass using Node Sass Lint", 5 | "license": "MIT", 6 | "repository": "sasstools/grunt-sass-lint", 7 | "author": { 8 | "name": "Micah Godbolt", 9 | "email": "micahgodbolt@gmail.com" 10 | }, 11 | "engines": { 12 | "node": ">=0.10.0" 13 | }, 14 | "scripts": { 15 | "test": "grunt" 16 | }, 17 | "files": [ 18 | "tasks" 19 | ], 20 | "keywords": [ 21 | "gruntplugin", 22 | "sass", 23 | "scss", 24 | "lint" 25 | ], 26 | "dependencies": { 27 | "sass-lint": "^1.12.0" 28 | }, 29 | "devDependencies": { 30 | "grunt": "^0.4.5", 31 | "grunt-cli": "^0.1.13", 32 | "grunt-contrib-clean": "^0.6.0", 33 | "grunt-contrib-nodeunit": "^0.4.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Grunt Sass Lint 2 | 3 | [Grunt](http://gruntjs.com/) plugin for [Sass Lint](https://github.com/sasstools/sass-lint). 4 | 5 | ## Install 6 | 7 | ``` 8 | npm install grunt-sass-lint --save-dev 9 | ``` 10 | 11 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 12 | 13 | ``` 14 | grunt.loadNpmTasks('grunt-sass-lint'); 15 | ``` 16 | 17 | ## Examples 18 | ```js 19 | grunt.initConfig({ 20 | sasslint: { 21 | options: { 22 | configFile: 'config/.sass-lint.yml', 23 | }, 24 | target: ['location/\*.scss', 'other_location/\*.scss'] 25 | } 26 | }); 27 | ``` 28 | 29 | ```js 30 | grunt.initConfig({ 31 | sasslint: { 32 | options: { 33 | configFile: 'config/.sass-lint.yml', 34 | formatter: 'junit', 35 | outputFile: 'report.xml' 36 | }, 37 | target: ['location/*.scss'] 38 | } 39 | }); 40 | ``` 41 | 42 | ## Options 43 | See the [sass-lint options](https://github.com/sasstools/sass-lint#options). 44 | 45 | In addition the following options are supported: 46 | ### configFile 47 | 48 | Type: `string` 49 | Default: `` 50 | 51 | Will fallback to `.sass-lint.yml` or the file location set at the `"sasslintConfig"` key inside of `package.json` 52 | 53 | ### formatter 54 | 55 | Type: `string` 56 | Default: `stylish` 57 | 58 | Changes the output format of the generated reports. See https://github.com/eslint/eslint/tree/master/lib/formatters for available formatters. 59 | 60 | ### outputFile 61 | 62 | Type: `string` 63 | Default: `` 64 | 65 | Will save the generated output to disk instead of command line. 66 | -------------------------------------------------------------------------------- /tasks/sass-lint.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'), 3 | lint = require('sass-lint'); 4 | 5 | module.exports = function (grunt) { 6 | grunt.verbose.writeln('\n' + lint.info + '\n'); 7 | 8 | grunt.registerMultiTask('sasslint', 'Lint your Sass', function () { 9 | var opts = this.options({ 10 | configFile: '' 11 | }); 12 | var results = []; 13 | 14 | this.filesSrc.forEach(function (file) { 15 | results = results.concat(lint.lintFiles(file, opts, opts.configFile)); 16 | }); 17 | 18 | var resultCount = lint.resultCount(results), 19 | errorCount = lint.errorCount(results), 20 | resultFormat = lint.format(results, { options: opts }); 21 | 22 | if (resultCount > 0) { 23 | if(opts['outputFile']) { 24 | opts['output-file'] = opts['outputFile']; 25 | lint.outputResults(results, { options: opts }); 26 | } else { 27 | grunt.log.writeln(resultFormat); 28 | } 29 | if (errorCount.count > 0) grunt.fail.warn(''); 30 | } 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /test/fixtures/test1.scss: -------------------------------------------------------------------------------- 1 | div { 2 | color: blue; 3 | span { 4 | color: green; 5 | } 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/fixtures/test2.scss: -------------------------------------------------------------------------------- 1 | div { 2 | color: blue; 3 | 4 | span { 5 | color: green; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var grunt = require('grunt'); 3 | 4 | exports.sasslint = { 5 | test: function (test) { 6 | 7 | } 8 | }; 9 | --------------------------------------------------------------------------------