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

Conversation

thelostone-mc
Copy link
Contributor

@thelostone-mc thelostone-mc commented Aug 3, 2017

Format commit wrapping lines containing RegEx and exceeding 80
chars.

Fixes: #14586

Files Changed:

  • test/addons-napi/test_properties/test.js
  • test/parallel/test-process-versions.js
  • test/parallel/test-repl.js
  • test/parallel/test-v8-serdes.js
  • test/parallel/test-whatwg-url-properties.js
  • test/parallel/test-zlib-not-string-or-buffer.js
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests. labels Aug 3, 2017
@@ -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: /^\bSyntaxError: Unexpected end of input/ },
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. There are some RegExps with the same pattern which are left unchanged (lines 193, 198, 203 etc).

  2. It seems the \b symbol after the ^ is unneeded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vsemozhetbyt

  1. Well I tried that. On introducing a ^ in L193 which uses strict mode, I get the Octal literals are not allowed in strict mode error as below: (Same case as in other lines you had mentioned )
Unix data: "(function() { \"use strict\"; return 0755; })()\n 
^^^^\n\nSyntaxError: Octal literals are not allowed in strict mode.\n\nnode via Unix socket> node via Unix socket> ", expecting /^SyntaxError: Octal literals are not allowed in strict mode/
assert.js:42
  1. Yeah makes sense. Will do that! Can I go ahead and remove the\b even where I can't introduce a ^ cause of strict mode ?

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Oh, sorry, I did not think this broke matching.

  2. I think that removing the \b is safe only if we place ^ before)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack and taken care of ^_^

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

💯 on the wrapping!

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

Choose a reason for hiding this comment

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

Nit: Now the whole thing would fit in a single line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thefourtheye True! But doesn't it look cleaner this way ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm with @thefourtheye, also could drop the () => { } to get:

assert.throws(v8.Serializer, serializerTypeError);

Now that's clean ✨

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well two against one !! Ack and taken care

// 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!

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM if CI is green.

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Aug 3, 2017

One aix fail in CI seems unrelated (parallel/test-async-wrap-getasyncid is crashed).

@Trott
Copy link
Member

Trott commented Aug 3, 2017

One aix fail in CI seems unrelated (parallel/test-async-wrap-getasyncid is crashed).

Yes, that's a known-flaky on that platform: #14599

@refack and possibly others are investigating.

CI is effectively green for this. 🎉

@refack refack self-assigned this Aug 3, 2017
Format commit wrapping lines containing RegEx and exceeding 80
chars.

Fixes: nodejs#14586
@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Aug 4, 2017

@vsemozhetbyt
Copy link
Contributor

CI failures seem unrelated.

refack pushed a commit to refack/node that referenced this pull request Aug 7, 2017
Format commit wrapping lines containing RegEx and exceeding 80
chars.

PR-URL: nodejs#14607
Fixes: nodejs#14586
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@refack
Copy link
Contributor

refack commented Aug 7, 2017

Landed in ad664ea
Turned out nice if I may say so myself.

@refack refack closed this Aug 7, 2017
addaleax pushed a commit that referenced this pull request Aug 10, 2017
Format commit wrapping lines containing RegEx and exceeding 80
chars.

PR-URL: #14607
Fixes: #14586
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@addaleax addaleax mentioned this pull request Aug 13, 2017
@MylesBorins
Copy link
Contributor

This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported

@refack refack removed their assignment Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lint: wrap long lines that include RegExp when possible
7 participants