Rule | Description | Snippet | ESLint Default | Link |
---|---|---|---|---|
callback-return | Enforce `return` after a callback |
// Good function foo() { if (err) { return callback(err); } callback(); } |
Off | [Link](http://eslint.org/docs/rules/callback-return) |
handle-callback-err | Enforce error handling in callbacks |
function loadData (err, data) { doSomething(); // forgot to handle error } |
Off | [Link](http://eslint.org/docs/rules/handle-callback-err) |
no-mixed-requires | Disallow mixing regular variable and require declarations |
var fs = require('fs'), // "core" async = require('async'), // "module" baz = 42, // "other" bam; // "uninitialized" |
Off | [Link](http://eslint.org/docs/rules/no-mixed-requires) |
no-new-require | Disallow use of `new` operator with the `require` function |
// Bad var appHeader = new require('app-header'); // Good var AppHeader = require('app-header'); |
Off | [Link](http://eslint.org/docs/rules/no-new-require) |
no-path-concat | Disallow string concatenation with `__dirname` and `__filename` |
// Bad var fullPath = __dirname + "/foo.js"; // Good var fullPath = path.join(__dirname, "foo.js"); |
Off | [Link](http://eslint.org/docs/rules/no-path-concat) |
no-process-exit | Disallow `process.exit()` |
// Bad if (somethingBadHappened) { console.error("Something bad happened!"); process.exit(1); } // Good if (somethingBadHappened) { throw new Error("Something bad happened!"); } |
Off | [Link](http://eslint.org/docs/rules/no-process-exit) |
no-restricted-modules | Restrict usage of specified node modules |
// With "fs" restricted var fs = require('fs'); // Disallowed |
Off | [Link](http://eslint.org/docs/rules/no-restricted-modules) |
no-sync | Disallow use of synchronous methods |
fs.existsSync(somePath); var contents = fs.readFileSync(somePath).toString(); |
Off | [Link](http://eslint.org/docs/rules/no-sync) |