You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ESLint lint fix时遇`splitter ??= new graphemer_1.default();`错误求助

解决方案

你遇到的错误是因为ESLint未识别??=(空值合并赋值运算符)语法,该语法属于ES2020标准,需确保ESLint配置正确支持对应ECMAScript版本。以下是具体修复步骤:

  • 检查.eslintrc.json的parserOptions配置,将ecmaVersion设为2020或更高:

    {
      "parserOptions": {
        "ecmaVersion": 2020,
        "sourceType": "module"
      }
    }
    
  • 若为TypeScript项目,确认使用@typescript-eslint/parser作为解析器,并完善配置:

    {
      "parser": "@typescript-eslint/parser",
      "parserOptions": {
        "ecmaVersion": 2020,
        "sourceType": "module",
        "project": "./tsconfig.json"
      }
    }
    
  • 更新ESLint及相关依赖到最新稳定版,确保版本兼容性:

    npm update eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
    
  • 检查tsconfig.json的target字段,至少设置为ES2020以支持该语法编译:

    {
      "compilerOptions": {
        "target": "ES2020"
      }
    }
    

调整完成后重新运行npm run lint或npm run lint:fix,再尝试Git提交即可。

内容的提问来源于stack exchange,提问作者Purvi Vichhi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 16:28:12