
Highlights
In ESLint v9.25.0, as part of adding support for TypeScript syntax in the no-unused-expressions
rule, we introduced a change in how this rule detects directives (for example, "use strict"
). This change revealed false negatives this rule had: when linting with ecmaVersion: 3
, statements that are directives in ES5+ should be reported by this rule, because ES3 environments do not support directives, so they are effectively unused.
While the v9.25.0 behavior of this rule is correct, it turned out that this change impacts projects that publish the same code with directives for both ES3 and ES5+ environments (issue #19637). In order to support this use case, the way the no-unused-expressions
rule detects directives has been reverted in v9.25.1. The change will be reintroduced in v9.26.0, and the default behavior of the no-unused-expressions
rule will be the same as in v9.25.0, but the rule will have an option to ignore directives even with ecmaVersion: 3
.
Bug Fixes
cdc8e8c
fix: revert directive detection in no-unused-expressions (#19639) (sethamus)