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



我正在尝试将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,但得到了这个错误:

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,
...
}

最新更新