Skip to content
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Version 2

### v2.0.0

- Supported Node.js versions: `^20.19.0 || ^22.12.0 || ^24.0.0`;
- ESM only build: all the Node.js versions listed above support `require(ESM)`;

## Version 1

### v1.3.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import fancyFn from "unlisted-module"; // Error: Importing unlisted-module is no

## Requirements

- Node.js `^18.18.0 || ^20.9.0 || ^22.0.0 || ^24.0.0`
- Node.js `^20.19.0 || ^22.12.0 || ^24.0.0`
- `eslint@^9.0.0`
- `typescript-eslint@^8.0.0`

Expand Down
370 changes: 133 additions & 237 deletions bun.lock

Large diffs are not rendered by default.

38 changes: 15 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"name": "eslint-plugin-allowed-dependencies",
"description": "ESLint plugin Allowed Dependencies",
"version": "1.3.2",
"version": "2.0.0-beta.2",
"type": "module",
"module": "dist/index.js",
"main": "dist/index.cjs",
"main": "dist/index.js",
"types": "dist/index.d.cts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"license": "MIT",
Expand All @@ -35,7 +29,7 @@
"*.md"
],
"scripts": {
"build": "bun run tsup && attw --pack",
"build": "bun run tsdown",
"lint": "bun run biome check",
"pretest": "tsc --noEmit",
"test": "bun test src",
Expand All @@ -47,26 +41,24 @@
"ramda": "^0.32.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.0",
"@arethetypeswrong/cli": "^0.18.2",
"@biomejs/biome": "2.2.5",
"@tsconfig/bun": "^1.0.7",
"@types/bun": "latest",
"@types/ramda": "^0.31.0",
"@types/semver": "^7.5.8",
"@typescript-eslint/rule-tester": "^8.9.0",
"eslint": "^9.12.0",
"@tsconfig/bun": "^1.0.9",
"@types/bun": "^1.3.0",
"@types/ramda": "^0.31.1",
"@typescript-eslint/rule-tester": "^8.46.0",
"eslint": "^9.37.0",
"json-schema-to-ts": "^3.1.1",
"semver": "^7.6.3",
"tsup": "^8.3.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.9.0"
"tsdown": "^0.15.6",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.0"
},
"peerDependencies": {
"eslint": "^9.0.0",
"typescript-eslint": "^8.0.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || ^22.0.0 || ^24.0.0"
"node": "^20.19.0 || ^22.12.0 || ^24.0.0"
},
"keywords": [
"modules",
Expand Down
5 changes: 5 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ export const splitPeers = (manifest: Manifest) => {
);
return { requiredPeers, optionalPeers };
};

export const mapTuple = <V extends R.Tuple<unknown, number>, U>(
fn: (n: V extends R.Tuple<infer T, number> ? T : never) => U,
dict: V,
) => R.map(fn, dict) as R.Tuple<U, V["length"]>;
17 changes: 12 additions & 5 deletions src/rule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ESLintUtils } from "@typescript-eslint/utils";
import * as R from "ramda";
import { getManifest, getName, splitPeers } from "./helpers.ts";
import { getManifest, getName, mapTuple, splitPeers } from "./helpers.ts";
import { type Category, type Options, options, type Value } from "./schema.ts";

const messages = {
Expand All @@ -15,7 +15,7 @@ const defaults: Options = {
optionalPeers: "typeOnly",
};

const values: Value[] = [true, false, "typeOnly"];
const values = [true, false, "typeOnly"] as const satisfies Value[];

const makeIterator =
(ctx: { cwd: string }) =>
Expand All @@ -42,12 +42,19 @@ const makeIterator =
),
);

const [allowed, prohibited, limited] = R.map(take, values);
const [allowed, prohibited, limited] = mapTuple(take, values);
limited.push(...typeOnly);

return { allowed, prohibited, limited, ignore };
};

const groups = [
"allowed",
"prohibited",
"limited",
"ignore",
] as const satisfies Array<keyof ReturnType<ReturnType<typeof makeIterator>>>;

const makeTester = (ignored: string[]) => {
const patterns = R.map(R.constructN(1, RegExp), ignored);
const invoker = R.invoker(1, "test");
Expand All @@ -65,9 +72,9 @@ export const rule = ESLintUtils.RuleCreator.withoutDocs({
const iterator = makeIterator(ctx);
const combined = R.map(iterator, ctx.options.length ? ctx.options : [{}]);

const [allowed, prohibited, limited, ignored] = R.map(
const [allowed, prohibited, limited, ignored] = mapTuple(
(group) => R.flatten(R.pluck(group, combined)),
["allowed", "prohibited", "limited", "ignore"] as const,
groups,
);

const isIgnored = makeTester(ignored);
Expand Down
8 changes: 8 additions & 0 deletions tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "tsdown";

export default defineConfig({
entry: "./src/index.ts",
minify: true,
skipNodeModulesBundle: true,
attw: { level: "error", profile: "esmOnly" },
});
18 changes: 0 additions & 18 deletions tsup.config.ts

This file was deleted.