PowerShell / PowerShell/PSScriptAnalyzer

Improve Usability of PSScriptAnalyzer.psd1

未关闭
#2,102 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
2.2k
派生
414
平均合并
13 小时 1 分钟
30 天内合并 PR
2

描述

Summary of the new feature
According to the docs it's as simple as adding rules to the Rules HashMap in PSScriptAnalyzer.psd1:

PSScriptAnalyzer.psd1
@{

  Rules             = @{
    'PSAvoidUsingCmdletAliases' = @{
      'allowlist' = @('cd', 'cls', 'copy', 'cp'')
    }
  }

  # Author of this module
  Author            = 'Microsoft Corporation'
...

Followed by running:

Import-Module PSScriptAnalyzer

However, in practice this does not work at all:

Import-Module: The '...\ms-vscode.powershell-2025.0.0\modules\PSScriptAnalyzer\1.23.0\PSScriptAnalyzer.psd1' module cannot be imported because its manifest contains one or more members that are not valid. The valid manifest members are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport', 'DscResourcesToExport', 'CompatiblePSEditions', 'HelpInfoURI', 'RootModule', 'DefaultCommandPrefix').
Remove the members that are not valid ('Rules'), then try to import the module again.

I am sure this is just a beginners mistake and CAN work but it SHOULD JUST work.

Proposed technical implementation details (optional)

A clear and concise description of what you want to happen.

What is the latest version of PSScriptAnalyzer at the point of writing
1.24.0

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 PSScriptAnalyzer.psd1 和 issue 中链接的 AvoidUsingCmdletAliases 文档开始。添加 Rules 成员并运行 Import-Module PSScriptAnalyzer 来复现故障。当文档中的规则配置可以在不出现 manifest-invalid-members 错误的情况下使用时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
powershell
领域
tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。