@najemi-software/typed-scss-modules 13.4.0 → 13.5.0

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 CHANGED
@@ -247,7 +247,7 @@ export type IStyles = {
247
247
  - **Default**: `"single"`
248
248
  - **Example**: `typed-scss-modules src --exportType default --quoteType double`
249
249
 
250
- Specify a quote type to match your TypeScript configuration. Only default exports are affected by this command. This example will wrap class names with double quotes ("). If [Prettier](https://prettier.io) is installed and configured in the project, it will be used and is likely to override the effect of this setting.
250
+ Specify a quote type to match your TypeScript configuration. Only default exports are affected by this command. This example will wrap class names with double quotes ("). If a formatter (e.g. Prettier/Oxfmt) is installed and configured in the project, it will be used and is likely to override the effect of this setting.
251
251
 
252
252
  ### `--updateStaleOnly` (`-u`)
253
253
 
@@ -47,9 +47,7 @@ export const classNamesToTypeDefinitions = async (options) => {
47
47
  break;
48
48
  }
49
49
  if (lines.length) {
50
- const typeDefinition = lines.join(`${os.EOL}`) + `${os.EOL}`;
51
- // return await attemptPrettier(options.file, typeDefinition); // ignore prettier (slows down)
52
- return typeDefinition;
50
+ return lines.join(`${os.EOL}`) + `${os.EOL}`;
53
51
  }
54
52
  else {
55
53
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@najemi-software/typed-scss-modules",
3
- "version": "13.4.0",
3
+ "version": "13.5.0",
4
4
  "private": false,
5
5
  "description": "TypeScript type definition generator for SCSS CSS Modules",
6
6
  "keywords": [
@@ -1 +0,0 @@
1
- export declare function canResolvePrettier(): boolean;
@@ -1,12 +0,0 @@
1
- // this is only extracted to a module to mock in testing as require.resolve can't be mocked.
2
- // https://github.com/facebook/jest/issues/9543
3
- export function canResolvePrettier() {
4
- try {
5
- import.meta.resolve("prettier");
6
- return true;
7
- }
8
- catch (_error) {
9
- // cannot resolve prettier
10
- return false;
11
- }
12
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Try to load prettier and config from project to format input,
3
- * fall back to input if prettier is not found or failed
4
- *
5
- * @param {file} file
6
- * @param {string} input
7
- */
8
- export declare const attemptPrettier: (file: string, input: string) => Promise<string>;
@@ -1,53 +0,0 @@
1
- import { alerts } from "../core/alerts.js";
2
- import { canResolvePrettier } from "./can-resolve.js";
3
- const isPrettier = (t) => !!t &&
4
- typeof t === "object" &&
5
- t !== null &&
6
- "format" in t &&
7
- typeof t.format === "function" &&
8
- "resolveConfig" in t &&
9
- typeof t.resolveConfig === "function";
10
- /**
11
- * Try to load prettier and config from project to format input,
12
- * fall back to input if prettier is not found or failed
13
- *
14
- * @param {file} file
15
- * @param {string} input
16
- */
17
- export const attemptPrettier = async (file, input) => {
18
- if (!canResolvePrettier()) {
19
- return input;
20
- }
21
- // Non-literal specifier: resolved against the consuming project at
22
- // runtime; must not become a compile-time dependency of this package.
23
- const prettierSpecifier = "prettier";
24
- let prettier;
25
- try {
26
- prettier = await import(prettierSpecifier);
27
- }
28
- catch (_error) {
29
- // prettier is not installed in the consuming project
30
- return input;
31
- }
32
- if (!isPrettier(prettier)) {
33
- // doesn't look like prettier
34
- return input;
35
- }
36
- try {
37
- const config = await prettier
38
- .resolveConfig(file, {
39
- editorconfig: true,
40
- })
41
- .catch(() => {
42
- /* default */
43
- });
44
- // try to return formatted output
45
- return prettier.format(input, { ...config, parser: "typescript" });
46
- }
47
- catch (error) {
48
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
49
- alerts.notice(`Tried using prettier, but failed with error: ${error}`);
50
- }
51
- // failed to format
52
- return input;
53
- };