@sister.software/oxlint-config 9.3.0 → 11.0.0

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.
Files changed (78) hide show
  1. package/README.md +198 -10
  2. package/out/browser-globals.d.ts +15 -0
  3. package/out/browser-globals.d.ts.map +1 -0
  4. package/out/browser-globals.js +76 -0
  5. package/out/browser-globals.js.map +1 -0
  6. package/out/console-padding-plugin.d.ts +16 -0
  7. package/out/console-padding-plugin.d.ts.map +1 -0
  8. package/out/console-padding-plugin.js +68 -0
  9. package/out/console-padding-plugin.js.map +1 -0
  10. package/out/constant-doc-plugin.d.ts +32 -0
  11. package/out/constant-doc-plugin.d.ts.map +1 -0
  12. package/out/constant-doc-plugin.js +91 -0
  13. package/out/constant-doc-plugin.js.map +1 -0
  14. package/out/headers-plugin.d.ts +6 -2
  15. package/out/headers-plugin.d.ts.map +1 -1
  16. package/out/headers-plugin.js +4 -2
  17. package/out/headers-plugin.js.map +1 -1
  18. package/out/index.d.ts +166 -13
  19. package/out/index.d.ts.map +1 -1
  20. package/out/index.js +332 -6
  21. package/out/index.js.map +1 -1
  22. package/out/jsdoc-plugin.d.ts +16 -0
  23. package/out/jsdoc-plugin.d.ts.map +1 -0
  24. package/out/jsdoc-plugin.js +68 -0
  25. package/out/jsdoc-plugin.js.map +1 -0
  26. package/out/length-truthiness-plugin.d.ts +18 -0
  27. package/out/length-truthiness-plugin.d.ts.map +1 -0
  28. package/out/length-truthiness-plugin.js +123 -0
  29. package/out/length-truthiness-plugin.js.map +1 -0
  30. package/out/multiline-statement-plugin.d.ts +18 -0
  31. package/out/multiline-statement-plugin.d.ts.map +1 -0
  32. package/out/multiline-statement-plugin.js +93 -0
  33. package/out/multiline-statement-plugin.js.map +1 -0
  34. package/out/padding-plugin.d.ts +4 -3
  35. package/out/padding-plugin.d.ts.map +1 -1
  36. package/out/padding-plugin.js +44 -27
  37. package/out/padding-plugin.js.map +1 -1
  38. package/out/padding-utils.d.ts +34 -0
  39. package/out/padding-utils.d.ts.map +1 -0
  40. package/out/padding-utils.js +50 -0
  41. package/out/padding-utils.js.map +1 -0
  42. package/out/plugin-types.d.ts +68 -3
  43. package/out/plugin-types.d.ts.map +1 -1
  44. package/out/plugin.d.ts.map +1 -1
  45. package/out/plugin.js +17 -0
  46. package/out/plugin.js.map +1 -1
  47. package/out/process-globals-plugin.d.ts.map +1 -1
  48. package/out/process-globals-plugin.js +6 -2
  49. package/out/process-globals-plugin.js.map +1 -1
  50. package/out/restrictions.d.ts +9 -3
  51. package/out/restrictions.d.ts.map +1 -1
  52. package/out/restrictions.js +4 -70
  53. package/out/restrictions.js.map +1 -1
  54. package/out/section-marker-plugin.d.ts +25 -0
  55. package/out/section-marker-plugin.d.ts.map +1 -0
  56. package/out/section-marker-plugin.js +234 -0
  57. package/out/section-marker-plugin.js.map +1 -0
  58. package/out/threshold-plugin.d.ts +27 -0
  59. package/out/threshold-plugin.d.ts.map +1 -0
  60. package/out/threshold-plugin.js +78 -0
  61. package/out/threshold-plugin.js.map +1 -0
  62. package/package.json +2 -2
  63. package/src/browser-globals.ts +77 -0
  64. package/src/console-padding-plugin.ts +76 -0
  65. package/src/constant-doc-plugin.ts +124 -0
  66. package/src/headers-plugin.ts +7 -3
  67. package/src/index.ts +490 -17
  68. package/src/jsdoc-plugin.ts +75 -0
  69. package/src/length-truthiness-plugin.ts +142 -0
  70. package/src/multiline-statement-plugin.ts +104 -0
  71. package/src/padding-plugin.ts +44 -29
  72. package/src/padding-utils.ts +70 -0
  73. package/src/plugin-types.ts +68 -3
  74. package/src/plugin.ts +22 -0
  75. package/src/process-globals-plugin.ts +6 -2
  76. package/src/restrictions.ts +16 -77
  77. package/src/section-marker-plugin.ts +306 -0
  78. package/src/threshold-plugin.ts +105 -0
