mirror of
https://git.proxmox.com/git/pve-eslint
synced 2025-10-10 17:57:43 +00:00

includes a (minimal) working wrapper Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
94 lines
1.9 KiB
Markdown
94 lines
1.9 KiB
Markdown
# Require space before/after arrow function's arrow (arrow-spacing)
|
|
|
|
This rule normalize style of spacing before/after an arrow function's arrow(`=>`).
|
|
|
|
```js
|
|
/*eslint-env es6*/
|
|
|
|
// { "before": true, "after": true }
|
|
(a) => {}
|
|
|
|
// { "before": false, "after": false }
|
|
(a)=>{}
|
|
```
|
|
|
|
## Rule Details
|
|
|
|
This rule takes an object argument with `before` and `after` properties, each with a Boolean value.
|
|
|
|
The default configuration is `{ "before": true, "after": true }`.
|
|
|
|
`true` means there should be **one or more spaces** and `false` means **no spaces**.
|
|
|
|
Examples of **incorrect** code for this rule with the default `{ "before": true, "after": true }` option:
|
|
|
|
```js
|
|
/*eslint arrow-spacing: "error"*/
|
|
/*eslint-env es6*/
|
|
|
|
()=> {};
|
|
() =>{};
|
|
(a)=> {};
|
|
(a) =>{};
|
|
a =>a;
|
|
a=> a;
|
|
()=> {'\n'};
|
|
() =>{'\n'};
|
|
```
|
|
|
|
Examples of **correct** code for this rule with the default `{ "before": true, "after": true }` option:
|
|
|
|
```js
|
|
/*eslint arrow-spacing: "error"*/
|
|
/*eslint-env es6*/
|
|
|
|
() => {};
|
|
(a) => {};
|
|
a => a;
|
|
() => {'\n'};
|
|
```
|
|
|
|
Examples of **incorrect** code for this rule with the `{ "before": false, "after": false }` option:
|
|
|
|
```js
|
|
/*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
|
|
/*eslint-env es6*/
|
|
|
|
() =>{};
|
|
(a) => {};
|
|
()=> {'\n'};
|
|
```
|
|
|
|
Examples of **correct** code for this rule with the `{ "before": false, "after": false }` option:
|
|
|
|
```js
|
|
/*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
|
|
/*eslint-env es6*/
|
|
|
|
()=>{};
|
|
(a)=>{};
|
|
()=>{'\n'};
|
|
```
|
|
|
|
Examples of **incorrect** code for this rule with the `{ "before": false, "after": true }` option:
|
|
|
|
```js
|
|
/*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
|
|
/*eslint-env es6*/
|
|
|
|
() =>{};
|
|
(a) => {};
|
|
()=>{'\n'};
|
|
```
|
|
|
|
Examples of **correct** code for this rule with the `{ "before": false, "after": true }` option:
|
|
|
|
```js
|
|
/*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
|
|
/*eslint-env es6*/
|
|
|
|
()=> {};
|
|
(a)=> {};
|
|
()=> {'\n'};
|
|
```
|