@sarj/eslint-plugin 2.5.0 → 2.6.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.cjs +19 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -7,7 +7,7 @@ declare const rules: {
|
|
|
7
7
|
"no-client-side-data-fetching": _typescript_eslint_utils_ts_eslint.RuleModule<"noClientFetch", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
|
-
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
10
|
+
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble" | "redundantNarration", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
11
11
|
name: string;
|
|
12
12
|
};
|
|
13
13
|
"no-enum": _typescript_eslint_utils_ts_eslint.RuleModule<"noEnum", readonly [{
|
|
@@ -94,7 +94,7 @@ declare const plugin: {
|
|
|
94
94
|
"no-client-side-data-fetching": _typescript_eslint_utils_ts_eslint.RuleModule<"noClientFetch", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
95
95
|
name: string;
|
|
96
96
|
};
|
|
97
|
-
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
97
|
+
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble" | "redundantNarration", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
98
98
|
name: string;
|
|
99
99
|
};
|
|
100
100
|
"no-enum": _typescript_eslint_utils_ts_eslint.RuleModule<"noEnum", readonly [{
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const rules: {
|
|
|
7
7
|
"no-client-side-data-fetching": _typescript_eslint_utils_ts_eslint.RuleModule<"noClientFetch", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
|
-
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
10
|
+
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble" | "redundantNarration", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
11
11
|
name: string;
|
|
12
12
|
};
|
|
13
13
|
"no-enum": _typescript_eslint_utils_ts_eslint.RuleModule<"noEnum", readonly [{
|
|
@@ -94,7 +94,7 @@ declare const plugin: {
|
|
|
94
94
|
"no-client-side-data-fetching": _typescript_eslint_utils_ts_eslint.RuleModule<"noClientFetch", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
95
95
|
name: string;
|
|
96
96
|
};
|
|
97
|
-
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
97
|
+
"no-comment-cruft": _typescript_eslint_utils_ts_eslint.RuleModule<"commentedOutCode" | "sectionBanner" | "fileHeaderPreamble" | "redundantNarration", readonly [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
98
98
|
name: string;
|
|
99
99
|
};
|
|
100
100
|
"no-enum": _typescript_eslint_utils_ts_eslint.RuleModule<"noEnum", readonly [{
|
package/dist/index.js
CHANGED
|
@@ -213,6 +213,8 @@ var no_client_side_data_fetching_default = ESLintUtils2.RuleCreator(
|
|
|
213
213
|
// src/rules/no-comment-cruft.ts
|
|
214
214
|
import { ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
|
|
215
215
|
var LEADING_PREAMBLE_MIN = 4;
|
|
216
|
+
var STEP_NARRATION_RE = /^(?:first(?:ly)?|second(?:ly)?|third(?:ly)?|then|next|after(?:wards| that)?|finally|lastly|now)\s*[,:]\s*\S|^step\s+\d+\b/i;
|
|
217
|
+
var META_COMMENTARY_RE = /\b(?:for now|keeping (?:it|this) simple|could be (?:refactored|improved|cleaned up|simplified)|refactor(?:ed|ing)? (?:later|this)|not sure (?:if|whether|why|how)|quick[- ](?:and[- ]dirty|fix)|(?:a |bit of a )?hacky|is a hack|temporary (?:solution|workaround|fix|hack)|revisit (?:this|later|below)|clean (?:this|it) up|not ideal|placeholder for now)\b/i;
|
|
216
218
|
var DIRECTIVE_RE = /^(eslint\b|eslint-|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
217
219
|
var LICENSE_RE = /copyright|licen[cs]ed?|spdx|permission is hereby granted|all rights reserved/i;
|
|
218
220
|
var BANNER_FULL_RE = /^[\s\-=*#~_+.]{4,}$/;
|
|
@@ -251,6 +253,13 @@ function isProse(text) {
|
|
|
251
253
|
}
|
|
252
254
|
return false;
|
|
253
255
|
}
|
|
256
|
+
function isRedundantNarration(body) {
|
|
257
|
+
const t = body.trim();
|
|
258
|
+
if (!t || looksLikeCode(t) || hasPseudocode(t)) return false;
|
|
259
|
+
if (STEP_NARRATION_RE.test(t)) return true;
|
|
260
|
+
if (META_COMMENTARY_RE.test(t)) return true;
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
254
263
|
function hasCommentedOutCode(texts, precedingProse) {
|
|
255
264
|
for (let i = 0; i < texts.length; i++) {
|
|
256
265
|
const line = texts[i];
|
|
@@ -276,7 +285,8 @@ var no_comment_cruft_default = ESLintUtils3.RuleCreator(
|
|
|
276
285
|
messages: {
|
|
277
286
|
commentedOutCode: "Commented-out code \u2014 delete it; git history remembers.",
|
|
278
287
|
sectionBanner: "Section-banner / region comment \u2014 structure code with functions, not ASCII rules.",
|
|
279
|
-
fileHeaderPreamble: "File-header comment preamble \u2014 use a brief doc comment for the why, not a block of `//` lines."
|
|
288
|
+
fileHeaderPreamble: "File-header comment preamble \u2014 use a brief doc comment for the why, not a block of `//` lines.",
|
|
289
|
+
redundantNarration: "Comment narrates the code \u2014 delete it or say *why*, not *what*. Code is self-documenting."
|
|
280
290
|
}
|
|
281
291
|
},
|
|
282
292
|
defaultOptions: [],
|
|
@@ -331,6 +341,13 @@ var no_comment_cruft_default = ESLintUtils3.RuleCreator(
|
|
|
331
341
|
const precedingProse = prev !== void 0 && prev.type === "Line" && prev.loc.end.line === comment.loc.start.line - 1 && isProse(stripCommentMarker(prev.value));
|
|
332
342
|
if (hasCommentedOutCode(texts, precedingProse)) {
|
|
333
343
|
context.report({ node: comment, messageId: "commentedOutCode" });
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (comment.type === "Line" && texts.length === 1) {
|
|
347
|
+
const body = texts[0];
|
|
348
|
+
if (body !== void 0 && isRedundantNarration(body)) {
|
|
349
|
+
context.report({ node: comment, messageId: "redundantNarration" });
|
|
350
|
+
}
|
|
334
351
|
}
|
|
335
352
|
}
|
|
336
353
|
reportLeadingPreamble(comments, firstCodeLine);
|
|
@@ -3766,7 +3783,7 @@ var rules = {
|
|
|
3766
3783
|
var plugin = {
|
|
3767
3784
|
meta: {
|
|
3768
3785
|
name: "@sarj/eslint-plugin",
|
|
3769
|
-
version: "2.
|
|
3786
|
+
version: "2.6.0"
|
|
3770
3787
|
},
|
|
3771
3788
|
rules,
|
|
3772
3789
|
configs: {
|