Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/how-tos/rules/FL0006.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ Uses the `numIndentationSpaces` global setting.
}
}

* *allowSingleLineLambda* - whether or not to allow single-line lambda pattern matches
* *allowSingleLineLambda* - whether or not to allow single-line lambda pattern matches.
2 changes: 1 addition & 1 deletion docs/content/how-tos/rules/FL0010.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Update typed item to use configured spacing.
}
}

* *typedItemStyle* - style of spacing: "NoSpaces", "SpaceAfter", "SpacesAround"
* *typedItemStyle* - style of spacing: "NoSpaces", "SpaceAfter", "SpacesAround".
2 changes: 1 addition & 1 deletion docs/content/how-tos/rules/FL0011.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Update higher order type to have correct formatting as per guide linked above.
}
}

* *mode* - how to enforce the rule ("Hybrid" or "Always" or "Never")
* *mode* - how to enforce the rule: "Hybrid", "Always", or "Never"
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0036.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0037.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0038.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0039.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0040.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0041.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0042.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0043.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0044.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0045.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0046.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0047.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0048.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0049.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
6 changes: 3 additions & 3 deletions docs/content/how-tos/rules/FL0050.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Consistency aides readability.

## How To Fix

Update the non-public value's naming to be consistent with the rules you have specified
Update the non-public value's naming to be consistent with the rules you have specified.

## Rule Settings

Expand All @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0055.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ hide_menu: true

## Cause

A value is binded to a wildcard e.g. `let _ = Console.ReadLine()`
A value is binded to a wildcard e.g. `let _ = Console.ReadLine()`.

## Rationale

Using the ignore function makes it clear what is intended to happen, rather than something that may be a mistake.

## How To Fix

Pipe the value into the ignore function e.g. `Console.ReadLine() |> ignore`
Pipe the value into the ignore function e.g. `Console.ReadLine() |> ignore`.

## Rule Settings

Expand Down
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0056.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ hide_menu: true

## Cause

A wildcard is given a name using the as pattern e.g. `match something with | _ as x -> x + y`
A wildcard is given a name using the as pattern e.g. `match something with | _ as x -> x + y`.

## Rationale

The wildcard and as pattern can be replaced with the identifier the value is to be bound to.

## How To Fix

Replace the wildcard with the identifier the wildcard is currently being bound to, e.g. change `match something with | _ as x -> x + y` to `match something with | x -> x + y`
Replace the wildcard with the identifier the wildcard is currently being bound to, e.g. change `match something with | _ as x -> x + y` to `match something with | x -> x + y`.

## Rule Settings

Expand Down
2 changes: 1 addition & 1 deletion docs/content/how-tos/rules/FL0057.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ hide_menu: true

## Cause

An identifier is binded to itself e.g. `let x = x`
An identifier is binded to itself e.g. `let x = x`.

## Rationale

Expand Down
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0058.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ hide_menu: true

## Cause

A constructor in a pattern has arguments that consist entirely of wildcards e.g. `SynPat.Paren(_, _)`
A constructor in a pattern has arguments that consist entirely of wildcards e.g. `SynPat.Paren(_, _)`.

## Rationale

The tuple of wildcards can be replaced with a single wildcard.

## How To Fix

Replace the tuple with a single wildcard e.g. the example in the cause could be turned into `SynPat.Paren(_)`
Replace the tuple with a single wildcard e.g. the example in the cause could be turned into `SynPat.Paren(_)`.

## Rule Settings

Expand Down
6 changes: 3 additions & 3 deletions docs/content/how-tos/rules/FL0061.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Remove any whitespace from the end of the line.
}
}

* *numberOfSpacesAllowed* - An integer property that specifies how many space characters are allowed on the end of a line. (Default 1)
* *oneSpaceAllowedAfterOperator* - A boolean property that will allow a single space on the end of the line if it's preceded by an operator/symbol character. (Default true)
* *ignoreBlankLines* - A boolean property that will ignore any lines that are made up of just whitespace. (Default true)
* *numberOfSpacesAllowed* - An integer property that specifies how many space characters are allowed on the end of a line (default: 1).
* *oneSpaceAllowedAfterOperator* - A boolean property that will allow a single space on the end of the line if it's preceded by an operator/symbol character (default: true).
* *ignoreBlankLines* - A boolean property that will ignore any lines that are made up of just whitespace (default: true).
6 changes: 3 additions & 3 deletions docs/content/how-tos/rules/FL0065.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Every hint is formed of two parts: the match and the suggestion. Both the match

Any F# expression can be matched by a variable or wildcard.

