tleunen / eslint-import-resolver-babel-module

Custom eslint resolve for babel-plugin-module-resolver
https://github.com/tleunen/babel-plugin-module-resolver
MIT License
248 stars 31 forks source link

Unresolved path alias with React Native, Metro, Typescript #116

Open KhubaibQaiser opened 3 years ago

KhubaibQaiser commented 3 years ago

Hi, I am getting this error while resolving path aliases in my react native project. You can find the repository here: https://github.com/KhubaibQaiser/rn-seed

Is there anything wrong with the configuration of my .eslintrc.js file?

aprilmintacpineda commented 3 years ago

Same here, I get that error as well, I have something like _screens as my alias, but eslint complains that it's not found, I'm not using TypeScript.

on .eslintrc.js

settings: {
  react: {
    version: 'detect'
  },
  'import/ignore': ['react-native'],
  'import/resolver': {
    'babel-module': {
      alias
    }
  }
}

import aliases:

module.exports = {
  _components: './src/components',
  _screens: './src/screens',
  _fluxible: './src/fluxible',
  _graphql: './src/graphql',
  _root: './src'
};

on babe.config.js

const alias = require('./importAliases');

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'module-resolver',
      {
        root: ['./src'],
        alias
      }
    ]
  ],
  env: {
    production: {
      plugins: ['react-native-paper/babel']
    }
  }
};

image