【发布时间】:2019-02-11 20:19:35
【问题描述】:
我正在尝试将我的 TSLint 规则配置为包括:ordered-imports 和 module-source-path。我想要有规则,其中导入首先按路径排序,然后是具有单独组的源(1grp = 外部库,2grp = 内部源)。自动修复对我来说也很重要。
正确排序的导入示例:
import { CommonModule } from '@angular/common';
import { Observable } from 'rxjs';
import { MainComponent } from 'app/components/main.component';
import { MainService } from 'app/services/main.service';
我将此添加到我的tslint.json:
"ordered-imports": [
true,
{
"import-sources-order": "any",
"named-imports-order": "case-insensitive",
"grouped-imports": true,
"module-source-path": "full"
}
],
我的 WebStorm 在行 "grouped-imports": true, 和 "module-source-path": "full" 上抛出错误/警告,说“不允许使用属性 'X'”(其中 X 是这些选项之一)。根据文档https://palantir.github.io/tslint/rules/ordered-imports/ 可以添加它。
有趣的是,GitHub 上的这条规则只有 4 个选项中的 3 个
使用:TSLint 5.11.0 和 WebStorm 2018.2.2。
我做错了吗?还有其他方法可以应用这些规则吗?
编辑: 顺便说一句,警告是一回事,另一件事是这两条规则根本不起作用 - linter 不会像这样的导入调用错误:
import { MainService } from 'app/services/main.service';
import { MainComponent } from 'app/components/main.component';
【问题讨论】:
标签: typescript webstorm tslint