Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6291

How to put import type always as last one with eslint-plugin-import

$
0
0

I have a react native project in which I use absolute paths starting withcomponents/ features/ or infrastructure/

I wanted them to be separated from the node modules imports but I want to

import type {xxx} from 'features|components|infrastructure|';

to always go last within a group, or even better to all the import type to always go last in the entire imports section and preferably sorted alphabetically.

So far I came up with such a config

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,        },      },    ],  },};

but the problem here is that it does not separate import and import type and it puts imports like so

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

Thanks.


Viewing all articles
Browse latest Browse all 6291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>