Skip to content

Commit b4c94df

Browse files
authored
chore: simplify apis (#59)
1 parent cdb5831 commit b4c94df

File tree

10 files changed

+47
-58
lines changed

10 files changed

+47
-58
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"commit": false,
1010
"fixed": [],
1111
"linked": [],
12-
"access": "public",
12+
"access": "restricted",
1313
"baseBranch": "main",
1414
"updateInternalDependencies": "patch",
1515
"ignore": []

.changeset/light-onions-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@menglinmaker/eslint-plugin-runtime-compat": minor
3+
---
4+
5+
Simplified apis and added comprehensive test suite
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
name: CD
1+
name: Changesets
22
on:
3-
workflow_run:
4-
workflows: [CI]
5-
branches: [main]
6-
types: [completed]
7-
8-
concurrency: ${{ github.workflow }}-${{ github.ref }}
3+
push:
4+
branches:
5+
- main
96

107
permissions:
118
contents: write
@@ -14,7 +11,6 @@ permissions:
1411

1512
jobs:
1613
release:
17-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1814
runs-on: ubuntu-latest
1915
steps:
2016
- uses: actions/checkout@v4
@@ -28,15 +24,16 @@ jobs:
2824

2925
- run: pnpm install
3026
- run: pnpm build
27+
- run: pnpm lint
28+
- run: pnpm test
3129

32-
- name: Create Release Pull Request or Publish to npm
33-
id: changesets
30+
- name: Update and publish versions
3431
uses: changesets/action@v1
3532
with:
36-
publish: pnpm release
3733
version: pnpm run version
3834
commit: "chore: new release"
3935
title: "chore: new release candidate"
36+
publish: pnpm release
4037
env:
4138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4239
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ npm install @menglinmaker/eslint-plugin-runtime-compat
3232
```
3333

3434
2. Add `eslint.config.mjs` to root. This detects incompatible APIs for all runtimes in the dataset.
35-
```Bash
36-
import runtimeCompat from "@menglinmaker/eslint-plugin-runtime-compat";
35+
```JavaScript
36+
import runtimeCompat from '@menglinmaker/eslint-plugin-runtime-compat'
37+
import tseslint from 'typescript-eslint'
3738

38-
export default [runtimeCompat.configs.strict];
39+
export default [...tseslint.configs.recommended, ...runtimeCompat.configs.strict]
3940
```
4041

4142
Alternatively, you can load a custom config:
42-
```Bash
43-
export default [runtimeCompat.configs.custom(['node', 'bun', 'deno'])];
43+
```JavaScript
44+
runtimeCompat.configs.custom(['node', 'bun', 'deno'])
4445
```
4546

4647
## Limitations:
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import runtimeCompat from '@menglinmaker/eslint-plugin-runtime-compat'
22
import tseslint from 'typescript-eslint'
33

4-
export default [
5-
...tseslint.configs.recommended,
6-
runtimeCompat.configs.recommended,
7-
{
8-
languageOptions: {
9-
parserOptions: {
10-
projectService: {
11-
allowDefaultProject: ['*.js'],
12-
},
13-
tsconfigRootDir: import.meta.dirname,
14-
},
15-
},
16-
},
17-
]
4+
export default [...tseslint.configs.recommended, ...runtimeCompat.configs.strict]

e2e/import-package-compat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "@eslint-plugin-runtime-compat/import-package-compat",
23
"private": true,
34
"type": "module",
45
"scripts": {
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import runtimeCompat from '@menglinmaker/eslint-plugin-runtime-compat'
22
import tseslint from 'typescript-eslint'
33

4-
export default [
5-
...tseslint.configs.recommended,
6-
runtimeCompat.configs.recommended,
7-
{
8-
languageOptions: {
9-
parserOptions: {
10-
projectService: {
11-
allowDefaultProject: ['*.js'],
12-
},
13-
tsconfigRootDir: import.meta.dirname,
14-
},
15-
},
16-
},
17-
]
4+
export default [...tseslint.configs.recommended, ...runtimeCompat.configs.strict]

e2e/internal-package-compat/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"name": "@eslint-plugin-runtime-compat/internal-package-compat",
3+
24
"private": true,
35
"type": "module",
46
"scripts": {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "turbo build",
1010
"clean": "rimraf packages/**/dist & rimraf .turbo packages/**/.turbo & rimraf node_modules packages/**/node_modules",
1111
"knip": "knip",
12+
"changeset": "changeset",
1213
"version": "changeset version",
1314
"release": "changeset publish"
1415
},

packages/plugin/src/index.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,33 @@ import { runtimeCompatRule } from './rules'
99
* @param ruleConfig - List of runtimes to check.
1010
* @returns Generated flat-config for ESLint.
1111
*/
12-
const runtimeCompatPlugin = (filterRuntimes: RuntimeName[]) => ({
13-
plugins: {
14-
'runtime-compat': {
15-
meta: {
16-
name: pkg.name,
17-
version: pkg.version,
18-
},
19-
rules: {
20-
'runtime-compat': runtimeCompatRule(filterRuntimes),
12+
const runtimeCompatPlugin = (filterRuntimes: RuntimeName[]) => [
13+
{
14+
plugins: {
15+
'runtime-compat': {
16+
meta: {
17+
name: pkg.name,
18+
version: pkg.version,
19+
},
20+
rules: {
21+
'runtime-compat': runtimeCompatRule(filterRuntimes),
22+
},
2123
},
2224
},
25+
rules: {
26+
'runtime-compat/runtime-compat': 'error',
27+
},
2328
},
24-
rules: {
25-
'runtime-compat/runtime-compat': 'error',
29+
{
30+
languageOptions: {
31+
parserOptions: {
32+
projectService: true,
33+
},
34+
},
2635
},
27-
})
36+
]
2837

2938
export const configs = {
30-
recommended: runtimeCompatPlugin(supportedRuntimes),
3139
strict: runtimeCompatPlugin(supportedRuntimes),
3240
custom: runtimeCompatPlugin,
3341
}

0 commit comments

Comments
 (0)