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.
Install ESLint and the shared configuration as development dependencies:
pnpm add -D eslint @globalbrain/eslint-configCreate an eslint.config.js file in your project root:
import globalbrain from '@globalbrain/eslint-config'
export default globalbrain()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.
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-formatSee 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.
Licensed under the MIT license.