Skip to content

Commit

Permalink
Bump eslint-config-beslogic to 3.0 and drop-pre-commit (#268)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 8921051 commit 61bd1a2
Show file tree
Hide file tree
Showing 19 changed files with 4,105 additions and 2,372 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/canopeum_backend_pr_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,35 @@ jobs:
version: PATH
python-version: "3.12"
working-directory: canopeum_backend

Ruff-Autofixes:
runs-on: unbuntu-latest
defaults:
run:
working-directory: canopeum_backend
# Only run autofixes on PRs
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Token with Contents permissions to allow retriggering workflow
token: ${{ secrets.PR_AUTOFIX_PAT }}
- run: echo "${{github.event.head_commit.author.name}}"
- uses: astral-sh/ruff-action@v1
with:
args: check --fix
- uses: astral-sh/ruff-action@v1
# Format even on lint failure
if: ${{ !cancelled() }}
with:
args: format
- name: Commit autofixes
uses: EndBug/add-and-commit@v9
# TODO: Prevent infinite loops, github.event.head_commit.author.name is not accessible in this context
# if: ${{ github.event.head_commit.author.name != 'github-actions' }}
# Push autofixes even on failure
if: ${{ !cancelled() }}
with:
default_author: github_actions
20 changes: 18 additions & 2 deletions .github/workflows/canopeum_frontend_pr_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,32 @@ on:
- ".github/workflows/canopeum_frontend_pr_validation.yml"

jobs:
Lint:
Lint-Autofixes:
runs-on: ubuntu-latest
defaults:
run:
working-directory: canopeum_frontend
# Only run autofixes on PRs
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Token with Contents permissions to allow retriggering workflow
token: ${{ secrets.PR_AUTOFIX_PAT }}
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run lint
- run: npm run lint:fix
- name: Commit autofixes
uses: EndBug/add-and-commit@v9
# TODO: Prevent infinite loops, github.event.head_commit.author.name is not accessible in this context
# if: ${{ github.event.head_commit.author.name != 'github-actions' }}
# Push autofixes even on failure
if: ${{ !cancelled() }}
with:
default_author: github_actions

Build:
runs-on: ubuntu-latest
defaults:
Expand Down
77 changes: 0 additions & 77 deletions .pre-commit-config.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ For backend
uv run ./scripts/checkers.py
```

For both: (autofixers)

```shell
pre-commit run --all
```

### Quickly running the application locally

We've made a `start-local-env.ps1` helper script to ease starting up the application. Feel free to use and improve it.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 5.1 on 2024-11-14 17:18

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("canopeum_backend", "0002_alter_role_name"),
("canopeum_backend", "0002_remove_batch_total_number_seed"),
]

operations = []
3 changes: 1 addition & 2 deletions canopeum_backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ dependencies = [
dev = [
# Tools
"mypy", # version taken from [compatible-mypy],
"pre-commit==3.8.*",
"pyright>=1.1.374",
"ruff==0.6.9", # must match .pre-commit-config.yaml
"ruff==0.6.*",
# Stubs
"django-stubs[compatible-mypy]>=5.0.0",
"djangorestframework-stubs[compatible-mypy]>=3.15.0",
Expand Down
70 changes: 1 addition & 69 deletions canopeum_backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions canopeum_frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ module.exports = {
extends: [
'beslogic/react',
'beslogic/typescript',
'beslogic/dprint',
'beslogic/extra-strict',
],
parser: '@typescript-eslint/parser',
parserOptions: {
// Experimental, but causes pre-commit to actually find the project and avoids OOM
projectService: {
allowDefaultProject: ['*/*/*.js', '.eslintrc.cjs'],
},
// Still needed for plugins that haven't updated to typescript-eslint@8 yet
// Namely: eslint-plugin-sonarjs
EXPERIMENTAL_useProjectService: true,
// eslint-disable-next-line no-undef -- false-positive
tsconfigRootDir: __dirname,
},
ignorePatterns: [
// Isn't included in any TSConfig
'.eslintrc.cjs',
'vite.config.ts',
// Not found by the project service. Isn't included in any TSConfig
'index.html',
// Auto-generated
'src/services/api.ts',
],
Expand All @@ -24,6 +29,7 @@ module.exports = {
'warn',
{ allowConstantExport: true }, // Works fine in Vite
],

/*
* Beslogic presets overrides
*/
Expand Down Expand Up @@ -66,18 +72,17 @@ module.exports = {
// will cause us to have to add classes to React Components
'react/forbid-component-props': 'off',
'@typescript-eslint/no-unsafe-member-access': 'warn',
// There is currently a bug with this rule causing the linter to crash
// Until this is fixed or solved, we'll turn this one off to prevent blocking
// in PR with the exception
// https://github.com/cartant/eslint-plugin-etc/issues/63
'etc/no-implicit-any-catch': 'off',
// Extremely slow rule
'etc/no-commented-out-code': 'off',
},
overrides: [
{
files: 'src/locale/**/*.ts',
rules: {
// These are not credentials
'sonarjs/no-hardcoded-credentials': 'off',
// We prefer avoiding line-breaks in translation files
'max-len': 'off',
'@stylistic/max-len': 'off',
// Imports across languages to use the "satisfies" keyword on object literals
// We need to apply it directly on object literals to check for excess properties
// https://www.typescriptlang.org/docs/handbook/2/objects.html#excess-property-checks
Expand Down
Loading

0 comments on commit 61bd1a2

Please sign in to comment.