Skip to content

Commit 317b8f5

Browse files
authored
Improve prettier setup, add a precommit hook to format files and format files (#202)
* remove unused prettier key in package.json * replace source.organizeImports with prettier-plugin-organize-imports * add husky pre-commit hook * widen lint-staged files selector * format all files with prettier * resolve formatting test failures * Revert "replace source.organizeImports with prettier-plugin-organize-imports" This reverts commit 7a1fdce.
1 parent e938f4c commit 317b8f5

210 files changed

Lines changed: 2369 additions & 2412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**@type {import('eslint').Linter.Config} */
22
// eslint-disable-next-line no-undef
33
module.exports = {
4-
// root: true,
5-
// parser: '@typescript-eslint/parser',
6-
// plugins: [
7-
// '@typescript-eslint',
8-
// ],
9-
// extends: [
10-
// 'eslint:recommended',
11-
// 'plugin:@typescript-eslint/recommended',
12-
// ],
13-
// rules: {
14-
// 'semi': [2, "always"],
15-
// '@typescript-eslint/no-unused-vars': 0,
16-
// '@typescript-eslint/no-explicit-any': 0,
17-
// '@typescript-eslint/explicit-module-boundary-types': 0,
18-
// '@typescript-eslint/no-non-null-assertion': 0,
19-
// }
4+
// root: true,
5+
// parser: '@typescript-eslint/parser',
6+
// plugins: [
7+
// '@typescript-eslint',
8+
// ],
9+
// extends: [
10+
// 'eslint:recommended',
11+
// 'plugin:@typescript-eslint/recommended',
12+
// ],
13+
// rules: {
14+
// 'semi': [2, "always"],
15+
// '@typescript-eslint/no-unused-vars': 0,
16+
// '@typescript-eslint/no-explicit-any': 0,
17+
// '@typescript-eslint/explicit-module-boundary-types': 0,
18+
// '@typescript-eslint/no-non-null-assertion': 0,
19+
// }
2020
};

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22
on:
33
push:
44
branches:
5-
- "**"
5+
- '**'
66

77
jobs:
88
build:
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/setup-node@v2
1313
with:
1414
node-version: 14.x
15-
cache: "yarn"
15+
cache: 'yarn'
1616

1717
- run: yarn
1818
- run: yarn turbo run lint test
@@ -22,4 +22,4 @@ jobs:
2222
- uses: actions/upload-artifact@v2
2323
with:
2424
name: xstate-tools
25-
path: "apps/extension/client/*.vsix"
25+
path: 'apps/extension/client/*.vsix'

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish
22
on:
33
push:
44
branches:
5-
- "main"
5+
- 'main'
66

77
concurrency: ${{ github.workflow }}-${{ github.ref }}
88

@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/setup-node@v2
1515
with:
1616
node-version: 14.x
17-
cache: "yarn"
17+
cache: 'yarn'
1818

1919
- run: yarn
2020
- run: yarn deps:build && yarn extension:compile

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.vscode/launch.json

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
// A launch configuration that compiles the extension and then opens it inside a new window
2-
{
3-
"version": "0.2.0",
4-
"configurations": [
5-
{
6-
"type": "node",
7-
"request": "launch",
8-
"name": "Jest Current File",
9-
"program": "${workspaceFolder}/node_modules/.bin/jest",
10-
"args": ["${file}", "--no-cache"],
11-
"console": "integratedTerminal",
12-
"internalConsoleOptions": "neverOpen",
13-
"disableOptimisticBPs": true,
14-
"windows": {
15-
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
16-
}
17-
},
18-
{
19-
"type": "extensionHost",
20-
"request": "launch",
21-
"name": "Launch Client",
22-
"runtimeExecutable": "${execPath}",
23-
"args": [
24-
"--extensionDevelopmentPath=${workspaceRoot}/apps/extension/client"
25-
],
26-
"outFiles": ["${workspaceRoot}/apps/extension/client/dist/**.js"],
27-
"preLaunchTask": "npm: extension:compile"
28-
},
29-
{
30-
"type": "node",
31-
"request": "attach",
32-
"name": "Attach to Server",
33-
"port": 6009,
34-
"restart": true,
35-
"outFiles": ["${workspaceRoot}/apps/extension/server/dist/**.js"]
36-
},
37-
{
38-
"name": "Language Server E2E Test",
39-
"type": "extensionHost",
40-
"request": "launch",
41-
"runtimeExecutable": "${execPath}",
42-
"args": [
43-
"--extensionDevelopmentPath=${workspaceRoot}/apps/extension/client",
44-
"--extensionTestsPath=${workspaceRoot}/apps/extension/client/out/test/index",
45-
"${workspaceRoot}apps/extension/client/testFixture"
46-
],
47-
"outFiles": ["${workspaceRoot}/apps/extension/client/dist/**.js"]
48-
}
49-
],
50-
"compounds": [
51-
{
52-
"name": "Client + Server",
53-
"configurations": ["Launch Client", "Attach to Server"]
54-
}
55-
]
56-
}
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
{
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"type": "node",
7+
"request": "launch",
8+
"name": "Jest Current File",
9+
"program": "${workspaceFolder}/node_modules/.bin/jest",
10+
"args": ["${file}", "--no-cache"],
11+
"console": "integratedTerminal",
12+
"internalConsoleOptions": "neverOpen",
13+
"disableOptimisticBPs": true,
14+
"windows": {
15+
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
16+
}
17+
},
18+
{
19+
"type": "extensionHost",
20+
"request": "launch",
21+
"name": "Launch Client",
22+
"runtimeExecutable": "${execPath}",
23+
"args": [
24+
"--extensionDevelopmentPath=${workspaceRoot}/apps/extension/client"
25+
],
26+
"outFiles": ["${workspaceRoot}/apps/extension/client/dist/**.js"],
27+
"preLaunchTask": "npm: extension:compile"
28+
},
29+
{
30+
"type": "node",
31+
"request": "attach",
32+
"name": "Attach to Server",
33+
"port": 6009,
34+
"restart": true,
35+
"outFiles": ["${workspaceRoot}/apps/extension/server/dist/**.js"]
36+
},
37+
{
38+
"name": "Language Server E2E Test",
39+
"type": "extensionHost",
40+
"request": "launch",
41+
"runtimeExecutable": "${execPath}",
42+
"args": [
43+
"--extensionDevelopmentPath=${workspaceRoot}/apps/extension/client",
44+
"--extensionTestsPath=${workspaceRoot}/apps/extension/client/out/test/index",
45+
"${workspaceRoot}apps/extension/client/testFixture"
46+
],
47+
"outFiles": ["${workspaceRoot}/apps/extension/client/dist/**.js"]
48+
}
49+
],
50+
"compounds": [
51+
{
52+
"name": "Client + Server",
53+
"configurations": ["Launch Client", "Attach to Server"]
54+
}
55+
]
56+
}

.vscode/settings.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{
2-
"editor.insertSpaces": false,
3-
"editor.formatOnSave": true,
4-
"editor.codeActionsOnSave": {
5-
"source.fixAll.eslint": true,
6-
"source.organizeImports": true
7-
}
8-
}
1+
{
2+
"editor.insertSpaces": false,
3+
"editor.formatOnSave": true,
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll.eslint": true,
6+
"source.organizeImports": true
7+
}
8+
}

.vscode/tasks.json

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
{
2-
"version": "2.0.0",
3-
"tasks": [
4-
{
5-
"type": "npm",
6-
"script": "compile",
7-
"group": "build",
8-
"presentation": {
9-
"panel": "dedicated",
10-
"reveal": "never"
11-
},
12-
"problemMatcher": [
13-
"$tsc"
14-
]
15-
},
16-
{
17-
"type": "npm",
18-
"script": "watch",
19-
"isBackground": true,
20-
"group": {
21-
"kind": "build",
22-
"isDefault": true
23-
},
24-
"presentation": {
25-
"panel": "dedicated",
26-
"reveal": "never"
27-
},
28-
"problemMatcher": [
29-
"$tsc-watch"
30-
]
31-
}
32-
]
33-
}
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "compile",
7+
"group": "build",
8+
"presentation": {
9+
"panel": "dedicated",
10+
"reveal": "never"
11+
},
12+
"problemMatcher": ["$tsc"]
13+
},
14+
{
15+
"type": "npm",
16+
"script": "watch",
17+
"isBackground": true,
18+
"group": {
19+
"kind": "build",
20+
"isDefault": true
21+
},
22+
"presentation": {
23+
"panel": "dedicated",
24+
"reveal": "never"
25+
},
26+
"problemMatcher": ["$tsc-watch"]
27+
}
28+
]
29+
}

apps/cli/jest.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/** @type {import('@jest/types').Config.InitialOptions} */
22
module.exports = {
3-
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
3+
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
44
watchPathIgnorePatterns: [
5-
"<rootDir>/src/__tests__/__examples__/*.typegen.ts",
5+
'<rootDir>/src/__tests__/__examples__/*.typegen.ts',
66
],
77
watchPlugins: [
8-
"jest-watch-typeahead/filename",
9-
"jest-watch-typeahead/testname",
8+
'jest-watch-typeahead/filename',
9+
'jest-watch-typeahead/testname',
1010
],
1111
snapshotFormat: {
1212
printBasicPrototype: false,
1313
escapeString: false,
1414
},
1515
transform: {
16-
"^.+\\.tsx?$": ["esbuild-jest", { sourcemap: true }],
16+
'^.+\\.tsx?$': ['esbuild-jest', { sourcemap: true }],
1717
},
1818
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { createMachine } from "xstate";
1+
import { createMachine } from 'xstate';
22

33
createMachine({
4-
tsTypes: {} as import("./action-backtick.typegen").Typegen0,
4+
tsTypes: {} as import('./action-backtick.typegen').Typegen0,
55
schema: {
6-
events: {} as { type: "PING" },
6+
events: {} as { type: 'PING' },
77
},
88
on: {
99
PING: {
10-
actions: "log `event`",
10+
actions: 'log `event`',
1111
},
1212
},
1313
});

apps/cli/src/__tests__/__examples__/action-double-quote.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createMachine } from "xstate";
1+
import { createMachine } from 'xstate';
22

33
createMachine({
4-
tsTypes: {} as import("./action-double-quote.typegen").Typegen0,
4+
tsTypes: {} as import('./action-double-quote.typegen').Typegen0,
55
schema: {
6-
events: {} as { type: "PING" },
6+
events: {} as { type: 'PING' },
77
},
88
on: {
99
PING: {

0 commit comments

Comments
 (0)