Absolute imports should come before relative imports 的解决方案

575 阅读1分钟

绝对引入必须要在相对引入之前例如:

import "../../utils"
import _ from 'lodash'

会报错,因为相对引入在绝对引入之前
解决方案:
1.更改引入顺序

import _ from 'lodash'
import "../../utils"

2.更改eslintrc.js

  "extends": ["taro/react"],
  "rules": {
    "react/jsx-uses-react": "off",
    "react/react-in-jsx-scope": "off",
    "import/first": [ 'error', 'DISABLE-absolute-first'    ]
      }
   }

增加"import/first": [ 'error', 'DISABLE-absolute-first' ]即可修复该警告