Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-unexpected-multiline rule clashes with Prettier #7005

Closed
denisw opened this issue May 7, 2019 · 5 comments · Fixed by #8039
Closed

no-unexpected-multiline rule clashes with Prettier #7005

denisw opened this issue May 7, 2019 · 5 comments · Fixed by #8039
Milestone

Comments

@denisw
Copy link

denisw commented May 7, 2019

I am using TypeScript, Prettier (1.17.0) and styled-components in a CRA app. When I define the prop types of my styled components inline, I end up with constructs like these:

const Component = styled.div<{
  prop1?: Type;
  prop2?: Type;
}>`
  /* Some styles here... */
`;

The above is the formatting chosen by Prettier. However, CRA's ESLint config doesn't seem to agree:

Line 1:  Unexpected newline between template tag and template literal  no-unexpected-multiline [no-unexpected-multiline]

This means that when I use the pattern above, it is impossible for me to use ESLint and create-react-app together without getting linter errors. It would be cool if the no-unexpected-multiline rule could be either disabled or configured to not trigger in the cases that Prettier creates.

@Hermanya
Copy link

this is crazy annoying, one kind of a workaround I found so far is replacing this

export const Checkbox = styled.input<
  React.HTMLAttributes<HTMLInputElement> & SpaceProps
>``

with this

type Props = React.HTMLAttributes<HTMLInputElement> & SpaceProps;
export const Checkbox = styled.input<Props>``

@stale
Copy link

stale bot commented Jun 30, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jun 30, 2019
@stale stale bot removed the stale label Jun 30, 2019
@bugzpodder bugzpodder added this to the 3.1 milestone Jun 30, 2019
@Garmega
Copy link

Garmega commented Aug 5, 2019

just ran into this issue. had to downgrade below 3.0.0 in order for the linter warning to go away.

@jonmcgill

This comment has been minimized.

@stefatkins
Copy link

stefatkins commented Sep 3, 2019

I added this to my package.json (i'm using typescript)

"eslintConfig": {
    "extends": "react-app",
    "overrides": [
      {
        "files": [
          "**/*.ts?(x)"
        ],
        "rules": {
          "no-unexpected-multiline": 0
        }
      }
    ]
  },

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants