eslint 將我的 *.ts 檔案視為也有 vue 的專案中的 javascript
P粉739706089
P粉739706089 2023-09-02 19:59:50
0
2
331
<p>我正在使用 typescript 和 vue 開發一個網頁專案。在閱讀了 typescript-eslint 和 eslint-plugin-vue 的文檔後,我已經解決了以下 eslint 配置:</p> <pre class="brush:php;toolbar:false;">module.exports = { root: true, env: { browser: true, es2021: true, }, extends: [ "eslint:recommended", "plugin:vue/vue3-essential", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking", "prettier", ], parser: "vue-eslint-parser", parserOptions: { parser: "@typescript-eslint/parser", project: ["./tsconfig.json"], tsconfigRootDir: __dirname, extraFileExtensions: [".vue"], }, overrides: [], parserOptions: { ecmaVersion: "latest", sourceType: "module", }, plugins: ["vue", "@typescript-eslint"], };</pre> <p>我的 vue 檔案解析正確,但我的 ts 檔案有不合理的 lint 錯誤。看來它們是針對 javascript 語法進行檢查的。如下圖所示:</p> <p>如果我刪除<code>parserOptions</code> 並將解析器更改為<code>@typescript-eslint/parser</code>,ts 檔案會正確lint,但vue 檔案的lint 會中斷。 </p > <p>有人知道嗎? </p>
P粉739706089
P粉739706089

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!