简体   繁体   English

禁用特定的 eslint 规则 reactjs

[英]disable specifict eslint rule reactjs

How can I disable the no-unused-vars rule only for the typescript interface?如何仅针对 typescript 接口禁用no-unused-vars规则?

export type IKeoTableColumn<T> = {
  id: T;
  align: 'left' | 'center' | 'right';
  label: string;
  minWidth: number;
  format?: (value: number) => string, <-------- warning here (value: number)
}[];

my eslintrc.json like我的 eslintrc.json 喜欢

--- some code ---
"rules": {
    "no-unused-vars": "warn",
    "@typescript-eslint/no-unused-vars": "off",
}

please help:(请帮忙:(

You can disable the rule using configuration comments :您可以使用配置注释禁用该规则:

/* eslint-disable no-unused-vars */
export type IKeoTableColumn<T> = {
  id: T;
  align: 'left' | 'center' | 'right';
  label: string;
  minWidth: number;
  format?: (value: number) => string;
}[];

If you only want to ignore a code portion just re-enable the rule after that:如果您只想忽略代码部分,只需在之后重新启用规则:

/* eslint-enable no-unused-vars */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM