Giter Club home page Giter Club logo

Comments (5)

ArnaudBarre avatar ArnaudBarre commented on June 16, 2024

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.

jameshulse avatar jameshulse commented on June 16, 2024

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.

ArnaudBarre avatar ArnaudBarre commented on June 16, 2024

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.

jameshulse avatar jameshulse commented on June 16, 2024

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.

ArnaudBarre avatar ArnaudBarre commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.