Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using putout linter on xterm codebase part 2 #3133

Merged
merged 4 commits into from
Nov 2, 2020
Merged

Using putout linter on xterm codebase part 2 #3133

merged 4 commits into from
Nov 2, 2020

Conversation

coderaiser
Copy link
Contributor

@coderaiser coderaiser commented Oct 19, 2020

Latest PR (#2953) was successfully merged, so I decide to do more checks with updated version of putout and discuss improving codebase with rules approved earlier and I can disable any of rules that not fits to current code style :).

So here is config:

{
    "rules": {
        "strict-mode": "off",
        "remove-useless-spread/object": "off",
        "remove-iife": "off",
        "convert-generic-to-shorthand": "off",
        "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": "on",
        "convert-index-of-to-includes": "on",
        "convert-for-each-to-for-of": "on",
        "apply-shorthand-properties": "on",
        "apply-numeric-separators": "off"
    },
}

Copy link
Member

@jerch jerch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for looking into that - looks good to me for most changes, but a few remarks below.

@@ -717,7 +717,7 @@ describe('Terminal', () => {

describe('unicode - surrogates', () => {
it('2 characters per cell', function (): void {
this.timeout(10000); // This is needed because istanbul patches code and slows it down
this.timeout(10_000); // This is needed because istanbul patches code and slows it down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this notation is still way too new and we should not yet rely on it. Same goes for the other occurrences.

@@ -17,7 +17,7 @@ const isNode = (typeof navigator === 'undefined') ? true : false;
const userAgent = (isNode) ? 'node' : navigator.userAgent;
const platform = (isNode) ? 'node' : navigator.platform;

export const isFirefox = !!~userAgent.indexOf('Firefox');
export const isFirefox = !!userAgent.includes('Firefox');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since .includes already returns a boolean, the !! type conversion gets redundant.

@@ -2,7 +2,7 @@
"extends": "../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015"
"es2017"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason for ES2017? I have no strong obligations against ES2017, but would not like to change that for a non-obvious reason. Being more vanilla/old-school is not a bad thing in terms of supported targets while maintaining the same functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is es2017 needs to be set to have ability to build files that contains includes with typescript.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderaiser 👍 Ah ok, well I'm fine to move on to ES2017 then, but would like to hear @Tyriar and @mofux 's opinion in this regard first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only thought is if we commit to this, that we also update all the other tsconfig.json files so they're not inconsistent. Since we only target evergreen browsers, I think this is safe to do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar I think it will change certain output shims. Imho our codebase is not really affected by that (Was it around generators? Or promises with async/await? Cant remember...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's for the target, the lib is just which typings to include. I see there is a lib "ES2016.Array.Include", that sounds like exactly what we want without needing to think about changing es2015.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar, I updated browser/tsconfig.json. Should I updatetsconfig.json in addons directories? They don't have lib option right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderaiser no need if they don't use lib, does ES2016.Array.Include work instead of es2017?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar yes, it works, just pushed

@@ -2,7 +2,7 @@
"extends": "../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015"
"es2017"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only thought is if we commit to this, that we also update all the other tsconfig.json files so they're not inconsistent. Since we only target evergreen browsers, I think this is safe to do?

@Tyriar Tyriar added this to the 4.10.0 milestone Oct 30, 2020
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clean up 🙂

@Tyriar Tyriar merged commit 38e81f0 into xtermjs:master Nov 2, 2020
@coderaiser coderaiser deleted the lint/putout branch November 2, 2020 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants