Fixed bug allowing versions of Object.keys method and hard coding of ownProps array (#35021)

* fix: disallow variants of Object.keys method

* fix: added new test to help prevent hardcoding array

* fix: refactored regex
pull/30387/head^2
Randell Dawson 2019-03-17 15:47:41 -07:00 committed by Manish Giri
parent 15a8e35288
commit 9051ad2eb5
1 changed files with 4 additions and 2 deletions

View File

@ -25,9 +25,11 @@ Add the <code>own</code> properties of <code>canary</code> to the array <code>ow
```yml
tests:
- text: <code>ownProps</code> should include the values <code>"numLegs"</code> and <code>"name"</code>.
testString: assert(ownProps.indexOf('name') !== -1 && ownProps.indexOf('numLegs') !== -1, '<code>ownProps</code> should include the values <code>"numLegs"</code> and <code>"name"</code>.');
testString: assert(ownProps.indexOf('name') !== -1 && ownProps.indexOf('numLegs') !== -1);
- text: Solve this challenge without using the built in method <code>Object.keys()</code>.
testString: assert(!/\Object.keys/.test(code), 'Solve this challenge without using the built in method <code>Object.keys()</code>.');
testString: assert(!/Object(\.keys|\[(['"`])keys\2\])/.test(code));
- text: Solve this challenge without hardcoding the <code>ownProps</code> array.
testString: assert(!/\[\s*(?:'|")(?:name|numLegs)|(?:push|concat)\(\s*(?:'|")(?:name|numLegs)/.test(code));
```