New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tslint-proper-import-require

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

  • 0.0.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 27 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc