https://github.com/flyrell/eslint-plugin-angular-template-spacing
Plugin that offers spacing possibilities in Angular's templates using ESLint
https://github.com/flyrell/eslint-plugin-angular-template-spacing
Last synced: about 1 year ago
JSON representation
Plugin that offers spacing possibilities in Angular's templates using ESLint
- Host: GitHub
- URL: https://github.com/flyrell/eslint-plugin-angular-template-spacing
- Owner: Flyrell
- License: mit
- Created: 2022-08-31T07:41:55.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-07T13:08:56.000Z (over 3 years ago)
- Last Synced: 2025-03-22T01:03:44.216Z (about 1 year ago)
- Language: TypeScript
- Size: 450 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-angular-template-spacing
Plugin that offers spacing possibilities in Angular's templates using ESLint.
You can set the spacing rules around interpolation and pipes.
### Requirements
In order for this plugin to work,
you have to have the peer dependencies installed:
- `@angular-eslint/eslint-plugin-template` `>= v12.0.0`
- `@angular-eslint/tempalte-parser` `>= 12.0.0`
- `@angular/complier` `>= 12.0.0`
- `eslint` `^8.0.0`
### Installation
In order to install plugin in your repository run:
```bash
npm install --save-dev eslint-plugin-angular-template-spacing
```
## Usage
Add plugin to the array of plugins for eslint
```json
{
"plugins": [
"angular-template-spacing"
]
}
```
Add the rules:
#### Recommended rules
You can extend the recommended set of rules which ensures spaces in interpolation statements and pipes.
```json
{
"extends": [
"plugin:angular-template-spacing/recommended"
]
}
```
Example of correct usage of recommended rules
```html
{{ 'My text' }}
{{ computedText | pipe }}
{{ numericVariable | pipe1 | pipe2 }}
{{ numericVariable | pipe:'pipe-arguments' }}
{{ numericVariable | pipe1:'pipe1-arguments' | pipe2:'pipe2-arguments' }}
```
#### Specific rules
Or add the specific rules yourself
```json5
{
"rules": {
// Checks the spacing before and after the pipe
// "always" => "value | pipe"
// "never" => "value|pipe"
"angular-template-spacing/pipes": ["off|warn|error", "always|never"],
// Checks the spacing at the begging and at the end of interpolation
// "always": "{{ value }}"
// "never": "{{value}}"
// "always" with "acceptWhitespaces: true":
// "{{
// example
// }}"
"angular-template-spacing/interpolation": ["off|warn|error", "always|never", { "acceptWhitespaces": true|false }]
}
}
```