eslint-plugin-prisma-nestjs-graphql
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -103,13 +103,16 @@ "use strict"; | ||
fix: function (fixer) { | ||
const imports = openResolvers.map(r => r.type.replace('[', '').replace(']', '')); | ||
const multiImports = openResolvers | ||
const importNode = context | ||
.getSourceCode() | ||
.ast.body.find(i => i.type === 'ImportDeclaration' && | ||
i.source.value.split('/').pop() === | ||
'nestjs-graphql'); | ||
const existingImports = importNode.specifiers.map(i => i.imported.name); | ||
const entityImports = openResolvers.map(r => r.type.replace('[', '').replace(']', '')); | ||
const findManyImports = openResolvers | ||
.filter(i => -1 !== i.type.indexOf('[')) | ||
.map(r => r.type.replace('[', '').replace(']', '')); | ||
const importFix = fixer.insertTextBefore(decorator, `import { | ||
${imports.join(', ')}, | ||
${multiImports | ||
.map(i => 'FindMany' + i + 'Args, ') | ||
.join('')} | ||
} from '@prisma/client/nestjs-graphql' | ||
`); | ||
.map(r => r.type.replace('[', '').replace(']', '')) | ||
.map(i => 'FindMany' + i + 'Args'); | ||
const newImports = [...entityImports, ...findManyImports]; | ||
const missingImports = newImports.filter(ni => !existingImports.includes(ni)); | ||
const importFixer = fixer.insertTextAfter(importNode.specifiers.pop(), missingImports.map(i => '\n,' + i).join('')); | ||
const txt = `\n\n\n // FIELDRESOLVERS \n` + | ||
@@ -134,3 +137,3 @@ openResolvers | ||
const resolverFix = fixer.insertTextAfter(classNode.body.body.find(b => b.key.name === 'constructor'), txt); | ||
return [importFix, resolverFix]; | ||
return [importFixer, resolverFix]; | ||
}, | ||
@@ -137,0 +140,0 @@ }); |
{ | ||
"name": "eslint-plugin-prisma-nestjs-graphql", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "eslint plugin for prisma & nestjs & graphql setups to not forget resolvers etc.", | ||
@@ -22,3 +22,3 @@ "main": "./dist/index.js", | ||
"@typescript-eslint/eslint-plugin": "^5.6.0", | ||
"@typescript-eslint/parser": "^5.6.0", | ||
"@typescript-eslint/parser": "^5.10.0", | ||
"@typescript-eslint/typescript-estree": "^5.6.0", | ||
@@ -25,0 +25,0 @@ "fs": "^0.0.1-security", |
@@ -30,4 +30,2 @@ # eslint-plugin-prisma-nestjs-graphql | ||
- Imports are added automatically (and naively) => if an import in a resolver file already exists before linting and the same one gets added by the linter => it will exist twice => error | ||
- Just delete the second (generated) import. | ||
- Paths are inflexible | ||
@@ -34,0 +32,0 @@ - Will hopefully be adressed in the future |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36666
145
37