Eslint-plugin-import: newline-after-import: Proposal to add import/require flags

Created on 23 Aug 2016  Â·  3Comments  Â·  Source: benmosher/eslint-plugin-import

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?

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 (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).

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings