Skip to content

Commit

Permalink
Fix safe colors (#101)
Browse files Browse the repository at this point in the history
* Fix safe colors

* Update README.md

Co-authored-by: Brahim Hadriche <[email protected]>

---------

Co-authored-by: Bronley Plumb <[email protected]>
  • Loading branch information
iBicha and TwitchBronBron authored Mar 11, 2024
1 parent 2cd798e commit a650d6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Default rules:

- `color-cert`: enforces Roku's [broadcast safe color 6.4 certification requirement](https://developer.roku.com/en-gb/docs/developer-program/certification/certification.md). Requires that `color-format` is set to `hash-hex` or `quoted-numeric-hex`.

- `always`: ensures all white and black color-format values either match or are darker/ lighter than the minimum recommended values. For white the minimum value is `#DBDBDB` and for black the minimum value is `#161616`
- `always`: ensures all white and black color-format values either match or are darker/ lighter than the minimum recommended values. For white the maximum value is `#EBEBEB` and for black the minimum value is `#161616`
- `off`: do not validate (**default**)

### Strictness rules
Expand Down
4 changes: 2 additions & 2 deletions src/createColorValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function createColorValidator(severity: Readonly<BsLintRules>) {
return (text, range, diagnostics) => {
const len = text.length;
if (len < 7 || len > 12) {
// we're only interested in string length is between 7 (#DBDBDB) to 12 ("0xDBDBDBff") chars long
// we're only interested in string length is between 7 (#EBEBEB) to 12 ("0xEBEBEBFF") chars long
return;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ function validateColorCertCompliance(matches: RegExpMatchArray, range: Range, di
const validateCertCompliant = certCompliant === 'always';
if (validateCertCompliant && matches) {
const BROADCAST_SAFE_BLACK = '161616';
const BROADCAST_SAFE_WHITE = 'DBDBDB';
const BROADCAST_SAFE_WHITE = 'EBEBEB';
const MAX_BLACK_LUMA = getColorLuma(BROADCAST_SAFE_BLACK);
const MAX_WHITE_LUMA = getColorLuma(BROADCAST_SAFE_WHITE);
let colorValue = matches[0];
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/codeStyle/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,9 @@ describe('codeStyle', () => {
});
program.setFile('source/main.bs', `
sub init()
color = "0xDBDBDC"
color = "0xEBEBEC"
color = "0x161616"
color = "0xDBDBDBFF"
color = "0xEBEBEBFF"
color = "0x161615"
longStringWithColors = "Long string value with 0x161615 non broadcast safe color values defined"
end sub
Expand All @@ -798,7 +798,7 @@ describe('codeStyle', () => {
sub init()
color = "0xDBDBDC"
color = "0x161616"
color = "0xDBDBDBFF"
color = "0xEBEBEBFF"
color = "0x161615"
longStringWithColors = "Long string value with 0x161615 non broadcast safe color values defined"
end sub
Expand Down

0 comments on commit a650d6f

Please sign in to comment.