@sarj/eslint-plugin 19.15.0 → 19.17.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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  src_default
3
- } from "./chunk-SIHWYU24.js";
3
+ } from "./chunk-4USNCXB3.js";
4
4
  export {
5
5
  src_default as default
6
6
  };
@@ -0,0 +1,96 @@
1
+ // src/stylelint.ts
2
+ import stylelint from "stylelint";
3
+ import { parse, walk } from "@eslint/css-tree";
4
+ var NAME = "@sarj/no-modern-shorthand-reset";
5
+ var INITIAL = /* @__PURE__ */ new Set([
6
+ "auto",
7
+ "normal",
8
+ "normal normal",
9
+ "initial",
10
+ "unset"
11
+ ]);
12
+ var UNKNOWN = /* @__PURE__ */ new Set(["inherit", "revert", "revert-layer", "revert-rule"]);
13
+ var SHORTHANDS = /* @__PURE__ */ new Map([
14
+ ["transition-behavior", "transition"],
15
+ ["animation-timeline", "animation"],
16
+ ["animation-range", "animation"],
17
+ ["animation-range-start", "animation"],
18
+ ["animation-range-end", "animation"]
19
+ ]);
20
+ function restores(property, later) {
21
+ return later === property || property.startsWith("animation-range-") && later === "animation-range";
22
+ }
23
+ function resetBy(longhand, shorthand, declarations) {
24
+ if (longhand.important && !shorthand.important) return false;
25
+ const index = declarations.indexOf(shorthand);
26
+ if (index < declarations.indexOf(longhand)) return false;
27
+ const value = shorthand.value.trim().toLowerCase();
28
+ if (value === "none" || INITIAL.has(longhand.value.trim().toLowerCase()) || hasUnknownValue(value) || hasUnknownValue(longhand.value))
29
+ return false;
30
+ if (declarations.slice(index + 1).some(
31
+ (declaration) => restores(longhand.prop.toLowerCase(), declaration.prop.toLowerCase()) && (!shorthand.important || declaration.important)
32
+ ))
33
+ return false;
34
+ if (longhand.prop.toLowerCase() === "animation-range" && ["animation-range-start", "animation-range-end"].every(
35
+ (property) => declarations.slice(index + 1).some(
36
+ (declaration) => declaration.prop.toLowerCase() === property && (!shorthand.important || declaration.important)
37
+ )
38
+ ))
39
+ return false;
40
+ let discrete = false;
41
+ if (shorthand.prop.toLowerCase() === "transition") {
42
+ walk(parse(value, { context: "value" }), (node) => {
43
+ if (node.type === "Identifier" && node.name.toLowerCase() === "allow-discrete")
44
+ discrete = true;
45
+ });
46
+ }
47
+ return !discrete;
48
+ }
49
+ function hasUnknownValue(value) {
50
+ let unknown = UNKNOWN.has(value);
51
+ try {
52
+ walk(parse(value, { context: "value" }), (node) => {
53
+ if (node.type === "Function" && ["var", "env"].includes(node.name.toLowerCase()))
54
+ unknown = true;
55
+ });
56
+ } catch {
57
+ unknown = true;
58
+ }
59
+ return unknown;
60
+ }
61
+ var rule = (enabled) => (root, result) => {
62
+ if (!stylelint.utils.validateOptions(result, NAME, { actual: enabled })) return;
63
+ root.walkRules((block) => {
64
+ const declarations = block.nodes.filter((node) => node.type === "decl");
65
+ const effective = /* @__PURE__ */ new Map();
66
+ for (const declaration of declarations) {
67
+ const property = declaration.prop.toLowerCase();
68
+ const previous = effective.get(property);
69
+ if (!previous?.important || declaration.important) effective.set(property, declaration);
70
+ }
71
+ const reported = /* @__PURE__ */ new Set();
72
+ for (const [property, longhand] of effective) {
73
+ const shorthand = SHORTHANDS.get(property);
74
+ const reset = shorthand === void 0 ? void 0 : effective.get(shorthand);
75
+ if (reset === void 0 || reported.has(reset) || !resetBy(longhand, reset, declarations))
76
+ continue;
77
+ reported.add(reset);
78
+ stylelint.utils.report({
79
+ ruleName: NAME,
80
+ result,
81
+ node: reset,
82
+ word: reset.prop,
83
+ message: `${reset.prop} resets ${longhand.prop}. Put the intended longhand after the shorthand.`
84
+ });
85
+ }
86
+ });
87
+ };
88
+ rule.ruleName = NAME;
89
+ rule.messages = { reset: "A later shorthand resets a modern longhand." };
90
+ rule.meta = {
91
+ url: "https://github.com/sarj-ai/code-standards/tree/main/plugins/sarj-skills/skills/lint-rule-generator/references/modern-web-guidance.md"
92
+ };
93
+ var stylelint_default = stylelint.createPlugin(NAME, rule);
94
+ export {
95
+ stylelint_default as default
96
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/eslint-plugin",
3
- "version": "19.15.0",
3
+ "version": "19.17.0",
4
4
  "packageManager": "npm@12.2.1",
5
5
  "description": "Custom Oxlint rules for hypermodern TypeScript / React / Next.js projects",
6
6
  "type": "module",
@@ -44,6 +44,10 @@
44
44
  },
45
45
  "./next": {
46
46
  "import": "./dist/next.js"
47
+ },
48
+ "./stylelint": {
49
+ "import": "./dist/stylelint.js",
50
+ "default": "./dist/stylelint.js"
47
51
  }
48
52
  },
49
53
  "files": [
@@ -97,7 +101,9 @@
97
101
  "oxlint": "1.91.0",
98
102
  "oxlint-plugin-eslint": "1.91.0",
99
103
  "oxlint-plugin-react-doctor": "0.9.22",
104
+ "postcss": "8.5.31",
100
105
  "prettier": "3.9.10",
106
+ "stylelint": "18.0.0",
101
107
  "syncpack": "15.3.3",
102
108
  "tsrs": "0.23.0-ts7.1.0-beta",
103
109
  "tsup": "9.0.0",
@@ -107,6 +113,7 @@
107
113
  "zod": "4.6.7"
108
114
  },
109
115
  "peerDependencies": {
116
+ "stylelint": "^18.0.0",
110
117
  "tsrs": ">=0.23.0-ts7.1.0-beta",
111
118
  "typescript": ">=5.6.0 <7"
112
119
  },
@@ -123,6 +130,9 @@
123
130
  "nanoid@<3.3.20": "3.3.20"
124
131
  },
125
132
  "peerDependenciesMeta": {
133
+ "stylelint": {
134
+ "optional": true
135
+ },
126
136
  "typescript": {
127
137
  "optional": true
128
138
  }