Skip to content

no-unresolved JS alias regression in 3.8+ #363

Closed
@RobHannay

Description

@RobHannay

Since 3.8 aliases are no-longer being resolved in .js files.

I've read a few of the issues raised about 3.8, but I think this is separate. I have tested with 3.8.3 and still face the issue.

We use aliases that are actually defined in three possible places:

  • webpack.config
  • jsconfig
  • tsconfig

Image

Perhaps it was never intended to resolve imports from js files?

It's fine is I use relative paths with lots of ../.

We have a verbose config but the key details are:

{
  eslint.configs.recommended,
  ...tseslint.configs.recommendedTypeChecked,
  importPlugin.flatConfigs.recommended,
  {
    languageOptions: {
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  {
    files: ['**/*.js', '**/*.mjs'],
    ...tseslint.configs.disableTypeChecked,
  },
  {
    languageOptions: {
      globals: {
        ...globals.node,
        ...globals.jest,
      },
    },
    settings: {
      'import/parsers': {
        '@typescript-eslint/parser': ['.ts', '.tsx'],
        '@babel/eslint-parser': ['.js', '.mjs'],
      },
      'import/resolver': {
        typescript: {
          alwaysTryTypes: true,
        },
      },
      // Gives false positives because RRD has two versions in our dependency tree.
      'import/ignore': ['react-router-dom'],

      'import/internal-regex': aliasesRegex,
    },
    rules: {
      'import/order': [
        'error',
        {
          'newlines-between': 'always',
          groups: ['type', 'external', 'internal', ['parent', 'sibling', 'index'], 'object'],

          alphabetize: {
            order: 'asc',
          },
        },
      ],

      'import/no-cycle': 'error',

      'import/no-unresolved': [
        'error',
        {
          caseSensitiveStrict: true,
        },
      ],

      'workspaces/no-cross-imports': [
        'error',
        {
          allow: '@blink/core',
        },
      ],

      'no-restricted-imports': [
        'error',
        {
          patterns: [
            {
              group: ['*.css', '!*.module.css'],
              importNames: ['default'],
              message: 'For CSS modules, use the `.module.css` extension.',
            },
          ],
        },
      ],

    },
  },
}

Happy to try and create a proper repro repo. Do you have a base I can clone?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy