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) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-tertiary-500 from-tertiary-500 via-white to-neutral-100 text-neutral-900">
|
||||
<main class="mx-auto flex min-h-screen w-full max-w-[720px] items-center px-6 py-12">
|
||||
<slot />
|
||||
</main>
|
||||
</div>
|
||||
<div class="min-h-screen bg-tertiary-500 from-tertiary-500 via-white to-neutral-100 text-neutral-900">
|
||||
<main class="mx-auto flex min-h-screen w-full max-w-[720px] items-center px-6 py-12">
|
||||
<slot />
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
60
frontend/eslint.config.mjs
Normal file
60
frontend/eslint.config.mjs
Normal file
@@ -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',
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
6
makefile
6
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/
|
||||
|
||||
10
pre-commit
10
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=$?
|
||||
|
||||
Reference in New Issue
Block a user