Showing 1,086 of 1,086 total issues
The universal selector (*) is known to be slow. Open
*, *:after, *:before {
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
.fraction {
- Exclude checks
Element (td.line-coverage) is overqualified, just use .line-coverage without element name. Open
table.coverage td.line-coverage {
- Exclude checks
Unexpected require(). Open
var pkgJson = require(path.resolve(__dirname, '../../package.json'));
- Read upRead up
- Exclude checks
Enforce require() on the top-level module scope (global-require)
In Node.js, module dependencies are included using the require()
function, such as:
var fs = require("fs");
While require()
may be called anywhere in code, some style guides prescribe that it should be called only in the top level of a module to make it easier to identify dependencies. For instance, it's arguably harder to identify dependencies when they are deeply nested inside of functions and other statements:
function foo() {
if (condition) {
var fs = require("fs");
}
}
Since require()
does a synchronous load, it can cause performance problems when used in other locations.
Further, ES6 modules mandate that import
and export
statements can only occur in the top level of the module's body.
Rule Details
This rule requires all calls to require()
to be at the top level of the module, similar to ES6 import
and export
statements, which also can occur only at the top level.
Examples of incorrect code for this rule:
/*eslint global-require: "error"*/
/*eslint-env es6*/
// calling require() inside of a function is not allowed
function readFile(filename, callback) {
var fs = require('fs');
fs.readFile(filename, callback)
}
// conditional requires like this are also not allowed
if (DEBUG) { require('debug'); }
// a require() in a switch statement is also flagged
switch(x) { case '1': require('1'); break; }
// you may not require() inside an arrow function body
var getModule = (name) => require(name);
// you may not require() inside of a function body as well
function getModule(name) { return require(name); }
// you may not require() inside of a try/catch block
try {
require(unsafeModule);
} catch(e) {
console.log(e);
}
Examples of correct code for this rule:
/*eslint global-require: "error"*/
// all these variations of require() are ok
require('x');
var y = require('y');
var z;
z = require('z').initialize();
// requiring a module and using it in a function is ok
var fs = require('fs');
function readFile(filename, callback) {
fs.readFile(filename, callback)
}
// you can use a ternary to determine which module to require
var logger = DEBUG ? require('dev-logger') : require('logger');
// if you want you can require() at the end of your module
function doSomethingA() {}
function doSomethingB() {}
var x = require("x"),
z = require("z");
When Not To Use It
If you have a module that must be initialized with information that comes from the file-system or if a module is only used in very rare situations and will cause significant overhead to load it may make sense to disable the rule. If you need to require()
an optional dependency inside of a try
/catch
, you can disable this rule for just that dependency using the // eslint-disable-line global-require
comment.
Source: http://eslint.org/docs/rules/
Expected error to be handled. Open
run (service, function(err, msg){
- Read upRead up
- Exclude checks
Enforce Callback Error Handling (handle-callback-err)
In Node.js, a common pattern for dealing with asynchronous behavior is called the callback pattern.
This pattern expects an Error
object or null
as the first argument of the callback.
Forgetting to handle these errors can lead to some really strange behavior in your application.
function loadData (err, data) {
doSomething(); // forgot to handle error
}
Rule Details
This rule expects that when you're using the callback pattern in Node.js you'll handle the error.
Options
The rule takes a single string option: the name of the error parameter. The default is "err"
.
Examples of incorrect code for this rule with the default "err"
parameter name:
/*eslint handle-callback-err: "error"*/
function loadData (err, data) {
doSomething();
}
Examples of correct code for this rule with the default "err"
parameter name:
/*eslint handle-callback-err: "error"*/
function loadData (err, data) {
if (err) {
console.log(err.stack);
}
doSomething();
}
function generateError (err) {
if (err) {}
}
Examples of correct code for this rule with a sample "error"
parameter name:
/*eslint handle-callback-err: ["error", "error"]*/
function loadData (error, data) {
if (error) {
console.log(error.stack);
}
doSomething();
}
regular expression
Sometimes (especially in big projects) the name of the error variable is not consistent across the project, so you need a more flexible configuration to ensure that the rule reports all unhandled errors.
If the configured name of the error variable begins with a ^
it is considered to be a regexp pattern.
- If the option is
"^(err|error|anySpecificError)$"
, the rule reports unhandled errors where the parameter name can beerr
,error
oranySpecificError
. - If the option is
"^.+Error$"
, the rule reports unhandled errors where the parameter name ends withError
(for example,connectionError
orvalidationError
will match). - If the option is
"^.*(e|E)rr"
, the rule reports unhandled errors where the parameter name matches any string that containserr
orErr
(for example,err
,error
,anyError
,some_err
will match).
When Not To Use It
There are cases where it may be safe for your application to ignore errors, however only ignore errors if you are confident that some other form of monitoring will help you catch the problem.
Further Reading
Use of !important Open
.visible-print-block{display:none!important}
- Exclude checks
The property -webkit-user-select is compatible with -moz-user-select and should be included as well. Open
.c3 text{-moz-user-select:none;user-select:none}
- Exclude checks
Adjoining classes: .c3-target.c3-focused path.c3-step Open
.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}
- Exclude checks
Element (td.status) is overqualified, just use .status without element name. Open
.table-services td.status{width:80px}
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
table.coverage td.line-coverage {
- Exclude checks
Adjoining classes: .c3-text.c3-empty Open
.c3-text.c3-empty{fill:grey;font-size:2em}
- Exclude checks
Adjoining classes: .status-line.medium Open
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
- Exclude checks
Adjoining classes: .c3-target.c3-focused path.c3-line Open
.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}
- Exclude checks
Element (pre.prettyprint) is overqualified, just use .prettyprint without element name. Open
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
.filter-container span.icon{position:absolute;left:10px;padding:10px 12px;pointer-events:none}
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
.services-sidebar table td.uptime span{display:inline-block;min-width:45px;font-weight:700}
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
body {
- Exclude checks
Element (li.L8) is overqualified, just use .L8 without element name. Open
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
- Exclude checks
The universal selector (*) is known to be slow. Open
*, *:after, *:before {
- Exclude checks
Rule doesn't have all its properties in alphabetical order. Open
table.coverage td.line-count {
- Exclude checks