【问题标题】:spec.ts Exceeds maximum line length of 140spec.ts 超过最大行长 140
【发布时间】:2017-04-23 20:28:42
【问题描述】:

我有一个 Angular2 组件的单元测试规范文件。
此规范文件导入文件/组件,如 import { DeviceProtocolModifiedLabelComponent } from '../../../../../src/app/device/deviceProtocol/deviceProtocolList/deviceProtocolWidget/deviceProtocolModifiedLabel/device-protocol-modified-label.component'; import { DeviceProtocolTagsComponent } from '../../../../../src/app/device/deviceProtocol/deviceProtocolList/deviceProtocolWidget/deviceProtocolTags/device-protocol-tags.component';

但上面的行在一行中跨越了 140 个字符,并在控制台上给出了以下错误。

test/specs/app/device/deviceProtocol/device-protocol.component.spec.ts[25, 1]: Exceeds maximum line length of 140


我经历了this 的问题,但没有帮助。我不想更改配置

【问题讨论】:

  • 你见过the flags吗?顺便说一句,在此路径的某个级别重新导出 index.ts 是有意义的。

标签: angular jasmine tslint


【解决方案1】:

我知道我在 stackoverflow 上回答这个问题已经很晚了。但是如果有人正在寻找这个问题的答案(比如我),那么这里有解决方案 -

    1. Write your code in this way -
     import { 
        DeviceProtocolTagsComponentA, 
        DeviceProtocolTagsComponentB, 
        DeviceProtocolTagsComponentC 
     } from
    '../../../../../../../../../../../../device-protocol-tags.component';
    
    2. OR Go to tslint.json file and change this -
       "max-line-length": [
          true,
          140  // increase this value
        ]

    3. OR Add below line just above your code, like this -

       // tslint:disable-next-line:max-line-length
       import { DeviceProtocolModifiedLabelComponent } from  '../../../../../src/app/device/deviceProtocol/deviceProtocolList/deviceProtocolWidget/deviceProtocolModifiedLabel/device-protocol-modified-label.component';

【讨论】:

    猜你喜欢
    • 2017-07-30
    • 2019-10-10
    • 1970-01-01
    • 2014-03-19
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多