### Install fsharplint as a Global Dotnet Tool Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/install-dotnet-tool.md Use this command to install the fsharplint tool globally on your system, making it accessible from any directory. ```bash dotnet tool install -g dotnet-fsharplint ``` -------------------------------- ### Install fsharplint to a Specific Directory Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/install-dotnet-tool.md Use this command to install the fsharplint tool to a specific directory on your system. Replace `` with your desired path. ```bash dotnet tool install --tool-path dotnet-fsharplint ``` -------------------------------- ### Rule Settings Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0077.md Shows how to configure the 'avoidSinglePipeOperator' rule in a settings file, demonstrating how to enable or disable it. ```json { "avoidSinglePipeOperator": { "enabled": false } } ``` -------------------------------- ### Lambda Function Example 1 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0035.md Demonstrates a lambda function that can be simplified using function composition. ```fsharp fun x -> not(isValid(x)) ``` -------------------------------- ### FL0056 Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0056.md Example configuration for enabling the FL0056 rule in fsharplint. ```json { "wildcardNamedWithAsPattern": { "enabled": true } } ``` -------------------------------- ### Example F# Program for Linting Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/index.md This F# program demonstrates a basic structure that FSharpLint can analyze for potential rule violations. ```fsharp type ExampleInterface = abstract member print : unit -> unit [] let main argv = let x = List.fold (fun x y -> x + y) 0 [1;2;3] printfn "%d" x 0 ``` -------------------------------- ### Lambda Function Example 2 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0035.md Shows another lambda function pattern that can be replaced with function composition. ```fsharp fun x -> x |> isValid |> not ``` -------------------------------- ### Configure Custom F# Linting Hints Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0065.md Example JavaScript configuration for F# linting, specifying hints to add and ignore. This allows customization of linting rules. ```javascript { "hints": { "add": [ "not (a = b) ===> a <> b", "not (a <> b) ===> a = b" ], "ignore": [ "x = true ===> x" ] } } ``` -------------------------------- ### FL0028 Rule Configuration Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0028.md This JSON configuration shows how to enable and set the maximum line count for the MaxLinesInProperty rule. ```json { "MaxLinesInProperty": { "enabled": false, "config": { "maxLines": 70 } } } ``` -------------------------------- ### Redundant Lambda Function Example 2 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0034.md This example demonstrates a lambda function that calls another function `foo` with its arguments. This lambda is redundant and can be replaced by a direct reference to `foo`. ```fsharp fun x y -> foo x y ``` -------------------------------- ### FL0074 Rule Configuration Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0074.md This JSON object shows how to configure the 'favourConsistentThis' rule. The 'symbol' property specifies the preferred instance identifier. ```json { "favourConsistentThis": { "enabled": false, "config": { "symbol": "this" } } } ``` -------------------------------- ### Example of wildcard binding Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0055.md This snippet demonstrates the pattern that FL0055 flags: binding a value to a wildcard (`_`). ```fsharp let _ = Console.ReadLine() ``` -------------------------------- ### FL0050 Rule Settings Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0050.md This JSON configuration shows how the FL0050 rule was enabled and configured. It specifies the expected naming convention and underscore usage for non-public values. ```json { "nonPublicValuesNames": { "enabled": true, "config": { "naming": "CamelCase", "underscores": "AllowPrefix" } } } ``` -------------------------------- ### FL0045 Rule Settings Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0045.md This JSON configuration enables the memberNames rule and specifies 'PascalCase' for naming and 'AllowPrefix' for underscore usage. Other settings like 'prefix' and 'suffix' can also be configured. ```json { "memberNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "AllowPrefix" } } } ``` -------------------------------- ### FL0096 Rule Settings Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0096.md Configuration for the FL0096 rule, specifying the 'mode' to control which APIs are checked. The 'OnlyPublicAPIsInLibraries' mode is suitable for library projects. ```json { "asynchronousFunctionNames": { "enabled": true, "config": { "mode": "OnlyPublicAPIsInLibraries" } } } ``` -------------------------------- ### FL0049 Rule Configuration Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0049.md This JSON snippet shows how to configure the publicValuesNames rule, specifying that underscores are allowed as a prefix for public value identifiers. ```json { "publicValuesNames": { "enabled": true, "config": { "underscores": "AllowPrefix" } } } ``` -------------------------------- ### Redundant Lambda Function Example 1 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0034.md This example shows a lambda function that performs addition, which is redundant. It can be replaced by the addition operator. ```fsharp fun x y -> x + y ``` -------------------------------- ### FL0069 Rule Settings Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0069.md This JSON configuration demonstrates how to set the naming convention and underscore rules for generic types. The 'naming' property specifies the expected casing (e.g., PascalCase), and 'underscores' defines allowed underscore usage (e.g., None). ```json { "genericTypesNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### FL0051 Rule Settings Example Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0051.md This JSON configuration shows how to disable the FL0051 rule and set the maximum allowed items in a tuple to 4. ```json { "maxNumberOfItemsInTuple": { "enabled": false, "config": { "maxItems": 4 } } } ``` -------------------------------- ### Async Function Naming Convention (Async Type) Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0096.md Functions returning the 'Async' type should be prefixed with 'Async'. This example demonstrates the correct naming convention. ```fsharp let AsyncFoo(): Async = async { return 1 } ``` -------------------------------- ### Add MSBuild Task to a Single Project Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/msbuild-task.md Add this MSBuild target to an individual project file to run FSharpLint after the build. Ensure the FSharpLint dotnet tool is installed and an fsharplint.json configuration file exists. ```xml ``` -------------------------------- ### Add MSBuild Task to All F# Projects Globally Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/msbuild-task.md Include this MSBuild target in a Directory.Build.props or Directory.Build.targets file to apply FSharpLint to all F# projects in your repository. This requires the FSharpLint dotnet tool to be installed and an fsharplint.json configuration file. ```xml ``` -------------------------------- ### FavourNamedMembers Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0094.md Example configuration object to enable or disable the 'favourNamedMembers' rule in FSharpLint. ```json { "favourNamedMembers": { "enabled": false } } ``` -------------------------------- ### Fixing Redundant Lambda Function 2 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0034.md This shows the corrected form of the second example, replacing the redundant lambda with a direct reference to the `foo` function. ```fsharp fun x y -> foo x y is the same as foo ``` -------------------------------- ### Synchronous Library Code Using Async.RunSynchronously Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0090.md This snippet shows an example of library code that incorrectly uses Async.RunSynchronously. This pattern is flagged by the FL0090 rule. ```fsharp type SomeType() = member self.SomeMethod someParam = let foo = asyncSomeFunc someParam |> Async.RunSynchronously processFoo foo ``` -------------------------------- ### Refactoring to Asynchronous Method Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0090.md This example demonstrates how to fix the FL0090 rule by refactoring the method to be asynchronous and return an async computation. It uses `let!` to bind the result of the async operation. ```fsharp type SomeType() = member self.AsyncSomeMethod someParam = async { let! foo = asyncSomeFunc someParam return processFoo foo } ``` -------------------------------- ### Ignoring Files by Glob Pattern Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rule-configuration.md Specify files to be ignored by the linter using glob patterns. This example ignores all files named 'assemblyinfo' with any extension, case-insensitively. ```json { "ignoreFiles": ["assemblyinfo.*"] } ``` -------------------------------- ### Fixing Redundant Lambda Function 1 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0034.md This shows the corrected form of the first example, replacing the redundant lambda with the addition operator `(+)`. ```fsharp fun x y -> x + y is the same as (+) ``` -------------------------------- ### Example of String Formatting Function Without Interpolation Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0087.md This snippet demonstrates the use of a string formatting function like `failwithf` without interpolation. If no formatting is needed, consider using `failwith`. ```fsharp let error = failwithf "An error occurred." ``` -------------------------------- ### Async Function Naming Convention (Task Type) Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0096.md Functions returning 'System.Threading.Task' should be suffixed with 'Async'. This example shows the correct naming for Task-based asynchronous functions. ```fsharp open System.Threading let FooAsync(): Task = task { return 1 } ``` -------------------------------- ### Clone Repository and Set Up Remotes Source: https://github.com/fsprojects/fsharplint/blob/master/CONTRIBUTING.md Steps to fork the FSharpLint project, clone your fork, and configure the upstream remote for tracking changes. ```bash git clone https://github.com//FSharpLint cd FSharpLint git remote add upstream https://github.com/fsprojects/FSharpLint ``` -------------------------------- ### Example of FL0054 Violation Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0054.md This example demonstrates a condition that violates the FL0054 rule by exceeding the default maximum of 4 boolean operators. ```fsharp if x && y || q || r && t && w then ``` -------------------------------- ### Display fsharplint Help Information Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/install-dotnet-tool.md Run this command to view the full usage information and available options for the fsharplint console application. ```bash dotnet fsharplint --help ``` -------------------------------- ### Run Project Build and Tests Source: https://github.com/fsprojects/fsharplint/blob/master/CONTRIBUTING.md Commands to restore project dependencies and build the project using FAKE, ensuring all tests pass before submitting changes. ```bash dotnet tool restore dotnet fake build ``` -------------------------------- ### Mutable vs. Non-Mutable Property Initialization Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0084.md Demonstrates the difference between initializing properties using mutation and using F#'s specific non-mutable syntax. Prefer the non-mutable approach for better code safety. ```fsharp let c = Cookie() c.Domain <- "example.com" ``` ```fsharp Cookie(Domain = "example.com") ``` -------------------------------- ### Providing a C#-Friendly Async Overload with Task Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0090.md This snippet shows how to provide a C#-friendly overload for a public method that returns a Task<'T>. It uses Async.StartAsTask to convert the async computation to a Task. ```fsharp type SomeType() = member self.AsyncSomeMethod someParam = async { let! foo = asyncSomeFunc someParam return processFoo foo } member self.SomeMethodAsync someParam = self.AsyncSomeMethod someParam |> Async.StartAsTask ``` -------------------------------- ### Example of FL0086 Violation Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0086.md This snippet demonstrates the pattern matching structure that triggers the FL0086 rule, where a named pattern is used in a guard against a constant. ```F# match something with | bar when bar = "baz" -> () ``` -------------------------------- ### Example of FL0052 Violation Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0052.md This code snippet demonstrates a function that violates the FL0052 rule by exceeding the default maximum number of parameters (5). ```fsharp let findCat one two three four five six = 0 ``` -------------------------------- ### Match Lambda Functions Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0065.md Match lambda functions using the 'fun args -> ()' syntax. Arguments can be wildcards or variables. ```hint fun x -> x ===> id ``` -------------------------------- ### Run fsharplint Console Application Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/install-dotnet-tool.md This command shows how to run the fsharplint console application to lint files. The input can be an fsproj, sln, fs, fsx file, or a string of source code. ```bash dotnet fsharplint lint ``` -------------------------------- ### Function Composition Replacement Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0035.md Illustrates the equivalent function composition for the lambda functions shown previously. ```fsharp isValid >> not ``` -------------------------------- ### Match Function Application and Operators Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0065.md Match function applications, prefix, and infix operators using standard F# syntax within the hint. ```hint not true ===> false ``` ```hint 4 + 4 ===> 8 ``` ```hint ~x ===> someFunc x ``` -------------------------------- ### Configure Module Naming Rules Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0042.md This JSON configuration enables the moduleNames rule and specifies the expected naming convention (PascalCase) and underscore usage (None). ```json { "moduleNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### Example of FL0024 Violation Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0024.md This snippet demonstrates a value binding that exceeds the maximum line count, triggering the FL0024 rule when the limit is set to 4. ```fsharp let value = let x = 7 let y = 6 let e = 5 let r = 4 r * y * e * x ``` -------------------------------- ### Fixing FL0054 Violation by Naming Expression Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0054.md This example shows how to fix a FL0054 violation by extracting the complex boolean expression into a named variable, improving readability. ```fsharp let catIsInBin = x && y || q || r && t && w if catIsInBin then ``` -------------------------------- ### Create a New Topic Branch Source: https://github.com/fsprojects/fsharplint/blob/master/CONTRIBUTING.md How to create a new branch for your feature, change, or fix, ensuring your local master stays synchronized with upstream. ```bash git checkout -b ``` -------------------------------- ### FL0079 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0079.md Configuration for the suggestUseAutoProperty rule. Set 'enabled' to true to activate this rule. ```json { "suggestUseAutoProperty": { "enabled": false } } ``` -------------------------------- ### FL0024 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0024.md Configuration for the FL0024 rule, showing how to enable/disable it and set the maximum allowed lines for value bindings. ```json { "maxLinesInValue": { "enabled": false, "config": { "maxLines": 100 } } } ``` -------------------------------- ### Enable FL0008 Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0008.md Configure the FL0008 rule in your .fsharplint.json settings to enforce module declaration spacing. ```json { "moduleDeclSpacing": { "enabled": false } } ``` -------------------------------- ### Example of Interpolated String Without Substitution Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0087.md This snippet shows an interpolated string used without any embedded F# expressions. It's recommended to use a regular string or embed an expression if substitution was intended. ```fsharp let message = $"This is a string." ``` -------------------------------- ### Specify Order of Operations with Parentheses Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0065.md Use parentheses in hints to specify the order of operations, including common function application operators like '|>'. ```hint someFunc (not x) ===> someOtherFunc x ``` -------------------------------- ### FL0054 Rule Settings Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0054.md This JSON object shows how to configure the FL0054 rule, including enabling/disabling it and setting the maximum number of allowed boolean operators (`maxItems`). ```json { "maxNumberOfBooleanOperatorsInCondition": { "enabled": false, "config": { "maxItems": 4 } } } ``` -------------------------------- ### Example of FS1182 Warning Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0082.md This F# code snippet demonstrates a scenario where the compiler warning FS1182 might be triggered due to an unused tuple element. It illustrates the problem that the FL0082 rule aims to address by enforcing the convention of underscore-prefixed elements. ```fsharp let SomeFunction (someDuParam: SomeDU) = match someDuParam with | FirstDuMemberWithNoArgs -> true | SecondDuMemberWithTuple(tupleElement1, tupleElement2) -> if tupleElement2.SomeProperty then false else true ``` -------------------------------- ### Using failwith When No Formatting is Needed Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0087.md This snippet demonstrates using `failwith` when string formatting or interpolation is not required, which is the recommended approach in such cases. ```fsharp let error = failwith "A simple error message." ``` -------------------------------- ### Configure Maximum Cyclomatic Complexity Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0071.md This JSON configuration snippet shows how to enable the cyclomatic complexity rule and set the maximum allowed complexity to 40. ```json { "cyclomaticComplexity": { "enabled": true, "config": { "maxComplexity": 40 } } } ``` -------------------------------- ### Rule Settings for FavourSingleton Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0089.md This JSON configuration shows how to enable or disable the FavourSingleton rule. Set 'enabled' to true to activate the rule. ```json { "favourSingleton": { "enabled": false } } ``` -------------------------------- ### Configure Indexer Accessor Style Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0088.md This JSON configuration sets the 'indexerAccessorStyleConsistency' rule to be enabled and specifies the desired style ('OCaml' or 'CSharp'). Use this to enforce a consistent indexer accessor style across your project. ```json { "indexerAccessorStyleConsistency": { "enabled": false, "config": { "style": "OCaml" } } } ``` -------------------------------- ### Enable FavourNestedFunctions Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0091.md This JSON configuration enables the FavourNestedFunctions rule. Set 'enabled' to true to activate this rule. ```json { "FavourNestedFunctions": { "enabled": false } } ``` -------------------------------- ### FL0044 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0044.md This JSON configuration object defines the settings for the FL0044 namespace naming rule. It specifies the expected casing and underscore usage for identifiers. ```json { "namespaceNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### Match Identifier with Hint Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0065.md Match specific F# identifiers (must be at least 2 characters long) in the code using the same identifier in the hint. ```hint List.fold (+) 0 ===> List.sum ``` -------------------------------- ### Rule Settings for FL0055 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0055.md Configuration for the 'favourIgnoreOverLetWild' rule in FSharpLint. This JSON object enables or disables the rule. ```json { "favourIgnoreOverLetWild": { "enabled": true } } ``` -------------------------------- ### FL0060 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0060.md This JSON object shows the configuration for the FL0060 rule, including enabling/disabling the rule and setting the maximum character limit per line. ```json { "maxCharactersOnLine": { "enabled": false, "config": { "maxCharactersOnLine": 120 } } } ``` -------------------------------- ### Configure LiteralNames Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0043.md This JSON configuration enables the literalNames rule and specifies the expected naming convention as PascalCase with no allowed underscores. ```json { "literalNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### Global Configuration for Indentation Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rule-configuration.md Define the number of spaces used for indentation globally. This setting can be omitted to use default values. ```json { "globals": { "numIndentationSpaces": 4 // number of spaces used for indentation } } ``` -------------------------------- ### FL0066 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0066.md This JSON configuration shows how to enable or disable the FL0066 rule and customize its behavior by specifying allowed and additional partial functions. ```json { "noPartialFunctions": { "enabled": false, "config": { "allowedPartials": [], "additionalPartials": [] } } } ``` -------------------------------- ### FL0052 Rule Settings Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0052.md This JSON object shows how to configure the `maxNumberOfFunctionParameters` rule, including enabling/disabling it and setting the `maxItems` limit. ```json { "maxNumberOfFunctionParameters": { "enabled": false, "config": { "maxItems": 5 } } } ``` -------------------------------- ### FL0086 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0086.md Configuration for the favourAsKeyword rule in FSharpLint. Set 'enabled' to true to activate the rule. ```JSON { "favourAsKeyword": { "enabled": true } } ``` -------------------------------- ### Push Topic Branch to Fork Source: https://github.com/fsprojects/fsharplint/blob/master/CONTRIBUTING.md Command to push your newly created topic branch to your GitHub fork, making it available for a pull request. ```bash git push origin ``` -------------------------------- ### Interface Names Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0036.md This JSON configuration object enables and defines the rules for interface naming. It specifies the expected casing, underscore usage, and optional prefix/suffix for interface identifiers. ```json { "interfaceNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None", "prefix": "I" } } } ``` -------------------------------- ### Named Discriminated Union Fields Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0094.md Demonstrates the preferred syntax for discriminated union cases with named fields, enhancing readability. ```fsharp type Data = | TwoParts of part1: string * part2: string | OnePart of part1: string ``` -------------------------------- ### Enable PatternMatchOrClausesOnNewLine Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0005.md Configure the 'patternMatchOrClausesOnNewLine' rule to be enabled in your F# linting settings. ```json { "patternMatchOrClausesOnNewLine": { "enabled": false } } ``` -------------------------------- ### Active Pattern Naming Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0048.md This JSON configuration object specifies the rules for active pattern naming. It enables the rule and defines the expected casing ('PascalCase') and underscore usage ('None'). ```json { "activePatternNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### FL0061 Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0061.md This JSON object shows the configuration settings for the trailingWhitespaceOnLine rule. It includes options to enable/disable the rule and specify allowed whitespace. ```json { "trailingWhitespaceOnLine": { "enabled": false, "config": { "numberOfSpacesAllowed": 1, "oneSpaceAllowedAfterOperator": true, "ignoreBlankLines": true } } } ``` -------------------------------- ### Rule Settings for favourStaticEmptyFields Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0076.md This JSON object shows how to configure the favourStaticEmptyFields rule, including enabling or disabling it. ```json { "favourStaticEmptyFields": { "enabled": false } } ``` -------------------------------- ### Rule Settings for failwithBadUsage Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0072.md This JSON object shows how to enable or disable the FL0072 rule in your F# linting configuration. ```json { "failwithBadUsage": { "enabled": true } } ``` -------------------------------- ### FL0053 Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0053.md This JSON configuration snippet shows how to enable and set the maximum number of members for the FL0053 rule. The 'maxItems' property defines the threshold for flagging a class. ```json { "maxNumberOfMembers": { "enabled": false, "config": { "maxItems": 32 } } } ``` -------------------------------- ### Configure Exception Naming Rules Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0037.md This JSON configuration object specifies the rules for exception naming. You can enable the rule and define the expected casing, underscore usage, and required suffix for exception identifiers. ```json { "exceptionNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None", "suffix": "Exception" } } } ``` -------------------------------- ### FL0011 Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0011.md This JSON configuration object enables and configures the 'typePrefixing' rule (FL0011). The 'mode' setting can be set to 'Hybrid', 'Always', or 'Never' to control how the rule is enforced. ```json { "typePrefixing": { "enabled": false, "config": { "mode": "Hybrid" } } } ``` -------------------------------- ### Configure Private Value Naming Rules Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0067.md This JSON configuration enables the privateValuesNames rule and specifies the expected naming convention as CamelCase with optional prefixes. ```json { "privateValuesNames": { "enabled": true, "config": { "naming": "CamelCase", "underscores": "AllowPrefix" } } } ``` -------------------------------- ### FL0027 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0027.md This JSON configuration enables or disables the FL0027 rule and sets the maximum allowed lines for a constructor. The default 'maxLines' is 100. ```json { "maxLinesInConstructor": { "enabled": false, "config": { "maxLines": 100 } } } ``` -------------------------------- ### Multiple Pipe Operator Usage Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0077.md Demonstrates the correct usage of the pipe operator for chaining multiple function calls, which is not flagged by this rule. ```fsharp let someFunc someParam = someParam |> someOtherFunc |> yetAnotherFunc ``` -------------------------------- ### Configure TypedItemSpacing Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0010.md This JSON configuration enables the typedItemSpacing rule and sets the desired spacing style to 'NoSpaces'. ```json { "typedItemSpacing": { "enabled": false, "config": { "typedItemStyle": "NoSpaces" } } } ``` -------------------------------- ### FL0046 Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0046.md This JSON configuration enables the parameterNames rule and specifies the expected naming convention (CamelCase) and underscore usage (AllowPrefix). ```json { "parameterNames": { "enabled": true, "config": { "naming": "CamelCase", "underscores": "AllowPrefix" } } } ``` -------------------------------- ### Rule Settings for noAsyncRunSynchronouslyInLibrary Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0090.md This JSON snippet shows the configuration for the noAsyncRunSynchronouslyInLibrary rule, indicating how to enable or disable it. ```json { "noAsyncRunSynchronouslyInLibrary": { "enabled": true } } ``` -------------------------------- ### Rule Settings for RedundantNewKeyword Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0014.md This JSON configuration shows how to enable or disable the redundantNewKeyword rule in fsharplint. ```json { "redundantNewKeyword": { "enabled": false } } ``` -------------------------------- ### Fixing Missing Task Complement Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0097.md To fix a missing Task complement for an Async function, create a FooAsync function that calls Async.StartAsTask. ```fsharp let FooAsync(): Task = Async.StartAsTask(AsyncFoo()) ``` -------------------------------- ### Record Field Naming Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0039.md Configure the naming convention and underscore rules for record fields. The 'naming' option specifies the expected casing, and 'underscores' defines allowed underscore usage. Optional 'prefix' and 'suffix' can also be enforced. ```json { "recordFieldNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### Rule Settings for FL0035 Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0035.md Configuration for enabling or disabling the FL0035 rule. ```json { "canBeReplacedWithComposition": { "enabled": true } } ``` -------------------------------- ### Configure Internal Value Naming Rules Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0068.md This JSON configuration object defines the settings for the `internalValuesNames` rule. It specifies the expected naming convention (e.g., CamelCase) and rules for underscore usage (e.g., AllowPrefix). ```json { "internalValuesNames": { "enabled": true, "config": { "naming": "CamelCase", "underscores": "AllowPrefix" } } } ``` -------------------------------- ### FL0034 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0034.md Configuration for the ReimplementsFunction (FL0034) rule, showing how to enable or disable it. ```json { "reimplementsFunction": { "enabled": true } } ``` -------------------------------- ### Configure Union Case Naming Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0041.md This JSON configuration enables the unionCasesNames rule and sets the expected naming convention to PascalCase with no allowed underscores. ```json { "unionCasesNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### FL0004 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0004.md Configuration for the FL0004 rule. Set 'enabled' to true to enforce the rule. ```json { "patternMatchClausesOnNewLine": { "enabled": false } } ``` -------------------------------- ### TypeNames Rule Configuration Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0038.md This JSON configuration enables the typeNames rule and specifies 'PascalCase' for naming and disallows underscores. ```json { "typeNames": { "enabled": true, "config": { "naming": "PascalCase", "underscores": "None" } } } ``` -------------------------------- ### Configure MaxLinesInUnion Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0032.md This JSON configuration snippet shows how to enable and set the maximum line limit for the MaxLinesInUnion rule. The 'maxLines' property defines the threshold. ```json { "maxLinesInUnion": { "enabled": false, "config": { "maxLines": 500 } } } ``` -------------------------------- ### FL0022 Rule Settings Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0022.md This JSON configuration shows how to enable and set the maximum allowed lines for lambda functions in F# Lint. The 'maxLines' property is configurable. ```json { "maxLinesInLambdaFunction": { "enabled": false, "config": { "maxLines": 7 } } } ``` -------------------------------- ### Configure MaxLinesInFile Rule Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0062.md This JSON configuration disables the rule and sets the maximum allowed lines per file to 1000. Adjust 'maxLinesInFile' to your project's needs. ```json { "maxLinesInFile": { "enabled": false, "config": { "maxLinesInFile": 1000 } } } ``` -------------------------------- ### Rule Settings for Synchronous Function Names Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0095.md Configuration object to enable or disable the synchronous function names rule. ```json { "synchronousFunctionNames": { "enabled": true } } ``` -------------------------------- ### Match Any Expression with Variables and Wildcards Source: https://github.com/fsprojects/fsharplint/blob/master/docs/content/how-tos/rules/FL0065.md Use variables (single letters) or wildcards (_) to match any F# expression. Variables can be referenced in the suggestion. ```hint not (a >= b) ===> a < b ```