Code Style Guide
NC-Scorer uses ESLint and Prettier to enforce consistent code style.
Running Linters
bash
# Check and auto-fix issues
npm run lint
# Alternative command
npm run lint:fixStyle Rules
JavaScript/Vue
- Quotes: Single quotes for strings
- Semicolons: Required
- Indentation: 2 spaces
- Line length: 100 characters max
- Trailing commas: Required in multi-line structures
Vue Components
- Use Composition API (
<script setup>) - Place components in appropriate directories:
components/- Reusable componentsviews/- Page components
Example Component
vue
<template>
<v-card>
<v-card-title>{{ title }}</v-card-title>
<v-card-text>{{ content }}</v-card-text>
</v-card>
</template>
<script setup>
import { ref, computed } from 'vue';
const props = defineProps({
title: String,
data: Object,
});
const content = computed(() => {
return props.data?.description || 'No description';
});
</script>Commit Messages
Use conventional commits:
bash
# Use the interactive tool
npm run commitFormat:
<type>(<scope>): <description>
[optional body]
[optional footer]Types:
feat: New featurefix: Bug fixdocs: Documentationstyle: Formattingrefactor: Code restructuringtest: Testschore: Maintenance
Best Practices
- Import order: External deps, then internal modules
- Naming: camelCase for variables, PascalCase for components
- Comments: Explain "why", not "what"
- Functions: Keep them small and focused
- Error handling: Always handle API errors gracefully
