eslint-plugin-complete 1.1.1 → 1.1.2
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/comments.js
CHANGED
|
@@ -9,9 +9,9 @@ export function isCommentOnOwnLine(sourceCode, comment) {
|
|
|
9
9
|
const startLine = comment.loc.start.line;
|
|
10
10
|
const endLine = comment.loc.end.line;
|
|
11
11
|
const previousToken = sourceCode.getTokenBefore(comment);
|
|
12
|
-
const previousTokenEndLine = previousToken === null ?
|
|
12
|
+
const previousTokenEndLine = previousToken === null ? undefined : previousToken.loc.end.line;
|
|
13
13
|
const nextToken = sourceCode.getTokenAfter(comment);
|
|
14
|
-
const nextTokenStartLine = nextToken === null ?
|
|
14
|
+
const nextTokenStartLine = nextToken === null ? undefined : nextToken.loc.start.line;
|
|
15
15
|
return startLine !== previousTokenEndLine && endLine !== nextTokenStartLine;
|
|
16
16
|
}
|
|
17
17
|
export function isEnumBlockLabel(text) {
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,9 @@ function getPackageJSONNameAndVersion() {
|
|
|
28
28
|
packageJSON = JSON.parse(packageJSONString);
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
throw new Error(`Failed to read the
|
|
31
|
+
throw new Error(`Failed to read the file: ${packageJSONPath}`, {
|
|
32
|
+
cause: error,
|
|
33
|
+
});
|
|
32
34
|
}
|
|
33
35
|
if (!isObject(packageJSON)) {
|
|
34
36
|
throw new Error(`Failed to parse the "${packageJSONPath}" file since it was not an object.`);
|
|
@@ -32,7 +32,7 @@ export const noMutableReturn = createRule({
|
|
|
32
32
|
const messageId = getErrorMessageId(t);
|
|
33
33
|
if (messageId !== undefined) {
|
|
34
34
|
context.report({
|
|
35
|
-
loc: node
|
|
35
|
+
loc: getLoc(node),
|
|
36
36
|
messageId,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -66,3 +66,25 @@ function getErrorMessageId(type) {
|
|
|
66
66
|
}
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
|
69
|
+
/** If that does not exist, If that does not exist, target the entire function. */
|
|
70
|
+
function getLoc(node) {
|
|
71
|
+
// First, target the function return type.
|
|
72
|
+
const { returnType } = node;
|
|
73
|
+
if (returnType !== undefined) {
|
|
74
|
+
// The return type location starts at the colon instead of at the type, which looks strange.
|
|
75
|
+
// Thus, we fix this by manually adding 2 to account for the ": ".
|
|
76
|
+
return {
|
|
77
|
+
start: {
|
|
78
|
+
line: returnType.loc.start.line,
|
|
79
|
+
column: returnType.loc.start.column + 2,
|
|
80
|
+
},
|
|
81
|
+
end: returnType.loc.end,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Second, target the function name.
|
|
85
|
+
if (node.id !== null) {
|
|
86
|
+
return node.id.loc;
|
|
87
|
+
}
|
|
88
|
+
// Fall back to highlighting the whole function.
|
|
89
|
+
return node.loc;
|
|
90
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-capital-const-assertions.d.ts","sourceRoot":"","sources":["../../src/rules/require-capital-const-assertions.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAkB5C,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"require-capital-const-assertions.d.ts","sourceRoot":"","sources":["../../src/rules/require-capital-const-assertions.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAkB5C,eAAO,MAAM,6BAA6B,kMAuExC,CAAC"}
|
|
@@ -59,15 +59,12 @@ export const requireCapitalConstAssertions = createRule({
|
|
|
59
59
|
loc: node.loc,
|
|
60
60
|
messageId: "noConstAssertion",
|
|
61
61
|
fix: (fixer) => {
|
|
62
|
-
// If this variable
|
|
62
|
+
// If this variable is not being assigned to anything, then there is nothing we can
|
|
63
63
|
// fix.
|
|
64
|
-
if (declaration.init === null
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
if (AUTO_FIX_TYPE_BLACKLIST.has(declaration.init.type)) {
|
|
64
|
+
if (declaration.init === null
|
|
65
|
+
|| declaration.init.type === AST_NODE_TYPES.TSAsExpression
|
|
66
|
+
|| AUTO_FIX_TYPE_BLACKLIST.has(declaration.init.type)) {
|
|
67
|
+
// eslint-disable-next-line unicorn/no-null
|
|
71
68
|
return null;
|
|
72
69
|
}
|
|
73
70
|
return fixer.insertTextAfter(declaration.init, " as const");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-complete",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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": "8.
|
|
48
|
-
"@typescript-eslint/utils": "8.
|
|
49
|
-
"typescript-eslint": "8.
|
|
47
|
+
"@typescript-eslint/type-utils": "8.39.0",
|
|
48
|
+
"@typescript-eslint/utils": "8.39.0",
|
|
49
|
+
"typescript-eslint": "8.39.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/core": "7.28.0",
|
|
53
53
|
"@babel/preset-env": "7.28.0",
|
|
54
54
|
"@babel/preset-typescript": "7.27.1",
|
|
55
55
|
"@types/jest": "30.0.0",
|
|
56
|
-
"@types/node": "24.0
|
|
57
|
-
"@typescript-eslint/rule-tester": "8.
|
|
58
|
-
"@typescript-eslint/types": "8.
|
|
59
|
-
"complete-common": "2.
|
|
60
|
-
"complete-node": "
|
|
61
|
-
"jest": "30.0.
|
|
56
|
+
"@types/node": "24.2.0",
|
|
57
|
+
"@typescript-eslint/rule-tester": "8.39.0",
|
|
58
|
+
"@typescript-eslint/types": "8.39.0",
|
|
59
|
+
"complete-common": "2.5.0",
|
|
60
|
+
"complete-node": "9.0.0",
|
|
61
|
+
"jest": "30.0.5",
|
|
62
62
|
"prettier": "3.6.2",
|
|
63
|
-
"typescript": "5.
|
|
63
|
+
"typescript": "5.9.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"eslint": ">= 9.0.0",
|