Open
Description
Feature Use Case
I have worked in a few large codebases, where due to difficulties with circular requires, the requires eventually were simply all added at the bottom of the file (unless used at top-level in the module, such as _.once
). It would be very helpful if there were an option to move all requires at the bottom of the file, to imports at the top. It doesn't need to try and position them correctly alongside other imports, comments, etc, but simply move all contiguous imports at the bottom of the file, to the top (possibly after existing block comments and requires/imports).
Feature Proposal
Example: cjstoesm --move-to-top ...
Before:
/**
* file block comment
**/
const _ = require('lodash')
module.exports = { ... }
const a = require('some-npm-package')
const b = require('some-local-package/a')
const c = require('./some-local-lib/c')
const d = require('./some-local-lib/d')
After:
/**
* file block comment
**/
import _ from 'lodash'
import a from 'some-npm-package'
import b from 'some-local-package/a'
import c from './some-local-lib/c'
import d from './some-local-lib/d'
export default { ... }