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