From 029952e5405a3bd8b081427c744c906bf02f1583 Mon Sep 17 00:00:00 2001 From: webwarrior-ws Date: Wed, 24 Dec 2025 10:53:14 +0100 Subject: [PATCH 1/3] Console: process multiple targets All supplied targets are processed (instead of only the last one, as it was before), but only if the --file-type is given or inferred type is the same for all targets. Otherwise there will be an error. Fixes https://github.com/fsprojects/FSharpLint/issues/802 --- src/FSharpLint.Console/Program.fs | 54 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/FSharpLint.Console/Program.fs b/src/FSharpLint.Console/Program.fs index b5e59f28a..653f50eea 100644 --- a/src/FSharpLint.Console/Program.fs +++ b/src/FSharpLint.Console/Program.fs @@ -159,30 +159,44 @@ let private start (arguments:ParseResults) (toolsPath:Ionide.ProjInfo. Configuration = configParam ReportLinterProgress = Some (parserProgress output) } - let target = lintArgs.GetResult Target - let fileType = lintArgs.TryGetResult File_Type |> Option.defaultValue (inferFileType target) + let targets = lintArgs.GetResults Target + + let fileType = + match lintArgs.TryGetResult File_Type with + | Some fileType -> + fileType + | None -> + match targets |> List.map inferFileType |> List.distinct with + | [ inferredType ] -> + inferredType + | inferredTypes -> + handleError $"""Given targets were inferred to have multiple types: {inferredTypes}. +Specify file type by passing --file-type argument.""" + exit exitCode + failwith "Unreachable" try - let lintResult = - match fileType with - | FileType.File -> Lint.lintFile lintParams target - | FileType.Source -> Lint.lintSource lintParams target - | FileType.Solution -> Lint.lintSolution lintParams target toolsPath - | FileType.Wildcard -> - output.WriteInfo "Wildcard detected, but not recommended. Using a project (slnx/sln/fsproj) can detect more issues." - let files = expandWildcard target - if List.isEmpty files then - output.WriteInfo $"No files matching pattern '%s{target}' were found." - LintResult.Success List.empty - else - output.WriteInfo $"Found %d{List.length files} file(s) matching pattern '%s{target}'." - Lint.lintFiles lintParams files - | FileType.Project - | _ -> Lint.lintProject lintParams target toolsPath - handleLintResult lintResult + for target in targets do + let lintResult = + match fileType with + | FileType.File -> Lint.lintFile lintParams target + | FileType.Source -> Lint.lintSource lintParams target + | FileType.Solution -> Lint.lintSolution lintParams target toolsPath + | FileType.Wildcard -> + output.WriteInfo "Wildcard detected, but not recommended. Using a project (slnx/sln/fsproj) can detect more issues." + let files = expandWildcard target + if List.isEmpty files then + output.WriteInfo $"No files matching pattern '%s{target}' were found." + LintResult.Success List.empty + else + output.WriteInfo $"Found %d{List.length files} file(s) matching pattern '%s{target}'." + Lint.lintFiles lintParams files + | FileType.Project + | _ -> Lint.lintProject lintParams target toolsPath + handleLintResult lintResult with | exn -> - let target = if fileType = FileType.Source then "source" else target + let target = if fileType = FileType.Source then "source" else String.Join(", ", targets) handleError $"Lint failed while analysing %s{target}.{Environment.NewLine}Failed with: %s{exn.Message}{Environment.NewLine}Stack trace: {exn.StackTrace}" | _ -> () From ee14b6d3c3c24fe68c287b6270fec93836c622be Mon Sep 17 00:00:00 2001 From: webwarrior-ws Date: Mon, 22 Dec 2025 13:32:23 +0100 Subject: [PATCH 2/3] GithubCI: lint single file in .NET 8 and 10 jobs Instead of whole Console project. For simplicity. --- .github/workflows/build+test+deploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build+test+deploy.yml b/.github/workflows/build+test+deploy.yml index 1aa9c4182..e92ae68e2 100644 --- a/.github/workflows/build+test+deploy.yml +++ b/.github/workflows/build+test+deploy.yml @@ -164,8 +164,8 @@ jobs: run: dotnet tool install --global dotnet-fsharplint --prerelease --framework net8.0 - name: Add .NET tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - - name: Lint FSharpLint.Console project (net8.0 only) - run: dotnet fsharplint lint ./src/FSharpLint.Console/FSharpLint.Console.fsproj --framework net8.0 + - name: Lint a file (net8.0) + run: dotnet fsharplint lint --framework net8.0 ./src/FSharpLint.Console/Program.fs testReleaseBinariesWithDotNet10: needs: packReleaseBinaries @@ -198,5 +198,5 @@ jobs: run: dotnet tool install --global dotnet-fsharplint --prerelease - name: Add .NET tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - - name: Lint FSharpLint.Console project - run: dotnet fsharplint lint ./src/FSharpLint.Console/FSharpLint.Console.fsproj + - name: Lint a file (net10.0) + run: dotnet fsharplint lint ./src/FSharpLint.Console/Program.fs From d729e9aa2182e96a94afac6198ab901a927a1434 Mon Sep 17 00:00:00 2001 From: webwarrior-ws Date: Wed, 24 Dec 2025 11:42:18 +0100 Subject: [PATCH 3/3] GithubCI: remove --framework argument When doing lint in testReleaseBinariesInDotNet8Container job. * Job was already installing specific image that only has .NET8 (not newer, not older). * Commit a3f6216fb (the one that introduced this job) was wrong anyway because --framework flag is for dotnet run, doesn't work for dotnet tools. --- .github/workflows/build+test+deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build+test+deploy.yml b/.github/workflows/build+test+deploy.yml index e92ae68e2..08b2a2ed4 100644 --- a/.github/workflows/build+test+deploy.yml +++ b/.github/workflows/build+test+deploy.yml @@ -165,7 +165,7 @@ jobs: - name: Add .NET tools to PATH run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH - name: Lint a file (net8.0) - run: dotnet fsharplint lint --framework net8.0 ./src/FSharpLint.Console/Program.fs + run: dotnet fsharplint lint ./src/FSharpLint.Console/Program.fs testReleaseBinariesWithDotNet10: needs: packReleaseBinaries