Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tizayi committed Oct 30, 2023
1 parent 616578e commit a29f257
Show file tree
Hide file tree
Showing 21 changed files with 451 additions and 317 deletions.
52 changes: 26 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// // Uncomment the next line to run commands after the container is created.
// // "postCreateCommand": "cat /etc/os-release",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],

// "initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
// "runArgs": [
// "--net=host",
// "--security-opt=label=disable"
// ],
// "mounts": [
// "source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
// "source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind"
// ],
// // make the workspace folder the same inside and outside of the container
// "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
// "workspaceFolder": "${localWorkspaceFolder}"
// // Uncomment the next line to run commands after the container is created.
// // "postCreateCommand": "cat /etc/os-release",

// "initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
// "runArgs": [
// "--net=host",
// "--security-opt=label=disable"
// ],
// "mounts": [
// "source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
// "source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind"
// ],
// // make the workspace folder the same inside and outside of the container
// "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
// "workspaceFolder": "${localWorkspaceFolder}"
}
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: github-pages-deploy

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
concurrency: ci-${{github.ref}}

steps:
- name: Checkout Source
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Node
uses: actions/setup-node@v3
with:
node-version: '21.0.0'

- name: Install test and build
run: |
npm ci
npm run lint
npm run test
npm run build
- name: Deploy to GH Pages 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./dist
branch: gh-pages
40 changes: 0 additions & 40 deletions .github/workflows/gh-pages.yml

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview --port 3000",
"test": "npx vitest",
"predeploy" : "npm run build",
"deploy" : "gh-pages -d build"
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down
9 changes: 4 additions & 5 deletions src/calculations/numericRange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ test("test numeric range interset", () => {
});

test("numeric range swap", () => {
const range1 = new NumericRange(100, 4)
expect(range1.min).toEqual(4)
expect(range1.max).toEqual(100)
})
const range1 = new NumericRange(100, 4);
expect(range1.min).toEqual(4);
expect(range1.max).toEqual(100);
});

test("test numeric range equality", () => {
const range1 = new NumericRange(2, 3);
const range2 = new NumericRange(2, 3);
expect(range1.equals(range2));
});

