0.0.6 • Published 7 years ago

tslint-proper-import-require v0.0.6

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

tslint-proper-import-require

A TSLint rule that verifies whether you should be using the import from or import require syntax when importing an external module to follow the ES6 spec, without depending on workarounds supplied by Typescript that have the potential to be removed in the future.

The rule works by resolving your specified module and checking if __esModule exists in the modules main exported file, and then reports accordingly.

Usage

In your tslint.json set the following:

{
  "extends": ["tslint-proper-import-require"],
  "rules": {
    "proper-import-require": true
  }
}

Examples

Importing an < ES6 module

example-module/index.js

module.exports = function() {
  return 'foo':
}

index.ts

import * as ExampleModule from 'example-module'; // Incorrect
import ExampleModule = require('example-module'); // Correct

Importing an ES6 module

example-module/index.js

export function foo() {
  return 'bar';
}

index.ts

import * as ExampleModule from 'example-module'; // Correct
import { foo } from 'example-module'; // Correct
import ExampleModule = require('example-module'); // Incorrect
0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago