eslint-plugin-node
eslint-plugin-node copied to clipboard
no-extraneous-require with paths that are symlinked
https://stackoverflow.com/questions/10860244/how-to-make-node-js-require-absolute-instead-of-relative shows a way of using symlinks to require modules using paths that are relative to node_modules rather than to the current file, which leads to much fewer changes when refactoring and moving files around. But if I create a link %%
to my source directory no-extraneous-require
shows all of the things I've required such as %%/module1
as being errors.
The workaround would be to allow us to specify a regex pattern of things to ignore, which are things starting with "%%/"
in this case. But even better would be if it could actually follow the symlink and tell us if we're really using require
on something that doesn't exist even in these cases, so that we don't need to ignore anything and the code would have no errors caused by incorrect require
. It's a fairly common pattern to use symlinks in this way so either of these solutions would allow to enable this rule in the code.
file-extension-in-import
also doesn't work correctly with such paths. %%/module1
won't be shown as an error with always
option even though it should be %%/module1.js
(or some extension).