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
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
Expand Down
5 changes: 5 additions & 0 deletions .changeset/light-onions-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@menglinmaker/eslint-plugin-runtime-compat": minor
---

Simplified apis and added comprehensive test suite
19 changes: 8 additions & 11 deletions .github/workflows/CD.yml → .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: CD
name: Changesets
on:
workflow_run:
workflows: [CI]
branches: [main]
types: [completed]

concurrency: ${{ github.workflow }}-${{ github.ref }}
push:
branches:
- main

permissions:
contents: write
Expand All @@ -14,7 +11,6 @@ permissions:

jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -28,15 +24,16 @@ jobs:

- run: pnpm install
- run: pnpm build
- run: pnpm lint
- run: pnpm test

- name: Create Release Pull Request or Publish to npm
id: changesets
- name: Update and publish versions
uses: changesets/action@v1
with:
publish: pnpm release
version: pnpm run version
commit: "chore: new release"
title: "chore: new release candidate"
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ npm install @menglinmaker/eslint-plugin-runtime-compat
```

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

export default [runtimeCompat.configs.strict];
export default [...tseslint.configs.recommended, ...runtimeCompat.configs.strict]
```

Alternatively, you can load a custom config:
```Bash
export default [runtimeCompat.configs.custom(['node', 'bun', 'deno'])];
```JavaScript
runtimeCompat.configs.custom(['node', 'bun', 'deno'])
```

## Limitations:
Expand Down
15 changes: 1 addition & 14 deletions e2e/import-package-compat/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import runtimeCompat from '@menglinmaker/eslint-plugin-runtime-compat'
import tseslint from 'typescript-eslint'

export default [
...tseslint.configs.recommended,
runtimeCompat.configs.recommended,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['*.js'],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
]
export default [...tseslint.configs.recommended, ...runtimeCompat.configs.strict]
1 change: 1 addition & 0 deletions e2e/import-package-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@eslint-plugin-runtime-compat/import-package-compat",
"private": true,
"type": "module",
"scripts": {
Expand Down
15 changes: 1 addition & 14 deletions e2e/internal-package-compat/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import runtimeCompat from '@menglinmaker/eslint-plugin-runtime-compat'
import tseslint from 'typescript-eslint'

export default [
...tseslint.configs.recommended,
runtimeCompat.configs.recommended,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['*.js'],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
]
export default [...tseslint.configs.recommended, ...runtimeCompat.configs.strict]
2 changes: 2 additions & 0 deletions e2e/internal-package-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name": "@eslint-plugin-runtime-compat/internal-package-compat",

"private": true,
"type": "module",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "turbo build",
"clean": "rimraf packages/**/dist & rimraf .turbo packages/**/.turbo & rimraf node_modules packages/**/node_modules",
"knip": "knip",
"changeset": "changeset",
"version": "changeset version",
"release": "changeset publish"
},
Expand Down
34 changes: 21 additions & 13 deletions packages/plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,33 @@ import { runtimeCompatRule } from './rules'
* @param ruleConfig - List of runtimes to check.
* @returns Generated flat-config for ESLint.
*/
const runtimeCompatPlugin = (filterRuntimes: RuntimeName[]) => ({
plugins: {
'runtime-compat': {
meta: {
name: pkg.name,
version: pkg.version,
},
rules: {
'runtime-compat': runtimeCompatRule(filterRuntimes),
const runtimeCompatPlugin = (filterRuntimes: RuntimeName[]) => [
{
plugins: {
'runtime-compat': {
meta: {
name: pkg.name,
version: pkg.version,
},
rules: {
'runtime-compat': runtimeCompatRule(filterRuntimes),
},
},
},
rules: {
'runtime-compat/runtime-compat': 'error',
},
},
rules: {
'runtime-compat/runtime-compat': 'error',
{
languageOptions: {
parserOptions: {
projectService: true,
},
},
},
})
]

export const configs = {
recommended: runtimeCompatPlugin(supportedRuntimes),
strict: runtimeCompatPlugin(supportedRuntimes),
custom: runtimeCompatPlugin,
}