Converting eslint config from json to JavaScript throws error when exporting config

Viewed 2151

I am trying to convert my eslint config from json to JavaScript.

After exporting a config object from .eslintrc.js like it sys in the docs:

JavaScript - use .eslintrc.js and export an object containing your configuration.

I get the error:

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

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

This is the first couple of lines of my config:

export default {
    env: {
        browser: true,

How can I fix the error?

Update

I have named the object and exported the const but get this error:

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

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

you should use module.exports like this:

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

thats all that you need

This is what I have in my .eslintrc.js :

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