Skip to content

Commit

Permalink
refactor: hooks pre-commit (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Mar 27, 2021
1 parent 39b6259 commit b6bdc8d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 173 deletions.
24 changes: 1 addition & 23 deletions .github/linters/.commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"header-max-length": [2, "always", 80],
"subject-case": [2, "always", ["lower-case"]],
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"sample"
]
]
}
"extends": ["@hadenlabs/commitlint-config"]
}
120 changes: 14 additions & 106 deletions .github/linters/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,117 +1,25 @@
module.exports = {
env: {
node: true,
es2021: true,
},
extends: [
'standard',
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:promise/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'prettier',
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
plugins: ['prettier'],
settings: {
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
'import/resolver': {
'babel-module': {},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
env: {
browser: true,
jest: true,
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
extends: [
'standard',
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:promise/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:jsx-a11y/recommended',
'prettier',
'prettier/@typescript-eslint',
],
plugins: ['prettier', 'react-hooks', 'jsx-a11y'],
parserOptions: {
ecmaversion: 2018,
project: './tsconfig.json',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
'babel-module': {},
},
},
rules: {
'react/react-in-jsx-scope': 0,
'ordered-imports': 0,
quotemark: 0,
'no-console': 0,
semicolon: 0,
'jsx-no-lambda': 0,
camelcase: 0,
'@typescript-eslint/interface-name-prefix': 0,
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'forbid',
},
{
selector: 'class',
format: ['PascalCase'],
},
{
selector: 'property',
modifiers: ['readonly'],
format: ['camelCase', 'UPPER_CASE'],
},
{
selector: 'memberLike',
modifiers: ['protected'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'variable',
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
},
{
selector: 'interface',
format: ['PascalCase'],
prefix: ['I'],
},
],
},
},
{
files: ['**/*.tsx'],
rules: {
'react/prop-types': 'off',
},
},
],
plugins: ['@typescript-eslint', 'prettier'],
rules: {},
}
4 changes: 3 additions & 1 deletion .github/linters/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ package-lock.json
coverage
.mypy_cache/
.build
CHANGELOG.tpl.md
.terraform
*.tpl.md
*.enc.yaml
30 changes: 14 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit
rev: v2.10.0
rev: v2.11.1
hooks:
- id: validate_manifest
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
Expand All @@ -19,24 +19,24 @@ repos:
args: []
files: .py$
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.6.0
rev: v2.7.2
hooks:
- id: pylint
exclude: __pycache__|migrations|conf.py|_build|.tox|pootle/static|pootle/translations|pootle/locale|pootle/assets|templates
args:
- --rcfile=__GIT_WORKING_DIR__/.github/linters/.pylintrc
- --rcfile=.github/linters/.pylintrc
- --disable=no-name-in-module,import-error,ungrouped-imports
- --ignore=settings_test, migrations
- repo: https://github.com/ambv/black
rev: 20.8b1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800
rev: v0.812
hooks:
- id: mypy
args:
Expand Down Expand Up @@ -78,17 +78,15 @@ repos:
hooks:
- id: do_not_commit
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.2
rev: v1.10.0
hooks:
- id: blacken-docs
additional_dependencies:
- black
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.45.0
rev: v1.48.0
hooks:
- id: terraform_docs
- id: terraform_docs_replace
args: ['--sort-by-required', '--dest=docs/include/terraform.md']
- id: terraform_tflint
args:
- '--args=--config=__GIT_WORKING_DIR__/.github/linters/.tflint.hcl'
Expand Down Expand Up @@ -122,25 +120,25 @@ repos:
args:
- '--write=true'
- '--list-different'
- '--config=__GIT_WORKING_DIR__/.github/linters/prettier.config.js'
- '--ignore-path=__GIT_WORKING_DIR__/.github/linters/.prettierignore'
files: \.(js?(on),ts?(x),scss,md,y?(a)ml,gql,graphql?(s),less,mjml,html)$
exclude: lib|node_modules
- '--config=.github/linters/prettier.config.js'
- '--ignore-path=.github/linters/.prettierignore'
files: \.(js|jsx|json|ts|tsx|mjs|d.ts|md|yml|yaml|gql|graphql|mjml)$
exclude: node_modules
- id: eslint
name: eslint
language: system
pass_filenames: true
entry: node_modules/eslint/bin/eslint.js --config=__GIT_WORKING_DIR__/.github/linters/.eslintrc.js --ignore-path=__GIT_WORKING_DIR__/.github/linters/.eslintignore --color
entry: node_modules/eslint/bin/eslint.js --config=.github/linters/.eslintrc.js --ignore-path=.github/linters/.eslintignore --color
args:
- '--fix'
files: \.(js|jsx|ts|tsx|mjs|d.ts)$
- id: stylint
name: stylint
language: system
pass_filenames: true
entry: node_modules/stylelint/bin/stylelint.js --config=__GIT_WORKING_DIR__/.github/linters/.stylintrc --syntax less **/*.less
entry: node_modules/stylelint/bin/stylelint.js --config=.github/linters/.stylintrc --syntax less **/*.less
args: [--fix]
files: \.(less)$
files: \.(css|scss|sass|less)$
- id: dockerfile-provides-entrypoint
name: hadolint
description: Lint Dockerfiles with hadolint
Expand Down
65 changes: 38 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,67 @@
"description": "terraform-aws-openvpn for terraform aws",
"repository": "ssh://git@github.com/hadenlabs/terraform-aws-openvpn.git",
"author": "Luis Mayta <slovacus@gmail.com>",
"license": "Apache-2.0",
"license": "MIT",
"engines": {
"node": ">=12"
"node": ">=14"
},
"keywords": [],
"scripts": {
"clean": "rimraf dist .next out build",
"clean:all": "yarn clean node_modules",
"build": "./node_modules/.bin/tsc -p",
"build:tool": "yarn run build ./tools/",
"clean": "rimraf -rf dist",
"clean:all": "yarn clean:cache && yarn clean:build:all && yarn clean node_modules",
"clean:build": "yarn clean dist .next out .serverless_nextjs",
"clean:build:all": "yarn clean && yarn clean:build && yarn clean:build:tool && yarn clean:build:test",
"clean:build:test": "yarn clean ./coverage",
"clean:build:tool": "yarn clean ./build/tools",
"clean:cache": "yarn clean ./node_modules/.cache",
"generate": "cross-env TS_NODE_PROJECT='./provision/generators/plop/ts-node.tsconfig.json' plop --plopfile provision/generators/plop/index.ts",
"lint": "eslint --config=.github/linters/.eslintrc.js --ignore-path=.github/linters/.eslintignore ./ --ext .js,.jsx,.mjs,.d.ts,.ts,.tsx",
"lint:fix": "yarn lint --fix",
"lint:less": "stylelint --config=.github/linters/.stylintrc --syntax less **/*.less",
"lint:less:fix": "yarn lint:less --fix",
"prebuild": "yarn run clean",
"precommit": "lint-staged",
"prettier": "prettier --config=.github/linters/prettier.config.js --ignore-path=.github/linters/.prettierignore",
"prettier:fix": "yarn prettier:lint --write=true",
"prettier:lint": "yarn prettier '**/*.{js?(on),ts?(x),scss,md,y?(a)ml,gql,graphql?(s),less,mjml}' --write=false --list-different"
},
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@equipindustry/eslint-config": "^0.3.4",
"@equipindustry/prettierrc": "^0.2.0",
"@types/jest": "^26.0.13",
"@types/mocha": "^8.0.3",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"axios": "^0.20.0",
"babel": "^6.23.0",
"babel-eslint": "^10.1.0",
"cross-env": "^7.0.2",
"eslint": "==6.8.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lint-staged": "^10.3.0",
"mjml": "^4.6.3",
"@babel/eslint-parser": "^7.13.10",
"@commitlint/cli": "^12.0.1",
"@hadenlabs/commitlint-config": "^0.1.0",
"@types/jest": "^26.0.21",
"@types/mocha": "^8.2.1",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"axios": "^0.21.1",
"babel-cli": "^6.26.0",
"cross-env": "^7.0.3",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.3.1",
"husky": "^5.1.3",
"lint-staged": "^10.5.4",
"node-plop": "^0.26.2",
"plop": "^2.6.0",
"prettier": "^2.1.1",
"plop": "^2.7.4",
"prettier": "^2.2.1",
"prettier-tslint": "^0.4.2",
"rimraf": "^3.0.2",
"semantic-release": "^17.1.1",
"sendmail": "^1.6.1",
"semantic-release": "^17.4.2",
"shelljs": "^0.8.4",
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
"stylelint": "^13.12.0",
"stylelint-config-standard": "^21.0.0",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
},
"publishConfig": {
"access": "restricted"
},
"prettier": "./.github/linters/prettier.config.js",
"husky": {
"hooks": {
"pre-commit": "yarn precommit",
Expand Down

0 comments on commit b6bdc8d

Please sign in to comment.