Function addEditor
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
addEditor: function ($el, quicktags, height, watch) {
// get settings from native WP Editor
// Editor may not be initialized and is not accessible through
// the tinymce api, thats why we take the settings from preInit
Function remoteGetEditor
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
remoteGetEditor: function ($el, name, id, content, postId, media, watch) {
Empty block statement. Open
if (jQuery(this).attr('id') === 'wp-content-wrap' || jQuery(this).attr('id') === 'ghosteditor' || jQuery(this).attr('id') === 'replycontent') {
- Read upRead up
- Exclude checks
disallow empty block statements (no-empty)
Empty block statements, while not technically errors, usually occur due to refactoring that wasn't completed. They can cause confusion when reading code.
Rule Details
This rule disallows empty block statements. This rule ignores block statements which contain a comment (for example, in an empty catch
or finally
block of a try
statement to indicate that execution should continue regardless of errors).
Examples of incorrect code for this rule:
/*eslint no-empty: "error"*/
if (foo) {
}
while (foo) {
}
switch(foo) {
}
try {
doSomething();
} catch(ex) {
} finally {
}
Examples of correct code for this rule:
/*eslint no-empty: "error"*/
if (foo) {
// empty
}
while (foo) {
/* empty */
}
try {
doSomething();
} catch (ex) {
// continue regardless of error
}
try {
doSomething();
} finally {
/* continue regardless of error */
}
Options
This rule has an object option for exceptions:
-
"allowEmptyCatch": true
allows emptycatch
clauses (that is, which do not contain a comment)
allowEmptyCatch
Examples of additional correct code for this rule with the { "allowEmptyCatch": true }
option:
/* eslint no-empty: ["error", { "allowEmptyCatch": true }] */
try {
doSomething();
} catch (ex) {}
try {
doSomething();
}
catch (ex) {}
finally {
/* continue regardless of error */
}
When Not To Use It
If you intentionally use empty block statements then you can disable this rule.
Related Rules
- [no-empty-function](./no-empty-function.md) Source: http://eslint.org/docs/rules/
'media' is already defined. Open
var media = false;
- Read upRead up
- Exclude checks
disallow variable redeclaration (no-redeclare)
In JavaScript, it's possible to redeclare the same variable name using var
. This can lead to confusion as to where the variable is actually declared and initialized.
Rule Details
This rule is aimed at eliminating variables that have multiple declarations in the same scope.
Examples of incorrect code for this rule:
/*eslint no-redeclare: "error"*/
var a = 3;
var a = 10;
Examples of correct code for this rule:
/*eslint no-redeclare: "error"*/
var a = 3;
// ...
a = 10;
Options
This rule takes one optional argument, an object with a boolean property "builtinGlobals"
. It defaults to false
.
If set to true
, this rule also checks redeclaration of built-in globals, such as Object
, Array
, Number
...
builtinGlobals
Examples of incorrect code for the { "builtinGlobals": true }
option:
/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
var Object = 0;
Examples of incorrect code for the { "builtinGlobals": true }
option and the browser
environment:
/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
/*eslint-env browser*/
var top = 0;
The browser
environment has many built-in global variables (for example, top
). Some of built-in global variables cannot be redeclared.
Source: http://eslint.org/docs/rules/
'id' is already defined. Open
var id = id || $el.attr('id');
- Read upRead up
- Exclude checks
disallow variable redeclaration (no-redeclare)
In JavaScript, it's possible to redeclare the same variable name using var
. This can lead to confusion as to where the variable is actually declared and initialized.
Rule Details
This rule is aimed at eliminating variables that have multiple declarations in the same scope.
Examples of incorrect code for this rule:
/*eslint no-redeclare: "error"*/
var a = 3;
var a = 10;
Examples of correct code for this rule:
/*eslint no-redeclare: "error"*/
var a = 3;
// ...
a = 10;
Options
This rule takes one optional argument, an object with a boolean property "builtinGlobals"
. It defaults to false
.
If set to true
, this rule also checks redeclaration of built-in globals, such as Object
, Array
, Number
...
builtinGlobals
Examples of incorrect code for the { "builtinGlobals": true }
option:
/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
var Object = 0;
Examples of incorrect code for the { "builtinGlobals": true }
option and the browser
environment:
/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
/*eslint-env browser*/
var top = 0;
The browser
environment has many built-in global variables (for example, top
). Some of built-in global variables cannot be redeclared.
Source: http://eslint.org/docs/rules/