Skip to content

Commit 32f1635

Browse files
authored
apply eslint and typescript checks on tests too (#464)
* apply eslint and typescript cheks on tests too * simplify config
1 parent 89d5fb9 commit 32f1635

7 files changed

Lines changed: 49 additions & 32 deletions

File tree

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default defineConfig([
7676
files: ['**/*.{ts,tsx}'],
7777
languageOptions: {
7878
parserOptions: {
79-
project: ['./tsconfig.eslint.json'],
79+
project: ['./tsconfig.json'],
8080
tsconfigRootDir: import.meta.dirname,
8181
},
8282
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
],
3838
"scripts": {
3939
"build:bundle": "vite build",
40-
"build:types": "tsc -b",
40+
"build:types": "tsc -p tsconfig.build.json",
4141
"build": "npm run build:bundle && npm run build:types",
4242
"coverage": "vitest run --coverage --coverage.include=src --coverage.exclude=src/**/*.stories.tsx",
4343
"lint": "eslint",
4444
"lint:fix": "eslint --fix",
4545
"prepublishOnly": "npm run build",
4646
"storybook": "storybook dev -p 6006 --disable-telemetry",
4747
"test": "vitest run",
48-
"typecheck": "tsc --noEmit"
48+
"typecheck": "tsc"
4949
},
5050
"devDependencies": {
5151
"@eslint/compat": "2.0.2",

test/helpers/dataframe/array.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ describe('arrayDataFrame', () => {
105105
df.eventTarget?.addEventListener('update', resolveListener)
106106

107107
// when a property of an array element (a cell) is changed, no event is dispatched, because the proxy is shallow
108-
df._array[0].name = 'Alicia'
108+
const originalRow = df._array[0]
109+
if (originalRow === undefined) {
110+
throw new Error('Original row is undefined')
111+
}
112+
originalRow.name = 'Alicia'
109113
expect(resolveListener).toHaveBeenCalledTimes(0)
110114
expect(df.getCell({ row: 0, column: 'name' })?.value).toBe('Alicia')
111115
})

test/providers/DataProvider.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ describe('DataProvider', () => {
198198
expect(getByTestId('column-descriptors').textContent).toBe(initialColumnDescriptors)
199199
// Change the column descriptors in the data frame
200200
data.columnDescriptors.push({ name: 'c', sortable: true })
201+
if (data.columnDescriptors[0] === undefined || data.columnDescriptors[1] === undefined) {
202+
throw new Error('Not enough column descriptors')
203+
}
201204
data.columnDescriptors[0].name = 'x'
202205
data.columnDescriptors[1].sortable = true
203206
// force a re-render without changing the data frame instance

tsconfig.build.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"useDefineForClassFields": true,
5+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
6+
"module": "ESNext",
7+
"skipLibCheck": true,
8+
9+
"moduleResolution": "bundler",
10+
"isolatedModules": true,
11+
"moduleDetection": "force",
12+
"jsx": "react-jsx",
13+
14+
"strict": true,
15+
"noUnusedLocals": true,
16+
"noUnusedParameters": true,
17+
"noFallthroughCasesInSwitch": true,
18+
"noUncheckedSideEffectImports": true,
19+
"noUncheckedIndexedAccess": true,
20+
21+
"rootDir": "src",
22+
"outDir": "dist/types",
23+
"emitDeclarationOnly": true,
24+
"declaration": true
25+
},
26+
"include": ["src"]
27+
}

tsconfig.eslint.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

tsconfig.json

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
{
2+
"extends": "./tsconfig.build.json",
23
"compilerOptions": {
3-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
4-
"target": "esnext",
5-
"useDefineForClassFields": true,
6-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
7-
"module": "ESNext",
8-
"skipLibCheck": true,
9-
10-
"moduleResolution": "bundler",
11-
"isolatedModules": true,
12-
"moduleDetection": "force",
13-
"jsx": "react-jsx",
14-
15-
"strict": true,
16-
"noUnusedLocals": true,
17-
"noUnusedParameters": true,
18-
"noFallthroughCasesInSwitch": true,
19-
"noUncheckedSideEffectImports": true,
20-
"noUncheckedIndexedAccess": true,
21-
22-
"rootDir": "src",
23-
"outDir": "dist/types",
24-
"emitDeclarationOnly": true,
25-
"declaration": true
4+
"noEmit": true,
5+
"rootDir": "."
266
},
27-
"include": ["src"]
7+
"include": [
8+
"src",
9+
"test",
10+
"**/*.js",
11+
"**/*.ts",
12+
"**/*.tsx",
13+
"**/.storybook/*.ts"
14+
]
2815
}

0 commit comments

Comments
 (0)