Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: wrap lines which include RegEx exceeding 80 chars #14607

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lint: wrap lines which include RegEx exceeding 80 chars
Format commit wrapping lines containing RegEx and exceeding 80
chars.

Fixes: #14586
  • Loading branch information
thelostone-mc committed Aug 4, 2017
commit 59d037fc3cd660342cb80d5e989bad3cc81783eb
3 changes: 2 additions & 1 deletion test/addons-napi/test_properties/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
const readonlyErrorRE = /^TypeError: Cannot assign to read only property '.*' of object '#<Object>'$/;
const readonlyErrorRE =
/^TypeError: Cannot assign to read only property '.*' of object '#<Object>'$/;

// Testing api calls for defining properties
const test_object = require(`./build/${common.buildType}/test_properties`);
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ assert(commonTemplate.test(process.versions.node));
assert(commonTemplate.test(process.versions.uv));
assert(commonTemplate.test(process.versions.zlib));

assert(/^\d+\.\d+\.\d+(?:\.\d+)?(?: \(candidate\))?$/.test(process.versions.v8));
assert(/^\d+\.\d+\.\d+(?:\.\d+)?(?: \(candidate\))?$/
.test(process.versions.v8));
assert(/^\d+$/.test(process.versions.modules));
21 changes: 12 additions & 9 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function error_test() {
expect: prompt_unix },
// But passing the same string to eval() should throw
{ client: client_unix, send: 'eval("function test_func() {")',
expect: /\bSyntaxError: Unexpected end of input/ },
expect: /^SyntaxError: Unexpected end of input/ },
// Can handle multiline template literals
{ client: client_unix, send: '`io.js',
expect: prompt_multiline },
Expand Down Expand Up @@ -171,30 +171,31 @@ function error_test() {
// invalid input to JSON.parse error is special case of syntax error,
// should throw
{ client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',
expect: /\bSyntaxError: Unexpected token i/ },
expect: /^SyntaxError: Unexpected token i/ },
// end of input to JSON.parse error is special case of syntax error,
// should throw
{ client: client_unix, send: 'JSON.parse(\'066\');',
expect: /\bSyntaxError: Unexpected number/ },
expect: /^SyntaxError: Unexpected number/ },
// should throw
{ client: client_unix, send: 'JSON.parse(\'{\');',
expect: /\bSyntaxError: Unexpected end of JSON input/ },
expect: /^SyntaxError: Unexpected end of JSON input/ },
// invalid RegExps are a special case of syntax error,
// should throw
{ client: client_unix, send: '/(/;',
expect: /\bSyntaxError: Invalid regular expression:/ },
expect: /^SyntaxError: Invalid regular expression:/ },
// invalid RegExp modifiers are a special case of syntax error,
// should throw (GH-4012)
{ client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ },
expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ },
// strict mode syntax errors should be caught (GH-5178)
{ 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/
expect:
/\bSyntaxError: Duplicate parameter name not allowed in this context/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit \b -> ^?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And below two instances too?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this somehow breaks matching: #14607 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some error messages quote erroneous code before the error message itself, so for these messages, we can't use ^ anchor (or we should add the /m flag beside).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then \b it is!

},
{
client: client_unix,
Expand All @@ -204,15 +205,17 @@ function error_test() {
{
client: client_unix,
send: '(function() { "use strict"; var x; delete x; })()',
expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/
expect:
/\bSyntaxError: Delete of an unqualified identifier in strict mode/
},
{ 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\./
expect:
/\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block\./
},
// Named functions can be used:
{ client: client_unix, send: 'function blah() { return 1; }',
Expand Down
16 changes: 7 additions & 9 deletions test/parallel/test-v8-serdes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const objects = [
circular
];

const serializerTypeError =
/^TypeError: Class constructor Serializer cannot be invoked without 'new'$/;
const deserializerTypeError =
/^TypeError: Class constructor Deserializer cannot be invoked without 'new'$/;

{
const ser = new v8.DefaultSerializer();
ser.writeHeader();
Expand Down Expand Up @@ -133,13 +138,6 @@ const objects = [
}

{
assert.throws(
() => { v8.Serializer(); },
/^TypeError: Class constructor Serializer cannot be invoked without 'new'$/
);

assert.throws(
() => { v8.Deserializer(); },
/^TypeError: Class constructor Deserializer cannot be invoked without 'new'$/
);
assert.throws(v8.Serializer, serializerTypeError);
assert.throws(v8.Deserializer, deserializerTypeError);
}
12 changes: 8 additions & 4 deletions test/parallel/test-whatwg-url-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ assert.strictEqual(url.searchParams, oldParams); // [SameObject]
// searchParams is readonly. Under strict mode setting a
// non-writable property should throw.
// Note: this error message is subject to change in V8 updates
assert.throws(() => url.origin = 'http://foo.bar.com:22',
/TypeError: Cannot set property origin of \[object URL\] which has only a getter$/);
assert.throws(
() => url.origin = 'http://foo.bar.com:22',
/^TypeError: Cannot set property origin of \[object URL\] which has only a getter$/
);
assert.strictEqual(url.origin, 'http://foo.bar.com:21');
assert.strictEqual(url.toString(),
'http://user:[email protected]:21/aaa/zzz?l=25#test');
Expand Down Expand Up @@ -118,8 +120,10 @@ assert.strictEqual(url.hash, '#abcd');
// searchParams is readonly. Under strict mode setting a
// non-writable property should throw.
// Note: this error message is subject to change in V8 updates
assert.throws(() => url.searchParams = '?k=88',
/^TypeError: Cannot set property searchParams of \[object URL\] which has only a getter$/);
assert.throws(
() => url.searchParams = '?k=88',
/^TypeError: Cannot set property searchParams of \[object URL\] which has only a getter$/
);
assert.strictEqual(url.searchParams, oldParams);
assert.strictEqual(url.toString(),
'https://user2:[email protected]:23/aaa/bbb?k=99#abcd');
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-zlib-not-string-or-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ require('../common');
const assert = require('assert');
const zlib = require('zlib');

const expected = /^TypeError: "buffer" argument must be a string, Buffer, TypedArray, or DataView$/;
const expected =
/^TypeError: "buffer" argument must be a string, Buffer, TypedArray, or DataView$/;

assert.throws(() => { zlib.deflateSync(undefined); }, expected);
assert.throws(() => { zlib.deflateSync(null); }, expected);
Expand Down