diff --git a/.jscsrc b/.jscsrc index 90a26c0..b8c3c54 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,46 +1,34 @@ { - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch", - "case", - "default" - ], - "requireSpaceAfterKeywords": [ - "if", - "else", - "for", - "while", - "do", - "switch", - "return", - "try", - "catch" - ], + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "requireSpaceBeforeBlockStatements": true, "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": { + "afterTest": true, + "beforeConsequent": true, + "afterConsequent": true, + "beforeAlternate": true + }, "requireSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, "requireMultipleVarDecl": true, "requireBlocksOnNewline": true, + "disallowPaddingNewlinesInBlocks": true, "disallowEmptyBlocks": true, - "disallowSpacesInsideObjectBrackets": true, - "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideObjectBrackets": "all", + "disallowSpacesInsideArrayBrackets": "all", "disallowSpacesInsideParentheses": true, "disallowSpaceAfterObjectKeys": true, "requireCommaBeforeLineBreak": true, "requireOperatorBeforeLineBreak": [ "?", + "=", "+", "-", "/", "*", - "=", "==", "===", "!=", @@ -50,13 +38,15 @@ "<", "<=" ], - "disallowLeftStickedOperators": [ + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforeBinaryOperators": [ "?", + "=", "+", "-", "/", "*", - "=", "==", "===", "!=", @@ -66,14 +56,13 @@ "<", "<=" ], - "requireRightStickedOperators": ["!"], - "disallowRightStickedOperators": [ + "requireSpaceAfterBinaryOperators": [ "?", + "=", "+", + "-", "/", "*", - ":", - "=", "==", "===", "!=", @@ -83,36 +72,22 @@ "<", "<=" ], - "requireLeftStickedOperators": [","], - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "requireSpaceBeforeBinaryOperators": [ - "+", - "-", - "/", - "*", - "=", - "==", - "===", - "!=", - "!==" - ], - "requireSpaceAfterBinaryOperators": [ - "+", - "-", - "/", - "*", - "=", - "==", - "===", - "!=", - "!==" - ], "requireCamelCaseOrUpperCaseIdentifiers": true, "disallowKeywords": ["with"], "disallowMultipleLineBreaks": true, + "validateQuoteMarks": "'", + "validateIndentation": 2, "disallowMixedSpacesAndTabs": true, + "disallowTrailingComma": true, "disallowKeywordsOnNewLine": ["else"], + "maximumLineLength": 120, + "requireCapitalizedConstructors": true, + "safeContextKeyword": ["that"], "disallowYodaConditions": true, - "excludeFiles": ["node_modules/**"] -} \ No newline at end of file + "validateJSDoc": { + "checkParamNames": true, + "checkRedundantParams": true, + "requireParamTypes": true + }, + "requireSpaceAfterLineComment": true +} diff --git a/Gruntfile.js b/Gruntfile.js index a5c039f..03af88f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -41,7 +41,7 @@ module.exports = function (grunt) { }, files: [{ src: [ - 'test/fixtures/fail.scss', + 'test/fixtures/fail.scss' ] }] } @@ -57,7 +57,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-internal'); grunt.loadNpmTasks('grunt-contrib-nodeunit'); - grunt.loadNpmTasks('grunt-jscs-checker'); + grunt.loadNpmTasks('grunt-jscs'); grunt.registerTask('test', ['jscs', 'jshint', 'nodeunit']); diff --git a/README.md b/README.md index c62d28a..b3ba85e 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,13 @@ Emits a Grunt event on scss-lint error called `scss-lint-error`. Set `force` to `true` to report scss-lint errors but not fail the task. +#### maxBuffer + +- Type: `Number` or `Boolean` +- Default: `300 * 1024` + +Set `maxBuffer` for the `child_process.exec` process, [if you're linting a lot of files and you're recieving no output](https://github.com/ahmednuaman/grunt-scss-lint/issues/63) then you can try and increase this value. Setting it to `false`, `0`, `NaN` or `Infinite` will not return any `stdout` or `stderr` and the task will think that everything's fine. + ### Usage Examples #### Example config diff --git a/package.json b/package.json index 907b650..723f41e 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ }, "dependencies": { "lodash": "2.4.1", - "xmlbuilder": "2.2.1", - "chalk": "0.4.0" + "xmlbuilder": "2.4.3", + "chalk": "0.5.1" }, "devDependencies": { "grunt-contrib-jshint": "0.10.0", "grunt-contrib-nodeunit": "0.4.1", "grunt-contrib-internal": "0.4.10", - "grunt-jscs-checker": "0.4.1", + "grunt-jscs": "0.6.2", "grunt": ">=0.4.5" }, "peerDependencies": { diff --git a/tasks/lib/scss-lint.js b/tasks/lib/scss-lint.js index 0e42890..185c190 100644 --- a/tasks/lib/scss-lint.js +++ b/tasks/lib/scss-lint.js @@ -16,7 +16,7 @@ exports.init = function (grunt) { return; } - results = (results.length !== 0) ? results.split("\n") : []; + results = (results.length !== 0) ? results.split('\n') : []; xml = xmlBuilder.create('testsuites'); @@ -62,7 +62,7 @@ exports.init = function (grunt) { matches; results = chalk.stripColor(results); - results = (results.length !== 0) ? results.split("\n") : []; + results = results.length !== 0 ? results.split('\n') : []; _.forEach(results, function (result) { if (result === '') { @@ -150,7 +150,7 @@ exports.init = function (grunt) { } child = exec(args.join(' '), { - maxBuffer: 300 * 1024, + maxBuffer: options.maxBuffer, cwd: process.cwd(), env: env }, function (err, results, code) { diff --git a/tasks/scss-lint.js b/tasks/scss-lint.js index f56c6cf..a474194 100644 --- a/tasks/scss-lint.js +++ b/tasks/scss-lint.js @@ -16,7 +16,8 @@ module.exports = function (grunt) { bundleExec: false, colorizeOutput: true, compact: false, - force: false + force: false, + maxBuffer: 300 * 1024 }); grunt.verbose.writeflags(opts, 'scss-lint options'); diff --git a/test/scss-lint-test.js b/test/scss-lint-test.js index d978948..8500d09 100644 --- a/test/scss-lint-test.js +++ b/test/scss-lint-test.js @@ -7,7 +7,7 @@ var path = require('path'), fixtures = path.join(__dirname, 'fixtures'), reporterOutFile = path.join(__dirname, 'output.xml'), escapeRe = function (str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); }, defaultOptions; @@ -25,7 +25,7 @@ exports.scsslint = { test.expect(5); var files = path.join(fixtures, 'fail.scss'); scsslint.lint(files, defaultOptions, function (results) { - results = results.split("\n"); + results = results.split('\n'); test.ok( results[0].indexOf('Class `Button` in selector should be written in all lowercase as `button`') !== -1, 'Should report bad case.' @@ -64,9 +64,9 @@ exports.scsslint = { stdout = [], testOptions; - testOptions = _.assign({}, defaultOptions, { - force: true - }); + testOptions = _.assign({}, defaultOptions, { + force: true + }); grunt.log.muted = false; @@ -78,7 +78,6 @@ exports.scsslint = { }); scsslint.lint(files, testOptions, function (results) { - grunt.option('debug', undefined); hooker.unhook(process.stdout, 'write'); grunt.log.muted = muted; @@ -110,6 +109,7 @@ exports.scsslint = { }); grunt.option('debug', true); + scsslint.lint(files, defaultOptions, function () { grunt.option('debug', undefined); hooker.unhook(process.stdout, 'write'); @@ -186,7 +186,7 @@ exports.scsslint = { scsslint.lint(files, testOptions, function (results) { var report = grunt.file.read(reporterOutFile); - results = results.split("\n"); + results = results.split('\n'); test.ok(report.indexOf(results[0]) !== -1, 'Should write the errors out to a report'); @@ -206,7 +206,6 @@ exports.scsslint = { }); scsslint.lint(files, testOptions, function (results) { - var report = grunt.file.read(reporterOutFile); test.ok(report.indexOf('errors="0"') !== -1, @@ -228,7 +227,7 @@ exports.scsslint = { scsslint.lint(file, testOptions, function (results) { var styles = chalk.styles; - results = results.split("\n")[0]; + results = results.split('\n')[0]; test.ok( results.indexOf(styles.cyan.open + file) !== -1, @@ -257,8 +256,7 @@ exports.scsslint = { }); scsslint.lint([file1, file2], testOptions, function (results) { - - results = results.split("\n"); + results = results.split('\n'); test.ok( results[1].indexOf(file1) !== -1, @@ -298,7 +296,7 @@ exports.scsslint = { scsslint.lint([file1, file2], testOptions, function (results) { var styles = chalk.styles; - results = results.split("\n"); + results = results.split('\n'); test.ok( results[1].indexOf(styles.bold.open + file1) !== -1, @@ -382,7 +380,7 @@ exports.scsslint = { }); scsslint.lint(file1, testOptions, function (results) { - results = results.split("\n"); + results = results.split('\n'); test.ok(results.length === 4); test.done(); }); @@ -390,7 +388,7 @@ exports.scsslint = { exitCodeOnFailure: function (test) { test.expect(1); - grunt.util.spawn({grunt: true, args: ["scsslint"]}, function (error, result, code) { + grunt.util.spawn({grunt: true, args: ['scsslint']}, function (error, result, code) { test.notEqual(code, 0); test.done(); }); @@ -398,18 +396,33 @@ exports.scsslint = { exitCodeAndOutputOnMissingRuby: function (test) { test.expect(2); - grunt.util.spawn({grunt: true, args: ["scsslint"], opts: {env: {PATH: "."}}}, function (error, result, code) { + grunt.util.spawn({grunt: true, args: ['scsslint'], opts: {env: {PATH: '.'}}}, function (error, result, code) { test.notEqual(code, 0); - test.ok(result.stdout.match("Please make sure you have ruby installed")); + test.ok(result.stdout.match('Please make sure you have ruby installed')); test.done(); }); }, exitCodeOnSuccess: function (test) { test.expect(1); - grunt.util.spawn({grunt: true, args: ["scsslint:success"]}, function (error, result, code) { + grunt.util.spawn({grunt: true, args: ['scsslint:success']}, function (error, result, code) { test.equal(code, 0); test.done(); }); + }, + + maxBuffer: function (test) { + test.expect(1); + var files = path.join(fixtures, 'fail.scss'), + testOptions; + + testOptions = _.assign({}, defaultOptions, { + maxBuffer: false + }); + + scsslint.lint(files, testOptions, function (results) { + test.ok(!results, 'There should be no lint errors'); + test.done(); + }); } };