From 7045debc66c3ebcd08d37566cb2ea09c987f6224 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 9 Apr 2026 14:16:25 +0200 Subject: [PATCH] feat : add ESLint linter to frontend with pre-commit hook Add ESLint with @nuxt/eslint-config enforcing 4-space indentation. Add make nuxt-lint and nuxt-lint-fix targets. Add ESLint check to pre-commit hook (lint only, no auto-fix). Fix auth.vue indentation from 2 to 4 spaces. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/app/layouts/auth.vue | 10 +++--- frontend/eslint.config.mjs | 60 +++++++++++++++++++++++++++++++++++ frontend/package.json | 12 ++++++- makefile | 6 ++++ pre-commit | 10 ++++++ 5 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 frontend/eslint.config.mjs diff --git a/frontend/app/layouts/auth.vue b/frontend/app/layouts/auth.vue index 117c591..baa8be6 100644 --- a/frontend/app/layouts/auth.vue +++ b/frontend/app/layouts/auth.vue @@ -1,7 +1,7 @@ diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs new file mode 100644 index 0000000..4172559 --- /dev/null +++ b/frontend/eslint.config.mjs @@ -0,0 +1,60 @@ +import nuxt from '@nuxt/eslint-config' + +export default await nuxt( + { + features: { + stylistic: false, + typescript: true, + nuxt: { + sortConfigKeys: false, + }, + }, + dirs: { + root: ['.', './app'], + }, + }, + { + name: 'coltura/custom-overrides', + rules: { + // Indentation 4 espaces (convention CLAUDE.md) + 'vue/html-indent': ['error', 4], + indent: ['error', 4, { SwitchCase: 1 }], + + // Vue — relaxed + 'vue/multi-word-component-names': 'off', + 'vue/no-multiple-template-root': 'off', + 'vue/require-default-prop': 'off', + 'vue/html-self-closing': 'off', + 'vue/singleline-html-element-content-newline': 'off', + 'vue/multiline-html-element-content-newline': 'off', + 'vue/attributes-order': 'off', + 'vue/v-on-event-hyphenation': 'off', + + // Console — allow console.error only + 'no-console': ['warn', { allow: ['error'] }], + + // Unused vars — warn, ignore underscore-prefixed + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['warn', { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }], + + // TypeScript — progressive strictness + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-dynamic-delete': 'off', + '@typescript-eslint/no-invalid-void-type': 'off', + + // Formatting — leave to stylistic tools + 'require-await': 'off', + 'comma-dangle': 'off', + curly: 'off', + semi: 'off', + quotes: 'off', + 'no-trailing-spaces': 'off', + 'no-multiple-empty-lines': 'off', + 'no-irregular-whitespace': 'off', + }, + }, +) diff --git a/frontend/package.json b/frontend/package.json index f0a806b..adf892b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,9 @@ "generate": "nuxt generate", "preview": "nuxt preview", "postinstall": "nuxt prepare", - "build:dist": "nuxt generate && rm -rf dist && cp -R .output/public dist" + "build:dist": "nuxt generate && rm -rf dist && cp -R .output/public dist", + "lint": "eslint .", + "lint:fix": "eslint . --fix" }, "dependencies": { "@malio/layer-ui": "^1.2.3", @@ -21,5 +23,13 @@ "pinia": "^3.0.4", "vue": "^3.5.29", "vue-router": "^4.6.4" + }, + "devDependencies": { + "@nuxt/eslint-config": "^1.9.0", + "@typescript-eslint/eslint-plugin": "^8.44.1", + "@typescript-eslint/parser": "^8.44.1", + "eslint": "^9.36.0", + "eslint-plugin-vue": "^10.5.0", + "vue-eslint-parser": "^10.2.0" } } diff --git a/makefile b/makefile index cd29cc5..3c28f89 100644 --- a/makefile +++ b/makefile @@ -53,6 +53,12 @@ build-nuxtJS: dev-nuxt: $(EXEC_PHP) sh -c "cd frontend && npm run dev" +nuxt-lint: + $(EXEC_PHP) sh -c "cd frontend && npm run lint" + +nuxt-lint-fix: + $(EXEC_PHP) sh -c "cd frontend && npm run lint:fix" + delete_built_dir: CURRENT_UID=$(shell id -u) CURRENT_GID=$(shell id -g) $(DOCKER_COMPOSE) up -d $(DOCKER) exec -u root $(PHP_CONTAINER) rm -rf vendor/ diff --git a/pre-commit b/pre-commit index 21c1f12..81d4db8 100755 --- a/pre-commit +++ b/pre-commit @@ -24,6 +24,16 @@ else fi echo "--- php-cs-fixer pre commit hook finish---" +echo "--- eslint pre commit hook start ---" +make nuxt-lint +ESLINT_RESULT=$? + +if [ $ESLINT_RESULT -ne 0 ]; then + echo "ESLint failed. Aborting commit." + exit 1 +fi +echo "--- eslint pre commit hook finished ---" + echo "--- phpunit pre commit hook start ---" make test PHPUNIT_RESULT=$?