[英]How to deal with Tslint error exceeds 100 characters when using imports in Typescript
I am importing a file: 我正在导入文件:
import { BodyTableHeaderExampleModule } from '../../components/example-table/example-table-header/example-table-header-xxxx/example-table-header-xxxxx.module';
However, tslint is complaining that the line exceeds 100 characters. 但是,tslint抱怨该行超过100个字符。 When I try to minimize line length, by doing the following:
当我尝试最小化行长时,请执行以下操作:
import { BodyTableHeaderExampleModule } from '../../components/example-table/example-table-header/' +
'example-table-header-xxxx/example-table-header-xxxxx.module';
I receive the following tslint errors: 我收到以下tslint错误:
ERROR: 11:92 semicolon Missing semicolon
ERROR: 11:93 no-unused-expression unused expression, expected an assignment or function call
Any suggestions on a way to remedy the Exceeds maximum line length of 100
when using long Typescript file imports, would be more than appreciated. 使用长的Typescript文件导入时,有关补救Exceeds
Exceeds maximum line length of 100
的方法的任何建议,将不胜感激。 Thank you. 谢谢。
There are few options here 这里很少有选择
You could rather rewrite the import into 您宁愿将导入内容重写为
import { BodyTableHeaderExampleModule } from '../../components/example-table/example-table-header/example-table-header-xxxx/example-table-header-xxxxx.module';
But yes, this would still be over a 100 characters 但是是的,这仍然会超过100个字符
You could simply disable that tslint rule for that one line 您只需为那一行禁用该tslint规则
BodyTableHeaderExampleModule
somewhere within that path. BodyTableHeaderExampleModule
。 Except 1. which won't still work for you, the other 3 solutions are all valid. 除了1.仍然无法为您工作之外,其他3个解决方案均有效。 For a long term solution, I'd myself probably solve it as described in 4. - and re-export the module somewhere in
../../components/example-table/example-table-header
or similar. 对于长期解决方案,我本人可能会按照4中的描述进行解决
../../components/example-table/example-table-header
将该模块重新导出到../../components/example-table/example-table-header
或类似位置中。 But choose what's best for your project and your need. 但是,选择最适合您的项目和需求的东西。
There is an option to ignore patterns from the max-line-rule. 有一个选项可以忽略max-line-rule中的模式。
https://palantir.github.io/tslint/rules/max-line-length/ https://palantir.github.io/tslint/rules/max-line-length/
Example: 例:
"max-line-length": [
true,
{
"limit": 120,
"ignore-pattern": "^import "
}
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.