@tony.ganchev/eslint-plugin-header 3.2.4 → 3.2.6

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,8 +1,8 @@
1
- /*
2
- * MIT License
3
- *
4
- * Copyright (c) 2025-present Tony Ganchev and contributors
5
- *
1
+ /**
2
+ * @file Schema definition for `header` rule.
3
+ * @copyright Copyright (c) 2015-present Stuart Knightley and contributors
4
+ * @copyright Copyright (c) 2025-2026 Tony Ganchev
5
+ * @license MIT
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the “Software”), to deal
8
8
  * in the Software without restriction, including without limitation the rights
@@ -22,6 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+
25
26
  "use strict";
26
27
 
27
28
  /**
@@ -41,7 +42,7 @@ const commentTypeOptions = Object.freeze({
41
42
  line: "line"
42
43
  });
43
44
 
44
- /** @type {import('json-schema').JSONSchema4} */
45
+ /** @type {import("json-schema").JSONSchema4} */
45
46
  const schema = Object.freeze({
46
47
  $ref: "#/definitions/options",
47
48
  definitions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tony.ganchev/eslint-plugin-header",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "description": "The native ESLint 9/10 header plugin. A zero-bloat, drop-in replacement for 'eslint-plugin-header' with first-class Flat Config & TypeScript support. Auto-fix Copyright, License, and banner comments in JavaScrip and TypeScript files.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,38 +17,29 @@
17
17
  "types",
18
18
  "CONTRIBUTING.md"
19
19
  ],
20
- "scripts": {
21
- "build": "npx tsc",
22
- "e2e": "npm run build && npx mocha --timeout 60000 tests/e2e/*.js",
23
- "eslint": "npx eslint .",
24
- "lint": "npm run eslint && npm run markdownlint",
25
- "markdownlint": "npx markdownlint-cli *.md",
26
- "test": "npm run lint && npm run unit && npm run e2e",
27
- "unit": "npx nyc --reporter=html --reporter=text --reporter=text-summary --reporter=lcov --check-coverage=true --statements=100 --branches=100 --lines=100 --functions=100 mocha tests/lib/*.js tests/lib/**/*.js"
28
- },
29
20
  "devDependencies": {
30
- "@eslint/eslintrc": "^3.3.3",
21
+ "@eslint/core": "^1.1.1",
31
22
  "@eslint/js": "^10.0.1",
32
23
  "@eslint/markdown": "^7.5.1",
33
- "@stylistic/eslint-plugin": "^5.8.0",
34
- "@types/node": "^25.2.3",
35
- "eslint": "^10.0.0",
36
- "eslint-plugin-eslint-plugin": "^7.3.0",
37
- "eslint-plugin-jsdoc": "^62.5.4",
38
- "eslint-plugin-n": "^17.23.2",
39
- "markdownlint-cli": "^0.47.0",
40
- "mocha": "^12.0.0-beta-9",
41
- "nyc": "^17.1.0",
24
+ "@stylistic/eslint-plugin": "^5.10.0",
25
+ "@types/estree": "^1.0.8",
26
+ "@types/json-schema": "^7.0.15",
27
+ "@types/node": "^25.3.5",
28
+ "c8": "^11.0.0",
29
+ "eslint": "^10.0.3",
30
+ "eslint-plugin-eslint-plugin": "^7.3.2",
31
+ "eslint-plugin-jsdoc": "^62.7.1",
32
+ "eslint-plugin-n": "^17.24.0",
33
+ "globals": "^17.4.0",
34
+ "markdownlint-cli": "^0.48.0",
35
+ "mocha": "12.0.0-beta-9",
42
36
  "testdouble": "^3.20.2",
43
37
  "typescript": "^5.9.3",
44
- "typescript-eslint": "^8.56.0"
38
+ "typescript-eslint": "^8.56.1"
45
39
  },
46
40
  "peerDependencies": {
47
41
  "eslint": ">=7.7.0"
48
42
  },
49
- "overrides": {
50
- "eslint": "^10.0.0"
51
- },
52
43
  "keywords": [
53
44
  "eslint",
54
45
  "eslint-plugin",
@@ -86,5 +77,14 @@
86
77
  "contributors": [
87
78
  "Josh Kelley",
88
79
  "Stuart Knightley"
89
- ]
90
- }
80
+ ],
81
+ "scripts": {
82
+ "build": "tsc",
83
+ "e2e": "pnpm build && mocha --timeout 60000 tests/e2e/*.js",
84
+ "eslint": "eslint .",
85
+ "lint": "pnpm eslint && pnpm markdownlint",
86
+ "markdownlint": "markdownlint *.md",
87
+ "test": "pnpm lint && pnpm unit && pnpm e2e",
88
+ "unit": "c8 --reporter=html --reporter=text --reporter=text-summary --reporter=lcov --check-coverage --100 mocha tests/lib/*.js tests/lib/**/*.js"
89
+ }
90
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export = pluginDefinition;
2
- /** @type {import('eslint').ESLint.Plugin} */
2
+ /** @type {import("eslint").ESLint.Plugin} */
3
3
  declare const pluginDefinition: import("eslint").ESLint.Plugin;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- declare function _exports(commentText: string): ["block" | "line", string[]];
1
+ declare function _exports(commentText: string): [import("./rules/header").CommentType, string[]];
2
2
  export = _exports;
3
3
  //# sourceMappingURL=comment-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"comment-parser.d.ts","sourceRoot":"","sources":["../../lib/comment-parser.js"],"names":[],"mappings":"AAsCiB,uCAJN,MAAM,GACJ,CAAC,OAAO,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAmBxC"}
1
+ {"version":3,"file":"comment-parser.d.ts","sourceRoot":"","sources":["../../lib/comment-parser.js"],"names":[],"mappings":"AAuCiB,uCALN,MAAM,GACJ,CAAC,OAAO,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAoB5D"}
@@ -1,100 +1,135 @@
1
1
  export { headerRule as header };
2
+ export type NodeListener = Rule.NodeListener;
3
+ export type ReportFixer = Rule.ReportFixer;
4
+ export type RuleFixer = Rule.RuleFixer;
5
+ export type RuleContext = Rule.RuleContext;
2
6
  /**
3
- * Import type definitions.
7
+ * The sequence of characters that define
8
+ * the end of a line.
4
9
  */
5
- export type Fix = import("eslint").Rule.Fix;
10
+ export type LineEnding = "\n" | "\r\n";
6
11
  /**
7
- * Import type definitions.
8
- */
9
- export type NodeListener = import("eslint").Rule.NodeListener;
10
- /**
11
- * Import type definitions.
12
- */
13
- export type ReportFixer = import("eslint").Rule.ReportFixer;
14
- /**
15
- * Import type definitions.
16
- */
17
- export type RuleFixer = import("eslint").Rule.RuleFixer;
18
- /**
19
- * Import type definitions.
20
- */
21
- export type RuleContext = import("eslint").Rule.RuleContext;
22
- /**
23
- * Import type definitions.
24
- */
25
- export type Comment = import("estree").Comment;
26
- /**
27
- * Import type definitions.
28
- */
29
- export type Program = import("estree").Program;
30
- /**
31
- * Import type definitions.
32
- */
33
- export type SourceLocation = import("estree").SourceLocation;
34
- /**
35
- * Local type definitions.
12
+ * Matching rule for a line from the header
13
+ * using regular expression and optionally providing an auto-fix replacement.
36
14
  */
37
15
  export type HeaderLinePattern = {
16
+ /**
17
+ * A regular expression that should match
18
+ * the header line.
19
+ */
38
20
  pattern: string | RegExp;
39
- template?: string;
21
+ /**
22
+ * When set, if the actual header line does not
23
+ * match `pattern`, this value is to be used when running auto-fix.
24
+ */
25
+ template?: string | undefined;
40
26
  };
