From 9ca1eba6486fa961ea1dba147a10b93a65d316ad Mon Sep 17 00:00:00 2001 From: James Shields <57457-lostcarpark@users.noreply.drupalcode.org> Date: Sun, 25 Feb 2024 19:58:35 +0000 Subject: [PATCH] Issue #3421699 by lostcarpark, fjgarlin, chrisfromredfin: Gitlab CI - get ESLint running --- .gitlab-ci.yml | 24 +++++++++++++++++++++--- js/project_browser.admin.js | 19 +++++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36dcf9e49..1c5dac02e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,9 +47,6 @@ include: # Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml ################ variables: - # eslint doesn't work right now because Project Browser's dev dependencies are not added on CI: https://git.drupalcode.org/issue/project_browser-3415079/-/jobs/644818#L34 - # Fix this in a follow-up. - SKIP_ESLINT: '1' # These two variables allow PHPUnit to run in a parallel job matrix. _PHPUNIT_CONCURRENT: '1' _PHPUNIT_TESTGROUPS: '' @@ -64,6 +61,27 @@ phpstan: before_script: - sed -i "s/\/core\//\/web\/core\//" phpstan.neon.dist +################ +# We want to run standard eslint for /js directory, but not /sveltejs directory. +# .eslintignore patterns do not work due to ESLint scanning for .eslintrc.js +################ +eslint: + before_script: + - rm -fr sveltejs + +################ +# Add a new section for validation of Svelte JS. +################ +eslint-sveltejs: + stage: validate + allow_failure: true + needs: + - composer + script: + - cd sveltejs + - yarn install + - yarn lint:svelte + ################ # Split tests by test type for parallel running. ################ diff --git a/js/project_browser.admin.js b/js/project_browser.admin.js index 5f74fa82f..937c1b17d 100644 --- a/js/project_browser.admin.js +++ b/js/project_browser.admin.js @@ -7,7 +7,7 @@ * @see core/modules/block/js/block.es6.js */ -(function ($, window, Drupal, once) { +(function enableDisablePlugin($, window, Drupal, once) { /** * Enable/Disable a Plugin in the table via select list. * @@ -20,7 +20,7 @@ * Attaches the tableDrag behavior plugin settings form. */ Drupal.behaviors.projectBrowserPluginSourceDrag = { - attach(context, settings) { + attach(context) { // Only proceed if tableDrag is present and we are on the settings page. if (!Drupal.tableDrag || !Drupal.tableDrag.project_browser) { return; @@ -63,7 +63,10 @@ // absolute minimum available weight. This way we always have an // unused upper and lower bound, which makes manually setting the // weights easier for users who prefer to do it that way. - () => ++weight, + () => { + weight += 1; + return weight; + }, ); } @@ -71,13 +74,13 @@ // Get the tableDrag object. const tableDrag = Drupal.tableDrag.project_browser; // Add a handler for when a row is swapped. - tableDrag.row.prototype.onSwap = function (swappedRow) { + tableDrag.row.prototype.onSwap = function swapHandler() { updateLastPlaced(table, this); }; // Add a handler so when a row is dropped, update fields dropped into // new regions. - tableDrag.onDrop = function () { + tableDrag.onDrop = function dropHandler() { const dragObject = this; const $rowElement = $(dragObject.rowObject.element); const regionRow = $rowElement.prevAll('tr.status-title').get(0); @@ -105,12 +108,12 @@ // Add the behavior to each region select list. $( once('source-status-select', 'select.source-status-select', context), - ).on('change', function (event) { + ).on('change', function addBehaviorOnce() { // Make our new row and select field. const row = $(this).closest('tr'); const select = $(this); - // Find the correct region and insert the row as the last in the - // region. + // Find the correct region and insert the row as the last in the region. + // eslint-disable-next-line new-cap tableDrag.rowObject = new tableDrag.row(row[0]); const regionMessage = table.find(`.status-title-${select[0].value}`); const regionItems = regionMessage.nextUntil('.status-title'); -- GitLab