pasika 0.3.3 → 0.3.4

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.
Files changed (188) hide show
  1. package/README.md +13 -17
  2. package/dist/cli/index.d.ts +0 -1
  3. package/dist/cli/index.js +4999 -103
  4. package/dist/eslint/pasika/index.d.ts +165 -53
  5. package/dist/eslint/pasika/index.js +4424 -89
  6. package/package.json +3 -3
  7. package/dist/cli/output.d.ts +0 -3
  8. package/dist/cli/output.js +0 -11
  9. package/dist/enforcement/coverage.d.ts +0 -55
  10. package/dist/enforcement/coverage.js +0 -239
  11. package/dist/enforcement/doctor.d.ts +0 -16
  12. package/dist/enforcement/doctor.js +0 -249
  13. package/dist/enforcement/normalize.d.ts +0 -11
  14. package/dist/enforcement/normalize.js +0 -21
  15. package/dist/enforcement/parse-docs.d.ts +0 -58
  16. package/dist/enforcement/parse-docs.js +0 -98
  17. package/dist/enforcement/types.d.ts +0 -54
  18. package/dist/enforcement/types.js +0 -50
  19. package/dist/eslint/pasika/ast-types.d.ts +0 -122
  20. package/dist/eslint/pasika/ast-types.js +0 -1
  21. package/dist/eslint/pasika/project/ccf.d.ts +0 -48
  22. package/dist/eslint/pasika/project/ccf.js +0 -119
  23. package/dist/eslint/pasika/project/index.d.ts +0 -21
  24. package/dist/eslint/pasika/project/index.js +0 -139
  25. package/dist/eslint/pasika/project/parse-module.d.ts +0 -27
  26. package/dist/eslint/pasika/project/parse-module.js +0 -128
  27. package/dist/eslint/pasika/rules/application-structure.d.ts +0 -2
  28. package/dist/eslint/pasika/rules/application-structure.js +0 -152
  29. package/dist/eslint/pasika/rules/component-conventions.d.ts +0 -16
  30. package/dist/eslint/pasika/rules/component-conventions.js +0 -145
  31. package/dist/eslint/pasika/rules/component-nesting.d.ts +0 -12
  32. package/dist/eslint/pasika/rules/component-nesting.js +0 -69
  33. package/dist/eslint/pasika/rules/component-placement.d.ts +0 -11
  34. package/dist/eslint/pasika/rules/component-placement.js +0 -75
  35. package/dist/eslint/pasika/rules/config-extraction.d.ts +0 -14
  36. package/dist/eslint/pasika/rules/config-extraction.js +0 -74
  37. package/dist/eslint/pasika/rules/cross-feature-import.d.ts +0 -2
  38. package/dist/eslint/pasika/rules/cross-feature-import.js +0 -75
  39. package/dist/eslint/pasika/rules/css/apply-usage.d.ts +0 -10
  40. package/dist/eslint/pasika/rules/css/apply-usage.js +0 -45
  41. package/dist/eslint/pasika/rules/css/base-layer-pair.d.ts +0 -10
  42. package/dist/eslint/pasika/rules/css/base-layer-pair.js +0 -49
  43. package/dist/eslint/pasika/rules/css/css-variable-naming.d.ts +0 -10
  44. package/dist/eslint/pasika/rules/css/css-variable-naming.js +0 -39
  45. package/dist/eslint/pasika/rules/css/custom-utility-apply.d.ts +0 -11
  46. package/dist/eslint/pasika/rules/css/custom-utility-apply.js +0 -52
  47. package/dist/eslint/pasika/rules/css/global-css-location.d.ts +0 -10
  48. package/dist/eslint/pasika/rules/css/global-css-location.js +0 -42
  49. package/dist/eslint/pasika/rules/css/helpers.d.ts +0 -29
  50. package/dist/eslint/pasika/rules/css/helpers.js +0 -93
  51. package/dist/eslint/pasika/rules/css/index.d.ts +0 -13
  52. package/dist/eslint/pasika/rules/css/index.js +0 -25
  53. package/dist/eslint/pasika/rules/css/root-variables.d.ts +0 -11
  54. package/dist/eslint/pasika/rules/css/root-variables.js +0 -53
  55. package/dist/eslint/pasika/rules/css/rule-tester.d.ts +0 -11
  56. package/dist/eslint/pasika/rules/css/rule-tester.js +0 -22
  57. package/dist/eslint/pasika/rules/css/stylesheet-ordering.d.ts +0 -11
  58. package/dist/eslint/pasika/rules/css/stylesheet-ordering.js +0 -76
  59. package/dist/eslint/pasika/rules/css/surface-utility.d.ts +0 -10
  60. package/dist/eslint/pasika/rules/css/surface-utility.js +0 -41
  61. package/dist/eslint/pasika/rules/css/theme-reset.d.ts +0 -9
  62. package/dist/eslint/pasika/rules/css/theme-reset.js +0 -36
  63. package/dist/eslint/pasika/rules/css/theme-variable-namespace.d.ts +0 -11
  64. package/dist/eslint/pasika/rules/css/theme-variable-namespace.js +0 -53
  65. package/dist/eslint/pasika/rules/cva-appearance-props.d.ts +0 -10
  66. package/dist/eslint/pasika/rules/cva-appearance-props.js +0 -77
  67. package/dist/eslint/pasika/rules/cva-boolean-variants.d.ts +0 -11
  68. package/dist/eslint/pasika/rules/cva-boolean-variants.js +0 -97
  69. package/dist/eslint/pasika/rules/data-testid-case.d.ts +0 -2
  70. package/dist/eslint/pasika/rules/data-testid-case.js +0 -76
  71. package/dist/eslint/pasika/rules/enforce-barrel-exports.d.ts +0 -9
  72. package/dist/eslint/pasika/rules/enforce-barrel-exports.js +0 -78
  73. package/dist/eslint/pasika/rules/enforce-cn-merge.d.ts +0 -21
  74. package/dist/eslint/pasika/rules/enforce-cn-merge.js +0 -86
  75. package/dist/eslint/pasika/rules/enforce-cva-variant-props.d.ts +0 -9
  76. package/dist/eslint/pasika/rules/enforce-cva-variant-props.js +0 -86
  77. package/dist/eslint/pasika/rules/filename-case.d.ts +0 -2
  78. package/dist/eslint/pasika/rules/filename-case.js +0 -123
  79. package/dist/eslint/pasika/rules/hook-complexity.d.ts +0 -12
  80. package/dist/eslint/pasika/rules/hook-complexity.js +0 -114
  81. package/dist/eslint/pasika/rules/hook-extraction.d.ts +0 -11
  82. package/dist/eslint/pasika/rules/hook-extraction.js +0 -55
  83. package/dist/eslint/pasika/rules/import-boundaries.d.ts +0 -2
  84. package/dist/eslint/pasika/rules/import-boundaries.js +0 -167
  85. package/dist/eslint/pasika/rules/import-through-index.d.ts +0 -2
  86. package/dist/eslint/pasika/rules/import-through-index.js +0 -52
  87. package/dist/eslint/pasika/rules/interactive-component.d.ts +0 -10
  88. package/dist/eslint/pasika/rules/interactive-component.js +0 -76
  89. package/dist/eslint/pasika/rules/json/index.d.ts +0 -5
  90. package/dist/eslint/pasika/rules/json/index.js +0 -9
  91. package/dist/eslint/pasika/rules/json/no-cache-flag.d.ts +0 -10
  92. package/dist/eslint/pasika/rules/json/no-cache-flag.js +0 -45
  93. package/dist/eslint/pasika/rules/json/no-vulyk-dependency.d.ts +0 -10
  94. package/dist/eslint/pasika/rules/json/no-vulyk-dependency.js +0 -41
  95. package/dist/eslint/pasika/rules/json/rule-tester.d.ts +0 -11
  96. package/dist/eslint/pasika/rules/json/rule-tester.js +0 -21
  97. package/dist/eslint/pasika/rules/jsx-hygiene.d.ts +0 -9
  98. package/dist/eslint/pasika/rules/jsx-hygiene.js +0 -108
  99. package/dist/eslint/pasika/rules/locale-dotted-path.d.ts +0 -10
  100. package/dist/eslint/pasika/rules/locale-dotted-path.js +0 -65
  101. package/dist/eslint/pasika/rules/locale-placement.d.ts +0 -13
  102. package/dist/eslint/pasika/rules/locale-placement.js +0 -163
  103. package/dist/eslint/pasika/rules/locales-location.d.ts +0 -11
  104. package/dist/eslint/pasika/rules/locales-location.js +0 -56
  105. package/dist/eslint/pasika/rules/md/doc-kind-suffix.d.ts +0 -5
  106. package/dist/eslint/pasika/rules/md/doc-kind-suffix.js +0 -29
  107. package/dist/eslint/pasika/rules/md/example-heading-description.d.ts +0 -5
  108. package/dist/eslint/pasika/rules/md/example-heading-description.js +0 -30
  109. package/dist/eslint/pasika/rules/md/glossary-term-linking.d.ts +0 -2
  110. package/dist/eslint/pasika/rules/md/glossary-term-linking.js +0 -99
  111. package/dist/eslint/pasika/rules/md/guide-folder-entry-point.d.ts +0 -2
  112. package/dist/eslint/pasika/rules/md/guide-folder-entry-point.js +0 -46
  113. package/dist/eslint/pasika/rules/md/guide-link-anchors.d.ts +0 -5
  114. package/dist/eslint/pasika/rules/md/guide-link-anchors.js +0 -50
  115. package/dist/eslint/pasika/rules/md/guide-overview-no-links.d.ts +0 -5
  116. package/dist/eslint/pasika/rules/md/guide-overview-no-links.js +0 -51
  117. package/dist/eslint/pasika/rules/md/guide-states-no-requirement.d.ts +0 -5
  118. package/dist/eslint/pasika/rules/md/guide-states-no-requirement.js +0 -26
  119. package/dist/eslint/pasika/rules/md/guide-step-single-link.d.ts +0 -5
  120. package/dist/eslint/pasika/rules/md/guide-step-single-link.js +0 -48
  121. package/dist/eslint/pasika/rules/md/guide-step-single-sentence.d.ts +0 -5
  122. package/dist/eslint/pasika/rules/md/guide-step-single-sentence.js +0 -42
  123. package/dist/eslint/pasika/rules/md/helpers.d.ts +0 -25
  124. package/dist/eslint/pasika/rules/md/helpers.js +0 -37
  125. package/dist/eslint/pasika/rules/md/index.d.ts +0 -27
  126. package/dist/eslint/pasika/rules/md/index.js +0 -53
  127. package/dist/eslint/pasika/rules/md/no-cross-document-link.d.ts +0 -5
  128. package/dist/eslint/pasika/rules/md/no-cross-document-link.js +0 -36
  129. package/dist/eslint/pasika/rules/md/no-nested-how-to.d.ts +0 -5
  130. package/dist/eslint/pasika/rules/md/no-nested-how-to.js +0 -39
  131. package/dist/eslint/pasika/rules/md/no-template-prompt.d.ts +0 -5
  132. package/dist/eslint/pasika/rules/md/no-template-prompt.js +0 -22
  133. package/dist/eslint/pasika/rules/md/overview-length.d.ts +0 -5
  134. package/dist/eslint/pasika/rules/md/overview-length.js +0 -47
  135. package/dist/eslint/pasika/rules/md/overview-present.d.ts +0 -5
  136. package/dist/eslint/pasika/rules/md/overview-present.js +0 -41
  137. package/dist/eslint/pasika/rules/md/policy-no-examples.d.ts +0 -5
  138. package/dist/eslint/pasika/rules/md/policy-no-examples.js +0 -28
  139. package/dist/eslint/pasika/rules/md/policy-single-document.d.ts +0 -5
  140. package/dist/eslint/pasika/rules/md/policy-single-document.js +0 -34
  141. package/dist/eslint/pasika/rules/md/policy-subject-headings.d.ts +0 -5
  142. package/dist/eslint/pasika/rules/md/policy-subject-headings.js +0 -58
  143. package/dist/eslint/pasika/rules/md/project-index.d.ts +0 -17
  144. package/dist/eslint/pasika/rules/md/project-index.js +0 -67
  145. package/dist/eslint/pasika/rules/md/reference-block-headings.d.ts +0 -6
  146. package/dist/eslint/pasika/rules/md/reference-block-headings.js +0 -31
  147. package/dist/eslint/pasika/rules/md/reference-no-rfc-vocabulary.d.ts +0 -6
  148. package/dist/eslint/pasika/rules/md/reference-no-rfc-vocabulary.js +0 -26
  149. package/dist/eslint/pasika/rules/md/requirement-present.d.ts +0 -5
  150. package/dist/eslint/pasika/rules/md/requirement-present.js +0 -41
  151. package/dist/eslint/pasika/rules/md/rfc-only-in-bullets.d.ts +0 -5
  152. package/dist/eslint/pasika/rules/md/rfc-only-in-bullets.js +0 -46
  153. package/dist/eslint/pasika/rules/md/rule-paired-examples.d.ts +0 -5
  154. package/dist/eslint/pasika/rules/md/rule-paired-examples.js +0 -36
  155. package/dist/eslint/pasika/rules/md/rule-tester.d.ts +0 -11
  156. package/dist/eslint/pasika/rules/md/rule-tester.js +0 -21
  157. package/dist/eslint/pasika/rules/md/support-document-placement.d.ts +0 -2
  158. package/dist/eslint/pasika/rules/md/support-document-placement.js +0 -36
  159. package/dist/eslint/pasika/rules/md/title-matches-file-name.d.ts +0 -2
  160. package/dist/eslint/pasika/rules/md/title-matches-file-name.js +0 -46
  161. package/dist/eslint/pasika/rules/named-exports.d.ts +0 -2
  162. package/dist/eslint/pasika/rules/named-exports.js +0 -49
  163. package/dist/eslint/pasika/rules/no-arbitrary-tailwind.d.ts +0 -9
  164. package/dist/eslint/pasika/rules/no-arbitrary-tailwind.js +0 -97
  165. package/dist/eslint/pasika/rules/no-eslint-disable.d.ts +0 -10
  166. package/dist/eslint/pasika/rules/no-eslint-disable.js +0 -33
  167. package/dist/eslint/pasika/rules/no-mixed-concerns.d.ts +0 -9
  168. package/dist/eslint/pasika/rules/no-mixed-concerns.js +0 -71
  169. package/dist/eslint/pasika/rules/no-util-barrel.d.ts +0 -2
  170. package/dist/eslint/pasika/rules/no-util-barrel.js +0 -48
  171. package/dist/eslint/pasika/rules/pure-function-extract.d.ts +0 -9
  172. package/dist/eslint/pasika/rules/pure-function-extract.js +0 -92
  173. package/dist/eslint/pasika/rules/shared-style-dedup.d.ts +0 -13
  174. package/dist/eslint/pasika/rules/shared-style-dedup.js +0 -91
  175. package/dist/eslint/pasika/rules/stay-flat.d.ts +0 -12
  176. package/dist/eslint/pasika/rules/stay-flat.js +0 -81
  177. package/dist/eslint/pasika/rules/support-file-placement.d.ts +0 -15
  178. package/dist/eslint/pasika/rules/support-file-placement.js +0 -70
  179. package/dist/eslint/pasika/rules/support-folder-shape.d.ts +0 -2
  180. package/dist/eslint/pasika/rules/support-folder-shape.js +0 -59
  181. package/dist/eslint/pasika/rules/type-extraction.d.ts +0 -13
  182. package/dist/eslint/pasika/rules/type-extraction.js +0 -85
  183. package/dist/eslint/pasika/rules/ui-state.d.ts +0 -9
  184. package/dist/eslint/pasika/rules/ui-state.js +0 -99
  185. package/dist/eslint/pasika/rules/util-file-name.d.ts +0 -2
  186. package/dist/eslint/pasika/rules/util-file-name.js +0 -48
  187. package/dist/eslint/pasika/rules/value-extraction.d.ts +0 -13
  188. package/dist/eslint/pasika/rules/value-extraction.js +0 -48
