Skip to content
Permalink
Browse files

Removed 'smarttabs' and stopped warning about mixed spaces and tabs.

Closes #1473
Closes #1530
  • Loading branch information...
valueof committed Mar 27, 2014
1 parent 4558cf2 commit 4035fef1af4ef426e9dc99918ca3aac0ce44b784
@@ -28,8 +28,7 @@ many people contributed. —[idiomatic.js](https://github.com/rwldrn/idiomatic.j
### Whitespace:

* We use hard tabs everywhere.
* [Smart tabs](http://www.emacswiki.org/SmartTabs) are okay.
* We use two spaces everywhere.
* Use one space after `if`, `for`, `while`, etc.
* Use one space after `function` for anonymous functions but not for named functions:

@@ -54,7 +54,6 @@
"multistr" : false, // true: Tolerate multi-line strings
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
@@ -58,7 +58,6 @@
"boss": true,
"node": true,
"strict": true,
"smarttabs": true,
"maxlen": 100,
"newcap": false,
"undef": true,
@@ -129,8 +129,6 @@ var JSHINT = (function () {
typed : true, // if typed array globals should be predefined
undef : true, // if variables should be declared before used
scripturl : true, // if script-targeted URLs should be tolerated
smarttabs : true, // if smarttabs should be tolerated
// (http://www.emacswiki.org/emacs/SmartTabs)
strict : true, // require the "use strict"; pragma
sub : true, // if all forms of subscript notation are tolerated
supernew : true, // if `new function () { ... };` and `new Object;`
@@ -215,7 +213,8 @@ var JSHINT = (function () {
onevar: true,
passfail: true,
white: true,
gcl: true
gcl: true,
smarttabs: true
},

declared, // Globals that were declared using /*global ... */ syntax.
@@ -1282,26 +1282,6 @@ Lexer.prototype = {
};
},

/*
* Scan for any occurence of mixed tabs and spaces. If smarttabs option
* is on, ignore tabs followed by spaces.
*
* Tabs followed by one space followed by a block comment are allowed.
*/
scanMixedSpacesAndTabs: function () {
var at, match;

if (state.option.smarttabs) {
// Negative look-behind for "//"
match = this.input.match(/(\/\/|^\s?\*)? \t/);
at = match && !match[1] ? 0 : -1;
} else {
at = this.input.search(/ \t|\t [^\*]/);
}

return at;
},

/*
* Scan for any occurence of non-breaking spaces. Non-breaking spaces
* can be mistakenly typed on OS X with option-space. Non UTF-8 web
@@ -1375,8 +1355,7 @@ Lexer.prototype = {

/*
* Switch to the next line and reset all char pointers. Once
* switched, this method also checks for mixed spaces and tabs
* and other minor warnings.
* switched, this method also checks for other minor warnings.
*/
nextLine: function () {
var char;
@@ -1417,11 +1396,6 @@ Lexer.prototype = {
this.trigger("warning", { code: "W125", line: this.line, character: char + 1 });
}

char = this.scanMixedSpacesAndTabs();
if (char >= 0) {
this.trigger("warning", { code: "W099", line: this.line, character: char + 1 });
}

this.input = this.input.replace(/\t/g, state.tab);
char = this.scanUnsafeChars();

@@ -172,7 +172,7 @@ var warnings = {
W096: "The '{a}' key may produce unexpected results.",
W097: "Use the function form of \"use strict\".",
W098: "'{a}' is defined but never used.",
W099: "Mixed spaces and tabs.",
W099: null,
W100: "This character may get silently deleted by one or more browsers.",
W101: "Line is too long.",
W102: "Trailing whitespace.",
@@ -39,16 +39,13 @@ exports.jQuery_1_7 = function (test) {
.addError(4465, "'curLoop' is defined but never used.")
.addError(4560, "Expected an assignment or function call and instead saw an expression.")
.addError(4694, "'cache' is defined but never used.")
.addError(4702, "Mixed spaces and tabs.")
.addError(4712, "Expected a 'break' statement before 'case'.")
.addError(4715, "Mixed spaces and tabs.")
.addError(4843, "Expected an assignment or function call and instead saw an expression.")
.addError(5635, "'elem' is defined but never used.")
.addError(5675, "'i' is defined but never used.")
.addError(5691, "'i' is defined but never used.")
.addError(7141, "'i' is defined but never used.")
.addError(6061, "'cur' is defined but never used.")
.addError(9209, "Mixed spaces and tabs.")
.test(src, { undef: true, unused: true }, globals);

test.done();
@@ -30,7 +30,7 @@
});

// this should trigger an error
if (true) {
if (a == 0) {
throw "why did you not lint the above line";
}

This file was deleted.

@@ -1325,22 +1325,6 @@ exports.maxlen = function (test) {
test.done();
};

exports.smarttabs = function (test) {
var src = fs.readFileSync(__dirname + '/fixtures/smarttabs.js', 'utf8');

TestRun(test)
.addError(4, "Mixed spaces and tabs.")
.addError(5, "Mixed spaces and tabs.")
.addError(13, "Mixed spaces and tabs.")
.test(src, {es3: true});

TestRun(test)
.addError(5, "Mixed spaces and tabs.")
.test(src, {es3: true, smarttabs: true });

test.done();
};

/*
* Tests the `laxcomma` option
*/
@@ -4117,7 +4117,7 @@ exports["/*jshint ignore */ should allow the linter to skip blocked-out lines to
var code = fs.readFileSync(__dirname + "/fixtures/gh826.js", "utf8");

TestRun(test)
.addError(33, "Mixed spaces and tabs.")
.addError(33, "Use '===' to compare with '0'.")
.test(code);

test.done();

5 comments on commit 4035fef

@denis-sokolov

This comment has been minimized.

Copy link
Contributor

replied Jun 11, 2014

What was the reasoning behind removing the mixed spaces and tabs message?
It's a useful warning.

@nkpz

This comment has been minimized.

Copy link

replied Aug 21, 2014

Also wondering about mixed spaces/tabs being removed. As a tool for enforcing internal code style guidelines it's very useful to have this. Looks like I'm going to have to add another tool to our dev deps just for this

@rwaldron

This comment has been minimized.

Copy link
Member

replied Aug 21, 2014

@nnjpp we recommend that you use JSCS. @mikesherov will gladly answer any questions you may have about getting started.

@mikesherov

This comment has been minimized.

Copy link
Contributor

replied Aug 21, 2014

Thanks @rwaldron. @nnjpp, JSCS formats whitespace so that JSHint can do the hard work of catching real errors for you. Let me know if you have any questions.

@nkpz

This comment has been minimized.

Copy link

replied Aug 21, 2014

Thanks guys, wasn't aware of JSCS but it looks like a perfect companion to jshint. Will try it out

Please sign in to comment.
You can’t perform that action at this time.