pasika 0.10.137 → 0.10.139
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.
|
@@ -135,7 +135,7 @@ declare const tailwindRules: {
|
|
|
135
135
|
"css-entry-point": _eslint_css.CSSRuleDefinition;
|
|
136
136
|
"feature-css-placement": _eslint_css.CSSRuleDefinition;
|
|
137
137
|
"global-stylesheet": _eslint_css.CSSRuleDefinition;
|
|
138
|
-
"unused-
|
|
138
|
+
"unused-css-definition": _eslint_css.CSSRuleDefinition;
|
|
139
139
|
"unique-css-definition": _eslint_css.CSSRuleDefinition;
|
|
140
140
|
"unique-css-token-value": _eslint_css.CSSRuleDefinition;
|
|
141
141
|
"no-utility-alias": _eslint_css.CSSRuleDefinition;
|
|
@@ -178,7 +178,7 @@ declare const pasikaPlugin: {
|
|
|
178
178
|
"css-entry-point": _eslint_css.CSSRuleDefinition;
|
|
179
179
|
"feature-css-placement": _eslint_css.CSSRuleDefinition;
|
|
180
180
|
"global-stylesheet": _eslint_css.CSSRuleDefinition;
|
|
181
|
-
"unused-
|
|
181
|
+
"unused-css-definition": _eslint_css.CSSRuleDefinition;
|
|
182
182
|
"unique-css-definition": _eslint_css.CSSRuleDefinition;
|
|
183
183
|
"unique-css-token-value": _eslint_css.CSSRuleDefinition;
|
|
184
184
|
"no-utility-alias": _eslint_css.CSSRuleDefinition;
|
|
@@ -10622,6 +10622,13 @@ function buildCssDependencyGraph(options) {
|
|
|
10622
10622
|
const utilities = new Set(definitions.filter((item) => item.kind === "utility").map((item) => item.name));
|
|
10623
10623
|
const selectors = new Set(definitions.filter((item) => item.kind === "selector").map((item) => item.name));
|
|
10624
10624
|
const keyframes = new Set(definitions.filter((item) => item.kind === "keyframes").map((item) => item.name));
|
|
10625
|
+
for (const token of definitions) {
|
|
10626
|
+
if (token.kind !== "theme-token" || !token.name.startsWith("--animate-") || !token.value) continue;
|
|
10627
|
+
for (const name of keyframes) {
|
|
10628
|
+
if (tokenLines(token.value, name).length === 0) continue;
|
|
10629
|
+
references.push({ kind: "keyframes", name, file: token.file, line: token.line, source: "css" });
|
|
10630
|
+
}
|
|
10631
|
+
}
|
|
10625
10632
|
const generatedClasses = /* @__PURE__ */ new Map();
|
|
10626
10633
|
const themeNames = definitions.filter((symbol) => symbol.kind === "theme-token").map((symbol) => symbol.name);
|
|
10627
10634
|
const classesByToken = themeClassesForTokens(themeNames, options.sourceRoot);
|
|
@@ -10705,9 +10712,6 @@ function buildCssDependencyGraph(options) {
|
|
|
10705
10712
|
}
|
|
10706
10713
|
return { definitions, references, imports };
|
|
10707
10714
|
}
|
|
10708
|
-
function cssSymbolUsages(graph, kind, name) {
|
|
10709
|
-
return graph.references.filter((item) => item.kind === kind && item.name === name);
|
|
10710
|
-
}
|
|
10711
10715
|
|
|
10712
10716
|
// eslint/rules/tailwind/css-ownership.ts
|
|
10713
10717
|
import path70 from "path";
|
|
@@ -11854,15 +11858,51 @@ var uniqueCssTokenValueRule = {
|
|
|
11854
11858
|
}
|
|
11855
11859
|
};
|
|
11856
11860
|
|
|
11857
|
-
// eslint/rules/tailwind/unused-
|
|
11861
|
+
// eslint/rules/tailwind/unused-css-definition.ts
|
|
11858
11862
|
import { statSync as statSync5 } from "fs";
|
|
11859
11863
|
import path79 from "path";
|
|
11860
|
-
|
|
11864
|
+
function isImplicitThemeToken(name) {
|
|
11865
|
+
return name === "--spacing" || name === "--radius" || name === "--font-sans" || name === "--font-mono" || name.startsWith("--breakpoint-") || name.startsWith("--default-");
|
|
11866
|
+
}
|
|
11867
|
+
function staticMention(content, name) {
|
|
11868
|
+
const pattern = new RegExp(`(?<![\\w-])${escapeRegExp(name)}(?![\\w-])`, "u");
|
|
11869
|
+
return pattern.test(content);
|
|
11870
|
+
}
|
|
11871
|
+
function isUnused(symbol, references, moduleContents) {
|
|
11872
|
+
if (symbol.kind === "utility") {
|
|
11873
|
+
return !references.some((reference) => reference.kind === "utility" && reference.name === symbol.name);
|
|
11874
|
+
}
|
|
11875
|
+
if (symbol.kind === "keyframes") {
|
|
11876
|
+
return !references.some((reference) => reference.kind === "keyframes" && reference.name === symbol.name);
|
|
11877
|
+
}
|
|
11878
|
+
if (symbol.kind !== "theme-token" || isImplicitThemeToken(symbol.name)) return false;
|
|
11879
|
+
const pairedText = /^(?<base>--text-[\w-]+)--(?:line-height|letter-spacing|font-weight)$/u.exec(symbol.name);
|
|
11880
|
+
if (pairedText && references.some((reference) => reference.kind === "theme-class" && reference.token === pairedText.groups?.base)) {
|
|
11881
|
+
return false;
|
|
11882
|
+
}
|
|
11883
|
+
if (references.some((reference) => reference.kind === "theme-class" && reference.token === symbol.name)) {
|
|
11884
|
+
return false;
|
|
11885
|
+
}
|
|
11886
|
+
if (references.some((reference) => reference.kind === "variable" && reference.name === symbol.name)) {
|
|
11887
|
+
return false;
|
|
11888
|
+
}
|
|
11889
|
+
return !moduleContents.some((content) => staticMention(content, symbol.name));
|
|
11890
|
+
}
|
|
11891
|
+
function unusedMessage(symbol) {
|
|
11892
|
+
if (symbol.kind === "utility") {
|
|
11893
|
+
return `Custom utility "${symbol.name}" is never referenced by project CSS or source.`;
|
|
11894
|
+
}
|
|
11895
|
+
if (symbol.kind === "keyframes") {
|
|
11896
|
+
return `@keyframes "${symbol.name}" is never referenced by project CSS or source.`;
|
|
11897
|
+
}
|
|
11898
|
+
return `Theme token "${symbol.name}" is never referenced by project CSS or source.`;
|
|
11899
|
+
}
|
|
11900
|
+
var unusedCssDefinitionRule = {
|
|
11861
11901
|
meta: {
|
|
11862
11902
|
schema: [],
|
|
11863
11903
|
type: "problem",
|
|
11864
11904
|
docs: {
|
|
11865
|
-
description: "
|
|
11905
|
+
description: "Report unused @utility, @keyframes and non-foundational @theme tokens across project CSS and modules."
|
|
11866
11906
|
}
|
|
11867
11907
|
},
|
|
11868
11908
|
create(context) {
|
|
@@ -11875,24 +11915,32 @@ var unusedUtilityRule = {
|
|
|
11875
11915
|
const current = path79.normalize(path79.resolve(context.filename));
|
|
11876
11916
|
const textOf = cachedTextReader();
|
|
11877
11917
|
const cssFiles = findFiles(sourceRoot, CSS_EXTENSIONS);
|
|
11878
|
-
const
|
|
11918
|
+
const moduleContents = findFiles(sourceRoot, MODULE_EXTENSIONS4).map((file) => ({
|
|
11919
|
+
path: file,
|
|
11920
|
+
content: textOf(file)
|
|
11921
|
+
}));
|
|
11879
11922
|
const graph = buildCssDependencyGraph({
|
|
11880
11923
|
sourceRoot,
|
|
11881
11924
|
css: cssFiles.map((file) => ({
|
|
11882
11925
|
path: file,
|
|
11883
11926
|
content: path79.normalize(file) === current ? context.sourceCode.text : textOf(file)
|
|
11884
11927
|
})),
|
|
11885
|
-
modules:
|
|
11928
|
+
modules: moduleContents
|
|
11886
11929
|
});
|
|
11930
|
+
const sourceTexts = moduleContents.map((module) => module.content);
|
|
11931
|
+
const unused = graph.definitions.filter(
|
|
11932
|
+
(symbol) => symbol.file === current && isUnused(symbol, graph.references, sourceTexts)
|
|
11933
|
+
);
|
|
11887
11934
|
return {
|
|
11888
11935
|
"StyleSheet:exit"(node) {
|
|
11889
|
-
for (const
|
|
11890
|
-
const name = preludeIdentifiers(utility)[0];
|
|
11891
|
-
if (!name) continue;
|
|
11892
|
-
if (cssSymbolUsages(graph, "utility", name).length > 0) continue;
|
|
11936
|
+
for (const symbol of unused) {
|
|
11893
11937
|
context.report({
|
|
11894
|
-
node
|
|
11895
|
-
|
|
11938
|
+
node,
|
|
11939
|
+
loc: {
|
|
11940
|
+
start: { line: symbol.line, column: 1 },
|
|
11941
|
+
end: { line: symbol.line, column: 2 }
|
|
11942
|
+
},
|
|
11943
|
+
message: unusedMessage(symbol)
|
|
11896
11944
|
});
|
|
11897
11945
|
}
|
|
11898
11946
|
}
|
|
@@ -12734,7 +12782,7 @@ var tailwindRules = {
|
|
|
12734
12782
|
"css-entry-point": cssEntryPointRule,
|
|
12735
12783
|
"feature-css-placement": featureCssPlacementRule,
|
|
12736
12784
|
"global-stylesheet": globalStylesheetRule,
|
|
12737
|
-
"unused-
|
|
12785
|
+
"unused-css-definition": unusedCssDefinitionRule,
|
|
12738
12786
|
"unique-css-definition": uniqueCssDefinitionRule,
|
|
12739
12787
|
"unique-css-token-value": uniqueCssTokenValueRule,
|
|
12740
12788
|
"no-utility-alias": noUtilityAliasRule
|
|
@@ -14142,6 +14190,7 @@ var tailwindImportGraph = {
|
|
|
14142
14190
|
languageOptions: { tolerant: true },
|
|
14143
14191
|
rules: {
|
|
14144
14192
|
"pasika/at-rule-spacing": "error",
|
|
14193
|
+
"pasika/unused-css-definition": "error",
|
|
14145
14194
|
"pasika/css-entry-point": "error",
|
|
14146
14195
|
"pasika/feature-css-placement": "error",
|
|
14147
14196
|
"pasika/unique-css-definition": "error",
|