mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Switch back to Prettier for Svelte formatting
Closes #3649 Closes #3713
This commit is contained in:
parent
178a3faaf7
commit
2c1a4895ba
6 changed files with 64 additions and 40 deletions
|
@ -8,13 +8,6 @@
|
||||||
},
|
},
|
||||||
"markdown": {},
|
"markdown": {},
|
||||||
"toml": {},
|
"toml": {},
|
||||||
"prettier": {
|
|
||||||
"trailingComma": "all",
|
|
||||||
"printWidth": 88,
|
|
||||||
"tabWidth": 4,
|
|
||||||
"semi": true,
|
|
||||||
"htmlWhitespaceSensitivity": "ignore"
|
|
||||||
},
|
|
||||||
"includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,toml,svelte,scss}"],
|
"includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,toml,svelte,scss}"],
|
||||||
"excludes": [
|
"excludes": [
|
||||||
".vscode",
|
".vscode",
|
||||||
|
@ -39,7 +32,6 @@
|
||||||
"https://plugins.dprint.dev/json-0.19.3.wasm",
|
"https://plugins.dprint.dev/json-0.19.3.wasm",
|
||||||
"https://plugins.dprint.dev/markdown-0.17.6.wasm",
|
"https://plugins.dprint.dev/markdown-0.17.6.wasm",
|
||||||
"https://plugins.dprint.dev/toml-0.6.2.wasm",
|
"https://plugins.dprint.dev/toml-0.6.2.wasm",
|
||||||
"https://plugins.dprint.dev/prettier-0.46.1.json@e5bd083088a8dfc6e5ce2d3c9bee81489b065bd5345ef55b59f5d96627928b7a",
|
|
||||||
"https://plugins.dprint.dev/disrupted/css-0.2.3.wasm"
|
"https://plugins.dprint.dev/disrupted/css-0.2.3.wasm"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
8
.prettierrc
Normal file
8
.prettierrc
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"trailingComma": "all",
|
||||||
|
"printWidth": 88,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"semi": true,
|
||||||
|
"htmlWhitespaceSensitivity": "ignore",
|
||||||
|
"plugins": ["prettier-plugin-svelte"]
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ use ninja_gen::node::DPrint;
|
||||||
use ninja_gen::node::EsbuildScript;
|
use ninja_gen::node::EsbuildScript;
|
||||||
use ninja_gen::node::Eslint;
|
use ninja_gen::node::Eslint;
|
||||||
use ninja_gen::node::GenTypescriptProto;
|
use ninja_gen::node::GenTypescriptProto;
|
||||||
|
use ninja_gen::node::Prettier;
|
||||||
use ninja_gen::node::SqlFormat;
|
use ninja_gen::node::SqlFormat;
|
||||||
use ninja_gen::node::SvelteCheck;
|
use ninja_gen::node::SvelteCheck;
|
||||||
use ninja_gen::node::SveltekitBuild;
|
use ninja_gen::node::SveltekitBuild;
|
||||||
|
@ -64,6 +65,7 @@ fn setup_node(build: &mut Build) -> Result<()> {
|
||||||
"vite",
|
"vite",
|
||||||
"vitest",
|
"vitest",
|
||||||
"protoc-gen-es",
|
"protoc-gen-es",
|
||||||
|
"prettier",
|
||||||
],
|
],
|
||||||
hashmap! {
|
hashmap! {
|
||||||
"jquery" => vec![
|
"jquery" => vec![
|
||||||
|
@ -290,10 +292,10 @@ fn build_and_check_reviewer(build: &mut Build) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_web(build: &mut Build) -> Result<()> {
|
fn check_web(build: &mut Build) -> Result<()> {
|
||||||
let dprint_files = inputs![glob![
|
let fmt_excluded = "{target,ts/.svelte-kit,node_modules}/**";
|
||||||
"**/*.{ts,mjs,js,md,json,toml,svelte,scss}",
|
let dprint_files = inputs![glob!["**/*.{ts,mjs,js,md,json,toml,scss}", fmt_excluded]];
|
||||||
"{target,ts/.svelte-kit,node_modules}/**"
|
let prettier_files = inputs![glob!["**/*.svelte", fmt_excluded]];
|
||||||
]];
|
|
||||||
build.add_action(
|
build.add_action(
|
||||||
"check:format:dprint",
|
"check:format:dprint",
|
||||||
DPrint {
|
DPrint {
|
||||||
|
@ -308,6 +310,20 @@ fn check_web(build: &mut Build) -> Result<()> {
|
||||||
check_only: false,
|
check_only: false,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
build.add_action(
|
||||||
|
"check:format:prettier",
|
||||||
|
Prettier {
|
||||||
|
inputs: prettier_files.clone(),
|
||||||
|
check_only: true,
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
build.add_action(
|
||||||
|
"format:prettier",
|
||||||
|
Prettier {
|
||||||
|
inputs: prettier_files,
|
||||||
|
check_only: false,
|
||||||
|
},
|
||||||
|
)?;
|
||||||
build.add_action(
|
build.add_action(
|
||||||
"check:vitest",
|
"check:vitest",
|
||||||
ViteTest {
|
ViteTest {
|
||||||
|
|
|
@ -207,6 +207,30 @@ impl BuildAction for DPrint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Prettier {
|
||||||
|
pub inputs: BuildInput,
|
||||||
|
pub check_only: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BuildAction for Prettier {
|
||||||
|
fn command(&self) -> &str {
|
||||||
|
"$prettier $mode $pattern"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn files(&mut self, build: &mut impl build::FilesHandle) {
|
||||||
|
build.add_inputs("prettier", inputs![":node_modules:prettier"]);
|
||||||
|
build.add_inputs("", &self.inputs);
|
||||||
|
build.add_variable("pattern", r#""**/*.svelte""#);
|
||||||
|
let (file_ext, mode) = if self.check_only {
|
||||||
|
("fmt", "--check")
|
||||||
|
} else {
|
||||||
|
("check", "--write")
|
||||||
|
};
|
||||||
|
build.add_variable("mode", mode);
|
||||||
|
build.add_output_stamp(format!("tests/prettier.{file_ext}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct SvelteCheck {
|
pub struct SvelteCheck {
|
||||||
pub tsconfig: BuildInput,
|
pub tsconfig: BuildInput,
|
||||||
pub inputs: BuildInput,
|
pub inputs: BuildInput,
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
"eslint-plugin-import": "^2.25.4",
|
"eslint-plugin-import": "^2.25.4",
|
||||||
"eslint-plugin-svelte": "^2",
|
"eslint-plugin-svelte": "^2",
|
||||||
"license-checker-rseidelsohn": "=4.3.0",
|
"license-checker-rseidelsohn": "=4.3.0",
|
||||||
"prettier": "^2.4.1",
|
"prettier": "^3.4.2",
|
||||||
"prettier-plugin-svelte": "^3.2.6",
|
"prettier-plugin-svelte": "^3.3.2",
|
||||||
"sass": "<1.77",
|
"sass": "<1.77",
|
||||||
"svelte": "^5.17.3",
|
"svelte": "^5.17.3",
|
||||||
"svelte-check": "^3.4.4",
|
"svelte-check": "^3.4.4",
|
||||||
|
|
36
yarn.lock
36
yarn.lock
|
@ -3637,15 +3637,15 @@ prelude-ls@^1.2.1:
|
||||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
||||||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
||||||
|
|
||||||
prettier-plugin-svelte@^3.2.6:
|
prettier-plugin-svelte@^3.3.2:
|
||||||
version "3.2.7"
|
version "3.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-3.2.7.tgz#10db2d553b48c6ed412e2d00688f8d2eaa274f8a"
|
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-3.3.2.tgz#f0c0b023a697f5cb43fb7257170e3d8762b547c6"
|
||||||
integrity sha512-/Dswx/ea0lV34If1eDcG3nulQ63YNr5KPDfMsjbdtpSWOxKKJ7nAc2qlVuYwEvCr4raIuredNoR7K4JCkmTGaQ==
|
integrity sha512-kRPjH8wSj2iu+dO+XaUv4vD8qr5mdDmlak3IT/7AOgGIMRG86z/EHOLauFcClKEnOUf4A4nOA7sre5KrJD4Raw==
|
||||||
|
|
||||||
prettier@^2.4.1:
|
prettier@^3.4.2:
|
||||||
version "2.8.8"
|
version "3.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f"
|
||||||
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
|
integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==
|
||||||
|
|
||||||
psl@^1.1.33:
|
psl@^1.1.33:
|
||||||
version "1.9.0"
|
version "1.9.0"
|
||||||
|
@ -4039,16 +4039,7 @@ std-env@^3.7.0:
|
||||||
resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.7.0.tgz#c9f7386ced6ecf13360b6c6c55b8aaa4ef7481d2"
|
resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.7.0.tgz#c9f7386ced6ecf13360b6c6c55b8aaa4ef7481d2"
|
||||||
integrity sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==
|
integrity sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==
|
||||||
|
|
||||||
"string-width-cjs@npm:string-width@^4.2.0":
|
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
|
||||||
version "4.2.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
|
||||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
|
||||||
dependencies:
|
|
||||||
emoji-regex "^8.0.0"
|
|
||||||
is-fullwidth-code-point "^3.0.0"
|
|
||||||
strip-ansi "^6.0.1"
|
|
||||||
|
|
||||||
string-width@^4.1.0:
|
|
||||||
version "4.2.3"
|
version "4.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||||
|
@ -4094,14 +4085,7 @@ string.prototype.trimstart@^1.0.8:
|
||||||
define-properties "^1.2.1"
|
define-properties "^1.2.1"
|
||||||
es-object-atoms "^1.0.0"
|
es-object-atoms "^1.0.0"
|
||||||
|
|
||||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||||
version "6.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
|
||||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
|
||||||
dependencies:
|
|
||||||
ansi-regex "^5.0.1"
|
|
||||||
|
|
||||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
|
||||||
version "6.0.1"
|
version "6.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||||
|
|
Loading…
Reference in a new issue