41
27
  /**
42
- * Local type definitions.
28
+ * Matching rule for
29
+ * a single line of the header comment or the header comment as a whole if only
30
+ * one used.
43
31
  */
44
32
  export type HeaderLine = string | RegExp | HeaderLinePattern;
45
33
  /**
46
- * Local type definitions.
34
+ * The set of header comment-
35
+ * matching rules.
47
36
  */
48
37
  export type HeaderLines = HeaderLine | HeaderLine[];
49
38
  /**
50
- * Local type definitions.
39
+ * Defines what EOL
40
+ * characters to expect - either forced to be Windows / POSIX-compatible, or
41
+ * defaulting to whatever the OS expects.
51
42
  */
52
43
  export type LineEndingOption = "os" | "unix" | "windows";
53
44
  /**
54
- * Local type definitions.
45
+ * How to treat
46
+ * line endings.
55
47
  */
56
48
  export type HeaderSettings = {
57
49
  lineEndings?: LineEndingOption;
58
50
  };
59
51
  /**
60
- * Local type definitions.
52
+ * The expected type of comment to use
53
+ * for the header.
61
54
  */
62
55
  export type CommentType = "block" | "line";
63
56
  /**
64
- * Local type definitions.
57
+ * Header content configuration defined in a
58
+ * separate JavaScript template file.
65
59
  */
66
60
  export type FileBasedConfig = {
61
+ /**
62
+ * Template file path relative to the directory
63
+ * from which ESLint runs.
64
+ */
67
65
  file: string;
68
- encoding?: BufferEncoding;
66
+ /**
67
+ * Encoding to use when reading the
68
+ * file. If omitted, `"utf8"` will be assumed.
69
+ */
70
+ encoding?: BufferEncoding | undefined;
69
71
  };
70
72
  /**
71
- * Local type definitions.
73
+ * Header content configuration defined inline
74
+ * within the ESLint configuration.
72
75
  */
73
76
  export type InlineConfig = {
77
+ /**
78
+ * The type of comment to expect.
79
+ */
74
80
  commentType: CommentType;
81
+ /**
82
+ * Matching rules for lines. If only one rule
83
+ * is provided, the rule would attempt to match either the first line ar all
84
+ * lines together.
85
+ */
75
86
  lines: HeaderLine[];
76
87
  };
77
88
  /**
78
- * Local type definitions.
89
+ * Rule configuration on the handling of
90
+ * empty lines after the header comment.
79
91
  */
80
92
  export type TrailingEmptyLines = {
81
- minimum?: number;
93
+ /**
94
+ * If set, the rule would check that at least
95
+ * a `minimum` number of EOL characters trail the header.
96
+ */
97
+ minimum?: number | undefined;
98
+ };
99
+ export type HeaderOptionsWithoutSettings = {
100
+ /**
101
+ * The text matching rules
102
+ * for the header.
103
+ */
104
+ header: FileBasedConfig | InlineConfig;
105
+ /**
106
+ * Rules about empty lines
107
+ * after the header comment.
108
+ */
109
+ trailingEmptyLines?: TrailingEmptyLines | undefined;
82
110
  };
83
111
  /**
84
- * Local type definitions.
112
+ * Modern
113
+ * object-based rule configuration.
85
114
  */
86
- export type HeaderOptions = {
87
- header: FileBasedConfig | InlineConfig;
88
- trailingEmptyLines?: TrailingEmptyLines;
89
- } & HeaderSettings;
115
+ export type HeaderOptions = HeaderOptionsWithoutSettings & HeaderSettings;
116
+ export type LegacyFileBasedConfig = [template: string];
117
+ export type LegacyFileBasedSettingsConfig = [template: string, settings: HeaderSettings];
118
+ export type LegacyInlineConfig = [type: CommentType, lines: HeaderLines];
119
+ export type LegacyInlineSettingsConfig = [type: CommentType, lines: HeaderLines, settings: HeaderSettings];
120
+ export type LegacyInlineMinLinesConfig = [type: CommentType, lines: HeaderLines, minLines: number];
121
+ export type LegacyInlineMinLinesSettingsConfig = [type: CommentType, lines: HeaderLines, minLines: number, settings: HeaderSettings];
90
122
  /**
91
- * Local type definitions.
123
+ * Full possible rule configuration options.
92
124
  */
