Skip to content

Revert "refactor: replace synckit with make-synchronized (#1366)" #1367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"escape-string-regexp": "^4.0.0",
"espree": "^10.1.0",
"esquery": "^1.6.0",
"make-synchronized": "^0.3.0",
"parse-imports": "^2.1.1",
"semver": "^7.6.3",
"spdx-expression-parse": "^4.0.0"
"spdx-expression-parse": "^4.0.0",
"synckit": "^0.9.1"
},
"description": "JSDoc linting rules for ESLint.",
"devDependencies": {
Expand Down Expand Up @@ -146,7 +146,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",
Expand Down
11 changes: 3 additions & 8 deletions pnpm-lock.yaml

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

11 changes: 0 additions & 11 deletions src/getImports.js

This file was deleted.

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;
}
})
6 changes: 5 additions & 1 deletion src/rules/checkValues.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import { createSyncFn } from 'synckit';
import semver from 'semver';
import spdxExpressionParse from 'spdx-expression-parse';
import iterateJsdoc from '../iterateJsdoc.js';
import getImports from '../getImports.js';

const __dirname = dirname(fileURLToPath(import.meta.url));
const pathName = join(__dirname, '../import-worker.mjs');

const allowedKinds = new Set([
'class',
Expand Down Expand Up @@ -172,6 +175,7 @@ export default iterateJsdoc(({
? `${typePart}${name} ${description}`
: `${typePart}${name}`);

const getImports = createSyncFn(pathName);
if (!getImports(imprt)) {
report(
`Bad @import tag`,
Expand Down
6 changes: 5 additions & 1 deletion src/rules/noUndefinedTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

import { createSyncFn } from 'synckit';
import {
getJSDocComment,
parse as parseType,
Expand All @@ -10,7 +11,9 @@ import {
import iterateJsdoc, {
parseComment,
} from '../iterateJsdoc.js';
import getImports from '../getImports.js';

const __dirname = dirname(fileURLToPath(import.meta.url));
const pathName = join(__dirname, '../import-worker.mjs');

const extraTypes = [
'null', 'undefined', 'void', 'string', 'boolean', 'object',
Expand Down Expand Up @@ -149,6 +152,7 @@ export default iterateJsdoc(({
? `${typePart}${name} ${description}`
: `${typePart}${name}`);

const getImports = createSyncFn(pathName);
const imports = /** @type {import('parse-imports').Import[]} */ (getImports(imprt));
if (!imports) {
return null;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"test/**/*.js",
"typings/gitdown.d.ts",
"typings/babel__eslint-parser.d.ts",
"src/import-worker.mjs"
],
"exclude": ["node_modules"]
}