stylebook 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stylebook-0.1/.gitignore +25 -0
- stylebook-0.1/PKG-INFO +200 -0
- stylebook-0.1/README.md +182 -0
- stylebook-0.1/pyproject.toml +42 -0
- stylebook-0.1/stylebook/__init__.py +1 -0
- stylebook-0.1/stylebook/__main__.py +4 -0
- stylebook-0.1/stylebook/cli.py +46 -0
- stylebook-0.1/stylebook/commands/__init__.py +11 -0
- stylebook-0.1/stylebook/commands/command.py +26 -0
- stylebook-0.1/stylebook/commands/sqlfluff.py +9 -0
- stylebook-0.1/stylebook/commands/taplo.py +9 -0
- stylebook-0.1/stylebook/commands/yamllint.py +9 -0
- stylebook-0.1/stylebook/resources/sqlfluff +30 -0
- stylebook-0.1/stylebook/resources/taplo.toml +3 -0
- stylebook-0.1/stylebook/resources/yamllintrc.yaml +14 -0
stylebook-0.1/.gitignore
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# macOS
|
|
2
|
+
.DS_Store
|
|
3
|
+
._*
|
|
4
|
+
|
|
5
|
+
# PyCharm
|
|
6
|
+
*.iml
|
|
7
|
+
.idea/
|
|
8
|
+
.venv/
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
__pycache__/
|
|
11
|
+
.coverage
|
|
12
|
+
coverage.xml
|
|
13
|
+
dist/
|
|
14
|
+
wheels/
|
|
15
|
+
*.egg-info
|
|
16
|
+
|
|
17
|
+
# WebStorm
|
|
18
|
+
node_modules/
|
|
19
|
+
/docs/
|
|
20
|
+
coverage/
|
|
21
|
+
test-report.junit.xml
|
|
22
|
+
|
|
23
|
+
# MkDocs
|
|
24
|
+
site/
|
|
25
|
+
!website/docs
|
stylebook-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: stylebook
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Permissive linter extensions for markup and data languages
|
|
5
|
+
Project-URL: Source Code, https://github.com/hanggrian/stylebook
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/hanggrian/stylebook/issues
|
|
7
|
+
Author-email: Hendra Anggrian <hanggrian@proton.me>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Keywords: lint,linter,sql,toml,yaml
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: sqlfluff==4.1.0
|
|
15
|
+
Requires-Dist: taplo==0.9.3
|
|
16
|
+
Requires-Dist: yamllint==1.38.0
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
[](https://github.com/hanggrian/stylebook/actions/workflows/code-analysis.yaml)
|
|
20
|
+
[](https://app.codecov.io/gh/hanggrian/stylebook/)
|
|
21
|
+
[](https://developer.mend.io/github/hanggrian/stylebook/)\
|
|
22
|
+
[](https://pypi.org/project/stylebook/)
|
|
23
|
+
[](https://test.pypi.org/project/stylebook/)
|
|
24
|
+
[](https://docs.python.org/3.10/)\
|
|
25
|
+
[](https://www.npmjs.com/package/@hanggrian/stylebook/)
|
|
26
|
+
[](https://nodejs.org/en/blog/release/v12.0.0/)
|
|
27
|
+
|
|
28
|
+
# Stylebook
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
Third-party linter rules and configuration for various data formats not
|
|
33
|
+
considered as a programming language.
|
|
34
|
+
|
|
35
|
+
<table>
|
|
36
|
+
<thead>
|
|
37
|
+
<tr>
|
|
38
|
+
<th>Runner</th>
|
|
39
|
+
<th>File type</th>
|
|
40
|
+
<th>Linter</th>
|
|
41
|
+
<th>Style</th>
|
|
42
|
+
</tr>
|
|
43
|
+
</thead>
|
|
44
|
+
<tbody>
|
|
45
|
+
<tr>
|
|
46
|
+
<td rowspan="3">Python</td>
|
|
47
|
+
<td>SQL</td>
|
|
48
|
+
<td>
|
|
49
|
+
<a href="https://github.com/sqlfluff/sqlfluff/">
|
|
50
|
+
SQLFluff
|
|
51
|
+
</a>
|
|
52
|
+
</td>
|
|
53
|
+
<td>
|
|
54
|
+
<a href="https://docs.telemetry.mozilla.org/concepts/sql_style/">
|
|
55
|
+
Mozilla SQL Style Guide
|
|
56
|
+
</a>
|
|
57
|
+
</td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr>
|
|
60
|
+
<td>TOML</td>
|
|
61
|
+
<td>
|
|
62
|
+
<a href="https://github.com/tamasfe/taplo/">
|
|
63
|
+
Taplo
|
|
64
|
+
</a>
|
|
65
|
+
</td>
|
|
66
|
+
<td>
|
|
67
|
+
<a href="https://toml.io/en/">
|
|
68
|
+
TOML Spec
|
|
69
|
+
</a>
|
|
70
|
+
</td>
|
|
71
|
+
</tr>
|
|
72
|
+
<tr>
|
|
73
|
+
<td>YAML</td>
|
|
74
|
+
<td>
|
|
75
|
+
<a href="https://github.com/adrienverge/yamllint/">
|
|
76
|
+
yamllint
|
|
77
|
+
</a>
|
|
78
|
+
</td>
|
|
79
|
+
<td>
|
|
80
|
+
<a href="https://yaml.org/spec/">
|
|
81
|
+
YAML Spec
|
|
82
|
+
</a>
|
|
83
|
+
</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td rowspan="4">Node</td>
|
|
87
|
+
<td>CSS</td>
|
|
88
|
+
<td>
|
|
89
|
+
<a href="https://github.com/stylelint/stylelint/">
|
|
90
|
+
Stylelint
|
|
91
|
+
</a>
|
|
92
|
+
</td>
|
|
93
|
+
<td>
|
|
94
|
+
<a href="https://protocol.mozilla.org/docs/contributing/css-guide/">
|
|
95
|
+
Mozilla HTML Coding Guide
|
|
96
|
+
</a>
|
|
97
|
+
</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<td>HTML</td>
|
|
101
|
+
<td>
|
|
102
|
+
<a href="https://github.com/htmlhint/HTMLHint/">
|
|
103
|
+
HTMLHint
|
|
104
|
+
</a>
|
|
105
|
+
</td>
|
|
106
|
+
<td>
|
|
107
|
+
<a href="https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Code_style_guide/HTML/">
|
|
108
|
+
Mozilla HTML Style Guide
|
|
109
|
+
</a>
|
|
110
|
+
</td>
|
|
111
|
+
</tr>
|
|
112
|
+
<tr>
|
|
113
|
+
<td>JSON</td>
|
|
114
|
+
<td>
|
|
115
|
+
<a href="https://github.com/prantlf/jsonlint/">
|
|
116
|
+
JSON Lint
|
|
117
|
+
</a>
|
|
118
|
+
</td>
|
|
119
|
+
<td>
|
|
120
|
+
<a href="https://spec.json5.org/">
|
|
121
|
+
JSON5 Spec
|
|
122
|
+
</a>
|
|
123
|
+
</td>
|
|
124
|
+
</tr>
|
|
125
|
+
<tr>
|
|
126
|
+
<td>Markdown</td>
|
|
127
|
+
<td>
|
|
128
|
+
<a href="https://github.com/davidanson/markdownlint/">
|
|
129
|
+
markdownlint
|
|
130
|
+
</a>
|
|
131
|
+
</td>
|
|
132
|
+
<td>
|
|
133
|
+
<a href="https://github.github.com/gfm/">
|
|
134
|
+
GitHub Flavored Markdown Spec
|
|
135
|
+
</a>
|
|
136
|
+
</td>
|
|
137
|
+
</tr>
|
|
138
|
+
</tbody>
|
|
139
|
+
</table>
|
|
140
|
+
|
|
141
|
+
## Download
|
|
142
|
+
|
|
143
|
+
### PyPI
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
pip install stylebook-data
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### NPM
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
npm install stylebook-markup \
|
|
153
|
+
stylelint @stylistic/stylelint-plugin stylelint-config-recommended \
|
|
154
|
+
@prantlf/jsonlint \
|
|
155
|
+
markdownlint markdownlint-cli2 --save-dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Usage
|
|
159
|
+
|
|
160
|
+
Insert target paths into the command. The program will recursively search for
|
|
161
|
+
qualifying file types and spawn the corresponding linter processes.
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
npm exec stylebook some-folder/ some-file.sql
|
|
165
|
+
source .venv/bin/activate && stylebook **/* # or use uv run
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### SQLFluff
|
|
169
|
+
|
|
170
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
171
|
+
`.sqlfluff` is needed.
|
|
172
|
+
|
|
173
|
+
### tomllint
|
|
174
|
+
|
|
175
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
176
|
+
`.taplo.toml` is needed.
|
|
177
|
+
|
|
178
|
+
### yamllint
|
|
179
|
+
|
|
180
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
181
|
+
`.yamllintrc.json` is needed.
|
|
182
|
+
|
|
183
|
+
### Stylelint
|
|
184
|
+
|
|
185
|
+
Create `.stylint.config.js` file in the root directory.
|
|
186
|
+
|
|
187
|
+
### HTML Hint
|
|
188
|
+
|
|
189
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
190
|
+
`.htmlhintrc` is needed.
|
|
191
|
+
|
|
192
|
+
### JSON Lint
|
|
193
|
+
|
|
194
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
195
|
+
`.jsonlintrc.config.json` is needed.
|
|
196
|
+
|
|
197
|
+
### markdownlint
|
|
198
|
+
|
|
199
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
200
|
+
`.markdownlint-cli2.json` is needed.
|
stylebook-0.1/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
[](https://github.com/hanggrian/stylebook/actions/workflows/code-analysis.yaml)
|
|
2
|
+
[](https://app.codecov.io/gh/hanggrian/stylebook/)
|
|
3
|
+
[](https://developer.mend.io/github/hanggrian/stylebook/)\
|
|
4
|
+
[](https://pypi.org/project/stylebook/)
|
|
5
|
+
[](https://test.pypi.org/project/stylebook/)
|
|
6
|
+
[](https://docs.python.org/3.10/)\
|
|
7
|
+
[](https://www.npmjs.com/package/@hanggrian/stylebook/)
|
|
8
|
+
[](https://nodejs.org/en/blog/release/v12.0.0/)
|
|
9
|
+
|
|
10
|
+
# Stylebook
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
Third-party linter rules and configuration for various data formats not
|
|
15
|
+
considered as a programming language.
|
|
16
|
+
|
|
17
|
+
<table>
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th>Runner</th>
|
|
21
|
+
<th>File type</th>
|
|
22
|
+
<th>Linter</th>
|
|
23
|
+
<th>Style</th>
|
|
24
|
+
</tr>
|
|
25
|
+
</thead>
|
|
26
|
+
<tbody>
|
|
27
|
+
<tr>
|
|
28
|
+
<td rowspan="3">Python</td>
|
|
29
|
+
<td>SQL</td>
|
|
30
|
+
<td>
|
|
31
|
+
<a href="https://github.com/sqlfluff/sqlfluff/">
|
|
32
|
+
SQLFluff
|
|
33
|
+
</a>
|
|
34
|
+
</td>
|
|
35
|
+
<td>
|
|
36
|
+
<a href="https://docs.telemetry.mozilla.org/concepts/sql_style/">
|
|
37
|
+
Mozilla SQL Style Guide
|
|
38
|
+
</a>
|
|
39
|
+
</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>TOML</td>
|
|
43
|
+
<td>
|
|
44
|
+
<a href="https://github.com/tamasfe/taplo/">
|
|
45
|
+
Taplo
|
|
46
|
+
</a>
|
|
47
|
+
</td>
|
|
48
|
+
<td>
|
|
49
|
+
<a href="https://toml.io/en/">
|
|
50
|
+
TOML Spec
|
|
51
|
+
</a>
|
|
52
|
+
</td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td>YAML</td>
|
|
56
|
+
<td>
|
|
57
|
+
<a href="https://github.com/adrienverge/yamllint/">
|
|
58
|
+
yamllint
|
|
59
|
+
</a>
|
|
60
|
+
</td>
|
|
61
|
+
<td>
|
|
62
|
+
<a href="https://yaml.org/spec/">
|
|
63
|
+
YAML Spec
|
|
64
|
+
</a>
|
|
65
|
+
</td>
|
|
66
|
+
</tr>
|
|
67
|
+
<tr>
|
|
68
|
+
<td rowspan="4">Node</td>
|
|
69
|
+
<td>CSS</td>
|
|
70
|
+
<td>
|
|
71
|
+
<a href="https://github.com/stylelint/stylelint/">
|
|
72
|
+
Stylelint
|
|
73
|
+
</a>
|
|
74
|
+
</td>
|
|
75
|
+
<td>
|
|
76
|
+
<a href="https://protocol.mozilla.org/docs/contributing/css-guide/">
|
|
77
|
+
Mozilla HTML Coding Guide
|
|
78
|
+
</a>
|
|
79
|
+
</td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td>HTML</td>
|
|
83
|
+
<td>
|
|
84
|
+
<a href="https://github.com/htmlhint/HTMLHint/">
|
|
85
|
+
HTMLHint
|
|
86
|
+
</a>
|
|
87
|
+
</td>
|
|
88
|
+
<td>
|
|
89
|
+
<a href="https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Code_style_guide/HTML/">
|
|
90
|
+
Mozilla HTML Style Guide
|
|
91
|
+
</a>
|
|
92
|
+
</td>
|
|
93
|
+
</tr>
|
|
94
|
+
<tr>
|
|
95
|
+
<td>JSON</td>
|
|
96
|
+
<td>
|
|
97
|
+
<a href="https://github.com/prantlf/jsonlint/">
|
|
98
|
+
JSON Lint
|
|
99
|
+
</a>
|
|
100
|
+
</td>
|
|
101
|
+
<td>
|
|
102
|
+
<a href="https://spec.json5.org/">
|
|
103
|
+
JSON5 Spec
|
|
104
|
+
</a>
|
|
105
|
+
</td>
|
|
106
|
+
</tr>
|
|
107
|
+
<tr>
|
|
108
|
+
<td>Markdown</td>
|
|
109
|
+
<td>
|
|
110
|
+
<a href="https://github.com/davidanson/markdownlint/">
|
|
111
|
+
markdownlint
|
|
112
|
+
</a>
|
|
113
|
+
</td>
|
|
114
|
+
<td>
|
|
115
|
+
<a href="https://github.github.com/gfm/">
|
|
116
|
+
GitHub Flavored Markdown Spec
|
|
117
|
+
</a>
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
</tbody>
|
|
121
|
+
</table>
|
|
122
|
+
|
|
123
|
+
## Download
|
|
124
|
+
|
|
125
|
+
### PyPI
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
pip install stylebook-data
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### NPM
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm install stylebook-markup \
|
|
135
|
+
stylelint @stylistic/stylelint-plugin stylelint-config-recommended \
|
|
136
|
+
@prantlf/jsonlint \
|
|
137
|
+
markdownlint markdownlint-cli2 --save-dev
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Usage
|
|
141
|
+
|
|
142
|
+
Insert target paths into the command. The program will recursively search for
|
|
143
|
+
qualifying file types and spawn the corresponding linter processes.
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
npm exec stylebook some-folder/ some-file.sql
|
|
147
|
+
source .venv/bin/activate && stylebook **/* # or use uv run
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### SQLFluff
|
|
151
|
+
|
|
152
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
153
|
+
`.sqlfluff` is needed.
|
|
154
|
+
|
|
155
|
+
### tomllint
|
|
156
|
+
|
|
157
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
158
|
+
`.taplo.toml` is needed.
|
|
159
|
+
|
|
160
|
+
### yamllint
|
|
161
|
+
|
|
162
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
163
|
+
`.yamllintrc.json` is needed.
|
|
164
|
+
|
|
165
|
+
### Stylelint
|
|
166
|
+
|
|
167
|
+
Create `.stylint.config.js` file in the root directory.
|
|
168
|
+
|
|
169
|
+
### HTML Hint
|
|
170
|
+
|
|
171
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
172
|
+
`.htmlhintrc` is needed.
|
|
173
|
+
|
|
174
|
+
### JSON Lint
|
|
175
|
+
|
|
176
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
177
|
+
`.jsonlintrc.config.json` is needed.
|
|
178
|
+
|
|
179
|
+
### markdownlint
|
|
180
|
+
|
|
181
|
+
No setup is necessary. However, to customize behaviors, a local
|
|
182
|
+
`.markdownlint-cli2.json` is needed.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "stylebook"
|
|
7
|
+
version = "0.1"
|
|
8
|
+
description = "Permissive linter extensions for markup and data languages"
|
|
9
|
+
keywords = [
|
|
10
|
+
"sql",
|
|
11
|
+
"toml",
|
|
12
|
+
"yaml",
|
|
13
|
+
"lint",
|
|
14
|
+
"linter",
|
|
15
|
+
]
|
|
16
|
+
authors = [{ name = "Hendra Anggrian", email = "hanggrian@proton.me" }]
|
|
17
|
+
license = { text = "Apache-2.0" }
|
|
18
|
+
readme = "README.md"
|
|
19
|
+
requires-python = ">=3.10"
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: Apache Software License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"sqlfluff==4.1.0",
|
|
27
|
+
"taplo==0.9.3",
|
|
28
|
+
"yamllint==1.38.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
"Source Code" = "https://github.com/hanggrian/stylebook"
|
|
33
|
+
"Bug Tracker" = "https://github.com/hanggrian/stylebook/issues"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
stylebook = "stylebook.cli:run"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["stylebook"]
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.sdist]
|
|
42
|
+
include = ["stylebook/"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""main"""
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from sys import argv, exit, stderr
|
|
3
|
+
|
|
4
|
+
from stylebook.commands import Command, SqlfluffCommand, TaploCommand, YamllintCommand
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def walk(target_path: Path) -> list[str]:
|
|
8
|
+
if target_path.is_file():
|
|
9
|
+
return [str(target_path)]
|
|
10
|
+
if target_path.is_dir():
|
|
11
|
+
results = []
|
|
12
|
+
for child in target_path.iterdir():
|
|
13
|
+
results.extend(walk(child))
|
|
14
|
+
return results
|
|
15
|
+
return []
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def run() -> None:
|
|
19
|
+
input_args: list[str] = argv[1:]
|
|
20
|
+
if not input_args:
|
|
21
|
+
print('Need a path.', file=stderr)
|
|
22
|
+
exit(1)
|
|
23
|
+
|
|
24
|
+
sqlfluff_command: Command = SqlfluffCommand()
|
|
25
|
+
taplo_command: Command = TaploCommand()
|
|
26
|
+
yamllint_command: Command = YamllintCommand()
|
|
27
|
+
commands: dict[Command, list[str]] = {
|
|
28
|
+
sqlfluff_command: [],
|
|
29
|
+
taplo_command: [],
|
|
30
|
+
yamllint_command: [],
|
|
31
|
+
}
|
|
32
|
+
for target_path in [path for arg in input_args for path in walk(Path(arg))]:
|
|
33
|
+
match Path(target_path).suffix.lower():
|
|
34
|
+
case '.sql':
|
|
35
|
+
commands[sqlfluff_command].append(target_path)
|
|
36
|
+
case '.toml':
|
|
37
|
+
commands[taplo_command].append(target_path)
|
|
38
|
+
case '.yaml' | '.yml':
|
|
39
|
+
commands[yamllint_command].append(target_path)
|
|
40
|
+
|
|
41
|
+
exit(
|
|
42
|
+
min(
|
|
43
|
+
1,
|
|
44
|
+
sum(command.execute(paths) for command, paths in commands.items() if paths),
|
|
45
|
+
),
|
|
46
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from stylebook.commands.command import Command
|
|
2
|
+
from stylebook.commands.sqlfluff import SqlfluffCommand
|
|
3
|
+
from stylebook.commands.taplo import TaploCommand
|
|
4
|
+
from stylebook.commands.yamllint import YamllintCommand
|
|
5
|
+
|
|
6
|
+
__all__: list[str] = [
|
|
7
|
+
'Command',
|
|
8
|
+
'SqlfluffCommand',
|
|
9
|
+
'TaploCommand',
|
|
10
|
+
'YamllintCommand',
|
|
11
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from importlib.resources import files
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from subprocess import run
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Command(ABC):
|
|
8
|
+
def __init__(self, binary: str, config_file: str) -> None:
|
|
9
|
+
self.binary = binary
|
|
10
|
+
local_config_file: Path = Path.cwd() / f'.{config_file}'
|
|
11
|
+
self.config_file = \
|
|
12
|
+
str(
|
|
13
|
+
local_config_file
|
|
14
|
+
if local_config_file.exists()
|
|
15
|
+
else files('stylebook.resources').joinpath(config_file),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def get_arguments(self) -> list[str]:
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
def execute(self, target_paths: list[str]) -> int:
|
|
23
|
+
return run(
|
|
24
|
+
[self.binary, *self.get_arguments(), *target_paths],
|
|
25
|
+
capture_output=False,
|
|
26
|
+
).returncode
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[sqlfluff]
|
|
2
|
+
dialect = snowflake
|
|
3
|
+
templater = jinja
|
|
4
|
+
exclude_rules = ambiguous.column_count, structure.column_order
|
|
5
|
+
max_line_length = 80
|
|
6
|
+
processes = -1
|
|
7
|
+
|
|
8
|
+
[sqlfluff:templater:dbt]
|
|
9
|
+
project_dir = ./
|
|
10
|
+
|
|
11
|
+
[sqlfluff:indentation]
|
|
12
|
+
implicit_indents = allow
|
|
13
|
+
tab_space_size = 2
|
|
14
|
+
|
|
15
|
+
[sqlfluff:rules:aliasing.length]
|
|
16
|
+
min_alias_length = 3
|
|
17
|
+
|
|
18
|
+
[sqlfluff:rules:capitalisation.keywords]
|
|
19
|
+
capitalisation_policy = upper
|
|
20
|
+
[sqlfluff:rules:capitalisation.identifiers]
|
|
21
|
+
extended_capitalisation_policy = lower
|
|
22
|
+
[sqlfluff:rules:capitalisation.functions]
|
|
23
|
+
extended_capitalisation_policy = lower
|
|
24
|
+
[sqlfluff:rules:capitalisation.literals]
|
|
25
|
+
capitalisation_policy = upper
|
|
26
|
+
[sqlfluff:rules:capitalisation.types]
|
|
27
|
+
extended_capitalisation_policy = upper
|
|
28
|
+
|
|
29
|
+
[sqlfluff:rules:convention.not_equal]
|
|
30
|
+
preferred_not_equal_style = c_style
|