1.32.2 • Published 6 days ago

@ttoss/config v1.32.2

Weekly downloads
-
License
-
Repository
github
Last release
6 days ago

@ttoss/config

@ttoss/config is an opinionated configuration library for monorepo and packages. It contains a set of default configurations that you can use on your projects.

Install

pnpm add -Dw @ttoss/config

Monorepo

Use the configs of this section on the root of your monorepo.

ESLint and Prettier

Install the following packages:

pnpm add -Dw eslint prettier @ttoss/eslint-config

Create the .prettierrc.js file and add the following configuration:

const { prettierConfig } = require('@ttoss/config');

module.exports = prettierConfig();

Create the .eslintrc.js file and add the following configuration:

module.exports = {
  extends: '@ttoss/eslint-config',
};

Husky, commitlint, and lint-staged

This group of packages will only work if you have already installed ESLint and Prettier because lint-staged will run the eslint --fix command.

Install the following packages on the root of your monorepo:

pnpm add -Dw husky @commitlint/cli lint-staged

Create the .commitlintrc.js file and add the following configuration:

const { commitlintConfig } = require('@ttoss/config');

module.exports = commitlintConfig();

Create the .lintstagedrc.js file and add the following configuration:

const { lintstagedConfig } = require('@ttoss/config');

module.exports = lintstagedConfig();

Finally, configure Husky:

npm set-script prepare "husky install"
pnpm run prepare
pnpm husky add .husky/commit-msg "pnpm commitlint --edit"
pnpm husky add .husky/pre-commit "pnpm lint-staged"

Packages

You can use configs below to your packages folders.

Babel

Add the babel.config.js file on the package folder:

const { babelConfig } = require('@ttoss/config');

module.exports = babelConfig();

Jest

Install Jest and its types on your package:

pnpm add -D jest @types/jest

Create the jest.config.ts file on the package folder:

import { jestConfig } from '@ttoss/config';

const config = jestConfig();

export default config;

Configure the test script on package.json of your package:

"scripts": {
  "test": "jest",
}

Tsup

Use tsup to bundle your TypeScript packages.

Install tsup on your package.

pnpm add -D tsup

Create the tsup.config.ts file on the package folder:

import { tsupConfig } from '@ttoss/config';

export const tsup = tsupConfig();

Configure the build script on package.json:

"scripts": {
  "build": "tsup",
}

TypeScript

Install TypeScript on your package:

pnpm add -D typescript

Extend default configuration for each tsconfig.json (touch tsconfig.json) on the package folder:

{
  "extends": "@ttoss/config/tsconfig.json"
}

For tests, you can extend the default test configuration tsconfig.test.json on the package tests folder:

{
  "extends": "@ttoss/config/tsconfig.test.json",
  "include": ["**/*.test.ts", "**/*.test.tsx"]
}

Extending configurations

Each configuration is customizable and you can extend them with your own. For example, you can use the default .prettierrc.js file in your monorepo:

const { prettierConfig } = require('@ttoss/config');

module.exports = prettierConfig();

But, if you want to change the printWidth option, you can do so:

const { prettierConfig } = require('@ttoss/config');

module.exports = prettierConfig({
  printWidth: 120,
});

You can also pass a second argument to every configuration to handle array's append or overwrite items.

const { babelConfig } = require('@ttoss/config');

// Append plugins (default)
const appendConfig = babelConfig(
  {
    plugins: ['@babel/plugin-proposal-class-properties'],
  },
  {
    arrayMerge: 'append',
  }
);

const overwriteConfig = babelConfig(
  {
    plugins: ['@babel/plugin-proposal-class-properties'],
  },
  {
    arrayMerge: 'overwrite',
  }
);
1.32.2

6 days ago

1.32.1

16 days ago

1.32.0

17 days ago

1.31.5

2 months ago

1.31.4

5 months ago

1.31.3

5 months ago

1.31.2

5 months ago

1.30.6

9 months ago

1.30.5

10 months ago

1.31.1

5 months ago

1.31.0

7 months ago

1.30.3

11 months ago

1.30.4

11 months ago

1.30.1

11 months ago

1.29.4

1 year ago

1.29.5

1 year ago

1.30.0

1 year ago

1.29.0

1 year ago

1.29.1

1 year ago

1.29.2

1 year ago

1.29.3

1 year ago

1.28.3

1 year ago

1.28.4

1 year ago

1.28.1

1 year ago

1.28.2

1 year ago

1.28.0

1 year ago

1.21.0

1 year ago

1.25.0

1 year ago

1.23.0

1 year ago

1.27.0

1 year ago

1.22.0

1 year ago

1.26.0

1 year ago

1.24.0

1 year ago

1.18.1

2 years ago

1.18.3

2 years ago

1.18.2

2 years ago

1.19.0

1 year ago

1.20.0

1 year ago

1.18.0

2 years ago

1.16.4

2 years ago

1.17.0

2 years ago

1.16.1

2 years ago

1.16.0

2 years ago

1.15.0

2 years ago

1.15.2

2 years ago

1.15.1

2 years ago

1.14.1

2 years ago

1.14.0

2 years ago

1.14.4

2 years ago

1.14.3

2 years ago

1.14.2

2 years ago

1.13.2

2 years ago

1.13.1

2 years ago

1.13.0

2 years ago

1.11.4

2 years ago

1.12.2

2 years ago

1.12.1

2 years ago

1.12.0

2 years ago

1.11.7

2 years ago

1.11.6

2 years ago

1.11.5

2 years ago

1.11.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

1.9.6

2 years ago

1.9.5

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

0.8.5

2 years ago

0.8.4

2 years ago

1.9.1

2 years ago

1.8.2

2 years ago

1.7.3

2 years ago

1.9.0

2 years ago

1.8.1

2 years ago

1.7.2

2 years ago

1.8.0

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.8.3

2 years ago

0.9.1

2 years ago

0.7.0

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago