Skip to content

marcop135/vite-vanilla-sass-lint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Vite Vanilla JS + Sass β€” No-Fuss Starter

A fast, modern starter template for vanilla JavaScript and Sass, powered by Vite. Includes comprehensive linting, formatting, image optimization, HTML minification, and legacy browser support. Perfect for performant, framework-free frontend apps with strict code quality.

✨ Features

  • ⚑️ Lightning-fast development with Vite
  • 🧱 Pure Vanilla JS & Sass (no frameworks)
  • 🧹 Integrated linting for HTML, CSS/SCSS, and JS
  • πŸ–ΌοΈ Automated image optimization
  • πŸ”§ Minified and templated HTML
  • πŸ•ΈοΈ Legacy browser compatibility
  • πŸŒ€ Autoprefixing for cross-browser CSS
  • πŸ§ͺ Testing with Vitest
  • πŸ”’ Pre-commit hooks with Husky & lint-staged
  • πŸš€ CI/CD pipeline with GitHub Actions

πŸ“¦ Tech Stack

  • Build: Vite
  • Language: Vanilla JavaScript
  • Styles: Dart Sass, modern-normalize
  • Linting: ESLint, Stylelint, HTMLHint
  • Formatting: Prettier
  • Testing: Vitest
  • Git Hooks: Husky, lint-staged
  • CI/CD: GitHub Actions
  • Images: vite-plugin-imagemin
  • HTML: vite-plugin-html
  • PostCSS: Autoprefixer
  • Legacy: @vitejs/plugin-legacy

πŸ§ͺ Project Structure

  • src/ – Source files (HTML, JS, SCSS, assets)
  • dist/ – Production build output
  • index.html – Entry HTML file
  • vite.config.js – Vite config
  • postcss.config.js – PostCSS config
  • eslint.config.js, .stylelintrc, .htmlhintrc – Lint configs
  • prettier.config.mjs – Formatting config
  • package.json – Scripts & dependencies
  • .vscode/ – VSCode workspace settings and recommended extensions

🌐 Browser Support

This starter supports modern browsers and legacy browsers (excluding IE 11) via @vitejs/plugin-legacy:

  • Modern browsers: Latest versions of Chrome, Firefox, Safari, Edge
  • Legacy browsers: Older versions with automatic polyfills and transpilation
  • Target: defaults, not IE 11 (configured in vite.config.js)

The build process generates both modern and legacy bundles for optimal performance and compatibility.

🧩 Vite Plugins


βš™οΈ Requirements

Note: The project uses .nvmrc to specify the Node.js version. If you use nvm, run nvm use to automatically switch to the correct version.

πŸš€ Getting Started

npx degit marcop135/vite-vanilla-sass-lint my-app
cd my-app
npm install
npm run dev

πŸ§ͺ Scripts

npm run dev          # Start dev server
npm run build        # Build for production
npm run preview      # Preview production build
npm run lint         # Lint html, css, scss, and js files
npm run lint:fix     # Lint and auto-fix issues
npm run format       # Format html, css, scss, js, and md files
npm run format:check # Check code formatting
npm run test         # Run tests
npm run test:ui      # Run tests with UI
npm run test:coverage # Run tests with coverage
npm run clean        # Remove dist folder
npm run audit        # Check for security vulnerabilities
npm run audit:fix    # Fix security vulnerabilities

🧹 Linting & Formatting

Includes:

  • eslint – Lint JavaScript (configured in eslint.config.js)
  • stylelint – Lint CSS/SCSS (configured in .stylelintrc)
  • htmlhint – Lint HTML/JSX (configured in .htmlhintrc)
  • prettier – Format code (configured in prettier.config.mjs)

Configuration Highlights

ESLint (eslint.config.js):

  • Enforces strict equality (===)
  • Warns on camelCase violations
  • Errors on undefined variables and unused vars
  • Browser globals enabled

Stylelint (.stylelintrc):

  • Extends stylelint-config-standard-scss
  • Validates SCSS syntax and best practices
  • Custom rules for project flexibility

HTMLHint (.htmlhintrc):

  • Enforces lowercase tags and attributes
  • Requires double quotes for attributes
  • Validates unique IDs and required attributes

πŸ“Œ Run automatically:

npm run lint
npm run format

πŸ“Œ Run manually:

npx eslint "src/assets/js/*.js"
npx stylelint "src/assets/scss/*.{scss,css}"
npx htmlhint "**/*.html"
npx prettier --check "src/**/*.{js,css,scss,html,md}"

πŸ§ͺ Testing

This project uses Vitest for testing.

Running Tests

npm run test         # Run tests in watch mode
npm run test:ui      # Run tests with UI
npm run test:coverage # Run tests with coverage report

Writing Tests

  • Test files should be named *.test.js or *.spec.js
  • Place test files next to the code they test or in a __tests__ directory
  • Use Vitest's API: describe, it, expect, etc.

Example test:

import { describe, it, expect } from 'vitest';

describe('My Feature', () => {
  it('should do something', () => {
    expect(true).toBe(true);
  });
});

πŸ“š Official Documentation


🀝 Contributing

Contributions welcome! Please read CONTRIBUTING.md for guidelines on how to contribute.

πŸ‘€ Author

Marco Pontili

πŸ“ License

Licensed under the MIT License.

About

πŸš€ Vite Vanilla JS + Sass: No-Fuss Starter - Fast setup with ESLint, Stylelint, HTMLHint, modern-normalize, HTML minify, image optimization, and zero-framework simplicity.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors