eslint - 汇总和 eslint : How can I fix this error "TypeError: eslint is not a function" using eslint with rollup?

标签 eslint rollup

我第一次尝试使用汇总,但我不明白为什么会出现此错误:

TypeError: eslint is not a function
我之前安装了 rollup (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/**',
        }),
    ],
}
当我使用 ./node_modules/.bin/rollup -c我收到此错误 TypeError: eslint is not a function . (注意:汇总仅使用 babel 即可正常工作)
但是,如果我使用 npm run lint,它会起作用在 package.json 中添加此代码
"scripts": {
    "lint": "eslint src/**"
  }
汇总配置有什么问题?
谢谢你的帮助

最佳答案

尝试改变:

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

Release notes for v5.0.0

关于eslint - 汇总和 eslint : How can I fix this error "TypeError: eslint is not a function" using eslint with rollup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54293089/

相关文章:

typescript - 在baseUrl之外导入文件时汇总+ Typescript错误

javascript - 解析源映射失败

javascript - TSLint。最大语句规则 - 可用吗?

javascript - 预期的 catch() 或返回(promise/catch-or-return)

javascript - 为什么 eslint 认为 "typeof v === ' string'"无效

javascript - 从 javascript 包的子文件夹导入

Mysql:通过不同的值(value)循环创建具有各种选择的过程

javascript - 错误 : Unexpected token (Note that you need plugins to import files that are not JavaScript) rollup vue package

javascript - 将 @author 的使用视为代码风格违规

reactjs - 'React' 在定义之前就被使用了