-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: adjust indentation for stricter linting #14431
Conversation
@@ -62,7 +62,7 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol && | |||
|
|||
function compareToNative(theObject, theConstructor) { | |||
assert.strictEqual(addon.doInstanceOf(theObject, theConstructor), |
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.
If we have to split parameters into several lines, I'd like to let first parameter use a new line also.
eg.
assert.strictEqual(
addon.doInstanceOf(...),
(theObject instanceof theConstructor));
VS
assert.strictEqual(addon.doInstanceOf(...),
(theObject instanceof theConstructor));
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'll do it here and anywhere else someone flags in this PR, but not sure about everywhere because this sort of thing is all over our code base already and the churn would be extreme.
test/.eslintrc.yaml
Outdated
MemberExpression: off, | ||
ObjectExpression: first, | ||
SwitchCase: 1}] | ||
indent-legacy: 0 |
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.
a tiny nit: may be off
according to overall verbose style.
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.
Oh, yes, and I'll make the same change in lib/.eslintrc.yaml
too!
// these lines should contain tab! | ||
// eslint-disable-next-line no-throw-literal | ||
throw ({ foo: 'bar' }); | ||
// these lines should contain tab! |
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 am a bit confused here. The comment states the tabs are needed here (as the eslint comment above disabling no-tabs
).
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.
Oops, yeah, I probably messed that test up. Will fix...
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.
Fixed.
@@ -1,5 +1,5 @@ | |||
before | |||
*test*message*throw_in_line_with_tabs.js:* | |||
throw ({ foo: 'bar' }); | |||
^ | |||
throw ({ foo: 'bar' }); |
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.
ditto
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.
Fixed.
test/parallel/test-buffer-from.js
Outdated
@@ -31,7 +31,7 @@ deepStrictEqual(Buffer.from(new String(checkString)), check); | |||
deepStrictEqual(Buffer.from(new MyString()), check); | |||
deepStrictEqual(Buffer.from(new MyPrimitive()), check); | |||
deepStrictEqual(Buffer.from( | |||
runInNewContext('new String(checkString)', { checkString })), | |||
runInNewContext('new String(checkString)', { checkString })), |
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 seems this line can be unwrapped now.
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.
Done!
test/parallel/test-buffer-new.js
Outdated
message: 'The "string" argument must be of type string. ' + | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
type: TypeError, | ||
message: 'The "string" argument must be of type string. ' + |
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 seems this line can be unwrapped (de-concatenated) now.
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.
Done!
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.
Some nits
allowNoInit, | ||
logid, | ||
logtype } = {}) { | ||
oninit, |
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 guess this is very C++, but not my cup of tea.
If there are no objections I'd rather have
exports = module.exports = function initHooks(
{ oninit, onbefore, onafter, ondestroy, allowNoInit, logid, logtype } = {}) {
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.
Uhh I'd prefer the form in the PR, because imagine what that variant would look like if I were to add another option.
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.
Yeah, it's definatly at it's limit... Although at a later stage we could move the destructuring into the function's body...
Anyway, I'm not strongly opposed to current format.
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.
Improved readability slightly by adding a new line after logtype
...
test/parallel/test-http-parser.js
Outdated
@@ -129,7 +129,7 @@ function expectBody(expected) { | |||
// | |||
{ | |||
const request = Buffer.from( | |||
'HTTP/1.1 200 OK' + CRLF + | |||
'HTTP/1.1 200 OK' + CRLF + |
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.
That's the rule? just the first one, and then there's a continuation indent added...
Not amazing 🤷♂️
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.
Continuation indentation is ignored. So this is fine by the linter:
const request = Buffer.from(
'HTTP/1.1 200 OK' + CRLF +
'Content-Type: text/plain' + CRLF +
'Content-Length: 4' + CRLF +
CRLF +
'pong'
);
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.
IMHO it should be "square"
AFAICT it's only in this file.
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.
Will square them all up. Might also take the opportunity to get rid of the CRLF
constant...
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.
All squared up.
'--use-bundled-ca', | ||
'--use-openssl-ca', | ||
'-p', 'process.version'], | ||
'--use-bundled-ca', |
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.
could you chop all the parameters:
const result = childProcess.spawnSync(
process.execPath,
[
'--use-bundled-ca',
'--use-openssl-ca',
'-p', 'process.version'
],
{ encoding: 'utf8' }
);
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'd like this one:
const result = childProcess.spawnSync(
process.execPath, [
'--use-bundled-ca',
'--use-openssl-ca',
'-p', 'process.version'
], {
encoding: 'utf8'
});
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.
Either one's good by me,
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.
Went with this third option:
const result = childProcess.spawnSync(
process.execPath,
[ '--use-bundled-ca', '--use-openssl-ca', '-p', 'process.version' ],
{ encoding: 'utf8' }
);
@Trott is an experienced contributor I'm using the red ❌ , but it's not a hard block. I'm assuming this is the result of |
deda5b7
to
63f23d7
Compare
20f1051
to
ff0c507
Compare
Nits addressed as far as I know. PTAL, @refack, and anyone else. |
ondestroy, | ||
allowNoInit, | ||
logid, | ||
logtype |
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.
not related to this PR about whitespace, but could we enforce trailing commas? makes things easier in git when another field is added and only have a 1 line change instead of 2.
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 was trying to propose this for the docs, but it seems this lacks approvement:
#12557
assert.strictEqual(Buffer.isEncoding(enc), true); | ||
}); | ||
assert.strictEqual(Buffer.isEncoding(enc), true); | ||
}); |
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.
this just looks weird. having the body of code on the same indentation level is confusing when quickly scanning the code.
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.
Agreed. Will fix.
@@ -92,7 +91,7 @@ function expectBody(expected) { | |||
// Simple request test. | |||
// | |||
{ | |||
const request = Buffer.from(`GET /hello HTTP/1.1${CRLF}${CRLF}`); | |||
const request = Buffer.from('GET /hello HTTP/1.1\r\n\r\n'); |
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.
This is a non whitespace change in a commit that only refers to changes in whitespace. Please also make note of this is the git message body.
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'll move that file's changes into its own commit.
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.
Moved to its own commit.
478b3f1
to
2e13dc4
Compare
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. PR-URL: nodejs#14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* eliminate CRLF identifier, reducing string concatenation * adjust indentation for stricter ESLint 4.x indentation linting PR-URL: #14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This doesn’t land cleanly on 8.x; if you can, please follow the guide and raise a backport PR, if you don’t think it’s worth it let me know and add the |
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. PR-URL: nodejs#14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Backported in #14522. |
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. Backport-PR-URL: #14522 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: #14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. Backport-PR-URL: nodejs#14522 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> PR-URL: nodejs#14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. Backport-PR-URL: #14835 PR-URL: #14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. Backport-PR-URL: #14835 PR-URL: #14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
ESLint 4.x has stricter linting than previous versions. We are currently
using the legacy indentation rules in the test directory. This commit
changes the indentation of files to comply with the stricter 4.x
linting and enable stricter linting in the test directory.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test tools