Skip to content

Commit

Permalink
fix: handle inconsistent exports of JSOX (#333)
Browse files Browse the repository at this point in the history
* fix: handle inconsistent exports of JSOX

* Create red-news-worry.md

* Update packages/sql/src/index.ts

* Update packages/sql/src/index.ts

---------

Co-authored-by: JounQin <admin@1stg.me>
  • Loading branch information
Brookke and JounQin committed Dec 16, 2023
1 parent 3d85966 commit 909e30a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-news-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prettier-plugin-sql": patch
---

fix: handle inconsistent exports of JSOX
4 changes: 3 additions & 1 deletion packages/sql/shim.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
declare module 'jsox' {
export const JSOX: typeof JSON
const JSOX: typeof JSON & { JSOX?: typeof JSON }

export = JSOX
}
5 changes: 4 additions & 1 deletion packages/sql/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/// <reference path="../shim.d.ts" />

import { JSOX } from 'jsox'
import * as _JSOX from 'jsox'
import type { AST, Option } from 'node-sql-parser'
import nodeSqlParser from 'node-sql-parser'
import type { Options, ParserOptions, Plugin } from 'prettier'
import { format, type FormatOptionsWithLanguage } from 'sql-formatter'

import { languages } from './languages.js'

// see #332 for more details
const JSOX = _JSOX.JSOX || _JSOX

const parser = new nodeSqlParser.Parser()

const SQL_FORMATTER = 'sql-formatter'
Expand Down

0 comments on commit 909e30a

Please sign in to comment.