组内的导入源必须按字母顺序排列 [英] Import sources within a group must be alphabetized

查看:21
本文介绍了组内的导入源必须按字母顺序排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好像我不认识字母表.请告诉我没有订购的地方:

seems like I don't know the alphabet. Please tell me where this is not ordered:

import * as React from 'react';
import {
  Badge,
  Button,
  ButtonGroup,
  Collapse,
  Dropdown,
  DropdownItem,
  DropdownMenu,
  DropdownToggle,
  Input,
  InputGroup,
  InputGroupAddon,
  Nav,
  Navbar,
  NavbarBrand,
  NavItem,
  NavLink,
  UncontrolledAlert,
} from 'reactstrap';
import {logoutUser} from '../actions/user';
import {positionSidebar,toggleSidebar,toggleVisibilitySidebar} from '../actions/navigation';

import s from './Header.scss';

import sender1 from '../../images/1.png';
import sender2 from '../../images/2.png';
import sender3 from '../../images/3.png';

它给了我第 22 行的错误:组内的导入源必须按字母顺序排列." (import {positionSidebar ....) 但是它们的顺序是正确的!!(或者也许我必须返回学校:().

It gave me the error at line 22: "Import sources within a group must be alphabetized." (import {positionSidebar....) But They are correctly ordered!! (or maybe I have to return to school :( ).

我试图禁用这个愚蠢的字母顺序:但我也不能:

I tried to disable this stupid alphabetical order: but I could not either:

 "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
 "ordered-imports": [true, {
   "import-sources-order": "any",
   "named-imports-order": "any",
   "grouped-imports": false,
   "module-source-path": "basename"
 }]

这不起作用,错误重复出现.我会把它发布在 github 上,但有很多关于这个的帖子,也许它不是一个错误.如果您认为这是错误,请告诉我,我会在那里发布.

That doesn't work and the error repeat. I would post it on github but there are lots of posts about this and maybe it is not a bug. If you think it is bug, tell me and I will post it there.

我的 tslint 导入:

My tslint imports:

"tslint": "^5.7.0",
"tslint-config-prettier": "^1.10.0",
"tslint-react": "^3.2.0",

推荐答案

lint 排序错误不在单个命名导入上,而是在文件路径上:

The ordering lint error is not on the individual named imports, but rather the file paths:

import {logoutUser} from '../actions/user';
import {positionSidebar,toggleSidebar,toggleVisibilitySidebar} from '../actions/navigation';

文件路径也用作排序的一部分,应该是:

The filepaths are also used as part of the ordering, and should be:

'../actions/navigation';
'../actions/user';

您可以使用此 tslint 配置完全禁用导入顺序:

You can disable import ordering entirely using this tslint config:

"ordered-imports": false

这篇关于组内的导入源必须按字母顺序排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