estlint -Cannot read property 'range' of null

问题

修改了.eslintrc.js文件中默认缩进为4个之后

"rules": {
      'indent': ['warn', 4]
}

编译出现"Cannot read property 'range' of null

eslint error.png

解决方法

方法一

卸载babel-eslint 重新安装
可以先进行清除cache之后,再进行安装

  npm cache clean
  npm install
  npm cache clean // npm cache clean --force 
方法二

增加‘ignoredNodes’配置

"rules": {
      'indent': ['warn', 4, {
                'ignoredNodes': ['TemplateLiteral']
      }]
}

参考

eslint error cannot read property 'range' of null

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容