oxc/no-const-enum Restriction
作用
禁止 TypeScript const enum
为什么这很糟糕?
const enum 是应该在使用位置内联的枚举。 打包工具不支持 const enum,并且与 isolatedModules 模式不兼容。 使用它们可能会导致导入不存在的值(因为 const enum 会被擦除)。
示例
以下是此规则的错误代码示例:
ts
const enum Color {
Red,
Green,
Blue,
}如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"oxc/no-const-enum": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"oxc/no-const-enum": "error",
},
});bash
oxlint --deny oxc/no-const-enum版本
此规则于 v0.4.2 中添加。
