Skip to content
New issue

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

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

Already on GitHub? # to your account

'jsx-newline' add ignore options #2926

Closed
RaddishIoW opened this issue Feb 17, 2021 · 7 comments
Closed

'jsx-newline' add ignore options #2926

RaddishIoW opened this issue Feb 17, 2021 · 7 comments

Comments

@RaddishIoW
Copy link

I have the jsx-newline rule turned on, but it causes problems with any {/* eslint-disable-next-line <rulename> */} comments in my code.

If I have the following:

{/* eslint-disable-next-line react/forbid-component-props */}
<Button popoverOpen='#settings-popover' style={{ width: 'fit-content' }}>
  <Icon f7='gear' />
</Button>

jsx-newline marks the <Button ...> line as needing a newline before, causing the ignore-next-line comment to stop working.

Would it be possible to add options to the jsx-newline rule, to allow ignoring?
e.g.

"react/jsx-newline": {
    2,
    { "ignore": [ '{/* */}'] }
}
@ljharb
Copy link
Member

ljharb commented Feb 17, 2021

I'd say an ignoreComments option would be reasonable.

ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Feb 22, 2022
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Feb 22, 2022
@ljharb ljharb closed this as completed in 0218e61 Feb 22, 2022
@Sreejit7
Copy link

is this not added to the plugin yet? we have a similar problem in our repo, and looking for a fix 👀

@ljharb
Copy link
Member

ljharb commented Nov 1, 2022

@Sreejit7 the tests pass, so it should already be fixed. If you're fully updated and still seeing problems, please file a new issue.

@jacob-orbiit
Copy link

@ljharb was ignore comments added to options? If so, it's not documented: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md#rule-options

@ljharb
Copy link
Member

ljharb commented Nov 17, 2022

@jacob-orbiit looks like it's not. want to make a PR to document it?

@jacob-orbiit
Copy link

jacob-orbiit commented Nov 18, 2022

Actually, I just tried to use it, and eslint throws that it's not recognised.

(Otherwise, sure, happy to put together a PR to update the docs)

@ljharb
Copy link
Member

ljharb commented Nov 18, 2022

@jacob-orbiit ahhh no, we didn't end up adding the option, because it wasn't needed - we just fixed the detection.

# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

4 participants