prettier-standard icon indicating copy to clipboard operation
prettier-standard copied to clipboard

conflict with react/jsx-curly-newline

Open havenchyk opened this issue 4 years ago • 5 comments

Hey @sheerun, I came across some conflict between prettier-standard and eslint with standard and standard-jsx presets included.

Example:

const A: React.FC = ({ children }) => <div>{children}</div>
const B: React.FC<{ onDelete: () => void }> = ({ children }) => (
  <div>{children}</div>
)

const MyComponent: FunctionComponent = () => {
  const someLongMethodHandlerName = (obj: {
    parameter1: string
    parameter2: string
  }) => {}

  return (
    <A>
      <B
        onDelete={() =>
          someLongMethodHandlerName({
            parameter1: 'parameter1',
            parameter2: 'parameter2'
          })
        }
      >
        B
      </B>
    </A>
  )
}

^^ this is how prettier-standard formats the code,

but eslint with standard and standard-jsx presets expects the next version

const A: React.FC = ({ children }) => <div>{children}</div>
const B: React.FC<{ onDelete: () => void }> = ({ children }) => (
  <div>{children}</div>
)

const MyComponent: FunctionComponent = () => {
  const someLongMethodHandlerName = (obj: {
    parameter1: string
    parameter2: string
  }) => {}

  return (
    <A>
      <B
        onDelete={() =>
          someLongMethodHandlerName({
            parameter1: 'parameter1',
            parameter2: 'parameter2'
-         })
-       }
+ .       })}
      >
        B
      </B>
    </A>
  )
}

Is it some expected behaviour or is it a bug? If you need any other information, please let me know.

havenchyk avatar Nov 30 '19 20:11 havenchyk

prettier-standard version looks better to me :) I'd consider it the bug in standard the same way as #76

sheerun avatar Nov 30 '19 20:11 sheerun

@sheerun do you mean in standard-jsx? could you please help with issue description I need to create in standard-jsx?

havenchyk avatar Dec 01 '19 08:12 havenchyk

Yes. Maybe you can try it first? Just describe this formatting in standard-jsx and show prettier-standard formatting

On Sun, 1 Dec 2019 at 09:44, Uladzimir Havenchyk [email protected] wrote:

@sheerun https://github.com/sheerun do you mean in standard-jsx? could you please help with issue description I need to create in standard-jsx?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sheerun/prettier-standard/issues/91?email_source=notifications&email_token=AACHMDPYUOPYRXZ6ZF3XSKDQWN2PFA5CNFSM4JTIFO6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFRBUCY#issuecomment-560077323, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACHMDNFY4H7IIYXEDVNH33QWN2PFANCNFSM4JTIFO6A .

sheerun avatar Dec 01 '19 11:12 sheerun

btw. prettier-standard has linting built-in that disables whitespace rules, just use --lint flag

sheerun avatar Dec 01 '19 16:12 sheerun

yeah, I used it, but I have other project specific rules which are not related to formatting, so I need to use eslint as a pre-step.

submitted https://github.com/standard/standard/issues/1458

havenchyk avatar Dec 01 '19 20:12 havenchyk