Friday, 12 April 2019

ES Lint or Prettier Rule to manage require() statements?

I'm wondering if there is an eslint or prettier rule/plugin that will sort and organize `require()` statements in node. I did find eslint-plugin-sort-requires but it doesn't handle one of the scenarios I'm looking for which is to formatconst axios = require('axios'); const errorPrefix = '[ERROR]: '; const { logger } = require('./logger'); to get sorted toconst axios = require('axios'); const { logger } = require('./logger'); const errorPrefix = '[ERROR]: '; This is a contrived example, but it illustrates what I'm going after. I would like the require()s at the very top, followed by a break (ideally) and then have any other top level variables.Is there anything out there that does this?

Submitted April 12, 2019 at 11:39PM by bit_cmdr

No comments:

Post a Comment