规则列表
这些 lint 规则由 deno lint
命令提供。
推荐
Fresh
JSX
React
JSR
要求重载签名彼此相邻。详情 about undefined
禁止在没有注释的情况下使用 Typescript 指令。详情 about undefined
禁止使用原始包装对象(例如,
String
对象是string
原始类型的包装器),以及非显式的Function
类型和被误解的Object
类型。详情 about undefined警告在忽略指令中使用未知的规则代码。详情 about undefined
要求
deno-lint-ignore
使用一个或多个规则名称进行注释。详情 about undefined要求 TODO 使用用户标签 (
@user
) 或问题引用 (#issue
) 进行注释。详情 about undefined警告未使用的忽略指令。详情 about undefined
检查
<button>
JSX 元素是否具有有效的type
属性。默认值是"submit"
,这通常不是期望的行为。详情 about undefined强制在变量名中使用驼峰命名法。详情 about undefined
验证构造函数的正确使用以及对
super()
的调用。详情 about undefined强制默认参数在函数签名中排在最后。详情 about undefined
强制使用类型安全的相等运算符
===
和!==
,而不是更容易出错的==
和!=
运算符。详情 about undefined要求所有函数都具有显式的返回类型。详情 about undefined
要求所有模块导出都具有完全类型化的声明。详情 about undefined
要求
for
循环控制变量在正确的方向上递增。详情 about undefined检查命名 fresh 中间件导出的正确性。详情 about undefined
禁止在 fresh 服务端组件中使用事件处理程序。详情 about undefined
要求所有属性 getter 函数都返回一个值。详情 about undefined
要求
for-in
循环包含if
语句。详情 about undefined强制一致的 JSX 布尔值样式。可以将
true
作为布尔值传递,但可以使用简写语法省略。详情 about undefined强制
<button>
元素具有type
属性。如果<button>
放置在<form>
元素内,则默认情况下它将充当提交按钮,这可能是意想不到的。详情 about undefined确保在 JSX 表达式周围一致地使用花括号。详情 about undefined
确保在将可迭代对象传递到 JSX 时存在
key
属性。它允许框架优化检查元素的顺序。详情 about undefined将 children 作为 JSX children 传递,而不是作为属性传递。详情 about undefined
JSX 中的文本节点内的 JavaScript 注释将呈现为纯文本。这通常是意想不到的。详情 about undefined
禁止重复的 JSX props。后面的 props 将始终覆盖前面的 props,这通常会导致意想不到的结果。详情 about undefined
在 JSX 中留下
>
或}
字符通常是不希望的并且难以发现。强制这些字符必须作为字符串传递。详情 about undefinedFragments 仅在 JSX “块”的顶部以及仅当有多个子元素时才是必要的。在其他情况下不需要 Fragments。详情 about undefined
多次 spread 同一个表达式通常是一个错误,并会导致不必要的计算。详情 about undefined
确保 HTML 中的 void 元素没有任何子元素,因为这在 HTML 中是无效的。有关更多信息,请参阅 MDN 上的
Void element
文章。详情 about undefined强制数组构造的常规用法。详情 about undefined
要求不使用异步 promise 执行器函数。详情 about undefined
要求不在 for 循环体中使用
await
。详情 about undefined禁止在非异步函数内部使用
await
关键字。详情 about undefined要求所有使用任意数量的
boolean
字面量作为参数调用的函数都使用自文档化的常量来代替。详情 about undefined要求 switch
case
或default
子句中的词法声明(let
、const
、function
和class
)使用括号进行作用域限定。详情 about undefined禁止修改类声明的变量。详情 about undefined
禁止与负零 (
-0
) 进行比较。详情 about undefined禁止在条件语句中使用赋值运算符
=
。详情 about undefined禁止使用
console
全局对象。详情 about undefined禁止修改声明为
const
的变量。详情 about undefined禁止在条件测试中使用常量表达式。详情 about undefined
禁止在正则表达式中使用 ASCII 控制字符。详情 about undefined
禁止使用
debugger
语句。详情 about undefined禁止删除变量。详情 about undefined
警告已弃用的 - Deno API 的用法。详情 about undefined
禁止在函数签名中多次使用相同的参数名称。详情 about undefined
禁止多次使用相同的类成员函数名称。详情 about undefined
禁止在
if
/else if
语句中两次使用相同的条件。详情 about undefined禁止在对象字面量中使用重复的键。详情 about undefined
禁止在 switch 语句中多次使用相同的 case 子句。详情 about undefined
禁止使用空块语句。详情 about undefined
禁止在正则表达式中使用空字符类。详情 about undefined
禁止声明空枚举。详情 about undefined
禁止声明空接口。详情 about undefined
禁止在解构中使用空模式。详情 about undefined
禁止使用
eval
。详情 about undefined禁止重新分配异常参数。详情 about undefined
禁止使用
any
类型。详情 about undefined禁止使用外部导入。详情 about undefined
禁止不必要的布尔类型转换。详情 about undefined
禁止不必要的非空断言。详情 about undefined
禁止 case 语句的隐式 fallthrough。详情 about undefined
禁止覆盖/重新分配现有函数。详情 about undefined
禁止赋值给原生 Javascript 对象。详情 about undefined
禁止在 ["ambient" 命名空间] 中使用隐式导出。详情 about undefined
禁止为导入属性使用
assert
关键字。详情 about undefined禁止重新分配导入的模块绑定。详情 about undefined
禁止容易推断的类型。详情 about undefined
禁止在嵌套块中定义变量或函数。详情 about undefined
禁止在 RegExp 构造函数中指定无效的正则表达式。详情 about undefined
警告三重斜杠引用指令的错误用法。详情 about undefined
禁止使用非空格或非制表符的空格字符。详情 about undefined
禁止为接口定义
constructor
或为类定义new
。详情 about undefined禁止在 TypeScript 代码中使用
namespace
和module
关键字。详情 about undefined禁止将
new
运算符与内置的Symbol
一起使用。详情 about undefined禁止使用 NodeJS 全局对象。详情 about undefined
禁止在可选链表达式后使用非空断言。详情 about undefined
禁止使用
!
后缀运算符进行非空断言。详情 about undefined禁止像函数一样调用内置的全局对象。详情 about undefined
禁止通过以
0
开头的数字字面量来表达八进制数字。详情 about undefined禁止使用 NodeJS
process
全局对象。详情 about undefined禁止直接使用
Object.prototype
内置函数。详情 about undefined禁止使用相同的名称重新声明变量、函数、参数。详情 about undefined
禁止在正则表达式字面量中使用多个空格。详情 about undefined
禁止自我赋值。详情 about undefined
禁止比较双方完全相同的情况。详情 about undefined
禁止从 setter 返回值。详情 about undefined
禁止遮蔽受限名称。详情 about undefined
强制在模块说明符中指定对路径的显式引用。详情 about undefined
强制使用显式或可以简单推断的类型。详情 about undefined
禁止稀疏数组。详情 about undefined
禁止在异步函数内部使用同步函数。详情 about undefined
禁止将变量赋值给
this
。详情 about undefined禁止在构造函数中调用
super()
之前使用this
或super
。详情 about undefined禁止抛出字面量作为异常。详情 about undefined
禁止使用顶层 await 表达式。详情 about undefined
禁止使用未声明的变量。详情 about undefined
禁止控制流语句之后无法访问的代码。详情 about undefined
禁止在
finally
块中使用控制流语句。详情 about undefined禁止将否定运算符
!
用作关系运算符的左操作数。详情 about undefined禁止未使用的标签。详情 about undefined
强制所有变量至少使用一次。详情 about undefined
禁止无用的重命名操作,其中原始名称和新名称完全相同。这通常是重构过程的残留,可以安全地删除。详情 about undefined
强制使用块作用域变量而不是更容易出错的函数作用域变量。块作用域变量使用
const
和let
关键字定义。详情 about undefined禁止使用
window
对象。详情 about undefined禁止通过
window
对象使用 Web API。详情 about undefined禁止使用
with
语句。详情 about undefined建议使用 const 断言 (
as const
) 而不是显式指定字面量类型或使用类型断言。详情 about undefined确保代码完全以 ASCII 字符编写。详情 about undefined
建议使用 [
const
] 而不是 [let
] 声明变量。详情 about undefined建议在声明 TypeScript 模块时使用
namespace
关键字而不是module
关键字。详情 about undefined建议使用来自
primordials
的冻结内部函数而不是默认的全局函数。详情 about undefined防止使用
dangerouslySetInnerHTML
,如果使用不当,可能会导致 XSS 漏洞。详情 about undefined将 JSX children 与
dangerouslySetInnerHTML
一起使用是无效的,因为它们将被忽略。详情 about undefined确保在 React/Preact 组件中正确调用 hooks。它们必须在组件的顶层调用,而不是在条件语句或循环内部调用。详情 about undefined
禁止没有 await 表达式或 await using 声明的异步函数。详情 about undefined
禁止没有
yield
的生成器函数。详情 about undefined禁止在同一声明语句中进行多个变量定义。详情 about undefined
禁止使用某些三重斜杠指令,而推荐使用 ES6 样式的导入声明。详情 about undefined
禁止与
NaN
进行比较。详情 about undefined将
typeof
运算符的使用限制为一组特定的字符串字面量。详情 about undefined强制类型导入声明为类型导入。详情 about undefined