diff --git a/README.md b/README.md index eb49c781..900b26da 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ For all [rules](https://github.com/sasstools/sass-lint/tree/master/docs/rules), If you want to configure options, set the rule to an array, where the first item in the array is the severity, and the second item in the array is an object including the options you would like to set. -Here is an example configuration of a rule, where we are specifying that breaking the [indentation rule](https://github.com/sasstools/sass-lint/blob/master/docs/rules/indentation.md) should be treated as an error (its severity set to two), and setting the `size` option of the rule to 2 spaces: +Here is an example configuration of a rule, where we are specifying that breaking the [indentation rule](https://github.com/sasstools/sass-lint/blob/master/docs/rules/indentation.md) should be treated as an error (its severity set to two), and setting the `size` option of the rule to 2 spaces: ```yml rules: @@ -127,6 +127,15 @@ p { } ``` +### Disable a rule for text next line + +```scss +p { + // sass-lint:disable-next-line border-zero + border: none; +} +``` + ### Disable all lints within a block (and all contained blocks) ```scss diff --git a/docs/toggle-rules-in-src.md b/docs/toggle-rules-in-src.md index 05e5ba78..c5755d98 100644 --- a/docs/toggle-rules-in-src.md +++ b/docs/toggle-rules-in-src.md @@ -29,6 +29,15 @@ p { } ``` +## Disable a rule for the next line + +```scss +p { + // sass-lint:disable-next-line border-zero + border: none; +} +``` + ## Disable all lints within a block (and all contained blocks) ```scss diff --git a/lib/ruleToggler.js b/lib/ruleToggler.js index f4bbd520..844bb270 100644 --- a/lib/ruleToggler.js +++ b/lib/ruleToggler.js @@ -196,6 +196,9 @@ module.exports.getToggledRules = function (ast) { case 'sass-lint:disable-line': addDisableLine(toggledRules, rules, comment.start.line); break; + case 'sass-lint:disable-next-line': + addDisableLine(toggledRules, rules, comment.start.line + 1); + break; default: return; } diff --git a/tests/ruleToggler.js b/tests/ruleToggler.js index 354da084..c4bd4dad 100644 --- a/tests/ruleToggler.js +++ b/tests/ruleToggler.js @@ -68,6 +68,15 @@ describe('rule toggling', function () { } }) === true); }); + it('should be able to disable next line', function () { + var ruleToggles = generateToggledRules('ruleToggler-disable-next-line.scss'); + assert(deepEqual(ruleToggles, { + globalEnable: [], + ruleEnable: { + a: [[false, 3, 1], [true, 4, 1]] + } + }) === true); + }); it('should be able to disable a block of code', function () { var ruleToggles = generateToggledRules('ruleToggler-disable-a-block.scss'); assert(deepEqual(ruleToggles, { diff --git a/tests/sass/ruleToggler-disable-next-line.sass b/tests/sass/ruleToggler-disable-next-line.sass new file mode 100644 index 00000000..cfbbd9dd --- /dev/null +++ b/tests/sass/ruleToggler-disable-next-line.sass @@ -0,0 +1,3 @@ +p + // sass-lint:disable-next-line a + border-color: red diff --git a/tests/sass/ruleToggler-disable-next-line.scss b/tests/sass/ruleToggler-disable-next-line.scss new file mode 100644 index 00000000..35544ba6 --- /dev/null +++ b/tests/sass/ruleToggler-disable-next-line.scss @@ -0,0 +1,4 @@ +p { + // sass-lint:disable-next-line a + border-color: red; +}