Skip to content

Commit

Permalink
feat(sage-monorepo): integrate SQL formatter and linter (ARCH-296) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter authored Sep 27, 2024
1 parent 8a559fc commit 9c1b90d
Show file tree
Hide file tree
Showing 10 changed files with 519 additions and 10 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"alefragnani.Bookmarks",
"Angular.ng-template",
"dbaeumer.vscode-eslint",
"dorzey.vscode-sqlfluff",
"eamodio.gitlens",
"emeraldwalk.RunOnSave",
"esbenp.prettier-vscode",
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ printWidth: 100
singleQuote: true
plugins:
- prettier-plugin-java
- prettier-plugin-sql
- prettier-plugin-tailwindcss
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"scss.validate": false,
"stylelint.enable": true,
"stylelint.validate": ["css", "scss"],
"sqlfluff.executablePath": "${workspaceFolder}/.venv/bin/sqlfluff",
"sqlfluff.format.enabled": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
-- sqlfluff:dialect:postgres
-- keycloak
CREATE USER keycloak WITH ENCRYPTED PASSWORD 'changeme';
CREATE USER keycloak
WITH
ENCRYPTED PASSWORD 'changeme';

CREATE DATABASE keycloak;
GRANT ALL PRIVILEGES ON DATABASE keycloak TO keycloak;

GRANT all PRIVILEGES ON DATABASE keycloak TO keycloak;
16 changes: 9 additions & 7 deletions apps/openchallenges/user-service/session.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
-- sqlfluff:dialect:mariadb
-- @block list users

SELECT * FROM challenge_user;
SELECT
*
FROM
challenge_user;

-- @block delete user by id

DELETE FROM challenge_user WHERE id=1;
DELETE FROM challenge_user
WHERE
id = 1;

-- @block delete all users

DELETE FROM challenge_user;

-- @block delete flyway schema history

DELETE FROM flyway_schema_history;
DELETE FROM flyway_schema_history;
7 changes: 7 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ module.exports = {
// Lint Dockerfiles with Hadolint
`hadolint ${filenames.join(' ')}`,
],

'**/*.{sql}': (filenames) => [
// Format files with Prettier
`prettier --write ${filenames.join(' ')}`,
// Lint files with SQLFluff
`poetry run sqlfluff lint ${filenames.join(' ')}`,
],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"postcss-url": "^10.1.3",
"prettier": "3.3.3",
"prettier-plugin-java": "2.6.4",
"prettier-plugin-sql": "0.18.1",
"prettier-plugin-tailwindcss": "0.6.8",
"primeicons": "7.0.0",
"primeng": "17.18.8",
Expand Down
47 changes: 47 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9c1b90d

Please sign in to comment.