* A variable is represented by a single letter e.g. `x`
* A wildcard is represented by the character `_`
* A variable is represented by a single letter e.g. `x`.
* A wildcard is represented by the character `_`.

Variables and wildcards are seemingly the same, and in terms of matching they are. The key difference is that using a variable lets you refer to it in the suggestion, enabling you to show where the matched expression should be moved within the matched code.

Expand Down Expand Up @@ -59,7 +59,7 @@ In the example above the boolean literal `true` is used to match any F# code whe

### Match Function Application and Operators

Matching function application, prefix operators, and infix operators in hints are all done in the same way as how you'd write it in F# e.g.
Matching function application, prefix operators, and infix operators in hints are all done in the same way as how you'd write it in F# e.g.:

[lang=hint]
not true ===> false
Expand Down
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0066.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Use non-partial function or pattern matching.
}
}

* *allowedPartials* - list of strings representing partial functions to allow (e.g. `"List.tryFind"`)
* *additionalPartials* - list of strings representing additional partial functions to disallow
* *allowedPartials* - list of strings representing partial functions to allow (e.g. `"List.tryFind"`).
* *additionalPartials* - list of strings representing additional partial functions to disallow.
4 changes: 2 additions & 2 deletions docs/content/how-tos/rules/FL0067.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
6 changes: 3 additions & 3 deletions docs/content/how-tos/rules/FL0068.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Consistency aides readability.

## How To Fix

Update the internal value's naming to be consistent with the rules you have specified
Update the internal value's naming to be consistent with the rules you have specified.

## Rule Settings

Expand All @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
6 changes: 3 additions & 3 deletions docs/content/how-tos/rules/FL0069.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Consistency aides readability.

## How To Fix

Update the generic type naming to be consistent with the rules you have specified
Update the generic type naming to be consistent with the rules you have specified.

## Rule Settings

Expand All @@ -34,7 +34,7 @@ Note, any of the settings below can be omitted and will not be checked.
}
}

* *naming* - expected casing of the identifiers ("PascalCase" or "CamelCase")
* *underscores* - if underscores are allowed in the identifiers ("AllowPrefix", "AllowAny", or "None")
* *naming* - expected casing of the identifiers: "PascalCase", "CamelCase", "AllUppercase", or "AllLowercase".
* *underscores* - if underscores are allowed in the identifiers: "AllowPrefix", "AllowInfix", "AllowAny", or "None".
* *prefix* - prefix string expected on the front of the identifiers.
* *suffix* - suffix string expected on the end of the identifiers.
6 changes: 3 additions & 3 deletions docs/content/how-tos/rules/FL0086.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ hide_menu: true

## Cause

A named pattern is used just to be compared in the guard against a constant expression e.g. `match something with | bar when bar = "baz" -> ()`
A named pattern is used just to be compared in the guard against a constant expression e.g. `match something with | bar when bar = "baz" -> ()`.

## Rationale

The named pattern can be changed to an as pattern that uses a constant pattern, improving the pattern matching exhaustiveness check
The named pattern can be changed to an as pattern that uses a constant pattern, improving the pattern matching exhaustiveness check.

## How To Fix

Remove the guard and replace the named pattern with the as pattern using a constant pattern, e.g. change `match something with | bar when bar = "baz" -> ()` to `match something with | "baz" as bar -> ()`
Remove the guard and replace the named pattern with the as pattern using a constant pattern, e.g. change `match something with | bar when bar = "baz" -> ()` to `match something with | "baz" as bar -> ()`.

## Rule Settings

Expand Down
3 changes: 3 additions & 0 deletions src/FSharpLint.Core/Framework/Rules.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ type AstNodeRuleConfig =
type NamingCase =
| PascalCase = 0
| CamelCase = 1
| AllLowercase = 2
| AllUppercase = 3

type NamingUnderscores =
| None = 0
| AllowPrefix = 1
| AllowAny = 2
| AllowInfix = 3

type NamingConfig =
{ Naming:NamingCase option
Expand Down
2 changes: 2 additions & 0 deletions src/FSharpLint.Core/Rules/Conventions/Naming/LiteralNames.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ let private getIdentifiers (args:AstNodeRuleParams) =
let rec getLiteralIdents = function
| SynPat.Named(SynIdent(identifier, _), _, _, _) ->
Array.singleton (identifier, identifier.idText, None)
| SynPat.LongIdent(SynLongIdent([identifier], _, _), _, _, _, _, _) ->
Array.singleton (identifier, identifier.idText, None)
| SynPat.Paren(pat, _) -> getLiteralIdents pat
| _ -> Array.empty

Expand Down
Loading
Loading