Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: move requires at bottom of file to top #31

Open
sa-0001 opened this issue Feb 28, 2023 · 0 comments
Open

feature request: move requires at bottom of file to top #31

sa-0001 opened this issue Feb 28, 2023 · 0 comments
Labels
feature request New feature or request

Comments

@sa-0001
Copy link

sa-0001 commented Feb 28, 2023

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 { ... }
@sa-0001 sa-0001 added the feature request New feature or request label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant