Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rollup and eslint : How can I fix this error "TypeError: eslint is not a function" using eslint with rollup?

Tags:

eslint

rollup

I'm trying to use rollup for the first time and I can't figure out why I get this error :

TypeError: eslint is not a function

I previously installed rollup (v1.1.0) then eslint npm install rollup-plugin-eslint (v5.0.0)

here is my 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/**',
        }),
    ],
}

When I use ./node_modules/.bin/rollup -c I get this error TypeError: eslint is not a function. (NB : rollup is working fine with only babel)

However it works if I use npm run lint adding this code in package.json

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

What do I do wrong with the rollup configuration ? Thanks for your help

like image 311
Anne Claire Avatar asked Jan 26 '23 20:01

Anne Claire


1 Answers

Try changing:

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

Release notes for v5.0.0

like image 196
a-sie Avatar answered Apr 24 '23 07:04

a-sie