plugin-angular-class-decorators-properties
v1.0.6
Published
A simple plugin for Prettier that allows you to automatically sort and modify Angular classes decorators parameters.
Maintainers
Readme
Intro
Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
This plugin adds support for the Angular class decorators properties (like NgModule or Component) to Prettier.
Getting started
Simply install prettier and plugin-angular-class-decorators-properties as your project’s devDependencies:
npm add --save-dev prettier plugin-angular-class-decorators-properties
# or
yarn add --dev prettier plugin-angular-class-decorators-properties
# or
pnpm add --save-dev prettier plugin-angular-class-decorators-propertiesUsage
CLI
npx prettier --write "**/*.ts" --plugin="plugin-angular-class-decorators-properties"
# or
yarn prettier --write "**/*.ts" --plugin="plugin-angular-class-decorators-properties"
# or
pnpm prettier --write "**/*.ts" --plugin="plugin-angular-class-decorators-properties"Configuration file (.prettierrc)
| Name | Description |
|----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
| NgModulePropertiesOrderType:string[] Default:[] | A list of @NgModule properties in the correct order. All properties outside the list will be sorted in the same order as they were. |
| ComponentPropertiesOrderType:string[] Default:[] | A list of @Component properties in the correct order. All properties outside the list will be sorted in the same order as they were. |
| InjectablePropertiesOrderType:string[] Default:[] | A list of @Injectable properties in the correct order. All properties outside the list will be sorted in the same order as they were. |
| DirectivePropertiesOrderType:string[] Default:[] | A list of @Directive properties in the correct order. All properties outside the list will be sorted in the same order as they were. |
| PipePropertiesOrderType:string[] Default:[] | A list of @Pipe properties in the correct order. All properties outside the list will be sorted in the same order as they were. |
| RemoveNgDecoratorEmptyArrayPropertiesType:boolean Default:false | If set to true will remove properties from decorator object where value is empty array. |
{
"plugins": ["plugin-angular-class-decorators-properties"],
"NgModulePropertiesOrder": ["imports", "providers", "declaration", "bootstrap", "exports"],
"ComponentPropertiesOrder": ["selector"],
"InjectablePropertiesOrder": ["providedIn"],
"DirectivePropertiesOrder": ["selector"],
"PipePropertiesOrder": ["name", "pure", "standalone"],
"RemoveNgDecoratorEmptyArrayProperties": true
}