diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..e2d872d --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +node_modules +venv +.venv diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..5417ead --- /dev/null +++ b/.eslintrc @@ -0,0 +1,24 @@ +{ + "extends": [ + "eslint:recommended" + ], + "parserOptions": { + "ecmaVersion": 9 + }, + "env": { + "browser": true + }, + "rules": { + // allow no lines between single line members (e.g. static declarations) + "lines-between-class-members": [ + "error", + "always", + { + "exceptAfterSingleLine": true + } + ], + // note you must disable the base rule as it can report incorrect errors + "no-use-before-define": "off", + "no-underscore-dangle": "error" + } +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 732b74e..60e536c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: hooks: - id: black language_version: python3 - args: ["--target-version", "py37"] + args: ['--target-version', 'py37'] - repo: https://github.com/timothycrosley/isort # isort config is in setup.cfg rev: 5.6.4 @@ -25,3 +25,26 @@ repos: rev: v1.4.13 hooks: - id: djhtml + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.5.1 + hooks: + - id: prettier + types_or: [css, javascript, json, yaml] + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.8.0 + hooks: + - id: eslint + types: [file] + files: \.(js)$ + args: [--report-unused-disable-directives] + additional_dependencies: + - eslint@8.8.0 + - repo: https://github.com/thibaudcolas/pre-commit-stylelint + rev: v14.2.0 + hooks: + - id: stylelint + files: \.css$ + additional_dependencies: + - stylelint@14.9.1 + - stylelint-config-standard@26.0.0 + - stylelint-config-prettier@9.0.3 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..39bd1a1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +# Irrelevant files ignored for performance reasons. +node_modules +venv +.venv +*.min.css +# File types which Prettier supports but we don’t want auto-formatting. +*.md +# Files which contain incompatible syntax. +*.html diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..96fb915 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,14 @@ +{ + "arrowParens": "always", + "bracketSameLine": false, + "bracketSpacing": true, + "embeddedLanguageFormatting": "auto", + "endOfLine": "lf", + "htmlWhitespaceSensitivity": "css", + "printWidth": 80, + "proseWrap": "preserve", + "quoteProps": "consistent", + "semi": true, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 0000000..59f92a5 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,4 @@ +node_modules +venv +.venv +*.min.css diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 0000000..5152b94 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,11 @@ +{ + "extends": ["stylelint-config-standard", "stylelint-config-prettier"], + "rules": { + "no-descending-specificity": null, + "custom-property-pattern": "^([a-z][a-z0-9]*)(-{1,2}[a-z0-9]+)*$", + "selector-class-pattern": [ + "^[a-z]+[0-9]{0,2}(-[a-z0-9]+)*(__[a-z0-9]+(-[a-z0-9]+)*)?(--[a-z0-9]+(-[a-z0-9]+)*)?$", + { "resolveNestedSelectors": true } + ] + } +} diff --git a/Makefile b/Makefile index 85b8083..58e2e85 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,27 @@ help: @echo "lint - check style with black, flake8, sort python with isort, and indent html" @echo "format - enforce a consistent code style across the codebase and sort python files with isort" -lint: +lint-server: black --target-version py37 --check --diff . flake8 isort --check-only --diff . curlylint --parse-only bakerydemo git ls-files '*.html' | xargs djhtml --check -format: +lint-client: + npm run lint:css --silent + npm run lint:js --silent + npm run lint:format --silent + +lint: lint-server lint-client + +format-server: black --target-version py37 . isort . git ls-files '*.html' | xargs djhtml -i + +format-client: + npm run format + npm run fix:js + +format: format-server format-client