Skip to content

Commit

Permalink
Merge branch 'master' into playwright-rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
TGCrystal committed Feb 6, 2024
2 parents bcaac68 + cf0c866 commit d6f054c
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node.js 16.x
uses: actions/setup-node@v1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ tests/index.js
app.yaml
yarn-error.log

.eslintcache

# IntelliJ
.idea/

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"test-e2e:digital": "npx playwright test --config ./playwright/config/digital.config.ts",
"test-e2e:landing": "npx playwright test --config ./playwright/config/landing.config.ts",
"test-e2e:ci": "npx playwright test --config ./playwright/config/ci.config.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint": "node ./build/scripts/lint.js --cache",
"lint:all": "node ./build/scripts/lint.js --cache --all",
"lint:fix": "node ./build/scripts/lint.js --cache --fix",
"lint:fix:all": "node ./build/scripts/lint.js --cache --fix --all",
"postinstall": "tsc --project ./scripts/tsconfig.json && copyfiles ./scripts/utils/browser/openChrome.applescript ./build"
},
"devDependencies": {
Expand Down Expand Up @@ -83,6 +85,7 @@
"react-refresh-typescript": "^2.0.7",
"sass": "^1.53.0",
"sass-loader": "^13.0.2",
"simple-git": "^3.14.1",
"ts-jest": "^28.0.5",
"ts-loader": "^9.3.1",
"ts-morph": "^15.1.0",
Expand Down
42 changes: 42 additions & 0 deletions scripts/lint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {ESLint} from "eslint";
import {simpleGit} from "simple-git";
import yargs from "yargs";


// CLI
(async () => {
const { fix, cache, all } = await yargs(process.argv.slice(2))
.boolean("fix")
.boolean("cache")
.boolean("all")
.argv;

const eslint = new ESLint({
fix, cache,
errorOnUnmatchedPattern: false, // disable because deleted files
extensions: [".ts", ".tsx"],
});

const files = await (async () => {
if (all)
return ["scripts/", "src/"];
const git = simpleGit();
// Get diff for all files that are staged (or something)
const diff = await git.diff(["--name-only", "origin/master...", "--"]);
// Get status for all unstaged files (or something)
const status = await git.status(["--short"]);
return [
...new Set([
...diff.split("\n"),
...status.files.map(f => f.path),
].filter((file) => (file.endsWith(".ts") || file.endsWith(".tsx")))
)];
})();

const results = await eslint.lintFiles(files);
if (fix)
await ESLint.outputFixes(results);
const formatter = await eslint.loadFormatter("stylish");
const resultText = formatter.format(results);
console.log(resultText);
})();
12 changes: 6 additions & 6 deletions src/app/core/tools/WiringTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {Port, Wire} from "core/models";


export const WiringTool = (() => {
enum StateType {
CLICKED,
DRAGGED,
const enum StateType {
Clicked,
Dragged,
}

let port: Port;
Expand Down Expand Up @@ -84,8 +84,8 @@ export const WiringTool = (() => {
// 2) if the port was initial dragged on,
// then letting go of the mouse will deactivate this
// 3) the user cancels using Escape, Backspace or RMB
return (stateType === StateType.CLICKED && event.type === "click") ||
(stateType === StateType.DRAGGED && event.type === "mouseup") ||
return (stateType === StateType.Clicked && event.type === "click") ||
(stateType === StateType.Dragged && event.type === "mouseup") ||
(event.type === "keydown" && event.key === "Escape") ||
(event.type === "keydown" && event.key === "Backspace") ||
(event.type === "mousedown" && event.button === RIGHT_MOUSE_BUTTON);
Expand All @@ -100,7 +100,7 @@ export const WiringTool = (() => {
wire = info.designer.createWire(port, undefined);
setWirePoint(port.getWorldTargetPos());

stateType = (event.type === "click" ? StateType.CLICKED : StateType.DRAGGED);
stateType = (event.type === "click" ? StateType.Clicked : StateType.Dragged);
},
onDeactivate({}: Event, info: CircuitInfo): void {
const { history, designer } = info;
Expand Down
2 changes: 1 addition & 1 deletion src/site/pages/digital/src/utils/DigitalCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function DigitalCreateN(pos: Vector, itemId: string, designer: DigitalCir
}


export enum SmartPlaceOptions {
export const enum SmartPlaceOptions {
Off = 0,
Inputs = 1 << 0,
Outputs = 1 << 1,
Expand Down
21 changes: 21 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,18 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"

"@kwsites/file-exists@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@kwsites/file-exists/-/file-exists-1.1.1.tgz#ad1efcac13e1987d8dbaf235ef3be5b0d96faa99"
integrity sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==
dependencies:
debug "^4.1.1"

"@kwsites/promise-deferred@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919"
integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==

"@leichtgewicht/ip-codec@^2.0.1":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
Expand Down Expand Up @@ -10344,6 +10356,15 @@ signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==

simple-git@^3.14.1:
version "3.14.1"
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.14.1.tgz#68018a5f168f8a568862e30b692004b37c3b5ced"
integrity sha512-1ThF4PamK9wBORVGMK9HK5si4zoGS2GpRO7tkAFObA4FZv6dKaCVHLQT+8zlgiBm6K2h+wEU9yOaFCu/SR3OyA==
dependencies:
"@kwsites/file-exists" "^1.1.1"
"@kwsites/promise-deferred" "^1.1.1"
debug "^4.3.4"

sirv@^1.0.7:
version "1.0.19"
resolved "https://registry.yarnpkg.com/sirv/-/sirv-1.0.19.tgz#1d73979b38c7fe91fcba49c85280daa9c2363b49"
Expand Down

0 comments on commit d6f054c

Please sign in to comment.