Skip to content

Commit 79bdabb

Browse files
committed
test: fix linter errors and add linter to pre-commit hook
1 parent 62ef92a commit 79bdabb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+269
-1496
lines changed

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pnpm run prettier-check
2+
pnpm run lint

eslint.global.mjs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "@typescript-eslint/eslint-plugin";
3+
import typescript from "@typescript-eslint/parser";
4+
import prettier from "eslint-config-prettier";
5+
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
6+
7+
export default [
8+
// JavaScript and TypeScript files
9+
{
10+
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
11+
languageOptions: {
12+
parser: typescript,
13+
parserOptions: {
14+
ecmaVersion: "latest",
15+
sourceType: "module",
16+
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
17+
},
18+
globals: {
19+
// Add Node.js globals
20+
NodeJS: "readonly",
21+
console: "readonly",
22+
process: "readonly",
23+
Buffer: "readonly",
24+
__dirname: "readonly",
25+
__filename: "readonly",
26+
module: "readonly",
27+
require: "readonly",
28+
},
29+
},
30+
plugins: {
31+
"@typescript-eslint": tseslint,
32+
},
33+
rules: {
34+
...eslint.configs.recommended.rules,
35+
...tseslint.configs.recommended.rules,
36+
"prefer-const": "warn",
37+
"no-constant-binary-expression": "error",
38+
39+
// Disable no-undef as TypeScript handles this better
40+
"no-undef": "off",
41+
"@typescript-eslint/no-unsafe-function-type": "off",
42+
// Customize TypeScript rules
43+
"@typescript-eslint/no-explicit-any": "off",
44+
"@typescript-eslint/no-unused-vars": [
45+
"error",
46+
{
47+
argsIgnorePattern: "^_",
48+
varsIgnorePattern: "^_",
49+
ignoreRestSiblings: true,
50+
},
51+
],
52+
},
53+
},
54+
// Vitest configuration
55+
{
56+
files: [
57+
"src/**/*.test.js",
58+
"src/**/*.test.ts",
59+
"src/**/*.spec.js",
60+
"src/**/*.spec.ts",
61+
],
62+
plugins: {
63+
vitest, // Register Vitest plugin
64+
},
65+
rules: {
66+
...vitest.configs.recommended.rules,
67+
},
68+
},
69+
// Add prettier as the last config to override other formatting rules
70+
prettier,
71+
];
+2-70
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
1-
import eslint from "@eslint/js";
2-
import tseslint from "@typescript-eslint/eslint-plugin";
3-
import typescript from "@typescript-eslint/parser";
4-
import prettier from "eslint-config-prettier";
5-
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
62

7-
export default [
8-
// JavaScript and TypeScript files
9-
{
10-
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
11-
languageOptions: {
12-
parser: typescript,
13-
parserOptions: {
14-
ecmaVersion: "latest",
15-
sourceType: "module",
16-
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
17-
},
18-
globals: {
19-
// Add Node.js globals
20-
NodeJS: "readonly",
21-
console: "readonly",
22-
process: "readonly",
23-
Buffer: "readonly",
24-
__dirname: "readonly",
25-
__filename: "readonly",
26-
module: "readonly",
27-
require: "readonly",
28-
},
29-
},
30-
plugins: {
31-
"@typescript-eslint": tseslint,
32-
},
33-
rules: {
34-
...eslint.configs.recommended.rules,
35-
...tseslint.configs.recommended.rules,
36-
"prefer-const": "warn",
37-
"no-constant-binary-expression": "error",
38-
39-
// Disable no-undef as TypeScript handles this better
40-
"no-undef": "off",
41-
"@typescript-eslint/no-unsafe-function-type": "off",
42-
// Customize TypeScript rules
43-
"@typescript-eslint/no-explicit-any": "off",
44-
"@typescript-eslint/no-unused-vars": [
45-
"error",
46-
{
47-
argsIgnorePattern: "^_",
48-
varsIgnorePattern: "^_",
49-
ignoreRestSiblings: true,
50-
},
51-
],
52-
},
53-
},
54-
// Vitest configuration
55-
{
56-
files: [
57-
"src/**/*.test.js",
58-
"src/**/*.test.ts",
59-
"src/**/*.spec.js",
60-
"src/**/*.spec.ts",
61-
],
62-
plugins: {
63-
vitest, // Register Vitest plugin
64-
},
65-
rules: {
66-
...vitest.configs.recommended.rules,
67-
},
68-
},
69-
// Add prettier as the last config to override other formatting rules
70-
prettier,
71-
];
3+
export default [...eslintGlobalConfig];
+2-70
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
1-
import eslint from "@eslint/js";
2-
import tseslint from "@typescript-eslint/eslint-plugin";
3-
import typescript from "@typescript-eslint/parser";
4-
import prettier from "eslint-config-prettier";
5-
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
62

