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 🙏

© 2026 – Pkg Stats / Ryan Hefner

shopback-test

v1.0.1

Published

A Node.js package scan a HTML content and show all of SEO defects

Downloads

8

Readme

const { Validator, InputType, OutputType } = require('shopback-test');
const config = require('./config'); // see Custom Configuration for more details
const validator = new Validator(config);

// Skip predefined 1-index based rules
validator.skipRules([1,4,5]);

// Set input type. There are 2 types: FILE and STREAM. It's by default FILE
validator.setInput(InputType.STREAM);

// Set output type. There are 3 types: CONSOLE, FILE and STREAM. It's by default CONSOLE
validator.setOutput(OutputType.FILE);

validator
  .validate()
  .then(async () => await validator.getResult())
  .catch(err => console.error(err));

Requirements

Node.js 8.0 or greater

Installation

npm install shopback-test

Predefined Rules

  1. Detect if there are any <img /> tags without alt attribute
  2. Detect if there are any <a /> tags without rel attribute
  3. Detect if there is any header that doesn’t have <title> tag
  4. Detect if there is any header that doesn’t have <meta name="descriptions" … /> tag
  5. Detect if there is any header that doesn’t have <meta name="keywords" … /> tag
  6. Detect if there are more than 15 <strong> tag in HTML
  7. Detect if a HTML have more than one <h1> tag

API

Custom Configuration

Cloning configuration from config/config.js of shopback-test module as a custom configuration in your Nodejs project, then change the value of properties as you desire. If no custom configuration isn't given, the default configuration in the module will be used instead.

const { Validator, InputType, OutputType } = require('shopback-test');
const config = require('./config');
const validator = new Validator(config);

Rule

const {
    TagExistenceRule,
    TagExistenceWithAttrRule,
    TagLimitCountRule,
    TagWithoutAttrCountRule
} = require('shopback-test');

new TagExistenceRule('head', 'title');
new TagExistenceWithAttrRule('head', 'img', 'alt');
new TagExistenceWithAttrRule('head', 'meta', 'name', 'description');
new TagLimitCountRule('', 'strong', 15);
new TagLimitCountRule('', 'h1', 1);
new TagWithoutAttrCountRule('', 'img', 'alt');
new TagWithoutAttrCountRule('', 'a', 'rel');

// Add rules
validator.addRule(new TagExistenceRule('head', 'title'));
validator.addRule(new TagExistenceWithAttrRule('head', 'img', 'alt'));

Input

There are 2 input types: FILE and STREAM. By default FILE, only invole setInput method of Validator in case of changing the input type. The input path is configured in the config.js file by input_path.

const { InputType } = require('shopback-test');
validator.setInput(InputType.FILE); // or InputType.STREAM.

Output

There are 3 output types: CONSOLE, FILE and STREAM. By default CONSOLE, only invole setOutput method of Validator in case of changing the output type. The output path is configured in the config.js file by output_path.

const { OutputType } = require('shopback-test');
validator.setOutput(OutputType.FILE);

Validator

constructor(skipPredefinedRules)

All predefined rules is by default added (skipPredefinedRules = false)

const { Validator } = require('shopback-test');
const validator = new Validator(true); // skip all predefined rules

skipRules(indexes)

Skip one-index based rules

validator.skipRules([1,4,5]);

addRule(rule)

validator.addRule(new RuleExistTag('head', 'title'));

validate() && getResult()

validator
  .validate()
  .then(async () => await validator.getResult())
  .catch(err => console.error(err));

Custom Rules

const { Rule } = require('shopback-test');

class NewRule extends Rule {
  constructor(rootTag, ...params) {
    super(rootTag);
    ...
  }

  validate() {
    // Write logic
    this.isValid = true; // or false
  }

  error() {
    return !this.isValid ? `Error message` : '';
  }
}

validator.addRule(new NewRule(rootTag, ...params));

Unit testing

Run npm test or mocha .\test\*\*test.js in the shopback-test module.