validateIndentation with chained methods and callbacks
Is there a way to make the following snippet validate using the current ruleset? On both lines with function on them, I get "Expected indentation of 0 characters". It also seems to reset the indent counter of the function body, requiring it to be on level one.
fs.createReadStream('..')
.on('bar', function() { // validateIndentation wants 0 indent here
hello() // and this to be on level 1 (2 spaces)
}) // 0
.on('baz', function() { // 0
}) // 0
Which version are you using?
1.2.4, the latest version on NPM.
This is not related to the functions.
I have a similar problem with
Log
.find({
level: 1
})
.filter('some')
Output is
Expected indentation of 4 characters at test.js :
1 |Log
2 | .find({
3 | level: 1
------------^
4 | })
5 | .filter('some')
Expected indentation of 0 characters at test.js :
2 | .find({
3 | level: 1
4 | })
--------^
5 | .filter('some')
6 |
and validateIndention: 4 on v1.2.4.
Surely,
Log
.find({
level: 1
})
.filter('some')
does not look right.
I'll be permafixing remaining indentation issues today. I have a strategy to solve this.
Any news on this?
We have a lot of issues to attend to, but it's on our radar, any help would be appreciated
It's currently the only issue I'm having with JSCS and prevents us from switching to it in Bootstrap. As soon as this is fixed, I will make the switch.
Have you tried latest master? This should be fixed... If not, I'll tackle it today. @xhmikosR, let me know.
If latest master fixes it, I'll cut a release.
@mikesherov: I just tried the latest master; we use jscs via grunt-jscs-checker btw.
I replaced grunt-jscs-checker jscs with the latest master and it seems I keep getting the warnings.
Example output:
231 |
232 | $target
Expected indentation of 12 characters at js/modal.js :
230 | if ($this.is('a')) e.preventDefault()
231 |
232 | $target
--------------------^
233 | .modal(option, this)
234 | .one('hide', function () {
Expected indentation of 10 characters at js/modal.js :
235 | $this.is(':visible') && $this.focus()
236 | })
237 | })
------------------^
238 |
239 | $(document)
Expected indentation of 12 characters at js/modal.js :
237 | })
238 |
239 | $(document)
--------------------^
240 | .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
241 | .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
Expected indentation of 10 characters at js/modal.js :
241 | .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
242 |
243 |}(jQuery);
------------------^
244 |
>> 181 code style errors found!
Warning: Task "jscs:src" failed. Use --force to continue.
Aborted due to warnings.
C:\Users\xmr\Desktop\bootstrap>
js/modal.js line 239
$(document)
.on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
.on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
Fix incoming. Thanks for the report and your patience.
No problem, thanks for your work!
@XhmikosR can you test against master again please? Just want to verify this fix is complete.
Unfortunately, It still fails :/
https://gist.github.com/XhmikosR/9edffc9de843289c716c
I just pushed my WIP branch here https://github.com/twbs/bootstrap/compare/jscs
Doing npm install && grunt jscs you should be able to reproduce the warnings better.
It's not chained methods and callbacks that's the problem. It's the semicolon-less, brace-less conditionals. Fix ready!
Hey, had the same problem.
fixed by writing the object in one line.
FROM: var session = { from : new Date(0), to : new Date(0), name : results.data[i].name };
TO: var session = {from:new Date(0),to:new Date(0),name:results.data[i].name};