vim-js-file-import icon indicating copy to clipboard operation
vim-js-file-import copied to clipboard

Sorting multiline imports not working

Open badeleux opened this issue 6 years ago • 5 comments

This block of imports after sort has syntax issues

Before:

import * as R from 'ramda';
import DeviceSettings from 'react-native-device-settings';
import fs from 'react-native-fs';
import moment from 'moment-timezone';
import MPEGRemuxer from 'react-native-ts-to-mp4';
import Permissions from 'react-native-permissions';
import Result from 'folktale/result';
import { 
  call, 
  fork, 
  put, 
  race, 
  select, 
  take, 
  takeEvery, 
} from 'redux-saga/effects';
import { eventChannel, channel, buffers, type Effect } from 'redux-saga';
import { Sentry } from 'react-native-sentry';

After:

  call, 
  fork, 
  put, 
  race, 
  select, 
  take, 
  takeEvery, 
import * as R from 'ramda';
import DeviceSettings from 'react-native-device-settings';
import fs from 'react-native-fs';
import moment from 'moment-timezone';
import MPEGRemuxer from 'react-native-ts-to-mp4';
import Permissions from 'react-native-permissions';
import Result from 'folktale/result';
import { 
import { eventChannel, channel, buffers, type Effect } from 'redux-saga';
import { Sentry } from 'react-native-sentry';
} from 'redux-saga/effects';

badeleux avatar Sep 26 '18 05:09 badeleux

Yeah implementation is very bare and simple, it behaves well only on full imports. Needs improvement.

kristijanhusak avatar Sep 26 '18 10:09 kristijanhusak

(Just started using this plugin, greatk work @kristijanhusak!)

Maybe it makes sense to remove the sorting functionality, since it has been superseded by other plugins and make the core functionality simpler to manage?

panosl avatar Mar 25 '21 08:03 panosl

Hey @panosl,

I agree that it's nowhere near perfect, but why would we remove it?

It's not being used unless specifically requested to via mapping or a opt in variable.

kristijanhusak avatar Mar 25 '21 09:03 kristijanhusak

I'm not saying you should. It just feels like it's outside of the core functionality of vim-js-file-import. Unless you plan to improve it further.

p.s. Still the automatic import functionality works like a charm, really happy that I stumbled on this. I was so jealous when I saw it on VS Code!

panosl avatar Mar 25 '21 10:03 panosl

Yeah it's not it's main functionality. I added it for my needs, since I work with some old node js applications that still use commonjs, and I didn't found any plugin or lsp that would sort require's properly.

I think this even handles some cases that VS code cannot handle :)

kristijanhusak avatar Mar 25 '21 10:03 kristijanhusak