npm.io
1.1.2 • Published 1 week ago

@cl3tus/config

Licence
MIT
Version
1.1.2
Deps
6
Size
17 kB
Vulns
0
Weekly
0

@cl3tus/config

Shared configuration files for ESLint, Prettier, TypeScript, and Commitlint for Node.js, Next.js, and React projects.

Installation

npm install --save-dev @cl3tus/config

Peer Dependencies

This package requires the following peer dependencies:

npm install --save-dev eslint prettier typescript @commitlint/cli @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss prettier-plugin-classnames

Usage

ESLint

Two configurations are available depending on your project type.

For Node.js / Vite projects

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

import eslintConfig from "@cl3tus/config/eslint/node";

export default eslintConfig;

Features:

  • TypeScript support with typescript-eslint
  • Unused imports detection and removal
  • Consistent type imports (inline import type)
  • Smart unused variables detection with _ prefix ignore pattern
  • Enforce type over interface (consistent-type-definitions)
  • Require braces on all control statements (curly)
  • Blank lines around if blocks (@stylistic/padding-line-between-statements)
For Next.js projects

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

import eslintConfig from "@cl3tus/config/eslint/nextjs";

export default eslintConfig;

Features:

  • All Node.js features above
  • Next.js core-web-vitals and TypeScript configs
  • React-specific rules
Extending the config

You can extend either config with your own rules:

import eslintConfig from "@cl3tus/config/eslint/node"; // or /nextjs

export default [
  ...eslintConfig,
  {
    rules: {
      // Your custom rules
    },
  },
];
Prettier

Create a prettier.config.mjs file in your project root:

export { default } from '@cl3tus/config/prettier';

Or extend the config:

import baseConfig from '@cl3tus/config/prettier';

export default {
  ...baseConfig,
  // Your custom options
};

Features:

  • Tailwind CSS class sorting
  • Import statement sorting (React/Next first, then third-party, then local)
  • Classnames plugin support
  • 2-space indentation, 100 character line width
Biome

An all-in-one alternative to ESLint + Prettier. Create a biome.json file in your project root:

{
  "extends": ["@cl3tus/config/biome"]
}

Or override specific options:

{
  "extends": ["@cl3tus/config/biome"],
  "files": {
    "includes": ["**", "!**/generated/**"]
  }
}

Features:

  • Formatter: 2-space indentation, 100 character line width, single quotes, trailing commas, semicolons
  • Same conventions as the ESLint config: type over interface, braces on all control statements, inline import type, no console.log (only warn/error/info)
  • Unused variable/import detection (respects _ prefix)
  • Tailwind CSS class sorting (cn, cva, clsx, tw) and CSS Modules / Tailwind directives parsing
  • Import organization with grouped ordering (node/bun, packages, aliases, relative paths)
  • Relaxed a11y rules under components/**

Note: the blank-line-around-if convention has no Biome equivalent and is only enforced by the ESLint config.

TypeScript

Extend the configuration in your tsconfig.json:

{
  "extends": "@cl3tus/config/tsconfig",
  "compilerOptions": {
    // Your custom options
  }
}

Features:

  • Optimized for Next.js projects
  • Path aliases support (@/*)
  • Strict mode enabled
  • Modern ES2017 target
Commitlint

Create a commitlint.config.js file in your project root:

module.exports = {
  extends: ["@cl3tus/config/commitlint"],
};

Features:

  • Conventional commits format
  • Extended body max line length (400 characters)

Complete Setup Examples

For a Node.js / Vite project
# Install the config package and peer dependencies
npm install --save-dev @cl3tus/config eslint prettier typescript @commitlint/cli @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss prettier-plugin-classnames husky

# Initialize husky (optional, for git hooks)
npx husky init

eslint.config.js:

import eslintConfig from "@cl3tus/config/eslint/node";

export default eslintConfig;

prettier.config.mjs:

export { default } from '@cl3tus/config/prettier';

tsconfig.json:

{
  "extends": "@cl3tus/config/tsconfig"
}

commitlint.config.js:

module.exports = {
  extends: ["@cl3tus/config/commitlint"],
};
For a Next.js project
# Install the config package and peer dependencies
npm install --save-dev @cl3tus/config eslint prettier typescript @commitlint/cli @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss prettier-plugin-classnames husky

# Initialize husky (optional, for git hooks)
npx husky init

eslint.config.js:

import eslintConfig from "@cl3tus/config/eslint/nextjs";

export default eslintConfig;

prettier.config.mjs:

export { default } from '@cl3tus/config/prettier';

tsconfig.json:

{
  "extends": "@cl3tus/config/tsconfig"
}

commitlint.config.js:

module.exports = {
  extends: ["@cl3tus/config/commitlint"],
};

package.json scripts:

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix",
    "format": "prettier --write .",
    "format:check": "prettier --check ."
  }
}

What's Included

ESLint Plugins & Configs

Node.js config:

  • @eslint/js (recommended rules)
  • typescript-eslint (TypeScript support)
  • eslint-plugin-unused-imports
  • @stylistic/eslint-plugin (stylistic rules)

Next.js config:

  • All Node.js plugins above
  • eslint-config-next (core-web-vitals + TypeScript)
  • @eslint/eslintrc (for compatibility)
Prettier Plugins
  • @trivago/prettier-plugin-sort-imports
  • prettier-plugin-tailwindcss
  • prettier-plugin-classnames
Biome Config
  • @biomejs/biome (optional peer dependency — only needed if you use the Biome config instead of ESLint + Prettier)
Commitlint Config
  • @commitlint/config-conventional

Development & Deployment

Automatic Release (Forgejo Actions)

Releases are fully automated with semantic-release. On every push to main, the workflow analyzes the commit messages, bumps the version, updates CHANGELOG.md, publishes to npm, pushes the release commit and tag back to the repository, and sends a Discord notification.

Setup
  1. Create an npm access token:

  2. Add secrets to Forgejo:

    • Go to Settings > Actions > Secrets in your Forgejo repository
    • Add NPM_TOKEN with your npm token
    • Add CI_TOKEN with a Forgejo access token (repository write permissions)
    • Add DISCORD_WEBHOOK with a Discord channel webhook URL (release notifications)
  3. Push to main branch:

    git push origin main

    The release workflow runs automatically — no manual trigger needed.

Commit Message Convention

The version bump is determined automatically from your conventional commits:

# Patch (1.0.0 -> 1.0.1)
git commit -m "fix: correct typo in README"

# Minor (1.0.0 -> 1.1.0)
git commit -m "feat: add new eslint rule"

# Major (1.0.0 -> 2.0.0)
git commit -m "feat: redesign config structure

BREAKING CHANGE: config imports have changed"

License

MIT