Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add stylelint to prevent typos in CSS #556

Merged
merged 12 commits into from
Mar 1, 2024
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ jobs:

- name: Lint
run: .ci/script.sh

# NPM tests

- name: Uses Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'
# No cache, there are complaints about lockfiles that we don't want otherwise. See <https://github.com/actions/setup-node/issues/928>.
# cache: 'npm'

- run: npm init --yes && npm install stylelint stylelint-config-standard

- name: Check CSS syntax (only epub.css, html5.css and fb2.css)
run: npx stylelint cr3gui/data/epub.css cr3gui/data/html5.css cr3gui/data/fb2.css
66 changes: 66 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"extends": "stylelint-config-standard",
"rules": {
"comment-empty-line-before": null,
"declaration-block-no-redundant-longhand-properties": null,
"declaration-block-single-line-max-declarations": null,
"length-zero-no-unit": [true, { "severity": "warning" }],
"no-descending-specificity": [true, { "severity": "warning" }],
"no-duplicate-selectors": [true, { "severity": "warning" }],
"property-no-unknown": [true, {
"ignoreProperties": [
"binding",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: can be removed after #555.


"hyphenate"
]
}],
"rule-empty-line-before": null,
"selector-attribute-quotes": null,
"selector-class-pattern": "(^([a-z][a-z0-9]*)(-[a-z0-9]+)*$|^fb2_info$)",
"selector-type-case": ["lower", {
"ignoreTypes": ["DocFragment", "rubyBox"]
}],
"selector-type-no-unknown": [true, {
"ignoreTypes": [
"noframes",
"rbc",

"DocFragment",
"rubyBox",

"empty-line",

"author",
"date",
"description",
"genre",

"epigraph",
"v",
"stanza",
"poem",
"text-author",
"epigraph",

"book-title",
"subtitle",
"title-info",
"keywords",
"lang",
"src-lang",
"translator",
"document-info",
"publish-info",
"custom-info",
"coverpage",
"underline",
"spacing",
"emphasis",
"underline",
"strikethrough",
"spacing"
]
}],
"shorthand-property-no-redundant-values": null
}
}
4 changes: 1 addition & 3 deletions cr3gui/data/fb2.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ title, h1, h2, h3, h4, h5, h6, subtitle {
h1, h2, h3, h4, h5, h6 {
display: block;
margin-top: 0.5em;
margin-bottom: 0.3em;
padding: 10px ;
margin-top: 0.5em;
margin-bottom: 0.5em;
padding: 10px ;
}
title, h1, h2 {
page-break-before: always;
Expand Down