lint: Migrate all custom CSS rules to stylelint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-08-05 11:32:25 -07:00 committed by Tim Abbott
parent 1d88c9e12e
commit 9f2cd66a4d
2 changed files with 15 additions and 20 deletions

View File

@ -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": [],
},
};

View File

@ -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,
],
)