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

Automatic file validation for components in src/pages #3045

Closed
calcsam opened this issue Nov 27, 2017 · 9 comments
Closed

Automatic file validation for components in src/pages #3045

calcsam opened this issue Nov 27, 2017 · 9 comments
Labels
good first issue Issue that doesn't require previous experience with Gatsby

Comments

@calcsam
Copy link
Contributor

calcsam commented Nov 27, 2017

Add regex validation to make sure files in src/pages export React components. Throw error otherwise. Programmatically enforce language in the docs: #3011

A cheap way of doing this is to make sure files contain at least two statements:

(1) an uppercase React
(2) export default or module.exports

@calcsam calcsam added the good first issue Issue that doesn't require previous experience with Gatsby label Nov 27, 2017
@calcsam calcsam changed the title Automatic file validation for Automatic file validation for components in src/pages Nov 27, 2017
@benjaminhoffman
Copy link
Contributor

I believe they can export a string too and still be valid.

@ppatel221
Copy link

Hey if no one is assigned to this, can I take over?

@benjaminhoffman
Copy link
Contributor

@ppatel221 sure go ahead! be sure to update this issue and/or reference it in your PR as you make progress

@calcsam
Copy link
Contributor Author

calcsam commented Dec 8, 2017

thanks @ppatel221!

@mhd-sln
Copy link
Contributor

mhd-sln commented Jan 26, 2018

@calcsam : If @ppatel221 isnt planning to do this, I would like to give it a shot

@benjaminhoffman
Copy link
Contributor

@salmanmanekia yeah! Give it a shot. This would be super helpful for gatsby newbs. This bug created an issue for me in the beginning. Keep in mind that non-js files should be okay. (ie, data.json or styles.css that live within /src/pages should be excluded from this check.

@mhd-sln
Copy link
Contributor

mhd-sln commented Jan 27, 2018

Thanks @benjaminhoffman. I will start with this. In the meanwhile can you please explain what do you meant by

'I believe they can export a string too and still be valid.'

Also, any hints on where to start looking to fix this problem. I am new to gatsby.

@benjaminhoffman
Copy link
Contributor

My apologies, I may have been mistaken. The official error I get is A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

So I guess you want to check for either a react element or null.

@calcsam may know where to start looking to fix this.

@mhd-sln
Copy link
Contributor

mhd-sln commented Feb 10, 2018

Closed with #3881 and #3949

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants