Отступы Преттиер и Эслинт не работают вместе - PullRequest
1 голос
/ 28 мая 2019

Я настроил настройку среды разработки на основе vim, но у меня возникла проблема с управлением отступами.

enter image description here

Возможно, '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,
};

1 Ответ

0 голосов
/ 29 мая 2019

Это должно исправить https://github.com/prettier/eslint-config-prettier

Это отключает правила в eslint, которые конфликтуют с более красивыми

...