prettier-plugin-embed 0.2.0 → 0.2.2

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.bak CHANGED
@@ -109,7 +109,7 @@ Click Here
109
109
  | :-----------------------: | :-----: | ----------------------------------------------------------------------------------------------------------------------------------------------- |
110
110
  | `embeddedNoopIdentifiers` | `[]` | Tag or comment identifiers that prevent their subsequent template literals from being identified as embedded languages and from being formatted |
111
111
 
112
- This doesn't require other plugins and can override the native embedded language formatting for ECMAScript code. It serves as a way to turn off embedded language formatting for specific language identifiers.
112
+ This doesn't require other plugins and can override the native embedded language formatting. It serves as a way to turn off embedded language formatting for specific language identifiers.
113
113
 
114
114
  #### CSS
115
115
 
@@ -130,9 +130,9 @@ Formatting embedded ECMAScript code doesn't require other plugins and uses the p
130
130
 
131
131
  #### HTML
132
132
 
133
- | Option | Default | Description |
134
- | :-----------------------: | :---------------------------------------: | --------------------------------------------------------------------------------------------------------------------- |
135
- | `embeddedHtmlIdentifiers` | [`[...]`](./src/embedded/html/options.ts) | Tag or comment identifiers that make their subsequent template literals be identified as ECMAScript (JavaScript) code |
133
+ | Option | Default | Description |
134
+ | :-----------------------: | :---------------------------------------: | -------------------------------------------------------------------------------------------------- |
135
+ | `embeddedHtmlIdentifiers` | [`[...]`](./src/embedded/html/options.ts) | Tag or comment identifiers that make their subsequent template literals be identified as HTML code |
136
136
 
137
137
  Formatting embedded HTML code doesn't require other plugins and uses the parsers and printers provided by Prettier natively. This can override the native embedded language formatting for HTML code.
138
138
 
@@ -168,7 +168,7 @@ Formatting embedded Ruby code requires [`@prettier/plugin-ruby`](https://github.
168
168
 
169
169
  Formatting embedded SQL code requires [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql#readme) to be loaded as well. And [options](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options) supported by `prettier-plugin-sql` can therefore be used to further control the formatting behavior.
170
170
 
171
- Note that `prettier-plugin-sql` supports many different SQL dialects, and there's a one-to-one correspondence between the dialects and the identifiers. To support custom identifiers for a specific dialect, put the identifiers after that specific dialect in the identifier list in option `embeddedSql`.
171
+ Note that `prettier-plugin-sql` supports many different SQL dialects, and there's a one-to-one correspondence between the dialects and the identifiers. To support custom identifiers for a specific dialect, put the identifiers after that specific dialect in the identifier list in option `embeddedSqlIdentifiers`.
172
172
 
173
173
  #### TS
174
174
 
package/README.md CHANGED
@@ -108,7 +108,7 @@ Click Here
108
108
  | :-----------------------: | :-----: | ----------------------------------------------------------------------------------------------------------------------------------------------- |
109
109
  | `embeddedNoopIdentifiers` | `[]` | Tag or comment identifiers that prevent their subsequent template literals from being identified as embedded languages and from being formatted |
110
110
 
111
- This doesn't require other plugins and can override the native embedded language formatting for ECMAScript code. It serves as a way to turn off embedded language formatting for specific language identifiers.
111
+ This doesn't require other plugins and can override the native embedded language formatting. It serves as a way to turn off embedded language formatting for specific language identifiers.
112
112
 
113
113
  #### CSS
114
114
 
@@ -129,9 +129,9 @@ Formatting embedded ECMAScript code doesn't require other plugins and uses the p
129
129
 
130
130
  #### HTML
131
131
 
132
- | Option | Default | Description |
133
- | :-----------------------: | :---------------------------------------: | --------------------------------------------------------------------------------------------------------------------- |
134
- | `embeddedHtmlIdentifiers` | [`[...]`](./src/embedded/html/options.ts) | Tag or comment identifiers that make their subsequent template literals be identified as ECMAScript (JavaScript) code |
132
+ | Option | Default | Description |
133
+ | :-----------------------: | :---------------------------------------: | -------------------------------------------------------------------------------------------------- |
134
+ | `embeddedHtmlIdentifiers` | [`[...]`](./src/embedded/html/options.ts) | Tag or comment identifiers that make their subsequent template literals be identified as HTML code |
135
135
 
136
136
  Formatting embedded HTML code doesn't require other plugins and uses the parsers and printers provided by Prettier natively. This can override the native embedded language formatting for HTML code.
137
137
 
@@ -167,7 +167,7 @@ Formatting embedded Ruby code requires [`@prettier/plugin-ruby`](https://github.
167
167
 
168
168
  Formatting embedded SQL code requires [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql#readme) to be loaded as well. And [options](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options) supported by `prettier-plugin-sql` can therefore be used to further control the formatting behavior.
169
169
 
170
- Note that `prettier-plugin-sql` supports many different SQL dialects, and there's a one-to-one correspondence between the dialects and the identifiers. To support custom identifiers for a specific dialect, put the identifiers after that specific dialect in the identifier list in option `embeddedSql`.
170
+ Note that `prettier-plugin-sql` supports many different SQL dialects, and there's a one-to-one correspondence between the dialects and the identifiers. To support custom identifiers for a specific dialect, put the identifiers after that specific dialect in the identifier list in option `embeddedSqlIdentifiers`.
171
171
 
172
172
  #### TS
173
173
 
@@ -3,7 +3,7 @@ import { type AutocompleteStringList, type StringListToInterfaceKey } from "../u
3
3
  * - https://github.com/microsoft/vscode/blob/de0121cf0e05d1673903551b6dbb2871556bfae9/extensions/javascript/package.json#L37
4
4
  * - https://github.com/github-linguist/linguist/blob/7ca3799b8b5f1acde1dd7a8dfb7ae849d3dfb4cd/lib/linguist/languages.yml#L3314
5
5
  */
6
- declare const DEFAULT_IDENTIFIERS: readonly ["js", "es", "es6", "mjs", "cjs", "pac", "javascript"];
6
+ declare const DEFAULT_IDENTIFIERS: readonly ["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"];
7
7
  type Identifiers = AutocompleteStringList<typeof DEFAULT_IDENTIFIERS>;
8
8
  type DefaultIdentifiersHolder = StringListToInterfaceKey<typeof DEFAULT_IDENTIFIERS>;
9
9
  declare const DEFAULT_ES_PARSERS: readonly ["babel", "babel-flow", "acorn", "espree", "flow", "meriyah"];
@@ -18,7 +18,7 @@ export declare const options: {
18
18
  type: "string";
19
19
  array: true;
20
20
  default: {
21
- value: ("js" | "es" | "es6" | "mjs" | "cjs" | "pac" | "javascript")[];
21
+ value: ("js" | "jsx" | "es" | "es6" | "mjs" | "cjs" | "pac" | "javascript")[];
22
22
  }[];
23
23
  description: string;
24
24
  };
@@ -4,9 +4,9 @@ export declare const embeddedParsers: EmbeddedParsers;
4
4
  export declare const embeddedEmbedders: EmbeddedEmbedders;
5
5
  export declare const embeddedOptions: EmbeddedOptions;
6
6
  import * as __glob__0_0 from "./css/index.js";
7
- import * as __glob__0_1 from "./es/index.js";
8
- import * as __glob__0_2 from "./glsl/index.js";
9
- import * as __glob__0_3 from "./html/index.js";
7
+ import * as __glob__0_1 from "./html/index.js";
8
+ import * as __glob__0_2 from "./es/index.js";
9
+ import * as __glob__0_3 from "./glsl/index.js";
10
10
  import * as __glob__0_4 from "./markdown/index.js";
11
11
  import * as __glob__0_5 from "./noop/index.js";
12
12
  import * as __glob__0_6 from "./php/index.js";
@@ -3,7 +3,7 @@ import { type AutocompleteStringList, type StringListToInterfaceKey } from "../u
3
3
  * - https://github.com/microsoft/vscode/blob/de0121cf0e05d1673903551b6dbb2871556bfae9/extensions/typescript-basics/package.json#L24
4
4
  * - https://github.com/github-linguist/linguist/blob/7ca3799b8b5f1acde1dd7a8dfb7ae849d3dfb4cd/lib/linguist/languages.yml#L7158
5
5
  */
6
- declare const DEFAULT_IDENTIFIERS: readonly ["ts", "cts", "mts", "typescript"];
6
+ declare const DEFAULT_IDENTIFIERS: readonly ["ts", "tsx", "cts", "mts", "typescript"];
7
7
  type Identifiers = AutocompleteStringList<typeof DEFAULT_IDENTIFIERS>;
8
8
  type DefaultIdentifiersHolder = StringListToInterfaceKey<typeof DEFAULT_IDENTIFIERS>;
9
9
  declare const DEFAULT_TS_PARSERS: readonly ["typescript", "babel-ts"];
@@ -18,7 +18,7 @@ export declare const options: {
18
18
  type: "string";
19
19
  array: true;
20
20
  default: {
21
- value: ("ts" | "cts" | "mts" | "typescript")[];
21
+ value: ("ts" | "tsx" | "cts" | "mts" | "typescript")[];
22
22
  }[];
23
23
  description: string;
24
24
  };
package/dist/index.js CHANGED
@@ -352,6 +352,7 @@ const { line: pe, group: B, indent: he, softline: ge } = k, Et = async (e, n, r,
352
352
  }
353
353
  }, Lt = [
354
354
  "js",
355
+ "jsx",
355
356
  "es",
356
357
  "es6",
357
358
  "mjs",
@@ -898,7 +899,10 @@ const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
898
899
  const { node: u } = r, { createPlaceholder: $, placeholderRegex: S } = j(), i = u.quasis.map(
899
900
  (a, c, { length: I }) => c === I - 1 ? a.value.cooked : a.value.cooked + $(c)
900
901
  ).join(""), _ = ((o = i.match(/^\s+/)) == null ? void 0 : o[0]) ?? "", b = ((h = i.match(/\s+$/)) == null ? void 0 : h[0]) ?? "", v = M(r, n), L = await e(i, {
901
- parser: t.embeddedTsParser ?? "typescript"
902
+ parser: t.embeddedTsParser ?? "typescript",
903
+ // set filepath to undefined to enable jsx auto detection:
904
+ // https://github.com/prettier/prettier/blob/427a84d24203e2d54160cde153a1e6a6390fe65a/src/language-js/parse/typescript.js#L49-L53
905
+ filepath: void 0
902
906
  }), m = q(
903
907
  L,
904
908
  S,
@@ -922,7 +926,7 @@ const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
922
926
  } catch (u) {
923
927
  throw console.error(u), u;
924
928
  }
925
- }, xn = ["ts", "cts", "mts", "typescript"], $n = "embeddedTsParser", vn = R(Ke), wn = {
929
+ }, xn = ["ts", "tsx", "cts", "mts", "typescript"], $n = "embeddedTsParser", vn = R(Ke), wn = {
926
930
  [vn]: {
927
931
  category: "Global",
928
932
  type: "string",
package/dist/options.d.ts CHANGED
@@ -64,7 +64,7 @@ export declare const options: {
64
64
  type: "string";
65
65
  array: true;
66
66
  default: {
67
- value: ("js" | "es" | "es6" | "mjs" | "cjs" | "pac" | "javascript")[];
67
+ value: ("js" | "jsx" | "es" | "es6" | "mjs" | "cjs" | "pac" | "javascript")[];
68
68
  }[];
69
69
  description: string;
70
70
  };
@@ -141,7 +141,7 @@ export declare const options: {
141
141
  type: "string";
142
142
  array: true;
143
143
  default: {
144
- value: ("ts" | "cts" | "mts" | "typescript")[];
144
+ value: ("ts" | "tsx" | "cts" | "mts" | "typescript")[];
145
145
  }[];
146
146
  description: string;
147
147
  };
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.2.0",
5
+ "version": "0.2.2",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "./dist"
@@ -61,17 +61,17 @@
61
61
  "postncu": "npm i"
62
62
  },
63
63
  "devDependencies": {
64
- "@commitlint/cli": "^18.0.0",
65
- "@commitlint/config-conventional": "^18.0.0",
64
+ "@commitlint/cli": "^18.1.0",
65
+ "@commitlint/config-conventional": "^18.1.0",
66
66
  "@semantic-release/git": "^10.0.1",
67
67
  "@types/estree": "^1.0.3",
68
- "@typescript-eslint/eslint-plugin": "^6.8.0",
69
- "@typescript-eslint/parser": "^6.8.0",
68
+ "@typescript-eslint/eslint-plugin": "^6.9.0",
69
+ "@typescript-eslint/parser": "^6.9.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.51.0",
74
+ "eslint": "^8.52.0",
75
75
  "fast-glob": "^3.3.1",
76
76
  "npm-check-updates": "^16.14.6",
77
77
  "playwright": "^1.39.0",