Closed mjomble closed 2 months ago
Maybe something like this:
export const Button = ...
// For Fractal
export default Button
Although the rule mainly talks about exports, the benefit of consistency mostly comes out in the import code blocks.
Yup, totally agree. Additionally, exporting everything as named makes it easier to re-export things in an index file (when building a library) - you can do export * from './my/module';
instead of having to re-export the default export separately.
The issue is that if we want to enforce this with an ESLint rule, we need to either disable it for React projects or disable it line-by-line where necessary, neither of which is too nice.
Maybe for React projects we could disable the rule only in src/patterns
, but still use it in src/app
and elsewhere.
An issue here is our usage of Fractal in our React projects, where Fractal's React adapter looks for a default export in a component template file in order to know what to render. Not sure if there are better solutions than just overriding this rule for React, but maybe you have some ideas?