-
Notifications
You must be signed in to change notification settings - Fork 72
/
Lint.fsi
147 lines (110 loc) · 6.27 KB
/
Lint.fsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
namespace FSharpLint.Application
/// Provides an API to manage/load FSharpLint configuration files.
/// <see cref="FSharpLint.Framework.Configuration" /> for more information on
/// the default configuration and overriding configurations.
module ConfigurationManagement =
open FSharpLint.Framework.Configuration
/// Load a FSharpLint configuration file from the contents (string) of the file.
val loadConfigurationFile : configurationFileText:string -> Configuration
/// Provides an API for running FSharpLint from within another application.
[<AutoOpen>]
module Lint =
open System.Threading
open FSharpLint.Framework
open FSharpLint.Framework.Configuration
open FSharpLint.Framework.Rules
open FSharp.Compiler.Text
open FSharp.Compiler.CodeAnalysis
/// Provides information on what the linter is currently doing.
[<NoComparison>]
type ProjectProgress =
/// Started parsing a file (file path).
| Starting of string
/// Finished parsing a file (file path).
| ReachedEnd of string * Suggestion.LintWarning list
/// Failed to parse a file (file path, exception that caused failure).
| Failed of string * System.Exception
/// Path of the F# file the progress information is for.
member FilePath : unit -> string
type ConfigurationParam =
| Configuration of Configuration
| FromFile of configPath:string
/// Tries to load the config from file `fsharplint.json`.
/// If this file doesn't exist or is invalid, falls back to the default configuration.
| Default
/// Optional parameters that can be provided to the linter.
[<NoEquality; NoComparison>]
type OptionalLintParameters = {
/// Cancels a lint in progress.
CancellationToken: CancellationToken option
/// Lint configuration to use.
/// Can either specify a full configuration object, or a path to a file to load the configuration from.
/// You can also explicitly specify the default configuration.
Configuration: ConfigurationParam
/// This function will be called every time the linter finds a broken rule.
ReceivedWarning: (Suggestion.LintWarning -> unit) option
ReportLinterProgress: (ProjectProgress -> unit) option
} with
static member Default: OptionalLintParameters
/// If your application has already parsed the F# source files using `FSharp.Compiler.Services`
/// you want to lint then this can be used to provide the parsed information to prevent the
/// linter from parsing the file again.
[<NoEquality; NoComparison>]
type ParsedFileInformation = {
/// File represented as an AST.
Ast: FSharp.Compiler.Syntax.ParsedInput
/// Contents of the file.
Source: string
/// Optional results of inferring the types on the AST (allows for a more accurate lint).
TypeCheckResults: FSharpCheckFileResults option
}
type BuildFailure = | InvalidProjectFileMessage of string
/// Reason for the linter failing.
[<NoComparison>]
type LintFailure =
/// Project file path did not exist on the local filesystem.
| ProjectFileCouldNotBeFound of string
/// Received exception when trying to get the list of F# file from the project file.
| MSBuildFailedToLoadProjectFile of string * BuildFailure
/// Failed to load a FSharpLint configuration file.
| FailedToLoadConfig of string
/// The specified file for linting could not be found.
| FailedToLoadFile of string
/// Failed to analyse a loaded FSharpLint configuration at runtime e.g. invalid hint.
| RunTimeConfigError of string
/// `FSharp.Compiler.Services` failed when trying to parse a file.
| FailedToParseFile of ParseFile.ParseFileFailure
/// `FSharp.Compiler.Services` failed when trying to parse one or more files in a project.
| FailedToParseFilesInProject of ParseFile.ParseFileFailure list
member Description: string
type Context =
{ IndentationRuleContext : Map<int,bool*int>
// TODO: investigate incorrect indentation warning
// fsharplint:disable-next-line Indentation
NoTabCharactersRuleContext : (string * Range) list }
/// Result of running the linter.
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type LintResult =
| Success of Suggestion.LintWarning list
| Failure of LintFailure
member TryGetSuccess : byref<Suggestion.LintWarning list> -> bool
member TryGetFailure : byref<LintFailure> -> bool
/// Runs all rules which take a node of the AST as input.
val runAstNodeRules : RuleMetadata<AstNodeRuleConfig> [] -> Rules.GlobalRuleConfig -> FSharpCheckFileResults option -> string -> string -> string [] -> AbstractSyntaxArray.Node [] -> Suggestion.LintWarning [] * Context
/// Runs all rules which take a line of text as input.
val runLineRules : LineRules -> Rules.GlobalRuleConfig -> string -> string -> string [] -> Context -> Suggestion.LintWarning []
/// Lints an entire F# solution by linting all projects specified in the `.sln` file.
val lintSolution : optionalParams:OptionalLintParameters -> solutionFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> LintResult
/// Lints an entire F# project by retrieving the files from a given
/// path to the `.fsproj` file.
val lintProject : optionalParams:OptionalLintParameters -> projectFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> LintResult
/// Lints F# source code.
val lintSource : optionalParams:OptionalLintParameters -> source:string -> LintResult
/// Lints F# source code that has already been parsed using
/// `FSharp.Compiler.Services` in the calling application.
val lintParsedSource : optionalParams:OptionalLintParameters -> parsedFileInfo:ParsedFileInformation -> LintResult
/// Lints an F# file from a given path to the `.fs` file.
val lintFile : optionalParams:OptionalLintParameters -> filePath:string -> LintResult
/// Lints an F# file that has already been parsed using
/// `FSharp.Compiler.Services` in the calling application.
val lintParsedFile : optionalParams:OptionalLintParameters -> parsedFileInfo:ParsedFileInformation -> filePath:string -> LintResult