import-js / import-js/eslint-plugin-import

ESlint: Missing file extension for jquery when configured as webpack externals using the webpack resolver

Open
#1,097 6 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

`import $ from 'jquery';` triggers `import/extensions` and when the js extension is added, `import/no-unresolved`.

my .eslintrc is:

```
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"airbnb-base",
"prettier"
],
"parser": "babel-eslint",
"plugins": [
"prettier"
],
"root": true,
"rules": {
"indent": ["error", 4, { "SwitchCase": 1 }],
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"no-underscore-dangle": 0,
"prettier/prettier": "error"
},
"settings": {
"import/ignore": ["\\.(scss|less|css)$"],
"import/resolver": {
"webpack": {
"config": "./webpack.config.js"
}
}
}
}
```

webpack.config.js has

```
externals: {
jquery: 'jQuery'
},
```

Note that the build works as intended with the latest version of eslint, webpack and all other modules..

Contributor guide

Open the contributing guide

Research direction

Start with the reported .eslintrc settings and webpack.config.js externals entry for jquery, then reproduce the conflicting import/extensions and import/no-unresolved results. Trace the webpack resolver's handling of externals and verify that the jquery import is resolved consistently without either error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.