亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

解決vue2使用腳手架配置prettier報錯prettier/prettier:context.getPhysicalFilename is not a function

 更新時間:2024年03月20日 09:19:25   作者:笑道三千  
這篇文章主要介紹了解決vue2使用腳手架配置prettier報錯prettier/prettier:context.getPhysicalFilename is not a function問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

vue2使用腳手架配置prettier報錯

原因

出現(xiàn)這個錯誤大概率是由于相關聯(lián)的依賴之間的版本不互相兼容導致的。

比如我用的是 vue 官方默認的 vue2 腳手架創(chuàng)建的項目,在此基礎上我又在項目中自己配置了 .eslintrc.js 和 .prettierrc,自己又裝了一些格式化插件,如 @vue/eslint-config-prettie、prettier,結果項目就運行不起來了。

包括我之后在安裝 sass和sass-loader運行不起來也是因為版本問題導致。

解決辦法

# 移除以下依賴,項目中不存在的就不用移除
npm rm @vue/cli-plugin-babel @vue/cli-plugin-eslint @vue/eslint-config-prettier eslint eslint-plugin-prettier eslint-plugin-vue prettier

然后安裝指定版本的依賴后重新打開vscode:

# 這些依賴都是開發(fā)環(huán)境才需要用到,加上 -D 
npm i -D @vue/cli-plugin-babel@4.4.6 @vue/cli-plugin-eslint@4.4.6 @vue/eslint-config-prettier@7.0.0 eslint@7.15.0 eslint-plugin-prettier@3.4.1 eslint-plugin-vue@7.2.0 prettier@2.5.1

vue prettier/prettier eslintrc相關問題

修改 eslint 記得重新 run 一下

1.warning Delete ? prettier/prettier(eslint配置的一些問題)

原因描述

在window系統(tǒng)中,clone代碼下來,會自動把換行符LF(linefeed character) 轉換成回車符CRLF(carriage-return character)。這時候我們本地的代碼都是回車符。

方法一: 自動修復,不可能每次拉代碼都要修改好麻煩不支持

npm run lint --fix

方法二:git 修改配置

git config --global core.autocrlf false

2.Replace (變量) with 變量eslintprettier/prettier

箭頭函數(shù)單個參數(shù)時,vscode的prettier和vue的prettier沖突,解決辦法,eslintrc.js中添加

錯誤信息

this.(values).then((success) => ({
Replace(success)withsuccesseslintprettier/prettier
//處理箭頭函數(shù)單個參數(shù)括號規(guī)則沖突
.eslintrc.js
rules: {
    "prettier/prettier": ["error", { singleQuote: true, parser: "flow" }] 
 },

3.vue-cli3報error Parsing error: Unexpected token (太難了)

這個問題網(wǎng)上所有辦法都不行,最后直接拿出一個完整版

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
  parserOptions: {
    parser: 'babel-eslint',
    ecmaFeatures: {
      // open the `decorators` function
      legacyDecorators: true,
    },
  },
  //    'arrow-parens': ['error', 'as-needed'],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-param-reassign': 'off',
    'no-unused-vars': 'off',
    'no-underscore-dangle': 'off',
    'no-unreachable': 'off',
    'generator-star-spacing': 'off',
    'import/no-extraneous-dependencies': 'off',
    'array-callback-return': 'off',
    'no-useless-escape': 'off',
    'no-confusing-arrow': 'off',
    'consistent-return': 'off',
    'no-debugger': 'warn',
    'no-plusplus': 'off',
    'jsx-a11y/label-has-associated-control': 'off',
    'jsx-a11y/label-has-for': 'off',
    'comma-dangle': 0,
    'object-curly-newline': 'off',
    'operator-linebreak': 'off',
    'import/prefer-default-export': 'off',
    'implicit-arrow-linebreak': 'off',
    'import/no-unresolved': 'off',
    'import/extensions': 'off',
    'arrow-parens': 0,
    'prettier/prettier': 'off',
  },
};

總結

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論