Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@karibsen/eslint-config

Shared ESLint flat config for Karibsen Studio projects. Written in TypeScript, with a framework-agnostic scope: no Nuxt or Vue dependency.

Features

  • Flat config only, built for ESLint 9 and 10
  • TypeScript rules without type-checking, so there is no project option to wire up
  • Formatting rules generated from @stylistic, consistent across every repo
  • Import and export sorting via simple-import-sort
  • Composable: every block is exported on its own, and the result keeps chaining

Installation

pnpm add -D @karibsen/eslint-config eslint

ESLint is a peer dependency (^9 or ^10), so the consuming project picks its own version.

Usage

// eslint.config.ts
import { karibsen } from "@karibsen/eslint-config";

export default karibsen();

karibsen() returns a FlatConfigComposer, so you can keep chaining:

import { karibsen } from "@karibsen/eslint-config";

export default karibsen({ stylistic: { quotes: "single" } })
  .append({
    files: ["scripts/**"],
    rules: { "no-console": "off" },
  });

TypeScript cannot name the inferred return type across package boundaries, which surfaces as TS2883 when your eslint.config.ts is type-checked. Annotate the export to fix it:

import type { Linter } from "eslint";
import type { FlatConfigComposer } from "eslint-flat-config-utils";

import { karibsen } from "@karibsen/eslint-config";

const config: FlatConfigComposer<Linter.Config> = karibsen();

export default config;

Options

Option Type Default Description
typescript boolean true Enable the typescript-eslint rules
stylistic boolean | StylisticOptions true Enable the formatting rules
imports boolean true Enable import and export sorting
ignores string[] [] Extra patterns, appended to DEFAULT_IGNORES
overrideIgnores boolean false Replace DEFAULT_IGNORES instead of extending it

StylisticOptions accepts indent (2), quotes ("double"), semi (true) and jsx (true).

What is included

Base

@eslint/js recommended, Node and ES2025 globals, plus the correctness rules the recommended preset leaves out: eqeqeq (smart), no-var, prefer-const, prefer-template, object-shorthand and no-debugger.

no-console follows NODE_ENV: error in production, warn otherwise. console.warn and console.error are allowed in both cases.

NODE_ENV is read when the config loads. CI usually does not set it to production, so stray logs stay warnings and will not fail eslint .. Run the lint step with NODE_ENV=production or --max-warnings 0 if you want them to break the build.

TypeScript

typescript-eslint recommended without type-checking, plus consistent-type-imports, consistent-type-definitions (interfaces over type aliases), method-signature-style and ban-ts-comment (ts-expect-error is allowed when it carries a description). no-unused-vars accepts an _ prefix for intentionally unused bindings.

Declaration files (*.d.ts) opt out of consistent-type-definitions and no-explicit-any.

Stylistic

Rules come from @stylistic's customize() factory, so the whole family stays coherent when a setting changes. On top of it: double quotes with avoidEscape, semicolons, object-curly-spacing, arrow-spacing, multiline trailing commas, one statement per line, and blank lines around functions and declarations.

Imports

simple-import-sort with the following groups, in order: side effects, node: builtins, framework imports (Nuxt and Vue), remaining packages, internal aliases (~, @/, #...), then relative imports.

The framework patterns are plain regexes. They cost nothing in a project that has no such import, and they keep the ordering identical across repos.

The builtin and package groups are not optional: simple-import-sort places anything matching no group last, so without them import x from "lodash" would sort after your relative imports.

Composing your own

Each block is exported separately if you need something narrower than the default preset:

import type { Linter } from "eslint";

import { base, ignores, stylistic, typescript } from "@karibsen/eslint-config";

const config: Linter.Config[] = [
  ...ignores(["dist"]),
  ...base(),
  ...typescript(),
  ...stylistic({ quotes: "single", semi: false }),
];

export default config;

DEFAULT_IGNORES, GLOB_SOURCE, IMPORT_GROUPS and STYLISTIC_DEFAULTS are exported as well.

Development

pnpm install
pnpm lint       # the repo is linted by the config it publishes
pnpm typecheck
pnpm build

License

MIT, Karibsen Studio

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages