Skip to content

Commit

Permalink
feat: updateAst. (#20)
Browse files Browse the repository at this point in the history
* chore!: upgrade eslint.
BREAKING CHANGE: upgrade supported Node.js versions to >= 20.0.0.
  • Loading branch information
knightedcodemonkey authored May 27, 2024
1 parent 69629a9 commit 4160583
Show file tree
Hide file tree
Showing 11 changed files with 1,225 additions and 3,156 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.json

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
uses: actions/checkout@v4.1.6
- name: Setup Node
uses: actions/setup-node@v3.6.0
uses: actions/setup-node@v4.0.2
with:
node-version: '20.8.1'
node-version: '22.2.0'
- name: Install Dependencies
run: npm ci
- name: Save error log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.3.3
if: ${{ failure() }}
with:
name: npm-debug-log-${{ hashFiles('package-lock.json') }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
uses: actions/checkout@v4.1.6
- name: Setup Node
uses: actions/setup-node@v3.6.0
uses: actions/setup-node@v4.0.2
with:
node-version: '20.8.1'
node-version: '22.2.0'
- name: Install Dependencies
run: npm ci
- name: Save error log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.3.3
if: ${{ failure() }}
with:
name: npm-debug-log-${{ hashFiles('package-lock.json') }}
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Pack
run: npm pack
- name: Push to NPM registry
uses: JS-DevTools/npm-publish@v2.1.0
uses: JS-DevTools/npm-publish@v3.1.1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
tag: ${{ contains(github.ref, '-') && 'next' || 'latest' }}
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 KCM

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,15 @@ interface RegexMap {
```

Where the other types have the same definition from [`specifier.update`](https://github.com/knightedcodemonkey/specifier#async-specifierupdatefilename-callback).

## `async specifier.updateAst(ast, code, callback)`

Updates specifiers in a Babel AST with source `code` using the value returned from `callback`, and returns an `Update`.

### Signature

```ts
(ast: ParseResult<File>, code: string, callback: Callback) => Promise<Update>
```

Where the other types have the same definition from [`specifier.update`](https://github.com/knightedcodemonkey/specifier#async-specifierupdatefilename-callback).
2 changes: 1 addition & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"targets": "node >= 14",
"targets": "node >= 20",
"comments": false,
"presets": [
["@babel/preset-env", {
Expand Down
23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import nodePlugin from 'eslint-plugin-n'

export default tseslint.config(
eslint.configs.recommended,
nodePlugin.configs['flat/recommended'],
...tseslint.configs.recommended,
{
rules: {
'no-console': 'error',
},
},
{
files: ['test/__fixtures__/**/*'],
rules: {
'no-undef': 'off',
'n/no-missing-import': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
)
Loading

0 comments on commit 4160583

Please sign in to comment.