-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Convert to TypeScript #339
Changes from all commits
8038561
9f930b6
2e8e8c8
c1ad3ce
438de84
1279ae6
13671de
b509030
4e5574e
b4233a9
38b2077
36f28d1
ad5cd3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { ClientConfig } from "pg"; | ||
|
||
/** | ||
* The configuration for schemalint. | ||
*/ | ||
type Config = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose the short name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine. It will likely only be used in configuration files where it will be clear what's being referenced. |
||
/** | ||
* The connection configuration for the database. | ||
* @see https://node-postgres.com/apis/client | ||
*/ | ||
connection: ClientConfig; | ||
/** | ||
* The plugins to be used. | ||
*/ | ||
plugins?: string[]; | ||
/** | ||
* The rules to be used. | ||
*/ | ||
rules: Record<string, RuleConfig>; | ||
/** | ||
* The schemas to be linted. | ||
*/ | ||
schemas: SchemaConfig[]; | ||
/** | ||
* The configuration for ignoring problems. | ||
*/ | ||
ignores?: IgnoreConfig[]; | ||
}; | ||
|
||
/** | ||
* A schema to be linted. | ||
*/ | ||
export type SchemaConfig = { | ||
/** | ||
* The name of the schema to be linted. | ||
*/ | ||
name: string; | ||
/** | ||
* The rules to be used spefically for this schema. These rules will be merged with the global rules. | ||
*/ | ||
rules?: Record<string, RuleConfig>; | ||
}; | ||
|
||
/** | ||
* A rule configuration. The first element is the severity of the rule, and the rest of the elements are the options for the rule. | ||
*/ | ||
export type RuleConfig = [Severity, ...unknown[]]; | ||
|
||
/** | ||
* The severity of a rule. `off` means the rule is disabled, `error` means the rule is enabled. | ||
*/ | ||
export type Severity = "off" | "error"; | ||
Comment on lines
+49
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, any value other than |
||
|
||
/** | ||
* A configuration for ignoring problems. | ||
*/ | ||
export type IgnoreConfig = { | ||
/** | ||
* The rule name to ignore. `rule` or `rulePattern` must be provided. | ||
*/ | ||
rule?: string; | ||
/** | ||
* A pattern to match against the rule name. `rule` or `rulePattern` must be provided. | ||
*/ | ||
rulePattern?: string; | ||
/** | ||
* The identifier to ignore. `identifier` or `identifierPattern` must be provided. | ||
*/ | ||
identifier?: string; | ||
/** | ||
* A pattern to match against the identifier. `identifier` or `identifierPattern` must be provided. | ||
*/ | ||
identifierPattern?: string; | ||
}; | ||
|
||
export default Config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { Schema } from "extract-pg-schema"; | ||
|
||
export type Reporter = (p: { | ||
export type Issue = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I named this object |
||
rule: string; | ||
identifier: string; | ||
message: string; | ||
suggestedMigration?: string; | ||
}) => void; | ||
}; | ||
|
||
export type Reporter = (p: Issue) => void; | ||
|
||
type Rule = { | ||
name: string; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type { default as Config } from "./Config"; | ||
export * from "./engine"; | ||
export type { default as Rule } from "./Rule"; | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we export the other non-default types such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess. I don't think anyone is creating custom reporters at this point, but if they want to then it would be useful. I don't think this is urgent though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed "main" and "types" here to export the
Rule
and theConfig
types from the package root. TheprocessDatabase
function is exported as before.