Problem/Motivation

As mentioned in the parent issue #3238306: [META] Where possible, refactor existing jQuery uses to vanillaJS to reduce jQuery footprint, we are working towards reducing our jQuery footprint. One of the ways to accomplish this is to reduce the number of jQuery features used in Drupal core. We have added eslint rules that identify specific features and fail tests when those features are in use.

There are (or will be) individual issues for each jQuery-use eslint rule. This one is specific to jquery/no-clone, which targets the jQuery clone function.

Steps to reproduce

Proposed resolution

Remaining tasks

  • In core/.eslintrc.jquery.json Change "jquery/no-clone": 0, to "jquery/no-clone": 2, to enable eslint checks for uses of jQuery .clone(). With this change, you'll be able to see uses of the undesirable jQuery feature by running yarn lint:core-js-passing from the core directory
  • Add the following lines to core/scripts/dev/commit-code-check.sh so the DrupalCI testing script can catch this jQuery usage on all files, not just those which have changed
    # @todo Remove the next chunk of lines before committing. This script only lints
    #  JavaScript files that have changed, so we add this to check all files for
    #  jQuery-specific lint errors.
    cd "$TOP_LEVEL/core"
    node ./node_modules/eslint/bin/eslint.js --quiet --config=.eslintrc.passing.json .
    
    CORRECTJQS=$?
    if [ "$CORRECTJQS" -ne "0" ]; then
      # No need to write any output the node command will do this for us.
      printf "${red}FAILURE ${reset}: unsupported jQuery usage. See errors above."
      STATUS=1
      FINAL_STATUS=1
    fi
    cd $TOP_LEVEL
    # @todo end lines to remove

    Add the block about 10 lines before the end of the file, just before if [[ "$FINAL_STATUS" == "1" ]] && [[ "$DRUPALCI" == "1" ]]; then, then remove it once all the jQuery uses have been refactored.

  • If it's determined to be feasible, refactor those uses of jQuery .clone() to use Vanilla (native) JavaScript instead.

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#8 3239490-8.patch1.39 KBsakthi_dev

Issue fork drupal-3239490

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Theresa.Grannum created an issue. See original summary.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Sam Phillemon’s picture

Assigned: Unassigned » Sam Phillemon
Status: Active » Needs work
sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB

Updated the patch with 11.x. Please review.

Sam Phillemon’s picture

Assigned: Sam Phillemon » Unassigned
Sam Phillemon’s picture

Assigned: Unassigned » Sam Phillemon
Status: Needs review » Needs work
Sam Phillemon’s picture

Assigned: Sam Phillemon » Unassigned

I am currently working on this issue.

Sam Phillemon’s picture

Status: Needs work » Needs review

I have looked into this issue and didn't find any js related linting issues.

smustgrave’s picture

Status: Needs review » Needs work

Should be MR and not include changes to core scripts.

Sam Phillemon’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Need to remove change to the script. Can see other related issues for guidance

Sam Phillemon’s picture

Removed the DrupalCI testing script. can you please let me know what other issues you are seeing?

guptahemant’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

That was it.

alexpott’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 9cdd64881d to 11.x and 5f2e43b35a to 10.3.x. Thanks!

  • alexpott committed 5f2e43b3 on 10.3.x
    Issue #3239490 by Sam Phillemon, Theresa.Grannum, smustgrave:  Refactor...

  • alexpott committed 9cdd6488 on 11.x
    Issue #3239490 by Sam Phillemon, Theresa.Grannum, smustgrave:  Refactor...
alexpott’s picture

Created #3425580: Run linting jobs when config for the linter changes to ensure the linting pipeline runs when eslint config changes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.