tslint - 如何使用 prettier 在类中的方法声明之后和之前添加新行?

标签 tslint prettier eslintrc

需要配置哪些设置才能使用prettier plugin在 typescript 文件中的类中的方法声明之前和之后添加新行在 VS 代码编辑器中?

如何通过在.prettierrctslint.json文件中编写任何规则来实现?

当前行为是

function one(){
// some code
}
function two(){
// some code
}

预期结果

function one(){
// some code
}

function two(){
// some code
}

我已尝试在 tslint.json 中使用以下行

"lines-between-class-methods": "true"

但没有成功

最佳答案

@lakshan 提到的是 ESLint rule 。有一个 TSLint 规则可以实现您正在寻找的内容,但与类方法有关。

https://github.com/chinchiheather/tslint-lines-between-class-members

运行

npm install --save-dev tslint-lines- Between-class-members

添加

tslint.json

{
  "rulesDirectory": [
    "node_modules/tslint-lines-between-class-members"
  ],
  "rules": {
    "lines-between-class-members": true,
  }
}

关于tslint - 如何使用 prettier 在类中的方法声明之后和之前添加新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52772097/

相关文章:

typescript - Typescript 中引号的使用标准是什么?

webpack - tslint 正确的错误/警告处理

react-native - react native - eslintrc - prettierrc : how to prevent removing of parentheses around one element in JSX

django - 如何配置 VS Code 以使用 Prettier HTML 格式化程序?

visual-studio-code - 在 VS Code 中使用 Prettier 格式化 .ejs 文件

javascript - eslint-config-google 没有检测到全局安装的 eslint

jestjs - 使用 eslintrc 的特定文件结尾的 ESlint 禁用规则

typescript - 如何重写代码以避免 TSLint "object access via string literals"

react-native - .eslintrc.js 不适用于规则 "off"

typescript - 用于检查未定义和 NULL 类属性的 TSLint 规则