Skip to content

Add configuration instructions for UseCorrectCasing (again) #2090

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 3 commits into from
Mar 20, 2025
Merged
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
45 changes: 28 additions & 17 deletions docs/Rules/UseCorrectCasing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Use exact casing of cmdlet/function/parameter name.
ms.date: 06/28/2023
ms.date: 03/19/2025
ms.topic: reference
title: UseCorrectCasing
---
@@ -10,10 +10,16 @@ title: UseCorrectCasing

## Description

This is a style formatting rule. PowerShell is case insensitive where applicable. The casing of
cmdlet names or parameters does not matter but this rule ensures that the casing matches for
consistency and also because most cmdlets/parameters start with an upper case and using that
improves readability to the human eye.
This is a style/formatting rule. PowerShell is case insensitive wherever possible, so the casing of
cmdlet names, parameters, keywords and operators does not matter. This rule nonetheless ensures
consistent casing for clarity and readability. Using lowercase keywords helps distinguish them from
commands. Using lowercase operators helps distinguish them from parameters.

## How

- Use exact casing for type names.
- Use exact casing of the cmdlet and its parameters.
- Use lowercase for language keywords and operators.

## Configuration

@@ -28,37 +34,42 @@ Rules = @{
}
```

### Enable: bool (Default value is `$false`)
### Parameters

#### Enable: bool (Default value is `$false`)

Enable or disable the rule during ScriptAnalyzer invocation.

### CheckCommands: bool (Default value is `$true`)
#### CheckCommands: bool (Default value is `$true`)

If true, require the case of all operators to be lowercase.

### CheckKeyword: bool (Default value is `$true`)
#### CheckKeyword: bool (Default value is `$true`)

If true, require the case of all keywords to be lowercase.

### CheckOperator: bool (Default value is `$true`)
#### CheckOperator: bool (Default value is `$true`)

If true, require the case of all commands to match their actual casing.

## How

Use exact casing of the cmdlet and its parameters, e.g.
`Invoke-Command { 'foo' } -RunAsAdministrator`.
## Examples

## Example

### Wrong
### Wrong way

```powershell
ForEach ($file in Get-childitem -Recurse) {
$file.Extension -eq '.txt'
}

invoke-command { 'foo' } -runasadministrator
```

### Correct
### Correct way

```powershell
foreach ($file in Get-ChildItem -Recurse) {
$file.Extension -eq '.txt'
}

Invoke-Command { 'foo' } -RunAsAdministrator
```