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

test: apply no-useless-concat ESLint rule #12613

Closed
wants to merge 2 commits into from
Closed

test: apply no-useless-concat ESLint rule #12613

wants to merge 2 commits into from

Conversation

vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt commented Apr 23, 2017

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

It seems to me that no-useless-concat is a simple reasonable rule, so I've tried:

eslint --rulesdir tools/eslint-rules/ --rule "no-useless-concat: error" benchmark lib test tools

which have found only some fragments in tests. Occasionally, I've added some template literals for simplicity, but that was not the main aim. Please, take a look, if this is a reasonable change.

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Apr 23, 2017
@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Apr 23, 2017

CI: https://ci.nodejs.org/job/node-test-pull-request/7624/

Only 1 Windows machine unstable (with flaky sequential/test-benchmark-child-process).

@gibfahn
Copy link
Member

gibfahn commented Apr 24, 2017

@not-an-aardvark
Copy link
Contributor

Is this commit supposed to modify an .eslintrc.yaml file? I see changed code but it doesn't look like any ESLint rules were actually enabled.

@vsemozhetbyt
Copy link
Contributor Author

vsemozhetbyt commented Apr 24, 2017

@not-an-aardvark No, I did not mean to propose to enable the rule, just to correct the code itself. However, if there is a consensus to add the rule, this can be done as well (here or in an other PR), just let me know.

@gibfahn
Copy link
Member

gibfahn commented Apr 24, 2017

@vsemozhetbyt +1 to adding the rule in this PR, seems no reason not to.

@vsemozhetbyt
Copy link
Contributor Author

@gibfahn
Copy link
Member

gibfahn commented Apr 24, 2017

cc/ @refack @addaleax @lpinca , does this still LGTY with the lint rule added?

@lpinca
Copy link
Member

lpinca commented Apr 24, 2017

Still LGTM.

socket.write('HTTP/1.1 200 Connection Established' + '\r\n' +
'Proxy-agent: Node-Proxy' + '\r\n' +
socket.write('HTTP/1.1 200 Connection Established\r\n' +
'Proxy-agent: Node-Proxy\r\n' +
Copy link
Contributor

@mscdex mscdex Apr 24, 2017

Choose a reason for hiding this comment

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

I wonder why the new eslint rule didn't complain about the next '\r\n' not being included as well? I guess it only considers string literals that are in between two other literals?

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't report multiline concatenations because people often use those intentionally (e.g. to avoid long lines).

Related: eslint/eslint#7947

Copy link
Contributor Author

@vsemozhetbyt vsemozhetbyt Apr 24, 2017

Choose a reason for hiding this comment

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

It just keeps strings in different lines:

Examples of correct code for this rule... when the string concatenation is multiline

Copy link
Contributor

@not-an-aardvark not-an-aardvark Apr 24, 2017

Choose a reason for hiding this comment

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

Yes, and that's why it didn't complain about the next '\r\n'.

I think we're both saying the same thing -- did I misunderstand the question?

edit: Never mind, I didn't read the author of the last reply and thought it was from @mscdex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I was writing while your answer did not appear yet)

@mscdex
Copy link
Contributor

mscdex commented Apr 24, 2017

LGTM

@vsemozhetbyt vsemozhetbyt changed the title test: apply no-useless-concat ESLint rule to tests test: apply no-useless-concat ESLint rule Apr 24, 2017
@vsemozhetbyt
Copy link
Contributor Author

Landed in 71abfa9

@vsemozhetbyt vsemozhetbyt deleted the no-useless-concat branch April 25, 2017 19:33
vsemozhetbyt added a commit that referenced this pull request Apr 25, 2017
* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: #12613
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
@evanlucas evanlucas mentioned this pull request May 1, 2017
evanlucas pushed a commit that referenced this pull request May 1, 2017
* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: #12613
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
evanlucas pushed a commit that referenced this pull request May 2, 2017
* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: #12613
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
@gibfahn
Copy link
Member

gibfahn commented May 16, 2017

@vsemozhetbyt would you be willing to backport to v6.x?

@vsemozhetbyt
Copy link
Contributor Author

@gibfahn Sure.

@vsemozhetbyt
Copy link
Contributor Author

@gibfahn PTAL: #13056

gibfahn pushed a commit that referenced this pull request May 16, 2017
* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: #12613
Backport-PR-URL: #13056
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
MylesBorins pushed a commit that referenced this pull request May 18, 2017
* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: #12613
Backport-PR-URL: #13056
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
@MylesBorins MylesBorins mentioned this pull request May 23, 2017
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
* Add `no-useless-concat: error` to .eslintrc.yaml.
* Apply no-useless-concat rule to tests.

PR-URL: nodejs/node#12613
Backport-PR-URL: nodejs/node#13056
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants