Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.1.1 raises import/no-unresolved in eslint. #1685

Open
jovanmaric opened this issue Jan 21, 2025 · 4 comments
Open

14.1.1 raises import/no-unresolved in eslint. #1685

jovanmaric opened this issue Jan 21, 2025 · 4 comments

Comments

@jovanmaric
Copy link

jovanmaric commented Jan 21, 2025

A bug is a crash or incorrect behavior. If you have a debugging or troubleshooting question, please open a discussion.

Environment

  1. Ruby version: /
  2. Rails version: /
  3. Shakapacker/Webpacker version: /
  4. React on Rails version: 14.1.1

Behavior

Eslint raises Unable to resolve path to module 'react-on-rails' import/no-unresolved on version 14.1.1, but not on version 14.1.0.

Small, reproducible repo

// package.json
{
  "type": "module",
  "dependencies": {
    "eslint": "^9.18.0",
    "eslint-plugin-import": "^2.31.0",
    "react-on-rails": "14.1.1"
  }
}
// eslint.config.js
import importPlugin from 'eslint-plugin-import';
import js from '@eslint/js';

export default [
  js.configs.recommended,
  importPlugin.flatConfigs.recommended,
  {
    files: ['**/*.{js,mjs,cjs}'],
    languageOptions: {
      ecmaVersion: 'latest',
      sourceType: 'module',
    },
    rules: {
      'no-unused-vars': 'off',
      'import/no-dynamic-require': 'warn',
      'import/no-nodejs-modules': 'warn',
    },
  },
];
// test.js
import ReactOnRails from 'react-on-rails';

Run with:
eslint test.js

@justin808
Copy link
Member

Thanks! Investigating!

@justin808
Copy link
Member

@jovanmaric is this only an eslint issue?

@Judahmeek
Copy link
Contributor

It likely is.

The issue is: eslint-plugin-import currently does not support subpaths

I'm not absolutely sure why we didn't encounter this issue when updating ReactOnRails Pro, but it's possible that either the node or typescript import resolvers do support subpaths.

Either that or our eslint configuration just doesn't catch undefined imports.

Anyway, I'm going to take the code from here & find a solution, starting with re-adding the main rule back.

@jovanmaric
Copy link
Author

jovanmaric commented Jan 22, 2025

@jovanmaric is this only an eslint issue?

Thanks all for the quick responses. Yes it is only an eslint issue. React on rails works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants