Formatter Breaking Change

In the next minor release of ESLint (which will be 0.7.1 due to us incorrectly pushing 0.6.2 as 0.7.0 last month), there will be a breaking change to the way formatters operate.

What’s Changing

Up until this point, formatters were passed a config object that contained the calculated severity for each rule (error or warning) so that this information could be output. With 0.7.1, the severity will now be represented on each message itself as a severity property. All of the built-in formatters have been updated to reflect this change.

Why Change?

There were several bugs related to rules being output with the incorrect severity. The most recent was #983, which led to the discovery that the config object being passed around didn’t take into account inline rule severity changes. #985 implemented a change that placed the severity of the message directly onto the message object, meaning the config object was no longer necessary.

The original plan was to deprecate the usage of the config object in formatters for 0.7.1 and remove it in 0.8.0. However, a major refactoring (#1013) led to a separation of responsibilities that made keeping this functionality as-is extremely difficult.

What You Have To Do

If you have written a custom formatter for ESLint, then you’ll need to change it to reflect this change. Previously, you may have been calculating severity like this:

var severity = config.rules[message.ruleId][0] || config.rules[message.ruleId];

To work with 0.7.1, you’ll have to use the severity on the message itself:

var severity = message.severity;

If you want your formatter to work with both old and new versions of ESLint, then you’ll need to combine these ways of calculating severity, such as:

var severity = "severity" in message ? message.severity :
(config.rules[message.ruleId][0] || config.rules[message.ruleId]);

Known Affected Modules

The following is a list of modules available on npm that are affected by this change:

Note that this list is not exhaustive. You should check any non-bundled ESLint formatters you may be using for compatibility.

Questions?

If you have further questions about this change, Open a discussion or stop by our Discord server.

The latest ESLint news, case studies, tutorials, and resources.

ESLint v9.0.0-rc.0 released
2 min read

ESLint v9.0.0-rc.0 released

We just pushed ESLint v9.0.0-rc.0, which is a major release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release. This release also has some breaking changes, so please read the following closely.

ESLint v9.0.0-beta.2 released
2 min read

ESLint v9.0.0-beta.2 released

We just pushed ESLint v9.0.0-beta.2, which is a major release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release. This release also has some breaking changes, so please read the following closely.

ESLint v9.0.0-beta.1 released
1 min read

ESLint v9.0.0-beta.1 released

We just pushed ESLint v9.0.0-beta.1, which is a minor release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release.