JS closure results in "Unexpected unnamed function" warning from eslint

Created on 22 January 2018, over 6 years ago
Updated 18 February 2023, over 1 year ago

I was attempting to use the core .eslintrc.json to lint the JS of a project I'm on and ran into what I believe is a bug or at least a conflict with the documented coding standards.

It seems the closure/wrapper required in the JS coding standards handbook page β†’ (and found in every core es6.js file I've seen) causes this eslint warning:

warning Unexpected unnamed function func-names

In a local project file I was able to do the following to get around it:

Old:

(function (Drupal, bar) {
...
}(Drupal, window.foo));

New:

((Drupal, bar) => {
...
})(Drupal, window.foo);

I'm not certain that approach would work throughout core, but I wanted to at least present the idea as a potential way forward here.

πŸ“Œ Task
Status

Closed: won't fix

Version

10.1 ✨

Component
JavascriptΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡ΊπŸ‡ΈUnited States chrisolof

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024