93
- export type AllHeaderOptions = [HeaderOptions] | [template: string] | [template: string, settings: HeaderSettings] | [type: CommentType, lines: HeaderLines] | [type: CommentType, lines: HeaderLines, settings: HeaderSettings] | [type: CommentType, lines: HeaderLines, minLines: number] | [type: CommentType, lines: HeaderLines, minLines: number, settings: HeaderSettings];
125
+ export type AllHeaderOptions = [HeaderOptions] | LegacyFileBasedConfig | LegacyFileBasedSettingsConfig | LegacyInlineConfig | LegacyInlineSettingsConfig | LegacyInlineMinLinesConfig | LegacyInlineMinLinesSettingsConfig;
94
126
  /**
95
- * Local type definitions.
127
+ * Rule
128
+ * configuration array including severity.
96
129
  */
97
- export type HeaderRuleConfig = import("eslint").Linter.RuleEntry<AllHeaderOptions>;
98
- /** @type {import('eslint').Rule.RuleModule} */
99
- declare const headerRule: import("eslint").Rule.RuleModule;
130
+ export type HeaderRuleConfig = Linter.RuleEntry<AllHeaderOptions>;
131
+ /** @type {Rule.RuleModule} */
132
+ declare const headerRule: Rule.RuleModule;
133
+ import type { Rule } from "eslint";
134
+ import type { Linter } from "eslint";
100
135
  //# sourceMappingURL=header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../lib/rules/header.js"],"names":[],"mappings":";;;;kBAoCa,OAAO,QAAQ,EAAE,IAAI,CAAC,GAAG;;;;2BACzB,OAAO,QAAQ,EAAE,IAAI,CAAC,YAAY;;;;0BAClC,OAAO,QAAQ,EAAE,IAAI,CAAC,WAAW;;;;wBACjC,OAAO,QAAQ,EAAE,IAAI,CAAC,SAAS;;;;0BAC/B,OAAO,QAAQ,EAAE,IAAI,CAAC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GAC7B,kBAAkB,GAClB,0BAA0B,GAC1B,0BAA0B,GAC1B,kCAAkC;;;;;+BAK1B,iBAAiB,gBAAgB,CAAC;AA0sB/C,8BAA8B;AAC9B,0BADW,eAAe,CAuHxB;0BAv6B4D,QAAQ;4BAAR,QAAQ"}
@@ -15,6 +15,6 @@ export const commentTypeOptions: Readonly<{
15
15
  block: "block";
16
16
  line: "line";
17
17
  }>;
18
- /** @type {import('json-schema').JSONSchema4} */
18
+ /** @type {import("json-schema").JSONSchema4} */
19
19
  export const schema: import("json-schema").JSONSchema4;
20
20
  //# sourceMappingURL=header.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.schema.d.ts","sourceRoot":"","sources":["../../../lib/rules/header.schema.js"],"names":[],"mappings":"gCA2BU,MAAM;AADhB;;GAEG;AACH;;;;GAIG;iCAGO,MAAM;AADhB;;GAEG;AACH;;;GAGG;AAEH,gDAAgD;AAChD,qBADW,OAAO,aAAa,EAAE,WAAW,CAwKzC"}
1
+ {"version":3,"file":"header.schema.d.ts","sourceRoot":"","sources":["../../../lib/rules/header.schema.js"],"names":[],"mappings":"gCA4BU,MAAM;AADhB;;GAEG;AACH;;;;GAIG;iCAGO,MAAM;AADhB;;GAEG;AACH;;;GAGG;AAEH,gDAAgD;AAChD,qBADW,OAAO,aAAa,EAAE,WAAW,CAwKzC"}