Repository: lesshint/lesshint (js)
Issue: spaceBeforeBrace flags trailing whitespace before a newline
**Which version of `lesshint` are you using?**
4.1.1

**How are you running `lesshint`? CLI, Node.js API, Grunt/Gulp plugin?**
CLI and Node.js API

**What's your `.lesshintrc` configuration?**
*(everything else is disabled)*
```js
"spaceBeforeBrace": {
    "enabled": true,
    "style": "new_line"
},
"trailingWhitespace": true,
```

**If you're reporting a bug, please show us some code that's failing.**
*Note the space after `.bbb`
```less
.bbb 
{}
```

**What did you expect to happen?**

```
Warning: original.less: line 2, col 5, trailingWhitespace: There shouldn't be any trailing whitespace.
```

**What's the actual result?**

```
Warning: original.less: line 2, col 5, trailingWhitespace: There shouldn't be any trailing whitespace.
Warning: original.less: line 3, col 1, spaceBeforeBrace: Opening curly brace should be on its own line.
```

**Would you be interested in submitting a PR for this issue?**

I'll take a look. It should be just adding a ` *` to the regex tester, right?

None of the test cases in `test/specs/linters/space_before_brace.js` refer to equivalents of `.bar \n{}`, just `.bar\n {}`.

Pull request description: Allowed spaces/tabs before newline for space_before_brace
Fixes #427.


Patch:
diff --git a/lib/linters/README.md b/lib/linters/README.md
index bf6aa3c..9f76081 100644
--- a/lib/linters/README.md
+++ b/lib/linters/README.md
@@ -866,7 +866,7 @@ Semicolons are optional after the last property in a ruleset but it's a good hab
 ```
 
 ## trailingWhitespace
-There should't be any trailing whitespace since this will mess up diffs etc.
+There shouldn't be any trailing whitespace since this will mess up diffs etc.
 
 ## urlFormat
 All URLs should be relative.
diff --git a/lib/linters/space_before_brace.js b/lib/linters/space_before_brace.js
index acfa2a3..795fc58 100644
--- a/lib/linters/space_before_brace.js
+++ b/lib/linters/space_before_brace.js
@@ -11,7 +11,7 @@ module.exports = {
 
     lint: function spaceBeforeBraceLinter (config, node) {
         const styles = {
-            'new_line': /^\n *\t*$/,
+            'new_line': /^ *\t*\n *\t*$/,
             'no_space': /^$/,
             'one_space': /^ $/
         };
diff --git a/lib/linters/trailing_whitespace.js b/lib/linters/trailing_whitespace.js
index 0fd24b9..88dbc88 100644
--- a/lib/linters/trailing_whitespace.js
+++ b/lib/linters/trailing_whitespace.js
@@ -3,7 +3,7 @@
 module.exports = {
     name: 'trailingWhitespace',
     nodeTypes: ['root'],
-    message: "There should't be any trailing whitespace.",
+    message: "There shouldn't be any trailing whitespace.",
 
     lint: function trailingWhitespaceLinter (config, node) {
         // Ignore empty files


Test patch:
diff --git a/test/specs/linters/space_before_brace.js b/test/specs/linters/space_before_brace.js
index 5669631..084a03e 100644
--- a/test/specs/linters/space_before_brace.js
+++ b/test/specs/linters/space_before_brace.js
@@ -281,6 +281,32 @@ describe('lesshint', function () {
             });
         });
 
+        it('should allow one new line preceded by spaces when "style" is "new_line"', function () {
+            const source = '.foo       \n{}';
+            const options = {
+                style: 'new_line'
+            };
+
+            return spec.parse(source, function (ast) {
+                const result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
+        it('should allow one new line surrounded by spaces when "style" is "new_line"', function () {
+            const source = '.foo       \n       {}';
+            const options = {
+                style: 'new_line'
+            };
+
+            return spec.parse(source, function (ast) {
+                const result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
         it('should allow one new line followed by tabs when "style" is "new_line"', function () {
             const source = '.foo\n\t\t{}';
             const options = {
@@ -294,6 +320,32 @@ describe('lesshint', function () {
             });
         });
 
+        it('should allow one new line preceded by tabs when "style" is "new_line"', function () {
+            const source = '.foo\t\t\n{}';
+            const options = {
+                style: 'new_line'
+            };
+
+            return spec.parse(source, function (ast) {
+                const result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
+        it('should allow one new line surrounded by tabs when "style" is "new_line"', function () {
+            const source = '.foo\t\t\n\t\t{}';
+            const options = {
+                style: 'new_line'
+            };
+
+            return spec.parse(source, function (ast) {
+                const result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
         it('should not allow multiple new lines when "style" is "new_line"', function () {
             const source = '.foo\n\n{}';
             const expected = [{
diff --git a/test/specs/linters/trailing_whitespace.js b/test/specs/linters/trailing_whitespace.js
index 83dd3c6..4a979f6 100644
--- a/test/specs/linters/trailing_whitespace.js
+++ b/test/specs/linters/trailing_whitespace.js
@@ -38,7 +38,7 @@ describe('lesshint', function () {
             const expected = [{
                 column: 9,
                 line: 1,
-                message: "There should't be any trailing whitespace."
+                message: "There shouldn't be any trailing whitespace."
             }];
 
             return spec.parse(source, function (ast) {
@@ -53,7 +53,7 @@ describe('lesshint', function () {
             const expected = [{
                 column: 9,
                 line: 1,
-                message: "There should't be any trailing whitespace."
+                message: "There shouldn't be any trailing whitespace."
             }];
 
             return spec.parse(source, function (ast) {