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

tools: enable no-proto rule for linter #5140

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ecmaFeatures:
rules:
# Possible Errors
# list: https://github.com/eslint/eslint/tree/master/docs/rules#possible-errors
## Disallow Use of __proto__
no-proto: 2
## disallow control characters in regular expressions
no-control-regex: 2
## check debugger sentence
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {

function protoCtrChain(o) {
var result = [];
for (; o; o = o.__proto__) { result.push(o.constructor); }
for (; o; o = Object.getPrototypeOf(o)) { result.push(o.constructor); }
return result.join();
}

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-arraybuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ assert.equal(dv.getFloat64(8, true), 3.1415);

assert.throws(function() {
function AB() { }
AB.__proto__ = ArrayBuffer;
AB.prototype.__proto__ = ArrayBuffer.prototype;
Object.setPrototypeOf(AB, ArrayBuffer);
Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype);
new Buffer(new AB());
}, TypeError);

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-fakes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const assert = require('assert');
const Buffer = require('buffer').Buffer;

function FakeBuffer() { }
FakeBuffer.__proto__ = Buffer;
FakeBuffer.prototype.__proto__ = Buffer.prototype;
Object.setPrototypeOf(FakeBuffer, Buffer);
Object.setPrototypeOf(FakeBuffer.prototype, Buffer.prototype);

const fb = new FakeBuffer();

Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-buffer-inheritance.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const vals = [new T(4), T(4)];

vals.forEach(function(t) {
assert.equal(t.constructor, T);
assert.equal(t.__proto__, T.prototype);
assert.equal(t.__proto__.__proto__, Buffer.prototype);
assert.equal(Object.getPrototypeOf(t), T.prototype);
assert.equal(Object.getPrototypeOf(Object.getPrototypeOf(t)),
Buffer.prototype);

t.fill(5);
let cntr = 0;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-child-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var spawn = require('child_process').spawn;
var env = {
'HELLO': 'WORLD'
};
env.__proto__ = {
Object.setPrototypeOf(env, {
'FOO': 'BAR'
};
});

var child;
if (common.isWindows) {
Expand Down