I mostly use import at the top level and require inline with the rest of my code. Here's an example:
if (module.hot) {
module.hot.accept(() => {
// eslint-disable-next-line global-require
const nextRootReducer = require('../reducers').default;
store.replaceReducer(nextRootReducer);
});
}
Would it be possible to add an option to ignore require calls?
I'd suggest a configuration object for this rule with two flags: "require": true/false, "import": true/false — not a single option require-only (btw require-only implies that it enforces a newline after require only, but the suggestion is to enforce the opposite — enforce a newline after import only).
There is a precedent in a handful of the rules where they take { esmodule, commonjs, amd } flags to enable/disable for different module schemes. Could use that here, too.
@benmosher, just saw your comment on this. I really like that idea because if it follows some convention then it's easier for developers to discover/use.
Most helpful comment
I'd suggest a configuration object for this rule with two flags: "require": true/false, "import": true/false — not a single option
require-only(btwrequire-onlyimplies that it enforces a newline afterrequireonly, but the suggestion is to enforce the opposite — enforce a newline afterimportonly).