{"id":18711830,"url":"https://github.com/laysent/eslint-import-resolver-custom-alias","last_synced_at":"2025-04-12T12:30:54.568Z","repository":{"id":45887290,"uuid":"117527023","full_name":"laysent/eslint-import-resolver-custom-alias","owner":"laysent","description":"Plugin for eslint-plugin-import to use custom alias","archived":false,"fork":false,"pushed_at":"2023-12-05T07:09:33.000Z","size":63,"stargazers_count":42,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T02:34:15.592Z","etag":null,"topics":["alias-resolver","eslint-import-plugin","eslint-import-resolver","eslint-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laysent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-15T09:48:48.000Z","updated_at":"2025-03-19T14:23:22.000Z","dependencies_parsed_at":"2024-06-18T15:24:52.689Z","dependency_job_id":"484b2527-9170-4625-8445-e2f109845694","html_url":"https://github.com/laysent/eslint-import-resolver-custom-alias","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laysent%2Feslint-import-resolver-custom-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laysent%2Feslint-import-resolver-custom-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laysent%2Feslint-import-resolver-custom-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laysent%2Feslint-import-resolver-custom-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laysent","download_url":"https://codeload.github.com/laysent/eslint-import-resolver-custom-alias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566440,"owners_count":21125666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alias-resolver","eslint-import-plugin","eslint-import-resolver","eslint-plugin"],"created_at":"2024-11-07T12:40:41.143Z","updated_at":"2025-04-12T12:30:54.178Z","avatar_url":"https://github.com/laysent.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/laysent/eslint-import-resolver-custom-alias.svg?branch=master)](https://travis-ci.org/laysent/eslint-import-resolver-custom-alias)\r\n\r\nThis plugin will help you configure [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import)\r\nto allow customized alias and extensions.\r\n\r\n## Installation\r\n\r\nTo install this plugin, run:\r\n\r\n```bash\r\nnpm install --dev eslint-import-resolver-custom-alias\r\n```\r\n\r\nor\r\n\r\n```bash\r\nyarn add --dev eslint-import-resolver-custom-alias\r\n```\r\n\r\n## Configuration\r\n\r\n```json\r\n{\r\n  \"settings\": {\r\n    \"import/resolver\": {\r\n      \"eslint-import-resolver-custom-alias\": {\r\n        \"alias\": {\r\n          \"src\": \"./src\"\r\n        },\r\n        \"extensions\": [\".js\", \".jsx\"],\r\n        \"packages\": [\r\n          \"packages/*\"\r\n        ]\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nHere, `alias` is a key-value pair, where `key` represents the alias, and `value` represents\r\nit's actual path. Relative path is allowed for `value`. When used, it's relative to project\r\nroot, where command line is running. (i.e. root path will be `process.cwd()`)\r\n\r\n`extensions` is an array of possible suffix. If not provided, default value will be `[\".js\"]`.\r\n\r\n`packages` is an optional configuration. When using lerna to manage packages and use eslint at\r\nroot folder, `packages` lets the resolver know where each package folder exist. This way, when\r\nresolving alias, relative path will be resolved based on current package, instead of root folder.\r\n\r\nConsider the file as an example:\r\n\r\n```jsx\r\nimport * as utils from '@/utils';\r\n```\r\n\r\nSuppose the above file locates at `./packages/subfolder/src/components/button.jsx` and command is\r\nrunning at root folder (i.e. `./`). If the resolver is configured the following way:\r\n\r\n```json\r\n{\r\n  \"settings\": {\r\n    \"import/resolver\": {\r\n      \"eslint-import-resolver-custom-alias\": {\r\n        \"alias\": {\r\n          \"@\": \"./src\"\r\n        },\r\n        \"extensions\": [\".js\", \".jsx\"],\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nResolver will tries to find file at `./src/utils` folder. However, with `packages` configured:\r\n\r\n```json\r\n{\r\n  \"settings\": {\r\n    \"import/resolver\": {\r\n      \"eslint-import-resolver-custom-alias\": {\r\n        \"alias\": {\r\n          \"@\": \"./src\"\r\n        },\r\n        \"extensions\": [\".js\", \".jsx\"],\r\n        \"packages\": [\r\n          \"packages/*\"\r\n        ]\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nResolver will try to find it at `./packages/subfolder/src/utils` folder instead.\r\n\r\nOne special alias is empty string `\"\"`. If configured, the resolver will try to\r\nadd prefix in front of the path before resolving. For example, with following configuration\r\n\r\n```json\r\n{\r\n  \"settings\": {\r\n    \"import/resolver\": {\r\n      \"eslint-import-resolver-custom-alias\": {\r\n        \"alias\": {\r\n          \"\": \"./src\"\r\n        },\r\n        \"extensions\": [\".js\", \".jsx\"],\r\n        \"packages\": [\r\n          \"packages/*\"\r\n        ]\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThe resolver will try to find the following import at path `./packages/subfolder/src/utils/helper`.\r\n\r\n```jsx\r\nimport * as helper from 'utils/helper';\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaysent%2Feslint-import-resolver-custom-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaysent%2Feslint-import-resolver-custom-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaysent%2Feslint-import-resolver-custom-alias/lists"}