Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3482661
build: run FSharpLint with 1 extra rule
Mersho Dec 12, 2023
8b716ea
build: run FSharpLint with 1 extra rule
Mersho Dec 12, 2023
7ac7fe2
Core,Tests: fix FSharpLint warning
Mersho Dec 12, 2023
f259492
build: run FSharpLint with 1 extra rule
Mersho Dec 12, 2023
83738b1
build: run FSharpLint with 1 extra rule
Mersho Dec 12, 2023
75432be
Core.Tests: fix FSharpLint warning
Mersho Feb 1, 2024
6b9fef6
build: run FSharpLint with 1 extra rule
Mersho Dec 12, 2023
109979e
Core: fix FSharpLint warning
Mersho Dec 13, 2023
06e8419
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
bc139f2
Core.Tests: fix FSharpLint warning
Mersho Feb 1, 2024
b67fd00
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
8442de9
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
59d6110
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
8b95d5b
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
88e5143
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
74e8e55
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
3d1c098
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
80e2a42
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
74d42c1
Core,Tests: fix FSharpLint warning
Mersho Dec 13, 2023
729216a
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
7df8c9e
Core,Tests: fix FSharpLint warning
Mersho Dec 13, 2023
6c0ce42
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
86e423b
Core,Tests: fix FSharpLint warning
webwarrior-ws Jul 29, 2025
4a6cf75
build: run FSharpLint with 1 extra rule
Mersho Dec 13, 2023
e9410e8
Console,Core,Tests: fix FSharpLint warning
Mersho Dec 13, 2023
18852db
build: run FSharpLint with 1 extra rule
Mersho Dec 18, 2023
681c301
build: run FSharpLint with 1 extra rule
Mersho Dec 22, 2023
041cd26
build: run FSharpLint with 1 extra rule
Mersho Dec 22, 2023
a8d48ce
Core,Tests: fix FSharpLint warning
Mersho Dec 22, 2023
0efbfcf
build: run FSharpLint with 1 extra rule
Mersho Dec 25, 2023
3a61be5
build: run FSharpLint with 1 extra rule
Mersho Dec 25, 2023
0f3688d
build: run FSharpLint with 1 extra rule
knocte Jan 6, 2024
32c3773
Core,Tests: fix FSharpLint warning
Mersho Jan 10, 2024
632f0e8
build: explain skipping NoPartialFunctions rule
Mersho Dec 18, 2023
74fdc0e
build: run FSharpLint with 1 extra rule
Mersho Feb 8, 2024
21e5416
Core,Tests: fix FSharpLint warnings
webwarrior-ws Jul 30, 2025
35ae87f
build: run FSharpLint with 1 extra rule
Mersho Feb 8, 2024
00fb057
Core: fix FSharpLint warning
Mersho Feb 8, 2024
a605197
Core(fsharplinit.json): enable rule by default
knocte Aug 13, 2025
c3ed7f0
Core: fix FSharpLint tail call warnings
webwarrior-ws Jul 30, 2025
bca8db7
build: refactoring for rule activation
Mersho Feb 7, 2024
6cc56af
build.fsx: use System.Text.Json
webwarrior-ws Aug 13, 2025
16281e2
tests: refactoring for DRY principle
Mersho Feb 8, 2024
628b178
Core: rename some funcs and params
webwarrior-ws Aug 13, 2025
c5388d4
tests: add *why* & re-enable rule after
webwarrior-ws Aug 13, 2025
7fdbff0
build.fsx: improve comments about excluded rules
knocte Aug 13, 2025
27f4222
build: run FSharpLint with 1 extra rule
knocte Aug 13, 2025
54ab0a3
Core,Tests: apply TupleParentheses rule suggestions
knocte Aug 13, 2025
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
8 changes: 7 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
# that they are unlikely to be what you are interested in when blaming.
# Like formatting with Fantomas
# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
# Add formatting commits here

# Console,Core,Tests: fix FSharpLint warning (Fixing the warning for AvoidTooShortNames rule.)
e9410e83af1de4d76230b0e8d44ae6a99fac6d7b

# Core: rename some funcs and params
628b1786e7f913ecd87e42a45ab7f195c536a6cb

65 changes: 59 additions & 6 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ open Fake.Api

open System
open System.IO
open System.Text.Json.Nodes

Target.initEnvironment()

