Skip to content

Commit 6dba5d5

Browse files
Add experimental IML formatter (#35)
1 parent e4e3201 commit 6dba5d5

31 files changed

+189644
-475
lines changed

.vscode/launch.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,48 @@
1919
"type": "npm",
2020
"script": "esbuild"
2121
}
22+
},
23+
{
24+
"name": "Debug imlformat",
25+
"type": "node",
26+
"request": "launch",
27+
"runtimeExecutable": "tsx",
28+
"console": "integratedTerminal",
29+
"internalConsoleOptions": "neverOpen",
30+
"cwd": "${workspaceFolder}/imlformat",
31+
"program": "${workspaceFolder}/imlformat/imlformat.ts",
32+
"args": [
33+
"${workspaceFolder}/imlformat/test/demo.iml"
34+
],
35+
"outFiles": [
36+
"${workspaceFolder}/imlformat/out-dbg/**/*.js"
37+
],
38+
"resolveSourceMapLocations": [
39+
"${workspaceFolder}/imlformat/**",
40+
],
41+
"skipFiles": [
42+
"<node_internals>/**",
43+
"${workspaceFolder}/out/**",
44+
"${workspaceFolder}/node_modules/**",
45+
"${workspaceFolder}/imlformat/node_modules/**",
46+
"${workspaceFolder}/node_modules/out/**"
47+
],
48+
},
49+
{
50+
"name": "Debug imlformat Jests",
51+
"type": "node",
52+
"request": "launch",
53+
"cwd": "${workspaceFolder}/imlformat",
54+
"env": {
55+
"NODE_OPTIONS": "--experimental-vm-modules"
56+
},
57+
"runtimeArgs": [
58+
"--inspect-brk",
59+
"${workspaceRoot}/imlformat/node_modules/.bin/jest",
60+
"--runInBand"
61+
],
62+
"console": "integratedTerminal",
63+
"internalConsoleOptions": "neverOpen"
2264
}
2365
]
2466
}

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
},
77
"editor.tabSize": 2,
88
"editor.insertSpaces": true,
9-
"editor.detectIndentation": false
9+
"editor.detectIndentation": false,
10+
"jest.rootPath": "imlformat",
11+
"jest.runMode": "on-demand",
1012
}

.vscodeignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ src/
1414
tsconfig.json
1515
tmp
1616
_opam
17+
README.dev.md
18+
.gitmodules
19+
.vscode-test.mjs
20+
eslint.config.mjs
21+
vendor
22+
imlformat
23+
!node_modules/prettier
24+
Makefile

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package-lock.json: package.json
44
npm i
55

66
# see https://code.visualstudio.com/api/working-with-extensions/bundling-extension#using-esbuild
7-
vsix: package-lock.json src/extension.ts
7+
vsix: package-lock.json src/*.ts
88
npm x vsce package
99

1010
distrib: vsix

imlformat/.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": false
7+
}

imlformat/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
imlformat
2+
=========
3+
4+
A formatter for IML files based on [prettier](https://prettier.io/).
5+
6+
Run me like so:
7+
8+
```
9+
npm install
10+
npx tsx imlformat.ts <filename>
11+
```
12+
13+
Usage from prettier with the plugin option:
14+
```
15+
npm run esbuild
16+
npx prettier --plugin=./out/iml-prettier.js <filename>
17+
```

imlformat/eslint.config.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import tseslint from "typescript-eslint";
2+
import eslint from "@eslint/js";
3+
4+
export default tseslint.config(
5+
eslint.configs.recommended,
6+
tseslint.configs.recommendedTypeChecked,
7+
tseslint.configs.stylisticTypeChecked,
8+
{
9+
files: ["**.ts", "**.*.ts"],
10+
},
11+
{
12+
languageOptions: {
13+
parserOptions: {
14+
projectService: true,
15+
tsconfigRootDir: import.meta.dirname
16+
},
17+
},
18+
},
19+
{
20+
rules: {
21+
"@typescript-eslint/no-unsafe-assignment": "warn",
22+
"@typescript-eslint/no-unsafe-argument": "warn",
23+
"@typescript-eslint/no-unsafe-call": "warn",
24+
"@typescript-eslint/no-unsafe-member-access": "off",
25+
"@typescript-eslint/dot-notation": "warn",
26+
"@typescript-eslint/no-explicit-any": "warn",
27+
"@typescript-eslint/no-floating-promises": "warn",
28+
"@typescript-eslint/no-unused-vars": "off",
29+
"no-prototype-builtins": "off",
30+
"@typescript-eslint/no-unsafe-return": "off",
31+
"@typescript-eslint/no-unsafe-call": "off",
32+
"@typescript-eslint/no-unsafe-assignment": "off",
33+
"@typescript-eslint/prefer-nullish-coalescing": "off",
34+
"@typescript-eslint/no-require-imports": "off",
35+
"@typescript-eslint/no-unsafe-argument": "off"
36+
}
37+
},
38+
{
39+
ignores: [
40+
"node_modules/**",
41+
"src/node_modules/**",
42+
"src/out/**",
43+
"eslint.config.mjs",
44+
".vscode-test.mjs"
45+
],
46+
},
47+
);

0 commit comments

Comments
 (0)