Skip to content

ESLint complaining about aliased `.json` modules with `import` syntax

When updating our code to use harmony modules import syntax for emoji-map and emoji-aliases, ESLint is complaining about the following:

import emojiMap from 'emoji-map';
import emojiAliases from 'emoji-aliases';
app/assets/javascripts/awards_handler.js
  3:22  error  Missing file extension "json" for "emoji-map"      import/extensions
  4:26  error  Missing file extension "json" for "emoji-aliases"  import/extensions

webpack.config.js

resolve: {
  extensions: ['.js', '.es6', '.js.es6'],
  alias: {
    'emoji-map$':     path.join(ROOT_PATH, 'fixtures/emojis/digests.json'),
    'emoji-aliases$': path.join(ROOT_PATH, 'fixtures/emojis/aliases.json'),
  }
}

I played around with the .eslintrc and webpack.config.js which gets pulled in by the .eslintrc but haven't found a winning combo yet.

See https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md

I created an issue on the benmosher/eslint-plugin-import repo, https://github.com/benmosher/eslint-plugin-import/issues/764


cc @mikegreiling