PowerShell / PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
https://www.powershellgallery.com/packages/PSScriptAnalyzer/
MIT License
1.85k stars 373 forks source link

feat: add pre-commit-hooks+config to use with pre-commit.com #1879

Open juju4 opened 1 year ago

juju4 commented 1 year ago

And self-apply in github workflows.

PR Summary

This allows easy integration with pre-commit that can be use to validate/lint code before commit (and also after/server side as per github workflow example).

Tested on Macos and Linux. Note that current workflow fail is related to warnings as seen on https://github.com/juju4/PSScriptAnalyzer/actions/runs/3867323454/jobs/6592019858#step:5:3554 can change severity to errors if prefer.

Further improvement discussion in https://github.com/pre-commit/pre-commit/issues/2645

PR Checklist

juju4 commented 1 year ago

It's up to you if want CI with warning(continue-on-error) or not and if violation fixes should go into this PR too. if small or exclusions, certainly. if bigger, probably better separate.

Only warnings here but exit code is equivalent to error. https://github.com/juju4/PSScriptAnalyzer/actions/runs/5984855087/job/16236411056#step:5:3575