Skip to content

Commit 1d9fbf8

Browse files
author
Template Bot
committed
Apply template update: fix autogen scripts (conflicts)
Source: mockdeep/Rails-Template#1337 This cherry-pick had conflicts that need manual resolution. Search for <<<<<<< in the changed files.
1 parent c8c85d4 commit 1d9fbf8

4 files changed

Lines changed: 144 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,39 @@ jobs:
8181
# name: Brakeman
8282
# command: bundle exec brakeman
8383

84+
<<<<<<< HEAD
8485
# - run:
8586
# name: Stylelint
8687
# command: yarn stylelint
88+
=======
89+
- run:
90+
name: Find Unused ESLint Rules
91+
command: pnpm eslint_find_unused_rules
92+
93+
- run:
94+
name: ESLint
95+
command: pnpm eslint
96+
97+
- run:
98+
name: Verify ESLint Autogen
99+
command: bundle exec exe/eslint_autogen
100+
101+
- run:
102+
name: Vitest
103+
command: pnpm vitest run --coverage
104+
105+
- run:
106+
name: Brakeman
107+
command: bundle exec brakeman
108+
109+
- run:
110+
name: Stylelint
111+
command: pnpm stylelint
112+
>>>>>>> a78f4ba (fix autogen scripts (#1337))
113+
114+
- run:
115+
name: Verify Stylelint Autogen
116+
command: bundle exec exe/stylelint_autogen
87117

88118
- run:
89119
name: Rubocop

.stylelint_todo.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This configuration was generated by `exe/stylelint_autogen`
2+
# on 2026-02-12 23:23:33 UTC.
3+
# The point is for the user to remove these configuration records
4+
# one by one as the offenses are removed from the code base.
5+
6+
overrides:
7+
8+
# Offense count: 9
9+
- rules: { 'order/properties-order': null }
10+
files:
11+
- app/assets/stylesheets/application.css
12+
13+
# Offense count: 21
14+
- rules: { 'plugin/selector-bem-pattern': null }
15+
files:
16+
- app/assets/stylesheets/application.css

exe/eslint_autogen

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "active_support/all"
5+
require "stringio"
6+
7+
TODO_FILE_PATH = "./.eslint_todo.ts"
8+
HEADING = <<~COMMENTS.freeze
9+
// This configuration was generated by `exe/eslint_autogen`
10+
// on #{Time.now.utc}.
11+
// The point is for the user to remove these configuration records
12+
// one by one as the offenses are removed from the code base.
13+
COMMENTS
14+
15+
File.write(TODO_FILE_PATH, "export default []")
16+
json = `pnpm --silent eslint --format json`
17+
results = JSON.parse(json)
18+
19+
by_rule =
20+
results.each_with_object({}) do |result, hash|
21+
result.fetch("messages").each do |message|
22+
rule_id = message.fetch("ruleId")
23+
next if rule_id.nil?
24+
25+
hash[rule_id] ||= []
26+
hash[rule_id] << result.fetch("filePath")
27+
end
28+
end
29+
30+
output = StringIO.new
31+
output.puts(HEADING)
32+
output.puts
33+
output.puts("export default [")
34+
35+
by_rule.sort.each do |rule, file_paths|
36+
output.puts(" // Offense count: #{file_paths.length}")
37+
output.puts(" {")
38+
output.puts(" files: [")
39+
40+
file_paths.uniq.sort.each do |file_path|
41+
relative_path = file_path.sub("#{Dir.pwd}/", "")
42+
output.puts(" \"#{relative_path}\",")
43+
end
44+
45+
output.puts(" ],")
46+
output.puts(" rules: {")
47+
output.puts(" \"#{rule}\": \"off\",")
48+
output.puts(" },")
49+
output.puts(" },")
50+
end
51+
52+
output.puts("];")
53+
54+
File.write(TODO_FILE_PATH, output.string)

exe/stylelint_autogen

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "active_support/all"
5+
require "stringio"
6+
7+
TODO_FILE_PATH = "./.stylelint_todo.yml"
8+
HEADING = <<~COMMENTS.freeze
9+
# This configuration was generated by `exe/stylelint_autogen`
10+
# on #{Time.now.utc}.
11+
# The point is for the user to remove these configuration records
12+
# one by one as the offenses are removed from the code base.
13+
COMMENTS
14+
15+
File.write(TODO_FILE_PATH, "{}")
16+
json =
17+
`pnpm --silent stylelint --quiet-deprecation-warnings --formatter json 2>&1`
18+
results = JSON.parse(json)
19+
20+
by_rule =
21+
results.each_with_object({}) do |result, hash|
22+
result.fetch("warnings").each do |warning|
23+
hash[warning.fetch("rule")] ||= []
24+
hash[warning.fetch("rule")] << result.fetch("source")
25+
end
26+
end
27+
28+
output = StringIO.new
29+
output.puts(HEADING)
30+
output.puts
31+
output.puts("overrides:")
32+
33+
by_rule.sort.each do |rule, file_paths|
34+
output.puts
35+
output.puts(" # Offense count: #{file_paths.length}")
36+
output.puts(" - rules: { '#{rule}': null }")
37+
output.puts(" files:")
38+
39+
file_paths.uniq.sort.each do |file_path|
40+
output.puts(" - #{file_path.sub("#{Dir.pwd}/", "")}")
41+
end
42+
end
43+
44+
File.write(TODO_FILE_PATH, output.string)

0 commit comments

Comments
 (0)