【问题标题】:Ionide: how to specify FSharpLint's configuration?Ionide:如何指定 FSharpLint 的配置?
【发布时间】:2020-11-05 18:30:39
【问题描述】:

根据FSharpLint documentation,在命令行可以通过--lint-config指定配置文件。

由于该工具已集成到 Ionide 中,因此我期待通过某种方式在该扩展程序的设置中指定配置文件。但是,documented 的唯一设置是 FSharp.Linter,它允许您打开或关闭 linter。

真的没有办法在 Ionide 中配置 FSharpLint 吗?

【问题讨论】:

    标签: f# ionide


    【解决方案1】:

    您可以在项目的根目录中创建一个 fsharplint.json 文件。我将从这个例子开始:https://github.com/microsoft/fsharplu/blob/master/fsharplint.json

    然后,您可以在闲暇时调整选项。请务必重新启动 VSCode 以使更改生效。

    【讨论】:

    • 好的,因此我目前没有使用 Ionide,我会尝试您的建议
    【解决方案2】:

    这是一个基于 Koenig Lear 回答的分步示例。

    我有一个代码库,其中一些函数的名称中有下划线。这显示为一个 linter 问题:

    注意规则代码是FL0049

    规则列表在这里:

    https://fsprojects.github.io/FSharpLint/how-tos/rule-configuration.html

    如果我点击 FL0049 的规则,我们将进入以下页面:

    https://fsprojects.github.io/FSharpLint/how-tos/rules/FL0049.html

    我们展示了如何配置此规则的示例:

    {
        "publicValuesNames": {
            "enabled": true,
            "config": {
                "underscores": "AllowPrefix"
            }
        }
    }
    

    我在注释中看到underscores 可以设置为AllowAny

    我在我的项目根目录中创建了一个fsharplint.json 文件,内容如下:

    {
        "conventions": {
            "naming": {
                "publicValuesNames": {
                    "enabled": true,
                    "config": {
                        "underscores": "AllowAny"
                    }
                }
            }
        }
    }
    

    我关闭了我的 F# 代码文件,重新打开它,波浪线消失了。 :-)

    【讨论】:

      猜你喜欢
      • 2017-03-04
      • 2011-10-01
      • 2013-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 2023-03-13
      • 1970-01-01
      相关资源
      最近更新 更多