no-unresolved https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
After installing eslint-import-resolver-webpack
My .eslintrc config
JavaScript
x
22
22
1
{
2
"extends": "airbnb",
3
"rules": {
4
"comma-dangle": ["error", "never"],
5
"semi": ["error", "always"],
6
"react/jsx-filename-extension": 0,
7
"react/prop-types": 0,
8
"react/no-find-dom-node": 0,
9
"jsx-a11y/label-has-for": 0
10
},
11
"globals": {
12
"document": true,
13
"window": true
14
},
15
"env": {
16
"jest": true
17
},
18
"settings": {
19
"import/resolver": "webpack"
20
}
21
}
22
My package.json
JavaScript
1
80
80
1
{
2
"name": "coinhover",
3
"version": "0.0.1",
4
"main": "index.js",
5
"author": "Leon Gaban",
6
"license": "MIT",
7
"scripts": {
8
"start": "webpack-dev-server",
9
"dev": "webpack-dev-server",
10
"production": "webpack -p",
11
"build": "webpack -p",
12
"test": "eslint app && jest",
13
"test:fix": "eslint --fix app"
14
},
15
"now": {
16
"name": "coinhover",
17
"engines": {
18
"node": "7.4.x"
19
},
20
"alias": "coinhover.io"
21
},
22
"jest": {
23
"moduleNameMapper": {},
24
"moduleFileExtensions": [
25
"js",
26
"jsx"
27
],
28
"moduleDirectories": [
29
"node_modules"
30
]
31
},
32
"dependencies": {
33
"axios": "^0.16.1",
34
"babel-runtime": "6.11.6",
35
"jsonwebtoken": "^7.4.1",
36
"prop-types": "^15.5.10",
37
"ramda": "^0.24.1",
38
"react": "^15.5.4",
39
"react-dom": "^15.5.4",
40
"react-hot-loader": "next",
41
"react-redux": "^5.0.5",
42
"react-router": "^4.1.1",
43
"react-router-dom": "^4.1.1",
44
"redux": "^3.6.0",
45
"redux-thunk": "^2.2.0"
46
},
47
"devDependencies": {
48
"babel-core": "^6.24.1",
49
"babel-loader": "^7.0.0",
50
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
51
"babel-plugin-transform-runtime": "^6.23.0",
52
"babel-polyfill": "^6.23.0",
53
"babel-preset-env": "^1.5.1",
54
"babel-preset-es2015": "^6.24.1",
55
"babel-preset-react": "^6.24.1",
56
"babel-preset-react-hmre": "^1.1.1",
57
"babel-preset-stage-0": "^6.24.1",
58
"copy-webpack-plugin": "^4.0.1",
59
"css-loader": "^0.28.4",
60
"enzyme": "^2.8.2",
61
"enzyme-to-json": "^1.5.1",
62
"eslint": "^4.3.0",
63
"eslint-config-airbnb": "^15.1.0",
64
"eslint-import-resolver-webpack": "^0.8.3",
65
"eslint-plugin-import": "^2.7.0",
66
"eslint-plugin-jsx-a11y": "^5.1.1",
67
"eslint-plugin-react": "^7.1.0",
68
"extract-text-webpack-plugin": "^2.1.0",
69
"html-webpack-plugin": "^2.28.0",
70
"jest": "^20.0.4",
71
"node-sass": "^4.5.3",
72
"react-addons-test-utils": "15.0.0-rc.2",
73
"react-test-renderer": "^15.5.4",
74
"sass-loader": "^6.0.5",
75
"style-loader": "^0.18.1",
76
"webpack": "^2.6.1",
77
"webpack-dev-server": "^2.4.5"
78
}
79
}
80
Webpack
JavaScript
1
113
113
1
import fs from 'fs'
2
import webpack from 'webpack'
3
import HtmlWebpackPlugin from 'html-webpack-plugin'
4
import ExtractTextPlugin from 'extract-text-webpack-plugin'
5
import CopyWebpackPlugin from 'copy-webpack-plugin'
6
import path from 'path'
7
import chalk from 'chalk'
8
9
const coinhover = path.resolve(__dirname, "coinhover")
10
const src = path.resolve(__dirname, "public/src")
11
const log = console.log
12
// https://gist.github.com/leongaban/dc92204454b3513e511645af98107775
13
14
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
15
template: __dirname + '/public/src/index.html',
16
filename: 'index.html',
17
inject: 'body'
18
})
19
20
const ExtractTextPluginConfig = new ExtractTextPlugin({
21
filename: "coinhover.css",
22
disable: false,
23
allChunks: true
24
})
25
26
const CopyWebpackPluginConfig = new CopyWebpackPlugin([{ from: "public/src/static", to: "static" }])
27
28
const PATHS = {
29
app: src,
30
build: coinhover,
31
}
32
33
const LAUNCH_COMMAND = process.env.npm_lifecycle_event
34
35
const isProduction = LAUNCH_COMMAND === 'production'
36
process.env.BABEL_ENV = LAUNCH_COMMAND
37
38
const productionPlugin = new webpack.DefinePlugin({
39
'process.env': {
40
NODE_ENV: JSON.stringify('production')
41
}
42
})
43
44
const base = {
45
entry: [
46
PATHS.app
47
],
48
output: {
49
path: PATHS.build,
50
filename: 'index_bundle.js'
51
},
52
module: {
53
rules: [
54
{
55
test: /.jsx?$/,
56
exclude: /node_modules/,
57
use: ["babel-loader"]
58
},
59
{
60
test: /.scss$/,
61
use: ExtractTextPlugin.extract({
62
fallback: "style-loader",
63
use: ["css-loader", "sass-loader"],
64
publicPath: coinhover
65
})
66
}
67
],
68
loaders: [
69
{ test: /.js$/, exclude: /node_modules/, loader: 'babel-loader' },
70
{ test: /.css$/, loader: 'style-loader!css-loader' }
71
]
72
},
73
resolve: {
74
modules: ['node_modules', path.resolve(__dirname, 'public/src')]
75
}
76
}
77
78
const developmentConfig = {
79
devServer: {
80
publicPath: "",
81
contentBase: path.join(__dirname, "dist"),
82
// hot: false,
83
quiet: true,
84
inline: true,
85
compress: true,
86
stats: "errors-only",
87
open: true
88
},
89
devtool: 'cheap-module-inline-source-map',
90
plugins: [
91
CopyWebpackPluginConfig,
92
ExtractTextPluginConfig,
93
HtmlWebpackPluginConfig,
94
// new webpack.HotModuleReplacementPlugin()
95
]
96
}
97
98
const productionConfig = {
99
devtool: 'cheap-module-source-map',
100
plugins: [
101
CopyWebpackPluginConfig,
102
ExtractTextPluginConfig,
103
HtmlWebpackPluginConfig,
104
productionPlugin
105
]
106
}
107
108
log(`${chalk.magenta('🤖 ')} ${chalk.italic.green('npm run:')} ${chalk.red(LAUNCH_COMMAND)}`)
109
110
export default Object.assign({}, base,
111
isProduction === true ? productionConfig : developmentConfig
112
)
113
Advertisement
Answer
You can add an option to ignore case:
JavaScript
1
7
1
"rules": {
2
"import/no-unresolved": [
3
2,
4
{ "caseSensitive": false }
5
]
6
}
7
This thread at github also describes how the linter was checking case for parts of the path which come before the folder containing package.json. If you for example have the path:
C:/Workspace/app
and you navigate to it using cd C:/workspace/app
(lowercase workspace), the linter would also give an error on the imports. Looks like it should now be fixed, but perhaps you are still using an older version.