首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“修复所有可自动修复的问题”没有尽可能多地修复vscode-eslint问题。

“修复所有可自动修复的问题”没有尽可能多地修复vscode-eslint问题。
EN

Stack Overflow用户
提问于 2018-09-13 23:07:10
回答 3查看 20.2K关注 0票数 9

通常情况下,当我试图在Javascript文件上运行时,修复所有可自动修复的问题命令时,这个应用程序会进入一个不停地移动选项卡/空格的循环,但永远不会感到满意:

我的.eslintrc.js如下:

代码语言:javascript
复制
const fs = require('fs');

const prettierOptions = JSON.parse(fs.readFileSync('./.prettierrc', 'utf8'));

module.exports = {
  parser: 'babel-eslint',
  extends: ['airbnb', 'prettier', 'prettier/react'],
  plugins: ['prettier', 'redux-saga', 'react', 'jsx-a11y'],
  env: {
    browser: true,
    node: true,
    jest: true,
    es6: true,
  },
  parserOptions: {
    ecmaVersion: 6,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
    },
  },
  rules: {
    'prettier/prettier': ['error', prettierOptions],
    'arrow-body-style': [2, 'as-needed'],
    'class-methods-use-this': 0,
    'comma-dangle': [2, 'always-multiline'],
    'import/imports-first': 0,
    'import/newline-after-import': 0,
    'import/no-dynamic-require': 0,
    'import/no-extraneous-dependencies': 0,
    'import/no-named-as-default': 0,
    'import/no-unresolved': 2,
    'import/no-webpack-loader-syntax': 0,
    'import/prefer-default-export': 0,
    indent: [
      2,
      2,
      {
        SwitchCase: 1,
      },
    ],
    "jsx-a11y/anchor-is-valid": 0,
    'jsx-a11y/aria-props': 2,
    'jsx-a11y/heading-has-content': 0,
    'jsx-a11y/label-has-for': 2,
    'jsx-a11y/mouse-events-have-key-events': 2,
    'jsx-a11y/role-has-required-aria-props': 2,
    'jsx-a11y/role-supports-aria-props': 2,
    'max-len': 0,
    'newline-per-chained-call': 0,
    'no-confusing-arrow': 0,
    'no-console': 1,
    'no-use-before-define': 0,
    'prefer-template': 2,
    'react/jsx-closing-tag-location': 0,
    'react/forbid-prop-types': 0,
    'react/jsx-first-prop-new-line': [2, 'multiline'],
    'react/jsx-filename-extension': 0,
    'react/jsx-no-target-blank': 0,
    'react/require-default-props': 0,
    'react/require-extension': 0,
    'react/self-closing-comp': 0,
    'react/sort-comp': 0,
    'redux-saga/no-yield-in-race': 2,
    'redux-saga/yield-effects': 2,
    'require-yield': 0,
  },
  settings: {
    'import/resolver': {
      webpack: {
        config: './internals/webpack/webpack.prod.babel.js',
      },
    },
  },
};

有人能帮我解决这个问题吗?

EN

回答 3

Stack Overflow用户

发布于 2018-11-08 21:11:07

UPD:

现在您只需选择vscode-eslint / prettier作为默认的格式化程序,它应该在一次传递中格式化文件:

  1. ctrl + shift + p
  2. 选择Format document with...
  3. 选择Configure default foramtter
  4. 选择您喜欢的格式化程序

由于vscode格式API的限制,这是vscode-eslint扩展中的老问题。一个可能的解决方案是通过cli修复代码:

代码语言:javascript
复制
eslint --fix
票数 7
EN

Stack Overflow用户

发布于 2020-01-14 02:50:47

在Save上安装extension格式,然后在Save > Enter上按CMD+SHIFT+P类型的Toggle格式。

希望能帮上忙

票数 0
EN

Stack Overflow用户

发布于 2022-05-16 12:22:11

简单修复:在VS代码中打开setting.json文件并放置"editor.formatOnSave": true,。这将自动修复保存。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52322892

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档