-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathLint.fsi
More file actions
214 lines (162 loc) · 9.74 KB
/
Copy pathLint.fsi
File metadata and controls
214 lines (162 loc) · 9.74 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
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 System.Threading.Tasks
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 filePath: string
/// Finished parsing a file (file path).
| ReachedEnd of filePath: string * violations: Suggestion.LintWarning list
/// Failed to parse a file (file path, exception that caused failure).
| Failed of filePath: string * ex: System.Exception
/// Path of the F# file the progress information is for.
member FilePath : unit -> string
type ConfigurationParam =
| Configuration of config: 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
/// Optional results of project-wide type info (allows for a more accurate lint).
ProjectCheckResults:FSharpCheckProjectResults option
/// Path to the project file (.fsproj), when known. Lets the library-heuristic
/// rules work under hosts (e.g. TransparentCompiler analyzer hosts) where the
/// project options cannot be derived from the check results.
ProjectFileName:string 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 projectFilePath: string
/// Received exception when trying to get the list of F# file from the project file.
| MSBuildFailedToLoadProjectFile of projectFilePath: string * failure: BuildFailure
/// Failed to load a FSharpLint configuration file.
| FailedToLoadConfig of errorMessage: string
/// The specified file for linting could not be found.
| FailedToLoadFile of filePath: string
/// Failed to analyse a loaded FSharpLint configuration at runtime e.g. invalid hint.
| RunTimeConfigError of errorMessage: string
/// `FSharp.Compiler.Services` failed when trying to parse a file.
| FailedToParseFile of failure: ParseFile.ParseFileFailure
/// `FSharp.Compiler.Services` failed when trying to parse one or more files in a project.
| FailedToParseFilesInProject of failures: 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 violations: Suggestion.LintWarning list
| Failure of failure: LintFailure
member TryGetSuccess : byref<Suggestion.LintWarning list> -> bool
member TryGetFailure : byref<LintFailure> -> bool
type RunAstNodeRulesConfig =
{
Rules: RuleMetadata<AstNodeRuleConfig>[]
GlobalConfig: Rules.GlobalRuleConfig
TypeCheckResults: FSharpCheckFileResults option
ProjectCheckResults: FSharpCheckProjectResults option
ProjectFileName: Lazy<string option>
FilePath: string
FileContent: string
Lines: string[]
SyntaxArray: AbstractSyntaxArray.Node array
}
/// Runs all rules which take a node of the AST as input.
val runAstNodeRules : RunAstNodeRulesConfig -> Suggestion.LintWarning [] * Context
type RunLineRulesConfig =
{
LineRules: Configuration.LineRules
GlobalConfig: Rules.GlobalRuleConfig
FilePath: string
FileContent: string
Lines: string[]
Context: Context
}
/// Gets a FSharpLint Configuration based on the provided ConfigurationParam.
val getConfig: ConfigurationParam -> Result<Configuration, string>
/// Runs all rules which take a line of text as input.
val runLineRules : RunLineRulesConfig -> Suggestion.LintWarning []
/// Lints an entire F# solution by linting all projects specified in the `.sln`, `slnx` or `.slnf` file.
val asyncLintSolution : optionalParams:OptionalLintParameters -> solutionFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> Async<LintResult>
/// Lints an entire F# solution by linting all projects specified in the `.sln`, `slnx` or `.slnf` file.
val lintSolutionAsync : optionalParams:OptionalLintParameters -> solutionFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> Task<LintResult>
/// [Obsolete] Lints an entire F# solution by linting all projects specified in the `.sln`, `slnx` or `.slnf` 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 asyncLintProject : optionalParams:OptionalLintParameters -> projectFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> Async<LintResult>
/// Lints an entire F# project by retrieving the files from a given path to the `.fsproj` file.
val lintProjectAsync : optionalParams:OptionalLintParameters -> projectFilePath:string -> toolsPath:Ionide.ProjInfo.Types.ToolsPath -> Task<LintResult>
/// [Obsolete] 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 async.
val asyncLintSource : optionalParams:OptionalLintParameters -> source:string -> Async<LintResult>
/// Lints F# source code async.
val lintSourceAsync : optionalParams:OptionalLintParameters -> source:string -> Task<LintResult>
/// [Obsolete] 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 asyncLintFile : optionalParams:OptionalLintParameters -> filePath:string -> Async<LintResult>
/// Lints an F# file from a given path to the `.fs` file.
val lintFileAsync : optionalParams:OptionalLintParameters -> filePath:string -> Task<LintResult>
/// [Obsolete] Lints an F# file from a given path to the `.fs` file.
val lintFile : optionalParams:OptionalLintParameters -> filePath:string -> LintResult
/// Lints multiple F# files from given file paths.
val asyncLintFiles : optionalParams:OptionalLintParameters -> filePaths:string seq -> Async<LintResult>
/// Lints multiple F# files from given file paths.
val lintFilesAsync : optionalParams:OptionalLintParameters -> filePaths:string seq -> Task<LintResult>
/// [Obsolete] Lints multiple F# files from given file paths.
val lintFiles : optionalParams:OptionalLintParameters -> filePaths:string seq -> 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