Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gajus/eslint-plugin-jsdoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v48.2.15
Choose a base ref
...
head repository: gajus/eslint-plugin-jsdoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v48.3.0
Choose a head ref
  • 3 commits
  • 13 files changed
  • 1 contributor

Commits on Jun 24, 2024

  1. Copy the full SHA
    54ac4fd View commit details
  2. Copy the full SHA
    ad31b14 View commit details
  3. refactor: work synchronously

    brettz9 committed Jun 24, 2024
    Copy the full SHA
    5497b03 View commit details
1 change: 1 addition & 0 deletions .README/rules/check-values.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ This rule checks the values for a handful of tags:
6. `@kind` - Insists that it be one of the allowed values: 'class',
'constant', 'event', 'external', 'file', 'function', 'member', 'mixin',
'module', 'namespace', 'typedef',
7. `@import` - For TypeScript `mode` only. Enforces valid ES import syntax.

## Options

2 changes: 1 addition & 1 deletion .README/rules/no-undefined-types.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ the tag types in the table below:
`@event`, `@external` (or `@host`), `@function` (or `@func` or `@method`),
`@interface`, `@member` (or `@var`), `@mixin`, `@name`, `@namespace`,
`@template` (for "closure" or "typescript" `settings.jsdoc.mode` only),
`@typedef`.
`@import` (for TypeScript), `@typedef`.

The following tags will also be checked but only when the mode is `closure`:

3 changes: 2 additions & 1 deletion .babelrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"plugins": [
"add-module-exports"
"add-module-exports",
"babel-plugin-transform-import-meta"
],
"presets": [
[
25 changes: 25 additions & 0 deletions docs/rules/check-values.md
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ This rule checks the values for a handful of tags:
6. `@kind` - Insists that it be one of the allowed values: 'class',
'constant', 'event', 'external', 'file', 'function', 'member', 'mixin',
'module', 'namespace', 'typedef',
7. `@import` - For TypeScript `mode` only. Enforces valid ES import syntax.

<a name="user-content-check-values-options"></a>
<a name="check-values-options"></a>
@@ -251,6 +252,14 @@ function quux (foo) {
}
// "jsdoc/check-values": ["error"|"warn", {"licensePattern":"^([^\n]+)\nCopyright"}]
// Message: Invalid JSDoc @license: "Oops"; expected SPDX expression: https://spdx.org/licenses/.
/**
* @import BadImportIgnoredByThisRule
*/
/**
* @import {AnotherBadImportIgnoredByThisRule} from
*/
// Message: Bad @import tag
````
@@ -405,5 +414,21 @@ function quux (foo) {
}
// "jsdoc/check-values": ["error"|"warn", {"licensePattern":"^([^\n]+)\nCopyright"}]
/**
* @import LinterDef, { Sth as Something, Another as Another2 } from "eslint"
*/
/**
* @import { Linter } from "eslint"
*/
/**
* @import LinterDefault from "eslint"
*/
/**
* @import {Linter as Lintee} from "eslint"
*/
/**
* @import * as Linters from "eslint"
*/
````
69 changes: 68 additions & 1 deletion docs/rules/no-undefined-types.md
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ the tag types in the table below:
`@event`, `@external` (or `@host`), `@function` (or `@func` or `@method`),
`@interface`, `@member` (or `@var`), `@mixin`, `@name`, `@namespace`,
`@template` (for "closure" or "typescript" `settings.jsdoc.mode` only),
`@typedef`.
`@import` (for TypeScript), `@typedef`.

The following tags will also be checked but only when the mode is `closure`:

@@ -307,6 +307,36 @@ const a = new Todo();
*/
// Settings: {"jsdoc":{"structuredTags":{"namepathOrURLReferencer":{"name":"namepath-or-url-referencing"}}}}
// Message: The type 'SomeType' is undefined.

/**
* @import BadImportIgnoredByThisRule
*/
/**
* @import LinterDef, { Sth as Something, Another as Another2 } from "eslint"
*/
/**
* @import { Linter } from "eslint"
*/
/**
* @import LinterDefault from "eslint"
*/
/**
* @import {Linter as Lintee} from "eslint"
*/
/**
* @import * as Linters from "eslint"
*/

/**
* @type {BadImportIgnoredByThisRule}
*/
/**
* @type {Sth}
*/
/**
* @type {Another}
*/
// Message: The type 'BadImportIgnoredByThisRule' is undefined.
````


@@ -777,8 +807,45 @@ function quux(foo) {

quux(0);

/**
* @import BadImportIgnoredByThisRule
*/
/**
* @import LinterDef, { Sth as Something, Another as Another2 } from "eslint"
*/
/**
* @import { Linter } from "eslint"
*/
/**
* @import LinterDefault from "eslint"
*/
/**
* @import {Linter as Lintee} from "eslint"
*/
/**
* @import * as Linters from "eslint"
*/

/**
* @type {LinterDef}
*/
/**
* @type {Something}
*/
/**
* @type {Another2}
*/
/**
* @type {Linter}
*/
/**
* @type {LinterDefault}
*/
/**
* @type {Lintee}
*/
/**
* @type {Linters}
*/
````

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -11,8 +11,10 @@
"debug": "^4.3.4",
"escape-string-regexp": "^4.0.0",
"esquery": "^1.5.0",
"parse-imports": "^2.1.0",
"semver": "^7.6.2",
"spdx-expression-parse": "^4.0.0"
"spdx-expression-parse": "^4.0.0",
"synckit": "^0.9.0"
},
"description": "JSDoc linting rules for ESLint.",
"devDependencies": {
@@ -43,6 +45,7 @@
"@typescript-eslint/parser": "^7.11.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-transform-import-meta": "^2.2.1",
"c8": "^9.1.0",
"camelcase": "^6.3.0",
"chai": "^4.3.10",
@@ -125,7 +128,7 @@
"scripts": {
"tsc": "tsc",
"tsc-build": "tsc -p tsconfig-prod.json",
"build": "rimraf ./dist && cross-env NODE_ENV=production babel ./src --out-file-extension .cjs --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored && replace 'require\\(\"\\.(.*?)\\.[^.]*?\"\\)' 'require(\".$1.cjs\")' 'dist' -r --include=\"*.cjs\" && pnpm tsc-build",
"build": "rimraf ./dist && cross-env NODE_ENV=production babel ./src --out-file-extension .cjs --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored && replace 'require\\(\"\\.(.*?)\\.[^.]*?\"\\)' 'require(\".$1.cjs\")' 'dist' -r --include=\"*.cjs\" && cp src/import-worker.mjs dist/import-worker.mjs && pnpm tsc-build",
"check-docs": "babel-node ./src/bin/generateDocs.js --check",
"create-docs": "npm run create-options && babel-node ./src/bin/generateDocs.js",
"create-rule": "babel-node ./src/bin/generateRule.js",
60 changes: 49 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/import-worker.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { runAsWorker } from 'synckit'

runAsWorker(async (imprt) => {
const { parseImports } = await import('parse-imports');
try {
// ESLint doesn't support async rules
return [...await parseImports(imprt)];
} catch (err) {
return false;
}
})
Loading