pasika 0.10.18 → 0.10.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -115,6 +115,7 @@ declare const tailwindRules: {
|
|
|
115
115
|
"css-entry-point": _eslint_css.CSSRuleDefinition;
|
|
116
116
|
"global-stylesheet": _eslint_css.CSSRuleDefinition;
|
|
117
117
|
"unused-utility": _eslint_css.CSSRuleDefinition;
|
|
118
|
+
"single-use-utility": _eslint_css.CSSRuleDefinition;
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
/** Framework-agnostic package.json rules any repository should follow. */
|
|
@@ -165,6 +166,7 @@ declare const pasikaPlugin: {
|
|
|
165
166
|
"css-entry-point": _eslint_css.CSSRuleDefinition;
|
|
166
167
|
"global-stylesheet": _eslint_css.CSSRuleDefinition;
|
|
167
168
|
"unused-utility": _eslint_css.CSSRuleDefinition;
|
|
169
|
+
"single-use-utility": _eslint_css.CSSRuleDefinition;
|
|
168
170
|
"doc-kind-suffix": _eslint_markdown.MarkdownRuleDefinition;
|
|
169
171
|
"title-matches-file-name": _eslint_markdown.MarkdownRuleDefinition;
|
|
170
172
|
overview: _eslint_markdown.MarkdownRuleDefinition;
|
|
@@ -6939,6 +6939,48 @@ var unusedUtilityRule = {
|
|
|
6939
6939
|
}
|
|
6940
6940
|
};
|
|
6941
6941
|
|
|
6942
|
+
// eslint/rules/tailwind/single-use-utility.ts
|
|
6943
|
+
import { statSync as statSync8 } from "fs";
|
|
6944
|
+
function usagePattern2(name) {
|
|
6945
|
+
return new RegExp(`(?<![\\\\w-])${escapeRegExp(name)}(?![\\\\w-])`);
|
|
6946
|
+
}
|
|
6947
|
+
var singleUseUtilityRule = {
|
|
6948
|
+
meta: {
|
|
6949
|
+
schema: [],
|
|
6950
|
+
type: "problem",
|
|
6951
|
+
docs: {
|
|
6952
|
+
description: "Disallow custom utilities referenced by only one source file."
|
|
6953
|
+
}
|
|
6954
|
+
},
|
|
6955
|
+
create(context) {
|
|
6956
|
+
const sourceRoot = sourceRootOf(context);
|
|
6957
|
+
let files;
|
|
6958
|
+
try {
|
|
6959
|
+
if (!statSync8(sourceRoot).isDirectory()) return {};
|
|
6960
|
+
files = findFiles(sourceRoot, SOURCE_EXTENSIONS);
|
|
6961
|
+
} catch {
|
|
6962
|
+
return {};
|
|
6963
|
+
}
|
|
6964
|
+
const textOf = cachedTextReader();
|
|
6965
|
+
return {
|
|
6966
|
+
"StyleSheet:exit"(node) {
|
|
6967
|
+
for (const utility of atrulesNamed(node, "utility")) {
|
|
6968
|
+
const name = preludeIdentifiers(utility)[0];
|
|
6969
|
+
if (!name) continue;
|
|
6970
|
+
const pattern = usagePattern2(name);
|
|
6971
|
+
const definition = `@utility ${name}`;
|
|
6972
|
+
const consumers = files.filter((file) => pattern.test(textOf(file).replaceAll(definition, "")));
|
|
6973
|
+
if (consumers.length !== 1) continue;
|
|
6974
|
+
context.report({
|
|
6975
|
+
node: utility,
|
|
6976
|
+
message: `Custom utility "${name}" is used by only one source file; keep that styling as static Tailwind classes in its consumer.`
|
|
6977
|
+
});
|
|
6978
|
+
}
|
|
6979
|
+
}
|
|
6980
|
+
};
|
|
6981
|
+
}
|
|
6982
|
+
};
|
|
6983
|
+
|
|
6942
6984
|
// eslint/rules/tailwind/index.ts
|
|
6943
6985
|
var tailwindRules = {
|
|
6944
6986
|
"theme-reset": themeResetRule,
|
|
@@ -6952,7 +6994,8 @@ var tailwindRules = {
|
|
|
6952
6994
|
"theme-variable-namespace": themeVariableNamespaceRule,
|
|
6953
6995
|
"css-entry-point": cssEntryPointRule,
|
|
6954
6996
|
"global-stylesheet": globalStylesheetRule,
|
|
6955
|
-
"unused-utility": unusedUtilityRule
|
|
6997
|
+
"unused-utility": unusedUtilityRule,
|
|
6998
|
+
"single-use-utility": singleUseUtilityRule
|
|
6956
6999
|
};
|
|
6957
7000
|
|
|
6958
7001
|
// eslint/rules/package-json/exact-version.ts
|