eslint 下划线问题

Vue中遇到Identifier 'aa_bb' is not in camel case

有时候写vue会遇到如下错误,

error Identifier 'aa_bb' is not in camel case

这是因为ESLint代码规范检测的要求,必须要求用骆驼式变量名,当我们写成下划线形式就出现error

解决办法:
1)对一个文件

如果是JS文件,在开头加上这样一行代码来取消对骆驼式变量名的检测:

/* eslint-disable camelcase */

如果是TS文件:

/* eslint-disable @typescript-eslint/camelcase */

2)全局取消检测骆驼式变量名

在根目录中找到eslint配置的代码,在rules中如下添加:

对JS文件:

rules: {

  ...

  'camelcase': 'off',
}

 

对TS文件:

rules:  
 ...
'@typescript-eslint/camelcase': 'off', }

 

posted @ 2022-03-29 10:54  程序員劝退师  阅读(542)  评论(0编辑  收藏  举报