@jandragsbaek/oxlint-plugin 0.1.0 → 0.3.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.
package/dist/index.mjs CHANGED
@@ -62,168 +62,6 @@ Object.freeze({
62
62
  throw Error("Cannot access `context.parserPath` in `createOnce`");
63
63
  }
64
64
  });
65
- // src/rules/namespace-node-imports.ts
66
- const NODE_MODULE_ALIASES = /* @__PURE__ */ new Map([["assert/strict", "Assert"], ["fs/promises", "FSP"]]);
67
- const NODE_SEGMENT_ALIASES = /* @__PURE__ */ new Map([
68
- ["fs", "FS"],
69
- ["os", "OS"],
70
- ["url", "URL"],
71
- ["vm", "VM"]
72
- ]);
73
- const toPascalCase = (value) => value.split(/[_-]/u).filter((segment) => segment.length > 0).map((segment) => segment[0]?.toUpperCase() + segment.slice(1)).join("");
74
- const expectedNamespaceAlias = (source) => {
75
- const moduleName = source.slice(5);
76
- const knownAlias = NODE_MODULE_ALIASES.get(moduleName);
77
- if (knownAlias !== void 0) return `Node${knownAlias}`;
78
- return `Node${moduleName.split("/").map((segment) => NODE_SEGMENT_ALIASES.get(segment) ?? toPascalCase(segment)).join("")}`;
79
- };
80
- const literalStringValue = (node) => {
81
- if (typeof node !== "object" || node === null) return void 0;
82
- if (!("type" in node) || node.type !== "Literal") return void 0;
83
- if (!("value" in node) || typeof node.value !== "string") return void 0;
84
- return node.value;
85
- };
86
- const identifierName = (node) => {
87
- if (typeof node !== "object" || node === null) return void 0;
88
- if (!("type" in node) || node.type !== "Identifier") return void 0;
89
- if (!("name" in node) || typeof node.name !== "string") return void 0;
90
- return node.name;
91
- };
92
- var namespace_node_imports_default = defineRule({
93
- meta: {
94
- type: "problem",
95
- docs: { description: "Require canonical namespace imports for Node.js built-in modules." }
96
- },
97
- create(context) {
98
- return { ImportDeclaration(node) {
99
- const source = literalStringValue(node.source);
100
- if (source === void 0 || !source.startsWith("node:")) return;
101
- const expectedAlias = expectedNamespaceAlias(source);
102
- const namespaceImport = node.specifiers.length === 1 && node.specifiers[0]?.type === "ImportNamespaceSpecifier" ? node.specifiers[0] : void 0;
103
- if (identifierName(namespaceImport?.local) === expectedAlias) return;
104
- context.report({
105
- node,
106
- message: `Import ${source} as a namespace named ${expectedAlias}.`
107
- });
108
- } };
109
- }
110
- });
111
- // src/rules/no-dom-test-environment.ts
112
- const DOM_ENVIRONMENT_PACKAGE = /^(?:jsdom|happy-dom)(?:\/|$)/u;
113
- const PRAGMA = ["@vitest", "environment"].join("-");
114
- const MESSAGE$5 = "Select test environments in Vitest project configuration instead of a per-file pragma or a DOM emulator import. Web DOM tests belong in *.browser.test.{ts,tsx}.";
115
- var no_dom_test_environment_default = defineRule({
116
- meta: {
117
- type: "problem",
118
- docs: { description: "Reject per-file Vitest environments and DOM emulator imports." }
119
- },
120
- create(context) {
121
- const checkImport = (source) => {
122
- if (source === null) return;
123
- const value = source.type === "Literal" ? source.value : source.type === "TemplateLiteral" && source.expressions.length === 0 ? source.quasis[0]?.value.cooked : void 0;
124
- if (typeof value === "string" && DOM_ENVIRONMENT_PACKAGE.test(value)) context.report({
125
- node: source,
126
- message: MESSAGE$5
127
- });
128
- };
129
- return {
130
- Program() {
131
- const index = context.sourceCode.text.indexOf(PRAGMA);
132
- if (index !== -1) context.report({
133
- loc: context.sourceCode.getLocFromIndex(index),
134
- message: MESSAGE$5
135
- });
136
- },
137
- ImportDeclaration: (node) => checkImport(node.source),
138
- ImportExpression: (node) => checkImport(node.source),
139
- ExportNamedDeclaration: (node) => checkImport(node.source),
140
- ExportAllDeclaration: (node) => checkImport(node.source),
141
- TSExternalModuleReference: (node) => checkImport(node.expression),
142
- CallExpression(node) {
143
- if (node.callee.type === "Identifier" && node.callee.name === "require") checkImport(node.arguments[0] ?? null);
144
- }
145
- };
146
- }
147
- });
148
- // src/rules/no-em-dash-copy.ts
149
- const EM_DASH = "—";
150
- const MESSAGE$4 = "No em dashes in product copy. Use a period, comma, colon, or parentheses instead.";
151
- var no_em_dash_copy_default = defineRule({
152
- meta: {
153
- type: "suggestion",
154
- docs: { description: "Disallow em dashes in strings and JSX text that users or agents read." }
155
- },
156
- create(context) {
157
- const check = (node, text) => {
158
- if (text?.includes(EM_DASH)) context.report({
159
- node,
160
- message: MESSAGE$4
161
- });
162
- };
163
- return {
164
- Literal(node) {
165
- if (typeof node.value === "string") check(node, node.value);
166
- },
167
- TemplateElement(node) {
168
- check(node, node.value.cooked);
169
- },
170
- JSXText(node) {
171
- check(node, node.value);
172
- }
173
- };
174
- }
175
- });
176
- // src/rules/no-hookless-use-function.ts
177
- const HOOK_NAME = /^use[A-Z]/;
178
- const HOOK_CALLEE = /^use([A-Z]|$)/;
179
- function isFunctionNode(node) {
180
- return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
181
- }
182
- function isHookCallee(callee) {
183
- if (callee.type === "Identifier") return HOOK_CALLEE.test(callee.name);
184
- if (callee.type === "MemberExpression" && !callee.computed) return callee.property.type === "Identifier" && HOOK_CALLEE.test(callee.property.name);
185
- return false;
186
- }
187
- function callsHook(node, root) {
188
- if (typeof node !== "object" || node === null) return false;
189
- if (Array.isArray(node)) return node.some((child) => callsHook(child, root));
190
- if (!("type" in node) || typeof node.type !== "string") return false;
191
- const typed = node;
192
- if (typed !== root && isFunctionNode(typed)) return false;
193
- if (typed.type === "CallExpression" && isHookCallee(typed.callee)) return true;
194
- for (const [key, value] of Object.entries(typed)) {
195
- if (key === "parent") continue;
196
- if (callsHook(value, root)) return true;
197
- }
198
- return false;
199
- }
200
- var no_hookless_use_function_default = defineRule({
201
- meta: {
202
- type: "problem",
203
- docs: { description: "Disallow use* functions that call no hooks; the React Compiler only compiles functions that do. Mirrors eslint-react's no-unnecessary-use-prefix, which oxlint does not ship." },
204
- schema: []
205
- },
206
- create(context) {
207
- const check = (name, fn, reportNode) => {
208
- if (!HOOK_NAME.test(name)) return;
209
- if (callsHook(fn.body, fn)) return;
210
- context.report({
211
- node: reportNode,
212
- message: `"${name}" calls no hooks, so the React Compiler skips it and whatever it returns is rebuilt on every render. Rename it to a plain function, or read the hook it depends on inside it.`
213
- });
214
- };
215
- return {
216
- FunctionDeclaration(node) {
217
- if (node.id) check(node.id.name, node, node.id);
218
- },
219
- VariableDeclarator(node) {
220
- if (node.id.type !== "Identifier" || node.init == null) return;
221
- if (node.init.type !== "ArrowFunctionExpression" && node.init.type !== "FunctionExpression") return;
222
- check(node.id.name, node.init, node.id);
223
- }
224
- };
225
- }
226
- });
227
65
  // node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Pipeable.js
