@djblackeagle/shared-project-tools v8.1.4
Welcome to @djblackeagle/shared-project-tools
Contents
- What is @djblackeagle/shared-project-tools
- Benefits using this package?
- How to clone this repository
- Getting started
- CLI commands
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.
Benefits using this package?
Easier code styling etc over multiple repositories. And it's esier, to update rules for code styles.
How to clone this repository
- Clone this repository with
git clonecommand. - Execute the following command:
npm run repo:prepare- 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.
Getting started
Install @djblackeagle/shared-project-tools
npm
npm install --save-dev @djblackeagle/shared-project-toolsYarn
yarn add --dev @djblackeagle/shared-project-toolsUsing ESLint config
Requirements
- Prettier - Prefer this prettier base config. How to use it.
Installing
- Install
eslintand 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 prettierYarn
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- Create file
.eslintrc.jsin the root folder. - 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'],
},
};- Save file.
- Create file
tsconfig.eslint.jsonin 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"]
}- 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'],
},
};Using Prettier config
Requirements
- No requirements
Installing
- Install
prettierand other dependencies in your package as devDependencies.
npm
npm install --save-dev prettierYarn
yarn add --dev prettier- Create file
.prettierrc.jsin the root folder. - 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;- Save file.
- 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,
};- Create file
.prettierignorein the root folder. - You can use this ignore pattern to ignore file for prettier.
**/.git/
**/node_modules/
**/.yarn/
.husky/
**/dist/*
**/build/*
yarn.lock
package-lock.jsonUsing release-it config
Requirements
- No requirements
Installing
- Install
release-itand other dependencies in your package as devDependencies.
npm
npm install --save-dev release-it @release-it/conventional-changelogYarn
yarn add --dev release-it @release-it/conventional-changelog- Create file
.release-it.jsin the root folder. - 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;- Save file.
- 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,
},
};Using commitlint config
Requirements
- husky - How to install, look in the documentation of husky.
Installing
- Install
commitlintand other dependencies in your package as devDependencies.
npm
npm install --save-dev @commitlint/cli @commitlint/config-conventionalYarn
yarn add --dev @commitlint/cli @commitlint/config-conventional- Create file
.commitlintrc.jsin the root folder. - 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;- Save file.
- 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],
},
};- Add Git hook
commit-msg
npx husky add .husky/commit-msg "npx --no -- commitlint --edit ${1}"Using nano-staged config
Requirements
- husky - How to install, look in the documentation of husky.
Installing
- Install
nano-stagedand other dependencies in your package as devDependencies.
npm
npm install --save-dev nano-stagedYarn
yarn add --dev nano-staged- Create file
.nano-staged.jsin the root folder. - 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;- Save file.
- 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(' ')}`,
};- Add Git hook
pre-commit
npx husky add .husky/pre-commit "npx nano-staged"Using lint-staged config
Requirements
- husky - How to install, look in the documentation of husky.
Installing
- Install
lint-stagedand other dependencies in your package as devDependencies.
npm
npm install --save-dev lint-stagedYarn
yarn add --dev lint-staged- Create file
.lintstagedrc.jsin the root folder. - 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;- Save file.
- 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(' ')}`,
};- Add Git hook
pre-commit
npx husky add .husky/pre-commit "npx lint-staged"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 pruneGoneBranches11 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago