Make WordPress Core

Opened 18 months ago

Closed 18 months ago

Last modified 8 months ago

#63077 closed defect (bug) (fixed)

JSHint config still requires esversion 6 which blocks use of async functions

Reported by: westonruter Owned by: westonruter
Priority: normal Milestone: 6.9
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch
Cc: Focuses: javascript

Description

In a PR which includes an async function, there is a JS coding standards check failure:

     34 |    const setTemporaryViewTransitionNames = async ( entries, vtPromise ) => {
                                                     ^ 'async functions' is only available in ES8 (use 'esversion: 8').

Back in #58472 I had previously tried to use async functions but ultimately at that time I refactored to use promises to unblock it it.

I think it's time to revisit the JSHint configuration to bump the esversion to 8 or higher in core. ES8 includes async functions which caniuse reports as being supported by 97% of users, where only IE11 doesn't support them. Async functions are also being used in Gutenberg packages which are not transpiled to ES5 to use Promises (example).

Change History (6)

#1 @westonruter
18 months ago

  • Type enhancementdefect (bug)

This ticket was mentioned in PR #8472 on WordPress/wordpress-develop by @westonruter.


18 months ago
#2

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/63077

This bumps the esversion config in .jshintrc to version 10. This includes support for the following features:

7 - To enable language features introduced by ECMAScript 7. Notable additions: the exponentiation operator.
8 - To enable language features introduced by ECMAScript 8. Notable additions: async functions, shared memory, and atomics
9 - To enable language features introduced by ECMAScript 9. Notable additions: asynchronous iteration, rest/spread properties, and various RegExp extensions
10 - To enable language features introduced by ECMAScript 10. Notable additions: optional catch bindings.

Note that for ES10 the notable addition is optional catch bindings. According to caniuse, this is supported by >95% of users globally. The feature was implemented in Chrome 66, Safari 11.1, and Firefox 58--all of which were released in 2018.

#3 @westonruter
18 months ago

  • Owner set to westonruter
  • Status newaccepted

#5 @westonruter
18 months ago

  • Resolutionfixed
  • Status acceptedclosed

In 59963:

Bump esversion from 6 to 10 in JSHint config.

The current esversion 6 corresponds to an ECMAScript version from a decade ago (2015). Updating from 6 to 10 allows the following features to be used in Core JS: the exponentiation operator, async functions, shared memory, atomics, asynchronous iteration, rest/spread properties, various RegExp extensions, and optional catch bindings. These features have been supported by all browsers (except for IE11) well beyond WordPress's browser support policy. This also brings Core's allowed ES version closer in line with Gutenberg which is currently using features like async functions.

Props westonruter, swissspidy, mukesh27.
Fixes #63077.

#6 @westonruter
8 months ago

In 61544:

Build/Test Tools: Bump esversion from 10 to 11 in JSHint config.

This updates the core configuration to allow JS language features which area already shipping in core via Gutenberg packages. Obsolete /* jshint esversion: 6 */ comments are also removed from JS files.

Developed in https://github.com/WordPress/wordpress-develop/pull/10808

Follow-up to [59963].

Props westonruter, jonsurrell, mukesh27.
See #63077.
Fixes #64562.

Note: See TracTickets for help on using tickets.