-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
tools: don't use global Buffer and add linter rule for it #1794
Changes from 3 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable require-buffer */ | ||
'use strict'; | ||
|
||
const binding = process.binding('buffer'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,17 +106,13 @@ function checkResults(expected_results, results) { | |
var actual = results[k], | ||
expected = expected_results[k]; | ||
|
||
if (typeof expected === 'function') { | ||
expected(r[k]); | ||
} else { | ||
var msg = (expected[1] || '') + | ||
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); | ||
var msg = (expected[1] || '') + | ||
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an actual error with the undefined |
||
|
||
if (expected && expected.length) { | ||
assert.equal(actual, expected[0], msg); | ||
} else { | ||
assert.equal(actual, expected, msg); | ||
} | ||
if (expected && expected.length) { | ||
assert.equal(actual, expected[0], msg); | ||
} else { | ||
assert.equal(actual, expected, msg); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,16 +106,12 @@ function checkResults(expected_results, results) { | |
var actual = results[k], | ||
expected = expected_results[k]; | ||
|
||
if (typeof expected === 'function') { | ||
expected(r[k]); | ||
var msg = (expected[1] || '') + | ||
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
if (expected && expected.length) { | ||
assert.equal(actual, expected[0], msg); | ||
} else { | ||
var msg = (expected[1] || '') + | ||
(' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); | ||
if (expected && expected.length) { | ||
assert.equal(actual, expected[0], msg); | ||
} else { | ||
assert.equal(actual, expected, msg); | ||
} | ||
assert.equal(actual, expected, msg); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ process.on('exit', function() { | |
assert.ok(starttime != null); | ||
assert.ok(timeouttime != null); | ||
|
||
diff = timeouttime - starttime; | ||
var diff = timeouttime - starttime; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange that both common and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange indeed. If I run this test manually on master without the testing framework, I see a ReferenceError. Not too familar with pummel tests, how are they executed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same way all the other tests are run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yeah. forgot about that slight nuance. :P Reason they're not run with all the others is because they have the potential to run a long time, or overload the systems resources. |
||
console.log('diff = ' + diff); | ||
|
||
assert.ok(timeout < diff); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
const msg = "Use const Buffer = require('buffer').Buffer; on top of this file"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: s/on top of/at the beginning of/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid escaping it's okay (There's a linter rule for it). |
||
|
||
module.exports = function(context) { | ||
return { | ||
"Program:exit": function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix that. |
||
context.getScope().through.forEach(function(ref) { | ||
if (ref.identifier.name === 'Buffer') { | ||
context.report(ref.identifier, msg); | ||
} | ||
}); | ||
} | ||
} | ||
} |
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 thought
'use strict'
had to go on the first line of either the file or function. Does that exclude comments?/cc @domenic
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.
nm. see it doesn't matter.
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 pretty sure it does exclude comments, considering the amount of files with copyright hats at the very top.