Closed adp-psych closed 3 years ago
Thank you for reporting the issue @adp-psych.
Not being an active user of both the babel plugin or the eslint plugin, I might not be the best person anymore to fix these issues unfortunately. But between 5.2.0 and 5.3.0, we didn't have any major changes in our codebase.
The only issue I could see is with one of the dependencies we updated.
Therefore, can I ask you to run a few tests with your codebase and see if the update to pkg-up
or resolve
is the source of the issue?
Here are the changes between the 2 versions btw: https://github.com/tleunen/eslint-import-resolver-babel-module/compare/v5.2.0...v5.3.0
Interestingly, I also just notice 5.3.0 should have been a major update because of the node 10 requirement now. But we'll soon force node 12 anyway so I'll make sure to make a major release then.
Hi @tleunen! Thanks for your quick response.
I investigated as you requested, and it seems the problem is here:
const absoluteSrc = path.join(path.dirname(file), src);
When this runs, src
is null
, so path.join()
fails.
Commenting out this line and the if
statement/block after it fixes the problem.
Thanks for investigating this!
@dword-design, could you also take a look at this, since you've added this piece of code?
@adp-psych @tleunen I tried to setup a minimal project with your config but I think I need further files. I added all deps and then get this error:
Error: Error while loading rule 'notice/notice': Can't find templateFile @ /Users/foo/Desktop/test-module-resolver/templates/copyright.js
Do you have a minimal failing example? Also, I guess it is maybe related to the importing statement rather than the config (don't know though).
@dword-design, my ESLint configuration expects templates/copyright.js
to contain the template for the copyright notice at the top of every source file. You can create templates/copyright.js
if you like, but you should just be able to disable the rule (and any others that bother you) via .eslintrc.js
:
module.exports = {
'extends': '@adp-psych',
'rules': {
'notice/notice': 'off',
},
};
@adp-psych Alright I could reproduce the issue. Coming up with a fix soon.
@adp-psych @tleunen This PR fixes the issue https://github.com/tleunen/eslint-import-resolver-babel-module/pull/118.
Problem was basically that the NPM import test was too specific for only testing babel plugin resolution. I replaced it with pkg-up
, which failed then. Fix was pretty simple by surrounding my code with if
. resolvePath
only returns non-null if it is a local import (in contrast to an NPM module import).
That's good to know! Thank you @dword-design for the explanation, and the fix :)
Version 5.3.0 of eslint-import-resolver-babel-module causes problems for me with eslint-plugin-import:
Downgrading to version 5.2.0 of eslint-import-resolver-babel-module (
npm install --no-save eslint-import-resolver-babel-module@5.2.0
) resolves the problem.Here's my
babel.config.js
(with comments removed):My full Babel and ESLint configurations are on npm as @adp-psych/babel-config and @adp-psych/eslint-config.