eslint-plugin-require-extensions

0.1.3 • Public • Published

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';

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-require-extensions

Weekly Downloads

64,881

Version

0.1.3

License

Apache-2.0

Unpacked Size

15.5 kB

Total Files

4

Last publish

Collaborators

  • jordansexton