Skip to content

Commit

Permalink
[change] clarified rules for styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Mollweide committed Jul 13, 2016
1 parent d7cbc34 commit 5c7c29d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 15 deletions.
6 changes: 0 additions & 6 deletions configurations/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ module.exports = {
'../rules/es6'
].map(require.resolve),

// overwrite es5 rules here
rules: {
// allow multiple var statement per function
'one-var': 0
},

parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
Expand Down
37 changes: 37 additions & 0 deletions documentation/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,23 @@ function _test(productData) {}

✓ Enabled (error)

```javascript

// Bad
/*
function bad() {
const d = 1, e = 2;
}
*/

// Good
function good() {
let a, b, c;
const d = 1;
const e = 2;
}

```
<br />


Expand All @@ -603,6 +620,26 @@ function _test(productData) {}

&#10003; Enabled (error)

```javascript

// Bad
/*
function bad() {
const a = 1,
b = 2,
c = 3;
}
*/

// Good
function good() {
const d = 4;
const e = 5;
const f = 6;
}


```
<br />


Expand Down
11 changes: 5 additions & 6 deletions rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module.exports = {
ignoreUrls: true,
ignoreComments: false
}],
// TODO clarify ignoreComments:true
// [08.07.2016] enabled

// specify the maximum depth callbacks can be nested
'max-nested-callbacks': [2, 5],
Expand Down Expand Up @@ -140,7 +140,7 @@ module.exports = {

// disallow if as the only statement in an else block
'no-lonely-if': 2,
// [08.07.2016] enabled TODO clearify
// [08.07.2016] enabled

// disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 2,
Expand Down Expand Up @@ -210,8 +210,8 @@ module.exports = {

// require a newline around variable declaration
// http://eslint.org/docs/rules/one-var-declaration-per-line
'one-var-declaration-per-line': [2, 'always'],
// [08.07.2016] enabled always
'one-var-declaration-per-line': [2, 'initializations'],
// [13.07.2016] enabled initializations

// require assignment operator shorthand where possible or prohibit it entirely
'operator-assignment': 0,
Expand All @@ -229,7 +229,6 @@ module.exports = {

// specify whether double or single quotes should be used
'quotes': [2, 'single', { avoidEscape: true }],
// TODO tbd

// do not require jsdoc
// http://eslint.org/docs/rules/require-jsdoc
Expand All @@ -240,7 +239,7 @@ module.exports = {
ClassDeclaration: true
}
}],
// TODO tbd
// [08.07.2016] enabled

// require or disallow use of semicolons instead of ASI
'semi': [2, 'always'],
Expand Down
17 changes: 15 additions & 2 deletions test/es5/rules/style/one-var-declaration-per-line.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@

// DESCRIPTION = require a newline around variable declaration
// STATUS = 2

/* eslint no-unused-vars: 0*/
/* eslint require-jsdoc: 0*/
/* eslint one-var: 0*/
// <!START
// Bad
/*
function bad() {
const d = 1, e = 2;
}
*/

// Good
function good() {
let a, b, c;
const d = 1;
const e = 2;
}
// END!>
document.window.append('', null);
18 changes: 17 additions & 1 deletion test/es5/rules/style/one-var.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@
// DESCRIPTION = allow just one var statement per function
// STATUS = 2

/* eslint no-unused-vars: 0*/
/* eslint require-jsdoc: 0*/
// <!START
// Bad
/*
function bad() {
const a = 1,
b = 2,
c = 3;
}
*/

// Good
function good() {
const d = 4;
const e = 5;
const f = 6;
}

// END!>
document.window.append('', null);

0 comments on commit 5c7c29d

Please sign in to comment.