From db4e7528b0e7324016ebbfd936f2e4be53ba57e7 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 18 Feb 2016 23:01:06 -0800 Subject: [PATCH] tools: add Node.js-specific ESLint rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add these rules: * no-restricted-modules: See http://eslint.org/docs/rules/no-restricted-modules. It has been configured to prohibit the use of the deprecated `sys` and `_linklist` modules. * no-new-require: See http://eslint.org/docs/rules/no-new-require * no-mixed-requires: http://eslint.org/docs/rules/no-mixed-requires PR-URL: https://github.com/nodejs/node/pull/5320 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Ben Noordhuis --- .eslintrc | 18 ++++++++++++------ test/parallel/test-sys.js | 2 +- test/parallel/test-timers-linked-list.js | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.eslintrc b/.eslintrc index 35907ef96d..d76e058b36 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,6 +31,18 @@ rules: no-octal: 2 no-redeclare: 2 + # Variables + # http://eslint.org/docs/rules/#variables + no-delete-var: 2 + no-undef: 2 + no-unused-vars: [2, {"args": "none"}] + + # Node.js and CommonJS + # http://eslint.org/docs/rules/#nodejs-and-commonjs + no-mixed-requires: 2 + no-new-require: 2 + no-restricted-modules: [2, "sys", "_linklist"] + # Stylistic Issues # https://github.com/eslint/eslint/tree/master/docs/rules#stylistic-issues comma-spacing: 2 @@ -66,12 +78,6 @@ rules: # https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode strict: [2, "global"] - # Variables - # https://github.com/eslint/eslint/tree/master/docs/rules#variables - no-delete-var: 2 - no-undef: 2 - no-unused-vars: [2, {"args": "none"}] - # Custom rules in tools/eslint-rules require-buffer: 2 new-with-error: [2, "Error", "RangeError", "TypeError", "SyntaxError", "ReferenceError"] diff --git a/test/parallel/test-sys.js b/test/parallel/test-sys.js index add692d736..3e28f02033 100644 --- a/test/parallel/test-sys.js +++ b/test/parallel/test-sys.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); var assert = require('assert'); -var sys = require('sys'); +var sys = require('sys'); // eslint-disable-line no-restricted-modules var util = require('util'); assert.strictEqual(sys, util); diff --git a/test/parallel/test-timers-linked-list.js b/test/parallel/test-timers-linked-list.js index c046a3024a..b5ff9f56bf 100644 --- a/test/parallel/test-timers-linked-list.js +++ b/test/parallel/test-timers-linked-list.js @@ -4,7 +4,7 @@ require('../common'); const assert = require('assert'); -const L = require('_linklist'); +const L = require('_linklist'); // eslint-disable-line no-restricted-modules const internalL = require('internal/linkedlist'); assert.strictEqual(L, internalL);