Socket
Socket
Sign inDemoInstall

eslint-plugin-require-extensions

Package Overview
Dependencies
85
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-plugin-require-extensions

TypeScript [doesn't transform extensions](https://github.com/microsoft/TypeScript/issues/16577) and [doesn't enforce file extensions](https://github.com/microsoft/TypeScript/issues/42813).


Version published
Weekly downloads
41K
decreased by-33.56%
Maintainers
1
Install size
15.2 kB
Created
Weekly downloads
 

Readme

Source

eslint-plugin-require-extensions

TypeScript doesn't transform extensions and doesn't enforce file extensions.

This is a simple eslint plugin that ensures that relative imports and exports have .js extensions.

Credit for the original implementation goes to johnrees. ❤️

  1. Install
npm install --save-dev eslint-plugin-require-extensions
  1. Edit .eslintrc
{
    "extends": [
        "plugin:require-extensions/recommended"
    ],
    "plugins": [
        "require-extensions"
    ]
}
  1. Code
// source.js

import Target from './target';
  1. Lint
eslint .
source.js
  1:1  error  Relative imports and exports must end with .js  require-extensions/require-extensions
  1. Fix
eslint --fix .
// source.js

import Target from './target.js';

FAQs

Last updated on 22 Mar 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc