Skip to content

Commit

Permalink
feat: check git hook (#33)
Browse files Browse the repository at this point in the history
* fix: dup rubocop rules

* feat: add commit lint and update lefthook config
  • Loading branch information
jacky-le-goldenowl authored Oct 23, 2024
1 parent 2de6f2c commit 062d214
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 106 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ node_modules

!/.env.sample
config/database.yml

/.husky
37 changes: 0 additions & 37 deletions .hooks/lint_commit_msg.rb

This file was deleted.

42 changes: 3 additions & 39 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ Layout/HashAlignment:
EnforcedColonStyle: key
EnforcedLastArgumentHashStyle: always_inspect

Layout/LineLength:
Exclude:
- config/initializers/content_security_policy.rb

Layout/MultilineArrayLineBreaks:
Enabled: true

Expand All @@ -64,9 +60,6 @@ Layout/MultilineHashKeyLineBreaks:
Layout/MultilineMethodArgumentLineBreaks:
Enabled: true

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Expand All @@ -82,37 +75,16 @@ Lint/UselessAccessModifier:
MethodCreatingMethods:
- delegate

Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Max: 25
Exclude:
- config/**/*
- test/**/*

Metrics/ClassLength:
Max: 200
Max: 250
Exclude:
- test/**/*

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/MethodLength:
Max: 25
Exclude:
- bin/setup
- db/migrate/*
- test/**/*

Metrics/ModuleLength:
Max: 200
Exclude:
- config/**/*

Metrics/ParameterLists:
Max: 6
Max: 4
Exclude:
- app/frontend/components/**/preview.rb

Expand Down Expand Up @@ -144,14 +116,12 @@ Layout/LineLength:
Max: 160
Exclude:
- db/migrate/*.rb
- config/initializers/content_security_policy.rb

Lint/MissingSuper:
Exclude:
- app/services/**/*

Lint/UselessAccessModifier:
Enabled: false

Style/AndOr:
Enabled: false

Expand Down Expand Up @@ -239,9 +209,6 @@ Metrics/BlockLength:
Exclude:
- spec/**/*

Metrics/ClassLength:
Max: 250

Metrics/ModuleLength:
Max: 250

Expand All @@ -250,9 +217,6 @@ Metrics/MethodLength:
Exclude:
- db/migrate/*.rb

Metrics/ParameterLists:
Enabled: false

Naming/BlockForwarding:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ GEM
launchy (3.0.1)
addressable (~> 2.8)
childprocess (~> 5.0)
lefthook (1.7.21)
lefthook (1.8.0)
letter_opener (1.10.0)
launchy (>= 2.2, < 4)
logger (1.6.1)
Expand Down
8 changes: 8 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [1, 'always', 200],
'subject-case': [0],
},
ignores: [(message) => message.includes('CodeFactor')],
};
22 changes: 11 additions & 11 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/** @type {import("@types/eslint").Linter.Config */

import globals from "globals";
import js from "@eslint/js";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import globals from 'globals';
import js from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
js.configs.recommended,
eslintPluginPrettierRecommended,
{
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
sourceType: 'module',
globals: {
...globals.browser,
...globals.es2021,
},
},
rules: {
"no-unused-vars": [
"error",
'no-unused-vars': [
'error',
{
args: "after-used",
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
args: 'after-used',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
"no-var": "error",
"prettier/prettier": "error",
'no-var': 'error',
'prettier/prettier': 'error',
},
},
];
28 changes: 15 additions & 13 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
commit-msg:
commands:
lint-commit-msg:
run: ruby .hooks/lint_commit_msg.rb
run: yarn commitlint --edit $1

pre-commit:
parallel: true
commands:
frontend-linter:
run: yarn lint:js
backend-linter:
eslint_check:
glob: '*.js'
run: yarn run eslint {staged_files}
rubocop_check:
glob: '*.rb'
run: bundle exec rubocop --force-exclusion {staged_files}
frontend-style:
run: yarn lint:css

pre-push:
commands:
client-tests:
root: "client/"
glob: "*.{ts,tsx}"
run: yarn test
# TODO: If you want to check rspec or bundle-audit before pushing, add them here:
# pre-push:
# 1_rspec:
# skip_empty: false
# run: bundle exec rspec
# 2_bundle-audit:
# skip_empty: false
# run: bundle exec bundle-audit check
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"vite-plugin-rails": "^0.5.0"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/js": "^9.9.0",
"@tailwindcss/forms": "^0.5.6",
"@tailwindcss/typography": "^0.5.10",
Expand Down
Loading

0 comments on commit 062d214

Please sign in to comment.