Skip to content

Commit

Permalink
Simplify to remove vscode problems
Browse files Browse the repository at this point in the history
  • Loading branch information
eoftedal committed Feb 7, 2024
1 parent 682239f commit 7a67ec2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ the object is bound to a parameter of the surrounding function, an return the as
* `/:<name>` - find an attribute of the current node with the given name
* `//:<name>` - find an attribute of the current node with the given name regardless of whether it's on the current node or on a descendant
* `/$:<name>` - find the binding of an Identifier
* `/$$:<name>` - return the binding or the attribute if bining cannot be resolved (helpful if a variable is sometimes directly assigned and sometimes not)
* `/$$:<name>` - return the binding or the attribute if binding cannot be resolved (helpful if a variable is sometimes directly assigned and sometimes not)
* `[]` - apply a filter to the node
* `&&`, `||` - logical conditions of a filter
* `==` - comparison in filter
Expand All @@ -52,8 +52,8 @@ the object is bound to a parameter of the surrounding function, an return the as

## API

* `query(code: ParseResult<Babel.File> | string, query: string) : Result[]` - Runs the given query on the given code in the form of an already parsed AST or a string (which is parsed as `sourceType: "script"`), and returns the result.
* `multiQuery<T extends Record<string, string>>(code: ParseResult<Babel.File> | string, namedQueries: T) : Record<keyof T, Result[]>` - Runs the given set of named queries on the given code in the form of an already parsed AST or a string (which is parsed as `sourceType: "script"`), and returns a map of named results (one result array per named query).
* `query(code: ParseResult<Babel.File> | string, query: string) : Result[]` - Runs the given query on the given code in the form of an already parsed AST or a string (which is parsed as `sourceType: "unambiguous"`), and returns the result.
* `multiQuery<T extends Record<string, string>>(code: ParseResult<Babel.File> | string, namedQueries: T) : Record<keyof T, Result[]>` - Runs the given set of named queries on the given code in the form of an already parsed AST or a string (which is parsed as `sourceType: "unambiguous"`), and returns a map of named results (one result array per named query).

where `Result` is `Babel.Node | string | number | boolean;`

Expand Down
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = {
transform: {
'^.+\\.ts?$': [
'ts-jest',
{ tsconfig: 'tsconfig.esm.json' }
'ts-jest'
],
},
testEnvironment: 'node',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"description": "offers a way to query an babel AST to find specific patterns using a syntax somewhat similar to XPath.",
"scripts": {
"lint": "eslint . --ext .ts --fix --ignore-path .gitignore",
"typecheck": "tsc --noEmit -p ./tsconfig.esm.json",
"typecheck": "tsc --noEmit",
"clean": "rm -rf lib && mkdir lib",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"build:esm": "tsc -p ./tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs",
"build:esm": "tsc && mv lib/esm/index.js lib/esm/index.mjs",
"build:cjs": "tsc -p ./tsconfig.cjs.json",
"watch": "tsc --watch -p ./tsconfig.esm.json",
"watch": "tsc --watch",
"check": "npm run lint && npm run typecheck",
"dev": "tsc --watch",
"testWatch": "jest --watchAll",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"lib": ["ES2022"],
"target": "ES2022",
Expand Down
11 changes: 0 additions & 11 deletions tsconfig.esm.json

This file was deleted.

9 changes: 8 additions & 1 deletion tsconfig.base.json → tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
"allowJs": true,
"declaration": true,
"declarationMap": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,

"lib": ["ES2022"],
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./lib/esm",
"declarationDir": "./lib/esm/types"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
Expand Down

0 comments on commit 7a67ec2

Please sign in to comment.