Skip to content

Commit

Permalink
[change] approved rules for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Mollweide committed Jul 13, 2016
1 parent 4270925 commit f951a14
Show file tree
Hide file tree
Showing 30 changed files with 720 additions and 45 deletions.
330 changes: 329 additions & 1 deletion documentation/errors.md

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion rules/errors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* global module */
/* [13.07.2016] approved by skill group core team */
module.exports = {
rules: {
// require trailing commas in multiline object literals
'comma-dangle': 0,
'comma-dangle': [2, 'never'],
// [13.07.2016] enabled

// disallow assignment in conditional expressions
'no-cond-assign': [2, 'always'],
Expand Down
23 changes: 22 additions & 1 deletion test/es5/rules/errors/comma-dangle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@

// DESCRIPTION = require trailing commas in multiline object literals
// STATUS = 0
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START
// Bad
/*
var bad = {
bar: 'baz',
qux: 'quux',
};
*/

// Good
var good = {
bar: 'baz',
qux: 'quux'
};
// END!>
document.window.append('', null);
18 changes: 16 additions & 2 deletions test/es5/rules/errors/no-cond-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
// DESCRIPTION = disallow assignment in conditional expressions
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START

// Bad
/*
var x;
if (x = 0) {
var b = 1;
}
*/
// END!>
document.window.append('', null);
6 changes: 4 additions & 2 deletions test/es5/rules/errors/no-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// STATUS = 2

// <!START

// Bad
/*
console.log('hello world');
*/
// END!>
document.window.append('', null);
9 changes: 7 additions & 2 deletions test/es5/rules/errors/no-constant-condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// DESCRIPTION = disallow use of constant expressions in conditions
// STATUS = 2

/* eslint no-undef: 0*/
// <!START

// Bad
/*
if (false) {
doSomethingUnfinished();
}
*/
// END!>
document.window.append('', null);
11 changes: 10 additions & 1 deletion test/es5/rules/errors/no-control-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
// DESCRIPTION = disallow control characters in regular expressions
// STATUS = 2

/* eslint no-unused-vars: 0*/
/* eslint no-redeclare: 0*/
// <!START
// Bad
/*
var pattern1 = /\x1f/;
var pattern2 = new RegExp('\x1f');
*/

// Good
var pattern1 = /\x20/;
var pattern2 = new RegExp('\x20');
// END!>
document.window.append('', null);
18 changes: 16 additions & 2 deletions test/es5/rules/errors/no-debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
// DESCRIPTION = disallow use of debugger
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START

// Bad
/*
function isTruthy(x) {
debugger;
return Boolean(x);
}
*/
// END!>
document.window.append('', null);
8 changes: 6 additions & 2 deletions test/es5/rules/errors/no-dupe-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// STATUS = 2

// <!START

// Bad
/*
function foo(a, b, a) {
console.log('value of the second a:', a);
}
*/
// END!>
document.window.append('', null);
11 changes: 9 additions & 2 deletions test/es5/rules/errors/no-dupe-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
// DESCRIPTION = disallow duplicate keys when creating object literals
// STATUS = 2

// <!START
/* eslint no-unused-vars: 0*/

// <!START
// Bad
/*
var foo = {
bar: 'baz',
bar: 'qux'
};
*/
// END!>
document.window.append('', null);
24 changes: 23 additions & 1 deletion test/es5/rules/errors/no-duplicate-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,29 @@
// DESCRIPTION = disallow a duplicate case label.
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START
// Bad
/*
var a = 1;
switch (a) {
case 1:
break;
case 2:
break;
case 1:
break;
default:
break;
}
*/
// END!>
document.window.append('', null);
10 changes: 9 additions & 1 deletion test/es5/rules/errors/no-empty-character-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
// STATUS = 2

// <!START
// Bad
/*
(/^abc[]/).test('abcdefg');
'abcdefg'.match(/^abc[]/);
*/

// Good
(/^abc/).test('abcdefg');
'abcdefg'.match(/^abc/);

// END!>
document.window.append('', null);
8 changes: 7 additions & 1 deletion test/es5/rules/errors/no-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// STATUS = 2

// <!START
// Bad
/*
var foo = true;
if (foo) {
}
*/
// END!>
document.window.append('', null);

10 changes: 8 additions & 2 deletions test/es5/rules/errors/no-ex-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// STATUS = 2

// <!START

// Bad
/*
try {
// code
} catch (e) {
e = 10;
}
*/
// END!>
document.window.append('', null);
1 change: 0 additions & 1 deletion test/es5/rules/errors/no-extra-boolean-cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
// <!START

// END!>
document.window.append('', null);
16 changes: 14 additions & 2 deletions test/es5/rules/errors/no-extra-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
// DESCRIPTION = disallow unnecessary parentheses
// STATUS = 0

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START

// Bad
var b = 1;
var c = 2;
var a = (b * c);
var d = (a * b) + c;
// END!>
document.window.append('', null);
16 changes: 14 additions & 2 deletions test/es5/rules/errors/no-extra-semi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
// DESCRIPTION = disallow unnecessary semicolons
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint semi-spacing: 0*/
// <!START

// Bad
/*
var x = 5;;
*/
// END!>
document.window.append('', null);
16 changes: 14 additions & 2 deletions test/es5/rules/errors/no-func-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
// DESCRIPTION = disallow overwriting functions written as function declarations
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START

// Bad
/*
function foo() {}
foo = bar;
*/
// END!>
document.window.append('', null);
18 changes: 17 additions & 1 deletion test/es5/rules/errors/no-inner-declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@
// DESCRIPTION = disallow function or variable declarations in nested blocks
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START
// Bad
/*
if (test) {
function doSomethingElse() { }
}
*/

// Good
function doSomething() { }
// END!>
document.window.append('', null);
9 changes: 7 additions & 2 deletions test/es5/rules/errors/no-invalid-regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// DESCRIPTION = disallow invalid regular expression strings in the RegExp constructor
// STATUS = 2

/* eslint no-new: 0*/
// <!START

// Bad
/*
RegExp('[');
RegExp('.', 'z');
new RegExp('\\');
*/
// END!>
document.window.append('', null);
18 changes: 16 additions & 2 deletions test/es5/rules/errors/no-negated-in-lhs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
// DESCRIPTION = disallow negation of the left operand of an in expression
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
// <!START

// Bad
/*
if (!key in object) {
// operator precedence makes it equivalent to (!key) in object
// and type conversion makes it equivalent to (key ? "false" : "true") in object
}
*/
// END!>
document.window.append('', null);
17 changes: 15 additions & 2 deletions test/es5/rules/errors/no-obj-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
// DESCRIPTION = disallow the use of object properties of the global object (Math and JSON) as functions
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint new-cap: 0*/
// <!START

// Bad
/*
var math = Math();
var json = JSON();
*/
// END!>
document.window.append('', null);
Loading

0 comments on commit f951a14

Please sign in to comment.