Visual studio code 如何使用eslint prettier/prettier内联注释?
我想在prettier中关闭该规则,它会在内联注释中换行。我的ESLint规则Visual studio code 如何使用eslint prettier/prettier内联注释?,visual-studio-code,eslint,prettier,eslint-config-airbnb,eslintrc,Visual Studio Code,Eslint,Prettier,Eslint Config Airbnb,Eslintrc,我想在prettier中关闭该规则,它会在内联注释中换行。我的ESLint规则无内联注释设置为off或warn,这样就可以处理并工作了。事实证明,Prettier仍然想要换行和内联评论: 我在我的VSCode中有一个设置,ESLint处理的是prettier for JS,prettier扩展处理的是所有其他语言。我也在使用airbnb基地。以下是我的相关配置: .eslintrc.json: { "extends": ["airbnb-base", "plugin:prettier/re
无内联注释设置为off或warn,这样就可以处理并工作了。事实证明,Prettier仍然想要换行和内联评论:
我在我的VSCode中有一个设置,ESLint处理的是prettier for JS,prettier扩展处理的是所有其他语言。我也在使用airbnb基地
。以下是我的相关配置:
.eslintrc.json
:
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"rules": {
"no-console": 0,
"no-plusplus": 0,
"no-inline-comments": "off",
"no-undef": "warn",
"no-use-before-define": "warn",
"no-restricted-syntax": [
"warn",
{
"selector": "ForOfStatement",
"message": "frowned upon using For...Of"
}
]
// "line-comment-position": ["warn", { "position": "above" }]
},
"env": {
"browser": true,
"webextensions": true
}
}
// all auto-save configs
"editor.formatOnSave": true,
// turn off for native beautifyjs
"[javascript]": {
"editor.formatOnSave": false
},
"eslint.autoFixOnSave": true,
"eslint.alwaysShowStatus": true,
"prettier.disableLanguages": ["js"],
"prettier.trailingComma": "es5"
}
VSCodesettings.json
:
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"rules": {
"no-console": 0,
"no-plusplus": 0,
"no-inline-comments": "off",
"no-undef": "warn",
"no-use-before-define": "warn",
"no-restricted-syntax": [
"warn",
{
"selector": "ForOfStatement",
"message": "frowned upon using For...Of"
}
]
// "line-comment-position": ["warn", { "position": "above" }]
},
"env": {
"browser": true,
"webextensions": true
}
}
// all auto-save configs
"editor.formatOnSave": true,
// turn off for native beautifyjs
"[javascript]": {
"editor.formatOnSave": false
},
"eslint.autoFixOnSave": true,
"eslint.alwaysShowStatus": true,
"prettier.disableLanguages": ["js"],
"prettier.trailingComma": "es5"
}
我知道你可以做//eslint禁用下一行prettier/prettier
,但我显然不想每次都设置它。你可以在我上面的图片中看到它被注释掉了
一般来说,将注释放在它们自己的行上,而不是放在行的末尾,会得到最好的结果。首选//eslint禁用下一行
而不是//eslint禁用行
我不确定这在这种情况下是否有用:
注意:虽然可以通过ESLint配置文件将选项传递给Prettier,但不建议这样做,因为编辑器扩展名(如Prettier atom
和Prettier vscode
)将读取。prettierrc
,但不会从ESLint读取设置,这可能会导致不一致的体验
我和几个人谈过,可能根本不可能?不过,这是一条规则,应该可以被推翻。如果我能提供任何其他信息,我会提供。我很想有一个解决方案,你在发帖后有没有发现更多信息?很抱歉,我没有找到解决方案:(这似乎是一个悬而未决的问题。对此有任何更新吗?使用插件ruby
的prettier breaks内联rubocop:disable
规则