首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >typescript-eslint: how to lint React props to newline

typescript-eslint: how to lint React props to newline
EN

Stack Overflow用户
提问于 2021-04-16 03:38:53
回答 1查看 86关注 0票数 0

我正在尝试添加一条将长React属性值拆分成新行的内联规则。下面的示例显示了属性paragraph是超长的,我不知道如何对其进行内联以使其换成新行。

代码语言:javascript
复制
<Card
  header="General Contractors, Engineering Procurement Providers, Prime Contractors"
  id="gen-contractor"
  paragraph={`Construction companies that build pipelines. While these companies may provide many services "in-house", they often sub-contract work that requires special equipment or
know-how`}
  onCardToggle={(isChecked) => console.log('isChecked', isChecked)}
/>

这是我的.eslintrc.json

代码语言:javascript
复制
{
  "extends": ["airbnb-typescript"],
  "env": {
    "jest": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "tsconfig.json",
    "sourceType": "module"
  },
  "plugins": ["@typescript-eslint/eslint-plugin"],
  "rules": {
    "@typescript-eslint/indent": "off",
    "react/jsx-one-expression-per-line": 0,
    "react/prop-types": 0,
    "react/require-default-props": "off",
    "react/destructuring-assignment": 0,
    "react/static-property-placement": 0,
    "jsx-a11y/alt-text": 0,
    "react/jsx-props-no-spreading": 0,
    "import/prefer-default-export": 0,
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/explicit-module-boundary-types": "off",
    "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
    "object-curly-newline": "off",
    "operator-linebreak": [
      "error",
      "before",
      { "overrides": { "=": "after" } }
    ],
    "implicit-arrow-linebreak": 0,
    "no-confusing-arrow": 0
  },
  "ignorePatterns": ["node_modules/", ".next/", ".eslintrc.json"]
}

这是我的.prettierrc

代码语言:javascript
复制
{
  "singleQuote": true,
  "trailingComma": "all"
}

下面是我的devDependencies中所有与linting相关的依赖项

代码语言:javascript
复制
"devDependencies": {
    "@babel/core": "^7.13.14",
    "@typescript-eslint/eslint-plugin": "^4.21.0",
    "@typescript-eslint/parser": "^4.21.0",
    "@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
    "autoprefixer": "^10.2.5",
    "babel-loader": "^8.2.2",
    "babel-plugin-module-resolver": "^4.1.0",
    "eslint": "^7.23.0",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.23.1",
    "eslint-plugin-react-hooks": "^4.2.0",
    "prettier": "^2.2.1",
  }
EN

回答 1

Stack Overflow用户

发布于 2021-04-19 04:05:00

对于诸如“我如何才能让我的代码更漂亮,以这样一种方式格式化我的代码……?”这样的问题的通用答案?就是“你不能”

Prettier的目的是通过关注代码样式来促进项目和团队中的协作,而不是成为一个可定制的代码格式化程序,可以随心所欲地做任何事情。换句话说,它产生的格式不是真正可定制的,这是有意为之的。点击此处阅读更多信息:https://prettier.io/docs/en/option-philosophy.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67115047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档