How to configure @typescript-eslint rules

北城余情 提交于 2020-01-24 10:29:27

问题


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?


回答1:


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

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

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



来源:https://stackoverflow.com/questions/56816619/how-to-configure-typescript-eslint-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!