From 4a0eb006ba76c78c2ea1ca5bc7ead7bacf5b24eb Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Fri, 6 Mar 2026 10:34:34 +0100 Subject: [PATCH 1/2] apply eslint and typescript cheks on tests too --- eslint.config.js | 2 +- package.json | 4 ++-- test/helpers/dataframe/array.test.ts | 6 ++++- test/providers/DataProvider.test.tsx | 3 +++ tsconfig.build.json | 28 ++++++++++++++++++++++ tsconfig.eslint.json | 4 ---- tsconfig.json | 35 +++++++++------------------- 7 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 tsconfig.build.json delete mode 100644 tsconfig.eslint.json diff --git a/eslint.config.js b/eslint.config.js index b69dddd4..24d22ea0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -76,7 +76,7 @@ export default defineConfig([ files: ['**/*.{ts,tsx}'], languageOptions: { parserOptions: { - project: ['./tsconfig.eslint.json'], + project: ['./tsconfig.json'], tsconfigRootDir: import.meta.dirname, }, }, diff --git a/package.json b/package.json index f3098c14..441ca938 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ ], "scripts": { "build:bundle": "vite build", - "build:types": "tsc -b", + "build:types": "tsc -b tsconfig.build.json", "build": "npm run build:bundle && npm run build:types", "coverage": "vitest run --coverage --coverage.include=src --coverage.exclude=src/**/*.stories.tsx", "lint": "eslint", @@ -45,7 +45,7 @@ "prepublishOnly": "npm run build", "storybook": "storybook dev -p 6006 --disable-telemetry", "test": "vitest run", - "typecheck": "tsc --noEmit" + "typecheck": "tsc" }, "devDependencies": { "@eslint/compat": "2.0.2", diff --git a/test/helpers/dataframe/array.test.ts b/test/helpers/dataframe/array.test.ts index eb908025..6af71cf6 100644 --- a/test/helpers/dataframe/array.test.ts +++ b/test/helpers/dataframe/array.test.ts @@ -105,7 +105,11 @@ describe('arrayDataFrame', () => { df.eventTarget?.addEventListener('update', resolveListener) // when a property of an array element (a cell) is changed, no event is dispatched, because the proxy is shallow - df._array[0].name = 'Alicia' + const originalRow = df._array[0] + if (originalRow === undefined) { + throw new Error('Original row is undefined') + } + originalRow.name = 'Alicia' expect(resolveListener).toHaveBeenCalledTimes(0) expect(df.getCell({ row: 0, column: 'name' })?.value).toBe('Alicia') }) diff --git a/test/providers/DataProvider.test.tsx b/test/providers/DataProvider.test.tsx index aa7eb39c..1548e4e6 100644 --- a/test/providers/DataProvider.test.tsx +++ b/test/providers/DataProvider.test.tsx @@ -198,6 +198,9 @@ describe('DataProvider', () => { expect(getByTestId('column-descriptors').textContent).toBe(initialColumnDescriptors) // Change the column descriptors in the data frame data.columnDescriptors.push({ name: 'c', sortable: true }) + if (data.columnDescriptors[0] === undefined || data.columnDescriptors[1] === undefined) { + throw new Error('Not enough column descriptors') + } data.columnDescriptors[0].name = 'x' data.columnDescriptors[1].sortable = true // force a re-render without changing the data frame instance diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..2f20abbf --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", + "target": "esnext", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + "moduleResolution": "bundler", + "isolatedModules": true, + "moduleDetection": "force", + "jsx": "react-jsx", + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true, + "noUncheckedIndexedAccess": true, + + "rootDir": "src", + "outDir": "dist/types", + "emitDeclarationOnly": true, + "declaration": true + }, + "include": ["src"] +} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json deleted file mode 100644 index 570d6ca3..00000000 --- a/tsconfig.eslint.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "test", "**/*.js", "**/*.ts", "**/*.tsx", "**/.storybook/*.ts"] -} diff --git a/tsconfig.json b/tsconfig.json index 2f20abbf..e21faa7f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,28 +1,15 @@ { + "extends": "./tsconfig.build.json", "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", - "target": "esnext", - "useDefineForClassFields": true, - "lib": ["ES2022", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - "moduleResolution": "bundler", - "isolatedModules": true, - "moduleDetection": "force", - "jsx": "react-jsx", - - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, - "noUncheckedIndexedAccess": true, - - "rootDir": "src", - "outDir": "dist/types", - "emitDeclarationOnly": true, - "declaration": true + "noEmit": true, + "rootDir": "." }, - "include": ["src"] + "include": [ + "src", + "test", + "**/*.js", + "**/*.ts", + "**/*.tsx", + "**/.storybook/*.ts" + ] } From 9489ef6ad570c2f628ab6706c8731f0cf62cd758 Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Fri, 6 Mar 2026 17:24:06 +0100 Subject: [PATCH 2/2] simplify config --- package.json | 2 +- tsconfig.build.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 441ca938..d0afa481 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ ], "scripts": { "build:bundle": "vite build", - "build:types": "tsc -b tsconfig.build.json", + "build:types": "tsc -p tsconfig.build.json", "build": "npm run build:bundle && npm run build:types", "coverage": "vitest run --coverage --coverage.include=src --coverage.exclude=src/**/*.stories.tsx", "lint": "eslint", diff --git a/tsconfig.build.json b/tsconfig.build.json index 2f20abbf..c2998055 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", "target": "esnext", "useDefineForClassFields": true, "lib": ["ES2022", "DOM", "DOM.Iterable"],