New Nov 29, 2024

ESLint v9.16.0 released

Libraries, Frameworks, etc. All from ESLint Blog View ESLint v9.16.0 released on eslint.org

Highlights

ignoreComputedKeys option for sort-keys

This release adds a new boolean option ignoreComputedKeys to the sort-keys rule. ignoreComputedKeys allows a more consistent sorting of properties with non-computed names by treating computed keys as group separators rather than part of a group. The following example shows the expected sorting of properties in an object literal without the ignoreComputedKeys option.

with ignoreComputedKeys: false (default)

const obj = { a: 10, b: 20, [c]: 7.5, d: 15 };

When ignoreComputedKeys is set to true, the computed key c can appear anywhere in the literal, as long as the other groups of properties are sorted.

with ignoreComputedKeys: true

const obj = { a: 10, b: 20, [c]: 7.5, d: 15 };

or

const obj = { d: 15, [c]: 7.5, a: 10, b: 20 };

or

const obj = { a: 10, b: 20, d: 15, [c]: 7.5 };

etc.

Language-agnostic no-restricted-syntax

Another enhancement in this release is the ability to use the no-restricted-syntax rule with any language. This was already possible in previous releases, but now usage with language plugins is officially supported and documented.

When linting JSON files with the @eslint/json plugin, a config that warns about the usage of null could look like this:

import json from "@eslint/json";

export default [
{
files: ["**/*.json"],
language: "json/json",
plugins: {
json,
},
rules: {
"no-restricted-syntax": [
"warn",
"Null" // AST selector for `null`
],
},
},
];

If you would like to restrict syntax in your project based on AST selectors but you’re unsure what nodes represent a particular code, we recommend using Code Explorer.

Features

Documentation

Chores

Scroll to top