pasika 0.3.2 → 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 (189) hide show
  1. package/README.md +72 -20
  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 +5 -6
  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 -51
  10. package/dist/enforcement/coverage.js +0 -206
  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 -94
  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
  189. package/enforcement/registry.json +0 -1145
@@ -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;
@@ -1,97 +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
- function extractCvaInfo(node) {
11
- if (node.callee.type !== "Identifier" || node.callee.name !== "cva") {
12
- return undefined;
13
- }
14
- const variantNames = new Set();
15
- const compoundVariants = new Set();
16
- const options = node.arguments[1];
17
- if (options?.type !== "ObjectExpression")
18
- return { variantNames, compoundVariants };
19
- for (const prop of options.properties) {
20
- if (prop.type !== "Property")
21
- continue;
22
- const keyName = prop.key.type === "Identifier" ? prop.key.name : undefined;
23
- if (keyName === "variants" && prop.value.type === "ObjectExpression") {
24
- for (const vProp of prop.value.properties) {
25
- if (vProp.type !== "Property")
26
- continue;
27
- const vName = vProp.key.type === "Identifier" ? vProp.key.name : undefined;
28
- if (vName)
29
- variantNames.add(vName);
30
- }
31
- }
32
- if (keyName === "compoundVariants" && prop.value.type === "ArrayExpression") {
33
- for (const entry of prop.value.elements) {
34
- if (entry?.type !== "ObjectExpression")
35
- continue;
36
- for (const cvProp of entry.properties) {
37
- if (cvProp.type !== "Property")
38
- continue;
39
- const cvName = cvProp.key.type === "Identifier" ? cvProp.key.name : undefined;
40
- if (cvName && variantNames.has(cvName)) {
41
- compoundVariants.add(cvName);
42
- }
43
- }
44
- }
45
- }
46
- }
47
- return { variantNames, compoundVariants };
48
- }
49
- export const cvaBooleanVariantsRule = {
50
- meta: {
51
- schema: [],
52
- type: "problem",
53
- docs: {
54
- description: "Enforce correct boolean variant placement between CVA and cn().",
55
- },
56
- },
57
- create(context) {
58
- const cvaInfos = [];
59
- return {
60
- // Collect all cva() calls in the file
61
- CallExpression(node) {
62
- const info = extractCvaInfo(node);
63
- if (info)
64
- cvaInfos.push(info);
65
- },
66
- // Detect boolean && "class" patterns anywhere inside a className attribute
67
- "JSXAttribute[name.name='className'] LogicalExpression[operator='&&']"(node) {
68
- if (cvaInfos.length === 0)
69
- return;
70
- if (node.type !== "LogicalExpression")
71
- return;
72
- const left = node.left;
73
- const right = node.right;
74
- // Right side should be a string literal (class name)
75
- if (right.type !== "Literal" || typeof right.value !== "string") {
76
- return;
77
- }
78
- // Left side should be an identifier (boolean prop)
79
- if (left.type !== "Identifier")
80
- return;
81
- const propName = left.name;
82
- // Check if this prop is also a CVA variant
83
- for (const info of cvaInfos) {
84
- if (info.variantNames.has(propName)) {
85
- context.report({
86
- node,
87
- message: `Boolean prop "${propName}" is used as a standalone conditional in cn() ` +
88
- "but is also defined as a CVA variant. Move it to one place: " +
89
- "either CVA (with both true/false treatments) or cn() (standalone). " +
90
- "See docs/styling-guide/rules/component-variant-rule.md",
91
- });
92
- }
93
- }
94
- },
95
- };
96
- },
97
- };
@@ -1,2 +0,0 @@
1
- import type { Rule } from "eslint";
2
- export declare const dataTestIdCaseRule: Rule.RuleModule;
@@ -1,76 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/data-testid-case
3
- *
4
- * Enforces data-testid casing for components whose rendered result has one
5
- * statically identifiable intrinsic root. Components with multiple or dynamic
6
- * roots are intentionally left alone, matching the documented exemption.
7
- *
8
- * @see docs/code-organization-guide/rules/smart-vs-dumb-component-rule.md
9
- */
10
- import path from "node:path";
11
- import { findSimpleRoot, getTestId, parseComponentInfo } from "./component-conventions.js";
12
- const NEXT_ROUTING_FILES = new Set([
13
- "page",
14
- "layout",
15
- "loading",
16
- "error",
17
- "not-found",
18
- "route",
19
- "template",
20
- "default",
21
- "middleware",
22
- "instrumentation",
23
- ]);
24
- const isPascalCase = (value) => /^[A-Z][A-Za-z0-9]*$/.test(value);
25
- const isKebabCase = (value) => /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value);
26
- export const dataTestIdCaseRule = {
27
- meta: {
28
- schema: [],
29
- type: "problem",
30
- docs: {
31
- description: "Enforce data-testid casing for smart and dumb components with a single intrinsic root.",
32
- },
33
- },
34
- create(context) {
35
- const filename = path.resolve(context.filename);
36
- if (!filename.endsWith(".tsx"))
37
- return {};
38
- const base = path.basename(filename, path.extname(filename));
39
- if (NEXT_ROUTING_FILES.has(base))
40
- return {};
41
- const text = context.sourceCode.text;
42
- const components = parseComponentInfo(text, filename);
43
- return {
44
- Program(node) {
45
- for (const component of components) {
46
- const root = findSimpleRoot(component, text, filename);
47
- if (!root)
48
- continue;
49
- const { value } = getTestId(root);
50
- const expected = component.smart ? component.name : toKebabCase(component.name);
51
- if (component.smart && value === undefined) {
52
- context.report({
53
- node,
54
- message: `Smart component "${component.name}" with one outer DOM element must set data-testid="${expected}".`,
55
- });
56
- continue;
57
- }
58
- if (value === undefined || value === expected)
59
- continue;
60
- if (component.smart ? !isPascalCase(value) || value !== expected : !isKebabCase(value)) {
61
- context.report({
62
- node,
63
- message: `data-testid for ${component.smart ? "smart" : "dumb"} component "${component.name}" must be ${component.smart ? "PascalCase" : "kebab-case"}: expected "${expected}".`,
64
- });
65
- }
66
- }
67
- },
68
- };
69
- },
70
- };
71
- function toKebabCase(value) {
72
- return value
73
- .replace(/(?<lower>[a-z0-9])(?<upper>[A-Z])/g, "$<lower>-$<upper>")
74
- .replace(/(?<first>[A-Z])(?<rest>[A-Z][a-z])/g, "$<first>-$<rest>")
75
- .toLowerCase();
76
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * ESLint rule: pasika/enforce-barrel-exports
3
- *
4
- * Enforces the "Folder Nesting Rule" — index.ts only re-exports parent component.
5
- *
6
- * @see docs/code-organization-guide/rules/folder-nesting-rule.md
7
- */
8
- import type { Rule } from "eslint";
9
- export declare const enforceBarrelExportsRule: Rule.RuleModule;