汇总和eslint:如何在汇总中使用eslint来解决此错误“ TypeError:eslint不是函数”?

时间:2019-01-21 15:29:38

标签: eslint rollup

我正在尝试第一次使用汇总,但我不知道为什么会出现此错误:

TypeError: eslint is not a function

我以前安装了汇总(v1.1.0),然后附加了npm install rollup-plugin-eslint(v5.0.0)

这是我的rollup.config.js

import babel from 'rollup-plugin-babel';
import eslint from 'rollup-plugin-eslint';

export default {
    input: 'src/main.js',
    output: {
        format: 'iife',
        file: 'build/js/main.min.js',
        name: 'main'
    },
    plugins: [
        eslint({
            exclude: [
                'src/styles/**',
            ]
        }),
        babel({
            exclude: 'node_modules/**',
        }),
    ],
}

使用./node_modules/.bin/rollup -c时出现此错误TypeError: eslint is not a function。 (注意:汇总仅使用Babel即可正常工作)

但是,如果我使用npm run lint在package.json中添加此代码,它会起作用

"scripts": {
    "lint": "eslint src/**"
  }

汇总配置有什么问题? 谢谢您的帮助

1 个答案:

答案 0 :(得分:2)

尝试更改:

- import eslint from 'rollup-plugin-eslint';
+ import { eslint } from 'rollup-plugin-eslint';

Release notes for v5.0.0