使用打字稿处理多个项目

时间:2020-09-11 14:34:01

标签: typescript vue.js single-page-application eslint

我的存储库,门户网站和商店中有多个项目。我都想使用打字稿,因此我有以下项目结构:

enter image description here

如您所见,tsconfig.json.eslint.js在门户和商店项目之外。在我的tsconfig文件中,出现此错误:

Cannot find definition file for 'webpack-env'

然后,如果我尝试运行npm run serve,则会出现此错误:

Failed to load plugin 'vue' declared in '..\.eslintrc.js': Cannot find module 'eslint-plugin-vue'

以下是我文件的全部内容:

tsconfig.json

{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": "portal",
"types": [
  "webpack-env"
],
"paths": {
  "@/*": [
    "src/*"
  ]
},
"lib": [
  "esnext",
  "dom",
  "dom.iterable",
  "scripthost"
]
},
 "include": [
   "portal/src/**/*.ts",
   "portal/src/**/*.tsx",
   "portal/src/**/*.vue"
],
"exclude": [
  "node_modules"
]
}

.eslintrc.js

module.exports = {
root: true,
env: {
  node: true,
},
extends: [
  'plugin:vue/essential',
  '@vue/airbnb',
  '@vue/typescript/recommended',
  'plugin:import/errors',
  'plugin:import/warnings',
  'plugin:import/typescript',
],
rules: {
  'prefer-destructuring': ['error', { object: false, array: false }],
  'no-debugger': 'off',
  'max-len': 'off',
  '@typescript-eslint/no-non-null-assertion': 'off',
  'arrow-parens': 'off',
  'max-classes-per-file': 'off',
  '@typescript-eslint/interface-name-prefix': 'off',
  '@typescript-eslint/explicit-module-boundary-types': 'off',
},
parserOptions: {
  parser: '@typescript-eslint/parser',
},

};

我在这里做事吗?我在网上搜索了无数次,找不到解决方案,甚至找不到一个人正在实现我想要达到的目标的例子

0 个答案:

没有答案