抑制导入的node_modules CSS 中的 eslint 警告

问题描述 投票:0回答:1

某些依赖项要求您将 CSS 从 node_modules 导入到您的文件中。

// editor.js
import 'froala-editor/css/froala_editor.pkgd.css';
import FroalaEditor from 'react-froala-wysiwyg';

export default = () => <FroalaEditor />

在这种情况下,包的 CSS 文件可能会导致错误。

Compiled with warnings.

./node_modules/froala-editor/css/froala_editor.pkgd.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./node_modules/froala-editor/css/froala_editor.pkgd.css)

Warning
(1990:3) Replace fill-available to stretch, because spec had been changed

./node_modules/froala-editor/css/froala_editor.pkgd.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./node_modules/froala-editor/css/froala_editor.pkgd.css)

Warning
(2047:3) Replace fill-available to stretch, because spec had been changed

./node_modules/froala-editor/css/froala_editor.pkgd.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./node_modules/froala-editor/css/froala_editor.pkgd.css)

Warning
(2111:3) Replace fill-available to stretch, because spec had been changed

eslint 禁用来自 node_modules 的 lint 警告,除了导入文件时之外。您如何抑制这些警告?

我尝试过的:

  • 添加文件名 .eslintignore
  • // 在 editor.js 中导入之前 eslint-disable-next-line
javascript eslint froala
1个回答
0
投票

这本身不是 ESLint 警告,而是来自 PostCSS 的警告。具体来说,它是由autoprefixer生成的。 (这是一个有效的警告,拉伸会自动添加前缀为

fill-available
)要抑制该错误,您应该禁用 PostCSS/Autoprefixer 在您导入的外部 CSS 上运行。执行此操作的方法取决于所使用的特定构建工具链。

© www.soinside.com 2019 - 2024. All rights reserved.