Skip to content

Commit

Permalink
Adding newline(s) after header (#29)
Browse files Browse the repository at this point in the history
* Update to eslint 7.7.0
* Add a third option to specify number of linebreaks after the header.
  • Loading branch information
emoller committed Aug 31, 2020
1 parent e840ff6 commit 8b26250
Show file tree
Hide file tree
Showing 7 changed files with 1,473 additions and 609 deletions.
File renamed without changes.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
language: node_js
node_js:
- "8"
- "10"
- "14"
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Often you will want to have a copyright notice at the top of every file. This ES

## Usage

This rule takes 1 or 2 arguments with an optional settings object.
This rule takes 1, 2 or 3 arguments with an optional settings object.

### 1 argument

Expand Down Expand Up @@ -48,6 +48,61 @@ In the 2 argument form the first must be either `"block"` or `"line"` to indicat
}
```

### 3 arguments

The optional third argument which defaults to 1 specifies the number of newlines that are enforced after the header.

Zero newlines:
```json
{
"plugins": [
"header"
],
"rules": {
"header/header": [2, "block", [" Copyright now","My Company "], 0]
}
}
```
```js
/* Copyright now
My Company */ console.log(1)
```

One newline (default)
```json
{
"plugins": [
"header"
],
"rules": {
"header/header": [2, "block", [" Copyright now","My Company "], 1]
}
}
```
```js
/* Copyright now
My Company */
console.log(1)
```

two newlines
```json
{
"plugins": [
"header"
],
"rules": {
"header/header": [2, "block", [" Copyright now","My Company "], 2]
}
}
```
```js
/* Copyright now
My Company */

console.log(1)
```

#### Regular expressions

Instead of a string to be checked for exact matching you can also supply a regular expression. Be aware that you have to escape backslashes:
Expand Down

0 comments on commit 8b26250

Please sign in to comment.