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

Support for custom JSX renderer #894

Open
lionel-bijaoui opened this issue Sep 16, 2022 · 3 comments
Open

Support for custom JSX renderer #894

lionel-bijaoui opened this issue Sep 16, 2022 · 3 comments

Comments

@lionel-bijaoui
Copy link

Hello,
I have created a custom JSX renderer that take JSX code and output HTML.
This custom implementation doesn't use that exact same keyword.
For example, I use "class" instead of "className" and "for" instead of "htmlFor".

I noticed that there is a certain level of customization for the rules, can it be opened to support my needs, or do you want to strictly adhere to React implementation ?

I'm open to do the PR if needed.
Thank you very much for your time.

@ljharb
Copy link
Member

ljharb commented Sep 16, 2022

While eslint-plugin-react has settings for custom jsx renderers, this plugin does not.

While we could add settings to map react jsx prop names to custom prop names, that's a lot of complexity to add for what feels like a very unwise use case.

Can you elaborate on why you think deviating from the overwhelmingly defacto standard is worth it?

@lionel-bijaoui
Copy link
Author

Ok, I will try to list some arguments, I hope this is enough to convince you of this need :

  1. While JSX was created by React, its specs does not force to use the same attributes as React. That would limit the use and scope of JSX.
  2. By this logic, every JSX system allow for custom renderers (typescript, babel, etc.). If JSX was limited to use with React, that would not be the case.
  3. Preact use slightly different attributes conventions than React. While React wished to adapt the HTML to be compatible with JS, Preact choose to more closely follow the HTML. I have chosen the same way, since my team is more accustomed to working with HTML, and our existing template use HTML syntax. Why call for as forHTML, or class as className ? How is this a standard compared to HTML ?
  4. If this plugin was called eslint-plugin-react-jsx-a11y I would agree that my demand made no sense, but the fact that eslint-plugin-react support custom jsx renderers, I see little reason why not (if not the complexity, which I understand of course and I not trying to underestimate it).

Again, I understand that this if fairly complex, but I don't think that is is completely out of the scope of this plugin. I willing to help, since I'm very curious about writing custom eslint rules and better understanding AST.

Anyway, thank you for your time and allowing me to state my reasoning. I hope this is enough, but if this is not, I understand and thank you for your work on this plugin raising awareness on a11y.

@ljharb
Copy link
Member

ljharb commented Sep 19, 2022

Because for and class are reserved words, so you can’t destructure into those variable names.

I hear your arguments, and it’s worth thinking about.

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

No branches or pull requests

2 participants