Skip to content

Commit

Permalink
chore: Update ESLint and Vitest config (#1854)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins authored Jun 29, 2024
1 parent 154ee80 commit 3611615
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 42 deletions.
7 changes: 2 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// @ts-check

// @ts-ignore Needed due to moduleResolution Node vs Bundler
// @ts-expect-error
import { tanstackConfig } from '@tanstack/config/eslint'

export default [
...tanstackConfig,
{
name: 'tanstack/local',
name: 'tanstack/temp',
rules: {
'ts/ban-types': 'off',
'ts/require-await': 'off',
'no-empty': 'off',
'no-prototype-builtins': 'off',
'no-shadow': 'off',
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.5.16",
"@rollup/plugin-replace": "^5.0.7",
"@tanstack/config": "^0.8.6",
"@tanstack/config": "^0.9.0",
"@types/node": "^20.14.7",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src",
"test:types": "tsc --noEmit",
"test:unit": "vitest --typecheck",
"test:unit": "vitest",
"test:unit:dev": "pnpm run test:unit --watch",
"test:build": "publint --strict",
"build": "vite build"
Expand Down
7 changes: 3 additions & 4 deletions packages/react-router/src/scroll-restoration.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as React from 'react'

const useLayoutEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect

import { useRouter } from './useRouter'
import { functionalUpdate } from './utils'
import type { ParsedLocation } from './location'
import type { NonNullableUpdater } from './utils'

const useLayoutEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect

const windowKey = 'window'
const delimiter = '___'

Expand Down
6 changes: 4 additions & 2 deletions packages/react-router/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
import react from '@vitejs/plugin-react'
import packageJson from './package.json'

const config = defineConfig({
plugins: [react()],
test: {
globals: true,
name: 'react-router',
name: packageJson.name,
dir: './tests',
watch: false,
environment: 'jsdom',
typecheck: { enabled: true },
},
})

Expand Down
2 changes: 1 addition & 1 deletion packages/router-cli/src/watch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'
import chokidar from 'chokidar'
import { generator, getConfig } from '@tanstack/router-generator'

Expand Down
2 changes: 1 addition & 1 deletion packages/router-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src",
"test:types": "tsc --noEmit",
"test:unit": "vitest --watch=false",
"test:unit": "vitest",
"test:build": "publint --strict",
"build": "vite build"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/router-generator/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path'
import { existsSync, readFileSync } from 'fs'
import path from 'node:path'
import { existsSync, readFileSync } from 'node:fs'
import { z } from 'zod'

export const configSchema = z.object({
Expand Down
6 changes: 3 additions & 3 deletions packages/router-generator/src/generator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import * as fs from 'fs'
import * as fsp from 'fs/promises'
import path from 'node:path'
import * as fs from 'node:fs'
import * as fsp from 'node:fs/promises'
import * as prettier from 'prettier'
import { cleanPath, logging, trimPathLeft } from './utils'
import type { Config } from './config'
Expand Down
10 changes: 9 additions & 1 deletion packages/router-generator/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
import packageJson from './package.json'

const config = defineConfig({})
const config = defineConfig({
test: {
name: packageJson.name,
dir: './tests',
watch: false,
typecheck: { enabled: true },
},
})

export default mergeConfig(
config,
Expand Down
2 changes: 1 addition & 1 deletion packages/router-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"scripts": {
"clean": "rimraf ./dist && rimraf ./coverage",
"test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit",
"test:unit": "vitest --typecheck --watch=false",
"test:unit": "vitest",
"test:eslint": "eslint ./src",
"test:types": "tsc --noEmit",
"test:build": "publint --strict",
Expand Down
10 changes: 9 additions & 1 deletion packages/router-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
import packageJson from './package.json'

const config = defineConfig({})
const config = defineConfig({
test: {
name: packageJson.name,
dir: './tests',
watch: false,
typecheck: { enabled: true },
},
})

export default mergeConfig(
config,
Expand Down
2 changes: 1 addition & 1 deletion packages/start-vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"scripts": {
"clean": "rimraf ./dist && rimraf ./coverage",
"test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit",
"test:unit": "vitest --typecheck --watch=false",
"test:unit": "vitest",
"test:eslint": "eslint ./src",
"test:types": "tsc --noEmit",
"test:build": "publint --strict",
Expand Down
10 changes: 9 additions & 1 deletion packages/start-vite-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
import packageJson from './package.json'

const config = defineConfig({})
const config = defineConfig({
test: {
name: packageJson.name,
dir: './tests',
watch: false,
typecheck: { enabled: true },
},
})

export default mergeConfig(
config,
Expand Down
2 changes: 1 addition & 1 deletion packages/start/src/client/headers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OutgoingHttpHeaders } from 'http2'
import type { OutgoingHttpHeaders } from 'node:http2'

// A utility function to turn HeadersInit into an object
export function headersInitToObject(
Expand Down
2 changes: 1 addition & 1 deletion packages/start/src/server/createRequestHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pipeline } from 'stream/promises'
import { pipeline } from 'node:stream/promises'
import {
type AnyRouter,
type Manifest,
Expand Down
2 changes: 1 addition & 1 deletion packages/start/src/server/defaultStreamHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PassThrough } from 'stream'
import { PassThrough } from 'node:stream'
import * as React from 'react'
import { isbot } from 'isbot'
import ReactDOMServer from 'react-dom/server'
Expand Down
Loading

0 comments on commit 3611615

Please sign in to comment.