简体   繁体   English

Eslint/更漂亮的 javascript 文件

[英]Eslint/prettier javascript files

I currently have an issue where eslint and prettier don't do anything on my.js files in VS code.我目前有一个问题,即 eslint 和 prettier 不对 VS 代码中的 my.js 文件执行任何操作。

Here is the content of my.prettierrc:这是 my.prettierrc 的内容:

{
    "singleQuote": true,
    "printWidth": 80,
    "editor.formatOnSave": true,
    "proseWrap": "always",
    "tabWidth": 4,
    "requireConfig": false,
    "useTabs": false,
    "trailingComma": "none",
    "bracketSpacing": true,
    "jsxBracketSameLine": false,
    "semi": true
}

eslintrc: eslintrc:

{
    "parser": "babel-eslint",
    "parserOptions": {
        "sourceType": "module",
        "allowImportExportEverywhere": false,
        "codeFrame": false,
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "extends": ["airbnb", "prettier"],
    "env": { "browser": true, "jest": true },
    "rules": {
        "max-len": ["error", { "code": 100 }],
        "prefer-promise-reject-errors": ["off"],
        "react/jsx-filename-extension": ["off"],
        "react/prop-types": ["warn"],
        "no-return-assign": ["off"],
        "react/jsx-indent": ["error", 4],
        "indent": [4, 4]
    }
}

I tried setting in setting.json我尝试在setting.json中设置

"eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "typescriptreact"
 ]

And nothing seems to work for the javascript file, where everything is ok for jsx files for example. javascript 文件似乎没有任何作用,例如,对于 jsx 文件来说一切正常。

If anyone has an idea on how to fix this issue, thank for you help in advance.如果有人对如何解决此问题有任何想法,请提前感谢您的帮助。

The error was in the eslintrc file错误出现在 eslintrc 文件中

 "indent": ["error", 4],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM