Skip to content

Repository files navigation

@sequencemedia/eslint-merge

Merge Flat Config for ESLint v9

Install

npm i -D @sequencemedia/eslint-merge

Use

The merge function combines two objects and returns the result

import merge from '@sequencemedia/eslint-merge'

The first argument should be a config, and the second argument an object which contains your changes

const result = merge(sharedConfig, changes)

You can easily achieve this with the spread operator in your eslint.config.*

/**
 *  You probably will use `import` to get this as a module!
 */
const sharedConfig = {
  name: 'shared config',
  files: [
    '**/*.{js,mjs,cjs}'
  ]
}

export default [
  {
    ...sharedConfig,
    files: [
      'src/**/*.{mjs,cjs}'
    ]
  }
]

But! Sometimes you need to make lots of changes, and many spreads is hard to manage, and hard to read

@sequencemedia/eslint-merge enables you to merge just your changes

/**
 *  Again, you will probably `import` this
 */
const sharedConfig = {
  name: 'shared config',
  files: [
    '**/*.{js,mjs,cjs}'
  ]
}

export default [
  merge(sharedConfig, {
    files: [
      'src/**/*.{mjs,cjs}'
    ]
  })
]

It's simpler to use spread for small projects, but for large or complex configurations (or for producing your own shared configs) use merge

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages