fix(client): remove JS comments from user code for tests (#41873)
* Removes comments in js challanges by default * fix local-scope-and-functions test regex * fix all languages * revert language changes * removed unnecessary removeJSComments from challenges * fix challanges in other languages * removed removeJSComments from all challanges
This commit is contained in:
committed by
GitHub
parent
ebe8f99345
commit
db369fbed1
@ -65,7 +65,7 @@ assert.deepEqual(copyMachine(['it works'], 3), [
|
||||
The `copyMachine` function should utilize the `spread operator` with array `arr`
|
||||
|
||||
```js
|
||||
assert(__helpers.removeJSComments(code).match(/\.\.\.arr/));
|
||||
assert(code.match(/\.\.\.arr/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
@ -2,6 +2,7 @@
|
||||
id: bd7123c9c441eddfaeb4bdef
|
||||
title: Comment Your JavaScript Code
|
||||
challengeType: 1
|
||||
removeComments: false
|
||||
videoUrl: 'https://scrimba.com/c/c7ynnTp'
|
||||
forumTopicId: 16783
|
||||
dashedName: comment-your-javascript-code
|
||||
|
@ -45,7 +45,7 @@ You should add a local `myVar` variable.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/functionmyLocalScope\(\)\{.+(var|let|const)myVar[\s\S]*}/.test(
|
||||
/functionmyLocalScope\(\)\{.*(var|let|const)myVar[\s\S]*}/.test(
|
||||
__helpers.removeWhiteSpace(code)
|
||||
)
|
||||
);
|
||||
|
@ -66,9 +66,7 @@ Your code should not rely on any kind of loops (`for` or `while` or higher order
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -76,7 +74,7 @@ You should use recursion to solve this problem.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers.removeJSComments(sum.toString()).match(/sum\(.*\)/g).length > 1
|
||||
sum.toString().match(/sum\(.*\)/g).length > 1
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -59,9 +59,7 @@ Your code should not rely on any kind of loops (`for`, `while` or higher order f
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -69,7 +67,7 @@ You should use recursion to solve this problem.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers.removeJSComments(countdown.toString()).match(/countdown\s*\(.+\)/)
|
||||
countdown.toString().match(/countdown\s*\(.+\)/)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -26,9 +26,7 @@ Your code should not use any loop syntax (`for` or `while` or higher order funct
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -36,9 +34,7 @@ assert(
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(rangeOfNumbers.toString())
|
||||
.match(/rangeOfNumbers\s*\(.+\)/)
|
||||
rangeOfNumbers.toString().match(/rangeOfNumbers\s*\(.+\)/)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -33,7 +33,7 @@ You should use `console.clear()` to clear the browser console.
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeWhiteSpace(__helpers.removeJSComments(code))
|
||||
.removeWhiteSpace(code)
|
||||
.match(/console.clear\(\)/)
|
||||
);
|
||||
```
|
||||
|
@ -32,11 +32,7 @@ Make the promise handle success and failure. If `responseFromServer` is `true`,
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g
|
||||
)
|
||||
code.match(/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -44,11 +40,7 @@ assert(
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g
|
||||
)
|
||||
code.match(/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -43,9 +43,7 @@ You should remove the ES5 assignment syntax.
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers
|
||||
.removeJSComments(code)
|
||||
.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g)
|
||||
!code.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -53,11 +51,7 @@ You should use destructuring to create the `today` variable.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g
|
||||
)
|
||||
code.match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g)
|
||||
);
|
||||
```
|
||||
|
||||
@ -65,11 +59,7 @@ You should use destructuring to create the `tomorrow` variable.
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeJSComments(code)
|
||||
.match(
|
||||
/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g
|
||||
)
|
||||
code.match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g)
|
||||
);
|
||||
```
|
||||
|
||||
|
@ -39,7 +39,7 @@ Refactor the function `setGear` inside the object `bicycle` to use the shorthand
|
||||
Traditional function expression should not be used.
|
||||
|
||||
```js
|
||||
(getUserInput) => assert(!__helpers.removeJSComments(code).match(/function/));
|
||||
(getUserInput) => assert(!code.match(/function/));
|
||||
```
|
||||
|
||||
`setGear` should be a declarative function.
|
||||
|
@ -28,7 +28,7 @@ assert.typeOf(squareList, 'function'),
|
||||
`for`, `while`, and `forEach` should not be used.
|
||||
|
||||
```js
|
||||
assert(!__helpers.removeJSComments(code).match(/for|while|forEach/g));
|
||||
assert(!code.match(/for|while|forEach/g));
|
||||
```
|
||||
|
||||
`map`, `filter`, or `reduce` should be used.
|
||||
@ -36,7 +36,7 @@ assert(!__helpers.removeJSComments(code).match(/for|while|forEach/g));
|
||||
```js
|
||||
assert(
|
||||
__helpers
|
||||
.removeWhiteSpace(__helpers.removeJSComments(code))
|
||||
.removeWhiteSpace(code)
|
||||
.match(/\.(map|filter|reduce)\(/g)
|
||||
);
|
||||
```
|
||||
|
@ -52,7 +52,7 @@ assert(
|
||||
Your code should not use a `for` loop.
|
||||
|
||||
```js
|
||||
assert(!__helpers.removeJSComments(code).match(/for\s*?\([\s\S]*?\)/));
|
||||
assert(!code.match(/for\s*?\([\s\S]*?\)/));
|
||||
```
|
||||
|
||||
Your code should use the `map` method.
|
||||
|
Reference in New Issue
Block a user