Search code examples
javascriptvisual-studio-codeeslintprettiereslintrc

ESlint javascript config - new line before first object in array removed


I'm using VS Code and the formatting option for it. When enabled it always removes empty lines on the first object in an array.

Example for Before formatting:

  var arr = [
    {
      id: 1
    },
    {
      id: 2
    }
  ]

becomes:

  var arr = [{
      id: 1
    },
    {
      id: 2
    }
  ]

after formatting. This messes up my code folding. What is the config in ESlint for this?

Eslint config as of now:

module.exports = {
  root: true,

  extends: ['eslint:recommended', 'plugin:vue/essential'],

  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-undef': 'off',
    'no-unused-vars': 'off',
  },

  parserOptions: {
    parser: 'babel-eslint',
  },

  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)',
      ],
      env: {
        mocha: true,
      },
    },
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)',
      ],
      env: {
        mocha: true,
      },
    },
  ],

  env: {
    node: true,
  },
}

Solution

  • This messes up my code folding. What is the config in ESlint for this?

    Enforce placing object properties on separate lines (object-property-newline).