@@ -10,16 +10,81 @@ export interface Comment {
10
10
  value: string;
11
11
  range: [number, number];
12
12
  }
13
- /** A loosely-typed AST node — only the fields the bundled rules read. */
13
+ /**
14
+ * A loosely-typed AST node — only the fields the bundled rules read.
15
+ */
14
16
  export interface AstNode {
15
17
  type: string;
16
18
  range: [number, number];
17
19
  parent?: AstNode;
18
- /** A statement-list body (block/program) is an array; a loop body is a single statement. */
20
+ /**
21
+ * A statement-list body (block/program) is an array; a loop body is a single statement.
22
+ */
19
23
  body?: AstNode[] | AstNode;
20
- /** `if`/`else` branches, for the require-braces rule. */
24
+ /**
25
+ * `if`/`else` branches, for the require-braces rule.
26
+ */
21
27
  consequent?: AstNode;
22
28
  alternate?: AstNode | null;
29
+ /**
30
+ * Binary/unary operator text, for the threshold rule.
31
+ */
32
+ operator?: string;
33
+ /**
34
+ * Binary-expression operands.
35
+ */
36
+ left?: AstNode;
37
+ right?: AstNode;
38
+ /**
39
+ * Unary-expression operand.
40
+ */
41
+ argument?: AstNode;
42
+ /**
43
+ * A literal's value, and its verbatim source text (`raw` preserves a `0x` prefix).
44
+ */
45
+ value?: unknown;
46
+ raw?: string;
47
+ /**
48
+ * `const` / `let` / `var`, for the constant-doc rule.
49
+ */
50
+ kind?: string;
51
+ /**
52
+ * Declarators of a variable declaration.
53
+ */
54
+ declarations?: AstNode[];
55
+ /**
56
+ * A declarator's binding identifier and initializer.
57
+ */
58
+ id?: AstNode;
59
+ init?: AstNode | null;
60
+ /**
61
+ * An identifier's name.
62
+ */
63
+ name?: string;
64
+ /**
65
+ * The condition of an `if`/`while`/`for`/ternary, for the length-truthiness rule.
66
+ */
67
+ test?: AstNode | null;
68
+ /**
69
+ * A member expression's accessed property.
70
+ */
71
+ property?: AstNode;
72
+ /**
73
+ * An expression statement's expression, for the console-padding rule.
74
+ */
75
+ expression?: AstNode;
76
+ /**
77
+ * An export statement's inner declaration, for the padding rules.
78
+ */
79
+ declaration?: AstNode | null;
80
+ /**
81
+ * A call expression's callee.
82
+ */
83
+ callee?: AstNode;
84
+ /**
85
+ * A member expression's object.
86
+ */
87
+ object?: AstNode;
23
88
  }
