{"id":18932258,"url":"https://github.com/bradennapier/eslint-plugin-ts-import","last_synced_at":"2025-04-15T16:33:42.619Z","repository":{"id":38174322,"uuid":"273350554","full_name":"bradennapier/eslint-plugin-ts-import","owner":"bradennapier","description":"Provide import-patterns that are expected to be followed within the rep","archived":false,"fork":false,"pushed_at":"2025-02-14T19:24:30.000Z","size":1988,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:43:30.650Z","etag":null,"topics":["eslint","eslintplugin","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/bradennapier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-06-18T22:17:00.000Z","updated_at":"2023-03-08T03:01:33.000Z","dependencies_parsed_at":"2025-03-06T13:02:15.113Z","dependency_job_id":"65452d2d-219d-4062-b0a9-ea31631a5f3b","html_url":"https://github.com/bradennapier/eslint-plugin-ts-import","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradennapier%2Feslint-plugin-ts-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradennapier%2Feslint-plugin-ts-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradennapier%2Feslint-plugin-ts-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradennapier%2Feslint-plugin-ts-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradennapier","download_url":"https://codeload.github.com/bradennapier/eslint-plugin-ts-import/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804825,"owners_count":21164135,"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":["eslint","eslintplugin","typescript"],"created_at":"2024-11-08T11:48:34.985Z","updated_at":"2025-04-15T16:33:42.290Z","avatar_url":"https://github.com/bradennapier.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\n    \u003cbr/\u003e\n    \u003cbr/\u003e\n    \u003cp align=\"center\"\u003e\n      \u003cimg src=\"docs/img/style.png\" width=\"400\" title=\"eslint-plugin-ts-import\"\u003e\n    \u003c/p\u003e\n    \u003cbr /\u003e\n    eslint-plugin-ts-import\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n  \u003c/h1\u003e\n  \u003csup\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://www.npmjs.com/package/eslint-plugin-ts-import\"\u003e\n       \u003cimg src=\"https://img.shields.io/npm/v/eslint-plugin-ts-import.svg\" alt=\"npm package\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- TODO\n     \u003ca href=\"https://www.npmjs.com/package/eslint-plugin-ts-import\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/dm/eslint-plugin-ts-import.svg\" alt=\"npm downloads\" /\u003e\n    \u003c/a\u003e\n    --\u003e\n    \u003c!-- TODO\n    \u003ca href=\"http://bradennapier.github.io/eslint-plugin-ts-import\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/demos-🚀-yellow.svg\" alt=\"demos\" /\u003e\n    \u003c/a\u003e\n    --\u003e\n    \u003cbr /\u003e\n    Define specific import rules for files within your \u003ca href=\"https://www.typescriptlang.org/index.html\"\u003e Typescript \u003c/a\u003e project.  Adapted and enhanced from \u003ca href=\"https://github.com/microsoft/vscode\"\u003eVSCode's\u003c/a\u003e \u003ca href=\"https://github.com/microsoft/vscode/blob/master/build/lib/eslint/code-import-patterns.ts\"\u003ecode-import-patterns\u003c/a\u003e\n  \u003c/sup\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cpre\u003eyarn add --dev \u003ca href=\"https://www.npmjs.com/package/eslint-plugin-ts-import\"\u003eeslint-plugin-ts-import\u003c/a\u003e\u003c/pre\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n\u003c/div\u003e\n\n## Features\n\n- Provide import patterns that restrict imports of certain files based on location.\n- Ensure imports meet the expected guidelines within your repo.\n- Adapted from VSCode's rule `code-import-patterns`.\n- Works with configured `paths` from your `tsconfig.json`\n- Provide custom eslint messaging for each pattern if needed.\n- Useful in monorepos and most Typescript projects which utilize incremental builds.\n\n## Simple Example\n\n```javascript\n// .eslintrc.js\n\nmodule.exports = {\n  root: true,\n  parser: '@typescript-eslint/parser',\n  rules: {\n    'ts-import/patterns': [\n      'error',\n      {\n        // these rules apply to any files which are within the src/services directory\n        target: '**/src/services/*/**',\n\n        // allow any imports to node_modules.  We confirm that the node_module exists in case the use of paths / absolute imports is used so that\n        // we can tell the difference\n        modules: true,\n\n        // allow imports of node core modules?  defaults to true.  if false, imports like fs, path, stream will cause an error\n        node: true,\n\n        allowed: [\n          // anything in src/services/{service}/** may import config `import config from 'config'`\n          'config',\n\n          // anything in src/services/{service}/** may import from core `import someModule from 'core/someModule'`\n          'core/**',\n\n          // run target.replace(arr[0], arr[1]) to build pattern\n          // any service may import from itself - so src/services/rest-api/** may always import from `src/services/rest-api/**`\n          // whether using relative or absolute imports.  However it will not be able to import from `../api-client/**` or `services/api-client/**`\n          [/.*\\/src\\/services\\/([^/]*)\\/.*/, '**/src/services/$1/**'],\n\n          // allow any imports whether relative or absolute as long as they are not higher than /src/services\n          [/(.*\\/src\\/services).*/, '$1/**'],\n\n          // this rule without the above rule would only allow the files to import themselves or higher and would restrict `../`\n          './**',\n        ],\n        message:\n          'Optional custom message to display when violated',\n      },\n    ],\n  },\n  plugins: ['ts-import']\n}\n```\n\n## Special Thanks\n\n- While originally utilizing custom logic, we since borrowed the resolving method used by [eslint-import-resolver-typescript](https://github.com/alexgorbatchev/eslint-import-resolver-typescript).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradennapier%2Feslint-plugin-ts-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradennapier%2Feslint-plugin-ts-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradennapier%2Feslint-plugin-ts-import/lists"}