forked from SimenB/stylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trailing whitespace and mixedSpacesAndTabs checks added
- Loading branch information
Ross
committed
Dec 26, 2014
1 parent
325d145
commit f52c8b7
Showing
16 changed files
with
352 additions
and
181 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ results | |
npm-debug.log | ||
node_modules | ||
styl | ||
|
||
|
||
lib/read.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* check for mixed spaces and tabs | ||
* @param {string} line the line being tested | ||
* @param {number} indentSpaces default is 4. if set to false the we do hard tabs instead of spaces | ||
* @return {boolean} true if mixed spaces and tabs, false if not | ||
* @todo this is kinda not 100% reliable in it's current form | ||
*/ | ||
var tabs = /\t/, // was a tab used, at all | ||
spaces = /\s{2,}/; // check for 2 or more spaces (if hard tabs, shouldn't find anything) | ||
|
||
module.exports = function checkMixedSpacesAndTabs( line, indentSpaces ) { | ||
// if this isnt set to false then we're indenting with spaces | ||
if ( indentSpaces ) { | ||
// look for hard tabs | ||
if ( tabs.test( line ) ) { | ||
return true; | ||
} | ||
// soft tabs, no hard tabs, all good | ||
else { | ||
return false; | ||
} | ||
} | ||
// else you're a hard tab believer | ||
else { | ||
// look for 2 or more spaces | ||
if ( spaces.test( line ) ) { | ||
return true; | ||
} | ||
// hard tab, no spaces, all good | ||
else { | ||
return false; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* check for trailing whitespace | ||
* @param {string} line the line being tested | ||
* @return {boolean} true if whitespace found, false if not | ||
*/ | ||
var whitespace = /[ \t]+$/, // check for unecessary tabs or whitespace at eol | ||
anythingElse = /[^ \t]/; // anything BUT whitespace (we dont want to return false positives on empty lines) | ||
|
||
module.exports = function checkWhitespace( line ) { | ||
// not an empty line, with whitespace at the end | ||
if ( anythingElse.test(line) && whitespace.test(line) ) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.