prettier-plugin-embed 0.2.5 → 0.3.0-rc.1
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.
- package/README.md +41 -9
- package/dist/embedded/css/embedder.d.ts +1 -1
- package/dist/embedded/es/embedder.d.ts +1 -1
- package/dist/embedded/html/embedder.d.ts +1 -1
- package/dist/embedded/index.d.ts +1 -1
- package/dist/embedded/noop/options.d.ts +1 -1
- package/dist/embedded/register.d.ts +7 -7
- package/dist/embedded/sql/options.d.ts +4 -4
- package/dist/embedded/ts/embedder.d.ts +1 -1
- package/dist/embedded/types.d.ts +1 -5
- package/dist/embedded/utils.d.ts +3 -3
- package/dist/embedded/xml/embedder.d.ts +1 -1
- package/dist/embedded/xml/index.d.ts +1 -1
- package/dist/embedded/xml/parser.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +959 -886
- package/dist/options.d.ts +18 -7
- package/dist/types.d.ts +15 -3
- package/dist/utils.d.ts +5 -0
- package/package.json +23 -18
package/dist/options.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type AutocompleteStringList, type EmbeddedDefaultIdentifier, type PrettierPluginEmbedOptions } from "./embedded/index.js";
|
|
2
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";
|
|
6
6
|
declare const NO_EMBEDDED_MULTI_LINE_INDENTATION = "noEmbeddedMultiLineIndentation";
|
|
7
|
+
declare const EMBEDDED_OVERRIDES = "embeddedOverrides";
|
|
7
8
|
export declare const options: {
|
|
8
9
|
noEmbeddedIdentificationByComment: {
|
|
9
10
|
category: "Global";
|
|
@@ -41,6 +42,13 @@ export declare const options: {
|
|
|
41
42
|
}[];
|
|
42
43
|
description: string;
|
|
43
44
|
};
|
|
45
|
+
embeddedOverrides: {
|
|
46
|
+
category: "Global";
|
|
47
|
+
type: "string";
|
|
48
|
+
array: false;
|
|
49
|
+
default: undefined;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
44
52
|
embeddedNoopIdentifiers: {
|
|
45
53
|
category: "Global";
|
|
46
54
|
type: "string";
|
|
@@ -132,7 +140,7 @@ export declare const options: {
|
|
|
132
140
|
type: "string";
|
|
133
141
|
array: true;
|
|
134
142
|
default: {
|
|
135
|
-
value:
|
|
143
|
+
value: string[];
|
|
136
144
|
}[];
|
|
137
145
|
description: string;
|
|
138
146
|
};
|
|
@@ -171,12 +179,15 @@ export declare const options: {
|
|
|
171
179
|
description: string;
|
|
172
180
|
};
|
|
173
181
|
};
|
|
182
|
+
export interface PrettierPluginGlobalOptions {
|
|
183
|
+
[NO_EMBEDDED_IDENTIFICATION_BY_COMMENT]?: EmbeddedIdentifiers;
|
|
184
|
+
[NO_EMBEDDED_IDENTIFICATION_BY_TAG]?: EmbeddedIdentifiers;
|
|
185
|
+
[PRESERVE_EMBEDDED_EXTERIOR_WHITESPACES]?: EmbeddedIdentifiers;
|
|
186
|
+
[NO_EMBEDDED_MULTI_LINE_INDENTATION]?: EmbeddedIdentifiers;
|
|
187
|
+
[EMBEDDED_OVERRIDES]?: string;
|
|
188
|
+
}
|
|
174
189
|
declare module "./embedded/types.js" {
|
|
175
|
-
interface PrettierPluginEmbedOptions {
|
|
176
|
-
[NO_EMBEDDED_IDENTIFICATION_BY_COMMENT]?: EmbeddedIdentifiers;
|
|
177
|
-
[NO_EMBEDDED_IDENTIFICATION_BY_TAG]?: EmbeddedIdentifiers;
|
|
178
|
-
[PRESERVE_EMBEDDED_EXTERIOR_WHITESPACES]?: EmbeddedIdentifiers;
|
|
179
|
-
[NO_EMBEDDED_MULTI_LINE_INDENTATION]?: EmbeddedIdentifiers;
|
|
190
|
+
interface PrettierPluginEmbedOptions extends PrettierPluginGlobalOptions {
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
declare module "prettier" {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Comment, Node as EsTreeNode, TemplateLiteral } from "estree";
|
|
2
|
+
import type { AstPath, Doc, Options } from "prettier";
|
|
3
|
+
import { makeIdentifiersOptionName, type AutocompleteStringList, type EmbeddedDefaultIdentifier, type EmbeddedLanguage, type PrettierPluginEmbedOptions } from "./embedded/index.js";
|
|
4
|
+
import type { PrettierPluginGlobalOptions } from "./options.js";
|
|
3
5
|
export type PrettierNode = EsTreeNode & {
|
|
4
6
|
comments?: (Comment & {
|
|
5
7
|
leading: boolean;
|
|
@@ -8,4 +10,14 @@ export type PrettierNode = EsTreeNode & {
|
|
|
8
10
|
})[];
|
|
9
11
|
};
|
|
10
12
|
export type InternalPrintFun = (selector?: string | number | (string | number)[] | AstPath<TemplateLiteral>) => Doc;
|
|
11
|
-
export
|
|
13
|
+
export interface EmbedderPayload {
|
|
14
|
+
identifier: string;
|
|
15
|
+
identifiers: string[];
|
|
16
|
+
embeddedOverrideOptions: EmbeddedOverride["options"] | undefined;
|
|
17
|
+
}
|
|
18
|
+
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>;
|
|
19
|
+
export interface EmbeddedOverride {
|
|
20
|
+
identifiers: AutocompleteStringList<EmbeddedDefaultIdentifier[]>;
|
|
21
|
+
options: Omit<Omit<Options, keyof PrettierPluginEmbedOptions> & Omit<PrettierPluginEmbedOptions, keyof PrettierPluginGlobalOptions | ReturnType<typeof makeIdentifiersOptionName<EmbeddedLanguage>>>, "printWidth" | "endOfLine" | "useTabs" | "tabWidth" | "parser" | "filepath" | "embeddedLanguageFormatting" | `__${string}`>;
|
|
22
|
+
}
|
|
23
|
+
export type EmbeddedOverrides = EmbeddedOverride[];
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type AstPath } from "prettier";
|
|
2
|
+
import type { PrettierNode } from "./types.js";
|
|
3
|
+
export declare const resolveEmbeddedOverrideOptions: (embeddedOverridesString: string | undefined, identifier: string, sourceFilePath?: string) => Promise<Omit<Omit<import("prettier").Options, keyof import("./index.js").PrettierPluginEmbedOptions> & Omit<import("./index.js").PrettierPluginEmbedOptions, "embeddedNoopIdentifiers" | "embeddedCssIdentifiers" | "embeddedEsIdentifiers" | "embeddedGlslIdentifiers" | "embeddedHtmlIdentifiers" | "embeddedMarkdownIdentifiers" | "embeddedPhpIdentifiers" | "embeddedRubyIdentifiers" | "embeddedSqlIdentifiers" | "embeddedTsIdentifiers" | "embeddedXmlIdentifiers" | keyof import("./options.js").PrettierPluginGlobalOptions>, "parser" | "filepath" | "endOfLine" | "embeddedLanguageFormatting" | "printWidth" | "tabWidth" | "useTabs" | `__${string}`> | undefined>;
|
|
4
|
+
export declare function getIdentifierFromComment({ node, parent }: AstPath<PrettierNode>, comments: string[], noIdentificationList: string[]): string | undefined;
|
|
5
|
+
export declare function getIdentifierFromTag({ node, parent }: AstPath<PrettierNode>, tags: string[], noIdentificationList: string[]): string | undefined;
|
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.
|
|
5
|
+
"version": "0.3.0-rc.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"./dist"
|
|
@@ -61,37 +61,42 @@
|
|
|
61
61
|
"postncu": "npm i"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@commitlint/cli": "^18.
|
|
65
|
-
"@commitlint/config-conventional": "^18.
|
|
64
|
+
"@commitlint/cli": "^18.4.3",
|
|
65
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
66
66
|
"@semantic-release/git": "^10.0.1",
|
|
67
|
-
"@types/estree": "^1.0.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
69
|
-
"@typescript-eslint/parser": "^6.
|
|
67
|
+
"@types/estree": "^1.0.5",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
69
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
70
70
|
"@vitest/browser": "^0.34.6",
|
|
71
71
|
"@vitest/coverage-istanbul": "^0.34.6",
|
|
72
72
|
"@vitest/ui": "^0.34.6",
|
|
73
73
|
"code-tag": "^1.1.0",
|
|
74
|
-
"eslint": "^8.
|
|
75
|
-
"fast-glob": "^3.3.
|
|
76
|
-
"npm-check-updates": "^16.14.
|
|
77
|
-
"playwright": "^1.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
74
|
+
"eslint": "^8.54.0",
|
|
75
|
+
"fast-glob": "^3.3.2",
|
|
76
|
+
"npm-check-updates": "^16.14.11",
|
|
77
|
+
"playwright": "^1.40.0",
|
|
78
|
+
"prettier-plugin-organize-imports": "^3.2.4",
|
|
79
|
+
"semantic-release": "^22.0.8",
|
|
80
|
+
"tsx": "^4.2.0",
|
|
81
|
+
"typescript": "^5.3.2",
|
|
82
|
+
"vite": "^5.0.2",
|
|
82
83
|
"vitest": "^0.34.6"
|
|
83
84
|
},
|
|
84
85
|
"peerDependencies": {
|
|
85
|
-
"@prettier/plugin-php": "
|
|
86
|
+
"@prettier/plugin-php": ">=0.20.1 <1",
|
|
86
87
|
"@prettier/plugin-ruby": "^4.0.0",
|
|
87
88
|
"@prettier/plugin-xml": "^3.1.0",
|
|
88
89
|
"@xml-tools/parser": "^1.0.11",
|
|
89
90
|
"chevrotain": "7.1.1",
|
|
90
91
|
"prettier": "^3.0.0",
|
|
91
|
-
"prettier-plugin-glsl": "
|
|
92
|
-
"prettier-plugin-sql": "
|
|
92
|
+
"prettier-plugin-glsl": ">=0.1.2 <1",
|
|
93
|
+
"prettier-plugin-sql": ">=0.15.0 <1"
|
|
93
94
|
},
|
|
94
95
|
"dependencies": {
|
|
95
|
-
"
|
|
96
|
+
"micro-memoize": "^4.1.2",
|
|
97
|
+
"package-up": "^5.0.0"
|
|
98
|
+
},
|
|
99
|
+
"optionalDependencies": {
|
|
100
|
+
"tsx": "^4.2.0"
|
|
96
101
|
}
|
|
97
102
|
}
|