英文:
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"]
}
}
]
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论