仅删除TS/TSX文件的CR-VSCode 1.46上更漂亮的ESLint [英] Delete CR only for TS/TSX files - Prettier ESLint on VSCode 1.46

查看:20
本文介绍了仅删除TS/TSX文件的CR-VSCode 1.46上更漂亮的ESLint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Create Reaction应用程序的类型脚本模板创建了一个Reaction项目,为ESLint6.8.0添加了必要的插件,并一起配置了ESLint和␍⏎␍⏎,但每当我编辑.ts.tsx文件时,我收到ESLint错误Delete ESLint``

我在VSCode中安装了ESLint和更漂亮的扩展

我在SO上查看了其他各种帖子,我尝试了上面提到的大多数设置,

我已将此添加到我的.eslintrc.json文件

"prettier/prettier": [
    "error",
    {
        "endOfLine": "auto"
    },
    { "usePrettierrc": true }
],

这是我的.prettierrc

{
    "trailingComma": "es5",
    "tabWidth": 2,
    "useTabs": true,
    "semi": true,
    "singleQuote": true,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "endOfLine": "auto"
}

但每当我在.ts/.tsx文件中创建新行时仍收到LINT错误

我将VSCode设置中的所有内容都更改为使用CRLF(我在Windows上)和"files.eol": " ",

即使我尝试使用不同的行尾,也会收到类似的错误。

如果我这样做

"prettier/prettier": [
    "error",
    {
        "endOfLine": "lf"
    },
    { "usePrettierrc": true }
],

如果我设置endOfLine : crlf,它与AUTO的错误相同!

这里值得的是我的整个.eslintrc.json

{
    "env": {
        "browser": true,
        "es6": true,
        "jest": true
    },
    "extends": [
        "standard",
        "plugin:react/recommended",
        "plugin:@typescript-eslint/recommended",
        "prettier/@typescript-eslint",
        "plugin:prettier/recommended",
        "plugin:jsx-a11y/recommended"
    ],
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly",
        "__DEV__": "readonly"
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "project": "tsconfig.json",
        "tsconfigRootDir": "."
    },
    "plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"],
    "rules": {
        "camelcase": "off",
        "no-unused-expressions": "off",
        "react/prop-types": "off",
        "react/jsx-one-expression-per-line": "off",
        "react-hooks/rules-of-hooks": "error",
        "react-hooks/exhaustive-deps": "warn",
        "react/jsx-filename-extension": [
            1,
            {
                "extensions": [".tsx"]
            }
        ],
        "@typescript-eslint/no-unused-vars": [
            "error",
            {
                "argsIgnorePattern": "_"
            }
        ],
        "@typescript-eslint/explicit-function-return-type": [
            "error",
            {
                "allowExpressions": true
            }
        ],

        // Remove after
        "@typescript-eslint/no-empty-interface": "off",
        "jsx-a11y/no-static-element-interactions": "off",
        "jsx-a11y/click-events-have-key-events": "off",
        "prettier/prettier": [
            "error",
            {
                "endOfLine": "crlf"
            },
            { "usePrettierrc": true }
        ],

        // Remove After

        "jsx-quotes": "warn",
        "import/prefer-default-export": "off",
        "import/extensions": [
            "error",
            "ignorePackages",
            {
                "ts": "never",
                "tsx": "never"
            }
        ]
    },
    "settings": {
        "import/resolver": {
            "typescript": {}
        },
        "react": {
            "version": "detect"
        }
    }
}

推荐答案

由于此帖子获得了一些流量,我通过将此规则添加到我的eslint配置中解决了此问题

rules: {
    'prettier/prettier': ['off', { singleQuote: true }],
}
此处的关键部分是'off',当您将其设置为'error'时,默认情况下会显示此错误。将其设置为OFF将禁用该检查。

这篇关于仅删除TS/TSX文件的CR-VSCode 1.46上更漂亮的ESLint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