Skip to content

Commit

Permalink
Create SQLFluff config package
Browse files Browse the repository at this point in the history
  • Loading branch information
psirenny authored May 21, 2024
1 parent 4d0c1dc commit 3eacb9a
Show file tree
Hide file tree
Showing 16 changed files with 697 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-rockets-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spear-ai/sqlfluff-config": major
---

Created SQLFluff config package.
Binary file modified .yarn/install-state.gz
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/sqlfluff-config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.ruff_cache
.turbo
.venv
dist
node_modules
24 changes: 24 additions & 0 deletions packages/sqlfluff-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @spear-ai/sqlfluff-config

A [SQLFluff](https://sqlfluff.com) config.

## Installation

```shell
poetry add -D spear_ai_sqlfluff_config
```

## Usage

Configure `poetry.toml` to save the virtual environment to your local project:

```
[virtualenvs]
in-project = true
```

Copy the following to your `.sqluff` file:

```shell
cp ./.venv/lib/python3.11/site-packages/spear-ai-sqlfluff-config/.sqlfluff .sqlfluff
```
12 changes: 12 additions & 0 deletions packages/sqlfluff-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { baseEslintConfig, prettierConfig } from "@spear-ai/eslint-config";

/** @type {import("eslint").Linter.FlatConfig} */
const eslintConfig = [
{
ignores: ["dist", "node_modules", ".venv"],
},
...baseEslintConfig,
prettierConfig,
];

export default eslintConfig;
7 changes: 7 additions & 0 deletions packages/sqlfluff-config/npmpackagejsonlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ["@spear-ai/npm-package-json-lint-config/spear-library"],
rules: {
"prefer-absolute-version-devDependencies": "off",
"prefer-alphabetical-scripts": "off",
},
};
45 changes: 45 additions & 0 deletions packages/sqlfluff-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@spear-ai/sqlfluff-config",
"version": "0.0.0",
"description": "Spear AI SQLFluff config",
"author": {
"name": "Spear AI",
"email": "[email protected]",
"url": "https://spear.ai"
},
"type": "module",
"devDependencies": {
"@types/eslint": "8.56.9",
"@types/regenerator-runtime": "^0.13.5",
"eslint": "8.57.0",
"graphql": "16.8.1",
"npm-package-json-lint": "7.1.0",
"prettier": "3.2.5",
"react": "18.2.0",
"regenerator-runtime": "^0.14.1",
"replace-in-file": "^7.1.0",
"tailwindcss": "3.4.3",
"tsup": "8.0.2",
"tsx": "4.7.2",
"typescript": "5.4.5"
},
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"directory": "packages/sqlfluff-config",
"url": "https://github.com/spear-ai/citizen.git"
},
"scripts": {
"build": "poetry build",
"eslint:check": "eslint --max-warnings 0 .",
"eslint:fix": "yarn eslint:check --fix",
"npmpkgjsonlint:check": "npmPkgJsonLint .",
"postinstall": "poetry install",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"publish-package": "poetry publish --skip-existing",
"sync-version": "tsx sync-version",
"typescript:check": "tsc --noEmit"
}
}
485 changes: 485 additions & 0 deletions packages/sqlfluff-config/poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/sqlfluff-config/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
in-project = true
22 changes: 22 additions & 0 deletions packages/sqlfluff-config/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[tool.poetry]
name = "spear-ai-sqlfluff-config"
version = "0.0.0"
description = "Spear AI Ruff config"
authors = ["Spear AI <[email protected]>"]
keywords = [
"ai",
"config",
"SQLFluff",
"spear"
]
packages = [{ include = "spear_ai_sqlfluff_config" }]
readme = "README.md"
repository = "https://github.com/spear-ai/citizen"

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
sqlfluff = "^3.0.6"

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]
37 changes: 37 additions & 0 deletions packages/sqlfluff-config/spear_ai_sqlfluff_config/.sqlfluff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[sqlfluff]
dialect = postgres
max_line_length = 120
templater = placeholder

[sqlfluff:templater:placeholder]
DATABASE_OWNER=owner_role
param_style = colon

[sqlfluff:rules:ambiguous.column_references]
group_by_and_order_by_style = explicit

[sqlfluff:rules:ambiguous.join]
fully_qualify_join_types = both

[sqlfluff:rules:capitalisation.functions]
capitalisation_policy = lower
extended_capitalisation_policy = lower

[sqlfluff:rules:capitalisation.identifiers]
capitalisation_policy = lower
extended_capitalisation_policy = lower

[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = lower

[sqlfluff:rules:convention.casting_style]
preferred_type_casting_style = shorthand

[sqlfluff:rules:references.consistent]
single_table_references = unqualified
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Spear AI SQLFluff config."""
12 changes: 12 additions & 0 deletions packages/sqlfluff-config/sync-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable regexp/require-unicode-regexp */
/* eslint-disable regexp/require-unicode-sets-regexp */

import replaceInFile from "replace-in-file";
import package_ from "./package.json" assert { type: "json" };

await replaceInFile({
files: "pyproject.toml",
from: /version = ".*"/,
to: `version = "${package_.version}"`,
});
16 changes: 16 additions & 0 deletions packages/sqlfluff-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"exclude": ["node_modules"],
"extends": "@spear-ai/tsconfig",
"include": [
"**/*.cjs",
"**/*.cts",
"**/*.js",
"**/*.jsx",
"**/*.jsx",
"**/*.mjs",
"**/*.mts",
"**/*.ts",
"**/*.tsx",
"types"
]
}
4 changes: 4 additions & 0 deletions workspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"name": "spear-ai/ruff-config",
"path": "packages/ruff-config",
},
{
"name": "spear-ai/sqlfluff-config",
"path": "packages/sqlfluff-config",
},
{
"name": "spear-ai/tsconfig",
"path": "packages/tsconfig",
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,26 @@ __metadata:
languageName: unknown
linkType: soft

"@spear-ai/sqlfluff-config@workspace:packages/sqlfluff-config":
version: 0.0.0-use.local
resolution: "@spear-ai/sqlfluff-config@workspace:packages/sqlfluff-config"
dependencies:
"@types/eslint": "npm:8.56.9"
"@types/regenerator-runtime": "npm:^0.13.5"
eslint: "npm:8.57.0"
graphql: "npm:16.8.1"
npm-package-json-lint: "npm:7.1.0"
prettier: "npm:3.2.5"
react: "npm:18.2.0"
regenerator-runtime: "npm:^0.14.1"
replace-in-file: "npm:^7.1.0"
tailwindcss: "npm:3.4.3"
tsup: "npm:8.0.2"
tsx: "npm:4.7.2"
typescript: "npm:5.4.5"
languageName: unknown
linkType: soft

"@spear-ai/tsconfig@workspace:packages/tsconfig":
version: 0.0.0-use.local
resolution: "@spear-ai/tsconfig@workspace:packages/tsconfig"
Expand Down

0 comments on commit 3eacb9a

Please sign in to comment.