Skip to content

Commit 09efac2

Browse files
authored
Add pipeline for linting and formatting (#146)
1 parent 5592fd6 commit 09efac2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1554
-388
lines changed

.eslintrc.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
browser: true,
5+
es6: true,
6+
},
7+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
ecmaVersion: 'latest',
11+
sourceType: 'module',
12+
},
13+
ignorePatterns: ['dist/', 'node_modules/', '*.gen.ts'],
14+
plugins: ['@typescript-eslint', 'unused-imports', '@stylistic/ts'],
15+
rules: {
16+
'@typescript-eslint/member-ordering': 'error',
17+
'@typescript-eslint/ban-ts-comment': 'off', // "move fast" mode
18+
'@typescript-eslint/no-explicit-any': 'off', // "move fast" mode
19+
'linebreak-style': ['error', 'unix'],
20+
'unused-imports/no-unused-imports': 'error',
21+
// No double quotes
22+
quotes: ['error', 'single', { avoidEscape: true }],
23+
// No extra semicolon
24+
'@stylistic/ts/semi': ['error', 'never'],
25+
},
26+
}

.github/workflows/lint.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9.15.5
18+
19+
- name: Setup Node.js 20
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
cache: pnpm
24+
25+
- name: Configure pnpm
26+
run: |
27+
pnpm config set auto-install-peers true
28+
pnpm config set exclude-links-from-lockfile true
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v4
35+
with:
36+
python-version: '3.10'
37+
38+
- name: Install and configure Poetry
39+
uses: snok/install-poetry@v1
40+
with:
41+
version: 1.5.1
42+
virtualenvs-create: true
43+
virtualenvs-in-project: true
44+
installer-parallel: true
45+
46+
- name: Install Python dependencies
47+
working-directory: python
48+
run: |
49+
poetry install --with dev
50+
pip install ruff=="0.11.12"
51+
52+
- name: Run linting
53+
run: |
54+
pnpm run lint
55+
56+
- name: Run formatting
57+
run: |
58+
pnpm run format
59+
60+
- name: Check for uncommitted changes
61+
run: |
62+
if [[ -n $(git status --porcelain) ]]; then
63+
echo "❌ Files are not formatted properly:"
64+
git status --short
65+
git diff
66+
exit 1
67+
else
68+
echo "✅ No changes detected."
69+
fi

chart_data_extractor/e2b_charts/charts/bars.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def _extract_info(self, ax: Axes) -> None:
3737
labels = [label.get_text() for label in ax.get_xticklabels()]
3838
values = heights
3939
for label, value in zip(labels, values):
40-
4140
bar = BarData(label=label, value=value, group=group_label)
4241
self.elements.append(bar)
4342

chart_data_extractor/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
"test": "poetry run pytest -n 4 --verbose -x",
77
"example": "poetry run python3 example.py",
88
"postVersion": "poetry version $(pnpm pkg get version --workspaces=false | tr -d \\\")",
9-
"pretest": "poetry install"
9+
"pretest": "poetry install",
10+
"lint": "poetry run ruff check .",
11+
"format": "poetry run ruff format ."
12+
},
13+
"devDependencies": {
14+
"@typescript-eslint/eslint-plugin": "^7.11.0",
15+
"@typescript-eslint/parser": "^7.11.0",
16+
"eslint": "^8.57.1"
1017
}
1118
}

chart_data_extractor/poetry.lock

Lines changed: 64 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart_data_extractor/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ pydantic = "^2.8.2"
2020
pytest = "^7.4.0"
2121
python-dotenv = "^1.0.0"
2222
pytest-dotenv = "^0.5.2"
23+
ruff = "^0.11.12"
24+
2325

2426
[build-system]
2527
requires = ["poetry-core"]
2628
build-backend = "poetry.core.masonry.api"
2729

2830
[tool.poetry.urls]
2931
"Bug Tracker" = "https://github.com/e2b-dev/code-interpreter/issues"
32+
33+
[tool.ruff.lint]
34+
ignore = ["F401", "F403"]

chart_data_extractor/tests/charts/test_blank.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import matplotlib.pyplot as plt
22

33
from e2b_charts import chart_figure_to_chart
4-
from e2b_charts.charts import BarChart, ChartType
54

65

76
def test_blank_chart():

chart_data_extractor/tests/charts/test_categorical_scale.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import numpy as np
21
import matplotlib.pyplot as plt
3-
import datetime
42

53
from e2b_charts import chart_figure_to_chart
64
from e2b_charts.charts import LineChart

chart_data_extractor/tests/charts/test_log_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_log_chart():
4040
assert chart.x_label == "X-axis"
4141
assert chart.y_label == "Y-axis (log scale)"
4242

43-
assert chart.x_unit == None
43+
assert chart.x_unit is None
4444
assert chart.y_unit == "log scale"
4545

4646
assert chart.x_scale == "linear"

js/.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '../.eslintrc.cjs',
4+
}

0 commit comments

Comments
 (0)