@exodus/eslint-plugin-require-extensions
v1.0.0
Published
ESLint plugin to require file extensions in import statements
Downloads
3,837
Maintainers
Keywords
Readme
@exodus/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. ❤️
- Install
npm install --save-dev eslint-plugin-require-extensions
- Edit
.eslintrc
{
"extends": ["plugin:@exodus/require-extensions/recommended"],
"plugins": ["@exodus/require-extensions"]
}
- Code
// source.js
import Target from './target'
- Lint
eslint .
source.js
1:1 error Relative imports and exports must end with .js require-extensions/require-extensions
- Fix
eslint --fix .
// source.js
import Target from './target.js'