⚙️ Configurations
The best configurations is no configuration.
Defaults are there for a reason. Start with the defaults and only change them when you have a good reason to.
However, these are some opinionated configurations to get started for a new project.
For system-wide configurations, see dotfiles.
Dependabot
# dependabot.yml
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference
version: 2
updates:
# Docker
- package-ecosystem: "docker"
directory: "/"
target-branch: "develop" # Add this line if using GitHub Flow or GitFlow
schedule:
interval: "daily"
assignees:
- "tomy0000000"
reviewers:
- "tomy0000000"
commit-message:
prefix: "⬆️ bump: "
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/" # Don't change this
target-branch: "develop" # Add this line if using GitHub Flow or GitFlow
schedule:
interval: "daily"
assignees:
- "tomy0000000"
reviewers:
- "tomy0000000"
commit-message:
prefix: "⬆️ bump: "
# npm, yarn, pnpm
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: "/"
target-branch: "develop" # Add this line if using GitHub Flow or GitFlow
schedule:
interval: "daily"
assignees:
- "tomy0000000"
reviewers:
- "tomy0000000"
commit-message:
prefix: "⬆️ bump: "
# pip, pip-compile, pipenv, poetry
- package-ecosystem: "pip"
directory: "/"
target-branch: "develop" # Add this line if using GitHub Flow or GitFlow
schedule:
interval: "daily"
assignees:
- "tomy0000000"
reviewers:
- "tomy0000000"
commit-message:
prefix: "⬆️ bump: "
EditorConfig
# .editorconfig
# https://editorconfig.org/
# top-most EditorConfig file
root = true
# Global style
[*]
charset = utf-8 # Set default charset
end_of_line = lf # Unix-style newlines
insert_final_newline = true # Ensure newline at the end of file
# Go
# https://go.dev/doc/effective_go#formatting
[*.{go}]
indent_style = tab
indent_size = 4
# JavaScript / TypeScript
[*.{css,html,js,json,jsx,scss,ts,tsx,yaml,yml}]
indent_style = space
indent_size = 2
max_line_length = 80 # Prettier default
# Makefiles
[Makefile,*.mk]
indent_style = tab
indent_size = 4
# Python
# https://peps.python.org/pep-0008/#indentation
[*.{py}]
indent_style = space
indent_size = 4
# PEP 8 recommends:
# 72 for docstrings
# 79 for code (or up to 99)
max_line_length = 88
# Ruby
# https://rubystyle.guide/#tabs-or-spaces
[*.{rb}]
indent_style = space
indent_size = 2
# Shell scripts
[*.{sh}]
indent_style = space
indent_size = 4
pyproject.toml
[project]
# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
name = ""
version = ""
description = ""
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.12,<4.0.0"
authors = [{ name = "Tomy Hsieh", email = "pypi@tomy.me" }]
dependencies = [
]
[project.urls]
repository = ""
issues = ""
documentation = ""
[build-system]
# Choose from "setuptools", "flit", "poetry", "flit_core", "pdm-backend"
requires = []
build-backend = ""
[tool.black]
# https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html
line-length = 88 # This is the default
[tool.coverage.run]
# https://coverage.readthedocs.io/en/latest/config.html
source = ["the_app"]
omit = ["the_app/tests/*"]
[tool.coverage.report]
show_missing = true
[tool.isort]
# https://pycqa.github.io/isort/docs/configuration/config_files.html
src_paths = ["the_app"]
profile = "black"
[tool.mypy]
# https://mypy.readthedocs.io/en/stable/config_file.html
strict = true
exclude = ["venv", ".venv", "alembic"]
[tool.poetry]
# https://python-poetry.org/docs/pyproject/
package-mode = false # Add this if you're writing a app instead of a library
[tool.pytest.ini_options]
# https://docs.pytest.org/en/stable/reference/customize.html#configuration-file-formats
addopts = "--capture=no" # This will show the output of print statements
[tool.ruff]
# https://docs.astral.sh/ruff/settings/
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"ARG001", # unused arguments in functions
]
[tool.uv]
# https://docs.astral.sh/uv/reference/settings/
ESLint
Use eslint.config.js
and change to eslint.config.ts
once the feature is stable.
// eslint.config.js
// https://eslint.org/docs/latest/use/configure/configuration-files
import js from "@eslint/js";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
);
Jest
// jest.config.ts
// https://jestjs.io/docs/configuration
Prettier
// .prettierrc
// https://prettier.io/docs/en/configuration.html
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": false
}
TypeScript
// `tsconfig.json`
// https://www.typescriptlang.org/tsconfig/
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
compilerOptions.target
The version to compile down to. Should be the minimum version supported by your users and should never be esnext
. Typically, the second or third most recent version is a good choice.
compilerOptions.module
See this guide for more.