@crutchcrew/oxlint-plugin-import-access 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # oxlint-plugin-import-access 📦🔒
1
+ # @crutchcrew/oxlint-plugin-import-access 📦🔒
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@crutchcrew/oxlint-plugin-import-access)](https://www.npmjs.com/package/@crutchcrew/oxlint-plugin-import-access)
4
4
  [![coverage](https://img.shields.io/endpoint?url=https://crutchcrew.github.io/oxlint-plugin-import-access/badges/coverage.json)](https://github.com/crutchcrew/oxlint-plugin-import-access/actions)
5
5
  [![provenance](https://img.shields.io/badge/provenance-verified-brightgreen)](https://www.npmjs.com/package/@crutchcrew/oxlint-plugin-import-access)
6
6
  [![license](https://img.shields.io/npm/l/@crutchcrew/oxlint-plugin-import-access)](./LICENSE)
7
7
 
8
- JSDoc import access for TypeScript, enforced by [oxlint](https://oxc.rs/docs/guide/usage/linter). Only `@public` exports can be imported from anywhere, and an export without an access tag is `@package`: only files in its own directory can import it. Tag an export `@public` to share it with the whole project, or `@private` so no other file can import it. To make untagged exports `@public` or `@private` instead, set [`defaultImportability`](#options).
8
+ JSDoc import access for TypeScript, enforced by [oxlint](https://oxc.rs/docs/guide/usage/linter). Only `@public` exports can be imported from anywhere, and an export without an access tag is `@package`: only files in its own package (its directory and subdirectories) can import it. Tag an export `@public` to share it with the whole project, or `@private` so no other file can import it. To make untagged exports `@public` or `@private` instead, set [`defaultImportability`](#options).
9
9
 
10
10
  A native oxlint JS plugin port of [eslint-plugin-import-access](https://github.com/uhyo/eslint-plugin-import-access) that needs **no type checker**: no `typescript` dependency, no `tsconfig.json` project loading, no typed linting setup.
11
11
 
@@ -110,11 +110,11 @@ The original rule asks the TypeScript type checker which declaration an import r
110
110
 
111
111
  1. resolve the import like TypeScript (`tsconfig` `paths`, `package.json` `exports`, `.js` → `.ts`) with [oxc-resolver](https://github.com/oxc-project/oxc-resolver),
112
112
  2. skip builtins and anything reached through `node_modules`,
113
- 3. read the target file's exports and JSDoc with [oxc-parser](https://github.com/oxc-project/oxc/tree/main/napi/parser) — module record and comments only, no syntax tree — and cache them,
113
+ 3. read the target file's exports and JSDoc with [oxc-parser](https://github.com/oxc-project/oxc/tree/main/napi/parser) — the module record and comments; the syntax tree only for the few files with decorators, `export =`, re-exported imports or JSDoc inside variable statements — and cache them,
114
114
  4. follow `export *`, stop at direct re-exports like upstream, and read JSDoc with TypeScript's attachment and tag rules,
115
115
  5. check ambient `declare module "…"` and wildcard `declare module "*.svg"` declarations too.
116
116
 
117
- **Verified against the original:** the upstream test suite passes unchanged (same lines, columns, messages), and a differential test compares this plugin with upstream's TypeScript-based rule on every fixture file and option combination, including new fixtures for re-export chains, overloads, enums, `export =`, wildcard modules and JSDoc placement. The [known differences](./docs/rule-jsdoc.md#differences-from-upstream) are edge cases such as module augmentation across files.
117
+ **Verified against the original:** the upstream test suite passes unchanged (same lines, columns, messages), and the port was compared with upstream's TypeScript-based rule on every fixture file and option combination, including new fixtures for re-export chains, overloads, enums, `export =`, wildcard modules and JSDoc placement, whose expectations in the test suite were generated by the original rule. The [known differences](./docs/rule-jsdoc.md#differences-from-upstream) are edge cases such as module augmentation across files.
118
118
 
119
119
  ## Performance
120
120
 
@@ -39,7 +39,8 @@ export declare class ImportabilityChecker {
39
39
  constructor(watching?: boolean);
40
40
  /**
41
41
  * Start checking `fileName`. In a long-running host, everything read for earlier files is
42
- * re-validated: exporter files are stat-ed again and specifiers resolved again.
42
+ * re-validated: exporter files are stat-ed again, specifiers resolved again and package names
43
+ * looked up again.
43
44
  */
44
45
  nextFile(fileName: string): void;
45
46
  clear(): void;
package/dist/index.js CHANGED
@@ -737,6 +737,9 @@ function lookupPackageName(file) {
737
737
  }
738
738
  return result;
739
739
  }
740
+ function clearPackageNameCache() {
741
+ packageNameCache.clear();
742
+ }
740
743
 
741
744
  // src/core/resolveModule.ts
742
745
  import { realpathSync } from "node:fs";
@@ -903,6 +906,7 @@ class ImportabilityChecker {
903
906
  }
904
907
  this.exportTables.nextGeneration();
905
908
  this.resolver.clear();
909
+ clearPackageNameCache();
906
910
  this.#found = new WeakMap;
907
911
  }
908
912
  clear() {
@@ -910,6 +914,7 @@ class ImportabilityChecker {
910
914
  this.resolver.clear();
911
915
  this.exportTables.clear();
912
916
  this.ambientModules.clear();
917
+ clearPackageNameCache();
913
918
  }
914
919
  }
915
920
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crutchcrew/oxlint-plugin-import-access",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Oxlint JS plugin for import access via JSDoc @public, @package and @private, without a type checker",
5
5
  "keywords": [
6
6
  "import-access",