【发布时间】:2019-10-13 16:26:45
【问题描述】:
我正在设置基于 vim 的打字稿开发环境,但在缩进管理方面存在问题。
可能'eslint' 说:indent: Expected indentation of 2 spaces but found 4. 在prettier 重新格式化之后。
我的.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,
};
【问题讨论】:
-
同样的问题!所有的 linter 和自动格式化选项都相互冲突!我无法得到没有分号的代码被接受而没有错误...我不得不求助于仅使用 vs 代码的本机自动格式化????????
标签: javascript typescript vim eslint prettier