@podman-desktop/eslint-plugin 0.2.0 → 0.3.0-next.202603061658-1db9d75
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 +122 -80
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,63 +1,102 @@
|
|
|
1
|
-
import { execFileSync as
|
|
2
|
-
import { lstatSync as
|
|
3
|
-
import { resolve as
|
|
4
|
-
const
|
|
5
|
-
version:
|
|
1
|
+
import { execFileSync as p } from "node:child_process";
|
|
2
|
+
import { lstatSync as O, readFileSync as P } from "node:fs";
|
|
3
|
+
import { resolve as l } from "node:path";
|
|
4
|
+
const L = "0.3.0-next.202603061658-1db9d75", $ = {
|
|
5
|
+
version: L
|
|
6
6
|
};
|
|
7
|
-
let Y,
|
|
8
|
-
function
|
|
9
|
-
|
|
7
|
+
let S, Y, d, f, y = !1, T;
|
|
8
|
+
function A() {
|
|
9
|
+
return process.env.GITHUB_ACTIONS === "true" && process.env.GITHUB_EVENT_NAME === "pull_request";
|
|
10
|
+
}
|
|
11
|
+
function H() {
|
|
12
|
+
const e = process.env.GITHUB_REF;
|
|
13
|
+
if (e) {
|
|
14
|
+
const t = /^refs\/pull\/(\d+)\/merge$/.exec(e);
|
|
15
|
+
if (t) return t[1];
|
|
16
|
+
}
|
|
17
|
+
const r = process.env.GITHUB_EVENT_PATH;
|
|
18
|
+
if (r)
|
|
19
|
+
try {
|
|
20
|
+
const t = JSON.parse(P(r, "utf-8"));
|
|
21
|
+
if (t?.pull_request?.number) return String(t.pull_request.number);
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _(e) {
|
|
26
|
+
if (!A()) return !1;
|
|
27
|
+
const r = H();
|
|
28
|
+
if (!r) return !1;
|
|
29
|
+
const t = process.env.GITHUB_REPOSITORY;
|
|
30
|
+
if (!t) return !1;
|
|
31
|
+
try {
|
|
32
|
+
const i = p(
|
|
33
|
+
"gh",
|
|
34
|
+
["api", "--paginate", `repos/${t}/pulls/${r}/files`, "--jq", ".[].filename"],
|
|
35
|
+
{ stdio: "pipe", encoding: "utf-8" }
|
|
36
|
+
), s = /* @__PURE__ */ new Set();
|
|
37
|
+
for (const n of i.split(`
|
|
38
|
+
`))
|
|
39
|
+
n && s.add(l(e, n));
|
|
40
|
+
return T = s, y = !0, !0;
|
|
41
|
+
} catch {
|
|
42
|
+
return !1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function v() {
|
|
46
|
+
if (f !== void 0) return;
|
|
10
47
|
try {
|
|
11
|
-
|
|
48
|
+
d = p("git", ["rev-parse", "--show-toplevel"], {
|
|
12
49
|
stdio: "pipe",
|
|
13
50
|
encoding: "utf-8"
|
|
14
|
-
}).trim(),
|
|
51
|
+
}).trim(), f = !0;
|
|
15
52
|
} catch {
|
|
16
|
-
|
|
53
|
+
f = !1;
|
|
17
54
|
return;
|
|
18
55
|
}
|
|
56
|
+
if (_(d))
|
|
57
|
+
return;
|
|
19
58
|
const e = /* @__PURE__ */ new Map();
|
|
20
|
-
|
|
21
|
-
const
|
|
59
|
+
S = e;
|
|
60
|
+
const r = d;
|
|
22
61
|
try {
|
|
23
|
-
const i =
|
|
62
|
+
const i = p(
|
|
24
63
|
"git",
|
|
25
64
|
["log", "--format=format:COMMIT:%ad", "--date=format:%Y", "--name-only", "--diff-filter=ACDMRT"],
|
|
26
65
|
{ stdio: "pipe", encoding: "utf-8", maxBuffer: 52428800 }
|
|
27
66
|
);
|
|
28
|
-
let
|
|
29
|
-
for (const
|
|
67
|
+
let s;
|
|
68
|
+
for (const n of i.split(`
|
|
30
69
|
`))
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
33
|
-
|
|
70
|
+
if (n) {
|
|
71
|
+
if (n.startsWith("COMMIT:")) {
|
|
72
|
+
s = Number(n.slice(7));
|
|
34
73
|
continue;
|
|
35
74
|
}
|
|
36
|
-
if (
|
|
37
|
-
const o =
|
|
38
|
-
e.has(o) || e.set(o,
|
|
75
|
+
if (s !== void 0) {
|
|
76
|
+
const o = l(r, n);
|
|
77
|
+
e.has(o) || e.set(o, s);
|
|
39
78
|
}
|
|
40
79
|
}
|
|
41
80
|
} catch {
|
|
42
|
-
|
|
81
|
+
f = !1;
|
|
43
82
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
83
|
+
const t = /* @__PURE__ */ new Set();
|
|
84
|
+
Y = t;
|
|
46
85
|
try {
|
|
47
|
-
const i =
|
|
86
|
+
const i = p("git", ["status", "--porcelain"], {
|
|
48
87
|
stdio: "pipe",
|
|
49
88
|
encoding: "utf-8"
|
|
50
89
|
});
|
|
51
|
-
for (const
|
|
90
|
+
for (const s of i.split(`
|
|
52
91
|
`)) {
|
|
53
|
-
if (!
|
|
54
|
-
const
|
|
55
|
-
|
|
92
|
+
if (!s || s.length < 4) continue;
|
|
93
|
+
const n = s.slice(3), o = n.indexOf(" -> "), c = o !== -1 ? n.slice(o + 4) : n;
|
|
94
|
+
t.add(l(r, c));
|
|
56
95
|
}
|
|
57
96
|
} catch {
|
|
58
97
|
}
|
|
59
98
|
}
|
|
60
|
-
const
|
|
99
|
+
const D = [
|
|
61
100
|
"Copyright (C) {year} Red Hat, Inc.",
|
|
62
101
|
"",
|
|
63
102
|
'Licensed under the Apache License, Version 2.0 (the "License");',
|
|
@@ -73,45 +112,46 @@ const R = [
|
|
|
73
112
|
"limitations under the License.",
|
|
74
113
|
"",
|
|
75
114
|
"SPDX-License-Identifier: Apache-2.0"
|
|
76
|
-
],
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
115
|
+
], M = /Copyright \(C\) (\d{4})(?:[-,\s]+(\d{4}))* (.+)/;
|
|
116
|
+
function G(e) {
|
|
117
|
+
if (v(), y)
|
|
118
|
+
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
119
|
+
const r = l(e);
|
|
120
|
+
if (Y?.has(r))
|
|
81
121
|
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
85
|
-
const i =
|
|
122
|
+
const t = S?.get(r);
|
|
123
|
+
if (t !== void 0)
|
|
124
|
+
return t;
|
|
125
|
+
const i = O(e, { throwIfNoEntry: !1 });
|
|
86
126
|
return i ? i.mtime.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear();
|
|
87
127
|
}
|
|
88
|
-
function
|
|
128
|
+
function j(e) {
|
|
89
129
|
return /\.ya?ml$/i.test(e);
|
|
90
130
|
}
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
return
|
|
131
|
+
const B = /\.(svelte|md)$/i;
|
|
132
|
+
function U(e) {
|
|
133
|
+
return B.test(e);
|
|
94
134
|
}
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
135
|
+
function q(e, r) {
|
|
136
|
+
const t = D.map((n) => n.replace("{year}", e));
|
|
137
|
+
if (j(r)) {
|
|
138
|
+
const n = "#" + "*".repeat(79), o = t.map((c) => c === "" ? "#" : `# ${c}`).join(`
|
|
99
139
|
`);
|
|
100
|
-
return `${
|
|
140
|
+
return `${n}
|
|
101
141
|
${o}
|
|
102
|
-
${
|
|
142
|
+
${n}
|
|
103
143
|
|
|
104
144
|
`;
|
|
105
145
|
}
|
|
106
|
-
const i = "*".repeat(79),
|
|
146
|
+
const i = "*".repeat(79), s = t.map((n) => n === "" ? " *" : ` * ${n}`).join(`
|
|
107
147
|
`);
|
|
108
148
|
return `/${i}
|
|
109
|
-
${
|
|
149
|
+
${s}
|
|
110
150
|
${i}/
|
|
111
151
|
|
|
112
152
|
`;
|
|
113
153
|
}
|
|
114
|
-
const
|
|
154
|
+
const k = {
|
|
115
155
|
meta: {
|
|
116
156
|
type: "suggestion",
|
|
117
157
|
docs: {
|
|
@@ -125,67 +165,69 @@ const H = {
|
|
|
125
165
|
}
|
|
126
166
|
},
|
|
127
167
|
create(e) {
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
168
|
+
const r = e.filename;
|
|
169
|
+
if (U(r))
|
|
170
|
+
return {};
|
|
171
|
+
if (v(), y && !T?.has(l(d ?? "", r)))
|
|
130
172
|
return {};
|
|
131
|
-
let
|
|
173
|
+
let t;
|
|
132
174
|
function i() {
|
|
133
|
-
return
|
|
175
|
+
return t === void 0 && (t = G(r)), t;
|
|
134
176
|
}
|
|
135
177
|
return {
|
|
136
|
-
Program(
|
|
178
|
+
Program(s) {
|
|
137
179
|
const o = e.sourceCode.getText(), c = o.split(`
|
|
138
180
|
`).slice(0, 30).join(`
|
|
139
|
-
`), a =
|
|
181
|
+
`), a = M.exec(c);
|
|
140
182
|
if (!a) {
|
|
141
183
|
e.report({
|
|
142
|
-
node:
|
|
184
|
+
node: s,
|
|
143
185
|
messageId: "missingHeader",
|
|
144
|
-
fix(
|
|
145
|
-
const
|
|
146
|
-
return
|
|
186
|
+
fix(h) {
|
|
187
|
+
const F = q(String((/* @__PURE__ */ new Date()).getFullYear()), r);
|
|
188
|
+
return h.insertTextBeforeRange([0, 0], F);
|
|
147
189
|
}
|
|
148
190
|
});
|
|
149
191
|
return;
|
|
150
192
|
}
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
193
|
+
const g = Number.parseInt(a[1], 10), I = (a[2] ? Number.parseInt(a[2], 10) : null) ?? g, u = (/* @__PURE__ */ new Date()).getFullYear();
|
|
194
|
+
if (I >= u)
|
|
153
195
|
return;
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
196
|
+
const E = i();
|
|
197
|
+
if (I >= E)
|
|
156
198
|
return;
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
199
|
+
const m = o.indexOf(a[0]);
|
|
200
|
+
if (m === -1) return;
|
|
201
|
+
const b = 14, N = a[3].length + 1, w = m + b, C = m + a[0].length - N, R = g === u ? String(u) : `${g}-${u}`;
|
|
160
202
|
e.report({
|
|
161
|
-
node:
|
|
203
|
+
node: s,
|
|
162
204
|
messageId: "outdatedYear",
|
|
163
|
-
fix(
|
|
164
|
-
return
|
|
205
|
+
fix(h) {
|
|
206
|
+
return h.replaceTextRange([w, C], R);
|
|
165
207
|
}
|
|
166
208
|
});
|
|
167
209
|
}
|
|
168
210
|
};
|
|
169
211
|
}
|
|
170
|
-
},
|
|
212
|
+
}, x = {
|
|
171
213
|
meta: {
|
|
172
214
|
name: "@podman-desktop/eslint-plugin",
|
|
173
|
-
version:
|
|
215
|
+
version: $.version
|
|
174
216
|
},
|
|
175
217
|
rules: {
|
|
176
|
-
copyright:
|
|
218
|
+
copyright: k
|
|
177
219
|
},
|
|
178
220
|
configs: {}
|
|
179
|
-
},
|
|
180
|
-
|
|
221
|
+
}, V = x.configs;
|
|
222
|
+
V.recommended = {
|
|
181
223
|
files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
182
224
|
plugins: {
|
|
183
|
-
"@podman-desktop/eslint-plugin":
|
|
225
|
+
"@podman-desktop/eslint-plugin": x
|
|
184
226
|
},
|
|
185
227
|
rules: {
|
|
186
228
|
"@podman-desktop/eslint-plugin/copyright": "error"
|
|
187
229
|
}
|
|
188
230
|
};
|
|
189
231
|
export {
|
|
190
|
-
|
|
232
|
+
x as default
|
|
191
233
|
};
|