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

Add eslint settings for TypeScript #1205

Merged
merged 3 commits into from Mar 4, 2020

Conversation

abetomo
Copy link
Collaborator

@abetomo abetomo commented Mar 2, 2020

Pull Request

Problem

#1191 (comment)

I suspect we aren't running lint on the TypeScript.

Solution

I tried setting TypeScript as a trial.

(@shadowspawn Close it if you are already working on it.)

ChangeLog

@shadowspawn
Copy link
Collaborator

Nice. Good start being able to lint the TypeScript separately. 👍

I tried turning it on for editor too by combining in eslintrc but ran into some issues, not sure whether it will be sensible to do combined settings. Running it separately like this is an ok fallback, we only have two TypeScript files.

I see there is https://github.com/standard/eslint-config-standard-with-typescript which could be appropriate since we are using standard for JavaScript.

I suggest if we keep two config files then use same filetype for .eslintrc.json and .typescript-eslint.js. I don't mind which — maybe .js because it is the first file that eslint looks for, and more flexible, and more familiar?

@abetomo abetomo force-pushed the feature/add_typescript_eslint branch from 2036ceb to 8c666fe Compare March 3, 2020 00:44
@abetomo
Copy link
Collaborator Author

abetomo commented Mar 3, 2020

Modified to use 'standard-with-typescript'.

I prefer setting with js because it is more flexible than json.

As you mentioned, the file type is different from .eslintrc.json.
I tried to js the file type as a suggestion.
Which one do you prefer?

@shadowspawn
Copy link
Collaborator

Let's go with .js format.

@shadowspawn
Copy link
Collaborator

standard-with-typescript produces more warnings, but I still like using standard for a start to be consistent with our eslint JavaScript setup.

I suggest add one rule to restore this to default and avoid a lot of errors. We have our own "semi" rule for javascript, so reasonable we need one for TypeScript too. Feel free to make layout a bit more compact, I used fully expanded layout here.

    // Set member-delimiter-style back to default, we use semicolons
    // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md
    '@typescript-eslint/member-delimiter-style': ['error', {
      "multiline": {
          "delimiter": "semi",
          "requireLast": true
      },
      "singleline": {
          "delimiter": "semi",
          "requireLast": false
      }
    }]

As otherwise get errors for the semicolons in this:

  interface CommanderError extends Error {
    code: string;
    exitCode: number;
    message: string;
    nestedError?: string;
  }

@shadowspawn
Copy link
Collaborator

Might be able to get the linting working with single configuration file using overrides. I have not tried this yet. Main reason I am interested is to see if works in editor too. 🙂

@abetomo abetomo force-pushed the feature/add_typescript_eslint branch from 2ca3a31 to a64398e Compare March 3, 2020 07:27
@abetomo
Copy link
Collaborator Author

abetomo commented Mar 3, 2020

Thank you for the review!

I have modified it based on your feedback.

@shadowspawn
Copy link
Collaborator

I can now see the errors in VisualStudio Code too when I open the TS files, nice! Quite a few things to fix after this lands, but mostly easy. 😅

Could lint both the typescript files:, script:

    "typescript-lint": "eslint 'typings/*.ts'",

Copy link
Collaborator

@shadowspawn shadowspawn left a comment

Choose a reason for hiding this comment

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

LGTM

@abetomo abetomo changed the title wip: Proposal of eslint setting of TypeScript. Add eslint settings for TypeScript Mar 3, 2020
@shadowspawn
Copy link
Collaborator

👍
I'm happy for this to be merged into develop now (before 5.0) if you like.

Nice changes to bring our TypeScript style support up to level of our JavaScript for future work with a lint script and editor support.

@abetomo
Copy link
Collaborator Author

abetomo commented Mar 4, 2020

Thanks for the review!

@abetomo abetomo merged commit f14df07 into tj:develop Mar 4, 2020
@abetomo abetomo deleted the feature/add_typescript_eslint branch March 4, 2020 11:04
Taylerpaul

This comment was marked as spam.

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.

None yet

3 participants