Skip to content

Commit

Permalink
refactor: lints code pre-commit (hadenlabs#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Sep 24, 2021
1 parent 6323ba8 commit c82ccce
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 41 deletions.
23 changes: 18 additions & 5 deletions .github/linters/.gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ title = "gitleaks config"

[[rules]]
description = "Env Var"
regex = '''(?i)(apikey|secret|key|api|password|pass|pw|host)=[0-9a-zA-Z-_.{}]{4,120}'''
regex = '''(?i)(apikey|secret|key|api|password|pass)=[0-9a-zA-Z-_.{}]{4,120}'''
tags = ["env"]
[rules.allowlist]
description = "ignore value fake"
Expand All @@ -170,11 +170,13 @@ title = "gitleaks config"
description = "ignore emails"
regexes = [
'''[a-zA-Z0-9._%+-]+@users.noreply.github.com''',
'''[a-zA-Z0-9._%+-]+@terraform-aws-openvpn-[a-zA-Z0-9._%+-]+.com''',
'''[a-zA-Z0-9._%+-]+@yopmail.com''',
'''git@github.com''',
'''git@gitlab.com''',
'''slovacus@gmail.com''',
'''luis@hadenlabs.com''',
'''hola@hadenlabs.com''',
'''hello@hadenlabs.com''',
'''support@hadenlbas.com''',
'''support@hadenlabs.com''',
'''dum-u@hadenlabs.com''',
Expand Down Expand Up @@ -233,14 +235,19 @@ title = "gitleaks config"

# Global allowlist
[allowlist]
description = "files allowlists"
description = "Whitelisted files"
files = [
'''(.*?)(jpg|gif|png|doc|pdf|bin|mp3|mp4|mov|ttf|woff|woff2|eot|lock)$''',
'''^\.gitignore$''',
'''^\.gitleaks.toml$''',
'''^yarn.lock$''',
'''^sonar-project.properties$''',
'''^test/fixtures/keys/.*-test.*$''',
]
paths = [
'''^vendor/(.*?)$''',
'''^node_modules/(.*?)$''',
]
commits = [
'''34ab6c88ea1e77b54bcbe3cda99b34ded7554c11''',
'''610c8caf8a7d198a0a0c910e40a1bc9a3ce575c7''',
Expand All @@ -249,11 +256,17 @@ title = "gitleaks config"
]

[whitelist]
description = "Ignore"
files = [
description = "image and html allowlists"
files = [
'''(.*?)(jpg|gif|png|doc|pdf|bin|mp3|mp4|mov|ttf|woff|woff2|eot|lock)$''',
'''^\.gitignore$''',
'''^\.gitleaks.toml$''',
'''^\.gitignore$''',
'''^yarn.lock$''',
'''^sonar-project.properties$''',
'''^test/fixtures/keys/.*-test.*$''',
]
paths = [
'''^vendor/(.*?)$''',
'''^node_modules/(.*?)$''',
]
9 changes: 3 additions & 6 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ linters-settings:
# report about shadowed variables
check-shadowing: true

golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8

gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true

goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/action-pre-commit/
local-prefixes: github.com/hadenlabs/

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
Expand Down Expand Up @@ -100,7 +96,6 @@ linters:
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- golint
- unconvert
- misspell
- nakedret
Expand All @@ -117,6 +112,7 @@ linters:
- testpackage
- goerr113
- scopelint
- golint

# Drives todos nuts
- godox
Expand All @@ -133,6 +129,7 @@ issues:
- gosec
- scopelint
- unparam
- golint

# - text: "should have a package comment"
# linters:
Expand Down
12 changes: 12 additions & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ignored:
- DL3008 # Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
- DL3013 # Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>`
- DL3016 # Pin versions in npm. Instead of `npm install <package>` use `npm install <package>@<version>
- DL3018 # Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>
- DL3028 # Pin versions in gem install. Instead of `gem install <gem>` use `gem install <gem>:<version>`

- SC2086 # info: Double quote to prevent globbing and word splitting.

# temp

- DL4006 # Set the SHELL option -o pipefail before RUN with a pipe in it
2 changes: 2 additions & 0 deletions .github/linters/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ coverage
.mypy_cache/
.build
.terraform
.github/linters/.cache/*
.cache/*
terraform.md
*.tpl.md
*.enc.yaml
Expand Down
3 changes: 3 additions & 0 deletions .github/linters/markdown-link-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"ignorePatterns": [
{
"pattern": "^https://hadenlabs.com"
},
{
"pattern": "^https://github.com/hadenlabs/terraform-aws-openvpn/compare"
}
],
"replacementPatterns": [
Expand Down
43 changes: 13 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
default_stages:
- commit

repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
rev: v2.1.0
hooks:
- id: codespell
args: [--ignore-words=.codespell-ignores]
Expand All @@ -10,6 +13,14 @@ repos:
.+\.node_modules\/.*$|
.+\.lock$|
)$
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v5.0.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@hadenlabs/commitlint-config']
args:
- --config=.github/linters/.commitlintrc.json
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
Expand All @@ -33,14 +44,11 @@ repos:
- id: check-docstring-first
- id: requirements-txt-fixer
- id: check-symlinks
- id: name-tests-test
args:
- --django
- id: file-contents-sorter
- id: fix-encoding-pragma
- id: sort-simple-yaml
- repo: https://github.com/hadenlabs/pre-commit-hooks
rev: 2bed7c6ec4930b235aaf54aff1cf34e3df694f37
rev: 6c173538c37aa802949cae5ff487d702319ba80a
hooks:
- id: do-not-commit
- id: markdown-link-check
Expand All @@ -65,7 +73,6 @@ repos:
args:
- '--output-file=docs/include/terraform.md'
- '--output-mode=replace'
- '--sort-by-type'

- id: terraform-tflint
args:
Expand All @@ -81,27 +88,3 @@ repos:
- --path=.
- --repo-config-path=.github/linters/.gitleaks.toml
- --verbose

- repo: local
hooks:
- id: prettier
name: prettier
language: system
entry: ./node_modules/prettier/bin-prettier.js
args:
- '--write=true'
- '--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: node
entry: node_modules/eslint/bin/eslint.js
args:
- '--fix'
- '--color'
- '--config=.github/linters/.eslintrc.js'
- '--ignore-path=.github/linters/.eslintignore'
files: \.(js|jsx|ts|tsx|mjs|d.ts)$
exclude: node_modules

0 comments on commit c82ccce

Please sign in to comment.