@agoric/eslint-plugin 0.1.1-dev-c5dea1c.0.c5dea1c → 0.1.1-dev-4ea2a82.0.4ea2a82

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/eslint-plugin",
3
- "version": "0.1.1-dev-c5dea1c.0.c5dea1c",
3
+ "version": "0.1.1-dev-4ea2a82.0.4ea2a82",
4
4
  "description": "ESLint plugin for Agoric best practices",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "eslint": "^9.0.0",
27
- "eslint-plugin-eslint-plugin": "^7.2.0"
27
+ "eslint-plugin-eslint-plugin": "^7.3.2"
28
28
  },
29
29
  "license": "Apache-2.0",
30
30
  "engines": {
31
31
  "node": "^20.9 || ^22.11"
32
32
  },
33
- "gitHead": "c5dea1c874d9ab8a0da0d559d66be9c7d611741f"
33
+ "gitHead": "4ea2a829ab7a251c14fa872a0c7ac3e85b178eeb"
34
34
  }
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const fs = require('node:fs');
2
- const path = require('path');
2
+ const path = require('node:path');
3
3
 
4
4
  const pkg = JSON.parse(
5
5
  fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'),
@@ -1,7 +1,12 @@
1
+ /**
2
+ * @import {Bar} from 'foo';
3
+ * @import {Rule} from 'eslint';
4
+ */
5
+
1
6
  /**
2
7
  * ESLint rule: group-jsdoc-imports
3
8
  *
4
- * Moves inline JSDoc type imports (e.g. \@type {import('foo').Bar})
9
+ * Moves inline JSDoc type imports (e.g. \@type {Bar})
5
10
  * into a top-level JSDoc block with \@import lines, then references the
6
11
  * import by name (e.g. \@type {Bar}).
7
12
  *
@@ -14,7 +19,7 @@
14
19
  * }
15
20
  * }
16
21
  *
17
- * @type {import('eslint').Rule.RuleModule}
22
+ * @type {Rule.RuleModule}
18
23
  */
19
24
  /**
20
25
  * ESLint rule: group-jsdoc-imports (one-fix-per-inline-import version)
@@ -270,26 +275,24 @@ module.exports = {
270
275
  `${buildNewBlock(importTypeName, importPath)}\n`,
271
276
  ),
272
277
  );
273
- } else {
278
+ } else if (
274
279
  // If we do have a block, ensure it includes `@import {typeName} from 'importPath'`
275
- if (
276
- !alreadyHasImport(
277
- topBlockComment.value,
278
- importTypeName,
279
- importPath,
280
- )
281
- ) {
282
- fixOps.push(
283
- fixer.replaceTextRange(
284
- topBlockComment.range,
285
- appendImportToComment(
286
- topBlockComment,
287
- importTypeName,
288
- importPath,
289
- ),
280
+ !alreadyHasImport(
281
+ topBlockComment.value,
282
+ importTypeName,
283
+ importPath,
284
+ )
285
+ ) {
286
+ fixOps.push(
287
+ fixer.replaceTextRange(
288
+ topBlockComment.range,
289
+ appendImportToComment(
290
+ topBlockComment,
291
+ importTypeName,
292
+ importPath,
290
293
  ),
291
- );
292
- }
294
+ ),
295
+ );
293
296
  }
294
297
 
295
298
  // (b) Remove the inline usage from *this* comment
@@ -11,6 +11,10 @@
11
11
  * @see https://github.com/microsoft/typescript/issues/60831
12
12
  */
13
13
 
14
+ /**
15
+ * @import {Rule} from 'eslint';
16
+ */
17
+
14
18
  const LINE_REGEX =
15
19
  /^(\s*\*?\s*)@typedef\s+\{\s*import\((['"])([^'"]+)\2\)\.([A-Za-z0-9_$]+)([^}]*)\}\s+([A-Za-z0-9_$]+)(.*)$/;
16
20
 
@@ -76,7 +80,7 @@ const transformCommentValue = value => {
76
80
  return lines.join('\n');
77
81
  };
78
82
 
79
- /** @type {import('eslint').Rule.RuleModule} */
83
+ /** @type {Rule.RuleModule} */
80
84
  module.exports = {
81
85
  meta: {
82
86
  type: 'problem',