@storm-software/eslint-plugin-banner 0.0.25 → 0.0.26

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.
@@ -1,4 +1,4 @@
1
- import { t as plugin } from "../plugin-CYXvSthy.mjs";
1
+ import { t as plugin } from "../plugin-D8pEXRmR.mjs";
2
2
  import { GLOB_EXCLUDE, GLOB_SRC } from "@storm-software/package-constants/globs";
3
3
  //#region src/configs/recommended.ts
4
4
  const config = {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as plugin } from "./plugin-CYXvSthy.mjs";
1
+ import { t as plugin } from "./plugin-D8pEXRmR.mjs";
2
2
  import { configs } from "./configs/index.mjs";
3
3
  //#region src/index.ts
4
4
  /**
@@ -4,7 +4,7 @@ import banner_default from "./rules/banner.mjs";
4
4
  const plugin = {
5
5
  meta: {
6
6
  name: "banner",
7
- version: "0.0.24"
7
+ version: "0.0.25"
8
8
  },
9
9
  rules: { banner: banner_default }
10
10
  };
package/dist/plugin.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as plugin } from "./plugin-CYXvSthy.mjs";
1
+ import { t as plugin } from "./plugin-D8pEXRmR.mjs";
2
2
  export { plugin };
@@ -21,7 +21,7 @@ function excludeShebangs(comments) {
21
21
  */
22
22
  function getLeadingComments(context, node) {
23
23
  const firstBodyNode = Array.isArray(node.body) && node.body.length ? node.body[0] : node;
24
- const all = excludeShebangs(context.getSourceCode().getAllComments(firstBodyNode));
24
+ const all = excludeShebangs((context.sourceCode || context.getSourceCode()).getAllComments(firstBodyNode));
25
25
  if (!all.length) return [];
26
26
  if (all[0] && all[0].type.toLowerCase() === "block") return [all[0]];
27
27
  let i = 1;
@@ -29,7 +29,7 @@ function getLeadingComments(context, node) {
29
29
  const prev = all[i - 1];
30
30
  const current = all[i];
31
31
  if (!prev || !current) break;
32
- if (!context.getSourceCode().getText().slice(prev.range[1], current.range[0]).match(/^(\r\n|\r|\n)$/)) break;
32
+ if (!(context.sourceCode || context.getSourceCode()).getText().slice(prev.range[1], current.range[0]).match(/^(\r\n|\r|\n)$/)) break;
33
33
  }
34
34
  return all.slice(0, i);
35
35
  }
@@ -42,7 +42,7 @@ function genCommentsRange(context, comments, eol) {
42
42
  if (!comments[0]) return [0, 0];
43
43
  const start = comments[0].range[0];
44
44
  let end = comments.slice(-1)[0]?.range[1] ?? start;
45
- if (context.getSourceCode().text[end] === eol) end += eol.length;
45
+ if ((context.sourceCode || context.getSourceCode()).text[end] === eol) end += eol.length;
46
46
  return [start, end];
47
47
  }
48
48
  function genPrependFixer(commentStyle, node, bannerLines, eol, newlines) {
@@ -167,7 +167,7 @@ var banner_default = createRule({
167
167
  let fixLines = bannerLines;
168
168
  return { Program(node) {
169
169
  const normalizedNewlines = newlines ?? 1;
170
- if (!hasBanner(normalizedCommentStyle, context.sourceCode.getText(), eol)) context.report({
170
+ if (!hasBanner(normalizedCommentStyle, (context.sourceCode || context.getSourceCode()).getText(), eol)) context.report({
171
171
  loc: node.loc,
172
172
  messageId: "missingBanner",
173
173
  fix: genPrependFixer(normalizedCommentStyle, node, fixLines, eol, normalizedNewlines)
@@ -218,7 +218,7 @@ var banner_default = createRule({
218
218
  }
219
219
  const lastLeadingComment = leadingComments[bannerLines.length - 1] ?? leadingComments[leadingComments.length - 1];
220
220
  if (!lastLeadingComment) return;
221
- if (!matchesLineEndings(context.sourceCode.text.substr(lastLeadingComment.range[1], normalizedNewlines * 2), normalizedNewlines)) context.report({
221
+ if (!matchesLineEndings((context.sourceCode || context.getSourceCode()).text.substr(lastLeadingComment.range[1], normalizedNewlines * 2), normalizedNewlines)) context.report({
222
222
  loc: node.loc,
223
223
  messageId: "noNewlineAfterBanner",
224
224
  fix: genReplaceFixer(normalizedCommentStyle, context, leadingComments, fixLines, eol, normalizedNewlines)
@@ -238,7 +238,7 @@ var banner_default = createRule({
238
238
  messageId: "incorrectBanner",
239
239
  fix: genReplaceFixer(normalizedCommentStyle, context, leadingComments, fixLines, eol, normalizedNewlines)
240
240
  });
241
- } else if (!matchesLineEndings(context.sourceCode.text.substr(firstLeadingComment.range[1], normalizedNewlines * 2), normalizedNewlines)) context.report({
241
+ } else if (!matchesLineEndings((context.sourceCode || context.getSourceCode()).text.substr(firstLeadingComment.range[1], normalizedNewlines * 2), normalizedNewlines)) context.report({
242
242
  loc: node.loc,
243
243
  messageId: "noNewlineAfterBanner",
244
244
  fix: genReplaceFixer(normalizedCommentStyle, context, leadingComments, fixLines, eol, normalizedNewlines)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/eslint-plugin-banner",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "private": false,
5
5
  "description": "An ESLint Plugin that enforces the existence of file banners in Storm Software projects.",
6
6
  "keywords": ["eslint", "eslint-plugin", "storm-software"],
@@ -53,14 +53,14 @@
53
53
  "typings": "dist/index.d.mts",
54
54
  "files": ["dist", "docs"],
55
55
  "dependencies": {
56
- "@storm-software/package-constants": "0.1.74",
56
+ "@storm-software/package-constants": "^0.1.74",
57
57
  "@typescript-eslint/utils": "^8.61.0",
58
58
  "defu": "^6.1.7"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@eslint/compat": "^2.1.0",
62
62
  "@eslint/config-inspector": "^1.5.0",
63
- "@storm-software/prettier": "0.59.114",
63
+ "@storm-software/prettier": "^0.59.114",
64
64
  "@types/eslint": "^9.6.1",
65
65
  "@types/eslint__js": "^8.42.3",
66
66
  "@types/node": "^25.9.3",
@@ -76,5 +76,5 @@
76
76
  "peerDependencies": { "eslint": ">=9.39.3" },
77
77
  "peerDependenciesMeta": { "eslint": { "optional": false } },
78
78
  "publishConfig": { "access": "public" },
79
- "gitHead": "ade45f9094482001d24bbd6778a45eee59afc076"
79
+ "gitHead": "679dea48cf6192e6df471e5d9b810c7828a96b89"
80
80
  }