Comments (5)
Hi,
I will mark this as out of scope of this plugin for now because I think this convention is well respected in the ecosystem in general and this is not trivial to add to this plugin.
You can create a rule that look for ArrowFunction as top level node of programs from .jsx
files, and warn if the return part is a JSXContainer (not sure how this last part is easy I've never done it)
Note: technically this is allowed to have function that takes multiple params and return JSX that are not component (but rarely advised)
from eslint-plugin-react-refresh.
Okay fair enough.
I was wondering if the logic would simply match what Vite/react-refresh(?) is looking for: "something exported that isn't pascal case".
So you wouldn't actually check the return type of the function etc - you can assume because it is .jsx that it is a component, but warn on the naming only.
Anyway, if it doesn't make sense for this plugin then that's okay. Thanks.
from eslint-plugin-react-refresh.
Personally it happens for me to have file with some JSX blocks without any components (for example sharing select options between components and one of the field is a callback that return custom JSX rendering)
If you want to make a lint rule that always forbid non pascal case exports in JSX files, starting from this rule and trimming all the unrelated part if probably a good way to get it done
from eslint-plugin-react-refresh.
Personally it happens for me to have file with some JSX blocks without any components (for example sharing select options between components and one of the field is a callback that return custom JSX rendering)
Fair point. But does Vite hot-reloading work in those cases? It felt like it was sensitive to naming, so would break if that's the case?
from eslint-plugin-react-refresh.
The React plugins only try to HMR files that contains Refresh code: https://github.com/vitejs/vite-plugin-react-swc/blob/08b41e98f5526d8bd8203c90c79de22b815ab15a/src/index.ts#L113
So normally in that case Babel/SWC should not found anything that could be a React function, so not injecting any React refresh boilerplate and the file will behave like any non TSX file (ie bubble HMR to all the component that imports it)
from eslint-plugin-react-refresh.
Related Issues (20)
- Allow `export type * from '...'` HOT 2
- Warning triggered for component using forwardRef HOT 7
- Support for constant objects? HOT 3
- 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 13
- 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
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.