Skip to content

Commit

Permalink
Apply Prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrimes committed Aug 19, 2024
1 parent 6554515 commit 1ab3dbd
Show file tree
Hide file tree
Showing 59 changed files with 5,402 additions and 5,585 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Node.js Package
on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ECL Builder

This is a collection of components and an app that allow a user to visually
build a SNOMED CT [Expression Constraint Language (ECL)](http://snomed.org/ecl)
This is a collection of components and an app that allow a user to visually
build a SNOMED CT [Expression Constraint Language (ECL)](http://snomed.org/ecl)
query.

The app is currently hosted [here](https://main.d3gfg08ybf406s.amplifyapp.com/).
Expand Down
2 changes: 1 addition & 1 deletion amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ applications:
artifacts:
baseDirectory: apps/ecl-builder-app/build
files:
- '**/*'
- "**/*"
cache:
paths:
- node_modules/**/*
6 changes: 3 additions & 3 deletions apps/ecl-builder-app/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ extends:
- eslint:recommended
- plugin:react/recommended
- plugin:@typescript-eslint/recommended
parser: '@typescript-eslint/parser'
parser: "@typescript-eslint/parser"
parserOptions:
ecmaFeatures:
jsx: true
ecmaVersion: latest
sourceType: module
plugins:
- react
- '@typescript-eslint'
- "@typescript-eslint"
settings:
react:
version: "17"
rules: { }
rules: {}
26 changes: 13 additions & 13 deletions apps/ecl-builder-app/public/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#000000"/>
<link
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<title>ECL Builder</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<main id="root"></main>
</body>
/>
<title>ECL Builder</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<main id="root"></main>
</body>
</html>
5 changes: 3 additions & 2 deletions apps/ecl-builder-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ theme = createTheme(theme, {
});

function App() {
const [currentExpression, setCurrentExpression] =
useState<string | undefined>(undefined);
const [currentExpression, setCurrentExpression] = useState<
string | undefined
>(undefined);

return (
<ThemeProvider theme={theme}>
Expand Down
2 changes: 1 addition & 1 deletion apps/ecl-builder-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ ReactDOM.render(
<StrictMode>
<App />
</StrictMode>,
document.getElementById("root")
document.getElementById("root"),
);
10 changes: 2 additions & 8 deletions apps/ecl-builder-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -20,7 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}
4 changes: 2 additions & 2 deletions packages/ecl-builder/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extends:
- plugin:react/recommended
- plugin:react-hooks/recommended
- plugin:@typescript-eslint/recommended
parser: '@typescript-eslint/parser'
parser: "@typescript-eslint/parser"
parserOptions:
ecmaFeatures:
jsx: true
Expand All @@ -15,7 +15,7 @@ parserOptions:
project: ./tsconfig.json
plugins:
- react
- '@typescript-eslint'
- "@typescript-eslint"
settings:
react:
version: "17"
Expand Down
11 changes: 4 additions & 7 deletions packages/ecl-builder/.storybook/compile.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { parseModule } from 'magicast';
import type { DynamicConfig } from '../src/stories/types';
import { parseModule } from "magicast";
import type { DynamicConfig } from "../src/stories/types";

// adapted from https://stackblitz.com/edit/github-h2rgfk?file=README.md

export const compile = async (
config: DynamicConfig
) => {
export const compile = async (config: DynamicConfig) => {
const { baseCsf } = config;
const stories = await config.stories();

const mod = parseModule(baseCsf);
stories.forEach(({csfName, story}) => {
stories.forEach(({ csfName, story }) => {
mod.exports[csfName] = story;
});

const { code } = mod.generate();
return code;
};

10 changes: 5 additions & 5 deletions packages/ecl-builder/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
*/
export default {
stories: [
"../src/**/*.stories.mdx",
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)",
"../src/**/*.dynamic.@(js|jsx|ts|tsx)"
"../src/**/*.dynamic.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-webpack5-compiler-swc",
"./preset"
"./preset",
],
framework: {
name: "@storybook/react-webpack5",
options: {}
options: {},
},
docs: {
autodocs: 'tag',
autodocs: "tag",
},
};
15 changes: 7 additions & 8 deletions packages/ecl-builder/.storybook/preset.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import type { Indexer } from '@storybook/types';
import { serverRequire } from '@storybook/core-common';
import { loadCsf } from '@storybook/csf-tools';
import { webpack, DYNAMIC_STORIES_REGEX } from './unplugin';
import { compile } from './compile';
import type { Indexer } from "@storybook/types";
import { serverRequire } from "@storybook/core-common";
import { loadCsf } from "@storybook/csf-tools";
import { webpack, DYNAMIC_STORIES_REGEX } from "./unplugin";
import { compile } from "./compile";

// adapted from https://stackblitz.com/edit/github-h2rgfk?file=README.md

const dynamicIndexer = {
test: DYNAMIC_STORIES_REGEX,
createIndex: async (fileName, opts) => {
console.log('indexing', fileName);
console.log("indexing", fileName);
delete require.cache[fileName];
const config = await serverRequire(fileName);
const compiled = await compile(config);
const indexed = loadCsf(compiled, {
...opts,
fileName,
makeTitle: () => fileName.replace(/^.*\/(.+?)\..*$/, '$1'),
makeTitle: () => fileName.replace(/^.*\/(.+?)\..*$/, "$1"),
}).parse();

return indexed.indexInputs;
Expand All @@ -31,4 +31,3 @@ export const webpackFinal = async (config: any) => {
config.plugins = plugins;
return config;
};

12 changes: 6 additions & 6 deletions packages/ecl-builder/.storybook/unplugin.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createUnplugin } from 'unplugin';
import { serverRequire } from '@storybook/core-common';
import { compile } from './compile';
import { createUnplugin } from "unplugin";
import { serverRequire } from "@storybook/core-common";
import { compile } from "./compile";

// adapted from https://stackblitz.com/edit/github-h2rgfk?file=README.md

export const DYNAMIC_STORIES_REGEX = /\.dynamic\.[tj]sx?/;

export const unplugin = createUnplugin(() => {
return {
name: 'unplugin-dynamic-stories',
enforce: 'pre',
name: "unplugin-dynamic-stories",
enforce: "pre",
loadInclude(id) {
return DYNAMIC_STORIES_REGEX.test(id);
},
Expand All @@ -22,4 +22,4 @@ export const unplugin = createUnplugin(() => {
};
});

export const { webpack } = unplugin;
export const { webpack } = unplugin;
2 changes: 1 addition & 1 deletion packages/ecl-builder/src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export function interleave<T>(...inputs: T[][]): T[] {
{
length: Math.max(...inputs.map((i) => i.length)),
},
(_, i) => inputs.reduce((acc, r) => (r[i] ? acc.concat(r[i]) : acc), [])
(_, i) => inputs.reduce((acc, r) => (r[i] ? acc.concat(r[i]) : acc), []),
).flat();
}
2 changes: 1 addition & 1 deletion packages/ecl-builder/src/components/CopyValueSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function CopyValueSet({ expression }: CopyValueSetProps) {
const valueSetUri = useMemo(
() =>
`http://snomed.info/sct?fhir_vs=ecl/${encodeURIComponent(expression)}`,
[expression]
[expression],
);
return (
<CopyToClipboard text={valueSetUri}>
Expand Down
6 changes: 3 additions & 3 deletions packages/ecl-builder/src/components/ExpressionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface ExpressionBuilderOptions {
}

export const OptionsContext = createContext<ExpressionBuilderOptions>(
applyDefaultOptions({})
applyDefaultOptions({}),
);

/**
Expand All @@ -62,7 +62,7 @@ export default function ExpressionBuilder({
[expression, setExpression] = useState(initialExpression);

useEffect(() => {
setExpression(initialExpression)
setExpression(initialExpression);
}, [initialExpression]);

function handleChange(newExpression: string) {
Expand Down Expand Up @@ -129,7 +129,7 @@ export default function ExpressionBuilder({
* Default configuration options.
*/
function applyDefaultOptions(
options: Partial<ExpressionBuilderOptions>
options: Partial<ExpressionBuilderOptions>,
): ExpressionBuilderOptions {
return {
terminologyServerUrl: "https://tx.ontoserver.csiro.au/fhir",
Expand Down
10 changes: 5 additions & 5 deletions packages/ecl-builder/src/components/ExpressionResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function ExpressionResultContent({
{ data, isFetching } = useValueSetExpansion(
terminologyServerUrl,
buildExpandParams(expression, maxSearchResults, includeInactives),
{ suspense: true }
{ suspense: true },
);
if (!data) {
console.warn("No error, but also no data");
Expand Down Expand Up @@ -126,7 +126,7 @@ function ExpressionResultContent({
* Default configuration options.
*/
function applyDefaultOptions(
options: Partial<ExpressionResultOptions>
options: Partial<ExpressionResultOptions>,
): ExpressionResultOptions {
return {
terminologyServerUrl: "https://tx.ontoserver.csiro.au/fhir",
Expand All @@ -139,13 +139,13 @@ function applyDefaultOptions(
function buildExpandParams(
expression: string,
limit: number,
includeInactives: boolean
includeInactives: boolean,
): URLSearchParams {
const searchParams = new URLSearchParams(),
activeOnly = !includeInactives;
searchParams.set(
"url",
`${SCT_URI}?fhir_vs=ecl/${encodeURIComponent(expression)}`
`${SCT_URI}?fhir_vs=ecl/${encodeURIComponent(expression)}`,
);
// Designations are included, so that we can get the semantic tag from the FSN.
searchParams.set("includeDesignations", "true");
Expand All @@ -155,7 +155,7 @@ function buildExpandParams(
"elements",
"expansion.contains.code,expansion.contains.display," +
"expansion.contains.fullySpecifiedName," +
"expansion.contains.active"
"expansion.contains.active",
);
// Only active concepts are included in the results.
searchParams.set("activeOnly", activeOnly.toString());
Expand Down
4 changes: 2 additions & 2 deletions packages/ecl-builder/src/components/ecl/BaseEclVisitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface BaseEclVisitorOptions {
// Options when removing the spans included in the removal context.
removalOptions?: {
// True if a white space should be maintained to the left of the first span to be removed.
preserveFirstWhiteSpace?: boolean
preserveFirstWhiteSpace?: boolean;
};
// True if within a refinement expression.
refinement: boolean;
Expand Down Expand Up @@ -67,7 +67,7 @@ export default class BaseEclVisitor extends ECLVisitor {
*/
addKeys(ctxs: VisualExpressionType[]): VisualExpressionType[] {
return ctxs.map((child) =>
isValidElement(child) ? cloneElement(child, { key: uuid.v4() }) : child
isValidElement(child) ? cloneElement(child, { key: uuid.v4() }) : child,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface ExpressionGroupingProps extends PropsWithChildren {
*/
function getStripingStyle(
theme: Theme,
levels: number
levels: number,
): Record<string, unknown> {
let style = {};
for (let i = 0; i < levels; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class ExpressionParserErrorListener implements ErrorListener {
offendingSymbol: Token,
line: number,
column: number,
msg: string
msg: string,
) {
throw new Error(`Syntax error at line ${line}, column ${column}: ${msg}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ describe("applyUpdates", () => {
const transformer = new ExpressionTransformer(
"(<< 195967001 |Asthma| OR (< 19829001 |Pulmonary disease| AND < 40733004 |Infection|))",
(expression) => {
expect(expression).toEqual("(<< 195967001 |Asthma| OR < 40733004 |Infection|)");
expect(expression).toEqual(
"(<< 195967001 |Asthma| OR < 40733004 |Infection|)",
);
done();
},
() => undefined,
Expand All @@ -161,6 +163,9 @@ describe("applyUpdates", () => {
getText: () => ")",
} as ParserRuleContext,
];
transformer.applyUpdates(contexts, "", { collapseWhiteSpaceLeft: true, preserveFirstWhiteSpace: true });
transformer.applyUpdates(contexts, "", {
collapseWhiteSpaceLeft: true,
preserveFirstWhiteSpace: true,
});
});
});
Loading

0 comments on commit 1ab3dbd

Please sign in to comment.