【发布时间】:2019-03-19 18:45:48
【问题描述】:
我在 Visual Studio Code 中使用带有 TSLint 和 Prettier 的 TypeScript 来编写 React Native 应用程序。
我尝试将我的编辑器配置为将每行中的代码自动包装为 100 个字符。但保存后总是 80 个字符,而不是 100 个。
以下是我更改的设置:
"prettier.tslintIntegration": true,
"prettier.printWidth": 100,
"editor.renderIndentGuides": true,
"editor.rulers": [100],
"editor.wordWrapColumn": 100,
"editor.formatOnSave": true
这是我的tslint.json:
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"rules": {
// "jsx-no-lambda": false,
"member-access": false,
"interface-name": false,
"max-line-length": [true, 100]
}
}
即使我以这种方式配置了所有内容,我的代码仍然会自动换行大约 80 个字符。我怎样才能让它停止?
如果我的行超过 100 个字符,我会收到 linting 错误,因此 tslint.json 设置似乎有效。
奖励:完成 VSCode 设置以防我错过了什么:
{
"telemetry.enableTelemetry": false,
"workbench.colorTheme": "One Dark Pro",
"workbench.iconTheme": "vscode-icons",
"window.zoomLevel": 0,
"prettier.eslintIntegration": true,
"prettier.tslintIntegration": true,
"prettier.printWidth": 100,
"editor.renderIndentGuides": true,
"editor.rulers": [100],
"[javascript]": {
"editor.tabSize": 2
},
"[typescript]": {
"editor.tabSize": 2
},
"[typescriptreact]": {
"editor.tabSize": 2
},
"[json]": {
"editor.tabSize": 2
},
"workbench.colorCustomizations": {
// "statusBar.background": "#272b33",
// "panel.background": "#30353f",
// "sideBar.background": "#2a2b33",
"editor.background": "#2c313a"
},
"todohighlight.keywords": [
{
"text": "DEBUG:",
"color": "#fff",
"backgroundColor": "limegreen",
"overviewRulerColor": "grey"
},
{
"text": "NOTE:",
"color": "#fff",
"backgroundColor": "mediumslateblue",
"overviewRulerColor": "grey"
},
{
"text": "REVIEW:",
"color": "#fff",
"backgroundColor": "dodgerblue",
"overviewRulerColor": "grey"
},
{
"text": "XXX:",
"color": "#fff",
"backgroundColor": "orangered",
"overviewRulerColor": "grey"
}
],
"editor.wordWrapColumn": 100,
"editor.formatOnSave": true
}
【问题讨论】:
标签: typescript visual-studio-code word-wrap tslint prettier