This ESLint plugin automates the conversion of relative import paths to absolute or path-mapped imports within TypeScript and JavaScript projects. Currently at version 0.0.4, it's an early-stage project focused on providing auto-fixing capabilities for import path management. It directly integrates with `tsconfig.json` (or `jsconfig.json`)'s `baseUrl` and `paths` configurations, addressing a common pain point where TypeScript's compiler understands these settings but does not rewrite the import paths in the compiled output. A key differentiator is its ability to auto-fix rules like `no-relative-parent-imports`, which some other plugins might only flag. It aims to streamline the migration from relative to absolute imports, particularly as project scale increases. There is no explicit release cadence, typical for community-driven ESLint plugins.
npm install eslint-plugin-import-typescriptVerified import paths — ran on the pinned version, not inferred.
This configuration demonstrates the basic setup for `eslint-plugin-import-typescript` in a TypeScript project, enabling its `no-relative-parent-imports` rule for automatic fixing. It also includes the necessary `parserOptions` for TypeScript and `import/resolver` settings for `eslint-plugin-import` to correctly interpret `baseUrl` and `paths` from `tsconfig.json`.
Integrate `tsconfig-paths` for runtime resolution (e.g., `node -r tsconfig-paths/register your-app.js`) or `tsc-alias` into your build process (e.g., `tsc && tsc-alias`). For Jest, configure `moduleNameMapper` and potentially `tsconfig-paths` for `globalSetup` scripts.
Install `npm install --save-dev eslint-plugin-import eslint-import-resolver-typescript` and add the `import/resolver` setting to your `.eslintrc.js` file: `settings: { 'import/resolver': { typescript: { project: './tsconfig.json' } } }`.Add or verify the `baseUrl` property in your `tsconfig.json` (e.g., `compilerOptions: { 'baseUrl': '.' }`).Monitor the GitHub repository for updates and breaking changes. Contribute bug reports or feature requests if issues are encountered. Consider this plugin for new projects or non-critical paths until it reaches a more stable major version.
Install `eslint-import-resolver-typescript` and configure it in your `.eslintrc.js` `settings['import/resolver']` to point to your `tsconfig.json`.
For runtime execution, use `tsconfig-paths` (e.g., `node -r tsconfig-paths/register your-app.js`). For build output, integrate `tsc-alias` into your post-compilation step (e.g., `tsc && tsc-alias`).
Install `@typescript-eslint/parser` and configure it in your `.eslintrc.js` `parser` option and `parserOptions.project` (e.g., `parser: '@typescript-eslint/parser', parserOptions: { project: './tsconfig.json' }`).