Skip to content

Doesn't work for aliases like "@": "./" #299

@melyux

Description

@melyux

Version: 1.5.0

Steps To Reproduce

The alias in the title lets me import everything from my root with an absolute path, like import CustomText from '@/components/CustomText'.

  1. Have a babel.config.js file with a module-resolver alias like '@': './'
  2. Try using a relative import like import CustomText from '../../../components/CustomText'
  3. See that there is no warning for the line

Link to code example:

babel.config.js:

module.exports = function (api) {
    api.cache(true)
    return {
        presets: ['babel-preset-expo'],
        plugins: [
            [
                'module-resolver',
                {
                    alias: {
                        '@': './',
                    },
                },
            ],
        ],
    }
}

The current behavior

With just the alias '@': './', the plugin doesn't detect an import like import CustomText from '../../../components/CustomText' to be invalid. But if you add another alias like '@components': './components', then it does detect the aforementioned line as invalid.

The expected behavior

It should detect relative imports as invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions