如何在eslint中为date-fns设置多次导入规则?

问题描述

我正在使用date-fns这样的函数导入:

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

但是我也从eslint那里得到一个错误node_modules/date-fns/typings.d.ts' imported multiple times.eslintimport/no-duplicates

怎么了?这不是多次导入,我是从不同级别导入的。

如何在不禁用多个导入规则的情况下进行修复?

解决方法

这是date-fns库的已知问题

这是问题

  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?