Skip to content

Commit e6962fa

Browse files
authored
Improve type compatibility (#12)
* Improve compatibility * add changeset * update workflow to use trusted publishing * update changeset
1 parent 0e09e63 commit e6962fa

File tree

4 files changed

+56
-44
lines changed

4 files changed

+56
-44
lines changed

.changeset/fruity-trains-lose.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-zod": patch
3+
---
4+
5+
Fix types to be compatible with ESLint's `defineConfig` and release with trusted publishing

.github/workflows/release.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ on:
55
branches:
66
- beta
77
- main
8+
workflow_dispatch:
89

910
jobs:
1011
release:
12+
if: github.event_name == 'push'
1113
permissions:
1214
contents: write
1315
id-token: write
@@ -36,11 +38,52 @@ jobs:
3638
- name: Install dependencies
3739
run: pnpm install --frozen-lockfile
3840

41+
# Ensure npm 11.5.1 or later is installed
42+
- name: Update npm
43+
run: npm install -g npm@latest
44+
3945
- name: Release
4046
uses: changesets/action@v1
4147
with:
4248
publish: pnpm release
4349
version: pnpm changeset version
4450
env:
4551
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
snapshot:
53+
if: github.event_name == 'workflow_dispatch'
54+
permissions:
55+
contents: write
56+
id-token: write
57+
pull-requests: write
58+
name: Publish snapshot version
59+
runs-on: ubuntu-latest
60+
env:
61+
CI: true
62+
steps:
63+
- name: Check out repo
64+
uses: actions/checkout@v4
65+
with:
66+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
67+
fetch-depth: 0
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Set up pnpm
71+
uses: pnpm/action-setup@v4
72+
73+
- name: Set up Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version-file: package.json
77+
cache: pnpm
78+
79+
- name: Install dependencies
80+
run: pnpm install --frozen-lockfile
81+
82+
# Ensure npm 11.5.1 or later is installed
83+
- name: Update npm
84+
run: npm install -g npm@latest
85+
86+
- name: Publish
87+
uses: seek-oss/changesets-snapshot@v0
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/snapshot.yml

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

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import preferZodNamespace from "./rules/prefer-zod-namespace";
22
import { TSESLint } from "@typescript-eslint/utils";
3+
import type { ESLint, Linter } from "eslint";
34

45
// Create the base plugin object
56
const importZod = {
@@ -8,12 +9,14 @@ const importZod = {
89
version: "1.0.0",
910
},
1011
rules: {
11-
"prefer-zod-namespace": preferZodNamespace,
12+
"prefer-zod-namespace": preferZodNamespace as unknown as NonNullable<
13+
ESLint.Plugin["rules"]
14+
>[string],
1215
},
1316
configs: {} as {
14-
recommended: TSESLint.FlatConfig.ConfigArray;
17+
recommended: Linter.Config[];
1518
},
16-
};
19+
} satisfies ESLint.Plugin;
1720

1821
Object.assign(
1922
importZod.configs as NonNullable<TSESLint.Linter.Plugin["configs"]>,
@@ -27,7 +30,7 @@ Object.assign(
2730
"import-zod/prefer-zod-namespace": "error",
2831
},
2932
},
30-
] satisfies TSESLint.FlatConfig.ConfigArray,
33+
] satisfies Linter.Config[],
3134
}
3235
);
3336

0 commit comments

Comments
 (0)