Skip to content

Rule Proposal: Disallow certain extensions in import path #209

@lo1tuma

Description

@lo1tuma

When I transpile my .jsx files with babel they will be renamed to have a .js extension. That’s why I usually avoid the .jsx extentions in the import path, but sometimes other contributors of my project commit code that has import statements with file extensions.

Having an eslint rule would be perfect to identify such problems.

When the rule is configured with: no-import-file-extensions: [ 2, [ '.js', '.jsx', '.json' ] ] this would be considered as problems:

import Foo from './Foo.jsx';
import lib from './lib.js';
import data from './data.json';

This would not be considered as a problem:

import Foo from './Foo';
import lib from './lib';
import data from './data';

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions