prettier-plugin-embed 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +297 -109
  2. package/dist/embedded/css/options.d.ts +2 -8
  3. package/dist/embedded/es/options.d.ts +2 -8
  4. package/dist/embedded/glsl/options.d.ts +2 -8
  5. package/dist/embedded/graphql/options.d.ts +2 -8
  6. package/dist/embedded/html/options.d.ts +2 -8
  7. package/dist/embedded/index.d.ts +1 -1
  8. package/dist/embedded/ini/options.d.ts +2 -9
  9. package/dist/embedded/ini/plugin-ini-types.d.ts +3 -0
  10. package/dist/embedded/ini/plugin-ini.d.ts +6 -0
  11. package/dist/embedded/java/options.d.ts +2 -13
  12. package/dist/embedded/java/plugin-java-types.d.ts +7 -0
  13. package/dist/embedded/java/plugin-java.d.ts +6 -0
  14. package/dist/embedded/json/options.d.ts +2 -8
  15. package/dist/embedded/jsonata/options.d.ts +2 -8
  16. package/dist/embedded/latex/options.d.ts +2 -8
  17. package/dist/embedded/markdown/embedder.d.ts +1 -1
  18. package/dist/embedded/markdown/options.d.ts +2 -9
  19. package/dist/embedded/markdown/plugin-markdown-types.d.ts +3 -0
  20. package/dist/embedded/markdown/plugin-markdown.d.ts +6 -0
  21. package/dist/embedded/nginx/options.d.ts +3 -10
  22. package/dist/embedded/nginx/plugin-nginx-types.d.ts +4 -0
  23. package/dist/embedded/nginx/plugin-nginx.d.ts +6 -0
  24. package/dist/embedded/noop/options.d.ts +2 -2
  25. package/dist/embedded/pegjs/options.d.ts +2 -11
  26. package/dist/embedded/pegjs/plugin-pegjs-types.d.ts +5 -0
  27. package/dist/embedded/pegjs/plugin-pegjs.d.ts +6 -0
  28. package/dist/embedded/php/options.d.ts +2 -11
  29. package/dist/embedded/php/plugin-php-types.d.ts +5 -0
  30. package/dist/embedded/php/plugin-php.d.ts +6 -0
  31. package/dist/embedded/prisma/options.d.ts +2 -8
  32. package/dist/embedded/properties/options.d.ts +2 -10
  33. package/dist/embedded/properties/plugin-properties-types.d.ts +4 -0
  34. package/dist/embedded/properties/plugin-properties.d.ts +6 -0
  35. package/dist/embedded/pug/options.d.ts +2 -35
  36. package/dist/embedded/pug/plugin-pug-types.d.ts +29 -0
  37. package/dist/embedded/pug/plugin-pug.d.ts +6 -0
  38. package/dist/embedded/register.d.ts +7 -7
  39. package/dist/embedded/ruby/options.d.ts +3 -16
  40. package/dist/embedded/ruby/plugin-ruby-types.d.ts +6 -0
  41. package/dist/embedded/ruby/plugin-ruby.d.ts +6 -0
  42. package/dist/embedded/sh/options.d.ts +3 -10
  43. package/dist/embedded/sh/plugin-sh-types.d.ts +4 -0
  44. package/dist/embedded/sh/plugin-sh.d.ts +6 -0
  45. package/dist/embedded/sql/options.d.ts +4 -13
  46. package/dist/embedded/sql/plugin-sql-cst-types.d.ts +4 -0
  47. package/dist/embedded/sql/plugin-sql-cst.d.ts +6 -0
  48. package/dist/embedded/sql/plugin-sql-types.d.ts +4 -0
  49. package/dist/embedded/sql/plugin-sql.d.ts +6 -0
  50. package/dist/embedded/toml/options.d.ts +3 -10
  51. package/dist/embedded/toml/plugin-toml-types.d.ts +4 -0
  52. package/dist/embedded/toml/plugin-toml.d.ts +6 -0
  53. package/dist/embedded/ts/options.d.ts +2 -8
  54. package/dist/embedded/types.d.ts +1 -1
  55. package/dist/embedded/utils.d.ts +5 -2
  56. package/dist/embedded/xml/options.d.ts +2 -12
  57. package/dist/embedded/xml/parser.d.ts +1 -0
  58. package/dist/embedded/xml/plugin-xml-types.d.ts +6 -0
  59. package/dist/embedded/xml/plugin-xml.d.ts +6 -0
  60. package/dist/embedded/yaml/options.d.ts +2 -8
  61. package/dist/index.d.ts +7 -2
  62. package/dist/index.js +707 -677
  63. package/dist/options.d.ts +14 -18
  64. package/dist/plugin-embed.d.ts +6 -0
  65. package/dist/types.d.ts +5 -24
  66. package/dist/utils.d.ts +1 -4
  67. package/package.json +37 -9
