diff --git a/src/content/blog/2025-01-10-eslint-v9.18.0-released.md b/src/content/blog/2025-01-10-eslint-v9.18.0-released.md index 2a0869aae..dd1ef5188 100644 --- a/src/content/blog/2025-01-10-eslint-v9.18.0-released.md +++ b/src/content/blog/2025-01-10-eslint-v9.18.0-released.md @@ -3,9 +3,8 @@ layout: post title: ESLint v9.18.0 released teaser: "We just pushed ESLint v9.18.0, which is a minor release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release." image: release-notes-minor.png -draft: true authors: - - eslintbot + - fasttime categories: - Release Notes tags: @@ -17,6 +16,59 @@ tags: +## Highlights + +### Stable TypeScript configuration file support + +In August of the previous year, ESLint launched support for TypeScript configuration files as an experimental feature. +In order to use a TypeScript configuration file like `eslint.config.ts`, users had to specify the `unstable_ts_config` flag in the command line, e.g. + +```shell +npx eslint --flag unstable_ts_config +``` + +Following an experimental period of several months, during which there were no specific complaints and only minor adjustments, we have made the decision to officially implement support for TypeScript configuration files as a stable feature. +Starting with ESLint v9.18.0, TypeScript configuration files with extensions `.ts`, `.mts` and `.cts` can be used like regular JavaScript configuration files. +If you are upgrading from a previous version of ESLint, be sure to remove the `unstable_ts_config` flag from the command. + +Note that in order to use a TypeScript configuration file in Node.js, you still need to have [jiti](https://www.npmjs.com/package/jiti) installed in version 2.0 or higher. +For Deno and Bun, no additional dependency is necessary. +See the documentation about [TypeScript Configuration Files](https://eslint.org/docs/head/use/configure/configuration-files#typescript-configuration-files) for more information about this feature. + +### `no-shadow-restricted-names` checks imports and class names + +The [`no-shadow-restricted-names`](https://eslint.org/docs/latest/rules/no-shadow-restricted-names) rule will now check for restricted names also in import declarations and in class names, for example: + +```js +import undefined from "foo"; + +class NaN {} +``` + +[**Playground Link**](https://eslint.org/play/#eyJ0ZXh0IjoiLyplc2xpbnQgbm8tc2hhZG93LXJlc3RyaWN0ZWQtbmFtZXM6IFwiZXJyb3JcIiovXG5cbmltcG9ydCB1bmRlZmluZWQgZnJvbSBcImZvb1wiO1xuXG5jbGFzcyBOYU4ge30iLCJvcHRpb25zIjp7InJ1bGVzIjp7fSwibGFuZ3VhZ2VPcHRpb25zIjp7InBhcnNlck9wdGlvbnMiOnsiZWNtYUZlYXR1cmVzIjp7fX19fX0=) + +This rule was added in ESLint v0.1.4 to report on variables and functions with names that could be confusing to developers like `NaN` or `undefined`. +As JavaScript evolved, new syntactic constructs were introduced that could accept the same problematic names. +These newer cases are now detected and reported by the rule. + +### Allowed method names in `no-config` problems + +The [`no-console-rule`](https://eslint.org/docs/latest/rules/no-console) has been updated to indicate the name of methods that are explicitly configured as allowed when reporting a problem. +This can help developers to find an acceptable alternative to problem reported by this rule. + +Consider the following case where `no-console` is configured to allow only the `warn` and `error` methods. + +```js +/* eslint no-console: ["error", { allow: ["warn", "error"] }] */ + +console.log("Some text."); +``` + +Previously, the rule would report a problem with the generic message "Unexpected console statement." +In ESLint v9.18.0, the message reads "Unexpected console statement. Only these console methods are allowed: warn, error." + +[**Playground Link**](https://eslint.org/play/#eyJ0ZXh0IjoiLyogZXNsaW50IG5vLWNvbnNvbGU6IFtcImVycm9yXCIsIHsgYWxsb3c6IFtcIndhcm5cIiwgXCJlcnJvclwiXSB9XSAqL1xuXG5jb25zb2xlLmxvZyhcIlNvbWUgdGV4dC5cIik7Iiwib3B0aW9ucyI6eyJydWxlcyI6e30sImxhbmd1YWdlT3B0aW9ucyI6eyJzb3VyY2VUeXBlIjoibW9kdWxlIiwicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9fX19fQ==) + ## Features