import-js / eslint-plugin-import

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

False positive on CI with long file paths - import/no-unresolved import/extensions #1037

Open Zidail opened 6 years ago

Zidail commented 6 years ago

We've specified a file using the current structure: /src/libs/components/Form/template/TextBox/TextBox.js

Then import it in /src/libs/components/Form/template/TextBox/index.js as ./TextBox.

Locally, we have no issues.

When we run it on CircleCI, it fails and gives two errors on the import:

When we change the file path to /src/libs/components/Form/TextBox/index.js by removing template it actually works and we don't get any errors.

Any idea how to resolve this issue besides changing the file structure?

ljharb commented 6 years ago

Are any of those dirs symlinks? What case sensitivity is your local fs and circle’s?

Zidail commented 6 years ago

None of those directories are symlinked, but we do use Babel Plugin Module Resolver.

System (Mac) is case sensitive. CircleCI is linux so it should be case sensitive as well.

Thanks @ljharb !

ljharb commented 6 years ago

That's not necessarily the case on either side; can you verify?

Zidail commented 6 years ago

You're right. Double checked, System is case-insensitive. CircleCI is case sensitive.

ljharb commented 6 years ago

In that case, if the path capitalizations don’t match precisely, they’d be failing correctly on circle CI.

thormengkheang commented 6 years ago

I have the same problem too in my local machine (macOS High Sierra) it does not report any errors but on gitlab CI/CD it has this errors

> l192app@0.0.1 lint /builds/khmerload/l192-app
> eslint src/ __test__/ __mock__/

/builds/khmerload/l192-app/src/api/AccountAPI.js
  4:29  error  Unable to resolve path to module '../components'  import/no-unresolved
  4:29  error  Missing file extension for "../components"        import/extensions

/builds/khmerload/l192-app/src/components/ItemRender/CategoryList.js
  3:29  error  Unable to resolve path to module '../'  import/no-unresolved
  3:29  error  Missing file extension for "../"        import/extensions

/builds/khmerload/l192-app/src/components/ItemRender/ItemCart.js
  3:31  error  Unable to resolve path to module '../'  import/no-unresolved
  3:31  error  Missing file extension for "../"        import/extensions

/builds/khmerload/l192-app/src/components/ItemRender/ItemOrderHistory.js
  5:31  error  Unable to resolve path to module '..'  import/no-unresolved
  5:31  error  Missing file extension for ".."        import/extensions

/builds/khmerload/l192-app/src/components/ItemRender/SeeMore.js
  3:29  error  Unable to resolve path to module '../'  import/no-unresolved
  3:29  error  Missing file extension for "../"        import/extensions

/builds/khmerload/l192-app/src/components/ProductDetail.js
  5:58  error  Unable to resolve path to module '../components'  import/no-unresolved
  5:58  error  Missing file extension for "../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Account/AccountScreen.js
  3:62  error  Unable to resolve path to module '../../components'  import/no-unresolved
  3:62  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Account/ChangePasswordScreen.js
  3:61  error  Unable to resolve path to module '../../components'  import/no-unresolved
  3:61  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Account/LogoutScreen.js
  3:40  error  Unable to resolve path to module '../../components'  import/no-unresolved
  3:40  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Account/UpdateProfileScreen.js
  5:62  error  Unable to resolve path to module '../../components'  import/no-unresolved
  5:62  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/CartScreen.js
  5:70  error  Unable to resolve path to module '../components'  import/no-unresolved
  5:70  error  Missing file extension for "../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Checkout/PaymentScreen.js
  4:55  error  Unable to resolve path to module '../../components'  import/no-unresolved
  4:55  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Checkout/SuccessScreen.js
  4:44  error  Unable to resolve path to module '../../components'  import/no-unresolved
  4:44  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/CustomPageScreen.js
  14:8  error  Unable to resolve path to module '../components'  import/no-unresolved
  14:8  error  Missing file extension for "../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Login/ChangePasswordScreen.js
  4:44  error  Unable to resolve path to module '../../components'  import/no-unresolved
  4:44  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Login/ForgetPasswordScreen.js
  4:57  error  Unable to resolve path to module '../../components'  import/no-unresolved
  4:57  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Login/LoginScreen.js
  15:73  error  Unable to resolve path to module '../../components'  import/no-unresolved
  15:73  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Login/RegisterScreen.js
  6:37  error  Unable to resolve path to module '../../components'  import/no-unresolved
  6:37  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Login/RegisterVerifyScreen.js
  5:37  error  Unable to resolve path to module '../../components'  import/no-unresolved
  5:37  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Order/OrderDetailScreen.js
  4:42  error  Unable to resolve path to module '../../components'  import/no-unresolved
  4:42  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/Order/OrderHistoryScreen.js
  10:8  error  Unable to resolve path to module '../../components'  import/no-unresolved
  10:8  error  Missing file extension for "../../components"        import/extensions

/builds/khmerload/l192-app/src/screens/ProductScreen.js
  5:72  error  Unable to resolve path to module '../components'  import/no-unresolved
  5:72  error  Missing file extension for "../components"        import/extensions

/builds/khmerload/l192-app/src/screens/SearchScreen.js
  15:76  error  Unable to resolve path to module '../components'  import/no-unresolved
  15:76  error  Missing file extension for "../components"        import/extensions

/builds/khmerload/l192-app/src/screens/SideMenu/SideMenuScreen.js
  13:49  error  Unable to resolve path to module '../../components'  import/no-unresolved
  13:49  error  Missing file extension for "../../components"        import/extensions

On my local machine I got no errors

screen shot 2018-03-30 at 9 02 10 am

I also set my rule case sensitive to false

"import/no-unresolved": [2, { "caseSensitive": false }]
Undistraction commented 5 years ago

@james1888 Did you manage to get that working? I have the same problem on Gitlab. Lots of false positives. Possible related to symlinks.

Waltari10 commented 5 years ago

Same problem here. no symlinks.

jkhusanov commented 5 years ago

I was able to get around this by renaming my .js files to .jsx. I don't know why but it works with Circle Ci, even though I have these settings to resolve them and there is no problem on a local machine:

  "settings": {
    "react": {
      "version": "detect"
    },
    "import/resolver": {
      "node": {
        "paths": ["client/src"],
        "extensions": [".js", ".jsx", ".ts", ".tsx"]
      }
    }
  },
Ciberusps commented 3 years ago

same problem with gitlab CI

oosswwaalldd commented 2 years ago

Did anyone solve this? I am having this issue on GitLab (Only)