Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some es lint issues with npx eslint@8 --ext .js --resolve-plugins… #215

Open
wants to merge 10 commits into
base: 2.x
Choose a base branch
from

Conversation

finnlewis
Copy link
Member

@finnlewis finnlewis commented Feb 2, 2025

See #214

Attempting to fix eslint issues with the automated tooling.

@finnlewis
Copy link
Member Author

I'm not sure how to deal with this one:

  152:46  error    Function declared in a loop contains unsafe references to variable(s) 'showHideButton', 'showHideButton'  no-loop-func

Any ideas @millnut / @ekes / @markconroy ?

See: https://github.com/localgovdrupal/localgov_paragraphs/actions/runs/13156346923/job/36714342761?pr=215#step:4:10

Then, the localgov-tabs.js files says it should not be edited directly, so I think we want to remove that file and rename the .es6 file to the .js file.

https://github.com/localgovdrupal/localgov_paragraphs/blob/2.x/modules/localgov_subsites_paragraphs/js/localgov-tabs.es6.js

@finnlewis finnlewis requested a review from rupertj February 6, 2025 09:52
}
}
});
button.addEventListener('click', (e) => doSomething(e));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the anonymous function here, as it's just passing the event through itself to doSomething. So this can be:

button.addEventListener('click', doSomething);

@@ -121,6 +121,44 @@
return -1;
}

function doSomething(e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest showHideButtonClickHandler is a better name than doSomething.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha - yeah, naming things!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the (renamed) showHideButtonClickHandler(e) need the "e" passing in?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it still needs the event as an argument.

@finnlewis
Copy link
Member Author

Just updated the latest commit on the dev branch of office_hours as they addressed the previous phpunit failure.

But now we get this:

1) Drupal\Tests\localgov_subsites_paragraphs\Functional\SubsitesParagraphsAdministrationTest::testSubsiteParagraphsTypes
ParseError: syntax error, unexpected identifier "UNDEFINED", expecting "="

/var/www/html/web/modules/contrib/office_hours/src/Plugin/Field/FieldType/OfficeHoursItem.php:133

From this commit: https://git.drupalcode.org/project/office_hours/-/commit/3e4c1b2bde8e2c463bca8bbc9c1972c8c75392af#c0851fec5de699ae4b1b81b00b8f30af27fe04a6_176_134

@ekes @millnut thoughts?

@millnut
Copy link
Member

millnut commented Feb 11, 2025

Hey @finnlewis the reason 8.1 and 8.2 fail is because office hours is using typed constants which were only introduced in PHP 8.3 and later

e.g.

public const string UPDATE = 'office_hours.update';

for < PHP 8.3 this would work

public const UPDATE = 'office_hours.update';

I've commented on the ticket that introduced this upstream https://www.drupal.org/project/office_hours/issues/3503165

@finnlewis
Copy link
Member Author

Yay! All tests are passing now, thanks @rupertj and @millnut

Might one of you approve this and I will merge and release?

@finnlewis finnlewis requested a review from millnut February 13, 2025 16:21
@@ -16,7 +16,7 @@
"drupal/fontawesome": "^3.0",
"drupal/geolocation": "^3.1",
"drupal/layout_paragraphs": "^2.0",
"drupal/office_hours": "^1.8",
"drupal/office_hours": "1.x-dev#27be616c",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should pin to a dev version, if we can hold this PR for now that would be preferred.

I've been speaking with the maintainer and they've reverted the changes and will be creating a new release soon. Then introducing a follow up release and specifying PHP version requirement as 8.3+ in the composer.json so it won't be pulled down by composer if the requirements do not match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants