From 918cabed2d1ec2f20c8def5bcb9ed90de6dc23e0 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Sat, 17 Jun 2023 18:19:55 +0200 Subject: [PATCH] fix: remove comments again (#50718) Co-authored-by: Naomi Carrigan --- .../es6/create-strings-using-template-literals.md | 5 ++--- .../es6/mutate-an-array-declared-with-const.md | 13 +++++-------- .../es6/prevent-object-mutation.md | 14 +++++--------- ...he-rest-parameter-to-reassign-array-elements.md | 3 ++- ...write-concise-declarative-functions-with-es6.md | 3 ++- ...declarations-using-object-property-shorthand.md | 9 ++++++++- curriculum/get-challenges.js | 8 ++++++++ curriculum/schema/challenge-schema.js | 2 +- 8 files changed, 33 insertions(+), 24 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md index 870716c3ec6..22e02de6657 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md @@ -69,14 +69,13 @@ assert( Template strings and expression interpolation should be used. ```js -(getUserInput) => assert(getUserInput('index').match(/(`.*\${.*}.*`)/)); +assert.match(code, /(`.*\${.*}.*`)/); ``` An iterator should be used. ```js -(getUserInput) => - assert(getUserInput('index').match(/for|map|reduce|forEach|while/)); +assert(code.match(/for|map|reduce|forEach|while/)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md index a00656a24c7..45e1bf50d4a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md @@ -36,24 +36,21 @@ An array is declared as `const s = [5, 7, 2]`. Change the array to `[2, 5, 7]` u You should not replace `const` keyword. ```js -(getUserInput) => assert(getUserInput('index').match(/const/g)); +assert(code.match(/const/g)); ``` `s` should be a constant variable (by using `const`). ```js -(getUserInput) => assert(getUserInput('index').match(/const\s+s/g)); +assert(code.match(/const\s+s/g)); ``` You should not change the original array declaration. ```js -(getUserInput) => - assert( - getUserInput('index').match( - /const\s+s\s*=\s*\[\s*5\s*,\s*7\s*,\s*2\s*\]\s*;?/g - ) - ); +assert(code.match( +/const\s+s\s*=\s*\[\s*5\s*,\s*7\s*,\s*2\s*\]\s*;?/g +)); ``` `s` should be equal to `[2, 5, 7]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md index b935faca1a4..81871af4d84 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md @@ -34,25 +34,21 @@ In this challenge you are going to use `Object.freeze` to prevent mathematical c You should not replace the `const` keyword. ```js -(getUserInput) => assert(getUserInput('index').match(/const/g)); +assert(code.match(/const/g)); ``` `MATH_CONSTANTS` should be a constant variable (by using `const`). ```js -(getUserInput) => - assert(getUserInput('index').match(/const\s+MATH_CONSTANTS/g)); +assert(code.match(/const\s+MATH_CONSTANTS/g)); ``` You should not change the original declaration of `MATH_CONSTANTS`. ```js -(getUserInput) => - assert( - getUserInput('index').match( - /const\s+MATH_CONSTANTS\s+=\s+{\s+PI:\s+3.14\s+};/g - ) - ); +assert(code.match( + /const\s+MATH_CONSTANTS\s+=\s+{\s+PI:\s+3.14\s+};/g +)); ``` `PI` should equal `3.14`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md index 520e4297f7c..dbcd444313a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md @@ -49,7 +49,7 @@ assert(testArr_.every((e, i) => e === i + 1) && testArr_.length === 5); `Array.slice()` should not be used. ```js -(getUserInput) => assert(!getUserInput('index').match(/slice/g)); +assert(!code.match(/slice/g)); ``` Destructuring on `list` should be used. @@ -82,6 +82,7 @@ const sourceWithoutFirstTwo = removeFirstTwo(source); ```js function removeFirstTwo(list) { + // comment with 'slice' to check comments are removed in tests const [, , ...shorterList] = list; return shorterList; } diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md index 78a62f5fb2d..358e8df5ea9 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md @@ -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(!code.match(/function/)); +assert(!code.match(/function/)); ``` `setGear` should be a declarative function. @@ -79,6 +79,7 @@ console.log(bicycle.gear); ```js const bicycle = { gear: 2, + // setGear: function(newGear) { setGear(newGear) { this.gear = newGear; } diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md index 33dabc5d3a5..5841f2d195e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md @@ -43,7 +43,7 @@ assert.deepEqual( Your code should not use `key:value`. ```js -(getUserInput) => assert(!getUserInput('index').match(/:/g)); +assert(!code.match(/:/g)) ``` # --seed-- @@ -66,10 +66,17 @@ const createPerson = (name, age, gender) => { ```js const createPerson = (name, age, gender) => { + // Only change code below this line + /*return { + name: name, + age: age, + gender: gender + };*/ return { name, age, gender }; + // Only change code above this line }; ``` diff --git a/curriculum/get-challenges.js b/curriculum/get-challenges.js index e6950f9496d..58d2ea7c2ed 100644 --- a/curriculum/get-challenges.js +++ b/curriculum/get-challenges.js @@ -334,6 +334,9 @@ Challenges that have been already audited cannot fall back to their English vers challenge.translationPending = lang !== 'english' && !isAuditedCert(lang, meta.superBlock); challenge.usesMultifileEditor = !!meta.usesMultifileEditor; + } + + function fixChallengeProperties(challenge) { if (challenge.challengeFiles) { // The client expects the challengeFiles to be an array of polyvinyls challenge.challengeFiles = challengeFilesToPolys( @@ -345,6 +348,10 @@ Challenges that have been already audited cannot fall back to their English vers // can sort them correctly. challenge.solutions = challenge.solutions.map(challengeFilesToPolys); } + // if removeComments is not explicitly set, default to true + if (typeof challenge.removeComments === 'undefined') { + challenge.removeComments = true; + } } async function createChallenge(filePath, maybeMeta) { @@ -371,6 +378,7 @@ Challenges that have been already audited cannot fall back to their English vers : parseMD(getFullPath('english', filePath))); addMetaToChallenge(challenge, meta); + fixChallengeProperties(challenge); return challenge; } diff --git a/curriculum/schema/challenge-schema.js b/curriculum/schema/challenge-schema.js index eb41f8a01bf..7d3a395c325 100644 --- a/curriculum/schema/challenge-schema.js +++ b/curriculum/schema/challenge-schema.js @@ -26,7 +26,7 @@ const schema = Joi.object() block: Joi.string().regex(slugRE).required(), blockId: Joi.objectId(), challengeOrder: Joi.number(), - removeComments: Joi.bool(), + removeComments: Joi.bool().required(), certification: Joi.string().regex(slugRE), challengeType: Joi.number().min(0).max(19).required(), checksum: Joi.number(),