@heyramzi/lint 2.4.3 → 2.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyramzi/lint",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "Shared oxlint rules, base config and gates for Studio projects",
5
5
  "license": "MIT",
6
6
  "repository": {
package/register.js CHANGED
@@ -22,6 +22,8 @@
22
22
  * Bands are counted, never typed. `scripts/measure-register.mjs` recounts them from the corpora named in each band's `source`, and the corpora are the ones humanizer `references/voice-measured.md` records.
23
23
  */
24
24
 
25
+ import { withoutCode } from "#lint/slop-views.js";
26
+
25
27
  const SENTENCE_SPLIT = /[.!?]+["'”’)]*(?:\s+|$)/;
26
28
  const CONTRACTION = /\b[\w]+['’](?:s|t|re|ve|ll|d|m)\b/gi;
27
29
  const SECOND_PERSON = /\b(?:you|your|yours|you're|you've|you'll|you'd|yourself)\b/gi;
@@ -29,7 +31,9 @@ const FIRST_PERSON = /\b(?:i|me|my|mine|myself|i'm|i've|i'll|i'd)\b/gi;
29
31
  const CHAINING = /\b(?:and|so|because|but)\b/gi;
30
32
 
31
33
  /** Counts only. No judgement, so a caller can report without a band. */
32
- export function measureRegister(text) {
34
+ export function measureRegister(copy) {
35
+ // A formula's commas aren't prose (TSK-1388).
36
+ const text = withoutCode(copy);
33
37
  const sentences = text
34
38
  .split(SENTENCE_SPLIT)
35
39
  .map((s) => s.trim())
@@ -78,6 +78,41 @@ function npmTrustedPublish(lines) {
78
78
  return /^\s*id-token\s*:\s*write\b/m.test(code) && /\bnpm\s+publish\b/.test(code);
79
79
  }
80
80
 
81
+ // A VPS runner's default MemoryMax (vps.md); a bigger Node heap can't run there.
82
+ const RUNNER_MEMORY_MB = 2560;
83
+
84
+ /** The first and past-the-end line of the job under `jobs:` that holds this line. */
85
+ function jobRange(lines, index) {
86
+ const header = /^ {2}[\w-]+\s*:/;
87
+ let end = index + 1;
88
+ while (end < lines.length && !header.test(lines[end]) && !/^\S/.test(lines[end])) end++;
89
+ let start = index;
90
+ while (start > 0 && !header.test(lines[start])) start--;
91
+ return { start, end };
92
+ }
93
+
94
+ /** A job that asks Node for more heap than a VPS runner holds may run hosted. */
95
+ function outgrowsRunner(lines, index) {
96
+ const { start, end } = jobRange(lines, index);
97
+ return lines.slice(start, end).some((line) => {
98
+ const heap = /--max-old-space-size=(\d+)/.exec(yamlCode(line));
99
+ return heap && Number(heap[1]) > RUNNER_MEMORY_MB;
100
+ });
101
+ }
102
+
103
+ /** Whether the job holding this line runs on a hosted runner. */
104
+ function hostedJob(lines, index) {
105
+ const { start, end } = jobRange(lines, index);
106
+ for (let at = start; at < end; at++) {
107
+ const runsOn = /^\s*runs-on\s*:\s*(.*)$/.exec(yamlCode(lines[at]));
108
+ if (runsOn) {
109
+ const value = runsOnValue(lines, at, runsOn[1].trim());
110
+ return HOSTED.test(value) && !value.includes("self-hosted");
111
+ }
112
+ }
113
+ return false;
114
+ }
115
+
81
116
  export function workflows(tree) {
82
117
  const found = [];
83
118
  for (const file of tree.touchedMatching(WORKFLOW)) {
@@ -94,15 +129,20 @@ export function workflows(tree) {
94
129
  const runsOn = /^\s*runs-on\s*:\s*(.*)$/.exec(line);
95
130
  if (runsOn) {
96
131
  const value = runsOnValue(lines, index, runsOn[1].trim());
97
- if (HOSTED.test(value) && !value.includes("self-hosted") && !hostedAllowed) {
132
+ if (
133
+ HOSTED.test(value) &&
134
+ !value.includes("self-hosted") &&
135
+ !hostedAllowed &&
136
+ !outgrowsRunner(lines, index)
137
+ ) {
98
138
  add(
99
139
  "workflow-runs-on",
100
140
  index,
101
- `runs-on ${value} is a hosted runner, and private repos burn the billed Actions allowance on them. Every job runs on our own hardware with no hosted fallback: runs-on: [self-hosted, Linux, X64, studio-linux], or [self-hosted, macOS, ARM64, studio-mac] for Xcode work only. Public forks keep hosted runners.`,
141
+ `runs-on ${value} is a hosted runner, and private repos burn the billed Actions allowance on them. Every job runs on our own hardware with no hosted fallback: runs-on: [self-hosted, Linux, X64, studio-linux], or [self-hosted, macOS, ARM64, studio-mac] for Xcode work only. Public forks keep hosted runners. The one exception is a job whose NODE_OPTIONS --max-old-space-size is over ${RUNNER_MEMORY_MB}, a VPS runner's memory cap.`,
102
142
  );
103
143
  }
104
144
  }
105
- if (NPMRC_WRITES.some((pattern) => pattern.test(line))) {
145
+ if (NPMRC_WRITES.some((pattern) => pattern.test(line)) && !hostedJob(lines, index)) {
106
146
  add(
107
147
  "workflow-npmrc-write",
108
148
  index,
package/slop-views.js CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  /*
14
- * those, every one of them inside a fence or a backtick span. Only the hashtag check reads this, because only it is confused by code.
14
+ * those, every one of them inside a fence or a backtick span. Every check that code confuses reads this: hashtags, bold, prose and the register rates.
15
15
  */
16
16
  export function withoutCode(text) {
17
17
  return (