New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prisma-lint

Package Overview
Dependencies
Maintainers
5
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-lint - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

26

dist/rules/field-name-mapping-snake-case.js

@@ -8,3 +8,3 @@ import { z } from 'zod';

compoundWords: z.array(z.string()).optional(),
requirePrefix: z.string().optional(),
requireUnderscorePrefixForIds: z.boolean().optional(),
})

@@ -48,6 +48,7 @@ .strict()

*
* @example { requirePrefix: ["_"] }
* @example { requireUnderscorePrefixForIds: true }
* // good
* model PersistedQuery {
* fooId String @map(name: "_foo_id")
* id String @id @map(name: "_id")
* otherField String @map(name: "other_field")
* }

@@ -57,3 +58,4 @@ *

* model PersistedQuery {
* fooId String @map(name: "foo_id")
* id String @id @map(name: "id")
* otherField String @map(name: "other_field")
* }

@@ -66,3 +68,3 @@ *

create: (config, context) => {
const { compoundWords, requirePrefix } = config ?? {};
const { compoundWords, requireUnderscorePrefixForIds } = config ?? {};
return {

@@ -75,8 +77,6 @@ Field: (model, field) => {

const report = (message) => context.report({ model, field, message });
const { name, attributes } = field;
const expectedSnakeCase = toSnakeCase(name, {
compoundWords,
requirePrefix,
});
const isMappingRequired = !isAllLowerCase(name);
const { attributes, name: fieldName } = field;
const isIdWithRequiredPrefix = requireUnderscorePrefixForIds &&
attributes?.find((a) => a.name === 'id');
const isMappingRequired = !isAllLowerCase(fieldName) || isIdWithRequiredPrefix;
if (!attributes) {

@@ -102,2 +102,6 @@ if (isMappingRequired) {

}
let expectedSnakeCase = toSnakeCase(fieldName, { compoundWords });
if (isIdWithRequiredPrefix) {
expectedSnakeCase = `_${expectedSnakeCase}`;
}
if (mappedName !== expectedSnakeCase) {

@@ -104,0 +108,0 @@ report(`Field name must be mapped to "${expectedSnakeCase}".`);

{
"name": "prisma-lint",
"version": "0.2.0",
"version": "0.3.0",
"description": "A linter for Prisma schema files.",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc