【问题标题】:Do not add new line in Styled Components with Prettier不要在带有 Prettier 的 Styled Components 中添加新行
【发布时间】:2021-08-03 12:14:57
【问题描述】:

我在使用 Prettier 格式化代码时将 React 与 Styled Components 一起使用。让我们有以下代码:

const Component = Styled.div`
    color: green;

    ${props => props.important && `
        font-weight: bold;
    `}
`

这是一个简单样式的组件,使用<Component /> 或<Component important={true} />。但是,当我使用 Prettier 格式化代码时,代码变为:

const Component = Styled.div`
    color: green;

    ${props =>
        props.important &&
        `
        font-weight: bold;
    `}
`

在这种情况下,有什么方法可以设置 Prettier 在=> 和&& 之后不添加换行符?我搜索了Prettier options,但没有找到任何东西。

【问题讨论】:

    标签: javascript format newline styled-components prettier


    【解决方案1】:

    如果您找不到执行此操作的选项here,那么这是不可能的。

    By design - Prettier is not intended to provide a lot of configuration options.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-15
      • 2017-11-18
      • 2018-10-13
      • 2023-03-24
      • 2020-07-20
      • 2021-01-03
      • 2018-12-13
      • 1970-01-01
      相关资源
      最近更新 更多