From 8c94cc2b5d1cf593c31a709b66c7afd98bc96bcc Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 3 Mar 2016 13:45:08 -0800 Subject: [PATCH] tools: enable no-self-assign ESLint rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enabled no-self-assign rule in ESLint. This required one change in a benchmark file. Changed a loop (that is outside of the benchmark itself, so performance is not critical) from a for loop that repeats a string to use String.prototype.repeat() instead. While at it, took the opportunity to const-ify the benchmark file. Also moved the "Strict" section in the .eslintrc to match where it is in the ESLint documentation. Updated the link for Strict rules to point to the ESLint website rather than the GitHub-hosted code. PR-URL: https://github.com/nodejs/node/pull/5552 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Johan Bergström Reviewed-By: targos - Michaël Zasso Reviewed-By: Roman Reiss --- .eslintrc | 15 ++++++++------- benchmark/buffers/buffer-base64-decode.js | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.eslintrc b/.eslintrc index fc4eadb9b2cb19..8e01cc4c94c0e4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,7 +4,7 @@ env: rules: # Possible Errors - # https://github.com/eslint/eslint/tree/master/docs/rules#possible-errors + # http://eslint.org/docs/rules/#possible-errors comma-dangle: [2, "only-multiline"] no-control-regex: 2 no-debugger: 2 @@ -28,12 +28,17 @@ rules: valid-typeof: 2 # Best Practices - # https://github.com/eslint/eslint/tree/master/docs/rules#best-practices + # http://eslint.org/docs/rules/#best-practices no-fallthrough: 2 no-octal: 2 no-redeclare: 2 + no-self-assign: 2 no-unused-labels: 2 + # Strict Mode + # http://eslint.org/docs/rules/#strict-mode + strict: [2, "global"] + # Variables # http://eslint.org/docs/rules/#variables no-delete-var: 2 @@ -48,7 +53,7 @@ rules: no-restricted-modules: [2, "sys", "_linklist"] # Stylistic Issues - # https://github.com/eslint/eslint/tree/master/docs/rules#stylistic-issues + # http://eslint.org/docs/rules/#stylistic-issues comma-spacing: 2 eol-last: 2 indent: [2, 2, {SwitchCase: 1}] @@ -79,10 +84,6 @@ rules: no-this-before-super: 2 prefer-const: 2 - # Strict Mode - # https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode - strict: [2, "global"] - # Custom rules in tools/eslint-rules new-with-error: [2, "Error", "RangeError", "TypeError", "SyntaxError", "ReferenceError"] diff --git a/benchmark/buffers/buffer-base64-decode.js b/benchmark/buffers/buffer-base64-decode.js index 76850c1231eda0..23ab92462f8927 100644 --- a/benchmark/buffers/buffer-base64-decode.js +++ b/benchmark/buffers/buffer-base64-decode.js @@ -1,13 +1,13 @@ -var assert = require('assert'); -var common = require('../common.js'); +const assert = require('assert'); +const common = require('../common.js'); -var bench = common.createBenchmark(main, {}); +const bench = common.createBenchmark(main, {}); function main(conf) { - for (var s = 'abcd'; s.length < 32 << 20; s += s); + const s = 'abcd'.repeat(8 << 20); s.match(/./); // Flatten string. assert.equal(s.length % 4, 0); - var b = Buffer(s.length / 4 * 3); + const b = Buffer(s.length / 4 * 3); b.write(s, 0, s.length, 'base64'); bench.start(); for (var i = 0; i < 32; i += 1) b.base64Write(s, 0, s.length);