List of rules
These lint rules are provided by the deno lint
command. You can enable sets of rules in deno.json(c)
by adding their tags (e.g. recommended
, react
) to the lint.rules.tags
array.
If no tag is provided, then the recommended
set of rules will be enabled by default.
Recommended
Fresh
JSX
React
JSR
要求重载签名必须相邻。 Details about undefined
不允许在没有注释的情况下使用 Typescript 指令。 Details about undefined
禁止使用原始包装对象(例如
String
这个对象是string
原始类型的包装),以及不明确的Function
类型和误解的Object
类型。 Details about undefined警告在忽略指令中使用未知规则代码。 Details about undefined
需要将
deno-lint-ignore
注解与一个或多个规则名称。 Details about undefined要求 TODO 注释必须带有用户标签(
@user
)或问题引用(#issue
)。 Details about undefined警告未使用的忽略指令。 Details about undefined
检查
<button>
JSX 元素是否具有有效的type
属性。默认值是"submit"
,这通常不是所期望的行为。 Details about undefined强制在变量名中使用 camelCase。 Details about undefined
验证构造函数和
super()
调用的正确使用。 Details about undefined强制默认参数在函数签名中位于最后。 Details about undefined
强制使用类型安全的相等运算符
===
和!==
代替更容易出错的==
和!=
运算符。 Details about undefined要求所有函数都有明确的返回类型。 Details about undefined
要求所有模块导出具备完全类型声明。 Details about undefined
需要
for
循环控制变量以正确的方向递增。 Details about undefined检查命名是否正确,适用于命名的 fresh 中间件导出。 Details about undefined
不允许在 fresh 服务器组件中使用事件处理程序。 Details about undefined
要求所有属性获取器函数返回一个值。 Details about undefined
要求
for-in
循环包含if
语句。 Details about undefined强制一致的 JSX 布尔值样式。传递
true
作为布尔值可以使用简写语法省略。 Details about undefinedEnforce
<button>
elements to have atype
attribute. If a<button>
is placed inside a<form>
element it will act as a submit button by default which can be unexpected. Details about undefined确保在 JSX 表达式周围一致使用花括号。 Details about undefined
确保在将可迭代对象传递给 JSX 时存在
key
属性。这允许框架优化元素顺序的检查。 Details about undefined将子元素作为 JSX 子元素传递,而不是作为属性。 Details about undefined
JavaScript comments inside text nodes are rendered as plain text in JSX. This is often unexpected. Details about undefined
不允许重复的 JSX 属性。后面的属性将始终覆盖前面的属性,这常常会导致意想不到的结果。 Details about undefined
Leaving the
>
or}
character in JSX is often undesired and difficult to spot. Enforce that these characters must be passed as strings. Details about undefined片段仅在 JSX "块" 的顶部是必要的,并且仅在有多个子元素时需要。在其他情况下不需要片段。 Details about undefined
重复同样的表达式通常是一个错误,并且会导致不必要的计算。 Details about undefined
确保 HTML 中的空元素没有任何子元素,因为这不是有效的 HTML。有关更多信息,请参阅
空元素
文章在 MDN。 Details about undefined强制执行数组构造的常规用法。 Details about undefined
要求不使用 async promise 执行器函数。 Details about undefined
在 for 循环体中未使用
await
。 Details about undefined禁止在非异步函数中使用
await
关键字。 Details about undefined要求所有函数在调用时,无论参数数量为多少,都使用自文档常量代替
boolean
字面量作为参数。 Details about undefined在
case
或default
子句中要求使用大括号来限制let
、const
、function
和class
的作用域。 Details about undefined不允许修改类声明的变量。 Details about undefined
不允许与负零(
-0
)进行比较。 Details about undefined禁止在条件语句中使用赋值操作符
=
。 Details about undefined不允许使用
console
全局对象。 Details about undefined禁止修改声明为
const
的变量。 Details about undefined不允许在条件测试中使用常量表达式。 Details about undefined
不允许在正则表达式中使用 ASCII 控制字符。 Details about undefined
禁止使用
debugger
语句。 Details about undefined不允许删除变量。 Details about undefined
警告使用已弃用的 - Deno APIs。 Details about undefined
不允许在函数签名中多次使用相同的参数名称。 Details about undefined
不允许在类中一个成员函数名使用多次。 Details about undefined
不允许在
if
/else if
语句中重复使用相同的条件。 Details about undefined不允许在对象字面量中使用重复的键。 Details about undefined
不允许在
switch
语句中重复使用相同的 case 子句。 Details about undefined禁止使用空的块语句。 Details about undefined
不允许在正则表达式中使用空字符类。 Details about undefined
不允许声明空枚举。 Details about undefined
不允许声明空接口。 Details about undefined
禁止在解构中使用空模式。 Details about undefined
不允许使用
eval
。 Details about undefined不允许重新赋值异常参数。 Details about undefined
禁止使用
any
类型。 Details about undefined禁止使用外部导入。 Details about undefined
禁止不必要的布尔类型强制转换。 Details about undefined
禁止不必要的非空断言。 Details about undefined
不允许隐式穿透 case 语句。 Details about undefined
不允许重写/重新赋值已有函数。 Details about undefined
禁止对原生 Javascript 对象进行赋值。 Details about undefined
禁止在 ["环境" 命名空间] 中使用隐式导出。 Details about undefined
不允许在导入属性中使用
assert
关键字。 Details about undefined禁止重新分配导入模块绑定。 Details about undefined
禁止容易推断的类型。 Details about undefined
不允许在嵌套块中定义变量或函数。 Details about undefined
不允许在 RegExp 构造函数中指定无效的正则表达式。 Details about undefined
警告三斜杠引用指令的错误用法。 Details about undefined
不允许使用非空格或非制表符的空白字符。 Details about undefined
禁止为接口定义
constructor
或为类定义new
Details about undefined不允许在 TypeScript 代码中使用
namespace
和module
关键字。 Details about undefined禁止使用
new
操作符与内置的Symbol
。 Details about undefined禁止使用 NodeJS 全局对象。 Details about undefined
禁止在可选链表达式后使用非空断言。 Details about undefined
禁止使用
!
后缀运算符进行非空断言。 Details about undefined禁止像函数一样调用内置全局对象。 Details about undefined
禁止使用以
0
开头的数字文字表达八进制数。 Details about undefined禁止使用 NodeJS 的
process
全局变量。 Details about undefined不允许直接使用
Object.prototype
的内置方法。 Details about undefined不允许重新声明具有相同名称的变量、函数和参数。 Details about undefined
禁止在正则表达式字面量中使用多个空格。 Details about undefined
禁止自我赋值。 Details about undefined
禁止比较两个完全相同的值或变量。 Details about undefined
不允许从设置器返回值。 Details about undefined
禁止对受限名称的遮蔽。 Details about undefined
强制在模块说明符中指定显式路径引用。 Details about undefined
强制使用明确或可以简单推断的类型。 Details about undefined
不允许稀疏数组。 Details about undefined
不允许在异步函数内部使用同步函数。 Details about undefined
不允许将变量赋值给
this
。 Details about undefined不允许在构造函数中调用
super()
前使用this
或super
。 Details about undefined禁止将文字量作为异常抛出。 Details about undefined
不允许使用顶级 await 表达式。 Details about undefined
不允许使用未声明的变量。 Details about undefined
禁止在控制流语句之后写无法到达的代码。 Details about undefined
不允许在
finally
块中使用控制流语句。 Details about undefined禁止将否定运算符
!
作为关系运算符的左操作数。 Details about undefined禁止未使用的标签。 Details about undefined
强制所有变量至少被使用一次。 Details about undefined
禁止无用的重命名操作,当原始名称和新名称完全相同时。这通常是重构过程中留下的,可以安全地删除。 Details about undefined
强制使用块作用域变量,而不是更容易出错的函数作用域变量。块作用域变量使用
const
和let
关键字定义。 Details about undefined不允许使用
window
对象。 Details about undefined禁止通过
window
对象使用 Web APIs。 Details about undefined不允许使用
with
语句。 Details about undefined推荐使用常量断言(
as const
)而不是显式指定字面量类型或使用类型断言。 Details about undefined确保代码完全使用 ASCII 字符编写。 Details about undefined
建议使用 [
const
] 声明变量,而不是 [let
]。 Details about undefined建议在声明 TypeScript 模块时使用
namespace
关键字而不是module
关键字。 Details about undefined建议使用来自
primordials
的冻结原语,而不是默认的全局对象。 Details about undefined防止使用
dangerouslySetInnerHTML
,如果使用不当可能导致 XSS 漏洞。 Details about undefined使用 JSX 子元素与
dangerouslySetInnerHTML
一起是无效的,因为它们将被忽略。 Details about undefinedEnsure that hooks are called correctly in React/Preact components. They must be called at the top level of a component and not inside a conditional statement or a loop. Details about undefined
不允许没有 await 表达式或 await 使用声明的异步函数。 Details about undefined
不允许没有
yield
的生成器函数。 Details about undefined不允许在同一声明语句中定义多个变量。 Details about undefined
禁止使用某些三斜杠指令,优先使用 ES6 风格导入声明。 Details about undefined
不允许与
NaN
进行比较。 Details about undefined将
typeof
运算符的使用限制为一组特定的字符串字面量。 Details about undefined强制类型导入声明为类型导入。 Details about undefined