Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 1.27 KB

consistent-syntax.md

File metadata and controls

62 lines (39 loc) · 1.27 KB

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';

Options

"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.

namespace

Examples of incorrect code with this option:

import React, { useState } from 'react';

Examples of correct code with this option:

import * as React from 'react';

default

Examples of incorrect code with this option:

import * as React from 'react';

Examples of correct code with this option:

import React from 'react';

When Not To Use It

If you do not care about React import consistencies