Skip to content

Commit

Permalink
Switch to biome
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 16, 2024
1 parent 6514a6f commit 1252e93
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 143 deletions.
33 changes: 0 additions & 33 deletions .eslintrc.js

This file was deleted.

39 changes: 22 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
exclude: ".yarn/|yarn.lock|static/f3cc"
exclude: ".yarn/|yarn.lock|\\.min\\.(css|js)$|static"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-builtin-literals
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.20.0
rev: 1.21.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.2"
rev: "v0.6.4"
hooks:
- id: ruff
args: [--unsafe-fixes]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
- repo: https://github.com/biomejs/pre-commit
rev: "v0.4.0"
hooks:
- id: prettier
args: [--list-different, --no-semi, "--trailing-comma=es5"]
exclude: "^conf/|.*\\.html$"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.56.0
- id: biome-check
additional_dependencies: ["@biomejs/[email protected]"]
args: [--unsafe]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.3
hooks:
- id: eslint
additional_dependencies:
- [email protected]
- eslint-config-prettier
- "@babel/core"
- "@babel/eslint-parser"
- "@babel/preset-env"
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
hooks:
- id: validate-pyproject
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Reorganized the repository a bit.
- Fixed and simplified the Google Consent Management integration.
- Added SRF support to the embedding functionality.
- Updated the pre-commit hooks, switched to biome.

## 1.5 (2024-05-05)

Expand Down
57 changes: 57 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"noSvgWithoutTitle": "off"
},
"correctness": {
"noUndeclaredVariables": "error",
"noUnusedImports": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "error",
"useHookAtTopLevel": "error"
},
"security": {
"noDangerouslySetInnerHtml": "warn"
},
"style": {
"noParameterAssign": "off",
"useForOf": "warn"
},
"suspicious": {
"noArrayIndexKey": "warn",
"noAssignInExpressions": "off"
}
}
},
"javascript": {
"formatter": {
"semicolons": "asNeeded"
},
"globals": ["django", "CKEDITOR"]
},
"css": {
"formatter": {
"enabled": true
},
"linter": {
"enabled": true
}
},
"json": {
"formatter": {
"enabled": false
}
}
}
10 changes: 5 additions & 5 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const esbuild = require("esbuild")

const path = require("path")
const util = require("util")
const readFile = util.promisify(require("fs").readFile)
const path = require("node:path")
const util = require("node:util")
const readFile = util.promisify(require("node:fs").readFile)

const InlineCSSPlugin = (_options = {}) => {
return {
Expand All @@ -22,11 +22,11 @@ const InlineCSSPlugin = (_options = {}) => {

async function generateInjectCSS(sourcePath) {
const sourceCSS = await readFile(sourcePath)
let transformed = await esbuild.transform(sourceCSS, {
const transformed = await esbuild.transform(sourceCSS, {
loader: "css",
minify: true,
})
const minified = ("" + transformed.code.trim())
const minified = `${transformed.code.trim()}`
.replaceAll(/\s+/g, " ")
.replaceAll(/\s*([{},;:])\s*/g, "$1")

Expand Down
2 changes: 1 addition & 1 deletion feincms3_cookiecontrol/static/f3cc.js

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

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"scripts": {
"build": "node esbuild.js"
},
"eslintIgnore": [
"**/build.*"
],
"prettier": {
"semi": false
}
Expand Down
90 changes: 43 additions & 47 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

requires = [ "hatchling" ]

[project]
name = "feincms3-cookiecontrol"
dynamic = ["version"]
description = "Cookie Control Panel for GDPR compliant feincms3 websites"
readme = "README.rst"
license = "BSD-3-Clause"
requires-python = ">=3.9"
license = { text = "BSD-3-Clause" }
authors = [
{ name = "York Schickl", email = "[email protected]" },
{ name = "York Schickl", email = "[email protected]" },
]
requires-python = ">=3.9"
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Application Frameworks",
]
dynamic = [ "version" ]
dependencies = [
"Django>=3.2",
"feincms3>=5.2.2",
"django>=3.2",
"feincms3>=5.2.2",
]

[project.optional-dependencies]
tests = [
"coverage",
"requests",
optional-dependencies.tests = [
"coverage",
"requests",
]

[project.urls]
Homepage = "https://github.com/feinheit/feincms3-cookiecontrol/"
urls.Homepage = "https://github.com/feinheit/feincms3-cookiecontrol/"

[tool.hatch.build]
include = ["feincms3_cookiecontrol/"]
include = [ "feincms3_cookiecontrol/" ]

[tool.hatch.version]
path = "feincms3_cookiecontrol/__init__.py"

[tool.ruff]
target-version = "py39"

fix = true
show-fixes = true
extend-select = [
# pyflakes, pycodestyle
"F", "E", "W",
"F",
"E",
"W",
# mmcabe
"C90",
# isort
Expand Down Expand Up @@ -97,21 +102,12 @@ extend-ignore = [
# No line length errors
"E501",
]
fix = true
show-fixes = true
target-version = "py39"

[tool.ruff.isort]
combine-as-imports = true
lines-after-imports = 2

[tool.ruff.mccabe]
max-complexity = 15

[tool.ruff.per-file-ignores]
"*/migrat*/*" = [
mccabe.max-complexity = 15
per-file-ignores."*/migrat*/*" = [
# Allow using PascalCase model names in migrations
"N806",
# Ignore the fact that migration files are invalid module names
"N999",
]
isort.combine-as-imports = true
isort.lines-after-imports = 2
1 change: 1 addition & 0 deletions src/gcm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
window.dataLayer = window.dataLayer || []
function gtag() {
// biome-ignore lint/style: arguments is fine here.
window.dataLayer.push(arguments)
}
gtag("consent", "default", {
Expand Down
Loading

0 comments on commit 1252e93

Please sign in to comment.