-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
tools: lint for function argument alignment #6268
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,43 +81,54 @@ assert.equal(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1); | |
| // test hex encoding | ||
| assert.equal( | ||
| Buffer.from(b.toString('hex'), 'hex') | ||
| .indexOf('64', 0, 'hex'), 3); | ||
| .indexOf('64', 0, 'hex'), | ||
|
||
| 3); | ||
| assert.equal( | ||
| Buffer.from(b.toString('hex'), 'hex') | ||
| .indexOf(Buffer.from('64', 'hex'), 0, 'hex'), 3); | ||
| .indexOf(Buffer.from('64', 'hex'), 0, 'hex'), | ||
| 3); | ||
|
|
||
| // test base64 encoding | ||
| assert.equal( | ||
| Buffer.from(b.toString('base64'), 'base64') | ||
| .indexOf('ZA==', 0, 'base64'), 3); | ||
| .indexOf('ZA==', 0, 'base64'), | ||
| 3); | ||
| assert.equal( | ||
| Buffer.from(b.toString('base64'), 'base64') | ||
| .indexOf(Buffer.from('ZA==', 'base64'), 0, 'base64'), 3); | ||
| .indexOf(Buffer.from('ZA==', 'base64'), 0, 'base64'), | ||
| 3); | ||
|
|
||
| // test ascii encoding | ||
| assert.equal( | ||
| Buffer.from(b.toString('ascii'), 'ascii') | ||
| .indexOf('d', 0, 'ascii'), 3); | ||
| .indexOf('d', 0, 'ascii'), | ||
| 3); | ||
| assert.equal( | ||
| Buffer.from(b.toString('ascii'), 'ascii') | ||
| .indexOf(Buffer.from('d', 'ascii'), 0, 'ascii'), 3); | ||
| .indexOf(Buffer.from('d', 'ascii'), 0, 'ascii'), | ||
| 3); | ||
|
|
||
| // test binary encoding | ||
| assert.equal( | ||
| Buffer.from(b.toString('binary'), 'binary') | ||
| .indexOf('d', 0, 'binary'), 3); | ||
| .indexOf('d', 0, 'binary'), | ||
| 3); | ||
| assert.equal( | ||
| Buffer.from(b.toString('binary'), 'binary') | ||
| .indexOf(Buffer.from('d', 'binary'), 0, 'binary'), 3); | ||
| .indexOf(Buffer.from('d', 'binary'), 0, 'binary'), | ||
| 3); | ||
| assert.equal( | ||
| Buffer.from('aa\u00e8aa', 'binary') | ||
| .indexOf('\u00e8', 'binary'), 2); | ||
| .indexOf('\u00e8', 'binary'), | ||
| 2); | ||
| assert.equal( | ||
| Buffer.from('\u00e8', 'binary') | ||
| .indexOf('\u00e8', 'binary'), 0); | ||
| .indexOf('\u00e8', 'binary'), | ||
| 0); | ||
| assert.equal( | ||
| Buffer.from('\u00e8', 'binary') | ||
| .indexOf(Buffer.from('\u00e8', 'binary'), 'binary'), 0); | ||
| .indexOf(Buffer.from('\u00e8', 'binary'), 'binary'), | ||
| 0); | ||
|
|
||
|
|
||
| // test optional offset with passed encoding | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was moving the arrow a line down necessary here for the rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't the only option, but yes. Moving it meant that the next line didn't have to be indented so much that it exceeded the 80-character limit on line length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm generally not a fan of moving the first argument down if it can be avoided but can live with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell There are certainly other options, like assigning the function to a variable so you can just do
assert.throws(foo,...).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, the previous indentation is, in my opinion at least, unfriendly to the reader:
I think moving the arrow function down one line is worth getting code that is easier to understand at a glance: