4

According to the FSharpLint documentation, on the command line, you can specify the config file via --lint-config.

Since the tool comes integrated into Ionide, I was expecting some means of specifying the config file in that extension's settings. However, the only setting that's documented is FSharp.Linter, which lets you turn the linter on or off.

Is there really no way to configure FSharpLint in Ionide?

Tatiana Racheva
  • 1,289
  • 1
  • 13
  • 31

2 Answers2

2

You can create a fsharplint.json file at the root of your project. I'd start with this example : https://github.com/microsoft/fsharplu/blob/master/fsharplint.json.

You can then tweak the options at your leisure. Be sure to restart VSCode for the changes to take effect.

Koenig Lear
  • 2,366
  • 1
  • 14
  • 29
1

Here's a step-by-step example based on Koenig Lear's answer.

I have a codebase where some functions have underscores in the name. This was showing up as a linter issue:

enter image description here

Note that the rule code is FL0049.

The rule list is here:

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

If I click on the rule for FL0049, we're taken to the following page:

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

We're shown an example of how to configure this rule:

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

I see in the notes that underscores can be set to AllowAny.

I create an fsharplint.json file in my project root directory with the following contents:

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

I close the my F# code file, re-open it, and the squigglies are gone. :-)

dharmatech
  • 8,979
  • 8
  • 42
  • 88
  • Worth noting that now your linter is checking only that one single rule https://github.com/fsprojects/FSharpLint/issues/488 – suside Jun 02 '23 at 07:45