Skip to content

Commit e8d1e48

Browse files
authored
integrate Stylelint (#1374)
1 parent fc10a10 commit e8d1e48

7 files changed

Lines changed: 1045 additions & 6 deletions

File tree

.circleci/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ jobs:
7171

7272
- run:
7373
name: ESLint
74-
command: pnpm lint
74+
command: pnpm eslint
75+
76+
- run:
77+
name: Stylelint
78+
command: pnpm stylelint
79+
80+
- run:
81+
name: Verify Stylelint Autogen
82+
command: bundle exec exe/stylelint_autogen
7583

7684
- run:
7785
name: Rubocop

.rubocop_todo.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400`
3-
# on 2026-02-02 14:59:16 UTC using RuboCop version 1.84.0.
3+
# on 2026-02-14 01:48:12 UTC using RuboCop version 1.84.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -73,7 +73,7 @@ Metrics/PerceivedComplexity:
7373
# Offense count: 3
7474
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
7575
# AllowedMethods: call
76-
# WaywardPredicates: nonzero?
76+
# WaywardPredicates: infinite?, nonzero?
7777
Naming/PredicateMethod:
7878
Exclude:
7979
- 'app/utils/sample_story.rb'
@@ -252,7 +252,7 @@ Rails/Validation:
252252
Exclude:
253253
- 'app/models/story.rb'
254254

255-
# Offense count: 16
255+
# Offense count: 20
256256
# This cop supports unsafe autocorrection (--autocorrect-all).
257257
# Configuration parameters: EnforcedStyle.
258258
# SupportedStyles: brackets, fetch
@@ -266,6 +266,7 @@ Style/HashLookupMethod:
266266
- 'app/controllers/feeds_controller.rb'
267267
- 'app/controllers/stories_controller.rb'
268268
- 'config/application.rb'
269+
- 'exe/stylelint_autogen'
269270
- 'spec/repositories/feed_repository_spec.rb'
270271
- 'spec/repositories/story_repository_spec.rb'
271272
- 'spec/repositories/user_repository_spec.rb'
@@ -293,6 +294,14 @@ Style/StaticClass:
293294
- 'app/repositories/story_repository.rb'
294295
- 'app/repositories/user_repository.rb'
295296

297+
# Offense count: 1
298+
# This cop supports safe autocorrection (--autocorrect).
299+
# Configuration parameters: EnforcedStyle.
300+
# SupportedStyles: single_quotes, double_quotes
301+
Style/StringLiteralsInInterpolation:
302+
Exclude:
303+
- 'exe/stylelint_autogen'
304+
296305
# Offense count: 1
297306
Style/TopLevelMethodDefinition:
298307
Exclude:

.stylelint_todo.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This configuration was generated by `exe/stylelint_autogen`
2+
# on 2026-02-14 01:44:58 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: 5
9+
- rules: { 'alpha-value-notation': null }
10+
files:
11+
- app/assets/stylesheets/application.css
12+
13+
# Offense count: 5
14+
- rules: { 'color-function-alias-notation': null }
15+
files:
16+
- app/assets/stylesheets/application.css
17+
18+
# Offense count: 5
19+
- rules: { 'color-function-notation': null }
20+
files:
21+
- app/assets/stylesheets/application.css
22+
23+
# Offense count: 1
24+
- rules: { 'color-hex-length': null }
25+
files:
26+
- app/assets/stylesheets/application.css
27+
28+
# Offense count: 2
29+
- rules: { 'comment-empty-line-before': null }
30+
files:
31+
- app/assets/stylesheets/application.css
32+
33+
# Offense count: 1
34+
- rules: { 'font-family-name-quotes': null }
35+
files:
36+
- app/assets/stylesheets/application.css
37+
38+
# Offense count: 15
39+
- rules: { 'length-zero-no-unit': null }
40+
files:
41+
- app/assets/stylesheets/application.css
42+
43+
# Offense count: 3
44+
- rules: { 'media-feature-range-notation': null }
45+
files:
46+
- app/assets/stylesheets/application.css
47+
48+
# Offense count: 64
49+
- rules: { 'order/properties-order': null }
50+
files:
51+
- app/assets/stylesheets/application.css
52+
53+
# Offense count: 19
54+
- rules: { 'property-no-vendor-prefix': null }
55+
files:
56+
- app/assets/stylesheets/application.css
57+
58+
# Offense count: 2
59+
- rules: { 'selector-class-pattern': null }
60+
files:
61+
- app/assets/stylesheets/application.css

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)

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
{
22
"private": true,
33
"scripts": {
4-
"lint": "eslint app/assets/javascripts/ spec/javascript/spec/"
4+
"eslint": "eslint app/assets/javascripts/ spec/javascript/spec/",
5+
"stylelint": "stylelint 'app/assets/stylesheets/**/*.css'"
56
},
67
"devDependencies": {
78
"@eslint/js": "^9.21.0",
89
"eslint": "^9.21.0",
9-
"globals": "^16.0.0"
10+
"globals": "^16.0.0",
11+
"stylelint": "^17.3.0",
12+
"stylelint-config-recess-order": "^7.6.1",
13+
"stylelint-config-standard": "^40.0.0",
14+
"stylelint-selector-bem-pattern": "^4.0.1"
1015
},
1116
"packageManager": "pnpm@10.4.1"
1217
}

0 commit comments

Comments
 (0)