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

[jsx-filename-extension]: option to allow empty files #3644

Closed
silverwind opened this issue Oct 17, 2023 · 6 comments · Fixed by #3674
Closed

[jsx-filename-extension]: option to allow empty files #3644

silverwind opened this issue Oct 17, 2023 · 6 comments · Fixed by #3674

Comments

@silverwind
Copy link
Contributor

Given the config

rules:
  react/jsx-filename-extension: [2, {allow: as-needed]}]

a file that is empty or contains only comments triggers the rule, for example a .jsx file with:

// Put your components here

I think a option to allow empty files when as-needed is specified would be ideal for this use case, not sure whether it should be the default, but I think it could be.

@silverwind silverwind changed the title jsx-filename-extension option to allow empty files [jsx-filename-extension]: option to allow empty files Oct 17, 2023
@ljharb
Copy link
Member

ljharb commented Oct 19, 2023

Why? That would mean that as soon as you add code to it, you might get an error that forces you to rename it.

@silverwind
Copy link
Contributor Author

silverwind commented Oct 19, 2023

The intention is that this empty file serves as a placeholder and is populated with JSX content later. If the user adds only non-JSX content, the error is justified and the file must be renamed.

@ljharb
Copy link
Member

ljharb commented Oct 19, 2023

ohhh, i see - you want it to be .jsx but the rule is saying it's not needed and warning on it?

@silverwind
Copy link
Contributor Author

silverwind commented Oct 19, 2023

Yes exactly. A empty file is kind of an edge case for such on-demand .jsx extension.

@ljharb
Copy link
Member

ljharb commented Oct 19, 2023

then yes, i think an additional option that ignores empty files would be reasonable.

@silverwind
Copy link
Contributor Author

Okay, maybe I'll look into implementing it if it's not too hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants