Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Proposal: Disallow certain extensions in import path #209

Closed
lo1tuma opened this issue Mar 6, 2016 · 1 comment · Fixed by #250
Closed

Rule Proposal: Disallow certain extensions in import path #209

lo1tuma opened this issue Mar 6, 2016 · 1 comment · Fixed by #250

Comments

@lo1tuma
Copy link
Contributor

lo1tuma commented Mar 6, 2016

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';
@benmosher
Copy link
Member

Interesting. This is almost the converse of #204.

Makes me think maybe a rule could support both by either enforcing extensions (import/extensions: [2, 'always'] for #204) or rejecting them, for this (import/extensions: [2, never: [js, jsx, json]]).

For my memory: may want to stat paths that fail to check that they don't exist without an extension (i.e. directories)

@lo1tuma lo1tuma changed the title Rule Proposal: Disallow file certain extensions in import path Rule Proposal: Disallo certain extensions in import path Mar 7, 2016
@lo1tuma lo1tuma changed the title Rule Proposal: Disallo certain extensions in import path Rule Proposal: Disallow certain extensions in import path Mar 7, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 20, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 20, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 20, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 20, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 20, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 20, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 22, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Apr 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants