繁体   English   中英

将 eslint 配置从 json 转换为 JavaScript 会在导出配置时引发错误

[英]Converting eslint config from json to JavaScript throws error when exporting config

我正在尝试将我的 eslint 配置从 json 转换为 JavaScript。

从 .eslintrc.js 中导出配置对象后,如文档中的sys :

JavaScript - 使用 .eslintrc.js 并导出包含您的配置的对象。

我收到错误:

(function (exports, require, module, __filename, __dirname) { export default {
                                                              ^^^^^^

SyntaxError: Unexpected token export
    at new Script (vm.js:83:7)

这是我的配置的前几行:

export default {
    env: {
        browser: true,

我该如何修复错误?

更新

我已经命名了对象并导出了常量,但出现了这个错误:

const config = {
    env: {
export default config;
^^^^^^

SyntaxError: Unexpected token export
    at new Script (vm.js:83:7)

你应该像这样使用 module.exports:

module.exports = {
  putYour: "config here"
};

这就是你所需要的

这是我在 .eslintrc.js 中的内容:

module.exports = {
    env: {
        browser: true,
...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM