Skip to content

Commit

Permalink
EsLint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-lli committed Jan 6, 2025
1 parent b3131da commit 7946fb2
Show file tree
Hide file tree
Showing 29 changed files with 1,072 additions and 1,120 deletions.
2 changes: 1 addition & 1 deletion build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pipeline {
"<a href=${BUILD_URL}artifact/integrations/standalone/build/mock.html>&raquo; Data Class Editor Mock</a>"

withChecks('ESLint') {
recordIssues enabledForFailure: true, publishAllIssues: true, aggregatingResults: true, tools: [esLint(pattern: 'packages/**/eslint.xml,integrations/**/eslint.xml')], qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]
recordIssues enabledForFailure: true, publishAllIssues: true, aggregatingResults: true, tools: [esLint(pattern: 'eslint.xml')], qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]
}

withChecks('Test') {
Expand Down
46 changes: 0 additions & 46 deletions config/base.eslintrc.json

This file was deleted.

16 changes: 16 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import tseslint from 'typescript-eslint';
import config from '@axonivy/eslint-config';

export default tseslint.config(
...config.base,
// TypeScript recommended configs
{
name: 'typescript-eslint',
languageOptions: {
parserOptions: {
project: true, // Uses tsconfig.json from current directory
tsconfigRootDir: import.meta.dirname
}
}
}
);
9 changes: 0 additions & 9 deletions integrations/standalone/.eslintrc.cjs

This file was deleted.

7 changes: 1 addition & 6 deletions integrations/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
"package": "vite build",
"type": "tsc --noEmit",
"dev": "vite",
"serve": "vite preview",
"lint": "eslint --ext .ts,.tsx ./src",
"lint:fix": "eslint --fix --ext .ts,.tsx ./src",
"webtest:mock": "npx playwright test -c ./tests/mock",
"webtest:engine": "npx playwright test -c ./tests/integration",
"webtest:screenshot": "npx playwright test -c ./tests/screenshots"
"serve": "vite preview"
},
"type": "module"
}
22 changes: 13 additions & 9 deletions integrations/standalone/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ import { webSocketConnection, type Connection } from '@axonivy/jsonrpc';
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import './index.css';
import { URLParams } from './url-helper';
import { appParam, directSaveParam, fileParam, pmvParam, readonlyParam, themeParam, webSocketBaseParam } from './url-helper';

export async function start(): Promise<void> {
const server = URLParams.webSocketBase();
const app = URLParams.app();
const pmv = URLParams.pmv();
const file = URLParams.file();
const directSave = URLParams.directSave();
const theme = URLParams.theme();
const readonly = URLParams.readonly();
const server = webSocketBaseParam();
const app = appParam();
const pmv = pmvParam();
const file = fileParam();
const directSave = directSaveParam();
const theme = themeParam();
const readonly = readonlyParam();
const queryClient = initQueryClient();
const root = ReactDOM.createRoot(document.getElementById('root')!);
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error('Root element not found.');
}
const root = ReactDOM.createRoot(rootElement);

root.render(
<React.StrictMode>
Expand Down
7 changes: 6 additions & 1 deletion integrations/standalone/src/mock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import * as ReactDOM from 'react-dom/client';
import './index.css';
import { DataClassClientMock } from './mock/dataclass-client-mock';

const root = ReactDOM.createRoot(document.getElementById('root')!);
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error('Root element not found.');
}
const root = ReactDOM.createRoot(rootElement);

const client = new DataClassClientMock();
const queryClient = initQueryClient();

Expand Down
96 changes: 47 additions & 49 deletions integrations/standalone/src/url-helper.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,59 @@
export namespace URLParams {
export function parameter(key: string): string | undefined {
const param = new URLSearchParams(window.location.search).get(key);
return param !== null ? decodeURIComponent(param) : undefined;
}
export function parameter(key: string): string | undefined {
const param = new URLSearchParams(window.location.search).get(key);
return param !== null ? decodeURIComponent(param) : undefined;
}

export function app(): string {
return parameter('app') ?? '';
}
export function appParam(): string {
return parameter('app') ?? '';
}

export function pmv(): string {
return parameter('pmv') ?? '';
}
export function pmvParam(): string {
return parameter('pmv') ?? '';
}

export function file(): string {
return parameter('file') ?? '';
}
export function fileParam(): string {
return parameter('file') ?? '';
}

export function directSave(): boolean {
return parameter('directSave') !== undefined;
export function directSaveParam(): boolean {
return parameter('directSave') !== undefined;
}

export function themeParam(): 'dark' | 'light' {
const theme = parameter('theme');
if (theme === 'dark') {
return theme;
}
return 'light';
}

export function theme(): 'dark' | 'light' {
const theme = parameter('theme');
if (theme === 'dark') {
return theme;
}
return 'light';
export function readonlyParam(): boolean {
const readonly = parameter('readonly');
if (readonly === 'true') {
return true;
}
return false;
}

export function webSocketBaseParam(): string {
return `${isSecureConnection() ? 'wss' : 'ws'}://${server()}`;
}

export function readonly(): boolean {
const readonly = parameter('readonly');
if (readonly === 'true') {
return true;
}
const isSecureConnection = () => {
const secureParam = parameter('secure');
if (secureParam === 'true') {
return true;
}
if (secureParam === 'false') {
return false;
}
return window.location.protocol === 'https:';
};

export function webSocketBase(): string {
return `${isSecureConnection() ? 'wss' : 'ws'}://${server()}`;
}
const server = () => {
return parameter('server') ?? basePath();
};

const isSecureConnection = () => {
const secureParam = parameter('secure');
if (secureParam === 'true') {
return true;
}
if (secureParam === 'false') {
return false;
}
return window.location.protocol === 'https:';
};

const server = () => {
return parameter('server') ?? basePath();
};

const basePath = () => {
return 'localhost:8081';
};
}
const basePath = () => {
return 'localhost:8081';
};
Loading

0 comments on commit 7946fb2

Please sign in to comment.