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

refactor(stylelint): change config to module format to enable more dynamic options #10311

Merged
merged 2 commits into from
Sep 16, 2024
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
81 changes: 81 additions & 0 deletions packages/calcite-components/.stylelintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// @ts-check

const scssPatternRules = [
"scss/at-function-pattern",
"scss/dollar-variable-pattern",
"scss/at-mixin-pattern",
"scss/percent-placeholder-pattern",
];

/** @type {import('stylelint').Config["rules"]} */
const rules = {
"length-zero-no-unit": true,
"liberty/use-logical-spec": [
"always",
{
except: ["left", "right"],
},
],
"no-descending-specificity": [
true,
{
ignore: ["selectors-within-list"],
},
],
"selector-disallowed-list": [
["/:host-context/"],
{
message: ":host-context is not supported in all browsers, so it should be avoided",
severity: "error",
},
],
"selector-max-specificity": [
"0,5,5",
{
message: "selector is too complex, consider applying multiple classes dynamically during rendering",
},
],
"selector-pseudo-element-colon-notation": [
"double",
{
message: "Use double colons for pseudo-elements",
},
],
"selector-type-no-unknown": [
true,
{
ignoreTypes: ["/^calcite-/"],
},
],
"scss/function-no-unknown": [
true,
{
ignoreFunctions: ["get-trailing-text-input-padding", "scale-duration", "theme", "var"],
severity: "error",
},
],
};

scssPatternRules.forEach((rule) => {
const kebabCasePattern = "^([a-z][a-z0-9]*)(-[a-z0-9]+)*$";

rules[rule] =
/** @type {import('stylelint').Config["rules"][string]} */
[
kebabCasePattern,
{
message: "Name should be kebab-cased",
severity: "error",
},
];
});

/** @type {import('stylelint').Config} */
const config = {
defaultSeverity: "warning",
extends: "stylelint-config-recommended-scss",
plugins: ["stylelint-use-logical-spec"],
rules,
};

module.exports = config;
80 changes: 0 additions & 80 deletions packages/calcite-components/.stylelintrc.json

This file was deleted.

Loading