文档管理中心

@typescript-eslint/init-declarations

禁止或者要求在变量声明中进行初始化。

规则配置

收起
自动换行
深色代码主题
复制
  1. // code-linter.json5
  2. {
  3. "rules": {
  4. "@typescript-eslint/init-declarations": "error"
  5. }
  6. }

正例

收起
自动换行
深色代码主题
复制
  1. // 默认变量必须在声明时初始化
  2. export function foo() {
  3. console.info('hello');
  4. }
  5. export const bar = 1;
  6. export const qux = 3;

反例

收起
自动换行
深色代码主题
复制
  1. // 默认变量必须在声明时初始化
  2. export function foo() {
  3. console.info('hello');
  4. }
  5. export let bar: string;
  6. export let qux: number;

规则集

收起
自动换行
深色代码主题
复制
  1. plugin:@typescript-eslint/all

Code Linter代码检查规则的配置指导请参考Code Linter代码检查

在 指南 中进行搜索
请输入您想要搜索的关键词