Search code examples
eslintdate-fns

How to set up imported multiple times rule for date-fns in eslint?


I am using import of date-fns functions like this:

import addHours from 'date-fns/addHours';
import addDays from 'date-fns/addDays';

But also I am getting an error from eslint: node_modules/date-fns/typings.d.ts' imported multiple times.eslintimport/no-duplicates

What is wrong? It is not multiple import, I am importing from different level.

How can I fix it without disable multiple import rule?


Solution

  • This is a know issue with date-fns library

    Here are the issues

    1. [Typescript] I can't import the translation (locale) of the terms in typescript.

    2. Is there any good way to import locale and other function within one line?