From b6bdc8d21bdbc441dd07b35966521eb704e99ff3 Mon Sep 17 00:00:00 2001 From: "@slovacus" Date: Sat, 27 Mar 2021 16:11:37 -0500 Subject: [PATCH] refactor: hooks pre-commit (#21) --- .github/linters/.commitlintrc.json | 24 +----- .github/linters/.eslintrc.js | 120 ++++------------------------- .github/linters/.prettierignore | 4 +- .pre-commit-config.yaml | 30 ++++---- package.json | 65 +++++++++------- 5 files changed, 70 insertions(+), 173 deletions(-) diff --git a/.github/linters/.commitlintrc.json b/.github/linters/.commitlintrc.json index a184cd2..8081b61 100644 --- a/.github/linters/.commitlintrc.json +++ b/.github/linters/.commitlintrc.json @@ -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"] } diff --git a/.github/linters/.eslintrc.js b/.github/linters/.eslintrc.js index 7662425..ad46715 100644 --- a/.github/linters/.eslintrc.js +++ b/.github/linters/.eslintrc.js @@ -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: {}, } diff --git a/.github/linters/.prettierignore b/.github/linters/.prettierignore index 84d1c0d..c092952 100644 --- a/.github/linters/.prettierignore +++ b/.github/linters/.prettierignore @@ -8,4 +8,6 @@ package-lock.json coverage .mypy_cache/ .build -CHANGELOG.tpl.md +.terraform +*.tpl.md +*.enc.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b313c43..ab5d4fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -19,12 +19,12 @@ 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 @@ -32,11 +32,11 @@ repos: 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: @@ -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' @@ -122,15 +120,15 @@ 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)$ @@ -138,9 +136,9 @@ repos: 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 diff --git a/package.json b/package.json index 93d803f..98ca9e1 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,27 @@ "description": "terraform-aws-openvpn for terraform aws", "repository": "ssh://git@github.com/hadenlabs/terraform-aws-openvpn.git", "author": "Luis Mayta ", - "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", @@ -23,37 +32,39 @@ }, "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",