简体   繁体   English

如何禁用断线更漂亮

[英]How can I disable break line prettier

My printWidth value is 200 and the like breaking every time for example.例如,我的 printWidth 值是 200 等,每次都会中断。

<Form.Item label="xxx"><Input /></Form.Item>
<Form.Item label="yyy"><Select /></Form.Item>
<Form.Item label="zzzz"><Input /></Form.Item>

When i run in this code block the eslint result is当我在这个代码块中运行时,eslint 结果是

<Form.Item label="xxx">
  <Input />
</Form.Item>
<Form.Item label="yyy">
  <Select />
</Form.Item>
<Form.Item label="zzzz">
  <Input />
</Form.Item>

I don't want to break line if printWidth wasn't max.如果 printWidth 不是最大值,我不想换行。 How can i block it?我怎样才能阻止它?

Eslint rules.埃斯林特规则。

module.exports = {
  extends: ['airbnb-typescript-prettier'],
  parser: '@typescript-eslint/parser',
  "ignorePatterns": ["**/components/global/context_menu/*"],
  rules: {
    "radix": 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    'react/button-has-type': 'off',
    'no-use-before-define': 'off',
    'react/jsx-filename-extension': 'off',
    'react/prop-types': 'off',
    'jsx-a11y/alt-text': 'off',
    'react/jsx-props-no-spreading': 'off',
    'comma-dangle': 'off',
    'consistent-this': [0, 'component'],
    '@typescript-eslint/no-this-alias': 'off',
    'react/forbid-prop-types': 'off',
    'no-self-compare': 'off',
    'react/require-default-props': 'off',
    'no-return-assign': 'off',
    'react/destructuring-assignment': 'off',
    camelcase: 'off',
    "jsx-a11y/label-has-associated-control":"off",
    'prefer-destructuring': 'off',
    'react-hooks/exhaustive-deps':'off',
    'jsx-a11y/click-events-have-key-events':'off',
    'jsx-a11y/no-static-element-interactions':'off',
    'no-throw-literal': 'off',
    'no-mixed-spaces-and-tabs': 'off',
    'no-tabs': 'off',
    'react/no-unescaped-entities': 'off',
    'no-underscore-dangle': 'off',
    'import/no-cycle': 'off',
    'max-len': [2, 150, 2],
  },
};

Prettier rules.更漂亮的规则。

module.exports = {
    singleQuote: true,
    trailingComma: 'all',
    printWidth: 200,
    arrowParens:"always"
  };

If you don't want the prettier to style a part of your code you just need to do this: (that prettier ignore comment)如果您不希望更漂亮的人为您的代码的一部分设置样式,您只需要这样做:(更漂亮的忽略注释)

{/* prettier-ignore */}
<Form.Item label="xxx"><Input /></Form.Item>

this is based on the docs: https://prettier.io/docs/en/ignore.html这是基于文档: https://prettier.io/docs/en/ignore.html

hope this helps希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM