我刚刚在我的项目中配置了 eslint 和 prettier,并为 max len 设置了一个规则。但它没有按预期工作。我想在超过 120 个字符时换行。它确实会换行,但仅当字符长度超过 135 个字符时。
我的配置文件: eslintrc
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"],
"plugins": ["import", "react", "prettier"],
"rules": {
"react/jsx-uses-react": 2,
"react/react-in-jsx-scope": "off",
"prettier/prettier": "error",
"camelcase": "off",
"import/prefer-default-export": "off",
"react/prop-types": "off",
"react/jsx-filename-extension": "off",
"react/jsx-props-no-spreading": "off",
"react/no-unused-prop-types": "off",
"react/require-default-props": "off",
"quotes": "off",
"no-unused-vars": "warn",
"no-console": "warn",
"max-len": ["error", { "code": 120, "ignoreUrls": true, "ignoreRegExpLiterals": true }]
}
更漂亮的
{
"trailingComma": "all",
"singleQuote": true,
"tabWidth": 2,
"printWidth": 120,
"proseWrap": "preserve",
"useTabs": true,
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "auto"
}