freeCodeCamp / curriculum

The freeCodeCamp curriculum and lesson editor
Creative Commons Attribution Share Alike 4.0 International
81 stars 124 forks source link

Grid Column Gap challenge matches with a declaration outside of the .container rule #228

Open joshalling opened 6 years ago

joshalling commented 6 years ago

The grid column gap challenge doesn't ensure that your declaration is within the .container rule. This means you can put the grid-column-gap declaration in a different rule and still pass the challenge.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. add the following code below the .container rule
    div {
     grid-column-gap: 20px;
    }
  3. Click run and the test passes

This issue persists throughout a lot of the Grid challenges. I propose that we update the regex to prevent the test from passing if a closing curly brace is present between the .container selector and the grid-column-gap declaration.

RobAnthony01 commented 6 years ago

Actually it's worse than that as this passes

    junk   grid-column-gap: 20px;

and

    junkgrid-column-gap: 20px;

We could check there is nothing else between the two forward slashes (in the comments) other than whitespace?

So, this would pass:

    /* add your code below this line */
    grid-column-gap: 20px;
    /* add your code above this line */

but this would not:

    /* add your code below this line */
    junk grid-column-gap: 20px;
    /* add your code above this line */