-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rivethealth/pauldraper/prettier
Upgrade to Prettier 3
- Loading branch information
Showing
34 changed files
with
328 additions
and
107 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
|
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
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
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
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
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
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
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,3 @@ | ||
export function load(specifier: string): Promise<any>; | ||
|
||
export function resolve(specifier: string, parent?: URL): Promise<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,11 @@ | ||
async function load() { | ||
const { load } = await import("./import.mjs"); | ||
return Reflect.apply(load, this, arguments); | ||
} | ||
|
||
async function resolve() { | ||
const { resolve } = await import("./import.mjs"); | ||
return Reflect.apply(resolve, this, arguments); | ||
} | ||
|
||
module.exports = { load, resolve }; |
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,7 @@ | ||
export function load(specifier) { | ||
return import(specifier); | ||
} | ||
|
||
export function resolve(specifier, parent) { | ||
return import.meta.resolve(specifier, parent); | ||
} |
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
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import { ArgumentParser } from "argparse"; | ||
import * as fs from "node:fs"; | ||
import prettier from "prettier"; | ||
import { readFile, writeFile } from "node:fs/promises"; | ||
import { Options, format } from "prettier"; | ||
|
||
export class PrettierWorker { | ||
constructor(private readonly options: any) {} | ||
constructor(private readonly options: Options | undefined) {} | ||
|
||
run(a: string[]) { | ||
async run(a: string[]) { | ||
const parser = new ArgumentParser(); | ||
parser.add_argument("input"); | ||
parser.add_argument("output"); | ||
const args = parser.parse_args(a); | ||
const input = fs.readFileSync(args.input, "utf8"); | ||
const output = prettier.format(input, { | ||
const input = await readFile(args.input, "utf8"); | ||
const output = await format(input, { | ||
...this.options, | ||
filepath: args.input, | ||
}); | ||
fs.writeFileSync(args.output, output, "utf8"); | ||
await writeFile(args.output, output, "utf8"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true | ||
"module": "es2020" | ||
}, | ||
"extends": "@better-rules-javascript/tools-typescript/tsconfig.common.json" | ||
} |
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
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,50 @@ | ||
load("//commonjs:rules.bzl", "cjs_root") | ||
load("//javascript:rules.bzl", "js_library") | ||
load("//jest:rules.bzl", "jest_test") | ||
load("//typescript:rules.bzl", "ts_library") | ||
|
||
js_library( | ||
name = "jest_config", | ||
srcs = ["jest.config.js"], | ||
root = ":root", | ||
deps = ["//test:lib"], | ||
) | ||
|
||
cjs_root( | ||
name = "root", | ||
package_name = "@better-rules-javascript/prettier-test", | ||
) | ||
|
||
jest_test( | ||
name = "test", | ||
size = "large", | ||
config = "jest.config.js", | ||
config_dep = ":jest_config", | ||
data = glob(["bazel/**/*"]) + ["@files//:common"], | ||
dep = ":test_lib", | ||
jest = "@npm//jest:lib", | ||
node = "@better_rules_javascript//tools/nodejs", | ||
tags = ["local"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
ts_library( | ||
name = "test_lib", | ||
srcs = glob(["src/**/*.ts"]), | ||
compiler = "//typescript:tsc", | ||
config = "tsconfig.json", | ||
config_dep = ":tsconfig", | ||
root = ":root", | ||
deps = [ | ||
"//test:lib", | ||
"@npm//@types/jest:lib", | ||
"@npm//@types/node:lib", | ||
], | ||
) | ||
|
||
js_library( | ||
name = "tsconfig", | ||
srcs = ["tsconfig.json"], | ||
root = ":root", | ||
deps = ["//tools/typescript:tsconfig"], | ||
) |
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 @@ | ||
workspace(name = "better_rules_javascript_test") | ||
|
||
# JavaScript | ||
|
||
local_repository( | ||
name = "better_rules_javascript", | ||
path = "../../../external/files/files", | ||
) | ||
|
||
load("@better_rules_javascript//test:workspace0.bzl", "test_repositories0") | ||
|
||
test_repositories0() | ||
|
||
load("@better_rules_javascript//test:workspace1.bzl", "test_repositories1") | ||
|
||
test_repositories1() |
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,30 @@ | ||
load("@better_rules_javascript//commonjs:rules.bzl", "cjs_root") | ||
load("@better_rules_javascript//javascript:rules.bzl", "js_library") | ||
load("@better_rules_javascript//prettier:rules.bzl", "configure_prettier") | ||
load("@rules_file//generate:rules.bzl", "format") | ||
|
||
format( | ||
name = "format", | ||
srcs = ["example.xml"], | ||
formatter = ":prettier", | ||
) | ||
|
||
js_library( | ||
name = "prettier_config", | ||
srcs = ["prettierrc.yml"], | ||
root = "root", | ||
deps = ["@npm//@prettier/plugin-xml:lib"], | ||
) | ||
|
||
cjs_root( | ||
name = "root", | ||
package_name = "@better-rules-javascript-test/prettier-plugin", | ||
descriptors = ["package.json"], | ||
) | ||
|
||
configure_prettier( | ||
name = "prettier", | ||
config = "prettierrc.yml", | ||
config_dep = ":prettier_config", | ||
dep = "@npm//prettier:lib", | ||
) |
File renamed without changes.
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 @@ | ||
{} |
File renamed without changes.
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,3 @@ | ||
const { jestConfig } = require("@better-rules-javascript/test/jest-config"); | ||
|
||
module.exports = jestConfig(); |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import { spawnOptions } from "@better-rules-javascript/test"; | ||
import * as childProcess from "node:child_process"; | ||
|
||
test("Format", () => { | ||
const result = childProcess.spawnSync("bazel", ["run", "plugin:format"], { | ||
cwd: "prettier/test/bazel", | ||
stdio: "inherit", | ||
...spawnOptions(), | ||
}); | ||
expect(result.status).toBe(0); | ||
}); |
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,3 @@ | ||
{ | ||
"extends": "@better-rules-javascript/tools-typescript/tsconfig.common.json" | ||
} |
Oops, something went wrong.