From 9f2cd66a4d9a876d9e4fc8238e5ac4b3f2a36905 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 5 Aug 2020 11:32:25 -0700 Subject: [PATCH] lint: Migrate all custom CSS rules to stylelint. Signed-off-by: Anders Kaseorg --- stylelint.config.js | 15 +++++++++++++++ tools/linter_lib/custom_check.py | 20 -------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/stylelint.config.js b/stylelint.config.js index 87ad25659a..5db04a336b 100644 --- a/stylelint.config.js +++ b/stylelint.config.js @@ -26,5 +26,20 @@ module.exports = { // Limit language features "color-no-hex": true, "color-named": "never", + "declaration-property-value-blacklist": { + // thin/medium/thick is under-specified, please use pixels + "/^(border(-top|-right|-bottom|-left)?|outline)(-width)?$/": [ + /\b(thin|medium|thick)\b/, + ], + }, + "function-blacklist": [ + // We use hsl(a) instead of rgb(a) + "rgb", + "rgba", + ], + + // Zulip CSS should have no dependencies on external resources + "function-url-no-scheme-relative": true, + "function-url-scheme-whitelist": [], }, }; diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 8092e4390c..5fa6fb3e54 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -418,26 +418,6 @@ bash_rules = RuleList( css_rules = RuleList( langs=['css', 'scss'], rules=[ - {'pattern': r'^(?:(?!/\*).)*https?://', - 'description': "Zulip CSS should have no dependencies on external resources", - 'good_lines': ['background: url(/static/images/landing-page/pycon.jpg);'], - 'bad_lines': ['background: url(https://example.com/image.png);']}, - {'pattern': ' thin[ ;]', - 'description': "thin CSS attribute is under-specified, please use 1px.", - 'good_lines': ["border-width: 1px;"], - 'bad_lines': ["border-width: thin;", "border-width: thin solid black;"]}, - {'pattern': ' medium[ ;]', - 'description': "medium CSS attribute is under-specified, please use pixels.", - 'good_lines': ["border-width: 3px;"], - 'bad_lines': ["border-width: medium;", "border: medium solid black;"]}, - {'pattern': ' thick[ ;]', - 'description': "thick CSS attribute is under-specified, please use pixels.", - 'good_lines': ["border-width: 5px;"], - 'bad_lines': ["border-width: thick;", "border: thick solid black;"]}, - {'pattern': r'rgba?\(', - 'description': 'Use of rgb(a) format is banned, Please use hsl(a) instead', - 'good_lines': ['hsl(0, 0%, 0%)', 'hsla(0, 0%, 100%, 0.1)'], - 'bad_lines': ['rgb(0, 0, 0)', 'rgba(255, 255, 255, 0.1)']}, *whitespace_rules, ], )