Skip to content

Commit

Permalink
enable import/extensions rule
Browse files Browse the repository at this point in the history
I'm explicitly specifying extensions so it won't report when using for example `require('lodash.template')` and the dependency is not resolvable (read not installed). Also people might use Webpack and require files like `.css` and `.png` and those extensions should definitely be included. Read more: import-js/eslint-plugin-import#378
  • Loading branch information
sindresorhus committed Jun 16, 2016
1 parent 4bb9eb6 commit ae7451c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions config/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ module.exports = {
// disabled because of https://github.com/benmosher/eslint-plugin-import/issues/268
// 'import/default': 2,
'import/export': 2,
// disabled because of https://github.com/benmosher/eslint-plugin-import/issues/378
// 'import/extensions': [2, 'never'],
'import/extensions': [2, {
js: 'never',
json: 'never',
jsx: 'never'
}],
'import/imports-first': 2,
// disabled because of https://github.com/benmosher/eslint-plugin-import/issues/268
// 'import/named': 2,
Expand Down

3 comments on commit ae7451c

@sholladay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using rollup with rollup-plugin-json (an awesome setup, btw) and this bit me. Without .json, it can't resolve the dependency.

I'm not asking for anything necessarily. I'll probably open an issue on rollup. Just pointing out that this might be painful. How are you going to handle things like cat-names.json (when this rule eventually applies there)? Which tools besides Node itself lookup .json?

@sindresorhus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which tools besides Node itself lookup .json?

Browserify at least, but all of them should. If it works in Node.js it should work with the packer. Otherwise the tool is fragmenting the community and annoys maintainers by users opening issues about it not working with their tool. You have no idea how many dumb webpack issues I've gotten on my repos because webpack v1 wasn't fully compatible with the Node.js resolution algorithm. IMHO, but rollup should bundle the rollup-plugin-json by default. Users shouldn't have to know or care that a module in their dependency tree is using require('./package') pointing at a JSON file. Hope you'll open an issue on Rollup about this, and thanks for bringing it up :)

@sholladay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. As a Node-based tool, overwhelmingly used by Node developers for projects designed using Node paradigms, it should follow suit.

I've opened rollup/rollup#1047.

Please sign in to comment.