Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-72677

Re-enable the "block-declaration-no-ignored-properties" rule in stylelint

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MDL-72677-stylelint-ignored-properties
    • Hide

      Testing this requires some manipulation of the code, given that this patch introduces a new stylelint rule, as well as the fix to a newly detected problem in the boost theme.

      Test 1: check that the lint tests in the grunt build pass using this patch.

      1. Run the grunt build:

        npm install
        npx grunt

      2. Verify that it passes without errors.

      Test 2: check that the grunt build passes, with the fix to the boost theme, and without the new stylelint plugin.

      1. Remove this line from the .stylelintrc file:

        "plugin/declaration-block-no-ignored-properties": true,

      2. Run the grunt build:

        npm install
        npx grunt

      3. Verify that it passes without errors.

      Test 3: check that the lint tests in the grunt build fail, without the patched fix to the boost theme, but with the new stylelint "no ignored properties" plugin.

      1. Restore the .stylelintrc file from the patch, i.e. ensure that this line is reinstated:

        "plugin/declaration-block-no-ignored-properties": true,

      2. Remove the z-index: 0 property from any CSS selector that also includes the position: static property, e.g. the .custom-control-input selector in the theme/boost/scss/moodle/debug.scss file, on line 34.
      3. Run the grunt build:

        npm install
        npx grunt

      4. Verify that the grunt build fails with an error:

        34:9 ✖ Unexpected "z-index" with "position: static" plugin/declaration-block-no-ignored-properties

      Show
      Testing this requires some manipulation of the code, given that this patch introduces a new stylelint rule, as well as the fix to a newly detected problem in the boost theme. Test 1: check that the lint tests in the grunt build pass using this patch. Run the grunt build: npm install npx grunt Verify that it passes without errors. Test 2: check that the grunt build passes, with the fix to the boost theme, and without the new stylelint plugin. Remove this line from the .stylelintrc file: "plugin/declaration-block-no-ignored-properties": true, Run the grunt build: npm install npx grunt Verify that it passes without errors. Test 3: check that the lint tests in the grunt build fail, without the patched fix to the boost theme, but with the new stylelint "no ignored properties" plugin. Restore the .stylelintrc file from the patch, i.e. ensure that this line is reinstated: "plugin/declaration-block-no-ignored-properties": true, Remove the z-index: 0 property from any CSS selector that also includes the position: static property, e.g. the .custom-control-input selector in the theme/boost/scss/moodle/debug.scss file, on line 34. Run the grunt build: npm install npx grunt Verify that the grunt build fails with an error: 34:9 ✖ Unexpected "z-index" with "position: static" plugin/declaration-block-no-ignored-properties

    Description

      Upgrading to new versions of stylelint at some point (around 8.x I think) pushed the "declaration-block-no-ignored-properties" rule out into a separate plugin. This languished for a while but has been recently updated and works well. I have a patch that adds it into package.json and enables it in .stylelintrc and it has found a minor issue in the boost theme (unexpected "z-index" with "position: static" - i.e. when a selector has a static position, its z-index is ignored).

      This is a useful rule, as it flags redundant CSS properties and may help avoid certain classes of bug, or at least make debugging the CSS less confusing!

      Attachments

        Activity

          People

            Unassigned Unassigned
            jonathanharker Jonathan
            Huong Nguyen, Bas Brands, Mathew May
            Votes:
            3 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: