我尝试设置基于vim的typescript开发环境,但有一个缩进管理的问题。

可能'eslint‘说的是:prettier重新格式化后的indent: Expected indentation of 2 spaces but found 4.。
我的.eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
tsx: true, // Allows for the parsing of TSX ???
},
},
rules: {
indent: ['error', 2],
quotes: ['error', 'single'],
semi: ['error', 'never'],
'sort-keys': ['error', 'asc', { caseSensitive: true, natural: false }],
},
}我的.prettierc:
module.exports = {
semi: false,
trailingComma: 'all',
singleQuote: true,
printWidth: 80,
tabWidth: 2,
};发布于 2019-11-21 23:02:24
根据凯卡塔尔多对这个GitHub issue的评论
ESLint的缩进规则和Prettier的缩进样式不匹配-它们是完全独立的实现,是解决同一问题的两种不同方法(“我们如何在项目中强制一致缩排”)。
因此,在使用prettier时,最好禁用eslint的indent规则。它们肯定会发生冲突。
发布于 2021-01-08 03:53:12
在eslintrc中添加indent: [2, 2, { SwitchCase: 1}]
发布于 2019-05-29 06:09:32
这应该可以修复它,https://github.com/prettier/eslint-config-prettier
它禁用eslint中与更漂亮的冲突的规则
https://stackoverflow.com/questions/56337176
复制相似问题