Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat unknown prototype props as unknown (#4428)
* Treat unknown prototype methods as unknown * Improve coverage
- Loading branch information
1 parent
9c8894e
commit 84c0ea3
Showing
24 changed files
with
100 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...samples/object-expression/nested-literal-assignment-without-access-side-effect/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
description: 'treats mutating nested properties as side effects', | ||
options: { | ||
treeshake: { propertyReadSideEffects: false } | ||
} | ||
}; |
3 changes: 3 additions & 0 deletions
3
...mples/object-expression/nested-literal-assignment-without-access-side-effect/_expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const obj = { __proto__: null }; | ||
|
||
obj.foo.bar = 'retained'; |
3 changes: 3 additions & 0 deletions
3
...rm/samples/object-expression/nested-literal-assignment-without-access-side-effect/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const obj = { __proto__: null }; | ||
|
||
obj.foo.bar = 'retained'; |
6 changes: 6 additions & 0 deletions
6
...form/samples/object-expression/nested-literal-value-without-access-side-effect/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
description: 'uses an unknown value for nested properties', | ||
options: { | ||
treeshake: { propertyReadSideEffects: false } | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
...rm/samples/object-expression/nested-literal-value-without-access-side-effect/_expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const obj = { __proto__: null }; | ||
|
||
if (obj.foo.bar) { | ||
console.log('retained'); | ||
} |
5 changes: 5 additions & 0 deletions
5
test/form/samples/object-expression/nested-literal-value-without-access-side-effect/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const obj = { __proto__: null }; | ||
|
||
if (obj.foo.bar) { | ||
console.log('retained'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const obj = {}; | ||
const obj = { __proto__: null }; | ||
obj.foo?.bar; | ||
obj.foo?.(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const obj = {}; | ||
obj?.foo | ||
const obj = { __proto__: null }; | ||
obj?.foo; | ||
obj.foo?.bar; | ||
obj.foo?.(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
test/form/samples/super-classes/super-class-prototype-values/_expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
test/function/samples/retain-unknown-prototype-access/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'treats unknown builtin prototype properties as unknown' | ||
}; |
10 changes: 10 additions & 0 deletions
10
test/function/samples/retain-unknown-prototype-access/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Object.defineProperty(Array.prototype, 'isEmpty', { | ||
get() { | ||
return this.length === 0; | ||
} | ||
}); | ||
|
||
const array = []; | ||
assert.strictEqual(array.isEmpty ? 'works' : 'broken', 'works'); | ||
array.push('foo'); | ||
assert.strictEqual(array.isEmpty ? 'broken' : 'works', 'works'); |