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.1.3 to 0.2.0

57

dist/rules/model-name-grammatical-number.js
import pluralize from 'pluralize';
import { z } from 'zod';
import { isRegexOrRegexStr, toRegExp } from '#src/common/regex.js';
const RULE_NAME = 'model-name-grammatical-number';

@@ -7,2 +8,3 @@ const Config = z

style: z.enum(['singular', 'plural']),
allowlist: z.array(z.union([z.string(), z.instanceof(RegExp)])).optional(),
})

@@ -37,2 +39,43 @@ .strict();

*
* @example { style: "singular", allowlist: ["UserData"] }
* // good
* model UserData {
* id String @id
* }
*
* model User {
* id String @id
* }
*
* model Tenant {
* id String @id
* }
*
* // bad ("data" is considered plural by default)
* model TenantData {
* id String @id
* }
*
* model Users {
* id String @id
* }
*
* @example { style: "singular", allowlist: ["/Data$/"] }
* // good
* model UserData {
* id String @id
* }
*
* model TenantData {
* id String @id
* }
*
* // bad
* model DataRecords {
* id String @id
* }
*
* model Users {
* id String @id
* }
*/

@@ -44,5 +87,17 @@ export default {

const { style } = config;
const allowlist = config.allowlist ?? [];
const simpleAllowlist = allowlist.filter((s) => !isRegexOrRegexStr(s));
const regexAllowlist = allowlist
.filter((s) => isRegexOrRegexStr(s))
.map(toRegExp);
return {
Model: (model) => {
const isPlural = pluralize.isPlural(model.name);
const modelName = model.name;
if (simpleAllowlist.includes(modelName)) {
return;
}
if (regexAllowlist.some((r) => r.test(modelName))) {
return;
}
const isPlural = pluralize.isPlural(modelName);
if (isPlural && style === 'singular') {

@@ -49,0 +104,0 @@ context.report({ model, message: 'Expected singular model name.' });

4

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

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

compoundWords: z.array(z.string()).optional(),
irregularPlurals: z.record(z.string()).optional(),
pluralize: z.boolean().optional(),
trimPrefix: z.string().optional(),
pluralize: z.boolean().optional(),
irregularPlurals: z.record(z.string()).optional(),
})

@@ -13,0 +13,0 @@ .strict()

{
"name": "prisma-lint",
"version": "0.1.3",
"version": "0.2.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