Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 2 months ago

#64562 closed defect (bug) (fixed)

JSHint: Bump esversion to 11 (ES2020)

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 7.0 Priority: normal
Severity: normal Version: 6.9
Component: Build/Test Tools Keywords:
Focuses: javascript, coding-standards Cc:

Description (last modified by westonruter)

In #63077, the .jshintrc had its esversion (docs) bumped from 6 to 10. This enabled the use of async functions. However, there is also 11 (ES2020) which includes features like:

These features are already being used in WordPress core for code pulled in from Gutenberg, as seen here: https://github.com/search?q=repo%3AWordPress%2FWordPress+%2F%5Cw%2B%5C%3F%5C.%5Cw%2B%7C%5C%3F%5C%3F%2F+language%3AJavaScript&type=code

These features were all introduced in 2020. They are supported by the browsers that WordPress supports.

It's time to update .jshintrc to recognize that the these JavaScript language features are blessed for usage.

Change History (7)

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


3 months ago
#1

  • Keywords has-patch added

#2 @westonruter
3 months ago

  • Keywords has-patch removed
  • Owner set to westonruter
  • Status changed from new to accepted

#3 @westonruter
3 months ago

  • Summary changed from JSHint: Bump esversion to 11 (es2020) to JSHint: Bump esversion to 11 (ES2020)

#5 @westonruter
3 months ago

  • Description modified (diff)

#6 @westonruter
3 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

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.

#7 @westonruter
2 months ago

In 61611:

Code Editor: Switch from Esprima to Espree for JavaScript linting in CodeMirror.

Esprima is no longer maintained, and it does not support the latest JavaScript features in ES11, as Espree does.

  • New Linter Integration: Introduces src/js/_enqueues/vendor/codemirror/javascript-lint.js using espree for parsing and error reporting, replacing the dependency on jshint and esprima scripts.
  • Script Modules: Registers espree as a script module and leverages the module_dependencies argument in wp_register_script() to ensure espree is available as a dynamic import.
  • Editor Settings: Updates wp_get_code_editor_settings() to use ES11 (ECMAScript 2020) defaults and synchronizes JSHint settings from .jshintrc for compatibility.
  • Editable Extensions: Adds .mjs to the list of editable file extensions for plugins and themes.
  • Deprecations: Marks esprima and jshint script handles as deprecated.
  • Build Tools: Updates Webpack configuration to bundle espree as a module and use the new local javascript-lint.js.

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

Follow-up to [61587], [61544], [61539], [42547].

Props westonruter, jonsurrell.
See #64562, #61500, #48456, #42850.
Fixes #64558.

Note: See TracTickets for help on using tickets.