Enforces React import style across your code. Can be customized to use default or namespace import (react-import/consistent-syntax
)
💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
Examples of incorrect code for this rule:
import React, { useState } from 'react';
Examples of correct code for this rule:
import * as React from 'react';
"react-import/consistent-syntax": [<enabled>, <'namespace' | 'default'>]
This rule has one string options that allows to choose the preferred syntax for React imports:
Note
If no option is provided namespace
will be used.
Examples of incorrect code with this option:
import React, { useState } from 'react';
Examples of correct code with this option:
import * as React from 'react';
Examples of incorrect code with this option:
import * as React from 'react';
Examples of correct code with this option:
import React from 'react';
If you do not care about React import consistencies