Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint9 #246

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; Form 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') {
junit testDataPublishers: [[$class: 'StabilityTestDataPublisher']], testResults: 'packages/**/report.xml'
Expand Down
45 changes: 0 additions & 45 deletions config/base.eslintrc.json

This file was deleted.

127 changes: 127 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
import reactJsxRuntime from 'eslint-plugin-react/configs/jsx-runtime.js';
import reactHooks from 'eslint-plugin-react-hooks';
import reactCompiler from 'eslint-plugin-react-compiler';
import testingLibrary from 'eslint-plugin-testing-library';
import playwright from 'eslint-plugin-playwright';
import pluginQuery from '@tanstack/eslint-plugin-query';
import globals from 'globals';

export default tseslint.config(
// Base eslint recommended config
eslint.configs.recommended,

// TypeScript recommended configs
...tseslint.configs.strict,
{
name: 'typescript-eslint',
languageOptions: {
parserOptions: {
project: true, // Uses tsconfig.json from current directory
tsconfigRootDir: import.meta.dirname
}
}
},

// React recommended configs
{
name: 'eslint-plugin-react/configs/recommended',
...reactRecommended
},
{
name: 'eslint-plugin-react/configs/jsx-runtime',
...reactJsxRuntime
},
{
name: 'eslint-plugin-react',
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true
}
},
globals: {
...globals.browser
}
},
settings: {
react: {
version: 'detect'
}
},
rules: {
'react/display-name': 'off'
}
},
{
name: 'eslint-plugin-react-hooks',
plugins: {
'react-hooks': reactHooks
},
rules: {
...reactHooks.configs.recommended.rules
}
},
{
name: 'eslint-plugin-react-compiler',
plugins: {
'react-compiler': reactCompiler
},
rules: {
'react-compiler/react-compiler': 'error'
}
},

// Testing library recommended configs
{
name: 'eslint-plugin-testing-library',
files: ['**/*.test.{js,mjs,cjs,ts,jsx,tsx}'],
...testingLibrary.configs['flat/react']
},

// Playwright recommended configs
{
name: 'eslint-plugin-playwright',
files: ['**/*.spec.{js,mjs,cjs,ts,jsx,tsx}'],
...playwright.configs['flat/recommended'],
rules: {
...playwright.configs['flat/recommended'].rules,
'playwright/expect-expect': 'off'
}
},

// Tanstack recommended configs
{
name: '@tanstack/eslint-plugin-query',
plugins: {
'@tanstack/query': pluginQuery
},
rules: {
...pluginQuery.configs.recommended.rules
}
},

// Project-specific overrides and custom rules
{
name: 'ingored-files',
ignores: [
'**/node_modules/**',
'eslint.config.*',
'**/vite*.config.*',
'**/playwright.config.*',
'**/*.d.ts',
'**/lib/*',
'**/build/*',
'**/schemaCodegen.cjs'
]
},
{
name: 'packages/core',
files: ['packages/core/**/*.{js,mjs,cjs,ts,jsx,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off'
}
}
);
9 changes: 0 additions & 9 deletions integrations/standalone/.eslintrc.cjs

This file was deleted.

4 changes: 1 addition & 3 deletions integrations/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,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"
"serve": "vite preview"
},
"type": "module",
"browserslist": {
Expand Down
26 changes: 15 additions & 11 deletions integrations/standalone/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import { ThemeProvider, ReadonlyProvider, toast, Toaster, Spinner, Flex } from '
import { webSocketConnection, type Connection } from '@axonivy/jsonrpc';
import React from 'react';
import { createRoot } from 'react-dom/client';
import { URLParams } from './url-helper';
import { webSocketBase, appParam, pmvParam, fileParam, directSaveParam, themeParam, readonlyParam } 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();
export async function start() {
const server = webSocketBase();
const app = appParam();
const pmv = pmvParam();
const file = fileParam();
const directSave = directSaveParam();
const theme = themeParam();
const readonly = readonlyParam();
const queryClient = initQueryClient();
const root = createRoot(document.getElementById('root')!);
const rootElement = document.getElementById('root');
if (rootElement === null) {
throw new Error('Root element not found');
}
const root = createRoot(rootElement);

root.render(
<React.StrictMode>
Expand Down Expand Up @@ -53,7 +57,7 @@ export async function start(): Promise<void> {
return initialize(connection);
};

webSocketConnection<FormClientJsonRpc>(FormClientJsonRpc.webSocketUrl(server)).listen({
await webSocketConnection<FormClientJsonRpc>(FormClientJsonRpc.webSocketUrl(server)).listen({
onConnection: initialize,
onReconnect: reconnect,
logger: { log: console.log, info: toast.info, warn: toast.warning, error: toast.error }
Expand Down
8 changes: 6 additions & 2 deletions integrations/standalone/src/mock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import React from 'react';
import { createRoot } from 'react-dom/client';
import { FormClientMock } from './mock/form-client-mock';

export async function start(): Promise<void> {
export function start() {
const formClient = new FormClientMock();
const queryClient = initQueryClient();

createRoot(document.getElementById('root')!).render(
const root = document.getElementById('root');
if (root === null) {
throw new Error('Root element not found');
}
createRoot(root).render(
<React.StrictMode>
<ThemeProvider defaultTheme='light'>
<ClientContextProvider client={formClient}>
Expand Down
10 changes: 5 additions & 5 deletions integrations/standalone/src/mock/form-client-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {
FormSaveData,
ValidationResult
} from '@axonivy/form-editor-protocol';
import { MetaMock } from './meta-mock';
import { validateMock } from './validation-mock';
import { Emitter } from '@axonivy/jsonrpc';
import { data } from './data-mock';
import { ATTRIBUTES, CMSQUICKACTIONS, COMPOSITE_PARAMS, COMPOSITES } from './meta-mock';

export class FormClientMock implements FormClient {
private formData: FormEditor = {
Expand Down Expand Up @@ -41,13 +41,13 @@ export class FormClientMock implements FormClient {
meta<TMeta extends keyof FormMetaRequestTypes>(path: TMeta): Promise<FormMetaRequestTypes[TMeta][1]> {
switch (path) {
case 'meta/data/attributes':
return Promise.resolve(MetaMock.ATTRIBUTES);
return Promise.resolve(ATTRIBUTES);
case 'meta/composite/all':
return Promise.resolve(MetaMock.COMPOSITES);
return Promise.resolve(COMPOSITES);
case 'meta/composite/params':
return Promise.resolve(MetaMock.COMPOSITE_PARAMS);
return Promise.resolve(COMPOSITE_PARAMS);
case 'meta/cms/cmsQuickActions':
return Promise.resolve(MetaMock.CMSQUICKACTIONS);
return Promise.resolve(CMSQUICKACTIONS);
case 'meta/cms/executeCmsQuickAction':
return Promise.resolve("#{ivy.cms.co('/Labels/Firstname')}");
case 'meta/data/logic':
Expand Down
Loading
Loading