Typescript – How to configure @typescript-eslint rules

eslinttypescripttypescript-eslint

I'm trying to convert to @typescript-eslint but the documentation seems sorely lacking. For example, I'm getting errors like this:

Line 58:  Expected a semicolon             @typescript-eslint/member-delimiter-style

I want to enforce no semicolons or commas. I found the documentation for that rule. https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/member-delimiter-style.md

But it doesn't seem to give any examples of how to configure it in a real eslint file! Anyone know how?

Best Answer

Using a .eslintrc.js configuration file you have to add this to the "rules" section:

"rules": {
    "@typescript-eslint/member-delimiter-style": ["error", {
      multiline: {
        delimiter: 'none',    // 'none' or 'semi' or 'comma'
        requireLast: true,
      },
      singleline: {
        delimiter: 'semi',    // 'semi' or 'comma'
        requireLast: false,
      },
    }]
}

Worked for me for the "@typescript-eslint/explicit-function-return-type" parameter. Options are from the rules project site on github

Thanks to maxkoryukov for improving my original answer.