@timefoldai/viz-cli 0.0.0 → 0.1.0

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.
package/package.json CHANGED
@@ -1,13 +1,90 @@
1
1
  {
2
2
  "name": "@timefoldai/viz-cli",
3
- "version": "0.0.0",
4
- "description": "Placeholder that reserves the name. The first release is 0.1.0.",
3
+ "version": "0.1.0",
4
+ "description": "Build tools for a Timefold model visualization app: shared Vite and Vitest configs, lint plugins and build guards.",
5
+ "keywords": [
6
+ "oxlint",
7
+ "stylelint",
8
+ "timefold",
9
+ "visualization",
10
+ "vite",
11
+ "vitest"
12
+ ],
13
+ "homepage": "https://timefold.ai",
14
+ "bugs": {
15
+ "url": "https://docs.timefold.ai/timefold-platform/latest/support/contacting-support"
16
+ },
5
17
  "license": "Apache-2.0",
6
18
  "repository": {
7
19
  "type": "git",
8
20
  "url": "git+https://github.com/TimefoldAI/timefold-visualisations.git",
9
21
  "directory": "packages/cli"
10
22
  },
11
- "homepage": "https://timefold.ai",
12
- "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org" }
13
- }
23
+ "bin": {
24
+ "viz-check-css-layer-order": "./bin/viz-check-css-layer-order.mjs",
25
+ "viz-check-leaked-env": "./bin/viz-check-leaked-env.mjs",
26
+ "viz-codegen": "./bin/viz-codegen.mjs"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "!dist/index.*",
31
+ "bin",
32
+ "oxlint",
33
+ "stylelint",
34
+ "!**/*.test.mjs"
35
+ ],
36
+ "type": "module",
37
+ "sideEffects": false,
38
+ "exports": {
39
+ "./vite": {
40
+ "types": "./dist/vite.d.mts",
41
+ "default": "./dist/vite.mjs"
42
+ },
43
+ "./vitest": {
44
+ "types": "./dist/vitest.d.mts",
45
+ "default": "./dist/vitest.mjs"
46
+ },
47
+ "./layer-order": {
48
+ "types": "./dist/layer-order.d.mts",
49
+ "default": "./dist/layer-order.mjs"
50
+ },
51
+ "./oxlint/*": "./oxlint/*.mjs",
52
+ "./stylelint/*": "./stylelint/*.mjs"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public",
56
+ "registry": "https://registry.npmjs.org"
57
+ },
58
+ "peerDependencies": {
59
+ "@tailwindcss/vite": "^4",
60
+ "@vitejs/plugin-react": "^6",
61
+ "@vitest/coverage-istanbul": "^5",
62
+ "openapi-typescript": "^7",
63
+ "stylelint": "^18",
64
+ "vite": "^8",
65
+ "vitest": "^5"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@tailwindcss/vite": {
69
+ "optional": true
70
+ },
71
+ "@vitejs/plugin-react": {
72
+ "optional": true
73
+ },
74
+ "@vitest/coverage-istanbul": {
75
+ "optional": true
76
+ },
77
+ "openapi-typescript": {
78
+ "optional": true
79
+ },
80
+ "stylelint": {
81
+ "optional": true
82
+ },
83
+ "vitest": {
84
+ "optional": true
85
+ }
86
+ },
87
+ "engines": {
88
+ "node": ">=26"
89
+ }
90
+ }
@@ -0,0 +1,71 @@
1
+ import stylelint from "stylelint";
2
+
3
+ const ruleName = "viz/no-stylesheet-comment";
4
+ const messages = stylelint.utils.ruleMessages(ruleName, {
5
+ rejected:
6
+ "A stylesheet carries no comment but a single-line `tokens-allow` directive",
7
+ });
8
+
9
+ const ABSORBED_COMMENT = /\/\/|\/\*/;
10
+ const strippedOfUrls = (value) => value.replace(/url\([^)]*\)/g, "");
11
+ const isAllowedText = (text) =>
12
+ !text.includes("\n") && /tokens-allow/.test(text);
13
+
14
+ const rawText = (raws, key) => raws[key] ?? "";
15
+ const rawOrOwnText = (raws, key, ownText) => raws[key]?.raw ?? ownText;
16
+
17
+ const declRaw = (decl) =>
18
+ rawText(decl.raws, "between") +
19
+ rawOrOwnText(decl.raws, "value", decl.value) +
20
+ rawText(decl.raws, "important");
21
+ const ruleRaw = (styleRule) =>
22
+ rawOrOwnText(styleRule.raws, "selector", styleRule.selector) +
23
+ rawText(styleRule.raws, "between");
24
+ const atRuleRaw = (atRule) =>
25
+ rawText(atRule.raws, "afterName") +
26
+ rawOrOwnText(atRule.raws, "params", atRule.params) +
27
+ rawText(atRule.raws, "between");
28
+
29
+ const rule = (primary) => (root, result) => {
30
+ if (
31
+ !stylelint.utils.validateOptions(result, ruleName, {
32
+ actual: primary,
33
+ possible: [true],
34
+ })
35
+ )
36
+ return;
37
+
38
+ const reportUnlessAllowed = (node, raw) => {
39
+ const stripped = strippedOfUrls(raw);
40
+ if (!ABSORBED_COMMENT.test(stripped)) return;
41
+ if (isAllowedText(stripped)) return;
42
+ stylelint.utils.report({
43
+ ruleName,
44
+ result,
45
+ message: messages.rejected,
46
+ node,
47
+ });
48
+ };
49
+
50
+ root.walkComments((comment) => {
51
+ if (isAllowedText(comment.text)) return;
52
+ stylelint.utils.report({
53
+ ruleName,
54
+ result,
55
+ message: messages.rejected,
56
+ node: comment,
57
+ });
58
+ });
59
+ root.walkDecls((decl) => reportUnlessAllowed(decl, declRaw(decl)));
60
+ root.walkRules((styleRule) =>
61
+ reportUnlessAllowed(styleRule, ruleRaw(styleRule)),
62
+ );
63
+ root.walkAtRules((atRule) =>
64
+ reportUnlessAllowed(atRule, atRuleRaw(atRule)),
65
+ );
66
+ };
67
+
68
+ rule.ruleName = ruleName;
69
+ rule.messages = messages;
70
+
71
+ export default stylelint.createPlugin(ruleName, rule);