24
89
  export interface SourceCode {
25
90
  getText(): string;
@@ -1 +1 @@
1
- {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E,UAAU,CAAA;IACvB,aAAa,CAAC,IAAI,UAAU,CAAA;IAC5B,MAAM,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;CACzF;AAED,MAAM,WAAW,IAAI;IACpB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;QAAC,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAA;IACxF,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC,CAAA;CACrE;AAED,MAAM,WAAW,MAAM;IACtB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAG/C,QAAA,MAAM,oBAAoB,EAAE,MAQ3B,CAAA;AAED,eAAe,oBAAoB,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAU/C,QAAA,MAAM,oBAAoB,EAAE,MAkB3B,CAAA;AAED,eAAe,oBAAoB,CAAA"}
package/out/plugin.js CHANGED
@@ -6,16 +6,33 @@
6
6
  * names) exposing all of Sister Software's custom rules under the `sister-software/` namespace.
7
7
  */
8
8
  import { bracesRule } from "./braces-plugin.js";
9
+ import { consolePaddingRule } from "./console-padding-plugin.js";
10
+ import { requireConstantDocRule } from "./constant-doc-plugin.js";
9
11
  import { headerRule } from "./headers-plugin.js";
12
+ import { multilineJSDocRule } from "./jsdoc-plugin.js";
13
+ import { preferLengthTruthinessRule } from "./length-truthiness-plugin.js";
14
+ import { multilineStatementPaddingRule } from "./multiline-statement-plugin.js";
10
15
  import { paddingRule } from "./padding-plugin.js";
11
16
  import { noProcessGlobalsRule } from "./process-globals-plugin.js";
17
+ import { conciseSectionMarkerRule, maxRegionsRule, preferMarkCommentRule, preferRegionOverMarksRule, } from "./section-marker-plugin.js";
18
+ import { noUnnamedThresholdRule } from "./threshold-plugin.js";
12
19
  const sisterSoftwarePlugin = {
13
20
  meta: { name: "sister-software" },
14
21
  rules: {
15
22
  "require-file-header": headerRule,
16
23
  "padding-lines": paddingRule,
24
+ "console-padding": consolePaddingRule,
25
+ "multiline-statement-padding": multilineStatementPaddingRule,
17
26
  "require-braces": bracesRule,
18
27
  "no-process-globals": noProcessGlobalsRule,
28
+ "no-unnamed-threshold": noUnnamedThresholdRule,
29
+ "require-constant-doc": requireConstantDocRule,
30
+ "prefer-length-truthiness": preferLengthTruthinessRule,
31
+ "multiline-jsdoc": multilineJSDocRule,
32
+ "prefer-mark-comment": preferMarkCommentRule,
33
+ "concise-section-marker": conciseSectionMarkerRule,
34
+ "prefer-region-over-marks": preferRegionOverMarksRule,
35
+ "max-regions": maxRegionsRule,
19
36
  },
20
37
  };
21
38
  export default sisterSoftwarePlugin;
package/out/plugin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,WAAW,EA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;QAC5D,gBAAgB,EAAE,UAAU;QAC5B,oBAAoB,EAAE,oBAAoB;QAC1C,sBAAsB,EAAE,sBAAsB;QAC9C,sBAAsB,EAAE,sBAAsB;QAC9C,0BAA0B,EAAE,0BAA0B;QACtD,iBAAiB,EAAE,kBAAkB;QACrC,qBAAqB,EAAE,qBAAqB;QAC5C,wBAAwB,EAAE,wBAAwB;QAClD,0BAA0B,EAAE,yBAAyB;QACrD,aAAa,EAAE,cAAc;KAC7B;CACD,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"process-globals-plugin.d.ts","sourceRoot":"","sources":["../src/process-globals-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,mBAAmB,CAAA;AA+BtD,eAAO,MAAM,oBAAoB,EAAE,IAwBlC,CAAA;AAED,eAAe,oBAAoB,CAAA"}
1
+ {"version":3,"file":"process-globals-plugin.d.ts","sourceRoot":"","sources":["../src/process-globals-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAmCtD,eAAO,MAAM,oBAAoB,EAAE,IAwBlC,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -7,9 +7,13 @@
7
7
  * few blessed helpers; the helper files disable the rule (`sister-software/no-process-globals`).
8
8
  * oxlint has no `no-restricted-syntax`, so this is a small dedicated rule instead.
9
9
  */
10
- /** `process` members that must be reached through a blessed helper, not accessed directly. */
10
+ /**
11
+ * `process` members that must be reached through a blessed helper, not accessed directly.
12
+ */
11
13
  const RESTRICTED_MEMBERS = new Set(["env", "argv"]);
12
- /** The accessed member name for `process.env` (identifier) or `process["env"]` (string literal). */
14
+ /**
15
+ * The accessed member name for `process.env` (identifier) or `process["env"]` (string literal).
16
+ */
13
17
  function accessedMember(node) {
14
18
  const property = node.property;
15
19
  if (!property)
@@ -1 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KACxD;IACD,MAAM,CAAC,OAAO;QACb,OAAO;YACN,gBAAgB,CAAC,IAAI;gBACpB,MAAM,MAAM,GAAG,IAAkB,CAAA;gBAEjC,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;oBAAE,OAAM;gBAEpF,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;gBAEnC,IAAI,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,OAAM;gBAElD,OAAO,CAAC,MAAM,CAAC;oBACd,IAAI;oBACJ,OAAO,EAAE,oBAAoB,IAAI,gIAAgI;iBACjK,CAAC,CAAA;YACH,CAAC;SACD,CAAA;IACF,CAAC;CACD,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -17,7 +17,9 @@ export declare const RuntimePackageNamesRecord: {
17
17
  readonly worker: readonly ["worker"];
18
18
  };
19
19
  export type RuntimePackageNamesRecord = typeof RuntimePackageNamesRecord;
20
- /** Valid runtime names. */
20
+ /**
21
+ * Valid runtime names.
22
+ */
21
23
  export type RuntimeName = keyof RuntimePackageNamesRecord;
22
24
  /**
23
25
  * Given a package name, produces the glob matcher for files belonging to that package.
@@ -27,7 +29,9 @@ export type RuntimeName = keyof RuntimePackageNamesRecord;
27
29
  * @returns A single-element glob array, e.g. `["**\/client.{js,...}"]`.
28
30
  */
29
31
  export declare function createPackageFileMatcher(packageName: string): string[];
30
- /** A restricted-import entry: an exact module name plus the message shown when it is imported. */
32
+ /**
33
+ * A restricted-import entry: an exact module name plus the message shown when it is imported.
34
+ */
31
35
  export interface RestrictedPath {
32
36
  name: string;
33
37
  message: string;
@@ -42,7 +46,9 @@ export declare function ambiguousNodeBuiltinPaths(): RestrictedPath[];
42
46
  * must not assume a Node runtime at all.
43
47
  */
44
48
  export declare function allNodeBuiltinPaths(message: string): RestrictedPath[];
45
- /** A per-file-glob oxlint override: applies `rules` only to files matching `files`. */
49
+ /**
50
+ * A per-file-glob oxlint override: applies `rules` only to files matching `files`.
51
+ */
46
52
  export interface OxlintOverride {
47
53
  files: string[];
48
54
  rules: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"restrictions.d.ts","sourceRoot":"","sources":["../src/restrictions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;;CAK5B,CAAA;AAEV,MAAM,MAAM,yBAAyB,GAAG,OAAO,yBAAyB,CAAA;AAExE,2BAA2B;AAC3B,MAAM,MAAM,WAAW,GAAG,MAAM,yBAAyB,CAAA;AAEzD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtE;AAiBD,kGAAkG;AAClG,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,cAAc,EAAE,CAK5D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAErE;AA+ED,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AA6BD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,EAAE,CAqDjF"}
1
+ {"version":3,"file":"restrictions.d.ts","sourceRoot":"","sources":["../src/restrictions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;;CAK5B,CAAA;AAEV,MAAM,MAAM,yBAAyB,GAAG,OAAO,yBAAyB,CAAA;AAExE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,yBAAyB,CAAA;AAEzD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtE;AAmBD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,cAAc,EAAE,CAK5D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAErE;AAMD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,EAAE,CAqDjF"}
@@ -5,6 +5,7 @@
5
5
  * @file Platform-layering import restrictions, ported to oxlint's `no-restricted-imports`.
6
6
  */
7
7
  import { builtinModules } from "node:module";
8
+ import { restrictedBrowserGlobalsRule } from "./browser-globals.js";
8
9
  //#region Runtime data
9
10
  /**
10
11
  * Reserved package-name suffixes mapped to their target runtime.
@@ -28,7 +29,9 @@ export const RuntimePackageNamesRecord = {
28
29
  export function createPackageFileMatcher(packageName) {
29
30
  return [`**/${packageName}.{js,mjs,cjs,ts,d.ts,mts,tsx}`];
30
31
  }
31
- /** Joins a namespace and package name into a specifier, e.g. `@sister.software/client`. */
32
+ /**
33
+ * Joins a namespace and package name into a specifier, e.g. `@sister.software/client`.
34
+ */
32
35
  function namespaced(packageNamespace, packageName) {
33
36
  return [packageNamespace, packageName].filter(Boolean).join("/");
34
37
  }
@@ -53,75 +56,6 @@ export function ambiguousNodeBuiltinPaths() {
53
56
  export function allNodeBuiltinPaths(message) {
54
57
  return [...NODE_BUILTINS_NO_PREFIX, ...NODE_BUILTINS_PREFIXED].map((name) => ({ name, message }));
55
58
  }
56
- //#endregion
57
- //#region Browser globals
58
- /**
59
- * Browser globals whose bare use is ambiguous (they collide with common identifiers). Browser- and node-runtime files
60
- * warn on these, nudging toward an explicit `window.` access.
61
- */
62
- const BROWSER_GLOBALS = [
63
- "addEventListener",
64
- "blur",
65
- "close",
66
- "closed",
67
- "confirm",
68
- "defaultStatus",
69
- "defaultstatus",
70
- "event",
71
- "external",
72
- "find",
73
- "focus",
74
- "frameElement",
75
- "frames",
76
- "history",
77
- "innerHeight",
78
- "innerWidth",
79
- "length",
80
- "location",
81
- "locationbar",
82
- "menubar",
83
- "moveBy",
84
- "moveTo",
85
- "name",
86
- "onblur",
87
- "onerror",
88
- "onfocus",
89
- "onload",
90
- "onresize",
91
- "onunload",
92
- "open",
93
- "opener",
94
- "opera",
95
- "outerHeight",
96
- "outerWidth",
97
- "pageXOffset",
98
- "pageYOffset",
99
- "parent",
100
- "print",
101
- "removeEventListener",
102
- "resizeBy",
103
- "resizeTo",
104
- "screen",
105
- "screenLeft",
106
- "screenTop",
107
- "screenX",
108
- "screenY",
109
- "scroll",
110
- "scrollbars",
111
- "scrollBy",
112
- "scrollTo",
113
- "scrollX",
114
- "scrollY",
115
- "self",
116
- "status",
117
- "statusbar",
118
- "stop",
119
- "toolbar",
120
- "top",
121
- ];
122
- function restrictedBrowserGlobalsRule() {
123
- return ["warn", ...BROWSER_GLOBALS.map((name) => ({ name, message: `Ambiguous: did you mean \`window.${name}\`?` }))];
124
- }
125
59
  /**
126
60
  * Builds the `patterns` entries forbidding a runtime from importing packages of incompatible runtimes, each with a
127
61
  * tailored message.
@@ -1 +1 @@
1
- {"version":3,"file":"restrictions.js","sourceRoot":"","sources":["../src/restrictions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,sBAAsB;AAEtB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAy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S,CAAA;AACjB,CAAC;AAED,YAAY"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Four rules over the comments people use to carve a file into sections. They form one
6
+ * escalation ladder, and each rung is a smaller file than the last:
7
+ *
8
+ * 1. `prefer-mark-comment` — a `----` banner becomes `// MARK: <label>` (autofixed). A banner is
9
+ * three lines of decoration to carry one label.
10
+ * 2. `concise-section-marker` — a marker's label is a label, not a paragraph. Past the limit, the
11
+ * detail belongs in the documented symbol's JSDoc or in the file's own `@file` block.
12
+ * 3. `prefer-region-over-marks` — past one marker, a file has sections, and sections have ENDS.
13
+ * Regions fold, so a reader can collapse what they are not reading.
14
+ * 4. `max-regions` — past ten regions, the sections want to be files.
15
+ *
16
+ * Rules 3 and 4 are advisory: where a section ends, and whether it should move, are judgment calls
17
+ * no fixer can make. Rules 1 and 2 are not — the first has one correct rewrite, the second has a
18
+ * measurable limit.
19
+ */
20
+ import type { Rule } from "./plugin-types.js";
21
+ export declare const preferMarkCommentRule: Rule;
22
+ export declare const conciseSectionMarkerRule: Rule;
23
+ export declare const preferRegionOverMarksRule: Rule;
24
+ export declare const maxRegionsRule: Rule;
25
+ //# sourceMappingURL=section-marker-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section-marker-plugin.d.ts","sourceRoot":"","sources":["../src/section-marker-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAW,IAAI,EAA2B,MAAM,mBAAmB,CAAA;AAuJ/E,eAAO,MAAM,qBAAqB,EAAE,IA+CnC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,IA+BtC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,IAwBvC,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,IA0B5B,CAAA"}
@@ -0,0 +1,234 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Four rules over the comments people use to carve a file into sections. They form one
6
+ * escalation ladder, and each rung is a smaller file than the last:
7
+ *
8
+ * 1. `prefer-mark-comment` — a `----` banner becomes `// MARK: <label>` (autofixed). A banner is
9
+ * three lines of decoration to carry one label.
10
+ * 2. `concise-section-marker` — a marker's label is a label, not a paragraph. Past the limit, the
11
+ * detail belongs in the documented symbol's JSDoc or in the file's own `@file` block.
12
+ * 3. `prefer-region-over-marks` — past one marker, a file has sections, and sections have ENDS.
13
+ * Regions fold, so a reader can collapse what they are not reading.
14
+ * 4. `max-regions` — past ten regions, the sections want to be files.
15
+ *
16
+ * Rules 3 and 4 are advisory: where a section ends, and whether it should move, are judgment calls
17
+ * no fixer can make. Rules 1 and 2 are not — the first has one correct rewrite, the second has a
18
+ * measurable limit.
19
+ */
20
+ /**
21
+ * A run of at least this many dashes reads as decoration rather than as prose.
22
+ */
23
+ const MIN_BANNER_DASHES = 10;
24
+ /**
25
+ * Default ceiling for a marker's label, in characters.
26
+ */
27
+ const DEFAULT_MAX_BODY_LENGTH = 60;
28
+ /**
29
+ * Default region ceiling. The rule fires past it, so the eleventh region is the one that trips it.
30
+ *
31
+ * Deliberately high. A file with four well-named regions is usually fine — data plus the operations on it, where
32
+ * splitting would separate a type from its helpers. This is a runaway detector, not a style nudge: past ten sections a
33
+ * file is doing too many jobs by any reading.
34
+ */
35
+ const DEFAULT_MAX_REGIONS = 10;
36
+ /**
37
+ * A line that is nothing but a comment marker and a rule of dashes.
38
+ */
39
+ const BANNER_SEPARATOR = new RegExp(String.raw `^[ \t]*//[ \t]*-{${MIN_BANNER_DASHES},}[ \t]*$`);
40
+ /**
41
+ * `// MARK: label`, with the leading dash Xcode allows (`// MARK: - label`) folded away.
42
+ */
43
+ const MARK_COMMENT = /^[ \t]*\/\/[ \t]*MARK:[ \t]*-?[ \t]*(.*)$/;
44
+ /**
45
+ * `//#region label` — the space after `//` is optional, which is how most editors emit it.
46
+ */
47
+ const REGION_COMMENT = /^[ \t]*\/\/[ \t]*#region\b[ \t]*(.*)$/;
48
+ /**
49
+ * Strip a line comment's `//` and the space that conventionally follows it.
50
+ */
51
+ function commentBody(line) {
52
+ return line
53
+ .trim()
54
+ .replace(/^\/\/[ \t]?/, "")
55
+ .trim();
56
+ }
57
+ /**
58
+ * Scan for banner blocks: a separator line, one or more comment lines, then another separator. Blocks are matched on
59
+ * raw lines rather than on the comment list because a banner is a visual construct — what makes it one is that the
60
+ * lines are adjacent, which the AST does not model.
61
+ */
62
+ function findBanners(lines) {
63
+ const banners = [];
64
+ let i = 0;
65
+ while (i < lines.length) {
66
+ if (!BANNER_SEPARATOR.test(lines[i])) {
67
+ i++;
68
+ continue;
69
+ }
70
+ let end = i + 1;
71
+ const body = [];
72
+ while (end < lines.length && lines[end].trim().startsWith("//") && !BANNER_SEPARATOR.test(lines[end])) {
73
+ body.push(commentBody(lines[end]));
74
+ end++;
75
+ }
76
+ if (body.length && end < lines.length && BANNER_SEPARATOR.test(lines[end])) {
77
+ banners.push({ startLine: i, endLine: end, body, indent: /^[ \t]*/.exec(lines[i])[0] });
78
+ i = end + 1;
79
+ continue;
80
+ }
81
+ i = end;
82
+ }
83
+ return banners;
84
+ }
85
+ /**
86
+ * Byte offset of the first character of a zero-based line.
87
+ */
88
+ function offsetOfLine(lines, line) {
89
+ let offset = 0;
90
+ for (let i = 0; i < line; i++) {
91
+ offset += lines[i].length + 1;
92
+ }
93
+ return offset;
94
+ }
95
+ /**
96
+ * Every line comment in the file, paired with its label under `pattern`.
97
+ */
98
+ function markersMatching(sourceCode, text, pattern) {
99
+ const found = [];
100
+ for (const comment of sourceCode.getAllComments()) {
101
+ if (comment.type !== "Line")
102
+ continue;
103
+ const match = pattern.exec(text.slice(comment.range[0], comment.range[1]));
104
+ if (match) {
105
+ found.push({ comment, label: match[1].trim() });
106
+ }
107
+ }
108
+ return found;
109
+ }
110
+ /**
111
+ * Shared preamble: the source text and its lines, which every rule here walks.
112
+ */
113
+ function read(context) {
114
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
115
+ const text = sourceCode.getText();
116
+ return { sourceCode, text, lines: text.split("\n") };
117
+ }
118
+ export const preferMarkCommentRule = {
119
+ meta: {
120
+ name: "prefer-mark-comment",
121
+ type: "suggestion",
122
+ fixable: "code",
123
+ schema: [{ type: "object", additionalProperties: true }],
124
+ },
125
+ create(context) {
126
+ const { text, lines } = read(context);
127
+ return {
128
+ Program() {
129
+ for (const banner of findBanners(lines)) {
130
+ const start = offsetOfLine(lines, banner.startLine);
131
+ const end = offsetOfLine(lines, banner.endLine) + lines[banner.endLine].length;
132
+ const node = { type: "Line", range: [start, end] };
133
+ // A banner wrapping real prose is a comment someone wrote, not decoration around a
134
+ // label. Collapsing it would delete the prose, so say what to do and leave it alone.
135
+ if (banner.body.length > 1) {
136
+ context.report({
137
+ node,
138
+ message: "Banner comment: keep the prose in a JSDoc block on what it describes, and leave a `// MARK: <label>` here.",
139
+ });
140
+ continue;
141
+ }
142
+ const label = banner.body[0];
143
+ context.report({
144
+ node,
145
+ message: "Banner comment: use `// MARK: <label>`.",
146
+ fix(fixer) {
147
+ // The marker wants a blank line on each side. Add one only where the source is
148
+ // missing it, so a correctly-spaced banner does not gain stray lines.
149
+ const before = text.slice(0, start).endsWith("\n\n") || start === 0 ? "" : "\n";
150
+ const after = text.slice(end).startsWith("\n\n") ? "" : "\n";
151
+ return fixer.replaceTextRange([start, end], `${before}${banner.indent}// MARK: ${label}${after}`);
152
+ },
153
+ });
154
+ }
155
+ },
156
+ };
157
+ },
158
+ };
159
+ export const conciseSectionMarkerRule = {
160
+ meta: {
161
+ name: "concise-section-marker",
162
+ type: "suggestion",
163
+ schema: [{ type: "object", additionalProperties: true }],
164
+ },
165
+ create(context) {
166
+ const { sourceCode, text } = read(context);
167
+ const options = (context.options[0] ?? {});
168
+ const limit = options.maxBodyLength ?? DEFAULT_MAX_BODY_LENGTH;
169
+ return {
170
+ Program() {
171
+ const markers = [
172
+ ...markersMatching(sourceCode, text, MARK_COMMENT).map((m) => ({ ...m, kind: "MARK" })),
173
+ ...markersMatching(sourceCode, text, REGION_COMMENT).map((m) => ({ ...m, kind: "#region" })),
174
+ ];
175
+ for (const { comment, label, kind } of markers) {
176
+ if (label.length <= limit)
177
+ continue;
178
+ context.report({
179
+ node: { type: "Line", range: comment.range },
180
+ message: `${kind} label is ${label.length} characters (max ${limit}) — shorten it, move the detail into ` +
181
+ "the JSDoc of what it describes, or split the file and put it in a `@file` block.",
182
+ });
183
+ }
184
+ },
185
+ };
186
+ },
187
+ };
188
+ export const preferRegionOverMarksRule = {
189
+ meta: {
190
+ name: "prefer-region-over-marks",
191
+ type: "suggestion",
192
+ schema: [{ type: "object", additionalProperties: true }],
193
+ },
194
+ create(context) {
195
+ const { sourceCode, text } = read(context);
196
+ return {
197
+ Program() {
198
+ const marks = markersMatching(sourceCode, text, MARK_COMMENT);
199
+ if (marks.length < 2)
200
+ return;
201
+ context.report({
202
+ node: { type: "Line", range: marks[0].comment.range },
203
+ message: `${marks.length} MARK comments in one file — give each section an END with ` +
204
+ "`//#region <label>` / `//#endregion`, so a reader can fold what they are not reading.",
205
+ });
206
+ },
207
+ };
208
+ },
209
+ };
210
+ export const maxRegionsRule = {
211
+ meta: {
212
+ name: "max-regions",
213
+ type: "suggestion",
214
+ schema: [{ type: "object", additionalProperties: true }],
215
+ },
216
+ create(context) {
217
+ const { sourceCode, text } = read(context);
218
+ const options = (context.options[0] ?? {});
219
+ const limit = options.max ?? DEFAULT_MAX_REGIONS;
220
+ return {
221
+ Program() {
222
+ const regions = markersMatching(sourceCode, text, REGION_COMMENT);
223
+ if (regions.length <= limit)
224
+ return;
225
+ context.report({
226
+ node: { type: "Line", range: regions[0].comment.range },
227
+ message: `${regions.length} regions in one file (max ${limit}) — a file with this many sections is ` +
228
+ "several files. Split it, and let each one's `@file` block say what it is.",
229
+ });
230
+ },
231
+ };
232
+ },
233
+ };
234
+ //# sourceMappingURL=section-marker-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AI,KAAK;oBAAE,OAAM;gBAEnC,OAAO,CAAC,MAAM,CAAC;oBACd,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,KAAK,EAAE;oBACxD,OAAO,EACN,GAAG,OAAO,CAAC,MAAM,6BAA6B,KAAK,wCAAwC;wBAC3F,2EAA2E;iBAC5E,CAAC,CAAA;YACH,CAAC;SACD,CAAA;IACF,CAAC;CACD,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file A no-unnamed-threshold rule, authored as an oxlint JS plugin (ESLint v9-compatible API). It
6
+ * flags a numeric literal used as a threshold — an operand of a comparison — and nothing else.
7
+ * Numbers inside array and object literals are left alone, because a bounding box or a codepoint
8
+ * table is data rather than a tuning knob. That distinction is why this exists instead of
9
+ * `no-magic-numbers`, which cannot express it.
10
+ */
11
+ import type { Rule } from "./plugin-types.js";
12
+ /**
13
+ * Options accepted by {@link noUnnamedThresholdRule}.
14
+ */
15
+ export interface ThresholdOptions {
16
+ /**
17
+ * Values that may appear unnamed. Replaces the default list rather than extending it.
18
+ */
19
+ ignore?: number[];
20
+ /**
21
+ * Exempt radix-prefixed literals, which already read as codepoints or bit masks.
22
+ */
23
+ allowHex?: boolean;
24
+ }
25
+ export declare const noUnnamedThresholdRule: Rule;
26
+ export default noUnnamedThresholdRule;
27
+ //# sourceMappingURL=threshold-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-plugin.d.ts","sourceRoot":"","sources":["../src/threshold-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAiBtD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,sBAAsB,EAAE,IA4DpC,CAAA;AAED,eAAe,sBAAsB,CAAA"}