-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 44de60e
Showing
399 changed files
with
12,148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Check http://editorconfig.org for more information | ||
# This is the main config file for this project: | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
end_of_line = lf | ||
|
||
[*.{js,ts,mjs}] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
*.js linguist-detectable=false | ||
*.mjs linguist-detectable=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Publish | ||
|
||
on: | ||
create: | ||
tags: | ||
- "v*" | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
RUST_LOG: "off" | ||
|
||
jobs: | ||
publish-npm: | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Install wasm-pack | ||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | ||
|
||
- name: Build wasm | ||
run: ./crates/rome_fmt/scripts/build.sh | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".node-version" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- run: | | ||
cd crates/rome_fmt/pkg | ||
npm publish --provenance | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
publish-github: | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Install wasm-pack | ||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | ||
|
||
- name: Build wasm | ||
run: ./crates/rome_fmt/scripts/build.sh | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".node-version" | ||
registry-url: "https://npm.pkg.github.com" | ||
|
||
- run: | | ||
cd crates/rome_fmt/pkg | ||
npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
publish-github-release: | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Install wasm-pack | ||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | ||
|
||
- name: Build wasm | ||
run: | | ||
# build for JS API | ||
./crates/rome_fmt/scripts/build.sh | ||
- name: Package | ||
run: cd crates/rome_fmt/pkg && npm pack | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d | ||
with: | ||
files: | | ||
crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_TERM_COLOR: "always" | ||
DIFF: 0 | ||
RUST_LOG: "off" | ||
|
||
jobs: | ||
cargo-fmt: | ||
name: Cargo fmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: rustfmt | ||
|
||
- run: cargo fmt -- --check | ||
|
||
cargo-clippy: | ||
name: Cargo clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: clippy | ||
|
||
- run: cargo clippy | ||
|
||
cargo-test: | ||
name: Cargo test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- run: cargo check | ||
- run: cargo test | ||
|
||
wasm-test: | ||
name: Wasm test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Install wasm-pack | ||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | ||
|
||
- name: Build wasm | ||
run: ./crates/rome_fmt/scripts/build.sh | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".node-version" | ||
|
||
- name: Node Test | ||
run: node --test | ||
|
||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Deno Test | ||
run: deno test --allow-read | ||
|
||
- name: Package | ||
run: cd crates/rome_fmt/pkg && npm pack | ||
|
||
- name: Upload | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: npm | ||
path: crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# group_imports = "StdExternalCrate" | ||
# imports_granularity = "Crate" | ||
reorder_imports = true | ||
use_small_heuristics = "Max" | ||
|
||
# normalize_comments = true | ||
# wrap_comments = true | ||
|
||
# condense_wildcard_suffixes = true | ||
# enum_discrim_align_threshold = 20 | ||
# reorder_impl_items = true | ||
use_field_init_shorthand = true | ||
|
||
# format_code_in_doc_comments = true | ||
# format_macro_matchers = true | ||
# format_strings = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# https://taplo.tamasfe.dev/configuration/formatter-options.html | ||
[formatting] | ||
align_entries = true | ||
indent_tables = true | ||
reorder_keys = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.enablePaths": [ | ||
"./crates/rome_fmt/test_deno" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[workspace] | ||
members = ["crates/*"] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
authors = ["magic-akari <akari.ccino@gmail.com>"] | ||
description = "JavaScript/TypeScript formatter powered by wasm ported from Rome" | ||
edition = "2021" | ||
homepage = "https://github.com/wasm-fmt/rome_fmt" | ||
keywords = [ | ||
"wasm", | ||
"JavaScript", | ||
"TypeScript", | ||
"JSX", | ||
"TSX", | ||
"formatter", | ||
"Rome", | ||
] | ||
license = "MIT" | ||
readme = "README.md" | ||
repository = "https://github.com/wasm-fmt/rome_fmt" | ||
version = "0.0.0" | ||
|
||
|
||
[workspace.dependencies] | ||
rome_formatter = { version = "0.0.1" } | ||
rome_js_formatter = { version = "0.0.2" } | ||
rome_js_parser = { version = "0.0.1" } | ||
rome_js_syntax = { version = "0.0.1" } | ||
serde = { version = "1.0" } | ||
serde_json = { version = "1.0" } | ||
wasm-bindgen = "0.2.87" | ||
|
||
[profile.release] | ||
lto = true | ||
opt-level = "s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 wasm-fmt | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
authors.workspace = true | ||
description.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
name = "rome_fmt" | ||
publish = true | ||
repository.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
rome_formatter = { workspace = true } | ||
rome_js_formatter = { workspace = true } | ||
rome_js_parser = { workspace = true } | ||
rome_js_syntax = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde-wasm-bindgen = "0.5" | ||
serde_json = { workspace = true, features = ["preserve_order"] } | ||
wasm-bindgen = { workspace = true } | ||
|
||
[dev-dependencies] | ||
testing_macros = "0.2.11" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.bak | ||
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export * from "./_rome_fmt.js"; | ||
|
||
export type Filename = | ||
| "file.js" | ||
| "file.mjs" | ||
| "file.cjs" | ||
| "file.ts" | ||
| "file.mts" | ||
| "file.cts" | ||
| "file.jsx" | ||
| "file.mjsx" | ||
| "file.cjsx" | ||
| "file.tsx" | ||
| "file.mtsx" | ||
| "file.ctsx" | ||
| "file.d.ts" | ||
| "file.d.mts" | ||
| "file.d.cts" | ||
| "file.d.mtsx" | ||
| "file.d.ctsx" | ||
| (string & {}); | ||
|
||
import init, { type Config } from "./_rome_fmt.js"; | ||
export default init; | ||
|
||
/** | ||
* @param {string} src - The content to format. | ||
* @param {string} filename - The filename to use for determining the language. | ||
* @param {Config} config - The Config to use for formatting. | ||
* @returns {string} The formatted content. | ||
*/ | ||
export function format(src: string, filename?: Filename, config?: Config): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import init from "./rome_fmt.js"; | ||
import wasm from "./rome_fmt_bg.wasm?url"; | ||
|
||
export default function __wbg_init(input = wasm) { | ||
return init(input); | ||
} | ||
|
||
export * from "./rome_fmt.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/crates/rome_fmt/pkg/rome_fmt.js b/crates/rome_fmt/pkg/rome_fmt.js | ||
index 1d29ee1..71c2a12 100644 | ||
--- a/crates/rome_fmt/pkg/rome_fmt.js | ||
+++ b/crates/rome_fmt/pkg/rome_fmt.js | ||
@@ -211,7 +211,7 @@ function addBorrowedObject(obj) { | ||
* @param {Config} config | ||
* @returns {string} | ||
*/ | ||
-export function format(src, filename, config) { | ||
+export function format(src, filename = "file.tsx", config = {}) { | ||
let deferred4_0; | ||
let deferred4_1; | ||
try { | ||
@@ -512,8 +512,17 @@ async function __wbg_init(input) { | ||
} | ||
const imports = __wbg_get_imports(); | ||
|
||
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { | ||
- input = fetch(input); | ||
+ switch (true) { | ||
+ case typeof input === 'string': | ||
+ input = new URL(input, import.meta.url); | ||
+ case input instanceof URL: | ||
+ if (typeof __webpack_require__ !== 'function' && input.protocol === 'file:') { | ||
+ const fs = await import('node:fs/promises'); | ||
+ input = fs.readFile(input); | ||
+ break; | ||
+ } | ||
+ case typeof Request === 'function' && input instanceof Request: | ||
+ input = fetch(input); | ||
} | ||
|
||
__wbg_init_memory(imports); |
Oops, something went wrong.