如何配置@ typescript-eslint规则 [英] How to configure @typescript-eslint rules

查看:1842
本文介绍了如何配置@ typescript-eslint规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试转换为@typescript-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

我不想强制使用分号或逗号.我找到了该规则的文档. https://github.com /bradzacher/eslint-plugin-typescript/blob/master/docs/rules/member-delimiter-style.md

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

但是它似乎没有提供任何有关如何在真实的eslint文件中进行配置的示例!有人知道吗?

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

推荐答案

使用.eslintrc.js配置文件,您必须将其添加到规则"部分:

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,
      },
    }]
}

为我工作了"@ typescript-eslint/explicit-function-return-type"参数. 选项来自

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

感谢maxkoryukov改善了我的原始答案.

Thanks to maxkoryukov for improving my original answer.

这篇关于如何配置@ typescript-eslint规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