@@ -1,93 +0,0 @@
1
- /**
2
- * Shared AST walkers for the CSS rules.
3
- *
4
- * The @eslint/css language parses with css-tree in tolerant mode, so constructs
5
- * Tailwind v4 extends beyond the CSS grammar — `--*: initial`, arbitrary
6
- * properties inside `@apply`, nested `@media` inside `@theme` — survive as
7
- * `Raw` nodes instead of structured ones. Rules therefore walk the plain AST
8
- * and fall back to raw text when a construct came through unparsed.
9
- */
10
- /** Visits `node` and every descendant, in document order. */
11
- export function walkNodes(node, visit) {
12
- visit(node);
13
- if ("children" in node && node.children) {
14
- for (const child of node.children)
15
- walkNodes(child, visit);
16
- }
17
- if ("prelude" in node && node.prelude) {
18
- walkNodes(node.prelude, visit);
19
- }
20
- if ("block" in node && node.block) {
21
- walkNodes(node.block, visit);
22
- }
23
- }
24
- /** Every `Atrule` node in the sheet, in document order. */
25
- export function atrules(node) {
26
- const result = [];
27
- walkNodes(node, (current) => {
28
- if (current.type === "Atrule")
29
- result.push(current);
30
- });
31
- return result;
32
- }
33
- /** Every `Atrule` with the given name. */
34
- export function atrulesNamed(node, name) {
35
- return atrules(node).filter((candidate) => candidate.type === "Atrule" && candidate.name === name);
36
- }
37
- /** The children of a block-bearing node. */
38
- export function blockChildren(node) {
39
- if (!node)
40
- return [];
41
- if (!("block" in node) || !node.block)
42
- return [];
43
- return node.block.children;
44
- }
45
- /**
46
- * The names in an at-rule prelude: `Identifier`s (the classes of an `@apply`,
47
- * the `inline` of `@theme inline`) and `Layer`s (the layers of `@layer base`).
48
- */
49
- export function preludeIdentifiers(node) {
50
- if (!node)
51
- return [];
52
- if (!("prelude" in node) || !node.prelude)
53
- return [];
54
- const names = [];
55
- walkNodes(node.prelude, (current) => {
56
- if (current.type === "Identifier")
57
- names.push(current.name);
58
- if (current.type === "Layer")
59
- names.push(current.name);
60
- });
61
- return names;
62
- }
63
- /** The text of a `Raw` node, or the empty string. */
64
- export function rawValue(node) {
65
- if (!node)
66
- return "";
67
- if (node.type === "Raw")
68
- return node.value;
69
- return "";
70
- }
71
- /** Every `Rule` node in the sheet, in document order. */
72
- export function rules(node) {
73
- const result = [];
74
- walkNodes(node, (current) => {
75
- if (current.type === "Rule")
76
- result.push(current);
77
- });
78
- return result;
79
- }
80
- /** The selector names of a rule's prelude, e.g. `root` for `:root`. */
81
- export function selectorNames(node) {
82
- if (!node)
83
- return [];
84
- if (!("prelude" in node) || !node.prelude)
85
- return [];
86
- const names = [];
87
- walkNodes(node.prelude, (current) => {
88
- if (current.type === "PseudoClassSelector" || current.type === "TypeSelector" || current.type === "ClassSelector") {
89
- names.push(current.name);
90
- }
91
- });
92
- return names;
93
- }
@@ -1,13 +0,0 @@
1
- export declare const cssRules: {
2
- "theme-reset": import("@eslint/css").CSSRuleDefinition;
3
- "root-variables": import("@eslint/css").CSSRuleDefinition;
4
- "apply-usage": import("@eslint/css").CSSRuleDefinition;
5
- "base-layer-pair": import("@eslint/css").CSSRuleDefinition;
6
- "stylesheet-ordering": import("@eslint/css").CSSRuleDefinition;
7
- "css-variable-naming": import("@eslint/css").CSSRuleDefinition;
8
- "custom-utility-apply": import("@eslint/css").CSSRuleDefinition;
9
- "surface-utility": import("@eslint/css").CSSRuleDefinition;
10
- "theme-variable-namespace": import("@eslint/css").CSSRuleDefinition;
11
- "global-css-location": import("@eslint/css").CSSRuleDefinition;
12
- };
13
- export type CssRuleName = keyof typeof cssRules;
@@ -1,25 +0,0 @@
1
- /**
2
- * All CSS rules for the global stylesheet checks.
3
- */
4
- import { themeResetRule } from "./theme-reset.js";
5
- import { rootVariablesRule } from "./root-variables.js";
6
- import { applyUsageRule } from "./apply-usage.js";
7
- import { baseLayerPairRule } from "./base-layer-pair.js";
8
- import { stylesheetOrderingRule } from "./stylesheet-ordering.js";
9
- import { cssVariableNamingRule } from "./css-variable-naming.js";
10
- import { customUtilityApplyRule } from "./custom-utility-apply.js";
11
- import { surfaceUtilityRule } from "./surface-utility.js";
12
- import { themeVariableNamespaceRule } from "./theme-variable-namespace.js";
13
- import { globalCssLocationRule } from "./global-css-location.js";
14
- export const cssRules = {
15
- "theme-reset": themeResetRule,
16
- "root-variables": rootVariablesRule,
17
- "apply-usage": applyUsageRule,
18
- "base-layer-pair": baseLayerPairRule,
19
- "stylesheet-ordering": stylesheetOrderingRule,
20
- "css-variable-naming": cssVariableNamingRule,
21
- "custom-utility-apply": customUtilityApplyRule,
22
- "surface-utility": surfaceUtilityRule,
23
- "theme-variable-namespace": themeVariableNamespaceRule,
24
- "global-css-location": globalCssLocationRule,
25
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/root-variables
3
- *
4
- * Every value used for the project's styling MUST be defined as a CSS variable
5
- * in :root, and a Tailwind theme variable MUST reference that CSS variable
6
- * through @theme inline.
7
- *
8
- * @see docs/styling-guide/rules/global-stylesheet-rule.md
9
- */
10
- import type { CSSRuleDefinition } from "@eslint/css";
11
- export declare const rootVariablesRule: CSSRuleDefinition;
@@ -1,53 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/root-variables
3
- *
4
- * Every value used for the project's styling MUST be defined as a CSS variable
5
- * in :root, and a Tailwind theme variable MUST reference that CSS variable
6
- * through @theme inline.
7
- *
8
- * @see docs/styling-guide/rules/global-stylesheet-rule.md
9
- */
10
- import { atrulesNamed, blockChildren, preludeIdentifiers, rules, selectorNames } from "./helpers.js";
11
- export const rootVariablesRule = {
12
- meta: {
13
- schema: [],
14
- type: "problem",
15
- docs: {
16
- description: "Require styling values to be CSS variables in :root referenced through @theme inline.",
17
- },
18
- },
19
- create(context) {
20
- return {
21
- "StyleSheet:exit"(node) {
22
- const hasRootVars = rules(node).some((rule) => {
23
- if (!selectorNames(rule).includes("root"))
24
- return false;
25
- return blockChildren(rule).some((child) => child.type === "Declaration");
26
- });
27
- if (!hasRootVars) {
28
- context.report({
29
- node,
30
- message: "Styling values must be defined as CSS variables in a :root block.",
31
- });
32
- }
33
- // A Tailwind theme variable that references a CSS variable must go
34
- // through @theme inline; a bare @theme block would generate values
35
- // instead of referencing the :root variables.
36
- const referencingThemes = atrulesNamed(node, "theme").filter((theme) => blockChildren(theme).some((child) => {
37
- if (child.type === "Raw")
38
- return child.value.includes("var(");
39
- if (child.type === "Declaration")
40
- return JSON.stringify(child.value).includes("var(");
41
- return false;
42
- }));
43
- const inlineThemes = atrulesNamed(node, "theme").filter((theme) => preludeIdentifiers(theme).includes("inline"));
44
- if (referencingThemes.length > 0 && inlineThemes.length === 0) {
45
- context.report({
46
- node,
47
- message: "Tailwind theme variables that reference CSS variables must use @theme inline.",
48
- });
49
- }
50
- },
51
- };
52
- },
53
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * Shared RuleTester wiring for the CSS rule tests.
3
- *
4
- * Each `describe` title in a rule test is the exact text of the requirement the
5
- * case pins, which is how `pasika coverage` verifies that a requirement recorded
6
- * as lint-enforced has a test behind it.
7
- */
8
- import { describe } from "node:test";
9
- import { RuleTester } from "eslint";
10
- export declare const cssRuleTester: RuleTester;
11
- export { describe };
@@ -1,22 +0,0 @@
1
- /**
2
- * Shared RuleTester wiring for the CSS rule tests.
3
- *
4
- * Each `describe` title in a rule test is the exact text of the requirement the
5
- * case pins, which is how `pasika coverage` verifies that a requirement recorded
6
- * as lint-enforced has a test behind it.
7
- */
8
- import { describe, it } from "node:test";
9
- import { RuleTester } from "eslint";
10
- import css from "@eslint/css";
11
- import { cssRules } from "../../index.js";
12
- RuleTester.describe = describe;
13
- RuleTester.it = it;
14
- export const cssRuleTester = new RuleTester({
15
- language: "css/css",
16
- languageOptions: { tolerant: true },
17
- plugins: {
18
- css,
19
- pasika: { rules: cssRules },
20
- },
21
- });
22
- export { describe };
@@ -1,11 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/stylesheet-ordering
3
- *
4
- * The global stylesheet MUST order imports, @custom-variant definitions, :root
5
- * variables and the selectors that override them, @theme definitions, custom
6
- * utilities, base styles, and keyframes in that order.
7
- *
8
- * @see docs/styling-guide/rules/global-stylesheet-rule.md
9
- */
10
- import type { CSSRuleDefinition } from "@eslint/css";
11
- export declare const stylesheetOrderingRule: CSSRuleDefinition;
@@ -1,76 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/stylesheet-ordering
3
- *
4
- * The global stylesheet MUST order imports, @custom-variant definitions, :root
5
- * variables and the selectors that override them, @theme definitions, custom
6
- * utilities, base styles, and keyframes in that order.
7
- *
8
- * @see docs/styling-guide/rules/global-stylesheet-rule.md
9
- */
10
- import { preludeIdentifiers, selectorNames } from "./helpers.js";
11
- const SECTION_ORDER = ["imports", "custom-variant", "root", "theme", "utility", "base styles", "keyframes"];
12
- export const stylesheetOrderingRule = {
13
- meta: {
14
- schema: [],
15
- type: "problem",
16
- docs: {
17
- description: "Require the global stylesheet sections in the documented order.",
18
- },
19
- },
20
- create(context) {
21
- return {
22
- "StyleSheet:exit"(node) {
23
- // Map each top-level child to its section name.
24
- const sections = [];
25
- let index = 0;
26
- for (const child of node.children) {
27
- if (child.type === "Atrule" && child.name === "import") {
28
- sections.push({ name: "imports", at: index });
29
- }
30
- else if (child.type === "Atrule" && child.name === "custom-variant") {
31
- sections.push({ name: "custom-variant", at: index });
32
- }
33
- else if (child.type === "Atrule" && child.name === "theme") {
34
- sections.push({ name: "theme", at: index });
35
- }
36
- else if (child.type === "Atrule" && child.name === "utility") {
37
- sections.push({ name: "utility", at: index });
38
- }
39
- else if (child.type === "Atrule" && child.name === "keyframes") {
40
- sections.push({ name: "keyframes", at: index });
41
- }
42
- else if (child.type === "Atrule" && child.name === "layer") {
43
- if (preludeIdentifiers(child).includes("base")) {
44
- sections.push({ name: "base styles", at: index });
45
- }
46
- }
47
- else if (child.type === "Rule" && selectorNames(child).includes("root")) {
48
- sections.push({ name: "root", at: index });
49
- }
50
- index += 1;
51
- }
52
- // The first occurrence of each section must not appear after a later
53
- // section has already started.
54
- const firstAt = new Map();
55
- for (const section of sections) {
56
- if (!firstAt.has(section.name))
57
- firstAt.set(section.name, section.at ?? 0);
58
- }
59
- let lastSeen = -1;
60
- for (const name of SECTION_ORDER) {
61
- const at = firstAt.get(name);
62
- if (at === undefined)
63
- continue;
64
- if (at < lastSeen) {
65
- context.report({
66
- node,
67
- message: `Global stylesheet sections must be ordered: imports, @custom-variant, :root, @theme, custom utilities, base styles, keyframes. Found "${name}" before an earlier section.`,
68
- });
69
- return;
70
- }
71
- lastSeen = at;
72
- }
73
- },
74
- };
75
- },
76
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/surface-utility
3
- *
4
- * A repeated combination of canvas, ink, and related styles MUST become a
5
- * *-surface custom Tailwind utility that owns the combination.
6
- *
7
- * @see docs/styling-guide/rules/theme-and-utility-definition-rule.md
8
- */
9
- import type { CSSRuleDefinition } from "@eslint/css";
10
- export declare const surfaceUtilityRule: CSSRuleDefinition;
@@ -1,41 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/surface-utility
3
- *
4
- * A repeated combination of canvas, ink, and related styles MUST become a
5
- * *-surface custom Tailwind utility that owns the combination.
6
- *
7
- * @see docs/styling-guide/rules/theme-and-utility-definition-rule.md
8
- */
9
- import { atrulesNamed, preludeIdentifiers } from "./helpers.js";
10
- export const surfaceUtilityRule = {
11
- meta: {
12
- schema: [],
13
- type: "problem",
14
- docs: {
15
- description: "Require repeated canvas+ink combinations to become a *-surface utility.",
16
- },
17
- },
18
- create(context) {
19
- return {
20
- "StyleSheet:exit"(node) {
21
- const combinations = new Map();
22
- for (const apply of atrulesNamed(node, "apply")) {
23
- const classes = preludeIdentifiers(apply);
24
- if (!classes.some((name) => name.includes("canvas")) || !classes.some((name) => name.includes("ink"))) {
25
- continue;
26
- }
27
- const key = [...classes].sort().join(" ");
28
- combinations.set(key, (combinations.get(key) ?? 0) + 1);
29
- }
30
- for (const [combo, count] of combinations) {
31
- if (count < 2)
32
- continue;
33
- context.report({
34
- node,
35
- message: `Combination "${combo}" appears ${String(count)} times. Create a *-surface custom Tailwind utility for it.`,
36
- });
37
- }
38
- },
39
- };
40
- },
41
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/theme-reset
3
- *
4
- * The global stylesheet MUST reset Tailwind's default theme with `--*: initial`.
5
- *
6
- * @see docs/styling-guide/rules/global-stylesheet-rule.md
7
- */
8
- import type { CSSRuleDefinition } from "@eslint/css";
9
- export declare const themeResetRule: CSSRuleDefinition;
@@ -1,36 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/theme-reset
3
- *
4
- * The global stylesheet MUST reset Tailwind's default theme with `--*: initial`.
5
- *
6
- * @see docs/styling-guide/rules/global-stylesheet-rule.md
7
- */
8
- import { atrulesNamed, blockChildren } from "./helpers.js";
9
- export const themeResetRule = {
10
- meta: {
11
- schema: [],
12
- type: "problem",
13
- docs: {
14
- description: "Require Tailwind's default theme reset --*: initial.",
15
- },
16
- },
17
- create(context) {
18
- return {
19
- "StyleSheet:exit"(node) {
20
- const resetFound = atrulesNamed(node, "theme").some((theme) => blockChildren(theme).some((child) => {
21
- if (child.type === "Declaration")
22
- return child.property.startsWith("--*");
23
- if (child.type === "Raw")
24
- return child.value.includes("--*: initial");
25
- return false;
26
- }));
27
- if (!resetFound) {
28
- context.report({
29
- node,
30
- message: "The global stylesheet must reset Tailwind's default theme with --*: initial inside an @theme block.",
31
- });
32
- }
33
- },
34
- };
35
- },
36
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/theme-variable-namespace
3
- *
4
- * A value that needs at least two utility classes from the same Tailwind
5
- * theme-variable namespace MUST use that namespace and have the same name in
6
- * :root.
7
- *
8
- * @see docs/styling-guide/rules/theme-and-utility-definition-rule.md
9
- */
10
- import type { CSSRuleDefinition } from "@eslint/css";
11
- export declare const themeVariableNamespaceRule: CSSRuleDefinition;
@@ -1,53 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/theme-variable-namespace
3
- *
4
- * A value that needs at least two utility classes from the same Tailwind
5
- * theme-variable namespace MUST use that namespace and have the same name in
6
- * :root.
7
- *
8
- * @see docs/styling-guide/rules/theme-and-utility-definition-rule.md
9
- */
10
- import { atrulesNamed, blockChildren, preludeIdentifiers } from "./helpers.js";
11
- export const themeVariableNamespaceRule = {
12
- meta: {
13
- schema: [],
14
- type: "problem",
15
- docs: {
16
- description: "Require utility classes from the same theme namespace to share a prefix.",
17
- },
18
- },
19
- create(context) {
20
- return {
21
- "StyleSheet:exit"(node) {
22
- // Namespaces are the first segment of each theme variable name, e.g.
23
- // --color-* defines the `color` namespace.
24
- const namespaces = new Set();
25
- for (const theme of atrulesNamed(node, "theme")) {
26
- for (const child of blockChildren(theme)) {
27
- if (child.type !== "Declaration")
28
- continue;
29
- const segments = child.property.replace(/^--/, "").split("-");
30
- if (segments[0])
31
- namespaces.add(segments[0]);
32
- }
33
- }
34
- for (const apply of atrulesNamed(node, "apply")) {
35
- const classes = preludeIdentifiers(apply);
36
- for (const ns of namespaces) {
37
- const matching = classes.filter((name) => name.startsWith(`${ns}-`) || name === ns);
38
- if (matching.length < 2)
39
- continue;
40
- // All classes from one namespace must share a deeper prefix.
41
- const prefixes = matching.map((name) => name.split("-").slice(0, 2).join("-"));
42
- if (new Set(prefixes).size > 1) {
43
- context.report({
44
- node: apply,
45
- message: `Utility classes ${matching.join(", ")} use namespace "${ns}" but lack a shared prefix; use the theme-variable namespace prefix.`,
46
- });
47
- }
48
- }
49
- }
50
- },
51
- };
52
- },
53
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/cva-appearance-props
3
- *
4
- * Enforces that components exposing visual option props (size, variant, etc.)
5
- * define them via a cva() call rather than raw union types.
6
- *
7
- * @see docs/styling-guide/rules/component-variant-rule.md
8
- */
9
- import type { Rule } from "eslint";
10
- export declare const cvaAppearancePropsRule: Rule.RuleModule;
@@ -1,77 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/cva-appearance-props
3
- *
4
- * Enforces that components exposing visual option props (size, variant, etc.)
5
- * define them via a cva() call rather than raw union types.
6
- *
7
- * @see docs/styling-guide/rules/component-variant-rule.md
8
- */
9
- const VISUAL_OPTION_NAMES = new Set([
10
- "size",
11
- "variant",
12
- "tone",
13
- "color",
14
- "appearance",
15
- "intent",
16
- "style",
17
- "scheme",
18
- "theme",
19
- ]);
20
- function hasCvaCall(body) {
21
- for (const stmt of body) {
22
- if (stmt.type !== "VariableDeclaration")
23
- continue;
24
- for (const decl of stmt.declarations) {
25
- const init = decl.init;
26
- if (init?.type === "CallExpression" && init.callee.type === "Identifier" && init.callee.name === "cva") {
27
- return true;
28
- }
29
- }
30
- }
31
- return false;
32
- }
33
- export const cvaAppearancePropsRule = {
34
- meta: {
35
- schema: [],
36
- type: "problem",
37
- docs: {
38
- description: "Components with visual option props must define them using cva.",
39
- },
40
- },
41
- create(context) {
42
- const program = context.sourceCode.ast;
43
- const hasCva = hasCvaCall(program.body);
44
- // If cva is used anywhere in the file, all visual option props are assumed
45
- // to be handled by that definition. This avoids false positives when the
46
- // cva call and the component are in different scopes.
47
- if (hasCva)
48
- return {};
49
- return {
50
- TSTypeAliasDeclaration(node) {
51
- if (node.id?.type !== "Identifier" || !node.id.name?.endsWith("Props"))
52
- return;
53
- if (node.typeAnnotation?.type !== "TSTypeLiteral")
54
- return;
55
- for (const member of node.typeAnnotation.members ?? []) {
56
- if (member.type !== "TSPropertySignature")
57
- continue;
58
- const keyName = member.key?.type === "Identifier" ? member.key.name : undefined;
59
- if (!keyName || !VISUAL_OPTION_NAMES.has(keyName))
60
- continue;
61
- // Only flag union types (string literal unions like "sm" | "lg")
62
- const typeAnnotation = member.typeAnnotation?.typeAnnotation ?? member.typeAnnotation;
63
- if (!typeAnnotation)
64
- continue;
65
- // Accept both TSUnionType and TSTypeLiteral
66
- if (typeAnnotation.type === "TSUnionType" || typeAnnotation.type === "TSTypeLiteral") {
67
- context.report({
68
- node,
69
- message: `Visual option prop "${keyName}" must be defined through a cva() call ` +
70
- "rather than a manual union type. See docs/styling-guide/rules/component-variant-rule.md",
71
- });
72
- }
73
- }
74
- },
75
- };
76
- },
77
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/cva-boolean-variants
3
- *
4
- * Enforces correct placement of boolean appearance props:
5
- * - If a boolean variant appears in both CVA and cn(), report it —
6
- * it belongs in exactly one place.
7
- *
8
- * @see docs/styling-guide/rules/component-variant-rule.md
9
- */
10
- import type { Rule } from "eslint";
11
- export declare const cvaBooleanVariantsRule: Rule.RuleModule;