npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

frontend-standards

v1.0.29

Published

A tool to help you catch syntax and formatting errors before your pipeline does. Setups ESlint, Prettier and Husky.

Downloads

1,538

Readme

🚀 Frontend Standards

Frontend Standards is a package that automatically sets up ESLint, Prettier, and Husky in your workspace, helping you catch syntax errors and maintain consistent code style before your code reaches the pipeline.

📋 Table of Contents


📦 Installation

The setup script will run automatically when you install the package, so all you need to do is:

npm install @mh-common/frontend-standards

If you can't find the husky directory and the other files like .eslintrc.cjs, .prettierrc etc. run the following command:

node node_modules/@mh-common/frontend-standards/install.js

The setup script will:

  • Install ESLint, Prettier, and Husky dependencies in your workspace.
  • Copy configuration files to the root of your workspace.
  • Initialize Git (if not already initialized) and set up Husky with a pre-commit hook.

Once installed, Frontend Standards is ready to enforce code quality and consistency with zero additional setup.


⚙️ Features

  • Consistent Formatting: Prettier ensures that your code has a uniform style, making it easier to read and maintain.
  • Linting: ESLint helps you catch syntax errors and common code issues, improving overall code quality and reducing bugs.
  • Git Hooks: Husky’s pre-commit hooks run checks before you commit, allowing you to catch and fix issues locally before they reach your repository or pipeline.

Why Linting?

Linting helps detect potential errors, code smells, and deviations from best practices. This prevents bugs from reaching production and makes the code easier to review and maintain.

Why Formatting?

Consistent code formatting improves readability and reduces friction between team members working on the same codebase, as it eliminates style-based diffs in version control.

Why Use This Setup?

Using this package allows you to catch issues before they reach the pipeline, saving you time and reducing the risk of failed builds. It’s better to identify errors locally than discover them after pushing code.


🔧 Usage

Automated Pre-commit Hook

Whenever you commit, a pre-commit hook will automatically run:

npx eslint --fix .

This will check your code for linting and formatting issues, automatically fixing any easy-to-solve errors before they’re committed. This ensures cleaner commits and reduces the need for manual code corrections.


🔌 Recommended Extensions

To ensure a consistent development experience, we recommend installing the following VS Code extensions:

  • Prettier - Code formatter by Esben Petersen (esbenp.prettier-vscode)
  • ESLint by Microsoft (dbaeumer.vscode-eslint)
  • Prettier ESLint by Rebecca Vest (rvest.vs-code-prettier-eslint)

📜 Pipeline

To automate linting and formatting checks in a Bitbucket pipeline, you can add a configuration to your bitbucket-pipelines.yml file. This ensures that all code changes meet your code quality standards before being merged.

Here’s an example of a Bitbucket pipeline setup:

image: node:latest

pipelines:
  default:
    - step:
        name: Lint and Format Check
        caches:
          - node
        script:
          - npm install
          - npx eslint .

This configuration runs ESLint and Prettier checks on every push to ensure that all code follows the defined style and linting rules.