【Eslint】eslint 单文件取消特定规则效验

报错示例

【Eslint】eslint 单文件取消特定规则效验_第1张图片

  • 最后的import/no-mutable-exportsno-var 表示效验规则
  169:8  warning  Exporting mutable 'var' binding, use 'const' instead  import/no-mutable-exports
  169:8  error    Unexpected var, use let or const instead              no-var
  185:8  warning  Exporting mutable 'var' binding, use 'const' instead  import/no-mutable-exports
  185:8  error    Unexpected var, use let or const instead              no-var
  209:8  warning  Exporting mutable 'var' binding, use 'const' instead  import/no-mutable-exports
  209:8  error    Unexpected var, use let or const instead              no-var
  238:8  warning  Exporting mutable 'var' binding, use 'const' instead  import/no-mutable-exports
  238:8  error    Unexpected var, use let or const instead              no-var
  304:8  warning  Exporting mutable 'var' binding, use 'const' instead  import/no-mutable-exports
  304:8  error    Unexpected var, use let or const instead              no-var

解决方法

  • 在该文件的上方加上 eslint-disable 注释,表示禁用某项 eslint 规则效验
/* eslint-disable no-var */
/* eslint-disable import/no-mutable-exports */

export var aa = 1;

你可能感兴趣的:(编码报错及解决方法,前端,eslint,eslint-disable)