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
9eefc8f
docs: fix typos inuse-isnan
(#19190) (루밀LuMir)0c8cea8
docs: switch the order of words inno-unreachable
(#19189) (루밀LuMir)0c19417
docs: add missing backtick tono-async-promise-executor
(#19188) (루밀LuMir)8df9276
docs: add backtick in-0
indescription
ofno-compare-neg-zero
(#19186) (루밀LuMir)7e16e3f
docs: fixcaseSensitive
option’s title ofsort-keys
(#19183) (Tanuj Kanti)0c6b842
docs: fix typos inmigration-guide.md
(#19180) (루밀LuMir)353266e
docs: fix a typo indebug.md
(#19179) (루밀LuMir)5ff318a
docs: delete unnecessary horizontal rule(---
) innodejs-api
(#19175) (루밀LuMir)576bcc5
docs: mark more rules as handled by TypeScript (#19164) (Tanuj Kanti)742d054
docs: note thatno-restricted-syntax
can be used with any language (#19148) (Milos Djermanovic)
Chores
feb703b
chore: upgrade to@eslint/js@9.16.0
(#19195) (Francesco Trotta)df9bf95
chore: package.json update for @eslint/js release (Jenkins)f831893
chore: add type forignoreComputedKeys
option ofsort-keys
(#19184) (Tanuj Kanti)3afb8a1
chore: update dependency @eslint/json to ^0.8.0 (#19177) (Milos Djermanovic)1f77c53
chore: addrepository.directory
property topackage.json
(#19165) (루밀LuMir)d460594
chore: update dependency @arethetypeswrong/cli to ^0.17.0 (#19147) (renovate[bot])45cd4ea
refactor: update default options in rules (#19136) (Milos Djermanovic)