@pobammer-ts/eslint-cease-nonsense-rules 1.2.4 → 1.4.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/build-metadata.json +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1532 -38
- package/dist/index.js.map +18 -4
- package/dist/recognizers/camel-case-detector.d.ts +10 -0
- package/dist/recognizers/code-recognizer.d.ts +28 -0
- package/dist/recognizers/contains-detector.d.ts +11 -0
- package/dist/recognizers/detector.d.ts +18 -0
- package/dist/recognizers/end-with-detector.d.ts +11 -0
- package/dist/recognizers/javascript-footprint.d.ts +8 -0
- package/dist/recognizers/keywords-detector.d.ts +11 -0
- package/dist/rules/no-async-constructor.d.ts +7 -0
- package/dist/rules/no-commented-code.d.ts +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Detector } from "./detector";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a detector for camelCase patterns.
|
|
4
|
+
* Returns 1 if lowercase char followed by uppercase char is found.
|
|
5
|
+
*
|
|
6
|
+
* @param probability - Base probability (0-1)
|
|
7
|
+
* @returns Detector instance
|
|
8
|
+
*/
|
|
9
|
+
declare function createCamelCaseDetector(probability: number): Detector;
|
|
10
|
+
export { createCamelCaseDetector };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Detector } from "./detector";
|
|
2
|
+
declare const PROBABILITY_THRESHOLD = 0.9;
|
|
3
|
+
/**
|
|
4
|
+
* Calculate combined probability that a line contains code.
|
|
5
|
+
* Uses: p = 1 - (1-p1)(1-p2)...(1-pn)
|
|
6
|
+
*
|
|
7
|
+
* @param detectors - Array of detectors to use
|
|
8
|
+
* @param line - The line to analyze
|
|
9
|
+
* @returns Combined probability between 0 and 1
|
|
10
|
+
*/
|
|
11
|
+
declare function computeProbability(detectors: ReadonlyArray<Detector>, line: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a line is likely code based on threshold.
|
|
14
|
+
*
|
|
15
|
+
* @param detectors - Array of detectors to use
|
|
16
|
+
* @param line - The line to check
|
|
17
|
+
* @returns True if probability >= threshold
|
|
18
|
+
*/
|
|
19
|
+
declare function isLikelyCode(detectors: ReadonlyArray<Detector>, line: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check if any line in the array is likely code.
|
|
22
|
+
*
|
|
23
|
+
* @param detectors - Array of detectors to use
|
|
24
|
+
* @param lines - Array of lines to check
|
|
25
|
+
* @returns True if at least one line meets the threshold
|
|
26
|
+
*/
|
|
27
|
+
declare function hasCodeLines(detectors: ReadonlyArray<Detector>, lines: ReadonlyArray<string>): boolean;
|
|
28
|
+
export { computeProbability, hasCodeLines, isLikelyCode, PROBABILITY_THRESHOLD };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Detector } from "./detector";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a detector that finds patterns in compressed text (whitespace removed).
|
|
4
|
+
* Supports both string literals and RegExp patterns.
|
|
5
|
+
*
|
|
6
|
+
* @param probability - Base probability (0-1)
|
|
7
|
+
* @param patterns - Patterns to detect (strings are escaped, RegExp used as-is)
|
|
8
|
+
* @returns Detector instance
|
|
9
|
+
*/
|
|
10
|
+
declare function createContainsDetector(probability: number, patterns: ReadonlyArray<string | RegExp>): Detector;
|
|
11
|
+
export { createContainsDetector };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A detector scans lines and returns match counts.
|
|
3
|
+
* Recognition probability: 1 - (1 - p)^matches
|
|
4
|
+
*/
|
|
5
|
+
interface Detector {
|
|
6
|
+
readonly probability: number;
|
|
7
|
+
readonly scan: (line: string) => number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Calculate recognition probability based on match count.
|
|
11
|
+
*
|
|
12
|
+
* @param detector - The detector to use
|
|
13
|
+
* @param line - The line to analyze
|
|
14
|
+
* @returns Probability between 0 and 1
|
|
15
|
+
*/
|
|
16
|
+
declare function recognize(detector: Detector, line: string): number;
|
|
17
|
+
export { recognize };
|
|
18
|
+
export type { Detector };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Detector } from "./detector";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a detector for lines ending with specific characters.
|
|
4
|
+
* Scans backwards, skipping whitespace and comment markers (* /).
|
|
5
|
+
*
|
|
6
|
+
* @param probability - Base probability (0-1)
|
|
7
|
+
* @param endings - Characters to match at line end
|
|
8
|
+
* @returns Detector instance
|
|
9
|
+
*/
|
|
10
|
+
declare function createEndWithDetector(probability: number, endings: ReadonlyArray<string>): Detector;
|
|
11
|
+
export { createEndWithDetector };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Detector } from "./detector";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a set of detectors for identifying JavaScript/TypeScript code patterns.
|
|
4
|
+
*
|
|
5
|
+
* @returns Array of configured detectors
|
|
6
|
+
*/
|
|
7
|
+
declare function createJavaScriptDetectors(): ReadonlyArray<Detector>;
|
|
8
|
+
export { createJavaScriptDetectors };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Detector } from "./detector";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a detector that counts keyword occurrences.
|
|
4
|
+
* Splits line by word boundaries and counts matches.
|
|
5
|
+
*
|
|
6
|
+
* @param probability - Base probability (0-1)
|
|
7
|
+
* @param keywords - Keywords to detect
|
|
8
|
+
* @returns Detector instance
|
|
9
|
+
*/
|
|
10
|
+
declare function createKeywordsDetector(probability: number, keywords: ReadonlyArray<string>): Detector;
|
|
11
|
+
export { createKeywordsDetector };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
type MessageIds = "awaitInConstructor" | "promiseChainInConstructor" | "asyncIifeInConstructor" | "unhandledAsyncCall" | "orphanedPromise";
|
|
3
|
+
interface RuleDocsWithRecommended extends TSESLint.RuleMetaDataDocs {
|
|
4
|
+
readonly recommended?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const noAsyncConstructor: TSESLint.RuleModuleWithMetaDocs<MessageIds, [], RuleDocsWithRecommended>;
|
|
7
|
+
export default noAsyncConstructor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "HowManySmall",
|
|
3
3
|
"dependencies": {
|
|
4
|
+
"oxc-parser": "^0.101.0",
|
|
4
5
|
"type-fest": "^5.2.0",
|
|
5
6
|
"typebox": "^1.0.60"
|
|
6
7
|
},
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
},
|
|
79
80
|
"type": "module",
|
|
80
81
|
"types": "./dist/index.d.ts",
|
|
81
|
-
"version": "1.
|
|
82
|
+
"version": "1.4.0"
|
|
82
83
|
}
|