Skip to content

Commit

Permalink
Merge pull request #742 from shufo/feature/bump-blade-formatter-to-1_…
Browse files Browse the repository at this point in the history
…33_1
  • Loading branch information
shufo committed Jul 8, 2023
2 parents 956acba + 1706f7f commit 727e61c
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
"blade-formatter": "^1.33.1",
"find-config": "^1.0.0",
"ignore": "^5.2.4",
"sucrase": "^3.32.0",
"tailwindcss": "^3.3.2",
"vscode-extension-telemetry": "^0.4.5"
},
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const REPORT_ISSUE = "Report Issue";

const knownIssuesUrl = "https://github.com/shufo/vscode-blade-formatter/issues";
const newIssueUrl =
"https://github.com/shufo/vscode-blade-formatter/issues/new";
"https://github.com/shufo/vscode-blade-formatter/issues/new/choose";

const WASM_ERROR_MESSAGE = "Must invoke loadWASM first.";

Expand Down
1 change: 0 additions & 1 deletion src/tailwind.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import findConfig from 'find-config';
import path from 'path';
import { findConfigFile } from './runtimeConfig';
import { requireUncached } from './util';

const __config__ = 'tailwind.config.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sortTailwindcssClasses": true,
"tailwindcssConfigPath": "tailwind.config.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="xxxl:col-end-8 col-start-2 col-end-11 md:col-end-12 xl:col-end-10">
<h1 class="text-white">Random Stuff</h1>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="md:col-end-12 xl:col-end-10 col-start-2 col-end-11 xxxl:col-end-8">
<h1 class="text-white">Random Stuff</h1>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export defau {
theme: {
screens: {
sm: "0",
md: "834px",
lg: "1024px",
xl: "1200px",
xxl: "1440px",
xxxl: "1900px",
},
},
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="md:col-end-12 xl:col-end-10 col-start-2 col-end-11 xxxl:col-end-8">
<div class="xxxl:col-end-8 col-start-2 col-end-11 md:col-end-12 xl:col-end-10">
<h1 class="text-white">Random Stuff</h1>
</div>
7 changes: 7 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ suite("Extension Test Suite", () => {
);
});

test("Should format file with runtime config / ES Module tailwind config (Syntax Error)", async function (this: any) {
this.timeout(20000);
await formatSameAsBladeFormatter(
"withConfig/tailwindConfigESModuleSyntaxError/index.blade.php",
"withConfig/tailwindConfigESModuleSyntaxError/formatted.index.blade.php"
);
});

test("Should format file with runtime config / sortHtmlAttributes", async function (this: any) {
this.timeout(20000);
Expand Down
8 changes: 6 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import vscode from "vscode";
import fs from 'fs';
import { transform } from 'sucrase';

/**
* Returns a node module installed with VSCode, or null if it fails.
Expand Down Expand Up @@ -26,8 +28,10 @@ export function requireUncached(moduleName: string) {
try {
// @ts-ignore
delete __non_webpack_require__.cache[__non_webpack_require__.resolve(moduleName)];
// @ts-ignore
import(moduleName);

const fileContent = fs.readFileSync(moduleName, 'utf8');

return transform(fileContent, { transforms: ['imports'] });
} catch (err: any) {
throw err;
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3369,7 +3369,7 @@ espree@^9.6.0:

esprima@^4.0.0, esprima@~4.0.0:
version "4.0.1"
resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==

esquery@^1.4.0:
Expand Down

0 comments on commit 727e61c

Please sign in to comment.