228
66
  /**
229
67
  * The `Pipeable` module defines the shared interface and implementation helpers
@@ -1996,6 +1834,302 @@ function isIdentifier(node, name) {
1996
1834
  const expression = node.value;
1997
1835
  return expression.type === "Identifier" && typeof expression.name === "string" && (name === void 0 || expression.name === name);
1998
1836
  }
1837
+ function countFileLines(lines) {
1838
+ return lines.at(-1) === "" ? lines.length - 1 : lines.length;
1839
+ }
1840
+ function readMaxLines(options, defaultMax) {
1841
+ const [first] = options;
1842
+ return typeof first === "object" && first !== null && "max" in first && typeof first.max === "number" && Number.isInteger(first.max) && first.max > 0 ? first.max : defaultMax;
1843
+ }
1844
+ const maxLinesSchema = (defaultMax) => [{
1845
+ type: "object",
1846
+ properties: { max: {
1847
+ type: "integer",
1848
+ minimum: 1,
1849
+ default: defaultMax
1850
+ } },
1851
+ additionalProperties: false
1852
+ }];
1853
+ var max_file_lines_default = defineRule({
1854
+ meta: {
1855
+ type: "suggestion",
1856
+ docs: { description: "Report a file longer than `max` lines (default 500); a reasoned disable can keep it." },
1857
+ schema: maxLinesSchema(500)
1858
+ },
1859
+ create(context) {
1860
+ const max = readMaxLines(context.options, 500);
1861
+ const { lines } = context.sourceCode;
1862
+ const count = countFileLines(lines);
1863
+ if (count <= max) return {};
1864
+ return { Program() {
1865
+ context.report({
1866
+ loc: {
1867
+ start: {
1868
+ line: max + 1,
1869
+ column: 0
1870
+ },
1871
+ end: {
1872
+ line: lines.length,
1873
+ column: lines.at(-1).length
1874
+ }
1875
+ },
1876
+ message: `This file has ${count} lines; the cap is ${max}. Split it by responsibility. If this file must stay long, say why at its top: \`/* oxlint-disable jandragsbaek/max-file-lines -- <why this file is long> */\`.`
1877
+ });
1878
+ } };
1879
+ }
1880
+ });
1881
+ const BEFORE_EVERY_DIRECTIVE = {
1882
+ line: 1,
1883
+ column: 0
1884
+ };
1885
+ var max_file_lines_hard_default = defineRule({
1886
+ meta: {
1887
+ type: "problem",
1888
+ docs: { description: "Report a file longer than `max` lines (default 750); no disable directive can silence it." },
1889
+ schema: maxLinesSchema(750)
1890
+ },
1891
+ create(context) {
1892
+ const max = readMaxLines(context.options, 750);
1893
+ const count = countFileLines(context.sourceCode.lines);
1894
+ if (count <= max) return {};
1895
+ return { Program() {
1896
+ context.report({
1897
+ loc: {
1898
+ start: BEFORE_EVERY_DIRECTIVE,
1899
+ end: BEFORE_EVERY_DIRECTIVE
1900
+ },
1901
+ message: `This file has ${count} lines; the hard cap is ${max}, and no directive silences it. Split the file by responsibility.`
1902
+ });
1903
+ } };
1904
+ }
1905
+ });
1906
+ // src/rules/namespace-node-imports.ts
1907
+ const NODE_MODULE_ALIASES = /* @__PURE__ */ new Map([["assert/strict", "Assert"], ["fs/promises", "FSP"]]);
1908
+ const NODE_SEGMENT_ALIASES = /* @__PURE__ */ new Map([
1909
+ ["fs", "FS"],
1910
+ ["os", "OS"],
1911
+ ["url", "URL"],
1912
+ ["vm", "VM"]
1913
+ ]);
1914
+ const toPascalCase = (value) => value.split(/[_-]/u).filter((segment) => segment.length > 0).map((segment) => segment[0]?.toUpperCase() + segment.slice(1)).join("");
1915
+ const expectedNamespaceAlias = (source) => {
1916
+ const moduleName = source.slice(5);
1917
+ const knownAlias = NODE_MODULE_ALIASES.get(moduleName);
1918
+ if (knownAlias !== void 0) return `Node${knownAlias}`;
1919
+ return `Node${moduleName.split("/").map((segment) => NODE_SEGMENT_ALIASES.get(segment) ?? toPascalCase(segment)).join("")}`;
1920
+ };
1921
+ const literalStringValue = (node) => {
1922
+ if (typeof node !== "object" || node === null) return void 0;
1923
+ if (!("type" in node) || node.type !== "Literal") return void 0;
1924
+ if (!("value" in node) || typeof node.value !== "string") return void 0;
1925
+ return node.value;
1926
+ };
1927
+ const identifierName = (node) => {
1928
+ if (typeof node !== "object" || node === null) return void 0;
1929
+ if (!("type" in node) || node.type !== "Identifier") return void 0;
1930
+ if (!("name" in node) || typeof node.name !== "string") return void 0;
1931
+ return node.name;
1932
+ };
1933
+ var namespace_node_imports_default = defineRule({
1934
+ meta: {
1935
+ type: "problem",
1936
+ docs: { description: "Require canonical namespace imports for Node.js built-in modules." }
1937
+ },
1938
+ create(context) {
1939
+ return { ImportDeclaration(node) {
1940
+ const source = literalStringValue(node.source);
1941
+ if (source === void 0 || !source.startsWith("node:")) return;
1942
+ const expectedAlias = expectedNamespaceAlias(source);
1943
+ const namespaceImport = node.specifiers.length === 1 && node.specifiers[0]?.type === "ImportNamespaceSpecifier" ? node.specifiers[0] : void 0;
1944
+ if (identifierName(namespaceImport?.local) === expectedAlias) return;
1945
+ context.report({
1946
+ node,
1947
+ message: `Import ${source} as a namespace named ${expectedAlias}.`
1948
+ });
1949
+ } };
1950
+ }
1951
+ });
1952
+ // src/rules/no-dom-test-environment.ts
1953
+ const DOM_ENVIRONMENT_PACKAGE = /^(?:jsdom|happy-dom)(?:\/|$)/u;
1954
+ const PRAGMA_SPLIT_TO_HIDE_IT_FROM_THIS_RULE = ["@vitest", "environment"].join("-");
1955
+ const MESSAGE$5 = "Select test environments in Vitest project configuration instead of a per-file pragma or a DOM emulator import. Web DOM tests belong in *.browser.test.{ts,tsx}.";
1956
+ var no_dom_test_environment_default = defineRule({
1957
+ meta: {
1958
+ type: "problem",
1959
+ docs: { description: "Reject per-file Vitest environments and DOM emulator imports." }
1960
+ },
1961
+ create(context) {
1962
+ const checkImport = (source) => {
1963
+ if (source === null) return;
1964
+ const value = source.type === "Literal" ? source.value : source.type === "TemplateLiteral" && source.expressions.length === 0 ? source.quasis[0]?.value.cooked : void 0;
1965
+ if (typeof value === "string" && DOM_ENVIRONMENT_PACKAGE.test(value)) context.report({
1966
+ node: source,
1967
+ message: MESSAGE$5
1968
+ });
1969
+ };
1970
+ return {
1971
+ Program() {
1972
+ const index = context.sourceCode.text.indexOf(PRAGMA_SPLIT_TO_HIDE_IT_FROM_THIS_RULE);
1973
+ if (index !== -1) context.report({
1974
+ loc: context.sourceCode.getLocFromIndex(index),
1975
+ message: MESSAGE$5
1976
+ });
1977
+ },
1978
+ ImportDeclaration: (node) => checkImport(node.source),
1979
+ ImportExpression: (node) => checkImport(node.source),
1980
+ ExportNamedDeclaration: (node) => checkImport(node.source),
1981
+ ExportAllDeclaration: (node) => checkImport(node.source),
1982
+ TSExternalModuleReference: (node) => checkImport(node.expression),
1983
+ CallExpression(node) {
1984
+ if (node.callee.type === "Identifier" && node.callee.name === "require") checkImport(node.arguments[0] ?? null);
1985
+ }
1986
+ };
1987
+ }
1988
+ });
1989
+ // src/rules/no-em-dash-copy.ts
1990
+ const EM_DASH = "—";
1991
+ const MESSAGE$4 = "No em dashes in product copy. Use a period, comma, colon, or parentheses instead.";
1992
+ var no_em_dash_copy_default = defineRule({
1993
+ meta: {
1994
+ type: "suggestion",
1995
+ docs: { description: "Disallow em dashes in strings and JSX text that users or agents read." }
1996
+ },
1997
+ create(context) {
1998
+ const check = (node, text) => {
1999
+ if (text?.includes(EM_DASH)) context.report({
2000
+ node,
2001
+ message: MESSAGE$4
2002
+ });
2003
+ };
2004
+ return {
2005
+ Literal(node) {
2006
+ if (typeof node.value === "string") check(node, node.value);
2007
+ },
2008
+ TemplateElement(node) {
2009
+ check(node, node.value.cooked);
2010
+ },
2011
+ JSXText(node) {
2012
+ check(node, node.value);
2013
+ }
2014
+ };
2015
+ }
2016
+ });
2017
+ // src/rules/no-explanatory-comments.ts
2018
+ const END = String.raw`(?![\w-])`;
2019
+ const TOOL_DIRECTIVES = [
2020
+ new RegExp(String.raw`^(?:oxlint|eslint)-(?:disable(?:-next-line|-line)?|enable)${END}`, "u"),
2021
+ new RegExp(String.raw`^@ts-(?:expect-error|ignore|nocheck|check)${END}`, "u"),
2022
+ /^\/\s*<(?:reference|amd-module|amd-dependency)\s/u,
2023
+ new RegExp(String.raw`^[@#]__(?:PURE|NO_SIDE_EFFECTS)__${END}`, "u"),
2024
+ new RegExp(String.raw`^@jsx(?:Frag|ImportSource|Runtime)?${END}`, "u"),
2025
+ new RegExp(String.raw`^(?:oxfmt|prettier|biome|dprint)-ignore(?:-start|-end)?${END}`, "u"),
2026
+ new RegExp(String.raw`^(?:v8|c8|istanbul)\s+ignore${END}`, "u"),
2027
+ new RegExp(String.raw`^node:coverage\s+(?:ignore|disable|enable)${END}`, "u"),
2028
+ new RegExp(String.raw`^@vite-ignore${END}`, "u"),
2029
+ /^(?:webpack|turbopack)[A-Z]\w*\s*:/u,
2030
+ new RegExp(String.raw`^@effect-diagnostics(?:-next-line)?${END}`, "u"),
2031
+ new RegExp(String.raw`^@(?:vitest|jest)-environment${END}`, "u"),
2032
+ /^[#@]\s*source(?:Mapping)?URL=/u,
2033
+ new RegExp(String.raw`^@refresh\s+reset${END}`, "u"),
2034
+ new RegExp(String.raw`^cspell:\s*(?:words|ignore|ignoreRegExp|includeRegExp|flagWords|dictionaries|language|locale|enable|disable(?:-next-line|-line)?)${END}`, "u"),
2035
+ /^quarantine:\s*#\d+(?!\w)/u
2036
+ ];
2037
+ const LICENSE_NOTICE_LINE = /^[\s*]*(?:copyright\b|©|\(c\)\s|SPDX-License-Identifier:|@license\b|Permission is hereby granted\b|Licensed under\b)/imu;
2038
+ const isLicenseNotice = (comment) => comment.type === "Block" && comment.value.startsWith("!") || LICENSE_NOTICE_LINE.test(comment.value);
2039
+ const LEADING_COMMENT_DECORATION = /^[\s*]*/u;
2040
+ const MESSAGE$3 = "Delete this comment. Make the code say it: a name, a type, a smaller function or a test. Only a license header at the top of the file and tool directives (lint, type-checker, formatter, coverage and bundler comments) stay.";
2041
+ const isToolDirective = (comment) => {
2042
+ const text = comment.value.replace(LEADING_COMMENT_DECORATION, "");
2043
+ return TOOL_DIRECTIVES.some((directive) => directive.test(text));
2044
+ };
2045
+ const continuesLineComment = (previous, comment) => comment.type === "Line" && previous?.type === "Line" && previous.loc.end.line === comment.loc.start.line - 1 && previous.loc.start.column === comment.loc.start.column;
2046
+ var no_explanatory_comments_default = defineRule({
2047
+ meta: {
2048
+ type: "suggestion",
2049
+ docs: { description: "Reject every comment except a license header at the top of the file and tool directives." }
2050
+ },
2051
+ create(context) {
2052
+ const { sourceCode } = context;
2053
+ return { Program(program) {
2054
+ const firstCodeStart = program.body[0]?.range[0] ?? Number.POSITIVE_INFINITY;
2055
+ const comments = sourceCode.getAllComments().filter((comment) => comment.type !== "Shebang");
2056
+ const licenseHeader = /* @__PURE__ */ new Set();
2057
+ const headerBlocks = [];
2058
+ for (const comment of comments) {
2059
+ if (comment.range[0] >= firstCodeStart) break;
2060
+ const block = headerBlocks.at(-1);
2061
+ if (block !== void 0 && continuesLineComment(block.at(-1), comment)) block.push(comment);
2062
+ else headerBlocks.push([comment]);
2063
+ }
2064
+ for (const block of headerBlocks) if (block.some(isLicenseNotice)) for (const comment of block) licenseHeader.add(comment);
2065
+ const reported = [];
2066
+ for (const comment of comments) {
2067
+ if (licenseHeader.has(comment) || isToolDirective(comment)) continue;
2068
+ const group = reported.at(-1);
2069
+ if (group !== void 0 && continuesLineComment(group.at(-1), comment)) group.push(comment);
2070
+ else reported.push([comment]);
2071
+ }
2072
+ for (const group of reported) context.report({
2073
+ loc: {
2074
+ start: group[0].loc.start,
2075
+ end: group.at(-1).loc.end
2076
+ },
2077
+ message: MESSAGE$3
2078
+ });
2079
+ } };
2080
+ }
2081
+ });
2082
+ // src/rules/no-hookless-use-function.ts
2083
+ const HOOK_NAME = /^use[A-Z]/;
2084
+ const HOOK_CALLEE_OR_REACT_19_USE = /^use([A-Z]|$)/;
2085
+ function isFunctionNode(node) {
2086
+ return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
2087
+ }
2088
+ function isHookCallee(callee) {
2089
+ if (callee.type === "Identifier") return HOOK_CALLEE_OR_REACT_19_USE.test(callee.name);
2090
+ if (callee.type === "MemberExpression" && !callee.computed) return callee.property.type === "Identifier" && HOOK_CALLEE_OR_REACT_19_USE.test(callee.property.name);
2091
+ return false;
2092
+ }
2093
+ function callsHookOutsideNestedFunctions(node, root) {
2094
+ if (typeof node !== "object" || node === null) return false;
2095
+ if (Array.isArray(node)) return node.some((child) => callsHookOutsideNestedFunctions(child, root));
2096
+ if (!("type" in node) || typeof node.type !== "string") return false;
2097
+ const typed = node;
2098
+ if (typed !== root && isFunctionNode(typed)) return false;
2099
+ if (typed.type === "CallExpression" && isHookCallee(typed.callee)) return true;
2100
+ for (const [key, value] of Object.entries(typed)) {
2101
+ if (key === "parent") continue;
2102
+ if (callsHookOutsideNestedFunctions(value, root)) return true;
2103
+ }
2104
+ return false;
2105
+ }
2106
+ var no_hookless_use_function_default = defineRule({
2107
+ meta: {
2108
+ type: "problem",
2109
+ docs: { description: "Disallow use* functions that call no hooks; the React Compiler only compiles functions that do. Mirrors eslint-react's no-unnecessary-use-prefix, which oxlint does not ship." },
2110
+ schema: []
2111
+ },
2112
+ create(context) {
2113
+ const check = (name, fn, reportNode) => {
2114
+ if (!HOOK_NAME.test(name)) return;
2115
+ if (callsHookOutsideNestedFunctions(fn.body, fn)) return;
2116
+ context.report({
2117
+ node: reportNode,
2118
+ message: `"${name}" calls no hooks, so the React Compiler skips it and whatever it returns is rebuilt on every render. Rename it to a plain function, or read the hook it depends on inside it.`
2119
+ });
2120
+ };
2121
+ return {
2122
+ FunctionDeclaration(node) {
2123
+ if (node.id) check(node.id.name, node, node.id);
2124
+ },
2125
+ VariableDeclarator(node) {
2126
+ if (node.id.type !== "Identifier" || node.init == null) return;
2127
+ if (node.init.type !== "ArrowFunctionExpression" && node.init.type !== "FunctionExpression") return;
2128
+ check(node.id.name, node.init, node.id);
2129
+ }
2130
+ };
2131
+ }
2132
+ });
1999
2133
  // src/rules/no-inline-schema-compile.ts
2000
2134
  const COMPILER_METHODS = /* @__PURE__ */ new Set([
2001
2135
  "is",
@@ -2101,86 +2235,6 @@ var no_inline_schema_compile_default = defineRule({
2101
2235
  };
2102
2236
  }
2103
2237
  });
2104
- // src/rules/no-low-value-comments.ts
2105
- const TS_FILE_PATTERN = /\.[cm]?tsx?$/u;
2106
- const DIRECTIVE_PATTERN$1 = /^\s*(?:(?:oxlint|eslint)-|@ts-|@effect-diagnostics|prettier-ignore|biome-ignore|c8 |istanbul |#(?:end)?region)/u;
2107
- const DIVIDER_LINE_PATTERN = /^(?:[-=*#~_/+]{3,}.*|.*[-=*#~_]{3,})$/u;
2108
- const TEST_STEP_PATTERN = /^(?:arrange|act|assert|given|when|then)\s*[:.]?$/iu;
2109
- const TASK_MARKER_PATTERN = /\b(?:TODO|FIXME|XXX|HACK)\b/u;
2110
- const TEST_MARKER_PATTERN = /^\s*(?:regression|quarantine):/u;
2111
- const TASK_LINK_PATTERN = /#\d+|https?:\/\//u;
2112
- const BARE_ISSUE_REF_PATTERN = /(?<![\w/&#-])#[1-9]\d{2,4}(?![\w-])/u;
2113
- const CODE_SPAN_PATTERN = /`[^`]*`/gu;
2114
- const PUBLIC_BOILERPLATE_PATTERN = /^@public\s+Service construction is part of the canonical/u;
2115
- const MAX_COMMENT_LINES = 4;
2116
- const LICENSE_PATTERN = /^!|@license|\bcopyright\b|\bSPDX-License-Identifier\b/iu;
2117
- const JSDOC_TYPE_PATTERN = /^@(?:param|returns?|type|typedef)\s+\{/u;
2118
- const EMPTY_JSDOC_TAG_PATTERN = /^@(?:param(?:\s+\[?[\w$.]+\]?)?|returns?)$/u;
2119
- const COMMENTED_CODE_PATTERN = /^(?:(?:(?:const|let|var)\s+[\w${}[\], ]+=.*|import\s.+\sfrom\s+["'].+["']|(?:await\s+|return\s+)?[\w$.]+\(.*\)|[\w$.[\]]+\s*=\s*.+);|(?:if|for|while|switch)\s*\(.*\)\s*\{|\}(?:\s*else\s*\{)?)$/u;
2120
- const DECLARATION_PATTERN = /^\s*(?:export\s+)?(?:default\s+)?(?:declare\s+)?(?:async\s+)?(?:static\s+)?(?:readonly\s+)?(?:(?:const|let|var|function\*?|class|interface|type|enum)\s+)?([A-Za-z_$][\w$]*)\s*[?!]?\s*[:=(<{]/u;
2121
- const FILLER_WORDS = new Set("a an the of for to in on at by with from and or is are be this that it its as get set return create new current value given whether".split(" "));
2122
- const stem = (word) => word.length > 3 ? word.replace(/([^s])s$/u, "$1") : word;
2123
- const words = (text) => (text.toLowerCase().match(/[a-z0-9]+/gu) ?? []).filter((word) => !FILLER_WORDS.has(word)).map(stem).filter((word) => !FILLER_WORDS.has(word));
2124
- const identifierWords = (name) => words(name.replace(/([a-z0-9])([A-Z])/gu, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/gu, "$1 $2"));
2125
- const commentLines = (comment) => comment.value.split("\n").map((line) => line.replace(/^\s*\*?\s?/u, "").trim()).filter((line) => line !== "");
2126
- var no_low_value_comments_default = defineRule({
2127
- meta: {
2128
- type: "suggestion",
2129
- docs: { description: "Reject comments that only repeat the code, divide sections, or narrate tests." }
2130
- },
2131
- create(context) {
2132
- const { sourceCode } = context;
2133
- const isTypeScript = TS_FILE_PATTERN.test(context.filename);
2134
- const groups = [];
2135
- for (const comment of sourceCode.getAllComments()) {
2136
- const previous = groups.at(-1)?.comments.at(-1);
2137
- if (comment.type === "Line" && previous?.type === "Line" && previous.loc.end.line === comment.loc.start.line - 1 && previous.loc.start.column === comment.loc.start.column) {
2138
- groups.at(-1).comments.push(comment);
2139
- groups.at(-1).lines.push(...commentLines(comment));
2140
- } else groups.push({
2141
- comments: [comment],
2142
- lines: commentLines(comment)
2143
- });
2144
- }
2145
- const restatesNextName = (lastLine, lines) => {
2146
- if (lines.some((line) => line.startsWith("@"))) return false;
2147
- const name = DECLARATION_PATTERN.exec(sourceCode.lines[lastLine] ?? "")?.[1];
2148
- if (name === void 0) return false;
2149
- const content = words(lines.join(" "));
2150
- if (content.length === 0 || content.length > 6) return false;
2151
- const nameWords = new Set(identifierWords(name));
2152
- return content.every((word) => nameWords.has(word));
2153
- };
2154
- const problem = (comments, lines) => {
2155
- const text = comments.map((comment) => comment.value).join("\n");
2156
- if (lines.length === 0 || comments.some((comment) => DIRECTIVE_PATTERN$1.test(comment.value))) return;
2157
- const isLine = comments[0].type === "Line";
2158
- if (lines.some((line) => DIVIDER_LINE_PATTERN.test(line))) return "Drop the section divider; split the file or let the code's structure show the grouping.";
2159
- if (isLine && lines.length === 1 && TEST_STEP_PATTERN.test(lines[0])) return "Drop the test step label.";
2160
- if (TASK_MARKER_PATTERN.test(text) && !TASK_LINK_PATTERN.test(text)) return "Link the issue that tracks this, or drop the marker.";
2161
- if (!TASK_MARKER_PATTERN.test(text) && !TEST_MARKER_PATTERN.test(text) && BARE_ISSUE_REF_PATTERN.test(text.replace(CODE_SPAN_PATTERN, ""))) return "Drop the PR or issue number; git history records it. Keep the reason.";
2162
- if (isTypeScript && lines.some((line) => JSDOC_TYPE_PATTERN.test(line))) return "Drop the JSDoc type; TypeScript already has it.";
2163
- if (lines.some((line) => PUBLIC_BOILERPLATE_PATTERN.test(line))) return "Keep `@public` alone; the boilerplate after it says nothing about this export.";
2164
- if (lines.some((line) => EMPTY_JSDOC_TAG_PATTERN.test(line))) return "Drop the JSDoc tag that has no description.";
2165
- if (isLine && lines.every((line) => COMMENTED_CODE_PATTERN.test(line))) return "Delete commented-out code; git keeps the history.";
2166
- if (restatesNextName(comments.at(-1).loc.end.line, lines)) return "Drop the comment; it only repeats the name below it. Say why, or say nothing.";
2167
- if (lines.length > MAX_COMMENT_LINES && !LICENSE_PATTERN.test(text)) return `Cut this to ${MAX_COMMENT_LINES} lines or fewer: keep the constraint, drop the background.`;
2168
- };
2169
- return { Program() {
2170
- for (const { comments, lines } of groups) {
2171
- const message = problem(comments, lines);
2172
- if (message === void 0) continue;
2173
- context.report({
2174
- loc: {
2175
- start: comments[0].loc.start,
2176
- end: comments.at(-1).loc.end
2177
- },
2178
- message
2179
- });
2180
- }
2181
- } };
2182
- }
2183
- });
2184
2238
  // src/rules/no-manual-effect-runtime-in-tests.ts
2185
2239
  const TEST_FILE_PATTERN$5 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2186
2240
  const EFFECT_RUNTIME_METHODS = /* @__PURE__ */ new Set([
@@ -2244,7 +2298,7 @@ var no_manual_effect_runtime_in_tests_default = defineRule({
2244
2298
  });
2245
2299
  // src/rules/no-manual-memo.ts
2246
2300
  const MANUAL_MEMO_HOOKS = /* @__PURE__ */ new Set(["useCallback", "useMemo"]);
2247
- const MEMO_DIRECTIVES = /* @__PURE__ */ new Set([
2301
+ const DIRECTIVES_THAT_HIDE_COMPILER_BAILOUTS = /* @__PURE__ */ new Set([
2248
2302
  "use memo",
2249
2303
  "use no memo",
2250
2304
  "use no forget"
@@ -2276,7 +2330,7 @@ var no_manual_memo_default = defineRule({
2276
2330
  const allowMemoHooks = readAllowMemoHooks(context.options);
2277
2331
  return {
2278
2332
  ExpressionStatement(node) {
2279
- if (typeof node.directive !== "string" || !MEMO_DIRECTIVES.has(node.directive)) return;
2333
+ if (typeof node.directive !== "string" || !DIRECTIVES_THAT_HIDE_COMPILER_BAILOUTS.has(node.directive)) return;
2280
2334
  context.report({
2281
2335
  node,
2282
2336
  message: node.directive === "use memo" ? "Drop \"use memo\": restructure so the compiler caches this on its own, e.g. move plain uses of a value before the hook call that splits its scope, or inline the helper." : `Drop "${node.directive}": fix the code the compiler cannot prove safe instead of skipping it.`
@@ -2294,6 +2348,85 @@ var no_manual_memo_default = defineRule({
2294
2348
  };
2295
2349
  }
2296
2350
  });
2351
+ // src/rules/no-raw-color.ts
2352
+ const DEFAULT_MESSAGE$1 = "Colors come from the theme. Read a CSS custom property (var(--token)) instead of a color literal, so every theme and its light and dark variants apply.";
2353
+ const readMessage$1 = (options) => {
2354
+ const [first] = options;
2355
+ return typeof first === "object" && first !== null && "message" in first && typeof first.message === "string" ? first.message : DEFAULT_MESSAGE$1;
2356
+ };
2357
+ const NAMED_COLORS = new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" "));
2358
+ const HEX = "#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})";
2359
+ const HEX_COLOR = new RegExp(`^\\s*${HEX}\\s*$`, "i");
2360
+ const HEX_IN_VALUE = new RegExp(`(?:^|[\\s,(:])${HEX}(?=$|[\\s,;)!])`, "i");
2361
+ const ENCODED_HEX = /%23(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})\b/i;
2362
+ const COLOR_FUNCTION = /\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i;
2363
+ const CSS_VALUE = /\b(?:solid|dashed|dotted|double|inset|gradient|-?[\d.]+(?:px|em|rem|%|deg))\b|^\s*[a-z-]+\s*:/i;
2364
+ const ONLY_LENGTHS_AND_HEX = new RegExp(`^\\s*(?:(?:-?[\\d.]+[a-z%]*|${HEX})\\s*)+$`, "i");
2365
+ const WORDS = /[a-z]+/gi;
2366
+ const COLOR_PLACE = /(?:color|colour|background|fill|stroke|border|outline|shadow|style)$/i;
2367
+ const SELECTOR_CALLS = /* @__PURE__ */ new Set([
2368
+ "querySelector",
2369
+ "querySelectorAll",
2370
+ "closest",
2371
+ "matches"
2372
+ ]);
2373
+ const hasNamedColor = (text) => Array.from(text.matchAll(WORDS), ([word]) => word.toLowerCase()).some((word) => NAMED_COLORS.has(word));
2374
+ const isValueText = (text) => HEX_COLOR.test(text) || COLOR_FUNCTION.test(text) || ENCODED_HEX.test(text) || ONLY_LENGTHS_AND_HEX.test(text) && HEX_IN_VALUE.test(text) || CSS_VALUE.test(text) && (HEX_IN_VALUE.test(text) || hasNamedColor(text));
2375
+ const nameOf = (node) => {
2376
+ if (node === null || node === void 0) return null;
2377
+ if (node.type === "Identifier") return node.name;
2378
+ if (node.type === "Literal" && typeof node.value === "string") return node.value;
2379
+ if (node.type === "JSXIdentifier") return node.name;
2380
+ if (node.type === "MemberExpression") return nameOf(node.property);
2381
+ return null;
2382
+ };
2383
+ const isColorPlace = (node) => {
2384
+ const parent = node.parent;
2385
+ if (parent === void 0 || parent === null) return false;
2386
+ if (parent.type === "JSXExpressionContainer") return isColorPlace(parent);
2387
+ if (parent.type === "Property" && parent.value === node) return COLOR_PLACE.test(nameOf(parent.key) ?? "");
2388
+ if (parent.type === "AssignmentExpression" && parent.right === node) return COLOR_PLACE.test(nameOf(parent.left) ?? "");
2389
+ if (parent.type === "JSXAttribute") return COLOR_PLACE.test(nameOf(parent.name) ?? "");
2390
+ if (parent.type === "CallExpression" && parent.arguments[1] === node) return nameOf(parent.callee) === "setProperty";
2391
+ return false;
2392
+ };
2393
+ const isSelector = (node) => {
2394
+ const parent = node.parent;
2395
+ return parent?.type === "CallExpression" && parent.arguments[0] === node && SELECTOR_CALLS.has(nameOf(parent.callee) ?? "");
2396
+ };
2397
+ var no_raw_color_default = defineRule({
2398
+ meta: {
2399
+ type: "problem",
2400
+ docs: { description: "Disallow color literals in code, so colors come from theme tokens that follow light and dark." },
2401
+ schema: [{
2402
+ type: "object",
2403
+ properties: { message: {
2404
+ type: "string",
2405
+ description: "Names the project's theme tokens and where they live."
2406
+ } },
2407
+ additionalProperties: false
2408
+ }]
2409
+ },
2410
+ create(context) {
2411
+ const message = readMessage$1(context.options);
2412
+ return {
2413
+ Literal(node) {
2414
+ if (typeof node.value !== "string" || isSelector(node)) return;
2415
+ const text = node.value;
2416
+ if (NAMED_COLORS.has(text.trim().toLowerCase()) && isColorPlace(node) || isValueText(text)) context.report({
2417
+ node,
2418
+ message
2419
+ });
2420
+ },
2421
+ TemplateElement(node) {
2422
+ if (isValueText(node.value.cooked ?? node.value.raw)) context.report({
2423
+ node,
2424
+ message
2425
+ });
2426
+ }
2427
+ };
2428
+ }
2429
+ });
2297
2430
  // src/rules/no-polling-loop-in-tests.ts
2298
2431
  const TEST_FILE_PATTERN$4 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2299
2432
  const FUNCTIONS$2 = /* @__PURE__ */ new Set([
@@ -2308,16 +2441,16 @@ const COUNTER_OPERATORS = /* @__PURE__ */ new Set([
2308
2441
  ">="
2309
2442
  ]);
2310
2443
  const TIMERS = /* @__PURE__ */ new Set(["setImmediate", "setTimeout"]);
2311
- const MESSAGE$3 = "Polling loop in a test. Spinning on `yieldNow`/`sleep` is scheduler- and load-dependent. Await the `Deferred`, `Queue.take`, `Stream` element, `drain()`, or `expect.poll` that marks the milestone.";
2444
+ const MESSAGE$2 = "Polling loop in a test. Spinning on `yieldNow`/`sleep` is scheduler- and load-dependent. Await the `Deferred`, `Queue.take`, `Stream` element, `drain()`, or `expect.poll` that marks the milestone.";
2312
2445
  const isNode = (value) => typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
2313
- const someDescendant = (node, match) => {
2314
- if (Array.isArray(node)) return node.some((child) => someDescendant(child, match));
2446
+ const someDescendantOutsideNestedFunctions = (node, match) => {
2447
+ if (Array.isArray(node)) return node.some((child) => someDescendantOutsideNestedFunctions(child, match));
2315
2448
  if (!isNode(node)) return false;
2316
2449
  if (match(node)) return true;
2317
2450
  if (FUNCTIONS$2.has(node.type)) return false;
2318
2451
  for (const [key, value] of Object.entries(node)) {
2319
2452
  if (key === "parent") continue;
2320
- if (someDescendant(value, match)) return true;
2453
+ if (someDescendantOutsideNestedFunctions(value, match)) return true;
2321
2454
  }
2322
2455
  return false;
2323
2456
  };
@@ -2337,7 +2470,7 @@ const isTimerReference = (node) => {
2337
2470
  const expression = unwrapExpression(node);
2338
2471
  return isSome(expression) && expression.value.type === "Identifier" && TIMERS.has(expression.value.name);
2339
2472
  };
2340
- const isTickPromise = (node) => {
2473
+ const isPromiseResolveOrTimerPromise = (node) => {
2341
2474
  const expression = unwrapExpression(node);
2342
2475
  if (isNone(expression)) return false;
2343
2476
  const value = expression.value;
@@ -2346,34 +2479,34 @@ const isTickPromise = (node) => {
2346
2479
  const [executor] = value.arguments;
2347
2480
  if (isTimerReference(executor)) return true;
2348
2481
  if (!isNode(executor) || !FUNCTIONS$2.has(executor.type)) return false;
2349
- return someDescendant(executor.body, (child) => child.type === "CallExpression" && isTimerReference(child.callee));
2482
+ return someDescendantOutsideNestedFunctions(executor.body, (child) => child.type === "CallExpression" && isTimerReference(child.callee));
2350
2483
  };
2351
2484
  const thunkReturnsTick = (node) => {
2352
2485
  if (!isNode(node) || node.type !== "ArrowFunctionExpression") return false;
2353
2486
  const body = node.body;
2354
- if (body.type !== "BlockStatement") return isTickPromise(body);
2487
+ if (body.type !== "BlockStatement") return isPromiseResolveOrTimerPromise(body);
2355
2488
  const last = body.body.at(-1);
2356
- return last?.type === "ReturnStatement" && isTickPromise(last.argument);
2489
+ return last?.type === "ReturnStatement" && isPromiseResolveOrTimerPromise(last.argument);
2357
2490
  };
2358
2491
  const isWait = (node) => {
2359
2492
  if (node.type === "MemberExpression") return isMember(node, "Effect", "yieldNow");
2360
- if (node.type === "AwaitExpression") return isTickPromise(node.argument);
2361
- if (node.type === "NewExpression") return isTickPromise(node);
2493
+ if (node.type === "AwaitExpression") return isPromiseResolveOrTimerPromise(node.argument);
2494
+ if (node.type === "NewExpression") return isPromiseResolveOrTimerPromise(node);
2362
2495
  if (node.type !== "CallExpression") return false;
2363
2496
  if (isMember(node.callee, "Effect", "sleep")) return true;
2364
2497
  if (isIdentifier(unwrapExpression(node.callee), "setImmediate")) return true;
2365
2498
  if (isMember(node.callee, "Effect", "promise")) return thunkReturnsTick(node.arguments[0]);
2366
2499
  return false;
2367
2500
  };
2368
- const hasConditionalExit = (body) => someDescendant(body, (node) => node.type === "IfStatement" && someDescendant([node.consequent, node.alternate], (child) => child.type === "ReturnStatement" || child.type === "BreakStatement" || child.type === "ThrowStatement"));
2501
+ const hasConditionalExit = (body) => someDescendantOutsideNestedFunctions(body, (node) => node.type === "IfStatement" && someDescendantOutsideNestedFunctions([node.consequent, node.alternate], (child) => child.type === "ReturnStatement" || child.type === "BreakStatement" || child.type === "ThrowStatement"));
2369
2502
  const isNumericBound = (node) => {
2370
2503
  const expression = unwrapExpression(node);
2371
2504
  if (isNone(expression)) return false;
2372
2505
  const value = expression.value;
2373
2506
  return value.type === "Identifier" || value.type === "Literal" && typeof value.value === "number";
2374
2507
  };
2375
- const updatesCounter = (node, name) => someDescendant(node, (child) => child.type === "UpdateExpression" && isIdentifier(unwrapExpression(child.argument), name) || child.type === "AssignmentExpression" && (child.operator === "+=" || child.operator === "-=") && isIdentifier(unwrapExpression(child.left), name));
2376
- const isCounterTest = (loop) => {
2508
+ const updatesCounter = (node, name) => someDescendantOutsideNestedFunctions(node, (child) => child.type === "UpdateExpression" && isIdentifier(unwrapExpression(child.argument), name) || child.type === "AssignmentExpression" && (child.operator === "+=" || child.operator === "-=") && isIdentifier(unwrapExpression(child.left), name));
2509
+ const isBoundByCounterTheLoopAdvances = (loop) => {
2377
2510
  if (loop.test == null) return false;
2378
2511
  const expression = unwrapExpression(loop.test);
2379
2512
  if (isNone(expression) || expression.value.type !== "BinaryExpression") return false;
@@ -2389,7 +2522,7 @@ const isTrueLiteral = (test) => {
2389
2522
  const expression = unwrapExpression(test);
2390
2523
  return isSome(expression) && expression.value.type === "Literal" && expression.value.value === true;
2391
2524
  };
2392
- const hasPredicateExit = (loop) => hasConditionalExit(loop.body) || loop.test != null && !isTrueLiteral(loop.test) && !isCounterTest(loop);
2525
+ const hasPredicateExit = (loop) => hasConditionalExit(loop.body) || loop.test != null && !isTrueLiteral(loop.test) && !isBoundByCounterTheLoopAdvances(loop);
2393
2526
  var no_polling_loop_in_tests_default = defineRule({
2394
2527
  meta: {
2395
2528
  type: "problem",
@@ -2399,11 +2532,11 @@ var no_polling_loop_in_tests_default = defineRule({
2399
2532
  create(context) {
2400
2533
  if (!TEST_FILE_PATTERN$4.test(context.filename)) return {};
2401
2534
  const check = (loop) => {
2402
- if (!someDescendant(loop.body, isWait)) return;
2535
+ if (!someDescendantOutsideNestedFunctions(loop.body, isWait)) return;
2403
2536
  if (!hasPredicateExit(loop)) return;
2404
2537
  context.report({
2405
2538
  node: loop,
2406
- message: MESSAGE$3
2539
+ message: MESSAGE$2
2407
2540
  });
2408
2541
  };
2409
2542
  return {
@@ -2436,7 +2569,7 @@ const FUNCTIONS$1 = /* @__PURE__ */ new Set([
2436
2569
  const REAL_CLOCK_MESSAGE = "Real-clock wait in a test. Await the `Deferred`/`Queue`/event that marks the milestone, or run under `it.effect` and `TestClock.adjust`. `it.live` is for subprocess/network fixtures, not for sleeping.";
2437
2570
  const UNDRIVEN_TEST_CLOCK_MESSAGE = "Sleeps on the TestClock never fire without `TestClock.adjust`; this test can only time out.";
2438
2571
  const MIXED_CLOCK_MESSAGE = "`setTimeout` is wall-clock while `Effect.sleep` here is TestClock; they never meet.";
2439
- const calleeChain = (callee) => {
2572
+ const flattenCalleeChain = (callee) => {
2440
2573
  const members = [];
2441
2574
  const calls = [];
2442
2575
  let current = unwrapExpression(callee);
@@ -2480,13 +2613,13 @@ const excludesTestServices = (chain) => chain.calls.some((call) => call.argument
2480
2613
  return isSome(key) && key.value === "excludeTestServices" && isSome(value) && value.value.type === "Literal" && value.value.value === true;
2481
2614
  });
2482
2615
  }));
2483
- const enclosingTester = (node) => {
2616
+ const clockOfNearestEnclosingTest = (node) => {
2484
2617
  let child = node;
2485
2618
  let current = node.parent;
2486
2619
  let tester = none();
2487
2620
  while (current) {
2488
2621
  if (current.type === "CallExpression" && current.arguments.some((argument) => argument === child)) {
2489
- const chain = calleeChain(current.callee);
2622
+ const chain = flattenCalleeChain(current.callee);
2490
2623
  if (isSome(chain)) {
2491
2624
  if (isNone(tester)) {
2492
2625
  tester = testerKind(chain.value);
@@ -2514,7 +2647,7 @@ const LOOPS$1 = /* @__PURE__ */ new Set([
2514
2647
  "ForStatement",
2515
2648
  "WhileStatement"
2516
2649
  ]);
2517
- const isPollingLoopStep = (node) => {
2650
+ const isUnconditionalStatementOfLoopBody = (node) => {
2518
2651
  let statement = node.parent;
2519
2652
  while (statement && statement.type !== "ExpressionStatement") {
2520
2653
  if (FUNCTIONS$1.has(statement.type)) return false;
@@ -2545,7 +2678,7 @@ var no_real_time_wait_in_tests_default = defineRule({
2545
2678
  create(context) {
2546
2679
  if (!TEST_FILE_PATTERN$3.test(context.filename)) return {};
2547
2680
  let drivesTestClock = false;
2548
- const untilDrivenReports = [];
2681
+ const reportsUnlessFileDrivesTestClock = [];
2549
2682
  const timerPromiseLocals = /* @__PURE__ */ new Set();
2550
2683
  const timerPromiseNamespaces = /* @__PURE__ */ new Set();
2551
2684
  const isTimerPromiseCall = (callee) => {
@@ -2576,7 +2709,7 @@ var no_real_time_wait_in_tests_default = defineRule({
2576
2709
  message
2577
2710
  });
2578
2711
  if (isTimerPromiseCall(node.callee) || isCallbackTimer(node.callee) && isInsidePromiseExecutor(node)) {
2579
- const tester = enclosingTester(node);
2712
+ const tester = clockOfNearestEnclosingTest(node);
2580
2713
  reportFor(isSome(tester) && tester.value === "effect" ? `${REAL_CLOCK_MESSAGE} ${MIXED_CLOCK_MESSAGE}` : REAL_CLOCK_MESSAGE);
2581
2714
  return;
2582
2715
  }
@@ -2589,31 +2722,31 @@ var no_real_time_wait_in_tests_default = defineRule({
2589
2722
  }
2590
2723
  const isSleep = object === "Effect" && property === "sleep";
2591
2724
  if (!(isSleep || object === "Effect" && property === "delay" || object === "Schedule" && SCHEDULE_WAITS.has(property))) return;
2592
- const tester = enclosingTester(node);
2725
+ const tester = clockOfNearestEnclosingTest(node);
2593
2726
  if (isNone(tester)) {
2594
- if (isPollingLoopStep(node)) reportFor(REAL_CLOCK_MESSAGE);
2595
- else untilDrivenReports.push({
2727
+ if (isUnconditionalStatementOfLoopBody(node)) reportFor(REAL_CLOCK_MESSAGE);
2728
+ else reportsUnlessFileDrivesTestClock.push({
2596
2729
  node: node.callee,
2597
2730
  message: REAL_CLOCK_MESSAGE
2598
2731
  });
2599
2732
  return;
2600
2733
  }
2601
2734
  if (tester.value !== "effect") reportFor(REAL_CLOCK_MESSAGE);
2602
- else if (isSleep) untilDrivenReports.push({
2735
+ else if (isSleep) reportsUnlessFileDrivesTestClock.push({
2603
2736
  node: node.callee,
2604
2737
  message: UNDRIVEN_TEST_CLOCK_MESSAGE
2605
2738
  });
2606
2739
  },
2607
2740
  "Program:exit"() {
2608
2741
  if (drivesTestClock) return;
2609
- for (const report of untilDrivenReports) context.report(report);
2742
+ for (const report of reportsUnlessFileDrivesTestClock) context.report(report);
2610
2743
  }
2611
2744
  };
2612
2745
  }
2613
2746
  });
2614
2747
  // src/rules/no-test-in-loop.ts
2615
2748
  const TEST_FILE_PATTERN$2 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2616
- const NODE_TEST_IMPORT_PATTERN = /["']node:test["']/u;
2749
+ const NODE_TEST_IMPORT_WHICH_HAS_NO_EACH = /["']node:test["']/u;
2617
2750
  const TEST_FUNCTIONS$1 = /* @__PURE__ */ new Set([
2618
2751
  "describe",
2619
2752
  "it",
@@ -2659,7 +2792,7 @@ var no_test_in_loop_default = defineRule({
2659
2792
  },
2660
2793
  create(context) {
2661
2794
  if (!TEST_FILE_PATTERN$2.test(context.filename)) return {};
2662
- if (NODE_TEST_IMPORT_PATTERN.test(context.sourceCode.text)) return {};
2795
+ if (NODE_TEST_IMPORT_WHICH_HAS_NO_EACH.test(context.sourceCode.text)) return {};
2663
2796
  return { CallExpression(node) {
2664
2797
  const name = testCallName(node.callee);
2665
2798
  if (isNone(name)) return;
@@ -2673,7 +2806,7 @@ var no_test_in_loop_default = defineRule({
2673
2806
  });
2674
2807
  // src/rules/no-test-timeout-or-unreasoned-skip.ts
2675
2808
  const TEST_FILE_PATTERN$1 = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2676
- const LIVE_TEST_FILE_PATTERN = /\.live\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2809
+ const OPT_IN_LIVE_AGENT_SUITE_PATTERN = /\.live\.(?:test|spec)\.[cm]?[jt]sx?$/u;
2677
2810
  const TEST_FUNCTIONS = /* @__PURE__ */ new Set([
2678
2811
  "describe",
2679
2812
  "it",
@@ -2707,16 +2840,16 @@ const SET_CONFIG_OPTIONS = /* @__PURE__ */ new Set([
2707
2840
  const QUARANTINE_PATTERN = /quarantine:\s*#\d+|https:\/\/github\.com\/[^\s/]+\/[^\s/]+\/issues\/\d+/u;
2708
2841
  const TIMEOUT_MESSAGE = "Per-test timeouts and retries hide waits that should be event-driven; the project timeout is the ceiling. Remove the override and await the milestone.";
2709
2842
  const SKIP_MESSAGE = "A skipped test needs a tracking issue in the comment above it: `// quarantine: #1234 <why>`.";
2710
- const chainRoot = (node) => {
2843
+ const identifierThatRegistersTheTest = (node) => {
2711
2844
  const expression = unwrapExpression(node);
2712
2845
  if (isNone(expression)) return none();
2713
2846
  const value = expression.value;
2714
2847
  if (value.type === "Identifier") return some(value.name);
2715
- if (value.type === "MemberExpression") return chainRoot(value.object);
2716
- if (value.type === "CallExpression") return chainRoot(value.callee);
2848
+ if (value.type === "MemberExpression") return identifierThatRegistersTheTest(value.object);
2849
+ if (value.type === "CallExpression") return identifierThatRegistersTheTest(value.callee);
2717
2850
  return none();
2718
2851
  };
2719
- const isTestChain = (node) => exists(chainRoot(node), (name) => TEST_FUNCTIONS.has(name));
2852
+ const isTestChain = (node) => exists(identifierThatRegistersTheTest(node), (name) => TEST_FUNCTIONS.has(name));
2720
2853
  const hasEnabledOption = (node, names) => {
2721
2854
  const expression = unwrapExpression(node);
2722
2855
  if (isNone(expression) || expression.value.type !== "ObjectExpression") return false;
@@ -2741,7 +2874,7 @@ var no_test_timeout_or_unreasoned_skip_default = defineRule({
2741
2874
  },
2742
2875
  create(context) {
2743
2876
  if (!TEST_FILE_PATTERN$1.test(context.filename)) return {};
2744
- const checkTimeouts = !LIVE_TEST_FILE_PATTERN.test(context.filename);
2877
+ const checkTimeouts = !OPT_IN_LIVE_AGENT_SUITE_PATTERN.test(context.filename);
2745
2878
  const reportUnlessQuarantined = (node) => {
2746
2879
  if (context.sourceCode.getCommentsBefore(enclosingStatement(node)).some((comment) => QUARANTINE_PATTERN.test(comment.value))) return;
2747
2880
  context.report({
@@ -2753,7 +2886,7 @@ var no_test_timeout_or_unreasoned_skip_default = defineRule({
2753
2886
  CallExpression(node) {
2754
2887
  const callee = unwrapExpression(node.callee);
2755
2888
  if (isNone(callee)) return;
2756
- if (callee.value.type === "MemberExpression" && exists(chainRoot(callee.value.object), (name) => name === "vi") && exists(getPropertyName(callee.value.property), (name) => name === "setConfig")) {
2889
+ if (callee.value.type === "MemberExpression" && exists(identifierThatRegistersTheTest(callee.value.object), (name) => name === "vi") && exists(getPropertyName(callee.value.property), (name) => name === "setConfig")) {
2757
2890
  if (checkTimeouts && hasOption(node.arguments[0], SET_CONFIG_OPTIONS)) context.report({
2758
2891
  node,
2759
2892
  message: TIMEOUT_MESSAGE
@@ -2806,7 +2939,7 @@ const isEffectHookCall = (node) => {
2806
2939
  if (expression.type === "MemberExpression" && !expression.computed) return exists(getPropertyName(expression.property), (name) => EFFECT_HOOKS.has(name));
2807
2940
  return false;
2808
2941
  };
2809
- const MESSAGE$2 = "Stop and reconsider before keeping this effect. Is it computable from props or state? Compute it during render; the compiler memoizes it. Does it respond to a user action? Do it in that handler. Does it reset state when a prop changes? Key the component on that prop. Does it tell a parent or store that a value changed? Do it where the change happens. Does it load app data? Read it from the data layer (an atom, query or loader). Does it read a value from outside React? Use a store subscription or useSyncExternalStore. An effect that sets state another effect reads is one handler or one derivation. An effect is right only when it keeps something outside React in step with this component while mounted: a DOM node, listener, timer, native module, connection, router, imperative toast, or a registry entry or resource held until unmount. Moving the same logic into a ref or store to dodge this rule is not a fix. If the effect does that, name what it keeps in step on the line above: `// oxlint-disable-next-line jandragsbaek/no-unreasoned-state-sync -- <what it syncs with and why>`.";
2942
+ const MESSAGE_FOR_AGENTS_ALTERNATIVES_FIRST = "Stop and reconsider before keeping this effect. Is it computable from props or state? Compute it during render; the compiler memoizes it. Does it respond to a user action? Do it in that handler. Does it reset state when a prop changes? Key the component on that prop. Does it tell a parent or store that a value changed? Do it where the change happens. Does it load app data? Read it from the data layer (an atom, query or loader). Does it read a value from outside React? Use a store subscription or useSyncExternalStore. An effect that sets state another effect reads is one handler or one derivation. An effect is right only when it keeps something outside React in step with this component while mounted: a DOM node, listener, timer, native module, connection, router, imperative toast, or a registry entry or resource held until unmount. Moving the same logic into a ref or store to dodge this rule is not a fix. If the effect does that, name what it keeps in step on the line above: `// oxlint-disable-next-line jandragsbaek/no-unreasoned-state-sync -- <what it syncs with and why>`.";
2810
2943
  var no_unreasoned_state_sync_default = defineRule({
2811
2944
  meta: {
2812
2945
  type: "suggestion",
@@ -2818,18 +2951,20 @@ var no_unreasoned_state_sync_default = defineRule({
2818
2951
  if (!isEffectHookCall(node)) return;
2819
2952
  context.report({
2820
2953
  node,
2821
- message: MESSAGE$2
2954
+ message: MESSAGE_FOR_AGENTS_ALTERNATIVES_FIRST
2822
2955
  });
2823
2956
  } };
2824
2957
  }
2825
2958
  });
2826
2959
  // src/rules/no-unscoped-has.ts
2827
2960
  const COMBINATOR_PATTERN = /[\s>+~]/u;
2828
- const NARROWING_PATTERN = /[.#[]|^[a-z]/iu;
2961
+ const CLASS_ID_ATTRIBUTE_OR_LEADING_TAG = /[.#[]|^[a-z]/iu;
2829
2962
  const ROOT_COMPOUND_PATTERN = /^(?:html|body|:root)(?![\w-])/iu;
2830
- const GROUP_PREFIX_PATTERN = /(?:^|:)(?:group|peer)-$/u;
2831
- const ANCESTOR_PREFIX_PATTERN = /(?:^|:)in-$/u;
2832
- const ATTRIBUTE_PREFIX_PATTERN = /(?:^|:)(?:data|aria)-$/u;
2963
+ const GROUP_OR_PEER_ELEMENT_PREFIX = /(?:^|:)(?:group|peer)-$/u;
2964
+ const ANCESTOR_PREFIX = /(?:^|:)in-$/u;
2965
+ const ATTRIBUTE_VALUE_NOT_SELECTOR_PREFIX = /(?:^|:)(?:data|aria)-$/u;
2966
+ const TAILWIND_SPACE = "_";
2967
+ const TAILWIND_ELEMENT_WITH_THE_CLASS = "&";
2833
2968
  const QUOTED_PATTERN = /(["'])(?:\\.|(?!\1).)*\1/gu;
2834
2969
  const VARIANT_END_PATTERN = /^(?:\/[\w-]+)?:/u;
2835
2970
  function variantGroups(token) {
@@ -2857,7 +2992,7 @@ function closingParen(selector, open) {
2857
2992
  else if (selector[index] === ")" && --depth === 0) return index;
2858
2993
  return selector.length;
2859
2994
  }
2860
- function isWrapperSubject(selector, from) {
2995
+ function hasIsInSubjectPositionOfNotIsOrWhere(selector, from) {
2861
2996
  let depth = 0;
2862
2997
  for (let index = from; index < selector.length; index++) {
2863
2998
  const char = selector[index] ?? "";
@@ -2882,22 +3017,22 @@ function hasCompounds(selector) {
2882
3017
  let compound = "";
2883
3018
  let depth = 0;
2884
3019
  let subjectEnd = closingParen(selector, index + 4) + 1;
2885
- let skippingBranch = false;
3020
+ let skippingOtherSelectorListBranch = false;
2886
3021
  for (let position = index - 1; position >= 0; position--) {
2887
3022
  const char = selector[position] ?? "";
2888
3023
  if (char === ")") depth++;
2889
3024
  else if (char === "(") {
2890
3025
  if (depth > 0) depth--;
2891
3026
  else {
2892
- if (!isWrapperSubject(selector, subjectEnd)) break;
2893
- skippingBranch = false;
3027
+ if (!hasIsInSubjectPositionOfNotIsOrWhere(selector, subjectEnd)) break;
3028
+ skippingOtherSelectorListBranch = false;
2894
3029
  subjectEnd = closingParen(selector, position) + 1;
2895
3030
  }
2896
3031
  } else if (depth === 0 && char === ",") {
2897
- skippingBranch = true;
3032
+ skippingOtherSelectorListBranch = true;
2898
3033
  continue;
2899
- } else if (depth === 0 && !skippingBranch && COMBINATOR_PATTERN.test(char)) break;
2900
- if (!skippingBranch) compound = char + compound;
3034
+ } else if (depth === 0 && !skippingOtherSelectorListBranch && COMBINATOR_PATTERN.test(char)) break;
3035
+ if (!skippingOtherSelectorListBranch) compound = char + compound;
2901
3036
  }
2902
3037
  compounds.push(compound);
2903
3038
  index = selector.indexOf(":has(", index + 1);
@@ -2924,12 +3059,12 @@ function findUnscopedHasVariants(text) {
2924
3059
  if (!text.toLowerCase().includes(":has(")) return [];
2925
3060
  const offenders = [];
2926
3061
  for (const token of text.split(/\s+/u)) for (const { prefix, group } of variantGroups(token)) {
2927
- if (ATTRIBUTE_PREFIX_PATTERN.test(prefix)) continue;
2928
- const relative = group.toLowerCase().replace(QUOTED_PATTERN, "\"\"").replaceAll("_", " ");
2929
- const owner = GROUP_PREFIX_PATTERN.test(prefix) ? ".group" : ".self";
2930
- if (hasCompounds(ANCESTOR_PREFIX_PATTERN.test(prefix) ? `:is(${relative.replaceAll("&", "*")}) .self` : relative.includes("&") ? relative.replaceAll("&", owner) : `${owner}:is(${relative})`).some((compound) => {
3062
+ if (ATTRIBUTE_VALUE_NOT_SELECTOR_PREFIX.test(prefix)) continue;
3063
+ const relative = group.toLowerCase().replace(QUOTED_PATTERN, "\"\"").replaceAll(TAILWIND_SPACE, " ");
3064
+ const owner = GROUP_OR_PEER_ELEMENT_PREFIX.test(prefix) ? ".group" : ".self";
3065
+ if (hasCompounds(ANCESTOR_PREFIX.test(prefix) ? `:is(${relative.replaceAll(TAILWIND_ELEMENT_WITH_THE_CLASS, "*")}) .self` : relative.includes(TAILWIND_ELEMENT_WITH_THE_CLASS) ? relative.replaceAll(TAILWIND_ELEMENT_WITH_THE_CLASS, owner) : `${owner}:is(${relative})`).some((compound) => {
2931
3066
  const anchor = withoutNegations(compound);
2932
- return !NARROWING_PATTERN.test(anchor) || ROOT_COMPOUND_PATTERN.test(anchor);
3067
+ return !CLASS_ID_ATTRIBUTE_OR_LEADING_TAG.test(anchor) || ROOT_COMPOUND_PATTERN.test(anchor);
2933
3068
  })) offenders.push(`[${group}]`);
2934
3069
  }
2935
3070
  return offenders;
@@ -2964,8 +3099,7 @@ const readMessage = (options) => {
2964
3099
  const [first] = options;
2965
3100
  return typeof first === "object" && first !== null && "message" in first && typeof first.message === "string" ? first.message : DEFAULT_MESSAGE;
2966
3101
  };
2967
- /** Attributes that users read or hear. */
2968
- const USER_FACING_ATTRIBUTES = /* @__PURE__ */ new Set([
3102
+ const ATTRIBUTES_USERS_READ_OR_HEAR = /* @__PURE__ */ new Set([
2969
3103
  "alt",
2970
3104
  "aria-description",
2971
3105
  "aria-label",
@@ -2976,7 +3110,7 @@ const USER_FACING_ATTRIBUTES = /* @__PURE__ */ new Set([
2976
3110
  "placeholder",
2977
3111
  "title"
2978
3112
  ]);
2979
- const HAS_LETTER = /\p{L}/u;
3113
+ const HAS_LETTER_NOT_ONLY_SEPARATORS_OR_MARKS = /\p{L}/u;
2980
3114
  var no_untranslated_ui_text_default = defineRule({
2981
3115
  meta: {
2982
3116
  type: "problem",
@@ -2993,7 +3127,7 @@ var no_untranslated_ui_text_default = defineRule({
2993
3127
  create(context) {
2994
3128
  const message = readMessage(context.options);
2995
3129
  const check = (node, text) => {
2996
- if (HAS_LETTER.test(text)) context.report({
3130
+ if (HAS_LETTER_NOT_ONLY_SEPARATORS_OR_MARKS.test(text)) context.report({
2997
3131
  node,
2998
3132
  message
2999
3133
  });
@@ -3003,7 +3137,7 @@ var no_untranslated_ui_text_default = defineRule({
3003
3137
  check(node, node.value);
3004
3138
  },
3005
3139
  JSXAttribute(node) {
3006
- if (node.name.type !== "JSXIdentifier" || !USER_FACING_ATTRIBUTES.has(node.name.name)) return;
3140
+ if (node.name.type !== "JSXIdentifier" || !ATTRIBUTES_USERS_READ_OR_HEAR.has(node.name.name)) return;
3007
3141
  const value = node.value;
3008
3142
  if (value?.type === "Literal" && typeof value.value === "string") check(value, value.value);
3009
3143
  if (value?.type === "JSXExpressionContainer" && value.expression.type === "Literal" && typeof value.expression.value === "string") check(value.expression, value.expression.value);
@@ -3057,7 +3191,7 @@ const isMockingCall = (callee) => {
3057
3191
  if (MOCK_METHODS.has(property.value)) return true;
3058
3192
  return VI_MOCKING_FUNCTIONS.has(property.value) && isIdentifier(unwrapExpression(expression.value.object), "vi");
3059
3193
  };
3060
- const isMockArgument = (node) => {
3194
+ const seedsFakeTimeThroughAMock = (node) => {
3061
3195
  let child = node;
3062
3196
  let current = node.parent;
3063
3197
  while (current) {
@@ -3077,7 +3211,7 @@ var no_wall_clock_in_tests_default = defineRule({
3077
3211
  return {
3078
3212
  CallExpression(node) {
3079
3213
  if (!isWallClockCall(node.callee)) return;
3080
- if (isMockArgument(node)) return;
3214
+ if (seedsFakeTimeThroughAMock(node)) return;
3081
3215
  context.report({
3082
3216
  node,
3083
3217
  message: MESSAGE$1
@@ -3086,7 +3220,7 @@ var no_wall_clock_in_tests_default = defineRule({
3086
3220
  NewExpression(node) {
3087
3221
  if (node.arguments.length > 0) return;
3088
3222
  if (!isIdentifier(unwrapExpression(node.callee), "Date")) return;
3089
- if (isMockArgument(node)) return;
3223
+ if (seedsFakeTimeThroughAMock(node)) return;
3090
3224
  context.report({
3091
3225
  node,
3092
3226
  message: MESSAGE$1
@@ -3207,22 +3341,23 @@ var prefer_effect_fn_default = defineRule({
3207
3341
  }
3208
3342
  });
3209
3343
  // src/rules/require-suppression-reason.ts
3210
- const DIRECTIVE_PATTERN = /^\s*\*?\s*(?:(?:oxlint|eslint)-(?:disable|enable)|@ts-(?:expect-error|ignore|nocheck)|@effect-diagnostics)/u;
3211
3344
  const TS_DIRECTIVE_PATTERN = /^\s*\*?\s*@ts-(?:expect-error|ignore|nocheck)(?![\w-])(.*)$/su;
3212
- const EMPTY_COMMENT_PATTERN = /^[\s*]*$/u;
3213
3345
  // src/index.ts
3214
3346
  var src_default = definePlugin({
3215
3347
  meta: { name: "jandragsbaek" },
3216
3348
  rules: {
3349
+ "max-file-lines": max_file_lines_default,
3350
+ "max-file-lines-hard": max_file_lines_hard_default,
3217
3351
  "namespace-node-imports": namespace_node_imports_default,
3218
3352
  "no-dom-test-environment": no_dom_test_environment_default,
3219
3353
  "no-em-dash-copy": no_em_dash_copy_default,
3354
+ "no-explanatory-comments": no_explanatory_comments_default,
3220
3355
  "no-hookless-use-function": no_hookless_use_function_default,
3221
3356
  "no-inline-schema-compile": no_inline_schema_compile_default,
3222
- "no-low-value-comments": no_low_value_comments_default,
3223
3357
  "no-manual-effect-runtime-in-tests": no_manual_effect_runtime_in_tests_default,
3224
3358
  "no-manual-memo": no_manual_memo_default,
3225
3359
  "no-polling-loop-in-tests": no_polling_loop_in_tests_default,
3360
+ "no-raw-color": no_raw_color_default,
3226
3361
  "no-real-time-wait-in-tests": no_real_time_wait_in_tests_default,
3227
3362
  "no-test-in-loop": no_test_in_loop_default,
3228
3363
  "no-test-timeout-or-unreasoned-skip": no_test_timeout_or_unreasoned_skip_default,
@@ -3235,37 +3370,24 @@ var src_default = definePlugin({
3235
3370
  "require-suppression-reason": defineRule({
3236
3371
  meta: {
3237
3372
  type: "suggestion",
3238
- docs: { description: "Require every lint or type-checker suppression to say why." }
3373
+ docs: { description: "Require every lint or type-checker suppression to say why, in the directive." }
3239
3374
  },
3240
3375
  create(context) {
3241
3376
  const { sourceCode } = context;
3242
3377
  return { Program() {
3243
- const comments = sourceCode.getAllComments();
3244
- const ownLineCommentsByEndLine = /* @__PURE__ */ new Map();
3245
- for (const comment of comments) {
3246
- const { line, column } = comment.loc.start;
3247
- if ((sourceCode.lines[line - 1] ?? "").slice(0, column).trim() === "") ownLineCommentsByEndLine.set(comment.loc.end.line, comment);
3248
- }
3249
- const explainedAbove = (directive) => {
3250
- let above = ownLineCommentsByEndLine.get(directive.loc.start.line - 1);
3251
- while (above && (DIRECTIVE_PATTERN.test(above.value) || EMPTY_COMMENT_PATTERN.test(above.value))) above = ownLineCommentsByEndLine.get(above.loc.start.line - 1);
3252
- return above !== void 0;
3253
- };
3254
3378
  for (const directive of sourceCode.getDisableDirectives().directives) {
3255
- if (directive.type === "enable" || directive.justification?.trim()) continue;
3256
- if (explainedAbove(directive.node)) continue;
3379
+ if (directive.type === "enable" || directive.justification.trim()) continue;
3257
3380
  context.report({
3258
3381
  loc: directive.node.loc,
3259
- message: "Say why: end the directive with `-- reason` or put a comment on the line above."
3382
+ message: "Say why: end the directive with `-- <reason>`."
3260
3383
  });
3261
3384
  }
3262
- for (const comment of comments) {
3385
+ for (const comment of sourceCode.getAllComments()) {
3263
3386
  const after = TS_DIRECTIVE_PATTERN.exec(comment.value)?.[1];
3264
3387
  if (after === void 0 || after.replace(/^[\s:-]+/u, "").trim()) continue;
3265
- if (explainedAbove(comment)) continue;
3266
3388
  context.report({
3267
3389
  loc: comment.loc,
3268
- message: "Say why: write the reason after the directive or in a comment on the line above."
3390
+ message: "Say why: write the reason after the directive, on the same comment."
3269
3391
  });
3270
3392
  }
3271
3393
  } };