欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解決vue2使用腳手架配置prettier報(bào)錯(cuò)prettier/prettier:context.getPhysicalFilename is not a function

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

vue2使用腳手架配置prettier報(bào)錯(cuò)

原因

出現(xiàn)這個(gè)錯(cuò)誤大概率是由于相關(guān)聯(lián)的依賴(lài)之間的版本不互相兼容導(dǎo)致的。

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

包括我之后在安裝 sass和sass-loader運(yùn)行不起來(lái)也是因?yàn)榘姹締?wèn)題導(dǎo)致。

解決辦法

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

然后安裝指定版本的依賴(lài)后重新打開(kāi)vscode:

# 這些依賴(lài)都是開(kāi)發(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相關(guān)問(wèn)題

修改 eslint 記得重新 run 一下

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

原因描述

在window系統(tǒng)中,clone代碼下來(lái),會(huì)自動(dòng)把換行符LF(linefeed character) 轉(zhuǎn)換成回車(chē)符CRLF(carriage-return character)。這時(shí)候我們本地的代碼都是回車(chē)符。

方法一: 自動(dòng)修復(fù),不可能每次拉代碼都要修改好麻煩不支持

npm run lint --fix

方法二:git 修改配置

git config --global core.autocrlf false

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

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

錯(cuò)誤信息

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

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

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

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',
  },
};

總結(jié)

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

相關(guān)文章

最新評(píng)論