Skip to content

A simple repository to publicly expose base configurations shared across different Beslogic projects.

License

Notifications You must be signed in to change notification settings

BesLogic/shared-configs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beslogic shared configurations

These are the base configurations shared across different Beslogic projects.

We recommend keeping the changes to the minimum needed (for example, avoid re-organizing entire sections) as to minimize the diff the next time you update your configs. It is generally recommended to check back on this page when updating workspace/editor/dev tooling settings.

VSCode

Copy the .vscode folder into the root of your git project.
If using a devcontainer or a code-workspace, copy its content in the appropriate sections instead.

Read the comments carefully, you will likely need to uncomment or modify a thing a two for your project. You can trim out configuration sections and extensions for languages your project doesn't use.

EditorConfig

Copy the .editorconfig skeleton file into the root of your git project.

dprint

Add the following into your .dprint.jsonc:

{
  // https://dprint.dev/config/#extending-a-different-configuration-file
  "extends": "https://raw.githubusercontent.com/BesLogic/shared-configs/main/dprint.json"
}

This configuration automatically includes known "exclusion" folders. But if you need to add more, you can copy and expand the exludes list in dprint.json.
If you'd like to pin your config version, you can use a commit hash, like https://raw.githubusercontent.com/BesLogic/shared-configs/a0d9a34/dprint.json.

package.json

(for dprint and ESLint)

To run dprint along with ESLint, add the following to your package.json:

"scripts": {
  "eslint": "eslint ./ --ignore-path .gitignore",
  "lint": "dprint check && npm run eslint",
  "lint:fix": "npm run eslint -- --fix && dprint fmt",
}

If your package.json isn't at root (like frontend/backend split monorepos), you can do the following to ensure the formatter (dprint) is run on all files:

"scripts": {
  "eslint": "eslint ./ --ignore-path .gitignore",
  "lint": "cd .. && dprint check && cd frontend && npm run eslint",
  "lint:fix": "npm run eslint -- --fix && cd .. && dprint fmt",
}

TypeScript (tsconfig) and ESLint

See https://www.npmjs.com/package/eslint-config-beslogic#base-tsconfigjson

Ruff

Copy the ruff.toml skeleton file into the root of your python project or root of your monorepo.
(this may change if/when Ruff allows sharing external configs: astral-sh/ruff#3363 (comment) / astral-sh/ruff#12352)

PR Autofixes

We've stopped attempting to support pre-commit.ci due to restrictions on downloaded bundle size and runtime downloads on the free tier. As well as having to individually duplicate and pin each ESLint plugin to an exact version. And finally, issues typescript-eslint project configuration and going Out Of Memory.

Instead, we can recommend:

GitHub Actions example configuration
name: PR Autofixes

on:
  pull_request:
    branches:
      - main

jobs:
  Autofixes:
    runs-on: ubuntu-latest
    # Only run autofixes on PRs
    if: ${{ github.event_name == 'pull_request' }}
    steps:
      - uses: actions/checkout@v4
        with:
          # Checkout the fork/head-repository and push changes to the fork.
          # If you skip this, the base repository will be checked out and changes will be committed to the base repository!
          repository: ${{ github.event.pull_request.head.repo.full_name }}
          # Checkout the branch made in the fork. Will automatically push changes back to this branch.
          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

      # - uses: other_custom_steps

      # Ruff autofixes
      - uses: astral-sh/ruff-action@v1
        # Fix even on other steps failure
        if: ${{ !cancelled() }}
        with:
          args: check --fix
      - uses: astral-sh/ruff-action@v1
        # Fix even on other steps failure
        if: ${{ !cancelled() }}
        with:
          args: format

      # ESLint & Dprint autofixes
      - run: npm run lint:fix
        # Fix even on other steps failure
        if: ${{ !cancelled() }}

      # Using https://github.com/marketplace/actions/add-commit
      - 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

      # OR using https://github.com/marketplace/actions/git-auto-commit
      - name: Commit autofixes
        uses: stefanzweifel/git-auto-commit-action@v5
        # 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() }}

About

A simple repository to publicly expose base configurations shared across different Beslogic projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published