Skip to content

Commit 5251849

Browse files
author
Matt Mcveigh
committed
Ensure ignoring a hint from config works
1 parent f58665f commit 5251849

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.1.200"
3+
"version": "3.1.301"
44
}
55
}

tests/FSharpLint.Console.Tests/TestApp.fs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,35 @@ type TestConsoleApplication() =
9595

9696
Assert.AreEqual(0, returnCode)
9797
Assert.AreEqual(Set.empty, errors)
98+
99+
/// Regression test for: https://github.com/fsprojects/FSharpLint/issues/466
100+
/// Hints listed in the ignore section of the config were not being ignored.
101+
[<Test>]
102+
member __.``Ignoring a hint in the configuration should stop it from being output as warning.``() =
103+
let input = """
104+
let x = [1; 2; 3; 4] |> List.map (fun x -> x + 2) |> List.map (fun x -> x + 2)
105+
"""
106+
107+
let (returnCode, errors) = main [| "lint"; input |]
108+
109+
// Check default config triggers the hint we're expecting to ignore later.
110+
Assert.AreEqual(-1, returnCode)
111+
Assert.AreEqual(Set.ofList [
112+
"`List.map f (List.map g x)` might be able to be refactored into `List.map (g >> f) x`."], errors)
113+
114+
let config = """
115+
{
116+
"hints": {
117+
"add": [],
118+
"ignore": [
119+
"List.map f (List.map g x) ===> List.map (g >> f) x"
120+
]
121+
}
122+
}
123+
"""
124+
use config = new TemporaryFile(config, "json")
125+
126+
let (returnCode, errors) = main [| "lint"; "--lint-config"; config.FileName; input |]
127+
128+
Assert.AreEqual(0, returnCode)
129+
Assert.AreEqual(Set.empty, errors)

0 commit comments

Comments
 (0)