Question

I'm using D3 in my project. I'd love to enforce a specific indentation pattern, but due to the multiple chaining I'd like to organize my code using multiple instances of indentation. JSHint throws an error when I have something like this:

var svgContainer = d3.select(location).append('svg')
    .attr()
    .attr();

    var xAxisGroup = svgContainer.append('g') // throws error here
        .attr()
        .call();

Is there any possible way I can enforce 4 indents, but ignore multiple indentations in .jshintrc? i.e. var AxisGroup stems from svgContainer, would like the nesting without warnings from JSHint.

Was it helpful?

Solution 2

Through research I've definitively found that "white" is deprecated and shouldn't be used.

It turns out I was using grunt's grunt-contrib-jshint at an older version before version 2.5.0 where JSHint allows multiple indentation.

Changing the package.json I had for grunt to "grunt-contrib-jshint": "^0.10.0", fixed this problem.

OTHER TIPS

You can try set this in your .jshintrc:

"indent": 4,
"white": false

Also, please check out JSHint Docs.
And it looks like in last version, devs solved issue with indent warnings: https://github.com/jshint/jshint/releases/tag/2.5.0

indent no longer provides warnings about indentation levels

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top