62 lines
1.4 KiB
Plaintext
62 lines
1.4 KiB
Plaintext
---
|
|
title: Pre-commit Hooks and Linting
|
|
hide_title: true
|
|
sidebar_position: 6
|
|
version: 1
|
|
---
|
|
|
|
## Git Hooks
|
|
|
|
Superset uses Git pre-commit hooks courtesy of [pre-commit](https://pre-commit.com/). To install run the following:
|
|
|
|
```bash
|
|
pip3 install -r requirements/integration.txt
|
|
pre-commit install
|
|
```
|
|
|
|
A series of checks will now run when you make a git commit.
|
|
|
|
Alternatively it is possible to run pre-commit via tox:
|
|
|
|
```bash
|
|
tox -e pre-commit
|
|
```
|
|
|
|
Or by running pre-commit manually:
|
|
|
|
```bash
|
|
pre-commit run --all-files
|
|
```
|
|
|
|
## Linting
|
|
|
|
### Python
|
|
|
|
We use [Pylint](https://pylint.org/) for linting which can be invoked via:
|
|
|
|
```bash
|
|
# for python
|
|
tox -e pylint
|
|
```
|
|
|
|
In terms of best practices please advoid blanket disablement of Pylint messages globally (via `.pylintrc`) or top-level within the file header, albeit there being a few exceptions. Disablement should occur inline as it prevents masking issues and provides context as to why said message is disabled.
|
|
|
|
Additionally the Python code is auto-formatted using [Black](https://github.com/python/black) which
|
|
is configured as a pre-commit hook. There are also numerous [editor integrations](https://black.readthedocs.io/en/stable/editor_integration.html)
|
|
|
|
### TypeScript
|
|
|
|
```bash
|
|
cd superset-frontend
|
|
npm ci
|
|
npm run lint
|
|
```
|
|
|
|
If using the eslint extension with vscode, put the following in your workspace `settings.json` file:
|
|
|
|
```json
|
|
"eslint.workingDirectories": [
|
|
"superset-frontend"
|
|
]
|
|
```
|