Skip to content

Commit a0a3b44

Browse files
authored
feat(ci): upgrade eslint to v9 (#457)
1 parent c8a24e3 commit a0a3b44

30 files changed

+194
-131
lines changed

.build/build_and_prepare.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { execSync } from 'child_process'
22
import fs from 'fs'
33
import * as process from 'process'
4-
;(() => {
4+
5+
void (async () => {
56
const [pkg] = process.argv.slice(2)
67
if (!pkg) {
78
console.error(`Expected package name as an argument`)
@@ -22,14 +23,19 @@ import * as process from 'process'
2223

2324
fs.copyFileSync(`./packages/${packageName}/package.json`, './package.json')
2425

25-
const packageJson = require('../package.json')
26-
const version = require(`../packages/${packageName}/src/version.ts`).default
26+
const packageJson = (await import('../package.json').then(
27+
(m) => m.default,
28+
)) as any
29+
const version = (
30+
await import(`../packages/${packageName}/src/version` + '.ts')
31+
).default
2732
console.log(`Current ${packageName} package version is: ${version}`)
2833
packageJson.version = version
2934

30-
if (packageJson['dependencies']['@clickhouse/client-common']) {
31-
const commonVersion =
32-
require(`../packages/client-common/src/version.ts`).default
35+
if (packageJson.dependencies['@clickhouse/client-common']) {
36+
const commonVersion = (
37+
await import('../packages/client-common/src/version' + '.ts')
38+
).default
3339
console.log(`Updating client-common dependency to ${commonVersion}`)
3440
packageJson['dependencies']['@clickhouse/client-common'] = commonVersion
3541
}
@@ -48,7 +54,7 @@ import * as process from 'process'
4854
fs.writeFileSync(
4955
'./package.json',
5056
JSON.stringify(packageJson, null, 2) + '\n',
51-
'utf-8'
57+
'utf-8',
5258
)
5359
} catch (err) {
5460
console.error(err)

.eslintignore

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

.eslintrc.json

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

eslint.config.mjs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import js from '@eslint/js'
2+
import { defineConfig } from 'eslint/config'
3+
import pluginPrettier from 'eslint-plugin-prettier'
4+
import pluginExpectType from 'eslint-plugin-expect-type/configs/recommended'
5+
import globals from 'globals'
6+
import tseslint from 'typescript-eslint'
7+
8+
export default defineConfig(
9+
// Base ESLint recommended rules
10+
js.configs.recommended,
11+
// TypeScript-ESLint recommended rules with type checking
12+
...tseslint.configs.strict,
13+
...tseslint.configs.stylistic,
14+
// Enable type-aware linting for TypeScript files only
15+
{
16+
files: ['**/*.ts'],
17+
languageOptions: {
18+
parserOptions: {
19+
project: './tsconfig.all.json',
20+
},
21+
},
22+
},
23+
// Project-wide rules and plugins
24+
{
25+
plugins: {
26+
prettier: pluginPrettier,
27+
'expect-type': pluginExpectType,
28+
},
29+
rules: {
30+
'prettier/prettier': 'error',
31+
'@typescript-eslint/no-floating-promises': 'error',
32+
eqeqeq: 'error',
33+
'no-console': 'error',
34+
// Keep some rules relaxed until addressed in dedicated PRs
35+
'@typescript-eslint/no-explicit-any': 'off',
36+
'@typescript-eslint/consistent-type-imports': 'warn',
37+
'@typescript-eslint/array-type': 'off',
38+
},
39+
},
40+
// Test files overrides
41+
{
42+
files: ['./**/__tests__/**/*.ts'],
43+
rules: {
44+
'@typescript-eslint/no-explicit-any': 'off',
45+
'@typescript-eslint/no-non-null-assertion': 'off',
46+
'@typescript-eslint/ban-ts-comment': 'off',
47+
'no-constant-condition': 'off',
48+
'no-console': 'off',
49+
},
50+
},
51+
// Examples and benchmarks overrides
52+
{
53+
files: [
54+
'./**/examples/**/*.ts',
55+
'./**/benchmarks/**/*.ts',
56+
'.build/*.ts',
57+
'.scripts/*.ts',
58+
],
59+
rules: {
60+
'no-console': 'off',
61+
},
62+
},
63+
// Root-level config files (ESM in Node)
64+
{
65+
files: ['*.mjs', '**/*.mjs'],
66+
languageOptions: {
67+
sourceType: 'module',
68+
ecmaVersion: 'latest',
69+
globals: globals.node,
70+
parserOptions: {
71+
projectService: false,
72+
},
73+
},
74+
rules: {
75+
'@typescript-eslint/no-floating-promises': 'off',
76+
'@typescript-eslint/consistent-type-imports': 'off',
77+
'no-console': 'off',
78+
},
79+
},
80+
// Ignore build artifacts and externals
81+
{
82+
ignores: ['out', 'dist', 'node_modules', 'webpack'],
83+
},
84+
)

examples/async_insert_without_waiting.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ void (async () => {
3737
`,
3838
})
3939

40-
type Row = { id: number; name: string }
40+
interface Row {
41+
id: number
42+
name: string
43+
}
4144

4245
// Assume we have an event listener in our application that periodically receives incoming data,
4346
// that we would like to have inserted into ClickHouse.

examples/insert_values_and_functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ClickHouseSettings } from '@clickhouse/client'
22
import { createClient } from '@clickhouse/client' // or '@clickhouse/client-web'
33

4-
type Data = {
4+
interface Data {
55
id: string
66
timestamp: number
77
email: string

examples/long_running_queries_timeouts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async function checkQueryExists(
212212
return result.length > 0 && result[0].exists !== 0
213213
}
214214

215-
type QueryLogInfo = {
215+
interface QueryLogInfo {
216216
type:
217217
| 'QueryStart'
218218
| 'QueryFinish'

examples/select_json_each_row.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { createClient } from '@clickhouse/client' // or '@clickhouse/client-web'
22

3-
type Data = { number: string }
3+
interface Data {
4+
number: string
5+
}
46

57
void (async () => {
68
const client = createClient()

karma.config.jwt.cjs renamed to karma.config.jwt.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const webpackConfig = require('./webpack.dev.js')
1+
import webpackConfig from './webpack.dev.mjs'
22

33
const TEST_TIMEOUT_MS = 400_000
44

5-
module.exports = function (config) {
5+
export default function (config) {
66
config.set({
77
// base path that will be used to resolve all patterns (e.g. files, exclude)
88
basePath: '',

karma.config.cjs renamed to karma.config.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const webpackConfig = require('./webpack.dev.js')
1+
import webpackConfig from './webpack.dev.mjs'
22

33
const TEST_TIMEOUT_MS = 400_000
44

5-
module.exports = function (config) {
5+
export default function (config) {
66
config.set({
77
// base path that will be used to resolve all patterns (e.g. files, exclude)
88
basePath: '',
@@ -29,10 +29,7 @@ module.exports = function (config) {
2929
'sourcemap',
3030
],
3131
'packages/client-common/__tests__/utils/*.ts': ['webpack', 'sourcemap'],
32-
'packages/client-web/__tests__/unit/*.test.ts': [
33-
'webpack',
34-
'sourcemap',
35-
],
32+
'packages/client-web/__tests__/unit/*.test.ts': ['webpack', 'sourcemap'],
3633
'packages/client-web/__tests__/integration/*.ts': [
3734
'webpack',
3835
'sourcemap',

0 commit comments

Comments
 (0)