From d876f418c123d30cea54e6c92e0192451724e423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Dom=C3=ADnguez?= Date: Fri, 23 Dec 2022 05:37:43 +0100 Subject: [PATCH] Add cli_lint_fix_arg_name (#2175) --- megalinter/descriptors/powershell.megalinter-descriptor.yml | 1 + megalinter/linters/PowershellLinter.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/megalinter/descriptors/powershell.megalinter-descriptor.yml b/megalinter/descriptors/powershell.megalinter-descriptor.yml index 2a413139e4b..5c14eac0587 100644 --- a/megalinter/descriptors/powershell.megalinter-descriptor.yml +++ b/megalinter/descriptors/powershell.megalinter-descriptor.yml @@ -39,6 +39,7 @@ linters: linter_rules_configuration_url: https://github.com/PowerShell/PSScriptAnalyzer#explicit linter_rules_inline_disable_url: https://github.com/PowerShell/PSScriptAnalyzer#suppressing-rules config_file_name: .powershell-psscriptanalyzer.psd1 + cli_lint_fix_arg_name: "-Fix" version_extract_regex: "(\\d+) *(\\d+) *(\\d+)" examples: - 'pwsh -NoProfile -NoLogo -Command "Invoke-ScriptAnalyzer -EnableExit -Path myfile.ps1"' diff --git a/megalinter/linters/PowershellLinter.py b/megalinter/linters/PowershellLinter.py index 55f609d8f5d..3700693f242 100644 --- a/megalinter/linters/PowershellLinter.py +++ b/megalinter/linters/PowershellLinter.py @@ -21,6 +21,8 @@ def build_lint_command(self, file=None): if self.config_file is not None: pwsh_script[0] += " -Settings " + self.config_file pwsh_script[0] += f" -Path '{file}'" + if self.apply_fixes is True and self.cli_lint_fix_arg_name is not None: + pwsh_script[0] += f" {self.cli_lint_fix_arg_name}" cmd = [ self.cli_executable, "-NoProfile",