@trackunit/eslint-plugin-trackunit 0.0.2

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 (147) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +117 -0
  3. package/package.json +31 -0
  4. package/src/index.d.ts +8 -0
  5. package/src/index.js +20 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/config/fragments/ignores.d.ts +2 -0
  8. package/src/lib/config/fragments/ignores.js +18 -0
  9. package/src/lib/config/fragments/ignores.js.map +1 -0
  10. package/src/lib/config/fragments/import-rules.d.ts +3 -0
  11. package/src/lib/config/fragments/import-rules.js +58 -0
  12. package/src/lib/config/fragments/import-rules.js.map +1 -0
  13. package/src/lib/config/fragments/jest-overrides.d.ts +2 -0
  14. package/src/lib/config/fragments/jest-overrides.js +30 -0
  15. package/src/lib/config/fragments/jest-overrides.js.map +1 -0
  16. package/src/lib/config/fragments/jsdoc-rules.d.ts +3 -0
  17. package/src/lib/config/fragments/jsdoc-rules.js +71 -0
  18. package/src/lib/config/fragments/jsdoc-rules.js.map +1 -0
  19. package/src/lib/config/fragments/module-boundaries.d.ts +2 -0
  20. package/src/lib/config/fragments/module-boundaries.js +92 -0
  21. package/src/lib/config/fragments/module-boundaries.js.map +1 -0
  22. package/src/lib/config/fragments/react-rules.d.ts +5 -0
  23. package/src/lib/config/fragments/react-rules.js +137 -0
  24. package/src/lib/config/fragments/react-rules.js.map +1 -0
  25. package/src/lib/config/fragments/restricted-imports.d.ts +2 -0
  26. package/src/lib/config/fragments/restricted-imports.js +58 -0
  27. package/src/lib/config/fragments/restricted-imports.js.map +1 -0
  28. package/src/lib/config/fragments/testing-library.d.ts +2 -0
  29. package/src/lib/config/fragments/testing-library.js +7 -0
  30. package/src/lib/config/fragments/testing-library.js.map +1 -0
  31. package/src/lib/config/fragments/typescript-rules.d.ts +2 -0
  32. package/src/lib/config/fragments/typescript-rules.js +97 -0
  33. package/src/lib/config/fragments/typescript-rules.js.map +1 -0
  34. package/src/lib/config/index.d.ts +863 -0
  35. package/src/lib/config/index.js +10 -0
  36. package/src/lib/config/index.js.map +1 -0
  37. package/src/lib/config/plugins.d.ts +90 -0
  38. package/src/lib/config/plugins.js +44 -0
  39. package/src/lib/config/plugins.js.map +1 -0
  40. package/src/lib/config/presets/base.d.ts +265 -0
  41. package/src/lib/config/presets/base.js +145 -0
  42. package/src/lib/config/presets/base.js.map +1 -0
  43. package/src/lib/config/presets/e2e.d.ts +10 -0
  44. package/src/lib/config/presets/e2e.js +19 -0
  45. package/src/lib/config/presets/e2e.js.map +1 -0
  46. package/src/lib/config/presets/public-api.d.ts +147 -0
  47. package/src/lib/config/presets/public-api.js +62 -0
  48. package/src/lib/config/presets/public-api.js.map +1 -0
  49. package/src/lib/config/presets/react.d.ts +598 -0
  50. package/src/lib/config/presets/react.js +97 -0
  51. package/src/lib/config/presets/react.js.map +1 -0
  52. package/src/lib/config/presets/server.d.ts +36 -0
  53. package/src/lib/config/presets/server.js +37 -0
  54. package/src/lib/config/presets/server.js.map +1 -0
  55. package/src/lib/config/utils.d.ts +6 -0
  56. package/src/lib/config/utils.js +28 -0
  57. package/src/lib/config/utils.js.map +1 -0
  58. package/src/lib/config-helpers/create-skip-when.d.ts +35 -0
  59. package/src/lib/config-helpers/create-skip-when.js +54 -0
  60. package/src/lib/config-helpers/create-skip-when.js.map +1 -0
  61. package/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.d.ts +16 -0
  62. package/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.js +83 -0
  63. package/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.js.map +1 -0
  64. package/src/lib/rules/design-guideline-button-icon-size-match/design-guideline-button-icon-size-match.d.ts +4 -0
  65. package/src/lib/rules/design-guideline-button-icon-size-match/design-guideline-button-icon-size-match.js +297 -0
  66. package/src/lib/rules/design-guideline-button-icon-size-match/design-guideline-button-icon-size-match.js.map +1 -0
  67. package/src/lib/rules/no-internal-barrel-files/examples.d.ts +80 -0
  68. package/src/lib/rules/no-internal-barrel-files/examples.js +84 -0
  69. package/src/lib/rules/no-internal-barrel-files/examples.js.map +1 -0
  70. package/src/lib/rules/no-internal-barrel-files/no-internal-barrel-files.d.ts +29 -0
  71. package/src/lib/rules/no-internal-barrel-files/no-internal-barrel-files.js +178 -0
  72. package/src/lib/rules/no-internal-barrel-files/no-internal-barrel-files.js.map +1 -0
  73. package/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.d.ts +5 -0
  74. package/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.js +67 -0
  75. package/src/lib/rules/no-internal-graphql-when-tagged-with-gql-public/no-internal-graphql-when-tagged-with-gql-public.js.map +1 -0
  76. package/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.d.ts +2 -0
  77. package/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.js +34 -0
  78. package/src/lib/rules/no-jest-mock-trackunit-react-core-hooks/no-jest-mock-trackunit-react-core-hooks.js.map +1 -0
  79. package/src/lib/rules/no-template-strings-in-classname-prop/no-template-strings-in-classname-prop.d.ts +16 -0
  80. package/src/lib/rules/no-template-strings-in-classname-prop/no-template-strings-in-classname-prop.js +55 -0
  81. package/src/lib/rules/no-template-strings-in-classname-prop/no-template-strings-in-classname-prop.js.map +1 -0
  82. package/src/lib/rules/no-typescript-assertion/examples.d.ts +1 -0
  83. package/src/lib/rules/no-typescript-assertion/examples.js +45 -0
  84. package/src/lib/rules/no-typescript-assertion/examples.js.map +1 -0
  85. package/src/lib/rules/no-typescript-assertion/no-typescript-assertion.d.ts +20 -0
  86. package/src/lib/rules/no-typescript-assertion/no-typescript-assertion.js +83 -0
  87. package/src/lib/rules/no-typescript-assertion/no-typescript-assertion.js.map +1 -0
  88. package/src/lib/rules/prefer-destructured-imports/prefer-destructured-imports.d.ts +73 -0
  89. package/src/lib/rules/prefer-destructured-imports/prefer-destructured-imports.js +333 -0
  90. package/src/lib/rules/prefer-destructured-imports/prefer-destructured-imports.js.map +1 -0
  91. package/src/lib/rules/prefer-event-specific-callback-naming/name-suggestion-strategies.d.ts +56 -0
  92. package/src/lib/rules/prefer-event-specific-callback-naming/name-suggestion-strategies.js +225 -0
  93. package/src/lib/rules/prefer-event-specific-callback-naming/name-suggestion-strategies.js.map +1 -0
  94. package/src/lib/rules/prefer-event-specific-callback-naming/prefer-event-specific-callback-naming.d.ts +49 -0
  95. package/src/lib/rules/prefer-event-specific-callback-naming/prefer-event-specific-callback-naming.js +75 -0
  96. package/src/lib/rules/prefer-event-specific-callback-naming/prefer-event-specific-callback-naming.js.map +1 -0
  97. package/src/lib/rules/prefer-event-specific-callback-naming/strategies/string-based.d.ts +32 -0
  98. package/src/lib/rules/prefer-event-specific-callback-naming/strategies/string-based.js +143 -0
  99. package/src/lib/rules/prefer-event-specific-callback-naming/strategies/string-based.js.map +1 -0
  100. package/src/lib/rules/prefer-event-specific-callback-naming/strategies/type-based.d.ts +27 -0
  101. package/src/lib/rules/prefer-event-specific-callback-naming/strategies/type-based.js +196 -0
  102. package/src/lib/rules/prefer-event-specific-callback-naming/strategies/type-based.js.map +1 -0
  103. package/src/lib/rules/prefer-event-specific-callback-naming/utils.d.ts +76 -0
  104. package/src/lib/rules/prefer-event-specific-callback-naming/utils.js +245 -0
  105. package/src/lib/rules/prefer-event-specific-callback-naming/utils.js.map +1 -0
  106. package/src/lib/rules/prefer-field-components/prefer-field-components.d.ts +4 -0
  107. package/src/lib/rules/prefer-field-components/prefer-field-components.js +289 -0
  108. package/src/lib/rules/prefer-field-components/prefer-field-components.js.map +1 -0
  109. package/src/lib/rules/prefer-mouse-event-handler-in-react-props/prefer-mouse-event-handler-in-react-props.d.ts +26 -0
  110. package/src/lib/rules/prefer-mouse-event-handler-in-react-props/prefer-mouse-event-handler-in-react-props.js +402 -0
  111. package/src/lib/rules/prefer-mouse-event-handler-in-react-props/prefer-mouse-event-handler-in-react-props.js.map +1 -0
  112. package/src/lib/rules/require-classname-alternatives/require-classname-alternatives.d.ts +13 -0
  113. package/src/lib/rules/require-classname-alternatives/require-classname-alternatives.js +271 -0
  114. package/src/lib/rules/require-classname-alternatives/require-classname-alternatives.js.map +1 -0
  115. package/src/lib/rules/require-list-item-virtualization-props/require-list-item-virtualization-props.d.ts +15 -0
  116. package/src/lib/rules/require-list-item-virtualization-props/require-list-item-virtualization-props.js +245 -0
  117. package/src/lib/rules/require-list-item-virtualization-props/require-list-item-virtualization-props.js.map +1 -0
  118. package/src/lib/rules/require-optional-prop-initialization/require-optional-prop-initialization.d.ts +17 -0
  119. package/src/lib/rules/require-optional-prop-initialization/require-optional-prop-initialization.js +133 -0
  120. package/src/lib/rules/require-optional-prop-initialization/require-optional-prop-initialization.js.map +1 -0
  121. package/src/lib/rules/require-optional-prop-initialization/suggestion-utils.d.ts +12 -0
  122. package/src/lib/rules/require-optional-prop-initialization/suggestion-utils.js +128 -0
  123. package/src/lib/rules/require-optional-prop-initialization/suggestion-utils.js.map +1 -0
  124. package/src/lib/rules-map.d.ts +66 -0
  125. package/src/lib/rules-map.js +34 -0
  126. package/src/lib/rules-map.js.map +1 -0
  127. package/src/lib/utils/ast-utils.d.ts +85 -0
  128. package/src/lib/utils/ast-utils.js +530 -0
  129. package/src/lib/utils/ast-utils.js.map +1 -0
  130. package/src/lib/utils/classname-utils.d.ts +150 -0
  131. package/src/lib/utils/classname-utils.js +492 -0
  132. package/src/lib/utils/classname-utils.js.map +1 -0
  133. package/src/lib/utils/file-utils.d.ts +14 -0
  134. package/src/lib/utils/file-utils.js +106 -0
  135. package/src/lib/utils/file-utils.js.map +1 -0
  136. package/src/lib/utils/import-utils.d.ts +85 -0
  137. package/src/lib/utils/import-utils.js +193 -0
  138. package/src/lib/utils/import-utils.js.map +1 -0
  139. package/src/lib/utils/nx-utils.d.ts +59 -0
  140. package/src/lib/utils/nx-utils.js +103 -0
  141. package/src/lib/utils/nx-utils.js.map +1 -0
  142. package/src/lib/utils/package-utils.d.ts +38 -0
  143. package/src/lib/utils/package-utils.js +74 -0
  144. package/src/lib/utils/package-utils.js.map +1 -0
  145. package/src/lib/utils/typescript-utils.d.ts +29 -0
  146. package/src/lib/utils/typescript-utils.js +213 -0
  147. package/src/lib/utils/typescript-utils.js.map +1 -0
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reactPreset = void 0;
4
+ const react_rules_1 = require("../fragments/react-rules");
5
+ const testing_library_1 = require("../fragments/testing-library");
6
+ const plugins_1 = require("../plugins");
7
+ exports.reactPreset = [
8
+ ...(plugins_1.storybook.configs["flat/recommended"] ?? []),
9
+ {
10
+ plugins: {
11
+ "@trackunit": plugins_1.localRulesPlugin,
12
+ "@typescript-eslint": plugins_1.typescriptEslint,
13
+ jsdoc: plugins_1.jsdoc,
14
+ react: plugins_1.react,
15
+ "react-hooks": plugins_1.reactHooks,
16
+ "testing-library": plugins_1.testingLibrary,
17
+ "@nx": plugins_1.nx,
18
+ },
19
+ settings: {
20
+ react: {
21
+ version: "detect",
22
+ },
23
+ },
24
+ languageOptions: {
25
+ globals: {
26
+ ...plugins_1.globals.browser,
27
+ ...plugins_1.jest.environments.globals.globals,
28
+ ...plugins_1.globals.node,
29
+ Text: "writable",
30
+ screen: "writable",
31
+ },
32
+ parser: plugins_1.tsParser,
33
+ ecmaVersion: 2022,
34
+ sourceType: "commonjs",
35
+ parserOptions: {
36
+ ecmaFeatures: {
37
+ jsx: true,
38
+ },
39
+ },
40
+ },
41
+ },
42
+ {
43
+ files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
44
+ rules: {
45
+ ...react_rules_1.reactCustomRules,
46
+ "no-multiple-empty-lines": [
47
+ "error",
48
+ {
49
+ max: 1,
50
+ },
51
+ ],
52
+ "no-unreachable": "error",
53
+ "prefer-spread": "error",
54
+ ...react_rules_1.reactRules,
55
+ "no-restricted-syntax": [
56
+ "warn",
57
+ {
58
+ selector: "TSEnumDeclaration",
59
+ message: "Please use string literal union or objects instead of enums.",
60
+ },
61
+ ],
62
+ },
63
+ },
64
+ {
65
+ files: ["**/*.stories.ts", "**/*.stories.tsx"],
66
+ rules: {
67
+ "jsdoc/require-jsdoc": "off",
68
+ "no-console": "off",
69
+ "@typescript-eslint/no-empty-function": "off",
70
+ },
71
+ },
72
+ {
73
+ files: ["**/*.spec.ts", "**/*.spec.tsx"],
74
+ plugins: {
75
+ jest: plugins_1.jest,
76
+ "testing-library": plugins_1.testingLibrary,
77
+ },
78
+ languageOptions: {
79
+ globals: {
80
+ ...plugins_1.globals.browser,
81
+ ...plugins_1.jest.environments.globals.globals,
82
+ ...plugins_1.globals.node,
83
+ Text: "writable",
84
+ screen: "writable",
85
+ },
86
+ parser: plugins_1.tsParser,
87
+ },
88
+ rules: {
89
+ ...plugins_1.jest.configs.recommended.rules,
90
+ ...plugins_1.jest.configs.style.rules,
91
+ ...testing_library_1.reactTestingLibraryRules,
92
+ "jest/no-commented-out-tests": "error",
93
+ "jest/expect-expect": "error",
94
+ },
95
+ },
96
+ ];
97
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/presets/react.ts"],"names":[],"mappings":";;;AAAA,0DAAwE;AACxE,kEAAwE;AACxE,wCAYoB;AAEP,QAAA,WAAW,GAAG;IACzB,GAAG,CAAC,mBAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;IAChD;QACE,OAAO,EAAE;YACP,YAAY,EAAE,0BAAgB;YAC9B,oBAAoB,EAAE,0BAAgB;YACtC,KAAK,EAAL,eAAK;YACL,KAAK,EAAL,eAAK;YACL,aAAa,EAAE,oBAAU;YACzB,iBAAiB,EAAE,wBAAc;YACjC,K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CAAC,OAAO;gBACpC,GAAG,iBAAO,CAAC,IAAI;gBACf,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,UAAU;aACnB;YAED,MAAM,EAAE,kBAAQ;SACjB;QAED,KAAK,EAAE;YACL,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;YACjC,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;YAC3B,GAAG,0CAAwB;YAC3B,6BAA6B,EAAE,OAAO;YACtC,oBAAoB,EAAE,OAAO;SAC9B;KACF;CACF,CAAC","sourcesContent":["import { reactCustomRules, reactRules } from \"../fragments/react-rules\";\nimport { reactTestingLibraryRules } from \"../fragments/testing-library\";\nimport {\n globals,\n jest,\n jsdoc,\n localRulesPlugin,\n nx,\n react,\n reactHooks,\n storybook,\n testingLibrary,\n tsParser,\n typescriptEslint,\n} from \"../plugins\";\n\nexport const reactPreset = [\n ...(storybook.configs[\"flat/recommended\"] ?? []),\n {\n plugins: {\n \"@trackunit\": localRulesPlugin,\n \"@typescript-eslint\": typescriptEslint,\n jsdoc,\n react,\n \"react-hooks\": reactHooks,\n \"testing-library\": testingLibrary,\n \"@nx\": nx,\n },\n\n settings: {\n react: {\n version: \"detect\",\n },\n },\n languageOptions: {\n globals: {\n ...globals.browser,\n ...jest.environments.globals.globals,\n ...globals.node,\n Text: \"writable\",\n screen: \"writable\",\n },\n parser: tsParser,\n ecmaVersion: 2022,\n sourceType: \"commonjs\",\n parserOptions: {\n ecmaFeatures: {\n jsx: true,\n },\n },\n },\n },\n {\n files: [\"**/*.ts\", \"**/*.tsx\", \"**/*.js\", \"**/*.jsx\"],\n rules: {\n ...reactCustomRules,\n\n \"no-multiple-empty-lines\": [\n \"error\",\n {\n max: 1,\n },\n ],\n\n \"no-unreachable\": \"error\",\n \"prefer-spread\": \"error\",\n\n ...reactRules,\n\n \"no-restricted-syntax\": [\n \"warn\",\n {\n selector: \"TSEnumDeclaration\",\n message: \"Please use string literal union or objects instead of enums.\",\n },\n ],\n },\n },\n {\n files: [\"**/*.stories.ts\", \"**/*.stories.tsx\"],\n rules: {\n \"jsdoc/require-jsdoc\": \"off\",\n \"no-console\": \"off\",\n \"@typescript-eslint/no-empty-function\": \"off\",\n },\n },\n {\n files: [\"**/*.spec.ts\", \"**/*.spec.tsx\"],\n\n plugins: {\n jest,\n \"testing-library\": testingLibrary,\n },\n languageOptions: {\n globals: {\n ...globals.browser,\n ...jest.environments.globals.globals,\n ...globals.node,\n Text: \"writable\",\n screen: \"writable\",\n },\n\n parser: tsParser,\n },\n\n rules: {\n ...jest.configs.recommended.rules,\n ...jest.configs.style.rules,\n ...reactTestingLibraryRules,\n \"jest/no-commented-out-tests\": \"error\",\n \"jest/expect-expect\": \"error\",\n },\n },\n];\n"]}
@@ -0,0 +1,36 @@
1
+ export declare const server: ({
2
+ languageOptions: {
3
+ globals: {
4
+ [x: string]: boolean | "readonly" | "writable";
5
+ };
6
+ parser: import("eslint").Linter.Parser;
7
+ parserOptions?: undefined;
8
+ };
9
+ files?: undefined;
10
+ plugins?: undefined;
11
+ rules?: undefined;
12
+ } | {
13
+ files: string[];
14
+ plugins: {
15
+ jsdoc: {
16
+ rules: Record<string, import("eslint").Rule.RuleModule>;
17
+ configs: Record<string, import("eslint").Linter.Config>;
18
+ };
19
+ "type-graphql": {
20
+ rules: Record<string, import("eslint").Rule.RuleModule>;
21
+ };
22
+ };
23
+ languageOptions: {
24
+ parserOptions: {
25
+ project: string[];
26
+ };
27
+ globals?: undefined;
28
+ parser?: undefined;
29
+ };
30
+ rules: {
31
+ "type-graphql/missing-decorator-type": string[];
32
+ "type-graphql/invalid-nullable-output-type": string;
33
+ "type-graphql/wrong-decorator-signature": string;
34
+ "type-graphql/invalid-nullable-input-type": string;
35
+ };
36
+ })[];
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.server = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const compat_1 = require("@eslint/compat");
6
+ const typeGraphql = tslib_1.__importStar(require("eslint-plugin-type-graphql"));
7
+ const plugins_1 = require("../plugins");
8
+ exports.server = [
9
+ {
10
+ languageOptions: {
11
+ globals: {
12
+ ...plugins_1.globals.browser,
13
+ },
14
+ parser: plugins_1.tsParser,
15
+ },
16
+ },
17
+ {
18
+ files: ["**/*.ts", "**/*.js"],
19
+ plugins: {
20
+ jsdoc: plugins_1.jsdoc,
21
+ "type-graphql": (0, compat_1.fixupPluginRules)(typeGraphql),
22
+ },
23
+ languageOptions: {
24
+ parserOptions: {
25
+ project: ["./tsconfig.*?.json"],
26
+ },
27
+ },
28
+ rules: {
29
+ ...typeGraphql.configs.recommended.rules,
30
+ "type-graphql/missing-decorator-type": ["error", "all"],
31
+ "type-graphql/invalid-nullable-output-type": "off",
32
+ "type-graphql/wrong-decorator-signature": "error",
33
+ "type-graphql/invalid-nullable-input-type": "off",
34
+ },
35
+ },
36
+ ];
37
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/presets/server.ts"],"names":[],"mappings":";;;;AAAA,2CAAkD;AAClD,gFAA0D;AAE1D,wCAAsD;AAEzC,QAAA,MAAM,GAAG;IACpB;QACE,eAAe,EAAE;YACf,OAAO,EAAE;gBACP,GAAG,iBAAO,CAAC,OAAO;aACnB;YAED,MAAM,EAAE,kBAAQ;SACjB;KACF;IACD;QACE,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;QAC7B,OAAO,EAAE;YACP,KAAK,EAAL,eAAK;YACL,cAAc,EAAE,IAAA,yBAAgB,EAAC,WAAW,CAAC;SAC9C;QACD,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,OAAO,EAAE,CAAC,oBAAoB,CAAC;aAChC;SACF;QAED,KAAK,EAAE;YACL,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;YACxC,qCAAqC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;YACvD,2CAA2C,EAAE,KAAK;YAClD,wCAAwC,EAAE,OAAO;YACjD,0CAA0C,EAAE,KAAK;SAClD;KACF;CACF,CAAC","sourcesContent":["import { fixupPluginRules } from \"@eslint/compat\";\nimport * as typeGraphql from \"eslint-plugin-type-graphql\";\n\nimport { globals, jsdoc, tsParser } from \"../plugins\";\n\nexport const server = [\n {\n languageOptions: {\n globals: {\n ...globals.browser,\n },\n\n parser: tsParser,\n },\n },\n {\n files: [\"**/*.ts\", \"**/*.js\"],\n plugins: {\n jsdoc,\n \"type-graphql\": fixupPluginRules(typeGraphql),\n },\n languageOptions: {\n parserOptions: {\n project: [\"./tsconfig.*?.json\"],\n },\n },\n\n rules: {\n ...typeGraphql.configs.recommended.rules,\n \"type-graphql/missing-decorator-type\": [\"error\", \"all\"],\n \"type-graphql/invalid-nullable-output-type\": \"off\",\n \"type-graphql/wrong-decorator-signature\": \"error\",\n \"type-graphql/invalid-nullable-input-type\": \"off\",\n },\n },\n];\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Finds the monorepo root by walking up from the config package directory
3
+ * until a directory containing nx.json is found.
4
+ * Falls back to process.cwd() if no nx.json is found.
5
+ */
6
+ export declare function findMonorepoRoot(): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findMonorepoRoot = findMonorepoRoot;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ let cachedRoot;
8
+ /**
9
+ * Finds the monorepo root by walking up from the config package directory
10
+ * until a directory containing nx.json is found.
11
+ * Falls back to process.cwd() if no nx.json is found.
12
+ */
13
+ function findMonorepoRoot() {
14
+ if (cachedRoot !== undefined) {
15
+ return cachedRoot;
16
+ }
17
+ let dir = __dirname;
18
+ while (dir !== path.dirname(dir)) {
19
+ if (fs.existsSync(path.join(dir, "nx.json"))) {
20
+ cachedRoot = dir;
21
+ return dir;
22
+ }
23
+ dir = path.dirname(dir);
24
+ }
25
+ cachedRoot = process.cwd();
26
+ return cachedRoot;
27
+ }
28
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../libs/eslint/plugin-trackunit/src/lib/config/utils.ts"],"names":[],"mappings":";;AAUA,4CAcC;;AAxBD,+CAAyB;AACzB,mDAA6B;AAE7B,IAAI,UAA8B,CAAC;AAEnC;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,OAAO,GAAG,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;YAC7C,UAAU,GAAG,GAAG,CAAC;YACjB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\n\nlet cachedRoot: string | undefined;\n\n/**\n * Finds the monorepo root by walking up from the config package directory\n * until a directory containing nx.json is found.\n * Falls back to process.cwd() if no nx.json is found.\n */\nexport function findMonorepoRoot(): string {\n if (cachedRoot !== undefined) {\n return cachedRoot;\n }\n let dir = __dirname;\n while (dir !== path.dirname(dir)) {\n if (fs.existsSync(path.join(dir, \"nx.json\"))) {\n cachedRoot = dir;\n return dir;\n }\n dir = path.dirname(dir);\n }\n cachedRoot = process.cwd();\n return cachedRoot;\n}\n"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Helper to create ESLint config that wraps rules with skip-when-lib-has-tag-tool logic.
3
+ *
4
+ * This provides a cleaner API than manually using the skip-when-lib-has-tag-tool/ prefix.
5
+ *
6
+ * @example
7
+ * createSkipWhen({
8
+ * when: { tags: ['scope:tool'] },
9
+ * plugins: {
10
+ * 'import-x': importXPlugin,
11
+ * },
12
+ * rules: {
13
+ * 'import-x/no-extraneous-dependencies': ["error", { ... }],
14
+ * }
15
+ * })
16
+ *
17
+ * Returns a config object with:
18
+ * - A unique plugin containing the wrapped rules for this specific config
19
+ * - Rules configured to use the wrapped versions
20
+ */
21
+ import type { Linter, Rule } from "eslint";
22
+ import { type MatchCriteria } from "../utils/nx-utils";
23
+ type PluginMap = Record<string, {
24
+ rules: Record<string, Rule.RuleModule>;
25
+ }>;
26
+ type CreateSkipWhenOptions = {
27
+ when: MatchCriteria;
28
+ plugins: PluginMap;
29
+ rules: Linter.RulesRecord;
30
+ };
31
+ /**
32
+ * Creates an ESLint config that wraps rules to skip enforcement based on NX project criteria.
33
+ */
34
+ export declare const createSkipWhen: (options: CreateSkipWhenOptions) => Linter.FlatConfig;
35
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSkipWhen = void 0;
4
+ const nx_utils_1 = require("../utils/nx-utils");
5
+ let skipWhenCounter = 0;
6
+ /**
7
+ * Creates an ESLint config that wraps rules to skip enforcement based on NX project criteria.
8
+ */
9
+ const createSkipWhen = (options) => {
10
+ const { when, plugins, rules } = options;
11
+ // Create a unique plugin name for this config
12
+ const pluginName = `skip-when-${skipWhenCounter++}`;
13
+ // Build wrapped rules from provided plugins
14
+ const wrappedRules = {};
15
+ for (const [originalPluginName, plugin] of Object.entries(plugins)) {
16
+ for (const [ruleName, originalRule] of Object.entries(plugin.rules)) {
17
+ const fullRuleName = `${originalPluginName}/${ruleName}`;
18
+ // Create wrapped version of this rule
19
+ wrappedRules[fullRuleName] = {
20
+ meta: originalRule.meta,
21
+ create(context) {
22
+ // Check if this file belongs to a project matching the criteria
23
+ const filename = context.filename || context.getFilename();
24
+ const metadata = (0, nx_utils_1.getProjectMetadata)(filename);
25
+ // Check if project matches the skip criteria
26
+ if (metadata && (0, nx_utils_1.projectMatchesCriteria)(metadata, when)) {
27
+ // Skip enforcement - return empty visitor
28
+ return {};
29
+ }
30
+ // Otherwise, delegate to the original rule
31
+ return originalRule.create(context);
32
+ },
33
+ };
34
+ }
35
+ }
36
+ // Build the rules config
37
+ const rulesConfig = {};
38
+ for (const [ruleName, ruleConfig] of Object.entries(rules)) {
39
+ // Disable the original rule
40
+ rulesConfig[ruleName] = "off";
41
+ // Enable our wrapped version
42
+ rulesConfig[`${pluginName}/${ruleName}`] = ruleConfig;
43
+ }
44
+ return {
45
+ plugins: {
46
+ [pluginName]: {
47
+ rules: wrappedRules,
48
+ },
49
+ },
50
+ rules: rulesConfig,
51
+ };
52
+ };
53
+ exports.createSkipWhen = createSkipWhen;
54
+ //# sourceMappingURL=create-skip-when.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-skip-when.js","sourceRoot":"","sources":["../../../../../../../libs/eslint/plugin-trackunit/src/lib/config-helpers/create-skip-when.ts"],"names":[],"mappings":";;;AAqBA,gDAAmG;AAUnG,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;GAEG;AACI,MAAM,cAAc,GAAG,CAAC,OAA8B,EAAqB,EAAE;IAClF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEzC,8CAA8C;IAC9C,MAAM,UAAU,GAAG,aAAa,eAAe,EAAE,EAAE,CAAC;IAEpD,4CAA4C;IAC5C,MAAM,YAAY,GAAoC,EAAE,CAAC;IAEzD,KAAK,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnE,KAAK,M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**\n * Helper to create ESLint config that wraps rules with skip-when-lib-has-tag-tool logic.\n *\n * This provides a cleaner API than manually using the skip-when-lib-has-tag-tool/ prefix.\n *\n * @example\n * createSkipWhen({\n * when: { tags: ['scope:tool'] },\n * plugins: {\n * 'import-x': importXPlugin,\n * },\n * rules: {\n * 'import-x/no-extraneous-dependencies': [\"error\", { ... }],\n * }\n * })\n *\n * Returns a config object with:\n * - A unique plugin containing the wrapped rules for this specific config\n * - Rules configured to use the wrapped versions\n */\nimport type { Linter, Rule } from \"eslint\";\nimport { getProjectMetadata, projectMatchesCriteria, type MatchCriteria } from \"../utils/nx-utils\";\n\ntype PluginMap = Record<string, { rules: Record<string, Rule.RuleModule> }>;\n\ntype CreateSkipWhenOptions = {\n when: MatchCriteria;\n plugins: PluginMap;\n rules: Linter.RulesRecord;\n};\n\nlet skipWhenCounter = 0;\n\n/**\n * Creates an ESLint config that wraps rules to skip enforcement based on NX project criteria.\n */\nexport const createSkipWhen = (options: CreateSkipWhenOptions): Linter.FlatConfig => {\n const { when, plugins, rules } = options;\n\n // Create a unique plugin name for this config\n const pluginName = `skip-when-${skipWhenCounter++}`;\n\n // Build wrapped rules from provided plugins\n const wrappedRules: Record<string, Rule.RuleModule> = {};\n\n for (const [originalPluginName, plugin] of Object.entries(plugins)) {\n for (const [ruleName, originalRule] of Object.entries(plugin.rules)) {\n const fullRuleName = `${originalPluginName}/${ruleName}`;\n\n // Create wrapped version of this rule\n wrappedRules[fullRuleName] = {\n meta: originalRule.meta,\n create(context: Rule.RuleContext) {\n // Check if this file belongs to a project matching the criteria\n const filename = context.filename || context.getFilename();\n const metadata = getProjectMetadata(filename);\n\n // Check if project matches the skip criteria\n if (metadata && projectMatchesCriteria(metadata, when)) {\n // Skip enforcement - return empty visitor\n return {};\n }\n\n // Otherwise, delegate to the original rule\n return originalRule.create(context);\n },\n };\n }\n }\n\n // Build the rules config\n const rulesConfig: Linter.RulesRecord = {};\n\n for (const [ruleName, ruleConfig] of Object.entries(rules)) {\n // Disable the original rule\n rulesConfig[ruleName] = \"off\";\n\n // Enable our wrapped version\n rulesConfig[`${pluginName}/${ruleName}`] = ruleConfig;\n }\n\n return {\n plugins: {\n [pluginName]: {\n rules: wrappedRules,\n },\n },\n rules: rulesConfig,\n };\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ type MessageIds = "stringNeedsArray" | "arrayNeedsSplit";
3
+ /**
4
+ * ESLint rule that converts cvaMerge base styles to arrays if more than one class is used.
5
+ *
6
+ * @example
7
+ * Invalid:
8
+ * const cvaMyComponent = cvaMerge("text-danger-600 mb-4 font-semibold");
9
+ * const cvaMyComponent = cvaMerge(["text-danger-600 mb-4","font-semibold"]);
10
+ * Valid:
11
+ * const cvaMyComponent = cvaMerge(["text-danger-600", "mb-4", "font-semibold"]);
12
+ */
13
+ export declare const cvaMergeBaseClassesAsArray: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
14
+ name: string;
15
+ };
16
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cvaMergeBaseClassesAsArray = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const classname_utils_1 = require("../../utils/classname-utils");
6
+ const createRule = utils_1.ESLintUtils.RuleCreator(name => `https://github.com/trackunit/manager/blob/main/libs/eslint/plugin-trackunit/src/lib/rules/${name}.ts`);
7
+ /**
8
+ * ESLint rule that converts cvaMerge base styles to arrays if more than one class is used.
9
+ *
10
+ * @example
11
+ * Invalid:
12
+ * const cvaMyComponent = cvaMerge("text-danger-600 mb-4 font-semibold");
13
+ * const cvaMyComponent = cvaMerge(["text-danger-600 mb-4","font-semibold"]);
14
+ * Valid:
15
+ * const cvaMyComponent = cvaMerge(["text-danger-600", "mb-4", "font-semibold"]);
16
+ */
17
+ exports.cvaMergeBaseClassesAsArray = createRule({
18
+ name: "cva-merge-base-classes-as-array",
19
+ meta: {
20
+ type: "layout",
21
+ docs: {
22
+ description: "Convert cvaMerge base styles to arrays if more than one class is used.",
23
+ },
24
+ fixable: "code",
25
+ messages: {
26
+ stringNeedsArray: "[cvaMerge] The first argument of cvaMerge should be an array if multiple classes are used.",
27
+ arrayNeedsSplit: "[cvaMerge] Only one class per array item is allowed.",
28
+ },
29
+ schema: [],
30
+ },
31
+ defaultOptions: [],
32
+ create(context) {
33
+ return {
34
+ CallExpression(node) {
35
+ const calleeName = (0, classname_utils_1.getCalleeName)(node.callee);
36
+ if (calleeName !== "cvaMerge" || node.arguments.length === 0) {
37
+ return;
38
+ }
39
+ const firstArg = node.arguments[0];
40
+ if (!firstArg) {
41
+ return;
42
+ }
43
+ // Handle string literal: cvaMerge("class1 class2")
44
+ if (firstArg.type === utils_1.AST_NODE_TYPES.Literal && typeof firstArg.value === "string") {
45
+ const value = firstArg.value;
46
+ if (value.includes(" ")) {
47
+ context.report({
48
+ node,
49
+ messageId: "stringNeedsArray",
50
+ fix(fixer) {
51
+ return fixer.replaceText(firstArg, (0, classname_utils_1.formatAsArray)((0, classname_utils_1.splitClasses)(value)));
52
+ },
53
+ });
54
+ }
55
+ return;
56
+ }
57
+ // Handle array: cvaMerge(["class1 class2", "class3"])
58
+ if (firstArg.type === utils_1.AST_NODE_TYPES.ArrayExpression) {
59
+ const hasMultiClassElement = firstArg.elements.some(element => element?.type === utils_1.AST_NODE_TYPES.Literal &&
60
+ typeof element.value === "string" &&
61
+ element.value.includes(" "));
62
+ if (hasMultiClassElement) {
63
+ context.report({
64
+ node,
65
+ messageId: "arrayNeedsSplit",
66
+ fix(fixer) {
67
+ // Extract all string values and split them into individual classes
68
+ const allClasses = [];
69
+ for (const element of firstArg.elements) {
70
+ if (element?.type === utils_1.AST_NODE_TYPES.Literal && typeof element.value === "string") {
71
+ allClasses.push(...(0, classname_utils_1.splitClasses)(element.value));
72
+ }
73
+ }
74
+ return fixer.replaceText(firstArg, (0, classname_utils_1.formatAsArray)(allClasses));
75
+ },
76
+ });
77
+ }
78
+ }
79
+ },
80
+ };
81
+ },
82
+ });
83
+ //# sourceMappingURL=cva-merge-base-classes-as-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cva-merge-base-classes-as-array.js","sourceRoot":"","sources":["../../../../../../../../libs/eslint/plugin-trackunit/src/lib/rules/cva-merge-base-classes-as-array/cva-merge-base-classes-as-array.ts"],"names":[],"mappings":";;;AAAA,oDAAiF;AACjF,iEAAyF;AAEzF,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,IAAI,CAAC,EAAE,CAAC,6FAA6F,IAAI,KAAK,CAC/G,CAAC;AAKF;;;;;;;;;GASG;AACU,QAAA,0BAA0B,GAAG,UAAU,CAAsB;IACxE,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,wEAAwE;SACtF;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,gBAAgB,EAAE,4FAA4F;YAC9G,eAAe,EAAE,sDAAsD;SACxE;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAA6B;gBAC1C,MAAM,UAAU,GAAG,IAAA,+BAAa,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAE9C,IAAI,UAAU,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC7D,OAAO;gBACT,CAAC;gBAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,OAAO;gBACT,CAAC;gBAED,mDAAmD;gBACnD,IAAI,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,OAAO,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,E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K,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAA,+BAAa,EAAC,UAAU,CAAC,CAAC,CAAC;4BAChE,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { AST_NODE_TYPES, ESLintUtils, TSESTree } from \"@typescript-eslint/utils\";\nimport { formatAsArray, getCalleeName, splitClasses } from \"../../utils/classname-utils\";\n\nconst createRule = ESLintUtils.RuleCreator(\n name => `https://github.com/trackunit/manager/blob/main/libs/eslint/plugin-trackunit/src/lib/rules/${name}.ts`\n);\n\ntype MessageIds = \"stringNeedsArray\" | \"arrayNeedsSplit\";\ntype Options = [];\n\n/**\n * ESLint rule that converts cvaMerge base styles to arrays if more than one class is used.\n *\n * @example\n * Invalid:\n * const cvaMyComponent = cvaMerge(\"text-danger-600 mb-4 font-semibold\");\n * const cvaMyComponent = cvaMerge([\"text-danger-600 mb-4\",\"font-semibold\"]);\n * Valid:\n * const cvaMyComponent = cvaMerge([\"text-danger-600\", \"mb-4\", \"font-semibold\"]);\n */\nexport const cvaMergeBaseClassesAsArray = createRule<Options, MessageIds>({\n name: \"cva-merge-base-classes-as-array\",\n meta: {\n type: \"layout\",\n docs: {\n description: \"Convert cvaMerge base styles to arrays if more than one class is used.\",\n },\n fixable: \"code\",\n messages: {\n stringNeedsArray: \"[cvaMerge] The first argument of cvaMerge should be an array if multiple classes are used.\",\n arrayNeedsSplit: \"[cvaMerge] Only one class per array item is allowed.\",\n },\n schema: [],\n },\n defaultOptions: [],\n create(context) {\n return {\n CallExpression(node: TSESTree.CallExpression) {\n const calleeName = getCalleeName(node.callee);\n\n if (calleeName !== \"cvaMerge\" || node.arguments.length === 0) {\n return;\n }\n\n const firstArg = node.arguments[0];\n if (!firstArg) {\n return;\n }\n\n // Handle string literal: cvaMerge(\"class1 class2\")\n if (firstArg.type === AST_NODE_TYPES.Literal && typeof firstArg.value === \"string\") {\n const value = firstArg.value;\n if (value.includes(\" \")) {\n context.report({\n node,\n messageId: \"stringNeedsArray\",\n fix(fixer) {\n return fixer.replaceText(firstArg, formatAsArray(splitClasses(value)));\n },\n });\n }\n return;\n }\n\n // Handle array: cvaMerge([\"class1 class2\", \"class3\"])\n if (firstArg.type === AST_NODE_TYPES.ArrayExpression) {\n const hasMultiClassElement = firstArg.elements.some(\n element =>\n element?.type === AST_NODE_TYPES.Literal &&\n typeof element.value === \"string\" &&\n element.value.includes(\" \")\n );\n\n if (hasMultiClassElement) {\n context.report({\n node,\n messageId: \"arrayNeedsSplit\",\n fix(fixer) {\n // Extract all string values and split them into individual classes\n const allClasses: Array<string> = [];\n for (const element of firstArg.elements) {\n if (element?.type === AST_NODE_TYPES.Literal && typeof element.value === \"string\") {\n allClasses.push(...splitClasses(element.value));\n }\n }\n return fixer.replaceText(firstArg, formatAsArray(allClasses));\n },\n });\n }\n }\n },\n };\n },\n});\n"]}
@@ -0,0 +1,4 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const designGuidelineButtonIconSizeMatch: ESLintUtils.RuleModule<"incorrectIconSize", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };