typescript和javascript混合项目的更漂亮的自动格式化错误
我正在将typescript添加到现有javascript项目中。这是一个大规模的项目,所以我决定一步一步地将项目转换为typescript 这是我的eslintrc.js文件typescript和javascript混合项目的更漂亮的自动格式化错误,javascript,typescript,prettier,eslint-config-airbnb,Javascript,Typescript,Prettier,Eslint Config Airbnb,我正在将typescript添加到现有javascript项目中。这是一个大规模的项目,所以我决定一步一步地将项目转换为typescript 这是我的eslintrc.js文件 module.exports = { parser: '@typescript-eslint/parser', // Specifies the ESLint parser extends: [ 'plugin:@typescript-eslint/recommended', // Uses the re
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'airbnb-typescript/base', // Airbnb style guide
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'prettier/@typescript-eslint' // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}
},
rules: {
// some rules here
},
plugins: ['prettier']
};
问题在于保存,prettier应该格式化我的代码。但事实并非如此
这是我的漂亮日志的输出
["ERROR" - 12:34:20 PM] Error formatting document.
Failed to load plugin '@typescript-eslint' declared in 'CLIOptions': Cannot find module '@typescript-eslint/eslint-plugin'
我试着运行npm install@typescript eslint--save dev
。但是没有运气
如何优化我的eslintrc以解决此问题。
提醒:我应该能够将此配置与typescript和javascript一起使用。禁用vscode prettier扩展修复了我的问题。该扩展与我的漂亮设置相冲突。希望扩展开发团队能尽快解决这个问题 禁用vscode prettier扩展修复了我的问题。该扩展与我的漂亮设置相冲突。希望扩展开发团队能尽快解决这个问题