
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
eslint-plugin-import-typescript
Advanced tools
Eslint rule enforcing supporting typescript absolute imports and paths
An ESLint plugin that auto-fixes relative imports to absolute imports. Support baseUrl and paths config in TSConfig.
A typical project starts out using relative imports, but once it has gotten bigger, the relative imports grows longer and messier. This plugin is useful when you want to migrate the relative imports to absolute imports, and keep it that way through auto-fixes.
Built on Jeff Chen's Absolute Imports plugin.
You must define baseUrl
and paths
(optional) in either tsconfig.json
or jsconfig.json
.
npm i --save-dev eslint-plugin-import-typescript
eslint-plugin-import-typescript
to your eslint plugins
sectionrules
section.Example:
plugins: ['eslint-plugin-import-typescript'],
rules: [
'import-typescript/no-relative-parent-imports': ['error'],
]
Rule | Description |
---|---|
no-relative-imports | Autofix relative imports to absolute import or paths import |
no-relative-parent-imports | Autofix relative parent imports to absolute import or paths import |
The rule no-relative-parent-imports
is useful when you still want to allow relative import within the same folder but disallow relative import in a parent folder. It's similar to eslint-plugin-import/no-relative-parent-imports rule, except it supports auto-fix. It is the recommended rule.
The rules supports baseUrl
and paths
, and will prioritize paths
import if it exists. It's possible to disable one of the rewritting rules by setting the corresponding options
Options | Description |
---|---|
onlyAbsoluteImport | Ignore paths config if it exists |
onlyPathsImport | Do not autofix absolute import. Only fix import if there is a path matching paths config |
Example:
'import-typescript/no-relative-parent-imports': [
'error', { onlyAbsoluteImport: true }
],
While baseUrl
and paths
are understood and supported by Typescript, it doesn't rewrite the import paths when it compiles the typescript code to javascript. Belows are some related readings and library to get typescript absolute imports works:
paths
, you need to use eslint-import-resolver-typescript to help eslint understands paths import.Contributions are welcome!
MIT
FAQs
Eslint rule enforcing supporting typescript absolute imports and paths
The npm package eslint-plugin-import-typescript receives a total of 2,796 weekly downloads. As such, eslint-plugin-import-typescript popularity was classified as popular.
We found that eslint-plugin-import-typescript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.