Closed canadaduane closed 2 weeks ago
Hi @canadaduane thanks for the feedback!
To ignore specific lint rules for a model and its fields, simply append the rule name at the end of the comment. You can ignore multiple rules with multiple lines:
model User {
/// prisma-lint-ignore-model field-name-mapping-snake-case
/// prisma-lint-ignore-model require-field-type
}
And some rules support parameterized ignores:
model User {
/// prisma-lint-ignore-model require-field tenantId,revisionCreatedAt
}
That will ignore only tenantId and revisionCreatedAt field violations for the model. Other required fields will still be enforced. A comma-separated list of fields can be provided to ignore multiple required fields.
Does this support your use cases? Thanks!
Thanks for the tips!
However, I don't think it is working as expected. For instance, when I add field-name-mapping-snake-case
to the ignore like so:
I still see a lint error that I don't expect:
@sai/database:lint: prisma/schema.prisma ✖
@sai/database:lint: AuthorizationCode 133:1
@sai/database:lint: error Model name must be mapped to "authorization_codes". model-name-mapping-snake-case
@sai/database:lint: ELIFECYCLE Command failed with exit code 1.
@sai/database:lint: ERROR: command finished with error: command (/Users/duane/schoolai/app/packages/database) /Users/duane/.nvm/versions/node/v20.13.1/bin/pnpm run lint exited (1)
@sai/database#lint: command (/Users/duane/schoolai/app/packages/database) /Users/duane/.nvm/versions/node/v20.13.1/bin/pnpm run lint exited (1)
Ah, the error to ignore here is about model name mapping, rather than field name mapping. So try an ignore comment like:
/// prisma-lint-ignore-model model-name-mapping-snake-case
In general, the name of the rule is printed to the right of the error message line, and that's what should be on the ignore line.
Thank you! That works perfectly.
Thanks to this library, we're slowly moving towards a sane schema.prisma file with consistent naming of columns and tables.
However, several of our models do not match table name rules. Currently, the best we can do (I think) is add
/// prisma-lint-ignore-model
within the model. This succeeds in ignoring the model/table name inconsistency, but it also causes prisma-lint to completely ignore other rules within the model such as column name rules.Example:
SpaceUsage
that was originally mapped to a table namedspace_usage
@@map("space_usages")
if we'd followed a consistent naming rule), but we need to ignore this inconsistency just for the short termIs it possible to ignore the model/table
@@map
, so the other rules can take effect within a model?