簡體   English   中英

Eslint 解析器的誤報

[英]False positive for Eslint parser

運行 vue 應用程序時出現誤報錯誤。 它告訴構造函數名稱不應以小寫字母開頭。 如何解決這個問題。

我的 .eslintrc.js 如下

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  parserOptions: {
    parser: 'babel-eslint',
  },
  extends: [
    '@nuxtjs',
    'prettier',
    'prettier/vue',
    'plugin:vue-scoped-css/recommended',
    'plugin:prettier/recommended',
    'plugin:nuxt/recommended',
  ],
  plugins: ['prettier'],
  // add your custom rules here
  rules: {
    'nuxt/no-cjs-in-config': 'off',
    'no-console': 'off',
    'vue-scoped-css/require-scoped': 'error',
    'vue/component-name-in-template-casing': 'error',
    'prettier/prettier': ['error', { endOfLine: 'auto' }],
  },
}

我嘗試運行應用程序時的錯誤是

$ npm run lint:fix

> v-moa-app@1.0.0 lint:fix
> npm run lint -- --fix


> v-moa-app@1.0.0 lint C:\Users\502622018\moa_workspace\v-moa-app
> eslint --ext .js,.vue --ignore-path .gitignore . "--fix"


C:\Users\502622018\moa_workspace\v-moa-app\server\passport.js
  260:30  error  A constructor name should not start with a lowercase letter  new-cap

✖ 1 problem (1 error, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! v-moa-app@1.0.0 lint: `eslint --ext .js,.vue --ignore-path .gitignore . "--fix"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the v-moa-app@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\502622018\AppData\Local\npm-cache\_logs\2021-07-21T22_16_39_215Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\502622018\moa_workspace\v-moa-app
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c npm run lint -- --fix

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\502622018\AppData\Local\npm-cache\_logs\2021-07-21T22_16_39_281Z-debug.log

產生此錯誤的部分如下:

const decoded = new Buffer.from(encoded, 'base64').toString()

Buffer上的from屬性不是構造函數。 這只是一個簡單的方法,所以你不應該使用new 請參閱文檔 你需要:

const decoded = Buffer.from(encoded, 'base64').toString()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM