ESLint Prefer default export import/prefer-default-export

roshambo picture roshambo · Oct 3, 2018 · Viewed 36.7k times · Source

Hi there I am struggling to understand / have this eslint error disappear with my React Project.

Prefer default export import/prefer-default-export

Helpers.js error is pointing to:

export function getItems() {
  fetch('./data/data_arr.js')
  .then(results => results.json())
  .then(results => this.setState({ items: results }));
}

import of function:

import { getItems } from '../helpers/helpers';

componentDidMount() {
    getItems.call(this);
}

I have tried to no avail:

"rules": {
     "import/prefer-default-export": off,
     ...
}

Do I need to add "default" to the function? export default function getItems() {...}

Thank you

Answer

SET picture SET · Dec 3, 2019
"rules": {
     "import/prefer-default-export": "off",
     ...
}

The word off has to be quoted.