From fe1c9190762e87678e068dc3c32f6c4056655622 Mon Sep 17 00:00:00 2001 From: "Chris K.Y. FUNG" <8746768+chriskyfung@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:37:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Configure=20PSScriptAnalyzer=20f?= =?UTF-8?q?or=20the=20project=20#5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added the following settings files to the root folder: + `PSScriptAnalyzerSettings.psd1` + `PSScriptAnalyzerSettings.desktop-3.0-windows.psd1` - Enabled `PSUseCompatibleCmdlets` and `PSUseCompatibleSyntax` rules to ensure the scripts are compatible with the target PowerShell version + `PSScriptAnalyzerSettings.psd1`: PowerShell 2.0 or higher + `...desktop-3.0-windows.psd1`: PowerShell 3.0 to 5.0 desktop version Fixes [#5](https://github.com/chriskyfung/My-PowerShell-Scripts/issues/5) --- ...tAnalyzerSettings.desktop-3.0-windows.psd1 | 22 +++++++++++++++++ PSScriptAnalyzerSettings.psd1 | 24 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 PSScriptAnalyzerSettings.desktop-3.0-windows.psd1 create mode 100644 PSScriptAnalyzerSettings.psd1 diff --git a/PSScriptAnalyzerSettings.desktop-3.0-windows.psd1 b/PSScriptAnalyzerSettings.desktop-3.0-windows.psd1 new file mode 100644 index 0000000..e57a95e --- /dev/null +++ b/PSScriptAnalyzerSettings.desktop-3.0-windows.psd1 @@ -0,0 +1,22 @@ +@{ + Severity = @('Error', 'Warning') + Rules = @{ + PSUseCompatibleCmdlets = @{ + Compatibility = @( + 'desktop-3.0-windows' + 'desktop-4.0-windows' + 'desktop-5.1.14393.206-windows' + ) + } + PSUseCompatibleSyntax = @{ + TargetedVersions = @( + '6.0' + '5.1' + '4.0' + '3.0' + '2.0' + ) + } + } + ExcludeRules = @('PSAvoidUsingWriteHost') +} diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 new file mode 100644 index 0000000..5ce3a2a --- /dev/null +++ b/PSScriptAnalyzerSettings.psd1 @@ -0,0 +1,24 @@ +@{ + Severity = @('Error', 'Warning') + Rules = @{ + PSUseCompatibleCmdlets = @{ + Compatibility = @( + 'desktop-2.0-windows' + 'desktop-3.0-windows' + 'desktop-4.0-windows' + 'desktop-5.1.14393.206-windows' + 'core-6.1.0-windows' + ) + } + PSUseCompatibleSyntax = @{ + TargetedVersions = @( + '6.0' + '5.1' + '4.0' + '3.0' + '2.0' + ) + } + } + ExcludeRules = @('PSAvoidUsingWriteHost') +}