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

seo-linter

v0.1.3

Published

SEO Linter - The package for linting your HTML file with Google SEO

Downloads

38

Readme

seo-linter

SEO Lint - The package for linting your HTML file with Google SEO

Build Status Coverage Status License: MIT npm version

Installation

SEOLinter requires node version 8.9.1 LTS or greater. We highly recommend nvm for installing node. Once you have node/npm, you can install/upgrade SEOLinter globally with the following command:

yarn add seo-linter

Usage

Command Line

To run SEOLint you need to provide configuration file and either html, uri, file

Read more about configuration file:

seolinter -c /path/to/config.yml -u https://google.com

To see the full usage information:

seolinter --help

Use in your code

Read more about configuration file:

Import SEOLinter first

const { SEOLinter } = require('seo-linter');

Create new Linter instance and using

const linter = new SEOLinter({ rules: { strong: { required: true } } });
linter.lint({ uri: 'https://google.com' }).then(errors => {
  // errors is an array which has format [{ code, message, tagName }]
});

If you want to use configuration file, you can use loadYamlConfig function or loading by yourself

const { SEOLinter, loadYamlConfig } = require('seo-linter');

loadYamlConfig('./config.yml')
  .then(cfg => {
    // After getting cfg, you able to using use SEOLinter
    // cfg must has format: { rules }
    const linter = new SEOLinter(cfg);
    linter.lint({ uri: 'https://google.com' }).then(errors => {
      // errors is an array which has format [{ code, message, tagName }]
    });
  })
  .catch(err => console.log);

Configs

One config rule should has either of [required, max, min, attrs, childs]

  • required: require tag present in HTML document or parent tag
  • max: The maximum tag allow in HTML document - default is -1 (Unlimited)
  • min: The minimum tag allow in HTML document - default is 0
  • attrs: Should has format { [attrName]: { required, value, min }}
  • childs: List of config rule

Here is the sample of configuration

rules:
  strong:
    max: 15 # <strong> tag can be present or not but if present shouldn't greater than 15 elements
  h1:
    max: 1 # If <h1> present, there is only 1 element is accepted
  img: # <img> tag has 2 configs
    -
      required: true
      attrs: # require <img> tag has attribute alt (the value of attribute can be any)
        alt:
          required: true
    -
      attrs:
        src:
          required: true
  a: # require <a> tag is present
    required: true
  head:
    required: true # require <head> tag is present
    childs: # inside of <head> tag has others config rule
      - title:
          required: true # <title> is required
      - meta:
          attrs:
            name:
              value: 'description' # At least 1 <meta> tag with attribute 'description' must be present
              min: 1 # If min is not set, require all <meta> tag with attribute 'description' present
      - meta:
          attrs:
            name:
              value: 'keywords'
              min: 1

LICENSE

Package release under MIT license.