Using putout linter on xterm codebase#2953
Using putout linter on xterm codebase#2953Tyriar merged 4 commits intoxtermjs:masterfrom coderaiser:lint/simplify
Conversation
There was a problem hiding this comment.
@coderaiser Did you actually look at the replacements? There are several issues with it, see my comments below.
|
@jerch thank you for review :), I did look at replacement but want to receive feedback before proceeding. I’ll fix all comments when get to a computer. |
|
@jerch just force pushed updates, we have only 4 rules not disabled, from found list :):
Also |
|
@coderaiser I think for time critical parts we should resort to good old index-for-loops. For non critical paths imho for-of is good to go with it. @Tyriar Do you see any issues with for-of, like ECMA version supported? Imho it got official with ES6, I am not sure if TS will transpile it for lower targets correctly. |
Tyriar
left a comment
There was a problem hiding this comment.
Pretty much agree with all your thoughts @jerch. Also I don't think we would want to include an additional linter, I'm trying to slim down out dev deps where possible.
The forEach change seemed negative to me at first, but having it not be inside a callback would help TS understand what's going on, specifically in this case which is just annoying to deal with:
I think for time critical parts we should resort to good old index-for-loops. For non critical paths imho for-of is good to go with it.
I have similar thoughts, I wouldn't even bother trying to convert for loops as we typically only use them not for perf critical parts and when we're working with the index.
Do you see any issues with for-of, like ECMA version supported? Imho it got official with ES6, I am not sure if TS will transpile it for lower targets correctly.
It transpiles down to this for es5 targets:
var a = [1, 2, 3];
for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
var b = a_1[_i];
console.log(b);
}This ends up being ~40% slower in Chromium for me which isn't too bad.
remove-empty is the only other rule that I think we may want to run. If that only catches the while (reports.pop()) { }, which would definitely be better written as reports = [] as suggested anyway.
Co-authored-by: Daniel Imms <[email protected]>
Absolutely agree with you :). The rule
Yep,
Yes, I'll add it, it is have sense :).
@Tyriar I don't suggest to add an additional linter :). I suggest to add results of it work :). |

Just read about switching eslint rules to warnings, and want to suggest usage results of putout linter that fixes everything it can find.
Here is list of things in code of
xterm.jsthat can be improved:Here is used config
.putout.json:{ "rules": { "remove-console": "off", "remove-unused-variables": "off", "remove-useless-variables": "off", "apply-destructuring": "off", "merge-if-statements": "off", "convert-apply-to-spread": "off", "convert-math-pow": "off", "convert-for-to-for-of": "off", "convert-template-to-string": "off", "remove-empty": "off" } }I'm willing to run
putoutagain disabling rules you choose If it's appropriate , I think this can make codebase ofxterm.jsa little bit better :).About an error:
1) CoreMouseService triggerMouseEvent eventCodes with modifiers (DEFAULT encoding): AssertionError: expected [ Array(8) ] to deeply equal [ Array(4) ] + expected - actual [ - "\u001b[M !!" - "\u001b[M!!!" - "\u001b[M\"!!" - "\u001b[Ma!!" "\u001b[M#!!" "\u001b[M#!!" "\u001b[M#!!" "\u001b[M`!!" at Context.<anonymous> (out/common/services/CoreMouseService.test.js:166:27)I have the same error on
master. Have no idea what it is :).