javascript - 如何在创建反应应用程序中创建绝对路径?
问题描述
我已将我的 eslint 配置配置为使用绝对路径。我使用了本手册https://dev.to/oliverandrich/absolute-imports-with-create-react-app-and-vscode-ihn。一切运行良好,但 eslint 显示错误 "Absolute imports should come before relative imports.eslint(import/first)" 。我试图用谷歌搜索但没有成功。有什么建议吗?
这是我的 eslint 配置:
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true
},
"extends": ["airbnb","react-app", "plugin:import/errors", "plugin:import/warnings"],
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": ["node_modules", "src/"]
}
}
},
"env": {
"jest/globals": true,
"browser": true,
"node": true
},
"rules": {
"arrow-parens": [
"off"
],
"compat/compat": "error",
"consistent-return": "off",
"comma-dangle": "off",
"flowtype-errors/show-errors": "error",
"generator-star-spacing": "off",
"import/no-unresolved": "error",
"import/no-extraneous-dependencies": "off",
"no-console": "off",
"no-use-before-define": "off",
"no-multi-assign": "off",
"no-underscore-dangle": "off",
"promise/param-names": "error",
"react/no-array-index-key": "off",
"promise/catch-or-return": "error",
"promise/no-native": "off",
"react/sort-comp": [
"error",
{
"order": [
"type-annotations",
"static-methods",
"lifecycle",
"everything-else",
"render"
]
}
],
"react/jsx-no-bind": "off",
"react/jsx-filename-extension": [
"error",
{
"extensions": [
".js",
".jsx"
]
}
],
"react/prefer-stateless-function": "off",
"react/forbid-prop-types": [
"error",
{
"forbid": []
}
],
"no-useless-escape": "off",
"no-confusing-arrow": "off",
"no-plusplus": "off",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/valid-expect": "error"
},
"plugins": [
"flowtype",
"flowtype-errors",
"import",
"promise",
"compat",
"react",
"jest"
]
}
解决方案
推荐阅读
- lisp - 球拍中的单身人士(LISP)
- mysql - 有没有办法在领域对象数据库与 mariadb 之间同步?
- amazon-s3 - 如果找不到环境变量,如何从文件中回退到凭据?
- django - Django 在排序的查询集中注释 x 的第一次出现
- reactjs - react-router:如何从基本名称导航到父路由
- mysql - 为什么即使启用了 MySQL 查询缓存也没有使用?
- swift - 更新到 Xcode 11 后,CGAffineTransform 翻译在标签栏上不起作用
- python-3.x - ValueError:发现样本数量不一致的输入变量:[755, 8]
- python - 如何在 python 的 Tkinter GUI 中显示完整的文本?
- sql - SQL如何对唯一键对的列求和