6 changes: 3 additions & 3 deletions src/calculations/numericRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class NumericRange {

/**
* Returns true if another range falls inside the numeric range
* @param other another range
* @param other another range
* @returns
*/
containsRange(other: NumericRange): boolean {
Expand All @@ -35,7 +35,7 @@ export default class NumericRange {

/**
* Returns string represtaion of the numeric range
* @returns
* @returns
*/
toString(): string {
return `(min:${this.min}, max:${this.max})`;
Expand All @@ -61,7 +61,7 @@ export default class NumericRange {
/**
* Returns true if the neumeric ranges are equal
* @param other another numeric range
* @returns
* @returns
*/
equals(other: NumericRange): boolean {
return this.min === other.min && this.max === other.max;
Expand Down
13 changes: 7 additions & 6 deletions src/calculations/qrange.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import QSpace, {
DetectorProperties,
} from "../calculations/qspace";
import QSpace, { DetectorProperties } from "../calculations/qspace";
import {
BeamlineConfig,
Beamstop,
Expand Down Expand Up @@ -107,15 +105,18 @@ export function computeQrange(
beamVector: new Vector3(0, 0, 1),
};


const qspace = new QSpace(detProps, beamProperties.wavelength * 1e10, 2 * Math.PI);
const qspace = new QSpace(
detProps,
beamProperties.wavelength * 1e10,
2 * Math.PI,
);

// get visible range
const visibleQMin = qspace.qFromPixelPosition(ptMin);
const visibleQMax = qspace.qFromPixelPosition(ptMax);

detProps.origin.z = beamProperties.minCameraLength * 1e3;
qspace.setDiffractionCrystalEnviroment(beamProperties.minWavelength * 1e10,);
qspace.setDiffractionCrystalEnviroment(beamProperties.minWavelength * 1e10);
const fullQMin = qspace.qFromPixelPosition(ptMax);

detProps.origin.z = beamProperties.maxCameraLength * 1e3;
Expand Down
2 changes: 1 addition & 1 deletion src/calculations/qvalue.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "vitest";

test("Test getting q from pixel position ", () => {
console.log("write some tests here");
console.log("write some tests here");
});
13 changes: 7 additions & 6 deletions src/data-entry/beamProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export default function BeampropertiesDataEntry() {
}

if (state.beamEnergyUnits === EnergyUnits.electronVolts) {
return kiloElectronVolts2ElectronVots(
state.energy,
);
return kiloElectronVolts2ElectronVots(state.energy);
}
return state.energy;
});
Expand Down Expand Up @@ -109,13 +107,16 @@ export default function BeampropertiesDataEntry() {
const handleWavelength = (event: React.ChangeEvent<HTMLInputElement>) => {
if (wavelengthUnits === WavelengthUnits.angstroms && event.target.value) {
updateConfig({
energy: wavelength2EnergyConverter(angstroms2Nanometres(parseFloat(event.target.value))),
energy: wavelength2EnergyConverter(
angstroms2Nanometres(parseFloat(event.target.value)),
),
wavelength: angstroms2Nanometres(parseFloat(event.target.value)),
});
} else {
updateConfig({
updateConfig({
energy: wavelength2EnergyConverter(parseFloat(event.target.value)),
wavelength: parseFloat(event.target.value) });
wavelength: parseFloat(event.target.value),
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/data-entry/beamlineconfigStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BeamlineConfig } from "../utils/types";
import { create } from "zustand";
import { AngleUnits, EnergyUnits, WavelengthUnits } from "../utils/units";
import { presetList,defaultConfig } from "../presets/presetManager";
import { presetList, defaultConfig } from "../presets/presetManager";

export interface BeamlineConfigStore extends BeamlineConfig {
preset: string | null;
Expand Down
2 changes: 0 additions & 2 deletions src/data-entry/beamstopStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export interface BeamstopStore extends Beamstop {
updateBeamstop: (presetBeamstop: Beamstop) => void;
}



export const useBeamstopStore = create<BeamstopStore>((set) => ({
...defaultConfig.beamstop,
clearance: defaultConfig.beamstop.clearance,
Expand Down
11 changes: 5 additions & 6 deletions src/plot/centrePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function CentrePlot(): JSX.Element {
const domains = getDomains(ajustedDetector, ajustedCameraTube);

// requested range on diagram
const requestedRange = useResultStore((state) => state.requestedRange)
const requestedRange = useResultStore((state) => state.requestedRange);
const requestedMax = getPointForQ(
requestedRange.max * 1e9,
bealineConfig.angle ?? 0,
Expand All @@ -143,7 +143,6 @@ export default function CentrePlot(): JSX.Element {
ajustedBeamstop,
);


return (
<Box>
<Stack direction="column" spacing={2}>
Expand Down Expand Up @@ -176,14 +175,14 @@ export default function CentrePlot(): JSX.Element {
),
new Vector3(
(ajustedBeamstop.centre.x ?? 0) +
ajustedBeamstop.diameter / 2,
ajustedBeamstop.diameter / 2,
ajustedBeamstop.centre.y ?? 0,
),
new Vector3(
ajustedBeamstop.centre.x ?? 0,
(ajustedBeamstop.centre.y ?? 0) +
ajustedBeamstop.diameter / 2 +
(ajustedBeamstop.clearance ?? 0),
ajustedBeamstop.diameter / 2 +
(ajustedBeamstop.clearance ?? 0),
),
new Vector3(
ajustedCameraTube.centre.x ?? 0,
Expand All @@ -192,7 +191,7 @@ export default function CentrePlot(): JSX.Element {
new Vector3(
ajustedCameraTube.centre.x ?? 0,
(ajustedCameraTube.centre.y ?? 0) +
ajustedCameraTube.diameter / 2,
ajustedCameraTube.diameter / 2,
),
new Vector3(0, 0),
new Vector3(
Expand Down
2 changes: 1 addition & 1 deletion src/presets/presetConfigs.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"minCameraLength": 1.9,
"maxCameraLength": 100
}
}
}
Loading

0 comments on commit a29f257

Please sign in to comment.