Skip to content

Commit

Permalink
lint RTL further
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Jun 25, 2024
1 parent 4918f64 commit df86b56
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
13 changes: 7 additions & 6 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ body {

table thead th {
border-bottom: 2px solid #777;
text-align: left;
text-align: inline-start;
}

table td:first-child, table th:first-child {
border-inline-end: 2px solid #777;
font-weight: bold;
text-align: left;
text-align: inline-start;
}

table td:not(first-child), table th:not(first-child) {
Expand Down Expand Up @@ -1263,14 +1263,15 @@ table.contributions{
div.highlight {
position: relative;
}
/* Code copy button */
div.highlight .btn{
-webkit-transition:opacity .3s ease-in-out;
-o-transition:opacity .3s ease-in-out;
transition:opacity .3s ease-in-out;
opacity:0;
padding:2px 6px;
position:absolute;
right:4px;
inset-inline-end:4px;
top:4px;
}

Expand Down Expand Up @@ -1476,7 +1477,7 @@ div.contributors-line {
}
dt {
width: 8em;
text-align: right;
text-align: end;
font-weight: initial;
}
dd {
Expand Down Expand Up @@ -1786,7 +1787,7 @@ figure > a[target="_blank"]::after {
}

figcaption {
text-align: left;
text-align: start;
}
}

Expand Down Expand Up @@ -1929,7 +1930,7 @@ body[data-brightness="dark"] {
width: 25%;
}
table tr td:nth-child(2) {
text-align: left;
text-align: start;
display: table-cell;
width: 100%;
}
Expand Down
53 changes: 51 additions & 2 deletions bin/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -916,18 +916,67 @@ def self.fix_ga_wf(contents)

def self.fix_css(contents)
results = []
results += find_matching_texts(contents, /-(left|right)/)
results += find_matching_texts(contents, /margin-left/)
.map do |idx, _text, selected|
ReviewDogEmitter.warning(
path: @path,
idx: idx,
match_start: selected.begin(1),
match_end: selected.end(1) + 1,
replacement: 'margin-inline-start',
message: 'Use margin-inline-start to support right-to-left languages See: https://firefox-source-docs.mozilla.org/code-quality/coding-style/rtl_guidelines.html',
code: 'GTN:037'
)
end
results += find_matching_texts(contents, /margin-right/)
.map do |idx, _text, selected|
ReviewDogEmitter.warning(
path: @path,
idx: idx,
match_start: selected.begin(1),
match_end: selected.end(1) + 1,
replacement: 'margin-inline-end',
message: 'Use margin-inline-end to support right-to-left languages See: https://firefox-source-docs.mozilla.org/code-quality/coding-style/rtl_guidelines.html',
code: 'GTN:037'
)
end
results += find_matching_texts(contents, /padding-left/)
.map do |idx, _text, selected|
ReviewDogEmitter.warning(
path: @path,
idx: idx,
match_start: selected.begin(1),
match_end: selected.end(1) + 1,
replacement: 'padding-inline-start',
message: 'Use padding-inline-start to support right-to-left languages See: https://firefox-source-docs.mozilla.org/code-quality/coding-style/rtl_guidelines.html',
code: 'GTN:037'
)
end
results += find_matching_texts(contents, /padding-right/)
.map do |idx, _text, selected|
ReviewDogEmitter.warning(
path: @path,
idx: idx,
match_start: selected.begin(1),
match_end: selected.end(1) + 1,
replacement: 'padding-inline-end',
message: 'Use padding-inline-end to support right-to-left languages See: https://firefox-source-docs.mozilla.org/code-quality/coding-style/rtl_guidelines.html',
code: 'GTN:037'
)
end
results += find_matching_texts(contents, /(left|[^b]right)/)
.map do |idx, _text, selected|
ReviewDogEmitter.warning(
path: @path,
idx: idx,
match_start: selected.begin(1),
match_end: selected.end(1) + 1,
replacement: '',
message: 'Use -start and -end instead of -left and -right to support right-to-left languages See: https://firefox-source-docs.mozilla.org/code-quality/coding-style/rtl_guidelines.html',
message: 'Use start/end to support right-to-left languages See: https://firefox-source-docs.mozilla.org/code-quality/coding-style/rtl_guidelines.html',
code: 'GTN:037'
)
end

results
end

Expand Down

0 comments on commit df86b56

Please sign in to comment.