jsx-eslint/eslint-plugin-react

[react/jsx-fragments] Enforce <Fragment>

Open

#2 420 ouverte le 26 sept. 2019

Voir sur GitHub
 (7 commentaires) (12 réactions) (0 assignés)JavaScript (2 797 forks)batch import
help wantednew rule

Métriques du dépôt

Stars
 (8 630 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

I would like to enforce using <Fragment>...</Fragment> instead of <React.Fragment>...</React.Fragment>. The fix option would mean to also add it to the imports if it hasn't been already.

So these would be a warning:

import React from 'react';

export default Component = () => (
    <>Foo</>
);
import React from 'react';

export default Component = () => (
    <React.Fragment>Foo</React.Fragment>
);

This would be the fix: (and should be fixable with --fix)

import React, { Fragment } from 'react';

export default Component = () => (
    <Fragment>Foo</Fragment>
);

Is this achievable?

Guide contributeur