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

anylint

v0.0.3

Published

Anylint: Linter for any languages

Downloads

20

Readme

Anylint

Linter for any languages.

TravisCI badge

Anylint is a linter created to lint anything with custom rules. You can easily write your own linters in any languages!

Install

npm install -g anylint

Usage

$ anylint foo.js

To specify rc file, use --config:

$ anylint foo.pl --config ./custom-anylintrc

.anylintrc

Anylint can be configured by .anylintrc files. .anylintrc is parsed as JSON5 format. Write settings like below and put it to the project root or your $HOME/.anylintrc.

{
  // Rules applied for all files
  "*": {
    // Key must be the path of executable
    "~/bin/lint-trailing-whitespace.sh": 2  // 2 is error
  },

  // Rules for `.js` files
  ".js": {
    "~/bin/eslint-wrapper.js": 2,
    "~/bin/jshint-wrapper.pl": 2,
  },
}

Writing Rules

Anylint accepts any rules you write. Rules must satisfy following spec:

  • Rules must be executable file (Don't forget chmod +x)
  • Rules take code to lint from stdin
  • Rules output errors in JSON format
$ cat foo.md | ./rule.pl
[{
  line: 1,
  column: 1,
  message: "Invalid indent",
  ruleId: "indent"
}, {
  line: 10,
  column: 13,
  message: "Use snake_case for variables",
  ruleId: "snake-case"
}]

Errors must have following properties:

  • line
  • column
  • message
  • ruleId

Note that line and column starts from 1, not 0.

Examples

in JavaScript:

#!/usr/bin/env node
// This rule disallows more than 2 blank lines

process.stdin.on('data', data => {
  const lines = data.toString().split('\n');
  let lastline = 'DUMMY';

  let errors = [];
  lines.forEach((line, lineNum) => {
    if (lastline.match(/^\s*$/) && line.match(/^\s*$/)) {
      errors.push({
        line: lineNum + 1,
        column: 1,
        message: 'Too many blank lines!',
        ruleId: 'no-multiple-blank-lines'
      });
    }
    lastline = line;
  });

  console.log(JSON.stringify(errors));
});

in Perl:

#!/usr/bin/env perl
# This rule disallows more than 2 blank lines
use strict;
use warnings;
use JSON;
use v5.010;

my $errors = [];

my $linenum = 1;
my $lastline = 'DUMMY';
while (<>) {
  my $line = $_;
  if ($line =~ /^\s*$/ && $lastline =~ /^\s*$/) {
    push @$errors, {
      line => $linenum,
      column => 1,
      message => 'Too many blank lines!',
      ruleId => 'no-multiple-blank-lines',
    }
  }
  $linenum++;
  $lastline = $line;
}

say encode_json($errors);

LICENSE

MIT