Skip to content

Commit

Permalink
test: fix linter errors and add linter to pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
snobbee committed Nov 22, 2024
1 parent 62ef92a commit 79bdabb
Show file tree
Hide file tree
Showing 68 changed files with 269 additions and 1,496 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pnpm run prettier-check
pnpm run lint
71 changes: 71 additions & 0 deletions eslint.global.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: [
"src/**/*.test.js",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.spec.ts",
],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
72 changes: 2 additions & 70 deletions packages/adapter-postgres/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,3 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
import eslintGlobalConfig from "../../eslint.global.mjs";

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: [
"src/**/*.test.js",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.spec.ts",
],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
export default [...eslintGlobalConfig];
72 changes: 2 additions & 70 deletions packages/adapter-sqlite/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,3 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
import eslintGlobalConfig from "../../eslint.global.mjs";

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: [
"src/**/*.test.js",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.spec.ts",
],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
export default [...eslintGlobalConfig];
72 changes: 2 additions & 70 deletions packages/adapter-sqljs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,3 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
import eslintGlobalConfig from "../../eslint.global.mjs";

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: [
"src/**/*.test.js",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.spec.ts",
],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
export default [...eslintGlobalConfig];
2 changes: 1 addition & 1 deletion packages/adapter-sqljs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export declare class Database {
callback: ParamsCallback,
done: () => void
): Database;
each(sql: string, callback: ParamsCallback, done: () => void): Database;
each(sql: string, callback: ParamsCallback, done: () => void): Database; // eslint-disable-line

/**
* Execute an SQL query, and returns the result.
Expand Down
72 changes: 2 additions & 70 deletions packages/adapter-supabase/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,71 +1,3 @@
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import typescript from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
import eslintGlobalConfig from "../../eslint.global.mjs";

export default [
// JavaScript and TypeScript files
{
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
languageOptions: {
parser: typescript,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
},
globals: {
// Add Node.js globals
NodeJS: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
module: "readonly",
require: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
...eslint.configs.recommended.rules,
...tseslint.configs.recommended.rules,
"prefer-const": "warn",
"no-constant-binary-expression": "error",

// Disable no-undef as TypeScript handles this better
"no-undef": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// Vitest configuration
{
files: [
"src/**/*.test.js",
"src/**/*.test.ts",
"src/**/*.spec.js",
"src/**/*.spec.ts",
],
plugins: {
vitest, // Register Vitest plugin
},
rules: {
...vitest.configs.recommended.rules,
},
},
// Add prettier as the last config to override other formatting rules
prettier,
];
export default [...eslintGlobalConfig];
Loading

0 comments on commit 79bdabb

Please sign in to comment.