如何将一个文件(异常情况)的最大长度设置为120?

huangapple go评论62阅读模式
英文:

How to set max-len for one file (exception) to 120?

问题

有 eslint 时,我将我的最大行长度设置为 80,我喜欢这样,除了一个文件,我想要按升序组织我的导出,而我在VS Code插件中唯一的方法是将每个导出放在一行。

默认情况下,我的最大行长度为80,如何为这个文件创建一个例外?是否有一个 eslint 注释可以做到这一点?

英文:

With eslint I've my max line length on 80 and I like this besides for one file where I'd like to organize my exports ASC and the only way to do this with my VS Code plugin is that I have each export on one line.

Default my max line length is 80, how can I make an exception for this one file? Is there an eslint comment for this?

答案1

得分: 0

使用注释:在文件顶部添加 /* eslint-disable max-len */(来源:https://eslint.org/docs/latest/use/configure/rules#disabling-rules)。

或者,在你的 .eslintrc 文件中为特定文件模式定义 overrides

"overrides": [
  {
    "files": ["path/to/your/very/long/*/files.js"],
    "rules": {
      "max-len": ["off"]
    }
  }
]

(来源:https://stackoverflow.com/questions/34764287/turning-off-eslint-rule-for-a-specific-file/65069069#65069069)

我本来会将此问题标记为与 https://stackoverflow.com/questions/34764287/turning-off-eslint-rule-for-a-specific-file 完全重复,但悬赏问题无法标记为重复。

相关链接:https://stackoverflow.com/questions/50468673/how-to-disable-eslint-rule-max-line-length-for-paragraph-in-template-of-vue-js

英文:

With a comment: Put /* eslint-disable max-len */ at the top of your file (src: https://eslint.org/docs/latest/use/configure/rules#disabling-rules).

Alternatively, define overrides for some rules for specific file patterns in your .eslintrc file:

"overrides": [
  {
    "files": ["path/to/your/very/long/*/files.js"],
    "rules": {
      "max-len": ["off"]
    }
  }
]

(src: https://stackoverflow.com/questions/34764287/turning-off-eslint-rule-for-a-specific-file/65069069#65069069)

I would have marked this question as an exact dupe of https://stackoverflow.com/questions/34764287/turning-off-eslint-rule-for-a-specific-file, but bountied questions cannot be marked as dupe.

Related: https://stackoverflow.com/questions/50468673/how-to-disable-eslint-rule-max-line-length-for-paragraph-in-template-of-vue-js

huangapple
  • 本文由 发表于 2023年7月28日 02:21:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76782482.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定