From 226e54e7123839c003afdf7c48f599f2c20b134d Mon Sep 17 00:00:00 2001 From: stradichenko Date: Sun, 26 Apr 2026 14:59:50 +0200 Subject: [PATCH] Unit 2: linting + developer tooling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add .editorconfig (UTF-8, LF, 2-space JS/CSS/HTML/TOML; tabs for Go). - Add .nvmrc pinning Node LTS. - Prettier 3 flat config (.prettierrc.json, .prettierignore). - ESLint 9 flat config (eslint.config.mjs): prefer-const, no-var, eqeqeq, no-unused-vars (warn), no-console (warn except .error), browser+node env. - Stylelint extending stylelint-config-standard (.stylelintrc.json, .stylelintignore). - PostCSS config: autoprefixer + postcss-preset-env stage 2. - package.json: drop broken seo-audit / validate-seo / build:advanced refs; add lint, lint:fix, format, format:check scripts. - Remove package-lock.json from .gitignore so installs are deterministic. - Whole-repo formatting is intentionally NOT applied here — later units format their own changes. --- .editorconfig | 18 ++++++++++++++++++ .gitignore | 1 - .nvmrc | 1 + .prettierignore | 11 +++++++++++ .prettierrc.json | 13 +++++++++++++ .stylelintignore | 5 +++++ .stylelintrc.json | 9 +++++++++ eslint.config.mjs | 25 +++++++++++++++++++++++++ package.json | 24 +++++++++++++++++------- postcss.config.js | 6 ++++++ 10 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 .editorconfig create mode 100644 .nvmrc create mode 100644 .prettierignore create mode 100644 .prettierrc.json create mode 100644 .stylelintignore create mode 100644 .stylelintrc.json create mode 100644 eslint.config.mjs create mode 100644 postcss.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7a9d74e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.go] +indent_style = tab + +[Makefile] +indent_style = tab + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 1e602b0..ae66203 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,6 @@ resources/ # Node.js dependencies node_modules/ -package-lock.json # Hugo build artifacts public/ diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..ee09fac --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v20.11.1 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..7ef555f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +node_modules +exampleSite/public +exampleSite/resources +public +resources +.hugo_build.lock +flake.lock +package-lock.json +*.min.js +*.min.css +static/bibtex diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..15049be --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,13 @@ +{ + "semi": true, + "singleQuote": true, + "trailingComma": "all", + "printWidth": 100, + "tabWidth": 2, + "useTabs": false, + "endOfLine": "lf", + "overrides": [ + { "files": "*.md", "options": { "printWidth": 80, "proseWrap": "preserve" } }, + { "files": "*.html", "options": { "parser": "html" } } + ] +} diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 0000000..b38ddd1 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,5 @@ +node_modules +exampleSite/public +public +resources +**/*.min.css diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000..48d0d71 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,9 @@ +{ + "extends": "stylelint-config-standard", + "rules": { + "declaration-no-important": [true, { "severity": "warning" }], + "custom-property-pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*$", + "selector-class-pattern": null, + "no-descending-specificity": null + } +} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..381fc6b --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,25 @@ +import js from '@eslint/js'; +import globals from 'globals'; + +export default [ + js.configs.recommended, + { + languageOptions: { + ecmaVersion: 2023, + sourceType: 'module', + globals: { ...globals.browser, ...globals.node }, + }, + rules: { + 'prefer-const': 'warn', + 'no-var': 'warn', + eqeqeq: ['warn', 'smart'], + 'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + 'no-console': ['warn', { allow: ['warn', 'error'] }], + }, + }, + { + files: ['scripts/**/*.js'], + languageOptions: { sourceType: 'commonjs' }, + }, + { ignores: ['node_modules', 'exampleSite/public', 'public', 'resources', '**/*.min.js'] }, +]; diff --git a/package.json b/package.json index f97fe40..604907c 100644 --- a/package.json +++ b/package.json @@ -5,23 +5,33 @@ "private": true, "scripts": { "build": "hugo --gc --minify", - "build:advanced": "npm run build && npm run optimize-images && npm run seo-audit", "dev": "hugo server --disableFastRender --navigateToChanged", "optimize-images": "node scripts/optimize-images.js", - "seo-audit": "node scripts/seo-audit.js", - "validate-seo": "node scripts/validate-seo.js" + "lint": "eslint assets/js scripts && stylelint 'assets/css/**/*.css'", + "lint:fix": "eslint --fix assets/js scripts && stylelint --fix 'assets/css/**/*.css'", + "format": "prettier --write 'assets/**/*.{js,css,md}' 'layouts/**/*.html' 'scripts/**/*.js' '**/*.md'", + "format:check": "prettier --check 'assets/**/*.{js,css,md}' 'layouts/**/*.html' 'scripts/**/*.js' '**/*.md'" }, "devDependencies": { - "sharp": "^0.34.0", + "@eslint/js": "^9.0.0", + "autoprefixer": "^10.4.0", + "cheerio": "^1.0.0", + "eslint": "^9.0.0", + "globals": "^15.0.0", "glob": "^11.0.0", - "cheerio": "^1.0.0" + "postcss": "^8.4.0", + "postcss-preset-env": "^9.5.0", + "prettier": "^3.2.0", + "sharp": "^0.34.0", + "stylelint": "^16.0.0", + "stylelint-config-standard": "^36.0.0" }, "engines": { - "node": ">=18.17.0" + "node": ">=20.0.0" }, "repository": { "type": "git", - "url": "https://github.com/your-username/pkb-theme" + "url": "https://github.com/stradichenko/PKB-theme" }, "keywords": [ "hugo", diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..ec964bc --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + autoprefixer: {}, + 'postcss-preset-env': { stage: 2 }, + }, +};