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

build(lint): use native stylelint config resolution #350

Merged
merged 4 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/**
* @type {import('npm:stylelint').Config}
*/
const config = {
extends: "stylelint-config-standard",
customSyntax: "postcss-less",
rules: {
"selector-class-pattern": null,
"custom-property-pattern": null,
"selector-id-pattern": null,

"rule-empty-line-before": null,
"comment-empty-line-before": null,
"custom-property-empty-line-before": null,
"at-rule-empty-line-before": null,
"declaration-empty-line-before": null,

"property-no-vendor-prefix": null,
"alpha-value-notation": null,
"color-function-notation": null,
"hue-degree-notation": null,

// Needed for Stylus v1.5.35 workaround, see #341
"media-feature-range-notation": "prefix",

// These are not invalid with Less.
"no-invalid-position-at-import-rule": null,
"no-invalid-double-slash-comments": null,

"at-rule-disallowed-list": [
["/^font.*/"],
{
/**
* @param {string} atRule
*/
message: (atRule) =>
`At-rule ${atRule} is not allowed in Catppuccin userstyles`,
},
],
"property-disallowed-list": [
[
// Disallow setting custom fonts.
"/font.*/",

// Ideally we could disallow these, but CSS continues to be gross.
// "/animation.*/",
// "/transition.*/",

// Prefer `border-color` over `border`, `outline-color` over `outline`, etc.
"border",
"outline",
],
{
/**
* @param {string} prop
*/
message: (prop) => {
if (["border", "outline"].includes(prop)) {
return `Use \`${prop}-color\` instead of \`${prop}\``;
} else {
return `Property \`${prop}\` is not allowed in Catppuccin userstyles`;
}
},
},
],

"function-no-unknown": [
true,
{
ignoreFunctions: [
// Generated from https://lesscss.org/functions/ via `Array.from(document.querySelectorAll('.section-content h3.docs-heading'), heading => heading.textContent.replace('\n', ''))`.
"%",
"abs",
"acos",
"alpha",
"argb",
"asin",
"atan",
"average",
"blue",
"boolean",
"ceil",
"color",
"contrast",
"convert",
"cos",
"darken",
"data-uri",
"default",
"desaturate",
"difference",
"e",
"each",
"escape",
"exclusion",
"extract",
"fade",
"fadein",
"fadeout",
"floor",
"get-unit",
"green",
"greyscale",
"hardlight",
"hsl",
"hsla",
"hsv",
"hsva",
"hsvhue",
"hsvsaturation",
"hsvvalue",
"hue",
"if",
"image-height",
"image-size",
"image-width",
"iscolor",
"isdefined",
"isem",
"iskeyword",
"isnumber",
"ispercentage",
"ispixel",
"isruleset",
"isstring",
"isunit",
"isurl",
"length",
"lighten",
"lightness",
"luma",
"luminance",
"max",
"min",
"mix",
"mod",
"multiply",
"negation",
"overlay",
"percentage",
"pi",
"pow",
"range",
"red",
"replace",
"rgb",
"rgba",
"round",
"saturate",
"saturation",
"screen",
"shade",
"sin",
"softlight",
"spin",
"sqrt",
"svg-gradient",
"tan",
"tint",
"unit",
],
},
],
"function-name-case": null,

"no-descending-specificity": null,
},
};

module.exports = config;
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"lint": "deno run -A ./scripts/lint/main.ts",
"lint:fix": "deno task lint --fix",
"update-types": "deno run -A ./scripts/update-types.ts"
}
},
"nodeModulesDir": true
}
24 changes: 11 additions & 13 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/lint/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ for await (const entry of stylesheets) {
);

// advanced linting with stylelint
lint(entry, content, flags.fix);
await lint(entry, content, flags.fix);
}

// if any files are missing, cause the workflow to fail
Expand Down
Loading