I don't quite understand what the linter expects in this case, what do you think?
return edits.reduceRight((contents, edit) => {
var head = contents.slice(0, edit.span.start);
var tail = contents.slice(edit.span.start + edit.span.length);
var change = new Buffer(edit.newText, "utf8");
return Buffer.concat([head, change, tail]);
}, file.contents);
:+1:
The align rule, with the arguments option set, checks that arguments that start on different lines are horizontally aligned to the same starting column. In your case, reduceRight's first argument, the arrow function, and the second argument, file.contents are not aligned. You could try something like this instead:
function() {
return edits.reduceRight(
(contents, edit) => {
var head = contents.slice(0, edit.span.start);
var tail = contents.slice(edit.span.start + edit.span.length);
var change = new Buffer(edit.newText, "utf8");
return Buffer.concat([head, change, tail]);
},
file.contents
);
};
Or, you could just remove the arguments options or disable the rule in this spot. Honestly, sample.tslint.json isn't a great starting tslint.json. In the future we want to have an option to generate a reasonable one for you though! See https://github.com/palantir/tslint/issues/717
Thanks @JKillian
Thank you very much for clearing this up!
No problem, sorry about the delay @alexgorbatchev! Thanks for the bump @johnjelinek
I'm also having problems understanding this rule - I thought I understood it, but I expected this to throw errors:
let a = 1,
b = 2
let c = 3,
d = 'hello',
e = '4'
I can get this rule to throw errors on parameters but not statements or arguments. Am I missing something?
@Billy- giving what I understand here, this only applies to parameters that you are passing to a function.
@Billy- I think what you're looking for is for your "statements" to be aligned.
"align": [true, "parameters", "statements"]
Here's all the current options to pass in for the align rule: [https://palantir.github.io/tslint/rules/align/]
Hmm, parameters alignment working for me, not statements though.
Most helpful comment
The
alignrule, with theargumentsoption set, checks that arguments that start on different lines are horizontally aligned to the same starting column. In your case,reduceRight's first argument, the arrow function, and the second argument,file.contentsare not aligned. You could try something like this instead:Or, you could just remove the
argumentsoptions or disable the rule in this spot. Honestly,sample.tslint.jsonisn't a great startingtslint.json. In the future we want to have an option to generate a reasonable one for you though! See https://github.com/palantir/tslint/issues/717