eslint-plugin-complete 1.1.0 → 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 ? null : previousToken.loc.end.line;
12
+ const previousTokenEndLine = previousToken === null ? undefined : previousToken.loc.end.line;
13
13
  const nextToken = sourceCode.getTokenAfter(comment);
14
- const nextTokenStartLine = nextToken === null ? null : nextToken.loc.start.line;
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) {
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,oBAAoB,UAAO,GAC1B,MAAM,CAyRR"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,oBAAoB,UAAO,GAC1B,MAAM,CAsSR"}
package/dist/format.js CHANGED
@@ -59,8 +59,17 @@ export function formatText(text, maxLength, shouldParseJSDocTags = true) {
59
59
  const previousLineEndedInColon = previousLine !== undefined && previousLine.trimEnd().endsWith(":");
60
60
  const previousLineWasSeparatorLine = previousLine !== undefined && isSeparatorLine(previousLine);
61
61
  const previousLineWasEnumBlockLabel = previousLine !== undefined && isEnumBlockLabel(previousLine);
62
+ const nextLine = lines[i + 1];
63
+ const nextLineIsJSDocTag = nextLine !== undefined && nextLine.trim().startsWith("@");
62
64
  // Handle blank lines.
63
65
  if (lineIsBlank) {
66
+ // If we are between JSDoc tags, skip this blank line entirely.
67
+ if (encounteredJSDocTags
68
+ && insideList !== undefined
69
+ && insideList.kind === ListKind.JSDocTag
70
+ && nextLineIsJSDocTag) {
71
+ continue;
72
+ }
64
73
  // Append the partial line that we were building, if any.
65
74
  [formattedLine, formattedText] = appendLineToText(formattedLine, formattedText);
66
75
  // Append the blank line, but ignore multiple blank lines in a row (unless we are inside of a
@@ -92,7 +101,6 @@ export function formatText(text, maxLength, shouldParseJSDocTags = true) {
92
101
  formattedLine += line;
93
102
  // Enforce newlines after the end of code blocks. (But not inside of an example code block,
94
103
  // because there should not be newlines between tags.)
95
- const nextLine = lines[i + 1];
96
104
  const nextLineIsBlank = nextLine === undefined || nextLine.trim() === "";
97
105
  if (hasCodeBlock
98
106
  && previousLineInsideCodeBlock
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ export default plugin;
20
20
  * We parse the package JSON manually since importing JSON files directly in Node is experimental.
21
21
  */
22
22
  function getPackageJSONNameAndVersion() {
23
- const packageRoot = path.join(import.meta.dirname, "..");
23
+ const packageRoot = path.resolve(import.meta.dirname, "..");
24
24
  const packageJSONPath = path.join(packageRoot, "package.json");
25
25
  let packageJSON;
26
26
  try {
@@ -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 "${packageJSONPath}" file: ${error}`);
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.loc,
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,kMA0ExC,CAAC"}
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 isn't being assigned to anything, then there is nothing we can
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
- return null;
66
- }
67
- if (declaration.init.type === AST_NODE_TYPES.TSAsExpression) {
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.0",
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.34.1",
48
- "@typescript-eslint/utils": "8.34.1",
49
- "typescript-eslint": "8.34.1"
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
- "@babel/core": "7.27.4",
53
- "@babel/preset-env": "7.27.2",
52
+ "@babel/core": "7.28.0",
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.3",
57
- "@typescript-eslint/rule-tester": "8.34.1",
58
- "@typescript-eslint/types": "8.34.1",
59
- "complete-common": "2.2.0",
60
- "complete-node": "5.1.6",
61
- "jest": "30.0.2",
62
- "prettier": "3.5.3",
63
- "typescript": "5.8.3"
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
+ "prettier": "3.6.2",
63
+ "typescript": "5.9.2"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "eslint": ">= 9.0.0",