babeljs - 如何清除babel缓存?

标签 babeljs eslint

我看到我的 eslint 规则应用于 VSCode,但它们在 Babel 中不起作用。 我认为我需要清除缓存,但我不知道该怎么做。

你能告诉我怎么做吗?

规则

"@typescript-eslint/camelcase": ["warn"],
"camelcase": "off"

Babel 输出

enter image description here

vscode 输出

enter image description here

最佳答案

如果您使用的是如下所示的 babel.config.js 文件。您可以通过将 false 传递给 api.cache(false) 来关闭缓存

module.exports = function (api) {
  const presets = [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage',
        corejs: { version: 3, proposals: true }
      }
    ],
    '@babel/preset-react',
    '@babel/preset-flow'
  ];
  const plugins = [

    'lodash',
    ['@babel/plugin-transform-spread', { loose: true }],
    ['@babel/plugin-proposal-class-properties', { loose: true }],
    '@babel/plugin-transform-runtime'
  ];

  /** this is just for minimal working purposes,
     * for testing larger applications it is
     * advisable to cache the transpiled modules in
     * node_modules/.bin/.cache/@babel/register* */
  api.cache(false);

  return {
    presets,
    plugins
  };
};

关于babeljs - 如何清除babel缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62296203/

相关文章:

javascript - 导出的标识符 "_default"未在 Babel 的范围跟踪器中声明

javascript - 在 TypeScript React Web 应用程序中使用 javascript 库

javascript - 更新对象数组而不改变

reactjs - EsLint 错误解释 no-unused-vars 中的导入语句

javascript - 将 Node.js 文件转换为 ES5

module - 在 ES6 模块中通过字符串访问导出函数

npm - 如何修复 ESLint 中的意外 token ?

javascript - Visual Studio 中的 EsLint - 无法在 javascript 文件上使用静态属性

css - 如何解决错误 'The name of the class AccordionGroup should end with the suffix Component'

javascript - Eslint 在 VScode 中不工作,但在终端工作