From ec689a53a0896c5196857b418544346fbd83a6c7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 13:05:37 +0100 Subject: [PATCH 1/4] Add linter configurations and update .gitignore for VS Code settings --- .github/linters/.jscpd.json | 10 + .github/linters/.markdown-lint.yml | 25 + .../linters/.powershell-psscriptanalyzer.psd1 | 56 ++ .github/linters/.textlintrc | 513 ++++++++++++++++++ .github/workflows/Linter.yml | 5 +- .gitignore | 11 +- 6 files changed, 612 insertions(+), 8 deletions(-) create mode 100644 .github/linters/.jscpd.json create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/linters/.powershell-psscriptanalyzer.psd1 create mode 100644 .github/linters/.textlintrc diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json new file mode 100644 index 0000000..23970e8 --- /dev/null +++ b/.github/linters/.jscpd.json @@ -0,0 +1,10 @@ +{ + "threshold": 0, + "reporters": [ + "consoleFull" + ], + "ignore": [ + "**/tests/**" + ], + "absolute": true +} diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..b9ecdfa --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,25 @@ +########################### +## Markdown Linter rules ## +########################### + +# Linter rules doc: +# - https://github.com/DavidAnson/markdownlint + +############### +# Rules by id # +############### +MD004: false # Unordered list style +MD007: + indent: 2 # Unordered list indentation +MD013: + line_length: 808 # Line length +MD026: + punctuation: ".,;:!。,;:" # List of not allowed +MD029: false # Ordered list item prefix +MD033: false # Allow inline HTML +MD036: false # Emphasis used instead of a heading + +################# +# Rules by tags # +################# +blank_lines: false # Error on blank lines diff --git a/.github/linters/.powershell-psscriptanalyzer.psd1 b/.github/linters/.powershell-psscriptanalyzer.psd1 new file mode 100644 index 0000000..09cc3d0 --- /dev/null +++ b/.github/linters/.powershell-psscriptanalyzer.psd1 @@ -0,0 +1,56 @@ +@{ + Rules = @{ + PSAlignAssignmentStatement = @{ + Enable = $true + CheckHashtable = $true + } + PSAvoidLongLines = @{ + Enable = $true + MaximumLineLength = 150 + } + PSAvoidSemicolonsAsLineTerminators = @{ + Enable = $true + } + PSPlaceCloseBrace = @{ + Enable = $true + NewLineAfter = $false + IgnoreOneLineBlock = $true + NoEmptyLineBefore = $false + } + PSPlaceOpenBrace = @{ + Enable = $true + OnSameLine = $true + NewLineAfter = $true + IgnoreOneLineBlock = $true + } + PSProvideCommentHelp = @{ + Enable = $true + ExportedOnly = $false + BlockComment = $true + VSCodeSnippetCorrection = $false + Placement = 'begin' + } + PSUseConsistentIndentation = @{ + Enable = $true + IndentationSize = 4 + PipelineIndentation = 'IncreaseIndentationForFirstPipeline' + Kind = 'space' + } + PSUseConsistentWhitespace = @{ + Enable = $true + CheckInnerBrace = $true + CheckOpenBrace = $true + CheckOpenParen = $true + CheckOperator = $true + CheckPipe = $true + CheckPipeForRedundantWhitespace = $true + CheckSeparator = $true + CheckParameter = $true + IgnoreAssignmentOperatorInsideHashTable = $true + } + } + ExcludeRules = @( + 'PSMissingModuleManifestField', # This rule is not applicable until the module is built. + 'PSUseToExportFieldsInManifest' + ) +} diff --git a/.github/linters/.textlintrc b/.github/linters/.textlintrc new file mode 100644 index 0000000..db48de8 --- /dev/null +++ b/.github/linters/.textlintrc @@ -0,0 +1,513 @@ +{ + "filters": { + "comments": true + }, + "rules": { + "terminology": { + "defaultTerms": false, + "terms": [ + "Airbnb", + "Android", + "AppleScript", + "AppVeyor", + "AVA", + "BrowserStack", + "Browsersync", + "Codecov", + "CodePen", + "CodeSandbox", + "DefinitelyTyped", + "EditorConfig", + "ESLint", + "GitHub", + "GraphQL", + "GraphiQL", + "iOS", + "JavaScript", + "JetBrains", + "jQuery", + "LinkedIn", + "Lodash", + "MacBook", + "Markdown", + "OpenType", + "PayPal", + "PhpStorm", + "PowerShell", + "PlayStation", + "RubyMine", + "Sass", + "SemVer", + "TypeScript", + "UglifyJS", + "Wasm", + "WebAssembly", + "WebStorm", + "WordPress", + "YouTube", + [ + "Common[ .]js", + "CommonJS" + ], + [ + "JSDocs?", + "JSDoc" + ], + [ + "Node[ .]js", + "Node.js" + ], + [ + "React[ .]js", + "React" + ], + [ + "SauceLabs", + "Sauce Labs" + ], + [ + "StackOverflow", + "Stack Overflow" + ], + [ + "styled ?components", + "styled-components" + ], + [ + "HTTP[ /]2(?:\\.0)?", + "HTTP/2" + ], + [ + "OS X", + "macOS" + ], + [ + "Mac ?OS", + "macOS" + ], + [ + "a npm", + "an npm" + ], + "ECMAScript", + [ + "ES2015", + "ES6" + ], + [ + "ES7", + "ES2016" + ], + "3D", + [ + "3-D", + "3D" + ], + "Ajax", + "API", + "APIs", + "API's", + [ + "(? Date: Sun, 16 Feb 2025 13:14:18 +0100 Subject: [PATCH 2/4] Refactor documentation comments and suppress warnings in helper scripts --- .../helpers/Build-PSModuleDocumentation.ps1 | 19 +++++++----- scripts/helpers/Import-PSModule.ps1 | 23 ++++++++------ .../helpers/Resolve-PSModuleDependency.ps1 | 31 ++++++++++--------- scripts/main.ps1 | 8 +++-- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/scripts/helpers/Build-PSModuleDocumentation.ps1 b/scripts/helpers/Build-PSModuleDocumentation.ps1 index b5488f4..cc0bb90 100644 --- a/scripts/helpers/Build-PSModuleDocumentation.ps1 +++ b/scripts/helpers/Build-PSModuleDocumentation.ps1 @@ -1,19 +1,22 @@ -#Requires -Modules GitHub -#Requires -Modules Utilities - -function Build-PSModuleDocumentation { +function Build-PSModuleDocumentation { <# - .SYNOPSIS - Builds a module. + .SYNOPSIS + Builds a module. - .DESCRIPTION - Builds a module. + .DESCRIPTION + Builds a module. #> [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', '', Scope = 'Function', Justification = 'LogGroup - Scoping affects the variables line of sight.' )] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSAvoidUsingWriteHost', '', Scope = 'Function', + Justification = 'Want to just write to the console, not the pipeline.' + )] + #Requires -Modules GitHub + #Requires -Modules Utilities param( # Name of the module. [Parameter(Mandatory)] diff --git a/scripts/helpers/Import-PSModule.ps1 b/scripts/helpers/Import-PSModule.ps1 index 3594bed..f7a2e9b 100644 --- a/scripts/helpers/Import-PSModule.ps1 +++ b/scripts/helpers/Import-PSModule.ps1 @@ -1,19 +1,22 @@ -#Requires -Modules Utilities - -function Import-PSModule { +function Import-PSModule { <# - .SYNOPSIS - Imports a build PS module. + .SYNOPSIS + Imports a build PS module. - .DESCRIPTION - Imports a build PS module. + .DESCRIPTION + Imports a build PS module. - .EXAMPLE - Import-PSModule -SourceFolderPath $ModuleFolderPath -ModuleName $ModuleName + .EXAMPLE + Import-PSModule -SourceFolderPath $ModuleFolderPath -ModuleName $ModuleName - Imports a module located at $ModuleFolderPath with the name $ModuleName. + Imports a module located at $ModuleFolderPath with the name $ModuleName. #> [CmdletBinding()] + #Requires -Modules Utilities + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSAvoidUsingWriteHost', '', Scope = 'Function', + Justification = 'Want to just write to the console, not the pipeline.' + )] param( # Path to the folder where the module source code is located. [Parameter(Mandatory)] diff --git a/scripts/helpers/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Resolve-PSModuleDependency.ps1 index 8a6ddca..14721f8 100644 --- a/scripts/helpers/Resolve-PSModuleDependency.ps1 +++ b/scripts/helpers/Resolve-PSModuleDependency.ps1 @@ -1,25 +1,28 @@ -#Requires -Modules Retry - -function Resolve-PSModuleDependency { +function Resolve-PSModuleDependency { <# - .SYNOPSIS - Resolve dependencies for a module based on the manifest file. + .SYNOPSIS + Resolve dependencies for a module based on the manifest file. - .DESCRIPTION - Resolve dependencies for a module based on the manifest file, following PSModuleInfo structure + .DESCRIPTION + Resolve dependencies for a module based on the manifest file, following PSModuleInfo structure - .EXAMPLE - Resolve-PSModuleDependency -Path 'C:\MyModule\MyModule.psd1' + .EXAMPLE + Resolve-PSModuleDependency -Path 'C:\MyModule\MyModule.psd1' - Installs all modules defined in the manifest file, following PSModuleInfo structure. + Installs all modules defined in the manifest file, following PSModuleInfo structure. - .NOTES - Should later be adapted to support both pre-reqs, and dependencies. - Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, - and latest version within a range MinimumVersion - MaximumVersion. + .NOTES + Should later be adapted to support both pre-reqs, and dependencies. + Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, + and latest version within a range MinimumVersion - MaximumVersion. #> [Alias('Resolve-PSModuleDependencies')] [CmdletBinding()] + #Requires -Modules Retry + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSAvoidUsingWriteHost', '', Scope = 'Function', + Justification = 'Want to just write to the console, not the pipeline.' + )] param( # The path to the manifest file. [Parameter(Mandatory)] diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 80fef4b..37d9e92 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,8 +1,12 @@ -#Requires -Modules Utilities - +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSAvoidUsingWriteHost', '', + Justification = 'Want to just write to the console, not the pipeline.' +)] [CmdletBinding()] param() +#Requires -Modules Utilities + $path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative LogGroup "Loading helper scripts from [$path]" { Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | ForEach-Object { From b8751fe540019fdf4f92b4bd41998942428e1017 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 13:15:32 +0100 Subject: [PATCH 3/4] Remove obsolete GitHub Actions workflows for testing, auto-release, and linting --- .github/{ => linters}/workflows/Action-Test.yml | 0 .github/{ => linters}/workflows/Auto-Release.yml | 0 .github/{ => linters}/workflows/Linter.yml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/{ => linters}/workflows/Action-Test.yml (100%) rename .github/{ => linters}/workflows/Auto-Release.yml (100%) rename .github/{ => linters}/workflows/Linter.yml (100%) diff --git a/.github/workflows/Action-Test.yml b/.github/linters/workflows/Action-Test.yml similarity index 100% rename from .github/workflows/Action-Test.yml rename to .github/linters/workflows/Action-Test.yml diff --git a/.github/workflows/Auto-Release.yml b/.github/linters/workflows/Auto-Release.yml similarity index 100% rename from .github/workflows/Auto-Release.yml rename to .github/linters/workflows/Auto-Release.yml diff --git a/.github/workflows/Linter.yml b/.github/linters/workflows/Linter.yml similarity index 100% rename from .github/workflows/Linter.yml rename to .github/linters/workflows/Linter.yml From 0335a73a074ea19823b15b4da9ac19e03108e242 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 13:16:00 +0100 Subject: [PATCH 4/4] Remove obsolete GitHub Actions workflows for testing, auto-release, and linting --- .github/{linters => }/workflows/Action-Test.yml | 0 .github/{linters => }/workflows/Auto-Release.yml | 0 .github/{linters => }/workflows/Linter.yml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/{linters => }/workflows/Action-Test.yml (100%) rename .github/{linters => }/workflows/Auto-Release.yml (100%) rename .github/{linters => }/workflows/Linter.yml (100%) diff --git a/.github/linters/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml similarity index 100% rename from .github/linters/workflows/Action-Test.yml rename to .github/workflows/Action-Test.yml diff --git a/.github/linters/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml similarity index 100% rename from .github/linters/workflows/Auto-Release.yml rename to .github/workflows/Auto-Release.yml diff --git a/.github/linters/workflows/Linter.yml b/.github/workflows/Linter.yml similarity index 100% rename from .github/linters/workflows/Linter.yml rename to .github/workflows/Linter.yml