jeff-style-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 84a03154285ed64b26bb85dfe5699f263a0ecbec33ba407c1aaa413214e54040
4
+ data.tar.gz: 5c0b9326580973f2f1e318f342fcc1d6edebecdd3187f19ec390fcccd0e3bf1b
5
+ SHA512:
6
+ metadata.gz: e6c54ac08e9d99407501151e4ff5e6b9d1d439adb46260f9fea9e20d02de9a9837aaf80c6cd2eeaa4ebc932dc180d3c0209f010dfe3691ab52fbd92b4e35ce38
7
+ data.tar.gz: 23db85f83fa1057d8ea1685c83c47f36b28287ba433b991e905c058b92ef9eb005bc59057ca3d1b48b7b66b6fe585f6116774fbd7394562257e32d2af857e136
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Jeff Lunt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # jeff-style-rails
2
+
3
+ Custom [RuboCop](https://rubocop.org) plugin enforcing personal Ruby on Rails style and conventions.
4
+
5
+ ## Usage in a Rails App
6
+
7
+ Add the gem to your Rails application's `Gemfile`:
8
+
9
+ ```ruby
10
+ group :development, :test do
11
+ gem "jeff-style-rails", github: "jefflunt/jeff-style-rails", require: false
12
+ end
13
+ ```
14
+
15
+ Enable the plugin in `.rubocop.yml`:
16
+
17
+ ```yaml
18
+ plugins:
19
+ - rubocop-rails
20
+ - jeff-style-rails
21
+ ```
22
+
23
+ ## Adding Custom Cops
24
+
25
+ 1. Create a cop class in `lib/rubocop/cop/jeff_style_rails/<cop_name>.rb` under `RuboCop::Cop::JeffStyleRails` (all files in that directory are auto-required).
26
+ 2. Add its default configuration entry in `config/default.yml`.
27
+ 3. Add specs in `spec/rubocop/cop/jeff_style_rails/<cop_name>_spec.rb`.
28
+
29
+ You can also place personal overrides for built-in `Style/*`, `Layout/*`, `Lint/*`, or `Rails/*` cops directly in `config/default.yml`.
30
+
31
+ ## Development
32
+
33
+ ```bash
34
+ bin/setup
35
+ bundle exec rake # runs RSpec and RuboCop
36
+ bundle exec rspec # runs cop specs only
37
+ bundle exec rubocop # lints this repository
38
+ ```
@@ -0,0 +1,7 @@
1
+ # Default configuration for jeff-style-rails.
2
+ # Add custom JeffStyleRails/* cops and personal RuboCop / Rails rule overrides here.
3
+
4
+ JeffStyleRails/Example:
5
+ Description: "Starter template cop demonstrating AST matching and autocorrection."
6
+ Enabled: false
7
+ VersionAdded: "0.1.0"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rubocop/jeff_style_rails"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module JeffStyleRails
6
+ # Starter template cop showing AST node pattern matching and autocorrection.
7
+ # Disabled by default in `config/default.yml`.
8
+ #
9
+ # @example
10
+ # # bad
11
+ # legacy_helper(user)
12
+ #
13
+ # # good
14
+ # modern_helper(user)
15
+ class Example < Base
16
+ extend AutoCorrector
17
+
18
+ MSG = "Prefer `modern_helper` over `legacy_helper`."
19
+ RESTRICT_ON_SEND = %i[legacy_helper].freeze
20
+
21
+ def_node_matcher :legacy_helper_call?, <<~PATTERN
22
+ (send nil? :legacy_helper ...)
23
+ PATTERN
24
+
25
+ def on_send(node)
26
+ return unless legacy_helper_call?(node)
27
+
28
+ add_offense(node.loc.selector) do |corrector|
29
+ corrector.replace(node.loc.selector, "modern_helper")
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lint_roller"
4
+
5
+ module RuboCop
6
+ module JeffStyleRails
7
+ # LintRoller plugin integration for RuboCop 1.72+.
8
+ class Plugin < LintRoller::Plugin
9
+ def about
10
+ LintRoller::About.new(
11
+ name: "jeff-style-rails",
12
+ version: VERSION,
13
+ homepage: "https://github.com/jefflunt/jeff-style-rails",
14
+ description: "Custom RuboCop rules enforcing personal Ruby on Rails style."
15
+ )
16
+ end
17
+
18
+ def supported?(context)
19
+ context.engine == :rubocop
20
+ end
21
+
22
+ def rules(_context)
23
+ LintRoller::Rules.new(
24
+ type: :path,
25
+ config_format: :rubocop,
26
+ value: CONFIG_DEFAULT
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module JeffStyleRails
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "rubocop"
5
+ require_relative "jeff_style_rails/version"
6
+ require_relative "jeff_style_rails/plugin"
7
+
8
+ module RuboCop
9
+ # Namespace for Jeff's custom Rails RuboCop plugin and rules.
10
+ module JeffStyleRails
11
+ PROJECT_ROOT = Pathname.new(__dir__).join("../..").expand_path.freeze
12
+ CONFIG_DEFAULT = PROJECT_ROOT.join("config/default.yml").freeze
13
+ end
14
+ end
15
+
16
+ Dir.glob(File.join(__dir__, "cop/jeff_style_rails/**/*.rb")).each do |cop_file|
17
+ require cop_file
18
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jeff-style-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Lunt
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: lint_roller
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rubocop
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.72'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.72'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rubocop-rails
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.28'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.28'
54
+ description: A RuboCop plugin containing custom cops and configuration for Jeff's
55
+ Ruby on Rails conventions.
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - LICENSE.txt
61
+ - README.md
62
+ - config/default.yml
63
+ - lib/jeff-style-rails.rb
64
+ - lib/rubocop/cop/jeff_style_rails/example.rb
65
+ - lib/rubocop/jeff_style_rails.rb
66
+ - lib/rubocop/jeff_style_rails/plugin.rb
67
+ - lib/rubocop/jeff_style_rails/version.rb
68
+ homepage: https://github.com/jefflunt/jeff-style-rails
69
+ licenses:
70
+ - MIT
71
+ metadata:
72
+ homepage_uri: https://github.com/jefflunt/jeff-style-rails
73
+ source_code_uri: https://github.com/jefflunt/jeff-style-rails
74
+ default_lint_roller_plugin: RuboCop::JeffStyleRails::Plugin
75
+ rubygems_mfa_required: 'true'
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 3.2.0
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 4.0.20
91
+ specification_version: 4
92
+ summary: Custom RuboCop rules enforcing personal Ruby on Rails style.
93
+ test_files: []