package/dist/options.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type AutocompleteStringList, type EmbeddedDefaultIdentifier, type PrettierPluginEmbedOptions } from "./embedded/index.js";
2
- type EmbeddedIdentifiers = AutocompleteStringList<EmbeddedDefaultIdentifier[]>;
1
+ import { type AutocompleteStringList, type EmbeddedDefaultIdentifier } from "./embedded/index.js";
2
+ type EmbeddedIdentifiers = AutocompleteStringList<EmbeddedDefaultIdentifier>;
3
3
  declare const NO_EMBEDDED_IDENTIFICATION_BY_COMMENT = "noEmbeddedIdentificationByComment";
4
4
  declare const NO_EMBEDDED_IDENTIFICATION_BY_TAG = "noEmbeddedIdentificationByTag";
5
5
  declare const PRESERVE_EMBEDDED_EXTERIOR_WHITESPACES = "preserveEmbeddedExteriorWhitespaces";
@@ -216,6 +216,15 @@ export declare const options: {
216
216
  }];
217
217
  readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.";
218
218
  };
219
+ readonly embeddedPegjsIdentifiers: {
220
+ readonly category: "Embed";
221
+ readonly type: "string";
222
+ readonly array: true;
223
+ readonly default: [{
224
+ readonly value: ["pegjs", "peggy", "peg"];
225
+ }];
226
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.";
227
+ };
219
228
  readonly embeddedTsIdentifiers: {
220
229
  readonly category: "Embed";
221
230
  readonly type: "string";
@@ -235,15 +244,6 @@ export declare const options: {
235
244
  description: string;
236
245
  }[];
237
246
  };
238
- readonly embeddedPegjsIdentifiers: {
239
- readonly category: "Embed";
240
- readonly type: "string";
241
- readonly array: true;
242
- readonly default: [{
243
- readonly value: ["pegjs", "peggy", "peg"];
244
- }];
245
- readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.";
246
- };
247
247
  readonly embeddedPhpIdentifiers: {
248
248
  readonly category: "Embed";
249
249
  readonly type: "string";
@@ -333,7 +333,7 @@ export declare const options: {
333
333
  default: "sqlite";
334
334
  description: string;
335
335
  choices: {
336
- value: "sqlite" | "bigquery" | "mysql" | "mariadb" | "postgresql";
336
+ value: "bigquery" | "mariadb" | "mysql" | "postgresql" | "sqlite";
337
337
  description: string;
338
338
  }[];
339
339
  };
@@ -374,7 +374,7 @@ export declare const options: {
374
374
  readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded YAML language.";
375
375
  };
376
376
  };
