import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

Linter mistakenly assumes global module is a parent directory of the project #1291

Open jonathanj opened 5 years ago

jonathanj commented 5 years ago

I have code doing an import like:

import {all} from 'redux-saga/effects';
import {REHYDRATE} from 'redux-persist/constants';

Producing the linter errors below:

1:25  error  Relative imports from parent directories are not allowed. Please either pass what you're importing through at runtime (dependency injection), move `session.js` to same directory as `redux-persist/constants` or consider making `redux-persist/constants` a package  import/no-relative-parent-imports

11:8  error  Relative imports from parent directories are not allowed. Please either pass what you're importing through at runtime (dependency injection), move `index.js` to same directory as `redux-saga/effects` or consider making `redux-saga/effects` a package  import/no-relative-parent-imports

Clearly the suggested resolution in the error doesn't make sense but I'm not sure why it thinks this should be the case. #793 has some similarities but I'm not sure if those are superficial or real.

tomzmtl commented 4 years ago

Having the same issue but with import/order, where

import { call, select, put } from "redux-saga/effects"
import { something } from "../api/something"

Flags the second line with a warning:

`../api/something` import should occur before import of `redux-saga/effects` : eslint(import/order)

My import/order rules config:

"import/order": [
  "warn",
  {
    "newlines-between": "never"
  }
],

The warning disappears if the first import is changed to "redux-saga"

hegde-codes commented 4 years ago

Any updates?

ljharb commented 4 years ago

@hegde-codes nope, nobody's submitted a PR yet.