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

feat(sage-monorepo): integrate SQL formatter and linter (ARCH-296) #2863

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading