8.1.3 • Published 7 months ago

@djblackeagle/shared-project-tools v8.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Welcome to @djblackeagle/shared-project-tools

Contents

What is @djblackeagle/shared-project-tools

@djblackeagle/shared-project-tools shares configuration of commitlint, eslint, nano-staged, prettier and release-it. And share some tools.

[Go to top]

Benefits using this package?

Easier code styling etc over multiple repositories. And it's esier, to update rules for code styles.

[Go to top]

How to clone this repository

  1. Clone this repository with git clone command.
  2. Execute the following command:
npm run repo:prepare
  1. This command will prepare the repository automatically. It's install all needed dependencies and all other things.

This repository use Yarn instead of NPM. NPM is only used for publishing the package via GitHub workflow.

[Go to top]

Getting started

Install @djblackeagle/shared-project-tools

npm

npm install --save-dev @djblackeagle/shared-project-tools

Yarn

yarn add --dev @djblackeagle/shared-project-tools

[Go to top]

Using ESLint config

Requirements

Installing

  1. Install eslint and other dependencies in your package as devDependencies.

npm

npm install --save-dev eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-airbnb-base eslint-config-airbnb-typescript eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier prettier

Yarn

yarn add --dev eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-airbnb-base eslint-config-airbnb-typescript eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier prettier
  1. Create file .eslintrc.js in the root folder.
  2. You can choose, which style of config you want. Here the base config.
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.eslint.typescript.base,
  parserOptions: {
    tsconfigRootDir: __dirname,
    extends: './tsconfig.eslint.json',
    project: ['./tsconfig.eslint.json'],
  },
};
  1. Save file.
  2. Create file tsconfig.eslint.json in the root folder.
{
  "extends": "./tsconfig.json",
  "compilerOptions": { "noEmit": true },
  "exclude": [".yarn/*", "yarn.lock", "package-lock.json", "node_modules"],
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/.*.js"]
}
  1. If you want change some options, you can do like this:
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.eslint.typescript.base,
  env: {
    ...sharedPrjTools.sharedConfig.eslint.typescript.base,
    node: false,
  },
  parserOptions: {
    tsconfigRootDir: __dirname,
    extends: './tsconfig.eslint.json',
    project: ['./tsconfig.eslint.json'],
  },
};

[Go to top]

Using Prettier config

Requirements

  • No requirements

Installing

  1. Install prettier and other dependencies in your package as devDependencies.

npm

npm install --save-dev prettier

Yarn

yarn add --dev prettier
  1. Create file .prettierrc.js in the root folder.
  2. You can choose, which style of config you want. Here the base config.
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = sharedPrjTools.sharedConfig.prettier.base;
  1. Save file.
  2. If you want change some options, you can do like this:
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.prettier.base,
  tabWidth: 4,
};
  1. Create file .prettierignore in the root folder.
  2. You can use this ignore pattern to ignore file for prettier.
**/.git/
**/node_modules/
**/.yarn/
.husky/
**/dist/*
**/build/*
yarn.lock
package-lock.json

[Go to top]

Using release-it config

Requirements

  • No requirements

Installing

  1. Install release-it and other dependencies in your package as devDependencies.

npm

npm install --save-dev release-it @release-it/conventional-changelog

Yarn

yarn add --dev release-it @release-it/conventional-changelog
  1. Create file .release-it.js in the root folder.
  2. You can choose, which style of config you want. Here the base config.
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = sharedPrjTools.sharedConfig.releaseIt.base;
  1. Save file.
  2. If you want change some options, you can do like this:
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.releaseIt.base,
  git: {
    ...sharedPrjTools.sharedConfig.releaseIt.base.git,
    push: false,
  },
};

[Go to top]

Using commitlint config

Requirements

Installing

  1. Install commitlint and other dependencies in your package as devDependencies.

npm

npm install --save-dev @commitlint/cli @commitlint/config-conventional

Yarn

yarn add --dev @commitlint/cli @commitlint/config-conventional
  1. Create file .commitlintrc.js in the root folder.
  2. You can choose, which style of config you want. Here the base config.
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = sharedPrjTools.sharedConfig.commitlint.base;
  1. Save file.
  2. If you want change some options, you can do like this:
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.commitlint.base,
  rules: {
    ...sharedPrjTools.sharedConfig.commitlint.base.rules,
    'header-max-length': [2, 'always', 250],
  },
};
  1. Add Git hook commit-msg
npx husky add .husky/commit-msg "npx --no -- commitlint --edit ${1}"

[Go to top]

Using nano-staged config

Requirements

Installing

  1. Install nano-staged and other dependencies in your package as devDependencies.

npm

npm install --save-dev nano-staged

Yarn

yarn add --dev nano-staged
  1. Create file .nano-staged.js in the root folder.
  2. You can choose, which style of config you want. Here the base config.
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = sharedPrjTools.sharedConfig.nanoStaged.base;
  1. Save file.
  2. If you want change some options, you can do like this:
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.nanoStaged.base,
  '*.{xml}': (api) => `validate-xml.sh ${api.filenames.join(' ')}`,
};
  1. Add Git hook pre-commit
npx husky add .husky/pre-commit "npx nano-staged"

[Go to top]

Using lint-staged config

Requirements

Installing

  1. Install lint-staged and other dependencies in your package as devDependencies.

npm

npm install --save-dev lint-staged

Yarn

yarn add --dev lint-staged
  1. Create file .lintstagedrc.js in the root folder.
  2. You can choose, which style of config you want. Here the base config.
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = sharedPrjTools.sharedConfig.lintStaged.base;
  1. Save file.
  2. If you want change some options, you can do like this:
const sharedPrjTools = require('@djblackeagle/shared-project-tools');

module.exports = {
  ...sharedPrjTools.sharedConfig.lintStaged.base,
  '*.{xml}': (api) => `validate-xml.sh ${api.filenames.join(' ')}`,
};
  1. Add Git hook pre-commit
npx husky add .husky/pre-commit "npx lint-staged"

[Go to top]

CLI commands

You can call it npx djbe-shared-project-tools. For the bin name, exists a short name: npx djbe-spt

In package.json

{
  "git:clean": "djbe-shared-project-tools git pruneGoneBranches"
}

Commands

help

Print the help.

git

This main command, holds some git tools commands (like pruneGoneBranches).

git pruneGoneBranches

This command would delete all branches, which doesn't exists anymore and merged already. If the current branch is deleted already remote, it will not delete the current local branch.

  • Parameter -f, --force: You can force to delete the local branch, even the branch is not merged already remote.
  • Parameter -d, --dry-run: This option don't delete any branches.

Console

npx djbe-shared-project-tools git pruneGoneBranches

[Go to top]

5.0.0

10 months ago

6.0.0

10 months ago

8.1.3

7 months ago

7.0.0

10 months ago

8.1.0

9 months ago

8.0.1

10 months ago

8.0.0

10 months ago

8.1.2

8 months ago

8.1.1

8 months ago

8.0.2

9 months ago

4.1.0

11 months ago

3.0.0

11 months ago

2.1.1

12 months ago

4.0.0

11 months ago

2.1.0

12 months ago

2.0.0

12 months ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago