eslint-plugin-complete 1.0.8 → 1.0.10
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/completeCommon.d.ts +7 -0
- package/dist/completeCommon.d.ts.map +1 -1
- package/dist/completeCommon.js +11 -0
- package/dist/completeSentence.js +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/rules/prefer-readonly-parameter-types.d.ts.map +1 -1
- package/dist/rules/prefer-readonly-parameter-types.js +12 -0
- package/package.json +16 -16
package/dist/completeCommon.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export declare function capitalizeFirstLetter(string: string): string;
|
|
|
13
13
|
* https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter
|
|
14
14
|
*/
|
|
15
15
|
export declare function isFirstLetterCapitalized(string: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to narrow an unknown value to an object (i.e. a TypeScript record).
|
|
18
|
+
*
|
|
19
|
+
* Under the hood, this checks for `typeof variable === "object"`, `variable !== null`, and
|
|
20
|
+
* `!Array.isArray(variable)`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isObject(variable: unknown): variable is Record<string, unknown>;
|
|
16
23
|
/**
|
|
17
24
|
* Helper function to trim a prefix from a string, if it exists. Returns the trimmed string.
|
|
18
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completeCommon.d.ts","sourceRoot":"","sources":["../src/completeCommon.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,QAAQ,CAC1E,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CACb,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC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,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,UAAQ,GACd,MAAM,CAWR"}
|
package/dist/completeCommon.js
CHANGED
|
@@ -33,6 +33,17 @@ export function capitalizeFirstLetter(string) {
|
|
|
33
33
|
export function isFirstLetterCapitalized(string) {
|
|
34
34
|
return FIRST_LETTER_CAPITALIZED_REGEX.test(string);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to narrow an unknown value to an object (i.e. a TypeScript record).
|
|
38
|
+
*
|
|
39
|
+
* Under the hood, this checks for `typeof variable === "object"`, `variable !== null`, and
|
|
40
|
+
* `!Array.isArray(variable)`.
|
|
41
|
+
*/
|
|
42
|
+
export function isObject(variable) {
|
|
43
|
+
return (typeof variable === "object" &&
|
|
44
|
+
variable !== null &&
|
|
45
|
+
!Array.isArray(variable));
|
|
46
|
+
}
|
|
36
47
|
/**
|
|
37
48
|
* Helper function to trim a prefix from a string, if it exists. Returns the trimmed string.
|
|
38
49
|
*
|
package/dist/completeSentence.js
CHANGED
|
@@ -30,9 +30,9 @@ export function getIncompleteSentences(text) {
|
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
32
|
const sentences = getSentences(squishedText);
|
|
33
|
-
const
|
|
33
|
+
const isLoneSentence = sentences.length === 1;
|
|
34
34
|
for (const sentence of sentences) {
|
|
35
|
-
const messageId = getIncompleteSentenceKind(sentence,
|
|
35
|
+
const messageId = getIncompleteSentenceKind(sentence, isLoneSentence);
|
|
36
36
|
if (messageId !== undefined) {
|
|
37
37
|
incompleteSentences.push({
|
|
38
38
|
sentence,
|
|
@@ -149,7 +149,7 @@ export function getSentences(text) {
|
|
|
149
149
|
}
|
|
150
150
|
return match;
|
|
151
151
|
}
|
|
152
|
-
function getIncompleteSentenceKind(sentence,
|
|
152
|
+
function getIncompleteSentenceKind(sentence, isLoneSentence) {
|
|
153
153
|
let text = sentence;
|
|
154
154
|
// Trim the parenthesis surrounding the sentence, if any.
|
|
155
155
|
let textBeforeModifications;
|
|
@@ -191,7 +191,7 @@ function getIncompleteSentenceKind(sentence, loneSentence) {
|
|
|
191
191
|
return "doublePeriod";
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
194
|
+
if (isLoneSentence &&
|
|
195
195
|
// Single words, double words, and triple words.
|
|
196
196
|
(/^\S+$/.test(text) || /^\S+ \S+$/.test(text) || /^\S+ \S+ \S+$/.test(text))) {
|
|
197
197
|
return undefined;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAUzD,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOX,CAAC;AAMF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { isObject } from "./completeCommon.js";
|
|
3
4
|
import { configs } from "./configs.js";
|
|
4
5
|
import { rules } from "./rules.js";
|
|
5
6
|
const { name, version } = getPackageJSONNameAndVersion();
|
|
@@ -12,6 +13,8 @@ const plugin = {
|
|
|
12
13
|
rules,
|
|
13
14
|
};
|
|
14
15
|
addPluginToConfigs(configs, name);
|
|
16
|
+
// ESLint plugins must provide a default export by design.
|
|
17
|
+
// eslint-disable-next-line
|
|
15
18
|
export default plugin;
|
|
16
19
|
/**
|
|
17
20
|
* We parse the package JSON manually since importing JSON files directly in Node is experimental.
|
|
@@ -27,6 +30,9 @@ function getPackageJSONNameAndVersion() {
|
|
|
27
30
|
catch (error) {
|
|
28
31
|
throw new Error(`Failed to read the "${packageJSONPath}" file: ${error}`);
|
|
29
32
|
}
|
|
33
|
+
if (!isObject(packageJSON)) {
|
|
34
|
+
throw new Error(`Failed to parse the "${packageJSONPath}" file since it was not an object.`);
|
|
35
|
+
}
|
|
30
36
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
31
37
|
const { name } = packageJSON;
|
|
32
38
|
if (typeof name !== "string") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-readonly-parameter-types.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-readonly-parameter-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAY1E,KAAK,OAAO,GAAG;IACb;QACE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;QAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,wBAAwB,CAAC,EAAE,OAAO,CAAC;KACpC;CACF,CAAC;AAGF,eAAO,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"prefer-readonly-parameter-types.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-readonly-parameter-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAY1E,KAAK,OAAO,GAAG;IACb;QACE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;QAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,wBAAwB,CAAC,EAAE,OAAO,CAAC;KACpC;CACF,CAAC;AAGF,eAAO,MAAM,4BAA4B,6MA6MvC,CAAC"}
|
|
@@ -71,6 +71,18 @@ export const preferReadonlyParameterTypes = createRule({
|
|
|
71
71
|
AST_NODE_TYPES.TSFunctionType,
|
|
72
72
|
AST_NODE_TYPES.TSMethodSignature,
|
|
73
73
|
].join(", ")](node) {
|
|
74
|
+
// Early return in the special case of a map method. (This would result in an unfixable lint
|
|
75
|
+
// error.)
|
|
76
|
+
if (node.type === AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
77
|
+
node.type === AST_NODE_TYPES.FunctionExpression) {
|
|
78
|
+
const { parent } = node;
|
|
79
|
+
if (parent.type === AST_NODE_TYPES.CallExpression &&
|
|
80
|
+
parent.callee.type === AST_NODE_TYPES.MemberExpression &&
|
|
81
|
+
parent.callee.property.type === AST_NODE_TYPES.Identifier &&
|
|
82
|
+
parent.callee.property.name === "map") {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
74
86
|
for (const param of node.params) {
|
|
75
87
|
if (checkParameterProperties === false &&
|
|
76
88
|
param.type === AST_NODE_TYPES.TSParameterProperty) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-complete",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "An ESLint plugin that contains useful rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"test": "jest"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@typescript-eslint/type-utils": "
|
|
48
|
-
"@typescript-eslint/utils": "
|
|
49
|
-
"typescript-eslint": "
|
|
47
|
+
"@typescript-eslint/type-utils": "8.25.0",
|
|
48
|
+
"@typescript-eslint/utils": "8.25.0",
|
|
49
|
+
"typescript-eslint": "8.25.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "
|
|
53
|
-
"@babel/preset-env": "
|
|
54
|
-
"@babel/preset-typescript": "
|
|
55
|
-
"@types/jest": "
|
|
56
|
-
"@types/node": "
|
|
57
|
-
"@typescript-eslint/rule-tester": "
|
|
58
|
-
"@typescript-eslint/types": "
|
|
59
|
-
"complete-common": "
|
|
60
|
-
"complete-node": "
|
|
61
|
-
"jest": "
|
|
62
|
-
"prettier": "
|
|
63
|
-
"typescript": "
|
|
52
|
+
"@babel/core": "7.26.9",
|
|
53
|
+
"@babel/preset-env": "7.26.9",
|
|
54
|
+
"@babel/preset-typescript": "7.26.0",
|
|
55
|
+
"@types/jest": "29.5.14",
|
|
56
|
+
"@types/node": "22.13.5",
|
|
57
|
+
"@typescript-eslint/rule-tester": "8.25.0",
|
|
58
|
+
"@typescript-eslint/types": "8.25.0",
|
|
59
|
+
"complete-common": "1.1.2",
|
|
60
|
+
"complete-node": "3.1.6",
|
|
61
|
+
"jest": "29.7.0",
|
|
62
|
+
"prettier": "3.5.2",
|
|
63
|
+
"typescript": "5.7.3"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"eslint": ">= 9.0.0",
|