7-
export default [
8-
// JavaScript and TypeScript files
9-
{
10-
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
11-
languageOptions: {
12-
parser: typescript,
13-
parserOptions: {
14-
ecmaVersion: "latest",
15-
sourceType: "module",
16-
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
17-
},
18-
globals: {
19-
// Add Node.js globals
20-
NodeJS: "readonly",
21-
console: "readonly",
22-
process: "readonly",
23-
Buffer: "readonly",
24-
__dirname: "readonly",
25-
__filename: "readonly",
26-
module: "readonly",
27-
require: "readonly",
28-
},
29-
},
30-
plugins: {
31-
"@typescript-eslint": tseslint,
32-
},
33-
rules: {
34-
...eslint.configs.recommended.rules,
35-
...tseslint.configs.recommended.rules,
36-
"prefer-const": "warn",
37-
"no-constant-binary-expression": "error",
38-
39-
// Disable no-undef as TypeScript handles this better
40-
"no-undef": "off",
41-
"@typescript-eslint/no-unsafe-function-type": "off",
42-
// Customize TypeScript rules
43-
"@typescript-eslint/no-explicit-any": "off",
44-
"@typescript-eslint/no-unused-vars": [
45-
"error",
46-
{
47-
argsIgnorePattern: "^_",
48-
varsIgnorePattern: "^_",
49-
ignoreRestSiblings: true,
50-
},
51-
],
52-
},
53-
},
54-
// Vitest configuration
55-
{
56-
files: [
57-
"src/**/*.test.js",
58-
"src/**/*.test.ts",
59-
"src/**/*.spec.js",
60-
"src/**/*.spec.ts",
61-
],
62-
plugins: {
63-
vitest, // Register Vitest plugin
64-
},
65-
rules: {
66-
...vitest.configs.recommended.rules,
67-
},
68-
},
69-
// Add prettier as the last config to override other formatting rules
70-
prettier,
71-
];
3+
export default [...eslintGlobalConfig];
+2-70
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
1-
import eslint from "@eslint/js";
2-
import tseslint from "@typescript-eslint/eslint-plugin";
3-
import typescript from "@typescript-eslint/parser";
4-
import prettier from "eslint-config-prettier";
5-
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
62

