Skip to content

Commit

Permalink
Merge pull request #37 from nils-a/feature/GH-23
Browse files Browse the repository at this point in the history
(GH-23) added options for inline configuration comments
  • Loading branch information
nils-a authored Jun 10, 2021
2 parents e25867f + fa08aeb commit 93d361b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Cake.ESLint.Tests/ESLintRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,26 @@ public void Should_add_max_warnings_arg_when_MaxWarnings_is_set()
actual.Args.ShouldContain("--max-warnings 5");
}

[Fact]
public void Should_no_inline_config_arg_when_NoInlineConfig_is_set()
{
fixture.Settings.NoInlineConfig = true;

var actual = fixture.Run();

actual.Args.ShouldContain("--no-inline-config");
}

[Fact]
public void Should_add_report_unused_disable_directives_arg_when_ReportUnusedDisableDirectives_is_set()
{
fixture.Settings.ReportUnusedDisableDirectives = true;

var actual = fixture.Run();

actual.Args.ShouldContain("--report-unused-disable-directives");
}

// ReSharper disable once ClassNeverInstantiated.Local
private class OutputFormatDataGenerator : IEnumerable<object[]>
{
Expand Down
10 changes: 10 additions & 0 deletions src/Cake.ESLint/ESLintRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ private ProcessArgumentBuilder GetArguments(ESLintSettings settings)
builder.AppendSwitch("--max-warnings", settings.MaxWarnings.Value.ToString());
}

if (settings.NoInlineConfig)
{
builder.Append("--no-inline-config");
}

if (settings.ReportUnusedDisableDirectives)
{
builder.Append("--report-unused-disable-directives");
}

// render arguments
foreach (var file in settings.Files.EnsureNotNull())
{
Expand Down
14 changes: 14 additions & 0 deletions src/Cake.ESLint/ESLintSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ public ESLintSettings()
/// </summary>
public int? MaxWarnings { get; set; }

/// <summary>
/// Gets or sets a value indicating whether
/// to prevent comments from changing config or rules.
/// <para>Option: <c>--no-inline-config</c>.</para>
/// </summary>
public bool NoInlineConfig { get; set; }

/// <summary>
/// Gets or sets a value indicating whether
/// to report errors for unused eslint-disable directives.
/// <para>Option: <c>--report-unused-disable-directives</c>.</para>
/// </summary>
public bool ReportUnusedDisableDirectives { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to continue on lint errors.
/// <para>
Expand Down

0 comments on commit 93d361b

Please sign in to comment.