diff --git a/src/Cake.ESLint.Tests/Cake.ESLint.Tests.csproj b/src/Cake.ESLint.Tests/Cake.ESLint.Tests.csproj
index 49efde78..d5d4b124 100644
--- a/src/Cake.ESLint.Tests/Cake.ESLint.Tests.csproj
+++ b/src/Cake.ESLint.Tests/Cake.ESLint.Tests.csproj
@@ -15,10 +15,6 @@
all
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
diff --git a/src/Cake.ESLint.Tests/ESLintAliasesTests.Runs_tool_with_given_action.verified.txt b/src/Cake.ESLint.Tests/ESLintAliasesTests.Runs_tool_with_given_action.verified.txt
index 8420bbf0..cd57286f 100644
--- a/src/Cake.ESLint.Tests/ESLintAliasesTests.Runs_tool_with_given_action.verified.txt
+++ b/src/Cake.ESLint.Tests/ESLintAliasesTests.Runs_tool_with_given_action.verified.txt
@@ -9,6 +9,9 @@
]
},
Process: {
+ Arguments: [
+ {}
+ ],
WorkingDirectory: {
FullPath: /Working,
Separator: "/",
@@ -17,5 +20,5 @@
]
}
},
- Args:
+ Args: "**/*"
}
\ No newline at end of file
diff --git a/src/Cake.ESLint.Tests/ESLintAliasesTests.cs b/src/Cake.ESLint.Tests/ESLintAliasesTests.cs
index 20b90bb0..7a287a48 100644
--- a/src/Cake.ESLint.Tests/ESLintAliasesTests.cs
+++ b/src/Cake.ESLint.Tests/ESLintAliasesTests.cs
@@ -64,6 +64,7 @@ public async Task Runs_tool_with_given_settings()
[Fact]
public async Task Runs_tool_with_given_action()
{
+ fixture.Settings = null;
fixture.Action = x => x.Files = new[] {new FilePath("**/*")};
var result = fixture.Run();
diff --git a/src/Cake.ESLint.Tests/ESLintRunnerTests.cs b/src/Cake.ESLint.Tests/ESLintRunnerTests.cs
index c1f43ccd..77d7742a 100644
--- a/src/Cake.ESLint.Tests/ESLintRunnerTests.cs
+++ b/src/Cake.ESLint.Tests/ESLintRunnerTests.cs
@@ -59,6 +59,16 @@ public void Should_Throw_If_Settings_Are_Null()
result.ShouldThrow();
}
+ [Fact]
+ public void Should_Throw_If_Log_Is_Null()
+ {
+ fixture.Log = null;
+
+ Action result = () => fixture.Run();
+
+ result.ShouldThrow();
+ }
+
[Fact]
public void Should_Throw_If_ESLint_Executable_Was_Not_Found()
{
@@ -84,6 +94,18 @@ public void Should_use_local_eslint_from_nodeModules_if_exists()
actual.Path.FullPath.ShouldBe(expected.Path.FullPath);
}
+ [Fact]
+ public void Should_use_eslint_cmd_on_windows()
+ {
+ fixture.GivenDefaultToolDoNotExist();
+ var expected = fixture.GivenFileExists("/some/project/node_modules/.bin/eslint");
+ fixture.Settings.WorkingDirectory = "/some/project";
+
+ var actual = fixture.Run();
+
+ actual.Path.FullPath.ShouldBe(expected.Path.FullPath);
+ }
+
[Fact]
public void Should_use_default_eslint_when_workingDirectory_contains_no_nodeModules()
{
@@ -290,6 +312,17 @@ public void Should_add_rulesdir_arg_when_rulesDirs_is_set()
actual.Args.ShouldContain("--rulesdir \"my-rules\" --rulesdir \"my-other-rules\"");
}
+ [Fact]
+ public void Should_add_rulesdir_arg_when_rulesDirs_is_set_multiple_times()
+ {
+ fixture.Settings.AddRulesDir("my-rules");
+ fixture.Settings.AddRulesDir("my-other-rules");
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--rulesdir \"my-rules\" --rulesdir \"my-other-rules\"");
+ }
+
[Fact]
public void Should_add_plugin_arg_when_plugins_is_set()
{
@@ -300,6 +333,17 @@ public void Should_add_plugin_arg_when_plugins_is_set()
actual.Args.ShouldContain("--plugin jquery --plugin eslint-plugin-mocha");
}
+ [Fact]
+ public void Should_add_plugin_arg_when_plugins_is_set_multiple_times()
+ {
+ fixture.Settings.AddPlugin("jquery");
+ fixture.Settings.AddPlugin("eslint-plugin-mocha");
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--plugin jquery --plugin eslint-plugin-mocha");
+ }
+
[Fact]
public void Should_add_rule_arg_when_Rules_is_set()
{
@@ -310,6 +354,88 @@ public void Should_add_rule_arg_when_Rules_is_set()
actual.Args.ShouldContain("--rule \"guard-for-in: 2\" --rule \"brace-style: [2, 1tbs]\"");
}
+ [Fact]
+ public void Should_add_rule_arg_when_Rules_is_set_multiple_times()
+ {
+ fixture.Settings.AddRule("guard-for-in: 2");
+ fixture.Settings.AddRule("brace-style: [2, 1tbs]");
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--rule \"guard-for-in: 2\" --rule \"brace-style: [2, 1tbs]\"");
+ }
+
+ [Fact]
+ public void Should_add_fix_arg_when_Fix_is_set()
+ {
+ fixture.Settings.Fix = true;
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--fix");
+ }
+
+ [Fact]
+ public void Should_add_fix_dry_run_arg_when_FixDryRun_is_set()
+ {
+ fixture.Settings.FixDryRun = true;
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--fix-dry-run");
+ }
+
+ [Fact]
+ public void Should_add_fix_type_arg_when_FixType_is_set()
+ {
+ fixture.Settings.AddFixType(ESLintFixType.Layout);
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--fix-type layout");
+ }
+
+ [Fact]
+ public void Should_add_fix_type_arg_when_FixType_is_set_with_multiple_flags()
+ {
+ fixture.Settings.AddFixType(ESLintFixType.Problem, ESLintFixType.Suggestion);
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--fix-type problem --fix-type suggestion");
+ }
+
+ [Fact]
+ public void Should_add_ignore_path_arg_when_IgnorePath_is_set()
+ {
+ fixture.Settings.IgnorePath = "tmp/.eslintignore";
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--ignore-path \"tmp/.eslintignore\"");
+ }
+
+ [Fact]
+ public void Should_add_ignore_pattern_arg_when_IgnorePatterns_is_set()
+ {
+ fixture.Settings.AddIgnorePattern(new DirectoryPath("/lib/"));
+ fixture.Settings.AddIgnorePattern(new FilePath("/src/vendor/*"));
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--ignore-pattern \"/lib/\" --ignore-pattern \"/src/vendor/*\"");
+ }
+
+ [Fact]
+ public void Should_add_no_ignore_arg_when_NoIgnore_is_set()
+ {
+ fixture.Settings.NoIgnore = true;
+
+ var actual = fixture.Run();
+
+ actual.Args.ShouldContain("--no-ignore");
+ }
+
// ReSharper disable once ClassNeverInstantiated.Local
private class OutputFormatDataGenerator : IEnumerable