简体   繁体   中英

enforce 2 space indentation with jshint

I have a .jshintrc file with this config:

{
  "indent": 2
}

And I have a js file that looks like this:

var hello = angular.module('hello', ['hello.controllers']);

angular.module('hello.controllers', []).
controller('MainCtrl', ['$scope', function ($scope) {

  'use strict';

  // hello msg
    var helloMsg = 'Some Awesome Things';
  $scope.helloMsg = helloMsg;
}]);

And when I run jshint on the file, no error is thrown.

Notice that the line var helloMsg = 'Some Awesome Things'; is indented two extra spaces.

What do I need to do so that jshint throws an error on the above code?

Are you using version >= 2.5.0? If so, seems they removed it:

indent no longer provides warnings about indentation levels

https://github.com/jshint/jshint/releases/tag/2.5.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM