JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6569
  • Score
    100M100P100Q126482F
  • License AGPL-3.0-or-later

ESLint rule enforcing supporting typescript paths

Package Exports

  • eslint-plugin-typescript-paths
  • eslint-plugin-typescript-paths/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-typescript-paths) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Installation

npm i -D eslint-plugin-typescript-paths

Requirements

It is recommended that you have already set up eslint-plugin-import, @typescript-eslint and eslint-import-resolver-typescript in your project beforehand.

Alternatively, you can simply use a level 2 Kiskadee setup that already includes all the prerequisite configuration and additionally supports this plugin.

Usage

To use the recommended rules, in the .eslintrc (or equivalent) file, extend plugin:typescript-paths/recommended.

  module.exports = {
    extends: ['plugin:typescript-paths/recommended'],
    rules: {
      // your rules
    },
  };

If you want to customize the rules, define 'typescript-paths' plugin.

  module.exports = {
    plugins: ['typescript-paths'],
    rules: {
      // your rules
    },
  };

Rules

absolute-import

Controls whether the import can be absolute if the source is in the same directory.

Options

  • enableAlias: boolean. Default: false. If true, the use of absolute import will be recommended even if the source is from the same directory or below.
  // .eslintrc
  module.exports = {
    rules: {
      'typescript-paths/absolute-import': 'warn'
      // 'typescript-paths/absolute-import': ['warn', { enableAlias: false } ]
    },
  };

absolute-export

Controls whether the export can be absolute if the source is in the same directory or below.

Options

  • enableAlias: boolean. Default: false. If true, the use of absolute export will be recommended even if the source is from the same directory or below.
  // .eslintrc
  module.exports = {
    rules: {
      'typescript-paths/absolute-export': 'warn'
      // 'typescript-paths/absolute-export': ['warn', { enableAlias: false } ]
    },
  };

absolute-parent-import

Encourages the use of absolute imports from parent directories.

Options

  • preferPathOverBaseUrl: boolean. Default: true. If false, it stops suggesting the use of aliases and starts accepting imports from the source baseUrl as well.
  // .eslintrc
  module.exports = {
    rules: {
      'typescript-paths/absolute-parent-import': 'warn'
      // 'typescript-paths/absolute-parent-import': ['warn', { preferPathOverBaseUrl: true } ]
    },
  };

absolute-parent-export

Encourages the use of absolute exports from parent directories.

Options

  • preferPathOverBaseUrl: boolean. Default: true. If false, it stops suggesting the use of aliases and starts accepting exports from the source baseUrl as well.
  // .eslintrc
  module.exports = {
    rules: {
      'typescript-paths/absolute-parent-export': 'warn'
      // 'typescript-paths/absolute-parent-export': ['warn', { preferPathOverBaseUrl: true } ]
    },
  };