7-
export default [
8-
// JavaScript and TypeScript files
9-
{
10-
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
11-
languageOptions: {
12-
parser: typescript,
13-
parserOptions: {
14-
ecmaVersion: "latest",
15-
sourceType: "module",
16-
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
17-
},
18-
globals: {
19-
// Add Node.js globals
20-
NodeJS: "readonly",
21-
console: "readonly",
22-
process: "readonly",
23-
Buffer: "readonly",
24-
__dirname: "readonly",
25-
__filename: "readonly",
26-
module: "readonly",
27-
require: "readonly",
28-
},
29-
},
30-
plugins: {
31-
"@typescript-eslint": tseslint,
32-
},
33-
rules: {
34-
...eslint.configs.recommended.rules,
35-
...tseslint.configs.recommended.rules,
36-
"prefer-const": "warn",
37-
"no-constant-binary-expression": "error",
38-
39-
// Disable no-undef as TypeScript handles this better
40-
"no-undef": "off",
41-
"@typescript-eslint/no-unsafe-function-type": "off",
42-
// Customize TypeScript rules
43-
"@typescript-eslint/no-explicit-any": "off",
44-
"@typescript-eslint/no-unused-vars": [
45-
"error",
46-
{
47-
argsIgnorePattern: "^_",
48-
varsIgnorePattern: "^_",
49-
ignoreRestSiblings: true,
50-
},
51-
],
52-
},
53-
},
54-
// Vitest configuration
55-
{
56-
files: [
57-
"src/**/*.test.js",
58-
"src/**/*.test.ts",
59-
"src/**/*.spec.js",
60-
"src/**/*.spec.ts",
61-
],
62-
plugins: {
63-
vitest, // Register Vitest plugin
64-
},
65-
rules: {
66-
...vitest.configs.recommended.rules,
67-
},
68-
},
69-
// Add prettier as the last config to override other formatting rules
70-
prettier,
71-
];
3+
export default [...eslintGlobalConfig];

packages/adapter-sqljs/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export declare class Database {
134134
callback: ParamsCallback,
135135
done: () => void
136136
): Database;
137-
each(sql: string, callback: ParamsCallback, done: () => void): Database;
137+
each(sql: string, callback: ParamsCallback, done: () => void): Database; // eslint-disable-line
138138

139139
/**
140140
* Execute an SQL query, and returns the result.
+2-70
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
1-
import eslint from "@eslint/js";
2-
import tseslint from "@typescript-eslint/eslint-plugin";
3-
import typescript from "@typescript-eslint/parser";
4-
import prettier from "eslint-config-prettier";
5-
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
62

7-
export default [
8-
// JavaScript and TypeScript files
9-
{
10-
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
11-
languageOptions: {
12-
parser: typescript,
13-
parserOptions: {
14-
ecmaVersion: "latest",
15-
sourceType: "module",
16-
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
17-
},
18-
globals: {
19-
// Add Node.js globals
20-
NodeJS: "readonly",
21-
console: "readonly",
22-
process: "readonly",
23-
Buffer: "readonly",
24-
__dirname: "readonly",
25-
__filename: "readonly",
26-
module: "readonly",
27-
require: "readonly",
28-
},
29-
},
30-
plugins: {
31-
"@typescript-eslint": tseslint,
32-
},
33-
rules: {
34-
...eslint.configs.recommended.rules,
35-
...tseslint.configs.recommended.rules,
36-
"prefer-const": "warn",
37-
"no-constant-binary-expression": "error",
38-
39-
// Disable no-undef as TypeScript handles this better
40-
"no-undef": "off",
41-
"@typescript-eslint/no-unsafe-function-type": "off",
42-
// Customize TypeScript rules
43-
"@typescript-eslint/no-explicit-any": "off",
44-
"@typescript-eslint/no-unused-vars": [
45-
"error",
46-
{
47-
argsIgnorePattern: "^_",
48-
varsIgnorePattern: "^_",
49-
ignoreRestSiblings: true,
50-
},
51-
],
52-
},
53-
},
54-
// Vitest configuration
55-
{
56-
files: [
57-
"src/**/*.test.js",
58-
"src/**/*.test.ts",
59-
"src/**/*.spec.js",
60-
"src/**/*.spec.ts",
61-
],
62-
plugins: {
63-
vitest, // Register Vitest plugin
64-
},
65-
rules: {
66-
...vitest.configs.recommended.rules,
67-
},
68-
},
69-
// Add prettier as the last config to override other formatting rules
70-
prettier,
71-
];
3+
export default [...eslintGlobalConfig];

0 commit comments

Comments
 (0)