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

Ann*_*ire 2 rollup eslint

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

TypeError: eslint is not a function
Run Code Online (Sandbox Code Playgroud)

我以前安装了汇总(v1.1.0),然后安装了eslint 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/**',
        }),
    ],
}
Run Code Online (Sandbox Code Playgroud)

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

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

"scripts": {
    "lint": "eslint src/**"
  }
Run Code Online (Sandbox Code Playgroud)

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

a-s*_*rra 5

尝试更改:

- import eslint from 'rollup-plugin-eslint';
+ import { eslint } from 'rollup-plugin-eslint';
Run Code Online (Sandbox Code Playgroud)

v5.0.0发行说明