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

react-ssr-friendly #209

Closed
cyberhck opened this issue Feb 27, 2019 · 3 comments
Closed

react-ssr-friendly #209

cyberhck opened this issue Feb 27, 2019 · 3 comments

Comments

@cyberhck
Copy link

Rule Suggestion

Is your rule for a general problem or is it specific to your development style?
This is a general purpose rule which actually should be enabled by default IMO (but that can be discussed later)

What does your suggested rule do?
It should check few methods in react projects, constructor, getDerivedStateFromProps, componentWillMount (deprecated), render (maybe more? We can list them later), and see if the code will be able to run in node env, it won't be perfect, but can we blacklist few things to be used there.

Example would include: document, window, localStorage (other types of browser storage etc)

List several examples where your rule could be used
I could enable this rule and later if project decides to use server side rendering, thanks to this rule, we'd have avoided those refactoring awkwardness.

Additional context
Not sure entirely, I've not written a lot of rules (just maybe around 3-4), let's discuss and see if we can proceed, if I get some time, I could also send a PR.

@JoshuaKGoldberg
Copy link

👋 @cyberhck, great idea! But: this repository is just for core rules that aren't tied to particular frameworks. You'll want to file a request in tslint-react, or failing that, eslint-plugin-react.

You could also publish this as a standalone package on npm if you don't want to be tied into their release cycles.

@cyberhck
Copy link
Author

cyberhck commented Mar 3, 2019

can we move this issue to maybe tslint-react? since it's same organization, I think there's a feature to do that now in gh

@adidahiya adidahiya transferred this issue from palantir/tslint Mar 3, 2019
@adidahiya adidahiya reopened this Mar 3, 2019
@adidahiya
Copy link
Contributor

Sounds like a good idea, but I would suggest making this an ESLint ruleset instead. See #210

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

3 participants