array-bracket-spacing |
Enfore spacing inside array brackets |
var arr = [ 'foo', 'bar' ];
var [ x, y ] = z;
|
Off |
[Link](http://eslint.org/docs/rules/array-bracket-spacing) |
brace-style |
Enfore one true brace style |
if (foo) {
} else {
}
------------
if (foo) {
}
else {
}
|
Off |
[Link](http://eslint.org/docs/rules/brace-style) |
camelcase |
Require camel case names |
variableName vs variable_name
|
Off |
[Link](http://eslint.org/docs/rules/camelcase) |
comma-spacing |
Enfore spacing before and after comma |
var foo = 1, bar = 2;
var foo = 1 ,bar = 2;
|
Off |
[Link](http://eslint.org/docs/rules/comma-spacing) |
comma-style |
Enfore one true comma style |
var foo = 1
, //lone comma
bar = 2;
var foo = 1
, bar = 2;
|
Off |
[Link](http://eslint.org/docs/rules/comma-style) |
computed-property-spacing |
Require or disallow padding inside computed properties |
obj[foo]
obj[ foo ]
|
Off |
[Link](http://eslint.org/docs/rules/computed-property-spacing) |
consistent-this |
Enfore consistent naming when capturing the current execution context |
// If alias is set to "self", the following are errors
var self = 42;
var that = this;
self = 42;
that = this;
|
Off |
[Link](http://eslint.org/docs/rules/consistent-this) |
eol-last |
Enfore newline at the end of file, with no multiple empty lines |
function doSmth() {
...
}
// no space here
|
Off |
[Link](http://eslint.org/docs/rules/eol-last) |
func-names |
Require function expressions to have a name |
// Bad
Foo.prototype.bar = function() {};
(function() {
// ...
}())
|
Off |
[Link](http://eslint.org/docs/rules/func-names) |
func-style |
Enfore use of function declarations or expressions |
function doSomething() {
// ...
}
----
var doSomething = function() {
// ...
};
|
Off |
[Link](http://eslint.org/docs/rules/func-style) |
id-length |
This option enforces minimum and maximum identifier lengths |
// id-length: 1 // default is minimum 2-chars ({ min: 2})
var x = 5; // too short
|
Off |
[Link](http://eslint.org/docs/rules/id-length) |
id-match |
Require identifiers to match the provided regular expression |
|
Off |
[Link](http://eslint.org/docs/rules/id-match) |
indent |
Specify tab or space width for your code |
|
Off |
[Link](http://eslint.org/docs/rules/indent) |
key-spacing |
Enforce spacing between keys and values in object literal properties |
// key-spacing beforeColon & afterColon = false
var obj = { foo:42 };
|
Off |
[Link](http://eslint.org/docs/rules/key-spacing) |
lines-around-comment |
Enfore empty lines around comments |
// beforeBlockComment only
var x = 0;
/* the vertical position */
var y = 10;
|
Off |
[Link](http://eslint.org/docs/rules/lines-around-comment) |
linebreak-style |
Disallow mixed 'LF' and 'CLRF' as linebreaks |
var a = 'a',\r\n // unix
b = 'b';\n // windows
|
Off |
[Link](http://eslint.org/docs/rules/linebreak-style) |
max-nested-callbacks |
Specify the maximum depth callbacks can be nested |
foo(function () {
bar(function () {
baz(function() {
qux(function () {
});
});
});
});
|
Off |
[Link](http://eslint.org/docs/rules/max-nested-callbacks) |
new-cap |
Require a capital letter for constructors |
// Bad
var friend = new person();
var colleague = Person();
// Good
var friend = new Person();
|
Off |
[Link](http://eslint.org/docs/rules/new-cap) |
new-parens |
Disallow the omission of parentheses when invoking a constructor with no arguments |
var person = new Person;
|
Off |
[Link](http://eslint.org/docs/rules/new-parens) |
newline-after-var |
Require or disallow an empty newline after variable declarations |
var foo;
// do something with foo
|
Off |
[Link](http://eslint.org/docs/rules/newline-after-var) |
no-array-constructor |
Disallow use of the `Array` constructor |
new Array(0, 1, 2)
|
Off |
[Link](http://eslint.org/docs/rules/no-array-constructor) |
no-continue |
Disallow use of the `continue` statement |
var sum = 0,
i;
for(i = 0; i < 10; i++) {
if(i >= 5) {
continue;
}
a += i;
}
|
Off |
[Link](http://eslint.org/docs/rules/no-continue) |
no-inline-comments |
Disallow comments inline after code |
var a = 1; // declaring a to 1
|
Off |
[Link](http://eslint.org/docs/rules/no-inline-comments) |
no-lonely-if |
Disallow `if` as the only statement in an `else` block |
if (...) {
...
} else {
if (...) {
...
}
}
|
Off |
[Link](http://eslint.org/docs/rules/no-lonely-if) |
no-mixed-spaces-and-tabs |
Disallow mixed spaces and tabs for indentation |
function main() {
--->var x = 5,
--->....y = 7;
}
|
Error |
[Link](http://eslint.org/docs/rules/no-mixed-spaces-and-tabs) |
no-multiple-empty-lines |
Disallow multiple empty lines |
// no-multiple-empty-lines: [1, {max: 2}] // Maximum of 2 empty lines.
var foo = 5;
var bar = 3;
|
Off |
[Link](http://eslint.org/docs/rules/no-multiple-empty-lines) |
no-nested-ternary |
Disallow nested ternary expressions |
var foo = bar ? baz : qux === quxx ? bing : bam;
|
Off |
[Link](http://eslint.org/docs/rules/no-nested-ternary) |
no-new-object |
Disallow the use of the `Object` constructor |
// Bad
var myObject = new Object();
// Good
var myObject = {};
|
Off |
[Link](http://eslint.org/docs/rules/no-new-object) |
no-spaced-func |
Disallow space between function identifier and application |
fn () vs fn()
|
Off |
[Link](http://eslint.org/docs/rules/no-spaced-func) |
no-ternary |
Disallow the use of ternary operators |
var foo = isBar ? baz : qux;
|
Off |
[Link](http://eslint.org/docs/rules/no-ternary) |
no-trailing-spaces |
Disallow trailing whitespace at the end of lines |
// spaces, tabs and unicode whitespaces
// are not allowed at the end of lines
var foo = 0;•••••
var baz = 5;••
|
Off |
[Link](http://eslint.org/docs/rules/no-trailing-spaces) |
no-underscore-dangle |
Disallow dangling underscores in identifiers |
var _foo;
|
Off |
[Link](http://eslint.org/docs/rules/no-underscore-dangle) |
no-unneeded-ternary |
Disallow the use of `Boolean` literals in conditional expressions |
// Bad
var isYes = answer === 1 ? true : false;
// Good
var isYes = answer === 1;
|
Off |
[Link](http://eslint.org/docs/rules/no-unneeded-ternary) |
object-curly-spacing |
Require or disallow padding inside curly braces |
var obj = { foo: "bar" };
var obj = {foo: "bar"};
|
Off |
[Link](http://eslint.org/docs/rules/object-curly-spacing) |
one-var |
Require or disallow one variable declaration per function |
// one variable declaration per function
function foo() {
var bar, baz;
}
// multiple variable declarations per function
function foo() {
var bar;
var baz;
}
|
Off |
[Link](http://eslint.org/docs/rules/one-var) |
operator-assignment |
Require assignment operator shorthand where possible or prohibit it entirely |
x += y;
x = x + y;
|
Off |
[Link](http://eslint.org/docs/rules/operator-assignment) |
operator-linebreak |
Enfore operators to be placed before or after line breaks |
var fullHeight = borderTop +
innerHeight +
borderBottom;
var fullHeight = borderTop
+ innerHeight
+ borderBottom;
|
Off |
[Link](http://eslint.org/docs/rules/operator-linebreak) |
padded-blocks |
Enfore padding within blocks |
if (a) {
b();
}
if (a) {
}
|
Off |
[Link](http://eslint.org/docs/rules/padded-blocks) |
quote-props |
Require quotes around object literal property names |
var object1 = {
property: true;
};
var object2 = {
"property": true
};
|
Off |
[Link](http://eslint.org/docs/rules/quote-props) |
quotes |
Specify whether backticks, double or single quotes should be used |
var double = "double";
var single = 'single';
var backtick = `backtick`;
|
Off |
[Link](http://eslint.org/docs/rules/quotes) |
semi-spacing |
Enfore spacing before and after semicolons |
var a = "b" ;
var c = "d";var e = "f";
|
Off |
[Link](http://eslint.org/docs/rules/semi-spacing) |
sort-vars |
Sort variables within the same declaration block |
var b, a;
var a, B, c;
var a, A;
|
Off |
[Link](http://eslint.org/docs/rules/sort-vars) |
space-after-keywords |
Require a space after certain keywords |
if (condition) {
doSomething();
} else {
doSomethingElse();
}
if(condition) {
doSomething();
}else{
doSomethingElse();
}
|
Off |
[Link](http://eslint.org/docs/rules/space-after-keywords) |
space-before-blocks |
Require or disallow a space before blocks |
if (a){
if (a) {
|
Off |
[Link](http://eslint.org/docs/rules/space-before-blocks) |
space-before-function-paren |
Require or disallow a space before function opening parenthesis |
function withoutSpace(x) {
}
function withSpace (x) {
}
|
Off |
[Link](http://eslint.org/docs/rules/space-before-function-paren) |
space-in-parens |
Require or disallow spaces inside parentheses |
foo( 'bar' );
var x = ( 1 + 2 ) * 3;
foo('bar');
var x = (1 + 2) * 3;
|
Off |
[Link](http://eslint.org/docs/rules/space-in-parens) |
space-infix-ops |
Require spaces around operators |
a+b
a +b
a+ b
|
Off |
[Link](http://eslint.org/docs/rules/space-infix-ops) |
space-return-throw-case |
Require a space after `return`, `throw`, and `case` |
throw{a:0}
throw {a:0}
|
Off |
[Link](http://eslint.org/docs/rules/space-return-throw-case) |
space-unary-ops |
Require or disallow spaces before/after unary operators |
foo++
foo ++
|
Off |
[Link](http://eslint.org/docs/rules/space-unary-ops) |
spaced-comment |
Require or disallow a space immediately following the `//` or `/*` in a comment |
//Comment
// Comment
|
Off |
[Link](http://eslint.org/docs/rules/spaced-comment) |
wrap-regex |
Require regex literals to be wrapped in parentheses |
return /foo/.test("bar");
return (/foo/).test("bar");
|
Off |
[Link](http://eslint.org/docs/rules/wrap-regex) |