Skip to content
This plugin adds TypeScript support to `eslint-plugin-import`.
TypeScript JavaScript Shell
Branch: master
Clone or download
Pull request Compare This branch is 7 commits ahead, 15 commits behind alexgorbatchev:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows chore: bump (dev)Dependencies, ignore node engines Oct 21, 2019
dummy.js
src chore: migrate from @1stg/rollup-config to @pkgr/rollup Oct 6, 2019
tests feat: replace glob with tiny-glob for faster speed, close #12 Sep 22, 2019
.commitlintrc chore(deps): upgrade configurations Sep 17, 2019
.editorconfig refactor: change code base to TypeScript, better workflow Sep 11, 2019
.eslintignore chore: stricter lint rules for tests Sep 12, 2019
.gitignore chore: stricter lint rules for tests Sep 12, 2019
.huskyrc.js refactor: change code base to TypeScript, better workflow Sep 11, 2019
.lintstagedrc.js chore: bump (dev)Dependencies, ignore node engines Oct 21, 2019
.prettierignore chore: change .eslintrc location Oct 6, 2019
.prettierrc refactor: change code base to TypeScript, better workflow Sep 11, 2019
.remarkrc
.renovaterc
.yarnrc
CHANGELOG.md chore(release): 0.4.2 Oct 2, 2019
README.md feat: replace glob with tiny-glob for faster speed, close #12 Sep 22, 2019
codechecks.yml feat: replace glob with tiny-glob for faster speed, close #12 Sep 22, 2019
deploy.sh chore: bump (dev)Dependencies, ignore node engines Oct 21, 2019
package.json chore: bump (dev)Dependencies, ignore node engines Oct 21, 2019
tsconfig.json
yarn.lock chore: bump (dev)Dependencies, ignore node engines Oct 21, 2019

README.md

eslint-import-resolver-ts

GitHub Actions type-coverage npm GitHub Release

David Peer David David Dev

Conventional Commits JavaScript Style Guide Code Style: Prettier codechecks.io

This plugin adds TypeScript support to eslint-plugin-import.

This means you can:

  • import/require files with extension .ts/.tsx!
  • Use paths defined in tsconfig.json.
  • Prefer resolve @types/* definitions over plain .js.
  • Multiple tsconfigs support just like normal.

TOC

Installation

# npm
npm i -D eslint-plugin-import @typescript-eslint/parser eslint-import-resolver-ts

# yarn
yarn add -D eslint-plugin-import @typescript-eslint/parser eslint-import-resolver-ts

Configuration

Add the following to your .eslintrc config:

{
  "plugins": ["import"],
  "rules": {
    // turn on errors for missing imports
    "import/no-unresolved": "error"
  },
  "settings": {
    "import/parsers": {
      "@typescript-eslint/parser": [".ts", ".tsx"]
    },
    "import/resolver": {
      // use <root>/tsconfig.json
      "ts": {
        "alwaysTryTypes": true // always try to resolve types under `<roo/>@types` directory even it doesn't contain any source code, like `@types/unist`
      },

      // use <root>/path/to/folder/tsconfig.json
      "ts": {
        "directory": "./path/to/folder"
      },

      // Multiple tsconfigs (Useful for monorepos)

      // use a glob pattern
      "ts": {
        "directory": "./packages/*/tsconfig.json"
      },

      // use an array
      "ts": {
        "directory": [
          "./packages/module-a/tsconfig.json",
          "./packages/module-b/tsconfig.json"
        ]
      },

      // use an array of glob patterns
      "ts": {
        "directory": [
          "./packages/*/tsconfig.json",
          "./other-packages/*/tsconfig.json"
        ]
      }
    }
  }
}

Contributing

  • Make sure your change is covered by a test import.
  • Make sure that yarn test passes without a failure.
  • Make sure that yarn lint passes without conflicts.
  • Make sure your code changes match our type-coverage settings: yarn type-coverage.

We have GitHub Actions which will run the above commands on your PRs.

If either fails, we won't be able to merge your PR until it's fixed.

You can’t perform that action at this time.