377
- export interface PrettierPluginGlobalOptions {
377
+ export interface PluginEmbedLanguageAgnosticOptions {
378
378
  [NO_EMBEDDED_IDENTIFICATION_BY_COMMENT]?: EmbeddedIdentifiers;
379
379
  [NO_EMBEDDED_IDENTIFICATION_BY_TAG]?: EmbeddedIdentifiers;
380
380
  [PRESERVE_EMBEDDED_EXTERIOR_WHITESPACES]?: EmbeddedIdentifiers;
@@ -382,11 +382,7 @@ export interface PrettierPluginGlobalOptions {
382
382
  [EMBEDDED_OVERRIDES]?: string;
383
383
  }
384
384
  declare module "./embedded/types.js" {
385
- interface PrettierPluginEmbedOptions extends PrettierPluginGlobalOptions {
386
- }
387
- }
388
- declare module "prettier" {
389
- interface Options extends PrettierPluginEmbedOptions {
385
+ interface PluginEmbedOptions extends PluginEmbedLanguageAgnosticOptions {
390
386
  }
391
387
  }
392
388
  export {};
@@ -0,0 +1,6 @@
1
+ import "prettier";
2
+ import type { PluginEmbedOptions } from "./embedded/index.js";
3
+
4
+ declare module "prettier" {
5
+ interface Options extends PluginEmbedOptions {}
6
+ }
package/dist/types.d.ts CHANGED
@@ -1,26 +1,8 @@
1
1
  import type { TemplateLiteral } from "estree";
2
2
  import type { AstPath, Doc, Options } from "prettier";
3
- import { type AutocompleteStringList, type EmbeddedDefaultIdentifier, type EmbeddedLanguage, type PrettierPluginEmbedOptions, makeIdentifiersOptionName } from "./embedded/index.js";
4
- import type { PrettierPluginGlobalOptions } from "./options.js";
5
- import { RemoveIndex } from "./utils.js";
6
- declare module "estree" {
7
- interface Comment {
8
- leading: boolean;
9
- trailing: boolean;
10
- nodeDescription: string;
11
- }
12
- interface BaseNode {
13
- comments?: Comment[];
14
- }
15
- interface File extends BaseNode {
16
- type: "File";
17
- sourceType: "script" | "module";
18
- program: Program;
19
- }
20
- interface NodeMap {
21
- File: File;
22
- }
23
- }
3
+ import type { OmitIndexSignature } from "type-fest";
4
+ import type { AutocompleteStringList, EmbeddedDefaultIdentifier, EmbeddedLanguage, PluginEmbedOptions, makeIdentifiersOptionName } from "./embedded/index.js";
5
+ import type { PluginEmbedLanguageAgnosticOptions } from "./options.js";
24
6
  export type InternalPrintFun = (selector?: string | number | (string | number)[] | AstPath<TemplateLiteral>) => Doc;
25
7
  export interface EmbedderPayload {
26
8
  identifier: string;
@@ -29,7 +11,6 @@ export interface EmbedderPayload {
29
11
  }
30
12
  export type Embedder<T extends Options = Options> = (textToDoc: (text: string, options: T) => Promise<Doc>, print: InternalPrintFun, path: AstPath<TemplateLiteral>, options: T, embedderPayload: EmbedderPayload) => Promise<Doc>;
31
13
  export interface EmbeddedOverride {
32
- identifiers: AutocompleteStringList<EmbeddedDefaultIdentifier[]>;
33
- options: Omit<Omit<RemoveIndex<Options>, keyof PrettierPluginEmbedOptions> & Omit<PrettierPluginEmbedOptions, keyof PrettierPluginGlobalOptions | ReturnType<typeof makeIdentifiersOptionName<EmbeddedLanguage>>>, "printWidth" | "endOfLine" | "useTabs" | "tabWidth" | "parser" | "filepath" | "embeddedLanguageFormatting" | `__${string}`>;
14
+ identifiers: AutocompleteStringList<EmbeddedDefaultIdentifier>;
15
+ options: Omit<Omit<OmitIndexSignature<Options>, keyof PluginEmbedOptions> & Omit<PluginEmbedOptions, keyof PluginEmbedLanguageAgnosticOptions | ReturnType<typeof makeIdentifiersOptionName<EmbeddedLanguage>>>, "printWidth" | "endOfLine" | "useTabs" | "tabWidth" | "parser" | "filepath" | "embeddedLanguageFormatting" | `__${string}`>;
34
16
  }
35
- export type EmbeddedOverrides = EmbeddedOverride[];
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,5 @@
1
1
  import type { Node } from "estree";
2
2
  import { type AstPath, type Options } from "prettier";
3
- export declare const resolveEmbeddedOverrideOptions: (embeddedOverridesString: string | undefined, identifier: string, sourceFilePath?: string) => Promise<Omit<Omit<RemoveIndex<Options>, keyof import("./index.js").PrettierPluginEmbedOptions> & Omit<import("./index.js").PrettierPluginEmbedOptions, "embeddedNoopIdentifiers" | "embeddedCssIdentifiers" | "embeddedEsIdentifiers" | "embeddedGlslIdentifiers" | "embeddedGraphqlIdentifiers" | "embeddedHtmlIdentifiers" | "embeddedIniIdentifiers" | "embeddedJavaIdentifiers" | "embeddedJsonIdentifiers" | "embeddedJsonataIdentifiers" | "embeddedLatexIdentifiers" | "embeddedMarkdownIdentifiers" | "embeddedNginxIdentifiers" | "embeddedTsIdentifiers" | "embeddedPegjsIdentifiers" | "embeddedPhpIdentifiers" | "embeddedPrismaIdentifiers" | "embeddedPropertiesIdentifiers" | "embeddedPugIdentifiers" | "embeddedRubyIdentifiers" | "embeddedShIdentifiers" | "embeddedSqlIdentifiers" | "embeddedTomlIdentifiers" | "embeddedXmlIdentifiers" | "embeddedYamlIdentifiers" | keyof import("./options.js").PrettierPluginGlobalOptions>, "parser" | "filepath" | "endOfLine" | "embeddedLanguageFormatting" | "printWidth" | "tabWidth" | "useTabs" | `__${string}`> | undefined>;
3
+ export declare const resolveEmbeddedOverrideOptions: (embeddedOverridesString: string | undefined, identifier: string, sourceFilePath?: string) => Promise<Omit<Omit<import("type-fest").OmitIndexSignature<Options>, keyof import("./index.js").PluginEmbedOptions> & Omit<import("./index.js").PluginEmbedOptions, "embeddedNoopIdentifiers" | "embeddedCssIdentifiers" | "embeddedEsIdentifiers" | "embeddedGlslIdentifiers" | "embeddedGraphqlIdentifiers" | "embeddedHtmlIdentifiers" | "embeddedIniIdentifiers" | "embeddedJavaIdentifiers" | "embeddedJsonIdentifiers" | "embeddedJsonataIdentifiers" | "embeddedLatexIdentifiers" | "embeddedMarkdownIdentifiers" | "embeddedNginxIdentifiers" | "embeddedPegjsIdentifiers" | "embeddedTsIdentifiers" | "embeddedPhpIdentifiers" | "embeddedPrismaIdentifiers" | "embeddedPropertiesIdentifiers" | "embeddedPugIdentifiers" | "embeddedRubyIdentifiers" | "embeddedShIdentifiers" | "embeddedSqlIdentifiers" | "embeddedTomlIdentifiers" | "embeddedXmlIdentifiers" | "embeddedYamlIdentifiers" | keyof import("./options.js").PluginEmbedLanguageAgnosticOptions>, "parser" | "filepath" | "endOfLine" | "embeddedLanguageFormatting" | "printWidth" | "tabWidth" | "useTabs" | `__${string}`> | undefined>;
4
4
  export declare function getIdentifierFromComment({ node, parent }: AstPath<Node>, comments: string[], options: Options): string | undefined;
5
5
  export declare function getIdentifierFromTag({ node, parent }: AstPath<Node>, tags: string[], options: Options): string | undefined;
6
- export type RemoveIndex<T> = {
7
- [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K];
8
- };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "prettier-plugin-embed",
3
3
  "description": "A configurable Prettier plugin to format embedded languages in js/ts files.",
4
4
  "private": false,
5
- "version": "0.4.8",
5
+ "version": "0.4.10",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "./dist"
@@ -13,7 +13,23 @@
13
13
  ".": {
14
14
  "import": "./dist/index.js",
15
15
  "default": "./dist/index.js"
16
- }
16
+ },
17
+ "./plugin-embed": {
18
+ "types": "./dist/plugin-embed.d.ts"
19
+ },
20
+ "./embedded/*": {
21
+ "types": "./dist/embedded/*.d.ts"
22
+ },
23
+ "./embedded/index": null,
24
+ "./embedded/register": null,
25
+ "./embedded/types": null,
26
+ "./embedded/utils": null,
27
+ "./embedded/*/index": null,
28
+ "./embedded/*/language": null,
29
+ "./embedded/*/options": null,
30
+ "./embedded/*/embedder": null,
31
+ "./embedded/*/parser": null,
32
+ "./embedded/*/printer": null
17
33
  },
18
34
  "repository": {
19
35
  "type": "git",
@@ -42,7 +58,8 @@
42
58
  "access": "public"
43
59
  },
44
60
  "scripts": {
45
- "prepare": "husky install",
61
+ "prepare": "patch-package",
62
+ "update-hooks": "simple-git-hooks",
46
63
  "bump": "bumpp",
47
64
  "dev": "vite",
48
65
  "lint": "biome lint .",
@@ -52,7 +69,12 @@
52
69
  "prebuild": "npm run check && npm run type-check",
53
70
  "build": "vite build",
54
71
  "add-glob-import-types": "tsx ./scripts/add-glob-import-types.ts",
55
- "postbuild": "tsc --project ./tsconfig.production.json && npm run add-glob-import-types",
72
+ "nocheck-chevrotain-types": "tsx ./scripts/nocheck-chevrotain-types.ts",
73
+ "copy": "copy-files-from-to",
74
+ "postbuild": "tsc --project ./tsconfig.production.json && conc \"npm:add-glob-import-types\" \"npm:nocheck-chevrotain-types\" \"npm:copy\"",
75
+ "prebuild:ci": "npm run type-check",
76
+ "build:ci": "vite build",
77
+ "postbuild:ci": "npm run postbuild",
56
78
  "test": "vitest",
57
79
  "test:ui": "vitest --ui",
58
80
  "preview": "vite preview",
@@ -61,10 +83,11 @@
61
83
  "prepublishOnly": "npm run build && npm run process-readme",
62
84
  "postpublish": "npm run restore-readme",
63
85
  "ncu": "npx ncu",
64
- "postncu": "npm i"
86
+ "postncu": "npm i",
87
+ "bump-biome": "npm i @biomejs/biome@latest --save-exact"
65
88
  },
66
89
  "devDependencies": {
67
- "@biomejs/biome": "1.5.2",
90
+ "@biomejs/biome": "1.5.3",
68
91
  "@commitlint/cli": "^18.4.4",
69
92
  "@commitlint/config-conventional": "^18.4.4",
70
93
  "@prettier/plugin-php": "^0.22.1",
@@ -72,18 +95,19 @@
72
95
  "@prettier/plugin-ruby": "^4.0.4",
73
96
  "@prettier/plugin-xml": "^3.2.2",
74
97
  "@stedi/prettier-plugin-jsonata": "^2.1.1",
75
- "@types/estree": "^1.0.5",
76
98
  "@types/node": "^20.11.5",
77
99
  "@vitest/coverage-istanbul": "^1.2.1",
78
100
  "@vitest/ui": "^1.2.1",
79
101
  "@xml-tools/parser": "^1.0.11",
80
102
  "bumpp": "^9.3.0",
81
103
  "chevrotain": "7.1.1",
104
+ "concurrently": "^8.2.2",
105
+ "copy-files-from-to": "^3.9.1",
82
106
  "esbuild": "^0.19.11",
83
107
  "fast-glob": "^3.3.2",
84
- "husky": "^8.0.3",
85
108
  "lint-staged": "^15.2.0",
86
109
  "npm-check-updates": "^16.14.12",
110
+ "patch-package": "^8.0.0",
87
111
  "prettier": "^3.2.4",
88
112
  "prettier-plugin-glsl": "^0.1.3",
89
113
  "prettier-plugin-ini": "^1.1.0",
@@ -99,14 +123,18 @@
99
123
  "prettier-plugin-sql": "^0.18.0",
100
124
  "prettier-plugin-sql-cst": "^0.10.2",
101
125
  "prettier-plugin-toml": "^2.0.1",
126
+ "simple-git-hooks": "^2.9.0",
102
127
  "tsx": "^4.7.0",
103
128
  "typescript": "^5.3.3",
104
129
  "vite": "^5.0.12",
105
130
  "vitest": "^1.2.1"
106
131
  },
107
132
  "dependencies": {
133
+ "@types/estree": "^1.0.5",
108
134
  "dedent": "^1.5.1",
109
135
  "micro-memoize": "^4.1.2",
110
- "package-up": "^5.0.0"
136
+ "package-up": "^5.0.0",
137
+ "tiny-jsonc": "^1.0.1",
138
+ "type-fest": "^4.9.0"
111
139
  }
112
140
  }