我有一个反应本机项目,其中我使用以以下开头的绝对路径
components/ features/ or infrastructure/
我希望它们与节点模块导入分开,但我想
import type {xxx} from 'features|components|infrastructure|';
始终在组中排在最后,或者更好的是所有导入类型始终在整个导入部分排在最后,并且最好按字母顺序排序。
到目前为止我想出了这样的配置
module.exports = {
root: true,
extends: ['@react-native-community'],
plugins: ['import'],
rules: {
'import/order': [
'error',
{
groups: [
['builtin', 'external'],
'internal',
'parent',
['sibling', 'index'],
'object',
'type',
],
pathGroups: [
{
pattern: '@(react|react-native)',
group: 'external',
position: 'before',
},
{
pattern: 'components/**',
group: 'internal',
},
{
pattern: 'features/**',
group: 'internal',
},
{
pattern: 'infrastructure/**',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
};
但这里的问题是它没有分离导入和导入类型,而是像这样放置导入
import React from 'react';
import { View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import RegistrationScreen from 'features/account/screens/Registration';
import type { Test } from 'features/account/types';
import { colors } from 'infrastructure/theme';
谢谢。