我正在尝试配置我的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上的这条规则中只有3个选项中有3个
使用:TSLint 5.11.0和WebStorm 2018.2.2。
难道我做错了什么?是否有其他方式来应用这些规则?
编辑:顺便说一句警告是一回事,其他的事情是这两个规则根本不起作用 - linter没有用这样的导入调用错误:
import { MainService } from 'app/services/main.service';
import { MainComponent } from 'app/components/main.component';
选项有效;问题是捆绑的tslint JSON模式文件是否经过验证并不是最新的。记录为WEB-34689,请关注它以获取更新。目前我只能建议在“设置”中禁用“遵从JSON模式检查”编辑| InspectionsJSON和JSON5来抑制错误