Expand Down Expand Up @@ -249,12 +250,64 @@ Target.create "Push" (fun _ ->


Target.create "SelfCheck" (fun _ ->
let srcDir = Path.Combine(rootDir.FullName, "src") |> DirectoryInfo

let consoleProj = Path.Combine(srcDir.FullName, "FSharpLint.Console", "FSharpLint.Console.fsproj") |> FileInfo
let sol = Path.Combine(rootDir.FullName, solutionFileName) |> FileInfo
exec "dotnet" $"run --framework net9.0 lint %s{sol.FullName}" consoleProj.Directory.FullName
)
let runLinter () =
let srcDir = Path.Combine(rootDir.FullName, "src") |> DirectoryInfo

let consoleProj = Path.Combine(srcDir.FullName, "FSharpLint.Console", "FSharpLint.Console.fsproj") |> FileInfo
let sol = Path.Combine(rootDir.FullName, solutionFileName) |> FileInfo

exec "dotnet" $"run --framework net9.0 lint %s{sol.FullName}" consoleProj.Directory.FullName

printfn "Running self-check with default rules..."
runLinter ()

let fsharplintJsonDir = Path.Combine("src", "FSharpLint.Core", "fsharplint.json")
let fsharplintJsonText = File.ReadAllText fsharplintJsonDir

let excludedRules =
[
// Formatting rules (maybe mark them as DEPRECATED soon, recommending the use of `fantomas` instead)
"typedItemSpacing"
"unionDefinitionIndentation"
"moduleDeclSpacing"
"classMemberSpacing"
"tupleCommaSpacing"
"tupleIndentation"
"patternMatchClausesOnNewLine"
"patternMatchOrClausesOnNewLine"
"patternMatchClauseIndentation"
"patternMatchExpressionIndentation"
"indentation"
"maxCharactersOnLine"
"trailingNewLineInFile"
"trailingWhitespaceOnLine"

// TODO: we should enable at some point
"typePrefixing"
"unnestedFunctionNames"
"nestedFunctionNames"
"nestedStatements"

// Running NoPartialFunctions on this file causes a bug in FSharp.Compiler, so skip it for now
"noPartialFunctions"

// rule is too complex, we can enable it later
"cyclomaticComplexity"
]

let jsonObj = JsonObject.Parse fsharplintJsonText

for pair in jsonObj.AsObject() do
if pair.Value.GetValueKind() = Text.Json.JsonValueKind.Object then
match pair.Value.AsObject().TryGetPropertyValue("enabled") with
| true, isRule when not (List.contains pair.Key excludedRules) ->
isRule.AsValue().ReplaceWith true
| _ -> ()

File.WriteAllText(fsharplintJsonDir, jsonObj.ToJsonString())

printfn "Now re-running self-check with more rules enabled..."
runLinter ())

// --------------------------------------------------------------------------------------
// Build order
Expand Down
5 changes: 2 additions & 3 deletions src/FSharpLint.Console/Output.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type StandardOutput () =
if String.length errorLine = 0 then "^"
else
errorLine
|> Seq.mapi (fun i _ -> if i = range.StartColumn then "^" else " ")
|> Seq.mapi (fun index _ -> if index = range.StartColumn then "^" else " ")
|> Seq.reduce (+)
$"{getErrorMessage range}{Environment.NewLine}{errorLine}{Environment.NewLine}{highlightColumnLine}"

Expand Down Expand Up @@ -59,5 +59,4 @@ type MSBuildOutput () =
<| warning.RuleIdentifier
<| warning.Details.Message
member _.WriteError (error:string) =
$"FSharpLint error: {error}"
|> Console.Error.WriteLine
Console.Error.WriteLine $"FSharpLint error: {error}"
12 changes: 6 additions & 6 deletions src/FSharpLint.Console/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ let private parserProgress (output:Output.IOutput) = function
String.Format(Resources.GetString("ConsoleFinishedFile"), List.length warnings) |> output.WriteInfo
| Failed (file, parseException) ->
String.Format(Resources.GetString("ConsoleFailedToParseFile"), file) |> output.WriteError
$"Exception Message:{Environment.NewLine}{parseException.Message}{Environment.NewLine}Exception Stack Trace:{Environment.NewLine}{parseException.StackTrace}{Environment.NewLine}"
|> output.WriteError
output.WriteError
$"Exception Message:{Environment.NewLine}{parseException.Message}{Environment.NewLine}Exception Stack Trace:{Environment.NewLine}{parseException.StackTrace}{Environment.NewLine}"

/// Infers the file type of the target based on its file extension.
let internal inferFileType (target:string) =
Expand All @@ -84,7 +84,7 @@ let private start (arguments:ParseResults<ToolArgs>) (toolsPath:Ionide.ProjInfo.
let version =
Assembly.GetExecutingAssembly().GetCustomAttributes false
|> Seq.pick (function | :? AssemblyInformationalVersionAttribute as aiva -> Some aiva.InformationalVersion | _ -> None)
$"Current version: {version}" |> output.WriteInfo
output.WriteInfo $"Current version: {version}"
Environment.Exit 0

let handleError (str:string) =
Expand Down Expand Up @@ -129,10 +129,10 @@ let private start (arguments:ParseResults<ToolArgs>) (toolsPath:Ionide.ProjInfo.
| _ -> Lint.lintProject lintParams target toolsPath
handleLintResult lintResult
with
| e ->
| exn ->
let target = if fileType = FileType.Source then "source" else target
$"Lint failed while analysing %s{target}.{Environment.NewLine}Failed with: %s{e.Message}{Environment.NewLine}Stack trace: {e.StackTrace}"
|> handleError
handleError
$"Lint failed while analysing %s{target}.{Environment.NewLine}Failed with: %s{exn.Message}{Environment.NewLine}Stack trace: {exn.StackTrace}"
| _ -> ()

exitCode
Expand Down
Loading
Loading