Skip to content

Improve spell checking on local development #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"**/_.gitignore",
"**/devcontainer.json",
"**/build-and-test-powershell-module.yml",
"**/build-test-and-deploy-powershell-module.yml"
"**/build-test-and-deploy-powershell-module.yml",
"**/bin/**", // Ignore C# build output files.
"**/obj/**", // Ignore C# build output files.
".gitignore"
],
"words": [
"behaviour",
Expand Down
7 changes: 4 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "PowerShell",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/powershell:lts-debian-11",
"image": "mcr.microsoft.com/dotnet/sdk:9.0",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
Expand All @@ -13,8 +13,9 @@
}
},

// Set VS Code's default shell to PowerShell.
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"",
// Set pwsh as the default shell for the devcontainer, install required PowerShell modules, and install NPM and CSpell.
// If you do not plan to use CSpell, you can remove everything after and including 'sudo apt update'.
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"; pwsh -c \"Install-Module Pester -Force\"; pwsh -c \"Install-Module PSScriptAnalyzer -Force\"; sudo apt update; sudo DEBIAN_FRONTEND=noninteractive apt install -y npm; npm install cspell",

// Configure tool-specific properties.
"customizations": {
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Custom additions:

# Ignore NPM files.
package-lock.json
package.json

# Created by https://www.toptal.com/developers/gitignore/api/powershell,visualstudiocode,visualstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=powershell,visualstudiocode,visualstudio

Expand Down
28 changes: 27 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"isDefault": true
},
"dependsOn": [
"Run PSScriptAnalyzer linter"
"Run PSScriptAnalyzer linter",
"Run CSpell spell checker"
]
},
{
Expand Down Expand Up @@ -46,6 +47,31 @@
"$func-powershell-watch"
]
},
{
"label": "Run CSpell spell checker",
"type": "shell",
"options": {
"shell": {
"executable": "pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
},
// If npx is not available, warn that Node.js is not installed. If we cannot run cspell, try to install and run it, and warn if we still cannot run it.
"command": "try { & npx -v > $null } catch {}; if (-not $?) { Write-Warning 'Node.js is not installed, so cannot download and run npx cspell.' } else { try { & npx cspell . } catch {}; if (-not $?) { & npm install cspell; & npx cspell . }; if (-not $?) { Write-Warning 'There was a problem installing or running cspell' } }",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated",
"clear": true,
"group": "build"
},
"problemMatcher": [
"$func-powershell-watch"
]
},
{
"label": "Run all Pester tests",
"type": "shell",
Expand Down
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This page is a list of _notable_ changes made in each version.

## v1.2.0 - March 27, 2025

Features:

- Add VS Code task to run CSpell spellcheck when building, as well as a stand-alone VS Code task.
- Update dev container to the latest PowerShell image and have it install PSScriptAnalyzer, Pester, and CSpell.
- Update default Contributing.md to include information around local development and building.

## v1.1.0 - April 20, 2024

Features:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"language": "en",
"ignorePaths": [
".devcontainer/devcontainer.json",
".github/workflows/*.yml"
".github/workflows/*.yml",
".gitignore"
],
"words": [
"behaviour",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

Feel free to open an issue or pull request.

## 💻 Local development

This PowerShell module is developed using Visual Studio Code.
If you encounter any issues developing on your local machine, you can use [Docker Desktop](https://www.docker.com/products/docker-desktop/) and the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) VS Code extension to develop in a Docker container with all of the required dependencies, so that you do not have to install them locally.
You may also develop in your web browser with GitHub Codespaces to avoid needing to put any code or dependencies on your local machine.

### 🛠️ Building and testing

The code is built and tested by CI/CD pipelines on every commit to the `main` branch and every PR opened against the `main` branch.

When developing locally, you can use [the VS Code tasks](/.vscode/tasks.json) to simulate the build and test process and be notified of any problems before pushing your code up to the remote repository.
In VS Code, open the command palette (Ctrl+Shift+P) and select `Tasks: Run Build Task` or `Tasks: Run Test Task`.

When you run the build task, it will run PSScriptAnalyzer and CSpell spellcheck.
If CSpell flags a word as `unknown` that is not misspelled, you can add it to the `.cspell.json` file in the root of the repository to have it ignore the word.

## 🚀 Publishing new versions

A prerelease version of the module is published automatically on every commit to the `main` branch.
Expand Down