diff --git a/.gitignore b/.gitignore index f43ead6..e2d121a 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,11 @@ .Trashes ehthumbs.db Thumbs.db + +# Node.js # +########### +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +package-lock.json diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..8c09561 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,11 @@ +{ + "default": true, + "MD001": false, + "MD013": false, + "MD033": { + "allowed_elements": ["details", "summary", "img", "br", "h2"] + }, + "MD041": false, + "MD034": false, + "MD036": false +} diff --git a/GIT_GUIDE.md b/GIT_GUIDE.md index a650688..9346cea 100644 --- a/GIT_GUIDE.md +++ b/GIT_GUIDE.md @@ -1,9 +1,11 @@ # Git Repository Management Guide + ## Industry Standard Best Practices for Beginners --- ## Table of Contents + 1. [Initial Setup (New Repository)](#initial-setup-new-repository) 2. [Daily Workflow](#daily-workflow) 3. [Branch Management](#branch-management) @@ -290,6 +292,7 @@ git stash clear ### Commit Messages **Good Commit Messages:** + ```bash git commit -m "Add user authentication feature" git commit -m "Fix bug in login validation" @@ -298,6 +301,7 @@ git commit -m "Refactor database connection logic" ``` **Bad Commit Messages:** + ```bash git commit -m "stuff" git commit -m "fixed it" @@ -306,7 +310,8 @@ git commit -m "changes" ``` **Format Convention:** -``` + +```text : Types: @@ -327,6 +332,7 @@ git commit -m "docs: update API documentation" ### When to Commit **DO Commit When:** + - You've completed a logical unit of work - You've fixed a bug - You've added a feature (even if small) @@ -334,6 +340,7 @@ git commit -m "docs: update API documentation" - End of your work session **DON'T Commit When:** + - Code doesn't work/run - Code has syntax errors - You're in the middle of something @@ -341,17 +348,20 @@ git commit -m "docs: update API documentation" ### When to Branch **Create a New Branch When:** + - Starting a new feature - Fixing a bug - Experimenting with something - Each separate task **Work Directly on Main When:** + - Almost never! (exception: very simple docs-only repos) ### Pull Before Push **Always do this:** + ```bash git pull origin main # Then resolve any conflicts @@ -359,6 +369,7 @@ git push origin main ``` **Not this:** + ```bash git push origin main # May fail if remote has changes ``` @@ -546,6 +557,7 @@ git checkout other-branch ## Quick Reference Commands ### Status & Information + ```bash git status # See what's changed git log # See commit history @@ -559,6 +571,7 @@ git remote -v # Show remote repositories ``` ### Basic Operations + ```bash git add # Stage specific file git add . # Stage all changes @@ -569,6 +582,7 @@ git fetch origin # Update remote references ``` ### Branching + ```bash git checkout -b # Create and switch to branch git checkout # Switch to existing branch @@ -577,6 +591,7 @@ git branch -d # Delete local branch ``` ### Undoing + ```bash git checkout -- # Discard changes to file git reset HEAD # Unstage file @@ -600,6 +615,7 @@ Before using `--force`, `--hard`, or deleting things: - [ ] Do I know how to undo this? **When in doubt, create a backup branch:** + ```bash git branch backup-$(date +%Y%m%d) ``` @@ -618,6 +634,7 @@ git branch backup-$(date +%Y%m%d) ## Notes for Future You Remember: + 1. **Commit often** - Small commits are better than large ones 2. **Pull before push** - Always sync before sharing 3. **Branch for everything** - Keep main clean @@ -628,4 +645,4 @@ Remember: --- **Last Updated:** 2025-11-16 -**Repository:** learning (practice/educational use) \ No newline at end of file +**Repository:** learning (practice/educational use) diff --git a/MARKDOWN_MAINTENANCE.md b/MARKDOWN_MAINTENANCE.md new file mode 100644 index 0000000..683e023 --- /dev/null +++ b/MARKDOWN_MAINTENANCE.md @@ -0,0 +1,354 @@ +# Markdown Maintenance Guide + +## Overview + +This repository uses **markdownlint-cli** to maintain consistent, high-quality markdown files. + +## Quick Start + +### Daily Workflow + +```bash +# Check for lint errors +npm run lint:md:check + +# Auto-fix most errors +npm run lint:md:fix + +# Review changes +git diff + +# Commit if satisfied +git add . +git commit -m "docs: fix markdown lint errors" +``` + +## Installation + +Dependencies are already installed. If you need to reinstall: + +```bash +npm install +``` + +## Available Commands + +### Using npm scripts (Recommended) + +```bash +# Check for errors (doesn't modify files) +npm run lint:md + +# Check with helpful message +npm run lint:md:check + +# Auto-fix errors (modifies files) +npm run lint:md:fix + +# Clean all markdown files (alias for fix) +npm run clean:md +``` + +### Using shell scripts + +```bash +# Check for errors +./scripts/check-markdown.sh + +# Auto-fix errors +./scripts/fix-markdown.sh + +# Setup pre-commit hook (optional) +./scripts/setup-pre-commit.sh +``` + +## Understanding Lint Errors + +### Common Errors and Fixes + +#### MD022 - Headings should be surrounded by blank lines + +**Bad:** + +```markdown +## Heading +Text immediately below +``` + +**Good:** + +```markdown +## Heading + +Text with blank line above +``` + +**Fix:** Auto-fixable ✅ + +--- + +#### MD013 - Line length + +**Bad:** + +```markdown +This is a very long line that exceeds the 120 character limit and needs to be broken up into multiple lines for better readability. +``` + +**Good:** + +```markdown +This is a very long line that exceeds the 120 character limit and needs to be +broken up into multiple lines for better readability. +``` + +**Fix:** Manual ❌ (requires rewording) + +--- + +#### MD040 - Fenced code blocks should have a language + +**Bad:** + +````markdown +``` +code here +``` +```` + +**Good:** + +````markdown +```bash +code here +``` +```` + +**Fix:** Manual ❌ (you need to specify the language) + +**Common languages:** `bash`, `javascript`, `python`, `json`, `yaml`, `markdown`, `text` + +--- + +#### MD032 - Lists should be surrounded by blank lines + +**Bad:** + +```markdown +Text before list +- Item 1 +- Item 2 +Text after list +``` + +**Good:** + +```markdown +Text before list + +- Item 1 +- Item 2 + +Text after list +``` + +**Fix:** Auto-fixable ✅ + +--- + +#### MD009 - No trailing spaces + +**Bad:** + +```markdown +Line with trailing spaces +``` + +**Good:** + +```markdown +Line without trailing spaces +``` + +**Fix:** Auto-fixable ✅ + +--- + +#### MD047 - Files should end with a single newline + +**Fix:** Auto-fixable ✅ + +--- + +## Configuration + +### .markdownlint.json + +The configuration file is located at `.markdownlint.json`: + +```json +{ + "default": true, + "MD013": { + "line_length": 120 + }, + "MD033": { + "allowed_elements": ["details", "summary", "img", "br", "h2"] + }, + "MD041": false, + "MD034": false, + "MD036": false +} +``` + +**What this means:** + +- **default: true** - Enable all rules by default +- **MD013** - Line length limit set to 120 characters (relaxed from default 80) +- **MD033** - Allow specific HTML elements (for GitHub-flavored markdown) +- **MD041** - Disabled (allows files to start with elements other than h1) +- **MD034** - Disabled (allows bare URLs) +- **MD036** - Disabled (allows emphasis used instead of headings) + +### Customizing Rules + +To disable a rule, add it to `.markdownlint.json`: + +```json +{ + "MD013": false +} +``` + +To configure a rule: + +```json +{ + "MD013": { + "line_length": 100, + "heading_line_length": 120 + } +} +``` + +## Pre-commit Hook (Optional) + +To automatically check markdown files before each commit: + +```bash +./scripts/setup-pre-commit.sh +``` + +This will: + +- Check all staged `.md` files before commit +- Block commits if lint errors are found +- Show helpful error messages + +**Bypass the hook** (when needed): + +```bash +git commit --no-verify +``` + +## Maintenance Schedule + +### Recommended workflow + +1. **Before committing:** Run `npm run lint:md:fix` +2. **Before pushing:** Run `npm run lint:md:check` +3. **Weekly:** Review and fix any remaining manual errors +4. **When adding new files:** Run linter on new markdown files + +## Troubleshooting + +### "markdownlint-cli is not installed" + +```bash +npm install +``` + +### "I want to ignore a specific rule for one line" + +Add a comment above the line: + +```markdown + +This is a really long line that I want to keep as-is for some reason + +``` + +### "I want to ignore a file" + +Create `.markdownlintignore`: + +```text +node_modules/ +dist/ +CHANGELOG.md +``` + +### "I want to see all available rules" + +Visit: + +## Best Practices + +1. **Run linter before committing** - Catch errors early +2. **Use auto-fix first** - Let the tool handle most issues +3. **Fix manual errors gradually** - Don't need to fix everything at once +4. **Configure, don't disable** - Adjust rules rather than disabling them +5. **Keep line length reasonable** - Makes diffs easier to review +6. **Use consistent heading styles** - Improves readability + +## Current Status + +Last auto-fix run: Fixed **32 errors** automatically + +Remaining issues: **29 errors** (mostly line length and missing code block languages) + +Most common remaining errors: + +- **MD013** - Line length violations (requires manual rewording) +- **MD040** - Missing language specifiers on code blocks +- **MD001** - Heading level increments +- **MD029** - Ordered list numbering + +## Additional Tools (Optional) + +### VS Code Extension + +Install "markdownlint" extension by David Anson: + +- Real-time linting as you type +- Quick fixes with one click +- Integrates with your `.markdownlint.json` config + +### GitHub Actions (Future Enhancement) + +Add automated markdown linting to PR checks: + +```yaml +name: Markdown Lint +on: [pull_request] +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - run: npm install + - run: npm run lint:md +``` + +## Resources + +- [Markdownlint GitHub](https://github.com/DavidAnson/markdownlint) +- [Markdownlint Rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md) +- [Markdown Guide](https://www.markdownguide.org/) +- [GitHub Flavored Markdown Spec](https://github.github.com/gfm/) + +--- + +**Last Updated:** 2025-11-18 +**Repository:** learning (practice/educational use) diff --git a/README.md b/README.md index 85701e7..37394a3 100644 --- a/README.md +++ b/README.md @@ -96,16 +96,18 @@ Creating a branch allows you to edit to your project without changing the `main` ### :keyboard: Activity: Your first commit -The following steps will guide you through the process of committing a change on GitHub. Committing a change requires first adding a new file to your new branch. +The following steps will guide you through the process of committing a change on GitHub. Committing a change requires first adding a new file to your new branch. 1. On the **Code** tab, make sure you're on your new branch `my-first-branch`. 2. Select the **Add file** drop-down and click **Create new file**.
![create new file option](/images/create-new-file.png) 3. In the **Name your file...** field, enter `PROFILE.md`. 4. In the **Edit new file** area, copy the following content to your file: - ``` + + ```markdown Welcome to my GitHub profile! ``` + profile.md file screenshot 5. For commits, you can enter a short commit message that describes what you changes you made. This helps others know what's included in your commit. GitHub offers a simple default message, but let's change it slightly for practice. Enter `Add PROFILE.md` in the first text-entry field below **Commit new file**. Then, if you want to confirm what your screen should look like, expand the dropdown below.
@@ -180,13 +182,14 @@ You successfully created a pull request. You can now merge your pull request. As noted in the previous step, you may have seen evidence of an action running which automatically progresses your instructions to the next step. You'll have to wait for it to finish before you can merge your pull request. It will be ready when the merge pull request button is green. ![screenshot of green merge pull request button](/images/Green-merge-pull-request.png) + ### :keyboard: Activity: Merge the pull request 1. Click **Merge pull request**. 1. Click **Confirm merge**. 1. Once your branch has been merged, you don't need it anymore. To delete this branch, click **Delete branch**.
screenshot showing delete branch button -2. Check out the **Finish** step to see what you can learn next!
+1. Check out the **Finish** step to see what you can learn next!
**Note**: Like before, you can wait about 20 seconds, then refresh this page (the one you're following instructions from) and [GitHub Actions](https://docs.github.com/en/actions) will automatically close this step and open the next one.
@@ -213,6 +216,7 @@ Here's a recap of your accomplishments: ### What's next? If you'd like to make a profile README, use the simplified instructions below or follow the instructions in the [Managing your profile README](https://docs.github.com/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme) article. + 1. Make a new public repository with a name that matches your GitHub username. 2. Create a file named `README.md` in it's root. The "root" means not inside any folder in your repository. 3. Edit the contents of the `README.md` file. @@ -221,6 +225,7 @@ Here's a recap of your accomplishments: 6. Lastly, we'd love to hear what you thought of this course [in our discussion board](https://github.com/skills/.github/discussions). Check out these resources to learn more or get involved: + - Are you a student? Check out the [Student Developer Pack](https://education.github.com/pack). - [Take another GitHub Skills course](https://github.com/skills). - [Read the GitHub Getting Started docs](https://docs.github.com/en/get-started). diff --git a/package.json b/package.json new file mode 100644 index 0000000..9272cc0 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "learning", + "version": "1.0.0", + "description": "Personal learning repository with markdown maintenance", + "private": true, + "scripts": { + "lint:md": "markdownlint '**/*.md' --ignore node_modules", + "lint:md:fix": "markdownlint '**/*.md' --ignore node_modules --fix", + "lint:md:check": "markdownlint '**/*.md' --ignore node_modules || echo '\\nRun: npm run lint:md:fix to auto-fix issues'", + "clean:md": "npm run lint:md:fix && echo '✅ Markdown files cleaned successfully!'" + }, + "devDependencies": { + "markdownlint-cli": "^0.39.0" + }, + "keywords": [ + "learning", + "documentation", + "markdown" + ], + "author": "", + "license": "ISC" +} diff --git a/scripts/check-markdown.sh b/scripts/check-markdown.sh new file mode 100755 index 0000000..5a0df22 --- /dev/null +++ b/scripts/check-markdown.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# check-markdown.sh - Check markdown files for lint errors +# Usage: ./scripts/check-markdown.sh + +set -e + +echo "🔍 Checking markdown files for lint errors..." +echo "" + +# Check if markdownlint is installed +if ! command -v markdownlint &> /dev/null; then + echo "❌ markdownlint-cli is not installed" + echo "📦 Install it with: npm install" + exit 1 +fi + +# Run markdownlint +if markdownlint '**/*.md' --ignore node_modules; then + echo "" + echo "✅ All markdown files are clean!" + exit 0 +else + echo "" + echo "⚠️ Lint errors found!" + echo "💡 Run './scripts/fix-markdown.sh' to auto-fix most issues" + exit 1 +fi diff --git a/scripts/fix-markdown.sh b/scripts/fix-markdown.sh new file mode 100755 index 0000000..96127e5 --- /dev/null +++ b/scripts/fix-markdown.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# fix-markdown.sh - Automatically fix markdown lint errors +# Usage: ./scripts/fix-markdown.sh + +set -e + +echo "🔧 Fixing markdown files..." +echo "" + +# Check if markdownlint is installed +if ! command -v markdownlint &> /dev/null; then + echo "❌ markdownlint-cli is not installed" + echo "📦 Install it with: npm install" + exit 1 +fi + +# Count files before fixing +MD_FILES=$(find . -name "*.md" -not -path "./node_modules/*" | wc -l) +echo "📄 Found $MD_FILES markdown file(s)" +echo "" + +# Run markdownlint with --fix +if markdownlint '**/*.md' --ignore node_modules --fix; then + echo "" + echo "✅ Markdown files fixed successfully!" + echo "💡 Review the changes with: git diff" +else + echo "" + echo "⚠️ Some issues couldn't be auto-fixed" + echo "📖 Check the errors above and fix manually" + exit 1 +fi + +# Show what changed +echo "" +echo "📊 Summary of changes:" +git diff --stat -- "*.md" || echo "No changes made" diff --git a/scripts/setup-pre-commit.sh b/scripts/setup-pre-commit.sh new file mode 100755 index 0000000..4795ac1 --- /dev/null +++ b/scripts/setup-pre-commit.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# setup-pre-commit.sh - Install pre-commit hook for markdown linting +# Usage: ./scripts/setup-pre-commit.sh + +set -e + +HOOK_FILE=".git/hooks/pre-commit" + +echo "⚙️ Setting up pre-commit hook for markdown linting..." +echo "" + +# Create the pre-commit hook +cat > "$HOOK_FILE" << 'EOF' +#!/bin/bash +# Pre-commit hook - Check markdown files before commit + +echo "🔍 Running markdown lint check..." + +# Get list of staged markdown files +STAGED_MD_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.md$' || true) + +if [ -z "$STAGED_MD_FILES" ]; then + echo "ℹ️ No markdown files to check" + exit 0 +fi + +# Check if markdownlint is installed +if ! command -v markdownlint &> /dev/null; then + echo "⚠️ markdownlint-cli is not installed, skipping check" + echo "💡 Install with: npm install" + exit 0 +fi + +# Run markdownlint on staged files +echo "📄 Checking:" +echo "$STAGED_MD_FILES" | sed 's/^/ - /' +echo "" + +if echo "$STAGED_MD_FILES" | xargs markdownlint; then + echo "✅ Markdown lint check passed!" + exit 0 +else + echo "" + echo "❌ Markdown lint errors found!" + echo "💡 Fix with: npm run lint:md:fix" + echo "⏭️ Or commit anyway with: git commit --no-verify" + exit 1 +fi +EOF + +# Make the hook executable +chmod +x "$HOOK_FILE" + +echo "✅ Pre-commit hook installed at: $HOOK_FILE" +echo "" +echo "🎯 Now markdown files will be checked automatically before each commit!" +echo "💡 To bypass the check, use: git commit --no-verify"