+
Skip to content

Conversation

stevebeauge
Copy link

Without this tweak, import './app' in the renderer.ts file yield ESLint error Unable to resolve path to module './app' .eslintimport/no-unresolved.

Cf https://stackoverflow.com/questions/65578102/import-local-file-not-resolved/65579426#65579426 for original issue

Without this tweak, `import './app'` in the `renderer.ts` file yield ESLint error `Unable to resolve path to module './app' .eslintimport/no-unresolved`.

Cf https://stackoverflow.com/questions/65578102/import-local-file-not-resolved/65579426#65579426 for original issue
@ivancuric
Copy link

ivancuric commented Feb 3, 2021

This is the wrong fix. The solution is to include "plugin:import/typescript" which includes these rules and some more:

/**
 * Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
 */

const allExtensions = ['.ts', '.tsx', '.d.ts', '.js', '.jsx'];

module.exports = {

  settings: {
    'import/extensions': allExtensions,
    'import/external-module-folders': ['node_modules', 'node_modules/@types'],
    'import/parsers': {
      '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
    },
    'import/resolver': {
      'node': {
        'extensions': allExtensions,
      },
    },
  },

  rules: {
    // analysis/correctness

    // TypeScript compilation already ensures that named imports exist in the referenced module
    'import/named': 'off',
  },
};

You didn't have it in your config.

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

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载