elsint报错Delete `␍`eslintprettier/prettier

打印 上一主题 下一主题

主题 912|帖子 912|积分 2736

一,原因

这篇博客写得很清晰:解决VSCode Delete `␍`eslint(prettier/prettier)错误_vscode 删除cr-CSDN博客
还有这篇文章,解决办法很详细:滑动验证页面
二,解决办法

根目录下新建.prettierrc.js文件
  1. module.exports = {
  2.   trailingComma: "all", // 设置是否末尾添加逗号的字段
  3.   arrowParens: "avoid", //箭头函数参数括号,avoid 能省略括号的时候就省略
  4.   useEditorConfig: false,
  5.   endOfLine: "auto", //避免报错delete (cr)的错
  6.   bracketSameLine: true,
  7.   jsxSingleQuote: true,
  8.   singleQuote: false, // 格式化以单引号为主
  9.   semi: true, // 格式化不加分号
  10.   printWidth: 300,
  11. };
复制代码
根目录下.eslintrc.js文件(可以不配置)
  1. module.exports = {
  2.   env: {
  3.     browser: true,
  4.     es6: true,
  5.     node: true,
  6.   },
  7.   extends: [
  8.     "plugin:vue/essential",
  9.     "airbnb-base",
  10.     "plugin:prettier/recommended", //这样写,让pettier的规则,放在eslint规则扩展中,于是会经由eslint报错
  11.   ],
  12.   globals: {
  13.     Atomics: "readonly",
  14.     SharedArrayBuffer: "readonly",
  15.   },
  16.   parserOptions: {
  17.     ecmaVersion: 2018,
  18.     sourceType: "module",
  19.   },
  20.   plugins: ["vue"],
  21.   rules: {
  22.     quotes: [2, "double"], //警告,必须双引号
  23.     "no-compare-neg-zero": 2, //禁止与 -0 进行比较
  24.     "no-cond-assign": [2, "except-parens"], //禁止条件语句中出现赋值操作符
  25.     "no-console": 0, //允许出现console
  26.     "no-constant-condition": 2, //禁止在条件中使用常量表达式
  27.     "no-control-regex": 2, //禁止在正则表达式中使用控制字符
  28.     "no-debugger": 0, //可以使用debugger
  29.     "no-dupe-args": 2, //禁止 function 定义中出现重名参数
  30.     "no-dupe-keys": 2, //禁止对象字面量中出现重复的 key
  31.     "no-duplicate-case": 2, //禁止出现重复的 case 标签
  32.     "no-empty": 2, //禁止出现空语句块
  33.     "no-empty-character-class": 2, //禁止在正则表达式中使用空字符集
  34.     "no-ex-assign": 2, //禁止对 catch 子句的参数重新赋值
  35.     "no-extra-boolean-cast": 2, //禁止不必要的布尔转换
  36.     "no-extra-parens": ["error", "functions"], //禁止不必要的括号
  37.     "no-extra-semi": 2, //禁止不必要的分号
  38.     "no-func-assign": 2, //禁止对 function 声明重新赋值
  39.     "no-inner-declarations": 0, //禁止在嵌套的块中出现变量声明或 function 声明
  40.     "no-invalid-regexp": 2, //禁止 RegExp 构造函数中存在无效的正则表达式字符串
  41.     "no-irregular-whitespace": 2, //禁止不规则的空白
  42.     "no-obj-calls": 2, //禁止把全局对象作为函数调用
  43.     "no-prototype-builtins": 2, //禁止直接调用 Object.prototypes 的内置属性
  44.     "no-regex-spaces": 2, //禁止正则表达式字面量中出现多个空格
  45.     "no-sparse-arrays": 2, //禁用稀疏数组
  46.     "no-template-curly-in-string": 0, //禁止在常规字符串中出现模板字面量占位符语法
  47.     "no-unexpected-multiline": 2, //禁止出现令人困惑的多行表达式
  48.     "no-unreachable": 2, //禁止在 return、throw、continue 和 break 语句之后出现不可达代码
  49.     "no-unsafe-finally": 2, //禁止在 finally 语句块中出现控制流语句
  50.     "no-unsafe-negation": 2, //禁止对关系运算符的左操作数使用否定操作符
  51.     "use-isnan": 2, //要求使用 isNaN() 检查 NaN
  52.     "valid-jsdoc": "off", //
  53.     "valid-typeof": 2, //强制 typeof 表达式与有效的字符串进行比较
  54.     curly: 2, //强制所有控制语句使用一致的括号风格
  55.     "consistent-return": [
  56.       2,
  57.       {
  58.         treatUndefinedAsUnspecified: true,
  59.       },
  60.     ],
  61.     "default-case": 2,
  62.     eqeqeq: "off",
  63.     "guard-for-in": 0,
  64.     "no-case-declarations": 0,
  65.     "no-empty-pattern": 2,
  66.     "no-fallthrough": 2,
  67.     "no-global-assign": [
  68.       2,
  69.       {
  70.         exceptions: [],
  71.       },
  72.     ],
  73.     "no-octal": 2,
  74.     "no-redeclare": 2,
  75.     "no-self-assign": 2,
  76.     "no-unused-labels": 2,
  77.     "no-useless-escape": 2,
  78.     strict: 2,
  79.     "no-delete-var": 2,
  80.     "no-undefined": 0,
  81.     "no-undef": 2,
  82.     "no-use-before-define": 2,
  83.     "array-bracket-spacing": [2, "never"],
  84.     "block-spacing": [2, "always"],
  85.     "brace-style": [2, "1tbs"],
  86.     "comma-dangle": ["error", "never"],
  87.     "comma-spacing": [
  88.       2,
  89.       {
  90.         before: false,
  91.         after: true,
  92.       },
  93.     ],
  94.     "comma-style": [2, "last"],
  95.     "computed-property-spacing": ["error", "never"],
  96.     "eol-last": [2, "always"],
  97.     "func-call-spacing": ["error", "never"],
  98.     indent: [
  99.       "error",
  100.       2,
  101.       {
  102.         SwitchCase: 1,
  103.       },
  104.     ],
  105.     "jsx-quotes": ["error", "prefer-double"],
  106.     "key-spacing": [
  107.       "error",
  108.       {
  109.         beforeColon: false,
  110.         afterColon: true,
  111.       },
  112.     ],
  113.     "new-cap": [
  114.       "error",
  115.       {
  116.         newIsCap: true,
  117.         capIsNewExceptionPattern: "(Type[a-zA-Z0-9]+|Deco[a-zA-Z0-9]+)+",
  118.       },
  119.     ],
  120.     "new-parens": "error",
  121.     "no-mixed-spaces-and-tabs": 2,
  122.     "no-multi-assign": "error",
  123.     "no-multiple-empty-lines": "error",
  124.     semi: [
  125.       2,
  126.       "always",
  127.       {
  128.         omitLastInOneLineBlock: true,
  129.       },
  130.     ],
  131.     "constructor-super": 2,
  132.     "no-class-assign": 0,
  133.     "no-const-assign": 2,
  134.     "no-this-before-super": 2,
  135.     "no-var": 2,
  136.     "no-dupe-class-members": 2,
  137.     "no-new-symbol": 2,
  138.     "require-yield": 2,
  139.     "prefer-const": 0,
  140.   },
  141. };
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

尚未崩坏

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表