eslint webpack解析器不起作用

时间:2017-01-05 02:23:22

标签: webpack eslint

我有一些variant文件,我已将webpack配置为包含。

.coffee

我已将// inside `webpack.config.js`... resolve: { // tell webpack which extensions to auto search when it resolves modules. With this, // you'll be able to do `require('./utils')` instead of `require('./utils.js')` extensions: ['', '.js', '.coffee', '.jsx'], // by default, webpack will search in `web_modules` and `node_modules`. Because we're using // Bower, we want it to look in there too modulesDirectories: ['node_modules', 'bower_components'], alias: { 'jquery.ui.widget': 'jquery-ui/ui/widget.js', 'jquery-ui/widget': 'jquery-ui/ui/widget.js', 'jquery-ui-css': 'jquery-ui/../../themes/base' } }, 安装到我的项目中,并在我的eslint-import-resolver-webpack文件中进行设置:

.eslintrc.json

出于某种原因,我仍然会得到"settings": { "import/parser": "babel-eslint", "import/resolver": { "webpack": { "config": "webpack.config.js" } } }, 这样一行的linting错误:

import/no-unresolved

目录中有import foo from './my-coffee-file'

关于出了什么问题的任何想法?

1 个答案:

答案 0 :(得分:2)

我的问题是由于我项目的目录结构......

config
|__webpack.config.js
|
frontend
|__package.json
|__all the JS/coffee files

所以我需要明确指向webpack配置文件:

"settings": {
    "import/resolver": {
        "webpack": { "config": "../config/webpack.config.js" }
    }
}

../是必要的,因为它会在找到package.json的位置开始搜索,这对我来说就在frontend目录中。