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

ESLint配置无效报错:.eslintrc.js存在意外顶级属性linebreak-style

ESLint配置错误修复方案

错误原因

报错提示的Unexpected top-level property "linebreak-style"是因为linebreak-style是ESLint的规则项,必须嵌套在配置对象的rules属性内,你当前将其放在了顶级层级,导致配置结构无效。

修复后的.eslintrc.js配置

将linebreak-style移至rules对象中,同时清理配置末尾多余的type here字符,另外移除重复的react/no-unescaped-entities规则:

module.exports = {
  extends: [
    "airbnb-base",
    "plugin:eslint-plugin/recommended",
    "eslint:recommended",
    "plugin:react/recommended",
  ],
  plugins: ["react"],
  rules: {
    "no-restricted-syntax": 0,
    "react/no-unescaped-entities": "off",
    "react/require-default-props": 0,
    "padded-blocks": ["error", "never"],
    "comma-dangle": "off",
    "linebreak-style": ["error", "windows"]
  },
};

额外注意事项

你的package.json中存在eslintConfig字段,同时又使用独立的.eslintrc.js配置文件。在Create React App项目中,独立配置文件会覆盖package.json里的ESLint配置,但如果后续出现规则不生效的情况,可以删除package.json中的eslintConfig节点,确保统一使用.eslintrc.js的配置。

内容的提问来源于stack exchange,提问作者Carmen Adrien

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 08:05:21