Skip to content
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

Make example folder self-contained #340

Merged
merged 8 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ $ npx schemalint
Here is an example configuration file:

```javascript
/** @type {import("schemalint").Config } */
module.exports = {
// Connection configuration. See: https://node-postgres.com/apis/client
connection: {
Expand All @@ -40,12 +41,12 @@ module.exports = {
charset: "utf8",
},

// Schemas to lint.
// Schemas to be linted.
schemas: [{ name: "public" }],

// Rules to be checked. The key is the rule name and the value is an array
// whose first value is the severity (only "error" is supported) and the
// rest are rule-specific parameters.
// whose first value is the severity ("error" to enable the rule, "off" to
// disable it) and the rest are rule-specific parameters.
rules: {
"name-casing": ["error", "snake"],
"name-inflection": ["error", "singular"],
Expand Down
3 changes: 2 additions & 1 deletion example/.schemalintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @type {import('schemalint').Config } */
module.exports = {
connection: {
host: 'localhost',
Expand All @@ -8,7 +9,7 @@ module.exports = {
port: 54321,
},

plugins: ['./example/custom-rules'],
plugins: ['./custom-rules'],

rules: {
'identifier-naming': ['error'],
Expand Down
8 changes: 4 additions & 4 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ I've created a Docker image that hosts it so if you have Docker installed, you c
npm run start-example-db
```

First, run the build script in this folder with:
First, run the install command in this folder with:

```
npm run build
npm install
```

Then, run the config file in this folder with:
Then, run the schemalint using the config file `schemalintrc.js` in this folder with:

```
npm run run-example
npm run lint:schema # or just `npx schemalint`
```

You should see output like this:
Expand Down
1 change: 1 addition & 0 deletions example/custom-rules/identifierNaming.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This example rule will enforce primary key columns be named like this: tablename_id

/** @type {import('schemalint').Rule} */
const identifierNaming = {
name: 'identifier-naming',
docs: {
Expand Down
Loading