@djblackeagle/shared-project-tools
v8.1.3
Published
Shared project tools config.
Downloads
852
Readme
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 clone
command. - 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-tools
Yarn
yarn add --dev @djblackeagle/shared-project-tools
Using ESLint config
Requirements
- Prettier - Prefer this prettier base config. How to use it.
Installing
- 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
- Create file
.eslintrc.js
in 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.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"]
}
- 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
prettier
and other dependencies in your package as devDependencies.
npm
npm install --save-dev prettier
Yarn
yarn add --dev prettier
- Create file
.prettierrc.js
in 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
.prettierignore
in 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.json
Using release-it config
Requirements
- No requirements
Installing
- 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
- Create file
.release-it.js
in 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
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
- Create file
.commitlintrc.js
in 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-staged
and other dependencies in your package as devDependencies.
npm
npm install --save-dev nano-staged
Yarn
yarn add --dev nano-staged
- Create file
.nano-staged.js
in 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-staged
and other dependencies in your package as devDependencies.
npm
npm install --save-dev lint-staged
Yarn
yarn add --dev lint-staged
- Create file
.lintstagedrc.js
in 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 pruneGoneBranches