Comments (3)
I though about it during the implementation but this is very complex to handle if the objet contains reference to other variables. In the case of constant object like this, this should be possible, I will see what I can do (I need to work on upcoming Vite 4.4, so in a few weeks)
from eslint-plugin-react-refresh.
So I took a look at this and actually this would be very difficult to do because to be safe the object needs to never be updated from inside the module like this:
export const documentProps = {
// This title and description will override the defaults
title: 'About SpaceX',
description: 'Our mission is to explore the galaxy.'
}
documentProps.title = "About NASA"
In that case the importers will still get the reference to the old export which will not received the modifications.
While this is feasible with static analysis, it's complex and this will need to also be done when transforming the React components. The second part is too independant of the plugin and complex if using SWC, so for now I'm on the side of making this pattern incompatible with FastRefresh.
If you have only two properties to export, is it feasible to have two string export? Is this documentProps coming from a framework?
Other idea that can be explored:
- naming conventions: making exceptions for ALL_UPPERCASES object exports or adding a suffix to the object name
- using an custom prop as a marker like
__refreshStable: true
to opt-in into a potential stale export
from eslint-plugin-react-refresh.
I use it for e.g. exporting meta data per page. In this case it would be feasible, and also possible to refactor the "problem" away.
Regarding the other ideas: if you think about tackling the issue, my feeling would be that it should work "natively".
Thanks for looking into it.
from eslint-plugin-react-refresh.
Related Issues (20)
- Warning is not appearing for enums HOT 1
- Fast Refresh and Hooks HOT 1
- Throwing error for typescript type exports. HOT 2
- Correct use with Context API and Vite - docs missing? HOT 2
- Consider not warning on `export *` when re-exported file is passing HOT 5
- Lazy Loading react component get some warning HOT 14
- Capitalized non-function not triggering rule HOT 2
- Possible false-positive with memo default export HOT 4
- Please add better description what it does HOT 2
- Add option for allowList of export names HOT 3
- False positives in v0.4.4 HOT 12
- How to use in flat config HOT 1
- Support for styled components HOT 1
- Warn exports instead of components when using only components HOT 3
- How to configure your plugin to work with a Vite+React project? HOT 2
- Possible false positive/negative HOT 1
- Allow constant exports doesn't work with objects. HOT 3
- Question about potential problems with barrel files HOT 1
- Bug: ts declaration types are not shipped with the package HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-react-refresh.