eslint error cannot read property 'range' of null
需将babel-eslint更新为@babel/eslint-parser'
卸载babel-eslint 安装@babel/eslint-parser
@babel/preset-react
uninstall babel-eslint npm i @babel/eslint-parser @babel/preset-react --save-dev
.eslintrc.js配置
{ parser: '@babel/eslint-parser', parserOptions: { requireConfigFile: false, // 是否需要 babel 配置文件 sourceType: 'module', // script 或者 module allowImportExportEverywhere: false, // 设置为 true,import 和 export 声明 可以出现在文件的任务位置,否则只能出现在顶部 ecmaFeatures: { globalReturn: false // 设置为 true,当 sourceType 为 script 时,允许全局 return }, babelOptions: { presets: ['@babel/preset-react'] } }, }
报错:
Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV` environment variables. Valid values are "development", "test", and "production". Instead, received: undefined.
修改package.json清空presets
"babel": { "presets": [ // "react-app" // 清空 ], "plugins": [ [ "import", { "libraryName": "antd-mobile", "libraryDirectory": "lib" }, "antd-mobile" ] ] }
相关文章:
https://newbedev.com/eslint-error-cannot-read-property-range-of-null
https://tjaddison.com/blog/2021/03/updating-babel-eslint-to-babeleslint-parser-for-react-apps/