cdmckay
cdmckay

Reputation: 32280

JSHint chaining method calls

I have the following code in an Angular app:

'use strict';

angular.module('fooApp')
    .controller('FooCtrl', function ($scope) {

    });

When I run JSHint (with indent set to 4) on this code, I get the following error:

[L6:C5] W015: Expected '}' to have an indentation at 1 instead at 5.
    });

How do I get JSHint to allow me to keep my chaining indentation?

Update

I found that if I add a body to the FooCtrl function like this:

'use strict';

angular.module('fooApp')
    .controller('FooCtrl', function ($scope) {
        $scope.foo = {};
    });

Then it does pass JSHint. Anyone know why?

Upvotes: 0

Views: 569

Answers (2)

zmo
zmo

Reputation: 24802

simply said: you don't. Either you remove all indentation checking from your config file, or you match the crockford's recommandation. There's an open bug about giving more flexible rules, but it has to be implemented.

Having submitted code to JSHint, it would not be hard to implement a more flexible way to check whitespaces. Except that there are a lot of cases where it has to be checked... The main problem is to find an intelligent way to fine tune your indentation preferences.

Upvotes: 1

GJK
GJK

Reputation: 37389

I don't believe there is a way to do it. The whitespace checking in JSHint is fairly static, you get on or off, no configuration. There's an open bounty to add some configuration, but nothing seems to be in the works (at least for your situation).

https://github.com/jshint/jshint/issues/28

You'll either have to just ignore it or turn off the whitespace check.

Upvotes: 2

Related Questions