Skip to content

Repository files navigation

Global Brain: ESLint Config

Global Brain's shared ESLint configuration, built on top of @antfu/eslint-config. It provides opinionated defaults with the flexibility to customize them for your project.

Usage

Installation

Install ESLint and the shared configuration as development dependencies:

pnpm add -D eslint @globalbrain/eslint-config

Configuration

Create an eslint.config.js file in your project root:

import globalbrain from '@globalbrain/eslint-config'

export default globalbrain()

Lint scripts

Add the following scripts to your package.json:

{
  "scripts": {
    "lint": "eslint . --fix",
    "lint:fail": "eslint ."
  }
}

Run pnpm lint to lint your project and apply automatic fixes. Use pnpm lint:fail to check for lint errors without modifying files, for example in CI.

Customization

The globalbrain() factory accepts:

  • An optional first argument containing options for @antfu/eslint-config.
  • Any number of additional ESLint configuration objects, appended after the preset to extend or override its rules.

For example, enable Markdown formatting and add a rule for JavaScript and TypeScript files:

import globalbrain from '@globalbrain/eslint-config'

export default globalbrain(
  { formatters: { markdown: true } },
  {
    files: ['**/*.{js,ts}'],
    rules: {
      'no-console': 'warn'
    }
  }
)

Enabling formatters requires installing eslint-plugin-format as a development dependency:

pnpm add -D eslint-plugin-format

See the formatters' documentation for more options.

The factory returns a FlatConfigComposer from eslint-flat-config-utils, so you can also chain methods to further customize the configuration.

License

Licensed under the MIT license.

About

Global Brain's ESLint config preset

Topics

Resources

Stars

4 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages