Skip to content

An ESLint plugin to enforce Allman-style braces for switch case statements.

License

Notifications You must be signed in to change notification settings

refringe/eslint-plugin-switch-allman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-switch-allman

This ESLint plugin provides a linting rule to enforce Allman-style braces for switch case statements, ensuring that the opening brace is placed on a new line.

Installation

Install the plugin with npm:

npm install eslint-plugin-switch-allman --save-dev

Note: You need to have ESLint installed on your project (version 7.0.0 or higher is recommended).

Usage

After installation, add the plugin to your ESLint configuration file:

{
    "plugins": ["switch-allman"],
    "rules": {
        "switch-allman/case-allman": "error"
    }
}

This sets up the case-allman rule to throw an error whenever the Allman brace style is not followed in a switch case statements.

Rules

case-allman

Enforces that opening braces for switch case statements must be on a new line.

Valid Example

switch (x) {
    case 1:
    {
        break;
    }
}

Invalid Example

switch (x) {
    case 1: {
        break;
    }
}

Contributing

Contributions to enhance the rules or add new ones are welcome. Please ensure you update tests as appropriate.

License

Distributed under the MIT License.

About

An ESLint plugin to enforce Allman-style braces for switch case statements.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published