@invexa/code-style
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@invexa/code-style

@invexa/code-style provides standardized ESLint and Prettier configurations to help enforce a consistent code style across your projects. Whether you're building Next.js applications, general JavaScript/TypeScript libraries, React apps—or even using Tailwind CSS—this package offers pre-configured setups that you can extend and customize.

Installation

Install the package as a development dependency using pnpm, npm, or yarn:

pnpm add @invexa/code-style -D
npm install --save-dev @invexa/code-style
yarn add -D @invexa/code-style

ESLint Configurations

The package includes several ESLint configuration presets. Choose the one that best fits your project type, then extend or override rules as needed.

Next.js Apps

For Next.js projects, use the eslint.next preset. For example:

// eslint.config.mjs
import { eslint } from "@invexa/code-style";

/** @type {import('eslint').Linter.Config[]} */
export default [
    ...eslint.next,
    {
        rules: {
            // Extend or override...
        },
    },
];

React Apps or React Libraries

For React projects, use the eslint.react preset:

// eslint.config.mjs
import { eslint } from "@invexa/code-style";

/** @type {import('eslint').Linter.Config[]} */
export default [
    ...eslint.react,
    {
        rules: {
            // Extend or override...
        },
    },
];

General JavaScript/TypeScript Libraries

For libraries or projects that do not use Next.js or React, use the eslint.general preset:

// eslint.config.mjs
import { eslint } from "@invexa/code-style";

/** @type {import('eslint').Linter.Config[]} */
export default [
    ...eslint.general,
    {
        rules: {
            // Extend or override...
        },
    },
];

Nest.js (Backend Projects)

For Nest.js backend projects, use the eslint.nest preset. For example:

// eslint.config.mjs
import { eslint } from "@invexa/code-style";

/** @type {import("typescript-eslint").ConfigArray} */
export default [
    {
        ignores: ["**/eslint.config.mjs"],
    },
    ...eslint.nest,
    {
        rules: {
            // Extend or override...
        },
    },
];

Prettier Configurations

@invexa/code-style also offers Prettier configurations to keep your code formatting consistent. There are two presets available: one for general projects and one for Tailwind CSS projects.

Frontend App Using Tailwind CSS

If your frontend project uses Tailwind CSS, use the Tailwind-specific Prettier configuration. Create a file named prettier.config.cjs with the following content:

// prettier.config.cjs
const codeStyle = require("@invexa/code-style");

/** @type {import('@invexa/code-style/types').PrettierTailwindOptions} */
const config = {
    ...codeStyle.prettier.tailwind,
    tailwindFunctions: ["cn", "cva", "tv", "clsx"], // Or other functions that compose tailwind classes
};

module.exports = config;

General Prettier Config

For projects that do not use Tailwind CSS (such as backend projects or standard frontend apps), use the general Prettier configuration:

// prettier.config.cjs
const codeStyle = require("@invexa/code-style");

/** @type {import('@invexa/code-style/types').PrettierGeneralOptions} */
const config = {
    ...codeStyle.prettier.general,
};

module.exports = config;

Customization

You can further customize both ESLint and Prettier configurations by merging or overriding specific rules. This flexibility allows you to adhere to your coding conventions while benefiting from the solid defaults provided by @invexa/code-style.

License

This project is licensed under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @invexa/code-style

Weekly Downloads

57

Version

1.0.1

License

UNLICENSED

Unpacked Size

56.6 kB

Total Files

22

Last publish

Collaborators

  • mohammadxali
  • mhaghshenas