typescript - 使用 eslint 和 prettier 在 typescript 中配置换行符
问题描述
我正在用打字稿写一个项目。我在项目的根目录中定义了一些关于 prettier 和 eslintrc.js 文件的配置。当 max-len 达到 100 个字符时,每个参数都设置在一行中。
但是,我想要完成的结果是尽可能多地填充线条。例如 :
const subPopulate = { path: 'appointments', match: { memberId: new Types.ObjectId(member._id) }, populate: 'notes', test1: '123', test2: '456'};
我使用 prettier 和 eslintrc 有什么:
const subPopulate = {
path: 'appointments',
match: { memberId: new Types.ObjectId(member._id) },
populate: 'notes',
test1: '123',
test2: '456',
};
我想尽可能多地填写这条线,我想要什么:
const subPopulate = { path: 'appointments',
match: { memberId: new Types.ObjectId(member._id) },
populate: 'notes', test1: '123', test2: '456'};
我想在定义变量和函数时这样做(同样的问题)。
试图在eslint 规则和更漂亮的规则中找到一些东西,但没有运气:(
我的更漂亮
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"printWidth": 100
}
我的 eslintrc
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended'],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'max-len': ['error', { code: 100 }],
'no-var': 'error',
semi: 'error'
},
};
解决方案
推荐阅读
- java - 由于外部库中的 org.junit.Test 类依赖关系,无法使用 LeakCanary
- javascript - 从 API OpenWeatherMap JavaScript 获取数据
- node.js - 我可以直接在反应应用程序上运行节点功能吗
- javascript - 有没有办法将我用 js 附加到 DOM 的任何内容存储在本地存储中,以便在页面重新加载后检索它?
- c++ - 跟踪参考修改以更新原始类
- html - 为什么我不能在表格上输入文字?
- discord.py - 解禁ID | 我使用了解禁命令,但仍然无法使用 ID 解禁
- javascript - fullcalendar.io 5:addEventSource 不能从外部函数工作
- javascript - 使用 ScrollTop 的聊天框不适用于使用 jQuery 的下一个包装类
- r - 使用 ddply 找不到对象