From a27098d92164f3f57dfd569d9adfd4f0fb3c432c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 25 Feb 2017 16:23:49 -0800 Subject: [PATCH] test: enable max-len for test-repl Instead of disabling max-len (ESLint's line-length rule) for the entire file, reformat to avoid exceeding length restrictions in most cases and disable the rule only on specific lines where exceeding the length restriction may be a better choice than conforming to it. PR-URL: https://github.com/nodejs/node/pull/11559 Reviewed-By: James M Snell Reviewed-By: Yuta Hiroto --- test/parallel/test-repl.js | 69 +++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 420010e1a3..3cf1b52e61 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -1,4 +1,3 @@ -/* eslint-disable max-len */ 'use strict'; const common = require('../common'); @@ -168,18 +167,32 @@ function error_test() { { client: client_unix, send: 'new RegExp("foo", "wrong modifier");', expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ }, // strict mode syntax errors should be caught (GH-5178) - { client: client_unix, send: '(function() { "use strict"; return 0755; })()', + { client: client_unix, + send: '(function() { "use strict"; return 0755; })()', expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ }, - { client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()', - expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ }, - { client: client_unix, send: '(function() { "use strict"; with (this) {} })()', - expect: /\bSyntaxError: Strict mode code may not include a with statement/ }, - { client: client_unix, send: '(function() { "use strict"; var x; delete x; })()', - expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ }, - { client: client_unix, send: '(function() { "use strict"; eval = 17; })()', + { + client: client_unix, + send: '(function(a, a, b) { "use strict"; return a + b + c; })()', + expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ // eslint-disable-line max-len + }, + { + client: client_unix, + send: '(function() { "use strict"; with (this) {} })()', + expect: /\bSyntaxError: Strict mode code may not include a with statement/ + }, + { + client: client_unix, + send: '(function() { "use strict"; var x; delete x; })()', + expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ // eslint-disable-line max-len + }, + { client: client_unix, + send: '(function() { "use strict"; eval = 17; })()', expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ }, - { client: client_unix, send: '(function() { "use strict"; if (true) function f() { } })()', - expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ }, + { + client: client_unix, + send: '(function() { "use strict"; if (true) function f() { } })()', + expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ // eslint-disable-line max-len + }, // Named functions can be used: { client: client_unix, send: 'function blah() { return 1; }', expect: prompt_unix }, @@ -312,16 +325,20 @@ function error_test() { { client: client_unix, send: 'require("internal/repl")', expect: /^Error: Cannot find module 'internal\/repl'/ }, // REPL should handle quotes within regexp literal in multiline mode - { client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}", + { client: client_unix, + send: "function x(s) {\nreturn s.replace(/'/,'');\n}", expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - { client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}", + { client: client_unix, + send: "function x(s) {\nreturn s.replace(/'/,'');\n}", expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - { client: client_unix, send: 'function x(s) {\nreturn s.replace(/"/,"");\n}', + { client: client_unix, + send: 'function x(s) {\nreturn s.replace(/"/,"");\n}', expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - { client: client_unix, send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}', + { client: client_unix, + send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}', expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, { client: client_unix, send: '{ var x = 4; }', @@ -356,14 +373,20 @@ function error_test() { expect: '{ value: undefined, done: true }' }, // https://github.com/nodejs/node/issues/9300 - { client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}', - expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, - - { client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())', - expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix }, - - { client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', - expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix } + { + client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}', + expect: `${prompt_multiline}${prompt_multiline}undefined\n${prompt_unix}` + }, + + { + client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())', + expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix + }, + + { + client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', + expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix + } ]); }