
亮点
🌐 Highlights
SourceCode 中对令牌和注释的支持
🌐 Support for tokens and comments in SourceCode
规则作者经常会使用 ESLint 的 SourceCode 对象,它表示正在被 lint 的 JavaScript 源代码。它的 getText()、getLoc() 和 getRange() 方法一直都接受节点、标记或注释,但文档没有描述所有的参数类型,而且类型定义会拒绝一些有效的调用,例如传入一个注释。
🌐 Rule authors often work with ESLint’s SourceCode object, which represents the JavaScript source code being linted. Its getText(), getLoc(), and getRange() methods have always accepted a node, token, or comment, but the documentation didn’t describe every argument type, and the type definitions rejected some valid calls, such as passing a comment.
这个版本更新了文档和类型定义,以匹配实际行为。这也让这些方法与语言插件中使用的核心 SourceCodeBase 接口的实现保持一致。调用这些方法的代码不会受影响,但实现或模拟 SourceCode 的 TypeScript 代码可能需要更新 getText()、getLoc() 和 getRange() 的签名,以接受 tokens 和 comments。
🌐 This release updates the documentation and type definitions to match the actual behavior. This also aligns these methods with implementations of the core SourceCodeBase interface used in language plugins. Code that calls these methods is unaffected, but TypeScript code that implements or mocks SourceCode may need its getText(), getLoc(), and getRange() signatures updated to accept tokens and comments.
规则修复
🌐 Rule fixes
以下规则已更新,以便在某些边缘情况下正确工作,包括自动修复行为和代码中补充Unicode字符的处理:
🌐 The following rules have been updated to work correctly in certain edge cases, including autofix behavior and the handling of supplementary Unicode characters in code:
consistent-returnmax-lines-per-functionnew-capno-evalno-invalid-thisno-loss-of-precisionprefer-arrow-callbackprefer-exponentiation-operator
特性
🌐 Features
4618052功能:在new-cap中处理天文字符 (#21357) (sary)4ec5168功能:允许SourceCode#getText()接受令牌和评论 (#21340) (electrohyun)
错误修复
🌐 Bug Fixes
bc51eee修复:prefer-arrow-callback在条件测试中的误报 (#21373) (Daniel Pinto)bbff86c修复:在max-lines-per-function中跳过有多个注释的行 (#21332) (xbinaryx)efc4d6b修复:consistent-return、no-eval、no-invalid-this中的天体字母 (#21360) (lumir)93de066修复: prefer-exponentiation-operator 自动修复异步函数基 (#21322) (Vladimir Babin)02e34ff修复:在curly的else后添加缺失的空格 自动修复 (#21355) (Pixel)b14b8bc修复:纠正id-length对长私有名称的消息 (#21348)(Pixel)69aac01修复:在getFunctionHeadLoc中支持TSFunctionType(#21335) (xbinaryx)686630e修复:no-loss-of-precision与0.e5的误报 (#21337) (sethamus)
文档
🌐 Documentation
67eb586文档:更新自述文件(GitHub Actions 机器人)5370d7e文档:澄清one-varseparateRequires匹配任何require()调用 (#21192) (sethamus)8816c1d文档:更新自述文件(GitHub Actions 机器人)3d2e7ce文档:修复 no-unused-expressions 文档中的拼写错误 (#21346) (bytedoe)
杂项
🌐 Chores
152067f杂务:更新生态系统插件 (#21362) (ESLint 机器人)b56d58e事务: 将 github/codeql-action 操作更新至 v4.38.2 (#21376) (renovate[bot])bfaea12性能:针对每个 languageOptions 缓存规范化的配置全局变量 (#21364) (James Ross)322209eci:在生态系统测试中避免 Nx 缓存并禁用失败的测试(#21369)(Francesco Trotta)d166567事务: 将依赖 prettier 更新到 v3.9.9 (#21371) (renovate[bot])29585ce任务:将依赖 eslint-plugin-expect-type 更新到 ^0.7.0 (#21359) (renovate[bot])39d79ba事务: 将 github/codeql-action 操作更新至 v4.38.1 (#21354) (renovate[bot])182a6e9事务: 将依赖 prettier 更新到 v3.9.8 (#21352) (renovate[bot])f995127任务: 删除 CLAUDE.md,改用 AGENTS.md (#21339) (Jarren)b95fb6c事务: 将依赖 prettier 更新到 v3.9.7 (#21347) (renovate[bot])3782dd4杂务:更新生态系统插件 (#21342) (ESLint 机器人)
