Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint Hanging #202

Closed
je-movers-market opened this issue Feb 8, 2024 · 8 comments
Closed

ESLint Hanging #202

je-movers-market opened this issue Feb 8, 2024 · 8 comments

Comments

@je-movers-market
Copy link

je-movers-market commented Feb 8, 2024

Describe the bug
I've installed ts-safeql as per docs on Prisma and read through the official SafeQL docs which seem to provide the same instructions. After doing so, my ESLint seems to have broken, hanging when running eslint . and providing no output.

To Reproduce
My .eslint.cjs contents for my SvelteKit project utilising Prisma:

require('dotenv').config();

/** @type { import("eslint").Linter.FlatConfig } */

module.exports = {
	root: true,
	extends: [
		'eslint:recommended',
		'plugin:@typescript-eslint/recommended',
		'plugin:svelte/recommended',
		'prettier'
	],
	parser: '@typescript-eslint/parser',
	plugins: ['@typescript-eslint', '@ts-safeql/eslint-plugin'],
	parserOptions: {
		sourceType: 'module',
		ecmaVersion: 2020,
		extraFileExtensions: ['.svelte'],
		project: './tsconfig.json'
	},
	env: {
		browser: true,
		es2017: true,
		node: true
	},
	overrides: [
		{
			files: ['*.svelte'],
			parser: 'svelte-eslint-parser',
			parserOptions: {
				parser: '@typescript-eslint/parser'
			}
		}
	],
	rules: {
		'@ts-safeql/check-sql': [
			'error',
			{
				connections: [
					{
						// The migrations path:
						connectionUrl: process.env.DB_URL,
						migrationsDir: './prisma/migrations',
						targets: [
							// This makes `prisma.$queryRaw` and `prisma.$executeRaw` commands linted
							{ tag: 'prismaClient.+($queryRaw|$executeRaw)', transform: '{type}[]' }
						]
					}
				]
			}
		]
	}
};

Expected behavior
I'd expect ESLint to function as normal and complete when running, as I've only followed the official instructions and configured it as documented from what I can see.

Desktop (please complete the following information):

  • OS: MacOS Sonoma 14.2
  • PostgreSQL version: 16
  • Version of @ts-safeql/eslint-plugin: ^2.0.3
@je-movers-market
Copy link
Author

I've tried using the debug flag and can see it hangs on this file:

eslint:linter Scope analysis successful: <MY_PROJECT_PATH>/src/lib/server/prisma.ts +0ms

That file itself contains code that matches the specified target:

prismaClient.+($queryRaw|$executeRaw)

Meaning it seems to be struggling at the point it reaches a file that contains the specified target.

@koka0012
Copy link

I'm facing the same issue, however I'm using NestJS with Prisma.

@notcodev
Copy link

I have the same issue

@notcodev
Copy link

I decided to debug the library code and came to the conclusion that this is not a problem with this particular library, but with a specific version of the "synckit" library used in this library, the check freezes on line 275 when calling the generateSync function, I found it useful in the issues of this library and found the issue related to this problem, at the moment the issue is already closed, so I think the solution to this problem is that you just need to update the dependencies

un-ts/synckit#128

@notcodev
Copy link

Ok, I figured it out, I've just installed Postgres via brew on my laptop and it worked

@notcodev
Copy link

To fix error with database name you should add string '/postgres' to your database url environment variable and make sure that your env variable value is not undefined

@Newbie012
Copy link
Collaborator

A reproduction would be helpful

@Newbie012
Copy link
Collaborator

Closing due to inactivity. If the issue still occurs, please open a new issue with a reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants