Skip to content

Instantly share code, notes, and snippets.

@AlyBadawy
Last active February 20, 2024 03:45
Show Gist options
  • Save AlyBadawy/cb85bdc687966c9338888b14c9d30390 to your computer and use it in GitHub Desktop.
Save AlyBadawy/cb85bdc687966c9338888b14c9d30390 to your computer and use it in GitHub Desktop.
Rails + React Gists
PostCheckout:
BundleInstall:
enabled: true
PreCommit:
ALL:
problem_on_unmodified_line: warn
requires_files: true
required: false
quiet: false
AuthorName:
enabled: false
BundleAudit:
enabled: true
flags: ['--update']
BundleCheck:
enabled: true
EsLint:
enabled: true
# https://github.com/sds/overcommit/issues/338
required_executable: 'yarn'
command: ['yarn', 'eslint']
flags: []
include:
[
'app/javascript/**/*.ts',
'app/javascript/**/*.tsx',
'app/javascript/**/*.js',
'app/javascript/**/*.js',
]
Fasterer:
enabled: true
exclude:
- 'vendor/**/*.rb'
- 'db/schema.rb'
ForbiddenBranches:
enabled: true
branch_patterns: ['main']
HamlLint:
enabled: true
MergeConflicts:
enabled: true
exclude:
- '**/conflict/file_spec.rb'
- '**/git/conflict/parser_spec.rb'
# prettier? https://github.com/sds/overcommit/issues/614 https://github.com/sds/overcommit/issues/390#issuecomment-495703284
Prettier:
enabled: true
command: ['npx', 'prettier']
flags: ['-c']
description: 'Ensure Prettier is used to format JS'
include:
- '**/*.js*'
- '**/*.ts*'
- '**/*.json'
RuboCop:
enabled: true
command: ['bundle', 'exec', 'rubocop']
# on_warn: fail # Treat all warnings as failures
ScssLint:
enabled: true
MarkdownLint:
enabled: true
description: 'Lint documentation for Markdown errors'
required_executable: 'node_modules/.bin/markdownlint'
flags: ['--config', '.markdownlint.yml', 'doc/**/*.md']
install_command: 'yarn install'
include:
- 'doc/**/*.md'
Vale:
enabled: true
description: 'Lint documentation for grammatical and formatting errors'
required_executable: 'vale'
flags: ['--config', '.vale.ini', '--minAlertLevel', 'error', 'doc']
install_command: 'brew install vale # (or use another package manager)'
include:
- 'doc/**/*.md'
PrePush:
# Unit & Integration TEST
RSpec:
enabled: true
command: ['bundle', 'exec', 'rspec', 'spec']
on_warn: fail
BundleInstall:
enabled: true
on_warn: fail
CommitMsg:
TextWidth:
enabled: true
min_subject_width: 8 # three 2-letter words with 2 spaces
max_subject_width: 72
quiet: false
EmptyMessage:
enabled: true
required: true
description: 'Checking for empty commit message'
AllCops:
NewCops: enable
Exclude:
- bin/yarn
- db/schema.rb
- vendor/**/*
- node_modules/**/*
- tmp/**/*
- public/**/*
- bin/**/*
require:
- rubocop-performance
- rubocop-rails
- rubocop-rspec
inherit_gem:
rubocop-config-prettier: config/rubocop.yml
#################### Bundler ###############################
Bundler/DuplicatedGem:
Enabled: true
Include:
- '**/*.gemfile'
- '**/Gemfile'
- '**/gems.rb'
Bundler/GemComment:
Enabled: false
Include:
- '**/*.gemfile'
- '**/Gemfile'
- '**/gems.rb'
IgnoredGems: []
OnlyFor: []
Bundler/GemFilename:
Enabled: true
EnforcedStyle: 'Gemfile'
Include:
- '**/Gemfile'
- '**/gems.rb'
- '**/Gemfile.lock'
- '**/gems.locked'
Bundler/GemVersion:
Enabled: false
EnforcedStyle: 'required'
Include:
- '**/*.gemfile'
- '**/Gemfile'
- '**/gems.rb'
AllowedGems: []
Bundler/OrderedGems:
Enabled: true
TreatCommentsAsGroupSeparators: true
ConsiderPunctuation: false
Include:
- '**/*.gemfile'
- '**/Gemfile'
- '**/gems.rb'
#################### Layout ###########################
Layout/AccessModifierIndentation:
Enabled: true
EnforcedStyle: indent
Layout/ArgumentAlignment:
Enabled: true
EnforcedStyle: with_first_argument
Layout/ArrayAlignment:
Enabled: true
EnforcedStyle: with_first_element
Layout/CaseIndentation:
Enabled: true
EnforcedStyle: case
IndentOneStep: false
Layout/ClassStructure:
Enabled: true
Categories:
module_inclusion:
- include
- prepend
- extend
ExpectedOrder:
- module_inclusion
- constants
- public_class_methods
- initializer
- public_methods
- protected_methods
- private_methods
Layout/CommentIndentation:
Enabled: true
AllowForAlignment: true
Layout/DotPosition:
Enabled: true
EnforcedStyle: leading
Layout/EmptyLineBetweenDefs:
Enabled: true
EmptyLineBetweenMethodDefs: true
EmptyLineBetweenClassDefs: true
EmptyLineBetweenModuleDefs: true
AllowAdjacentOneLineDefs: true
NumberOfEmptyLines: 1
Layout/EmptyLinesAroundAccessModifier:
Enabled: true
EnforcedStyle: around
Layout/HashAlignment:
Enabled: true
AllowMultipleStyles: true
EnforcedHashRocketStyle: key
EnforcedColonStyle: key
Layout/IndentationStyle:
Enabled: true
EnforcedStyle: spaces
Layout/IndentationWidth:
Width: 2
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
###################### Lint ###########################
Lint/Debugger:
Enabled: true
Severity: error
#################### Metrics ##########################
Metrics/AbcSize:
Max: 50
Metrics/BlockLength:
CountComments: false
Max: 50
AllowedMethods:
- context
- describe
- it
- shared_examples
- shared_examples_for
- namespace
- draw
- configure
- group
Exclude:
- config/routes.rb
- config/seeds.rb
Metrics/ClassLength:
Enabled: true
Max: 200
Metrics/ModuleLength:
Enabled: true
Max: 250
Metrics/MethodLength:
Enabled: true
Max: 20
Rails:
Enabled: true # enable rubocop-rails cops
Rails/ApplicationController:
Enabled: true
Exclude:
- app/controllers/react_controller.rb
Rails/FilePath:
Enabled: false
Rails/ResponseParsedBody:
Enabled: false
RSpec:
Enabled: true # enable rubocop-rspec cops
RSpec/DescribeClass:
Enabled: false # ignore missing comments on classes
RSpec/ExampleLength:
Enabled: true
Max: 25
RSpec/FilePath:
Enabled: true
Exclude:
- spec/helpers/react
RSpec/HookArgument:
Enabled: false
RSpec/InstanceVariable:
Enabled: false
RSpec/NestedGroups:
Enabled: true
Max: 5
RSpec/MultipleExpectations:
Enabled: true
Max: 5
Style/Documentation:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
Style/QuotedSymbols:
Enabled: true
EnforcedStyle: single_quotes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment