Skip to content

Commit 2335d7e

Browse files
TrottMylesBorins
authored andcommitted
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: #11559 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent 854b3ea commit 2335d7e

File tree

1 file changed

+46
-23
lines changed

1 file changed

+46
-23
lines changed

test/parallel/test-repl.js

+46-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable max-len */
21
'use strict';
32

43
const common = require('../common');
@@ -168,18 +167,32 @@ function error_test() {
168167
{ client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
169168
expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ },
170169
// strict mode syntax errors should be caught (GH-5178)
171-
{ client: client_unix, send: '(function() { "use strict"; return 0755; })()',
170+
{ client: client_unix,
171+
send: '(function() { "use strict"; return 0755; })()',
172172
expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ },
173-
{ client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()',
174-
expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ },
175-
{ client: client_unix, send: '(function() { "use strict"; with (this) {} })()',
176-
expect: /\bSyntaxError: Strict mode code may not include a with statement/ },
177-
{ client: client_unix, send: '(function() { "use strict"; var x; delete x; })()',
178-
expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ },
179-
{ client: client_unix, send: '(function() { "use strict"; eval = 17; })()',
173+
{
174+
client: client_unix,
175+
send: '(function(a, a, b) { "use strict"; return a + b + c; })()',
176+
expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ // eslint-disable-line max-len
177+
},
178+
{
179+
client: client_unix,
180+
send: '(function() { "use strict"; with (this) {} })()',
181+
expect: /\bSyntaxError: Strict mode code may not include a with statement/
182+
},
183+
{
184+
client: client_unix,
185+
send: '(function() { "use strict"; var x; delete x; })()',
186+
expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ // eslint-disable-line max-len
187+
},
188+
{ client: client_unix,
189+
send: '(function() { "use strict"; eval = 17; })()',
180190
expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ },
181-
{ client: client_unix, send: '(function() { "use strict"; if (true) function f() { } })()',
182-
expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ },
191+
{
192+
client: client_unix,
193+
send: '(function() { "use strict"; if (true) function f() { } })()',
194+
expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ // eslint-disable-line max-len
195+
},
183196
// Named functions can be used:
184197
{ client: client_unix, send: 'function blah() { return 1; }',
185198
expect: prompt_unix },
@@ -312,16 +325,20 @@ function error_test() {
312325
{ client: client_unix, send: 'require("internal/repl")',
313326
expect: /^Error: Cannot find module 'internal\/repl'/ },
314327
// REPL should handle quotes within regexp literal in multiline mode
315-
{ client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
328+
{ client: client_unix,
329+
send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
316330
expect: prompt_multiline + prompt_multiline +
317331
'undefined\n' + prompt_unix },
318-
{ client: client_unix, send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
332+
{ client: client_unix,
333+
send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
319334
expect: prompt_multiline + prompt_multiline +
320335
'undefined\n' + prompt_unix },
321-
{ client: client_unix, send: 'function x(s) {\nreturn s.replace(/"/,"");\n}',
336+
{ client: client_unix,
337+
send: 'function x(s) {\nreturn s.replace(/"/,"");\n}',
322338
expect: prompt_multiline + prompt_multiline +
323339
'undefined\n' + prompt_unix },
324-
{ client: client_unix, send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}',
340+
{ client: client_unix,
341+
send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}',
325342
expect: prompt_multiline + prompt_multiline +
326343
'undefined\n' + prompt_unix },
327344
{ client: client_unix, send: '{ var x = 4; }',
@@ -356,14 +373,20 @@ function error_test() {
356373
expect: '{ value: undefined, done: true }' },
357374

358375
// https://github.com/nodejs/node/issues/9300
359-
{ client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}',
360-
expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix },
361-
362-
{ client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())',
363-
expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix },
364-
365-
{ client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())',
366-
expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }
376+
{
377+
client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}',
378+
expect: `${prompt_multiline}${prompt_multiline}undefined\n${prompt_unix}`
379+
},
380+
381+
{
382+
client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())',
383+
expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix
384+
},
385+
386+
{
387+
client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())',
388+
expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix
389+
}
367390
]);
368391
}
369392

0 commit comments

Comments
 (0)