Linting issue with imports

I am unable to resolve the linting issue “import/no-unresolved” if using import statements like this

import { xxx } from '/client/xxx/yyy’
or
import { xxx } from ‘/server/xxx/yyy’

Thanks in advance for help.

This linting error just tells you that the file you’re trying to import cannot be found.
See here.

Are you sure you’re pointing at the right location?

Obviosuly this can also happen if you’re writing your test first (i.e. TDD) and implement the actual code afterwards. In this case, that lint warning would be expected.

Actually the files are there and there is no linting errors when using the relative path for e.g.

import xxx from '../client/xxx';

The linting errors are only occurring when using the following import statements.

import xxx from '/client/xxx'; { this works only linting issue }

Ah ok.
Well I’m no expert, but Meteor’s final paths (after build) may be different than what your linter is looking at - especially if you’re using absolute paths as in your second example.

So I’d definitely recommend using relative paths only.

And simply silencing the linter is out of the question? Otherwise you could “fix” it with the solution @will is providing here:

https://forums.meteor.com/t/code-style-article/20189/6?u=smeijer

I did silence it with the linter but i was just looking out if there is another way or somebody has written a resolver for the import plugin.

Looks like there’s some work being done on this; new as of 2 days ago:

https://github.com/clayne11/eslint-import-resolver-meteor

1 Like

Good catch, I updated my boilerplate code to use it thanks https://github.com/trajano/meteor-boilerplate/commit/5cee306c3a11577aa63da33ddb4042f393e10136 it just needs one more tweak namely support meteor/ I opened up an issue already https://github.com/clayne11/eslint-import-resolver-meteor/issues/1

Found it:

// .eslintrc
"rules": {
    "import/no-unresolved": [2, {ignore: ["^meteor/"]}],
}

How do you deal with imports of folders?

such as

import '/imports/startup/client';

I’m not sure exactly what you’re asking. What are you expecting to happen with that statement and what is ESLint doing that is violating that expectation?

I think it was an issue with absolute vs relative path…in any case it fixed itself after installing

eslint-import-resolver-meteor

Sorry for not closing not editing the comment