Skip to content

Commit f11be27

Browse files
authored
v2: ESM only (#66)
* Drop Node 18, elevating requirements. * Drop CJS exports. * Switching to tsdown. * Upgrading trivial dev dependencies. * Updating types/bun. * Updating typescript. * Strict: upgrading tsconfig base and improving constraints on iterating over tuples. * Readme: upd node.js versions. * tsdown config: rm defaults. * tsdown config: minor, shortening. * Ref: shortening type for mapTuple. * v2.0.0-beta.1 * v2.0.0-beta.2
1 parent d9b9dd2 commit f11be27

8 files changed

Lines changed: 181 additions & 284 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Version 2
4+
5+
### v2.0.0
6+
7+
- Supported Node.js versions: `^20.19.0 || ^22.12.0 || ^24.0.0`;
8+
- ESM only build: all the Node.js versions listed above support `require(ESM)`;
9+
310
## Version 1
411

512
### v1.3.2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import fancyFn from "unlisted-module"; // Error: Importing unlisted-module is no
4545

4646
## Requirements
4747

48-
- Node.js `^18.18.0 || ^20.9.0 || ^22.0.0 || ^24.0.0`
48+
- Node.js `^20.19.0 || ^22.12.0 || ^24.0.0`
4949
- `eslint@^9.0.0`
5050
- `typescript-eslint@^8.0.0`
5151

bun.lock

Lines changed: 133 additions & 237 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
{
22
"name": "eslint-plugin-allowed-dependencies",
33
"description": "ESLint plugin Allowed Dependencies",
4-
"version": "1.3.2",
4+
"version": "2.0.0-beta.2",
55
"type": "module",
66
"module": "dist/index.js",
7-
"main": "dist/index.cjs",
7+
"main": "dist/index.js",
88
"types": "dist/index.d.cts",
99
"exports": {
1010
".": {
11-
"import": {
12-
"types": "./dist/index.d.ts",
13-
"default": "./dist/index.js"
14-
},
15-
"require": {
16-
"types": "./dist/index.d.cts",
17-
"default": "./dist/index.cjs"
18-
}
11+
"types": "./dist/index.d.ts",
12+
"default": "./dist/index.js"
1913
}
2014
},
2115
"license": "MIT",
@@ -35,7 +29,7 @@
3529
"*.md"
3630
],
3731
"scripts": {
38-
"build": "bun run tsup && attw --pack",
32+
"build": "bun run tsdown",
3933
"lint": "bun run biome check",
4034
"pretest": "tsc --noEmit",
4135
"test": "bun test src",
@@ -47,26 +41,24 @@
4741
"ramda": "^0.32.0"
4842
},
4943
"devDependencies": {
50-
"@arethetypeswrong/cli": "^0.18.0",
44+
"@arethetypeswrong/cli": "^0.18.2",
5145
"@biomejs/biome": "2.2.5",
52-
"@tsconfig/bun": "^1.0.7",
53-
"@types/bun": "latest",
54-
"@types/ramda": "^0.31.0",
55-
"@types/semver": "^7.5.8",
56-
"@typescript-eslint/rule-tester": "^8.9.0",
57-
"eslint": "^9.12.0",
46+
"@tsconfig/bun": "^1.0.9",
47+
"@types/bun": "^1.3.0",
48+
"@types/ramda": "^0.31.1",
49+
"@typescript-eslint/rule-tester": "^8.46.0",
50+
"eslint": "^9.37.0",
5851
"json-schema-to-ts": "^3.1.1",
59-
"semver": "^7.6.3",
60-
"tsup": "^8.3.0",
61-
"typescript": "^5.6.3",
62-
"typescript-eslint": "^8.9.0"
52+
"tsdown": "^0.15.6",
53+
"typescript": "^5.9.3",
54+
"typescript-eslint": "^8.46.0"
6355
},
6456
"peerDependencies": {
6557
"eslint": "^9.0.0",
6658
"typescript-eslint": "^8.0.0"
6759
},
6860
"engines": {
69-
"node": "^18.18.0 || ^20.9.0 || ^22.0.0 || ^24.0.0"
61+
"node": "^20.19.0 || ^22.12.0 || ^24.0.0"
7062
},
7163
"keywords": [
7264
"modules",

src/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ export const splitPeers = (manifest: Manifest) => {
3131
);
3232
return { requiredPeers, optionalPeers };
3333
};
34+
35+
export const mapTuple = <V extends R.Tuple<unknown, number>, U>(
36+
fn: (n: V extends R.Tuple<infer T, number> ? T : never) => U,
37+
dict: V,
38+
) => R.map(fn, dict) as R.Tuple<U, V["length"]>;

src/rule.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ESLintUtils } from "@typescript-eslint/utils";
22
import * as R from "ramda";
3-
import { getManifest, getName, splitPeers } from "./helpers.ts";
3+
import { getManifest, getName, mapTuple, splitPeers } from "./helpers.ts";
44
import { type Category, type Options, options, type Value } from "./schema.ts";
55

66
const messages = {
@@ -15,7 +15,7 @@ const defaults: Options = {
1515
optionalPeers: "typeOnly",
1616
};
1717

18-
const values: Value[] = [true, false, "typeOnly"];
18+
const values = [true, false, "typeOnly"] as const satisfies Value[];
1919

2020
const makeIterator =
2121
(ctx: { cwd: string }) =>
@@ -42,12 +42,19 @@ const makeIterator =
4242
),
4343
);
4444

45-
const [allowed, prohibited, limited] = R.map(take, values);
45+
const [allowed, prohibited, limited] = mapTuple(take, values);
4646
limited.push(...typeOnly);
4747

4848
return { allowed, prohibited, limited, ignore };
4949
};
5050

51+
const groups = [
52+
"allowed",
53+
"prohibited",
54+
"limited",
55+
"ignore",
56+
] as const satisfies Array<keyof ReturnType<ReturnType<typeof makeIterator>>>;
57+
5158
const makeTester = (ignored: string[]) => {
5259
const patterns = R.map(R.constructN(1, RegExp), ignored);
5360
const invoker = R.invoker(1, "test");
@@ -65,9 +72,9 @@ export const rule = ESLintUtils.RuleCreator.withoutDocs({
6572
const iterator = makeIterator(ctx);
6673
const combined = R.map(iterator, ctx.options.length ? ctx.options : [{}]);
6774

68-
const [allowed, prohibited, limited, ignored] = R.map(
75+
const [allowed, prohibited, limited, ignored] = mapTuple(
6976
(group) => R.flatten(R.pluck(group, combined)),
70-
["allowed", "prohibited", "limited", "ignore"] as const,
77+
groups,
7178
);
7279

7380
const isIgnored = makeTester(ignored);

tsdown.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "tsdown";
2+
3+
export default defineConfig({
4+
entry: "./src/index.ts",
5+
minify: true,
6+
skipNodeModulesBundle: true,
7+
attw: { level: "error", profile: "esmOnly" },
8+
});

tsup.config.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)