
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
9eefc8fdocs: fix typos inuse-isnan(#19190) (루밀LuMir)0c8cea8docs: switch the order of words inno-unreachable(#19189) (루밀LuMir)0c19417docs: add missing backtick tono-async-promise-executor(#19188) (루밀LuMir)8df9276docs: add backtick in-0indescriptionofno-compare-neg-zero(#19186) (루밀LuMir)7e16e3fdocs: fixcaseSensitiveoption’s title ofsort-keys(#19183) (Tanuj Kanti)0c6b842docs: fix typos inmigration-guide.md(#19180) (루밀LuMir)353266edocs: fix a typo indebug.md(#19179) (루밀LuMir)5ff318adocs: delete unnecessary horizontal rule(---) innodejs-api(#19175) (루밀LuMir)576bcc5docs: mark more rules as handled by TypeScript (#19164) (Tanuj Kanti)742d054docs: note thatno-restricted-syntaxcan be used with any language (#19148) (Milos Djermanovic)
Chores
feb703bchore: upgrade to@eslint/js@9.16.0(#19195) (Francesco Trotta)df9bf95chore: package.json update for @eslint/js release (Jenkins)f831893chore: add type forignoreComputedKeysoption ofsort-keys(#19184) (Tanuj Kanti)3afb8a1chore: update dependency @eslint/json to ^0.8.0 (#19177) (Milos Djermanovic)1f77c53chore: addrepository.directoryproperty topackage.json(#19165) (루밀LuMir)d460594chore: update dependency @arethetypeswrong/cli to ^0.17.0 (#19147) (renovate[bot])45cd4earefactor: update default options in rules (#19136) (Milos Djermanovic)
