Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Added true as a configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Vishnyak committed Oct 16, 2014
1 parent 8e05b0a commit 0800db4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1098,21 +1098,28 @@ if ( a == b ) { } else { c = d; }

Requires an empty line above the specified keywords unless the keyword is the first expression in a block.

Type: `Array`
Type: `Array` or `Boolean`

Values: Array of quoted types
Values: Array of quoted types or `true` to require padding new lines after all of the keywords below

#### Example

```js
"requirePaddingNewlinesBeforeKeywords": [
"if",
"for",
"return",
"switch",
"case",
"break",
"throw"
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"void",
"while",
"with",
"return",
"typeof",
"function"
]
```

Expand Down Expand Up @@ -1154,9 +1161,9 @@ function(a) {

Disallow an empty line above the specified keywords.

Type: `Array`
Type: `Array` or `Boolean`

Values: Array of quoted types
Values: Array of quoted types or `true` to disallow padding newlines before all possible keywords.

#### Example

Expand Down
8 changes: 7 additions & 1 deletion lib/rules/disallow-padding-newlines-before-keywords.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
var assert = require('assert');
var defaultKeywords = require('../utils').spacedKeywords;

module.exports = function() { };

module.exports.prototype = {

configure: function(keywords) {
assert(Array.isArray(keywords), 'disallowPaddingNewlinesBeforeKeywords option requires array value');
assert(Array.isArray(keywords) || keywords === true, 'disallowPaddingNewlinesBeforeKeywords option requires array or true value');

if (keywords === true) {
keywords = defaultKeywords;
}

this._keywordIndex = {};
for (var i = 0, l = keywords.length; i < l; i++) {
this._keywordIndex[keywords[i]] = true;
Expand Down
8 changes: 7 additions & 1 deletion lib/rules/require-padding-newlines-before-keywords.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
var assert = require('assert');
var defaultKeywords = require('../utils').spacedKeywords;

module.exports = function() { };

module.exports.prototype = {

configure: function(keywords) {
assert(Array.isArray(keywords), 'requirePaddingNewlinesBeforeKeywords option requires array value');
assert(Array.isArray(keywords) || keywords === true, 'requirePaddingNewlinesBeforeKeywords option requires array or true value');

if (keywords === true) {
keywords = defaultKeywords;
}

this._keywordIndex = {};
for (var i = 0, l = keywords.length; i < l; i++) {
this._keywordIndex[keywords[i]] = true;
Expand Down

0 comments on commit 0800db4

Please sign in to comment.