standard-erb 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: ed9f75dc92182335444d8bbb55403026b54f0714b65bfbd6fe77b144b6872355
4
+ data.tar.gz: c3fe6f221ca384a2c795c6ea771a7ad4daf90692d858c5f7b58dc30e4ab3de47
5
+ SHA512:
6
+ metadata.gz: a069fe0def4318e3bf5c41a99d126a5c0bbe7d5641fcf8e0fc92560e14e3768d98066b6a419236efe2e81a5da7d0cf5728c951802f0aa50721d2f228f188c7c5
7
+ data.tar.gz: 25afbebc9ed1f5e0d888dfb30e162db91bfb230f8948a198a7d6957fbc1d070a4e5765f53ab40985353c2392125f2a8e24b85b3e2408ff2342d093016fa44933
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-08-24
4
+
5
+ - Initial release: load rubocop-erb as a Standard plugin, dropping the
6
+ config entries that fail Standard's validation.
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "standard-erb" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["foca@foca.io"](mailto:"foca@foca.io").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Nicolas Sanguinetti
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,106 @@
1
+ # standard-erb
2
+
3
+ Lint the Ruby inside your ERB templates with [Standard](https://github.com/standardrb/standard).
4
+
5
+ This gem is a thin adapter that makes [rubocop-erb](https://github.com/r7kamura/rubocop-erb) load as a Standard plugin. It is **not a fork**: rubocop-erb keeps doing all the work of extracting Ruby from templates; this gem only fixes the integration layer that breaks under Standard.
6
+
7
+ ## Why does this exist?
8
+
9
+ rubocop-erb works fine under plain RuboCop, but Standard does two things RuboCop doesn't:
10
+
11
+ 1. **It validates plugin configs.** RuboCop never validates the configuration a plugin contributes; Standard does. rubocop-erb's config contains an entry for a cop that doesn't exist (`Layout/LeadingEmptyLine`) and a customization of `Lint/Syntax`, which RuboCop forbids configuring. Both are harmless under RuboCop and fatal under Standard. This gem drops those two entries.
12
+ 2. **It merges plugin configs first-come-first-served.** Standard's own rules are always merged first, and once a cop is configured, later plugins can't touch it. rubocop-erb excludes `**/*.erb` from ~50 layout and style cops that make no sense inside a template, but since Standard already configures all of those cops, the excludes are silently discarded. No plugin can fix this; it has to be done in your `.standard.yml` (see below).
13
+
14
+ On top of that, the gem's name (`rubocop-erb`) doesn't match its require path (`rubocop/erb`), so it can't be listed in `plugins:` without extra configuration. `standard-erb` can.
15
+
16
+ ## Installation
17
+
18
+ ```ruby
19
+ # Gemfile
20
+ gem "standard-erb", require: false
21
+ ```
22
+
23
+ ```yaml
24
+ # .standard.yml
25
+ plugins:
26
+ - standard-erb
27
+ ```
28
+
29
+ That's enough for `standardrb` to pick up `.erb` files and report offenses in them.
30
+
31
+ ## Silencing layout cops inside templates
32
+
33
+ Because of the merge behavior described above, you also need to tell Standard which cops to skip for ERB files. Standard's `ignore:` key is applied after all plugins are merged, so it's the one place this can be done. Copy this block into your `.standard.yml` (paths resolve relative to the config file):
34
+
35
+ <!-- ignore-block:start -->
36
+ ```yaml
37
+ ignore:
38
+ - "**/*.erb":
39
+ - Layout/ArgumentAlignment
40
+ - Layout/ArrayAlignment
41
+ - Layout/BlockAlignment
42
+ - Layout/ClosingParenthesisIndentation
43
+ - Layout/CommentIndentation
44
+ - Layout/InitialIndentation
45
+ - Layout/EmptyLineAfterGuardClause
46
+ - Layout/EndAlignment
47
+ - Layout/FirstArgumentIndentation
48
+ - Layout/FirstArrayElementIndentation
49
+ - Layout/FirstArrayElementLineBreak
50
+ - Layout/FirstHashElementIndentation
51
+ - Layout/FirstHashElementLineBreak
52
+ - Layout/FirstMethodArgumentLineBreak
53
+ - Layout/FirstParameterIndentation
54
+ - Layout/HashAlignment
55
+ - Layout/IndentationConsistency
56
+ - Layout/IndentationWidth
57
+ - Layout/LeadingEmptyLine
58
+ - Layout/LeadingEmptyLines
59
+ - Layout/LineEndStringConcatenationIndentation
60
+ - Layout/LineLength
61
+ - Layout/MultilineArrayBraceLayout
62
+ - Layout/MultilineAssignmentLayout
63
+ - Layout/MultilineHashBraceLayout
64
+ - Layout/MultilineMethodCallBraceLayout
65
+ - Layout/MultilineMethodCallIndentation
66
+ - Layout/MultilineMethodDefinitionBraceLayout
67
+ - Layout/MultilineOperationIndentation
68
+ - Layout/ParameterAlignment
69
+ - Layout/TrailingEmptyLines
70
+ - Layout/TrailingWhitespace
71
+ - Lint/EmptyFile
72
+ - Lint/OutOfRangeRegexpRef
73
+ - Lint/Syntax
74
+ - Lint/UselessAssignment
75
+ - Lint/Void
76
+ - Metrics/BlockLength
77
+ - Metrics/BlockNesting
78
+ - Naming/FileName
79
+ - Style/FrozenStringLiteralComment
80
+ - Style/IdenticalConditionalBranches
81
+ - Style/IfUnlessModifier
82
+ - Style/MultilineTernaryOperator
83
+ - Style/NestedTernaryOperator
84
+ - Style/Next
85
+ - Style/ParallelAssignment
86
+ - Style/RescueModifier
87
+ - Style/Semicolon
88
+ - Style/TrailingCommaInArguments
89
+ - Style/TrailingCommaInArrayLiteral
90
+ - Style/TrailingCommaInHashLiteral
91
+ - Style/WhileUntilDo
92
+ - Style/WhileUntilModifier
93
+ ```
94
+ <!-- ignore-block:end -->
95
+
96
+ This is exactly the list of cops rubocop-erb itself excludes from `.erb` files. It's kept in sync with the installed rubocop-erb version by this gem's test suite.
97
+
98
+ `Lint/Syntax` is in the list because the Ruby that rubocop-erb extracts from a template isn't always parseable on its own. If you'd rather see RuboCop's syntax diagnostics on templates, remove it.
99
+
100
+ ## Development
101
+
102
+ Run `bin/setup` to install dependencies, then `bundle exec rake` to run the tests and lint the gem itself.
103
+
104
+ ## License
105
+
106
+ MIT. See [LICENSE.txt](LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[test standard]
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lint_roller"
4
+ require "rubocop"
5
+ require "rubocop/erb"
6
+ require "yaml"
7
+
8
+ module Standard
9
+ module Erb
10
+ class Plugin < LintRoller::Plugin
11
+ # Entries in rubocop-erb's config/default.yml that fail RuboCop's config
12
+ # validation. Plain RuboCop never validates plugin configs, but Standard
13
+ # does, so these are fatal under standardrb.
14
+ #
15
+ # The goal state is for upstream's config to load clean and this list to
16
+ # be empty. Whenever rubocop-erb fixes one of these, delete it here and
17
+ # bump the minimum rubocop-erb version.
18
+ #
19
+ # - Layout/LeadingEmptyLine: dead cop name (the real cop is
20
+ # Layout/LeadingEmptyLines, which upstream also configures).
21
+ # - Lint/Syntax: RuboCop forbids configuring this cop at all under
22
+ # validation, so it can't be fixed upstream. The ignore block in the
23
+ # README restores upstream's intent (no syntax diagnostics on .erb).
24
+ INVALID_UPSTREAM_ENTRIES = ["Layout/LeadingEmptyLine", "Lint/Syntax"].freeze
25
+
26
+ def about
27
+ LintRoller::About.new(
28
+ name: "standard-erb",
29
+ version: VERSION,
30
+ homepage: "https://github.com/foca/standard-erb",
31
+ description: "Lint ERB templates with rubocop-erb under Standard"
32
+ )
33
+ end
34
+
35
+ def supported?(context)
36
+ context.engine == :rubocop
37
+ end
38
+
39
+ def rules(_context)
40
+ register_ruby_extractor
41
+
42
+ LintRoller::Rules.new(
43
+ config_format: :rubocop,
44
+ type: :object,
45
+ value: upstream_config.except(*INVALID_UPSTREAM_ENTRIES)
46
+ )
47
+ end
48
+
49
+ private
50
+
51
+ def register_ruby_extractor
52
+ extractors = RuboCop::Runner.ruby_extractors
53
+ extractors.unshift(RuboCop::Erb::RubyExtractor) unless extractors.include?(RuboCop::Erb::RubyExtractor)
54
+ end
55
+
56
+ def upstream_config
57
+ gem_dir = Gem.loaded_specs.fetch("rubocop-erb").full_gem_path
58
+ YAML.load_file(File.join(gem_dir, "config", "default.yml"))
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Standard
4
+ module Erb
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "erb/version"
4
+ require_relative "erb/plugin"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "standard/erb"
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: standard-erb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nicolas Sanguinetti
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-erb
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.7'
40
+ - !ruby/object:Gem::Dependency
41
+ name: standard
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.35.1
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.35.1
54
+ description: A thin adapter that makes rubocop-erb load cleanly as a Standard (standardrb)
55
+ plugin.
56
+ email:
57
+ - foca@foca.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - CODE_OF_CONDUCT.md
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/standard-erb.rb
68
+ - lib/standard/erb.rb
69
+ - lib/standard/erb/plugin.rb
70
+ - lib/standard/erb/version.rb
71
+ homepage: https://github.com/foca/standard-erb
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ homepage_uri: https://github.com/foca/standard-erb
76
+ source_code_uri: https://github.com/foca/standard-erb
77
+ changelog_uri: https://github.com/foca/standard-erb/blob/main/CHANGELOG.md
78
+ rubygems_mfa_required: 'true'
79
+ default_lint_roller_plugin: Standard::Erb::Plugin
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 3.2.0
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.6.9
95
+ specification_version: 4
96
+ summary: Lint ERB templates with rubocop-erb under Standard
97
+ test_files: []