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

antler

v0.2.0

Published

Directory structure linter

Downloads

4,200

Readme

Antler

CircleCI

Directory structure linter

About

Antler allows you to configure linting rules to enforce the structure of your project directories and files.

Installation

Install with NPM:

npm i antler -S

Note: -S is shorthand for --save to automatically add this to your package.json

If you are using a version of NPM that doesn't support package lock files I'd recommend using -SE or --save-exact, which will pin the version in your package.json.

Usage

Currently Antler only supports supplying a root directory to lint from, but I intend to allow multiple root directories in the future.

antler <directory>

If no directory is supplied Antler won't run. If you'd like to lint the current directory you can supply . or ./, as you like.

Note: there are no rules configured by default. You will have to configure your own .antlerrc.json config file as explained below.

Configuration

All Antler configuration is stored in an .antlerrc.json file. Antler will look in the target directory, and all of its parent directories until it finds a file named .antlerrc.json.

The basic structure of a config file is as follows:

{
  "rules": {
    "RuleName": "warning",
    "AnotherRule": {
      "level": "error",
      "options": {
        "allow": "^my-file$",
        "disallow": ["nope", "bad"]
      }
    }
  }
}

Each rule can be provided with either a string representing the error level (off, warning, or error), or an object with a level key.

Some rules allow (or require) the user to provide additional options as an object in the options key.

Options are (at the time of writing) always strings, or arrays of strings.

See the example .antlerrc.json file in the root of this project for a more complex example.

Rules

NoLonelyIndex

Ensures that no directories contain only a single index file e.g. index.js, or index.html.

{
  "NoLonelyIndex": "error"
}

Acceptable

foo/
  cli.js
  index.js

foo/
  index/
    file.js

Unacceptable

foo/
  index.js

NoJuniors

Ensures that no files, or directories share a name with their parent directory.

{
  "NoJuniors": "error"
}

Acceptable

foo/
  bar.js

Unacceptable

foo/
  foo.js

foo/
  foo/

NoEmptyDirectory

Ensures that there are no empty directories.

{
  "NoEmptyDirectory": "error"
}

Acceptable

foo/
  bar/
    baz.js

foo/
  bar.js

Unacceptable

foo/
  bar/

foo/

FileName

Allows the user to define allowed and disallowed patterns to match all file names against.

The patterns provided are converted to case sensitive regular expressions, and should be prefixed with ^ (start of string) and suffixed with $ (end of string), if you want to ensure that the whole string matches your pattern, and not just a section of it.

The options; allow and disallow, can be either a string, or array of strings.

{
  "FileName": {
    "level": "error",
    "options": {
      "allow": "",
      "disallow": ""
    }
  }
}

DirectoryName

Allows the user to define allowed and disallowed patterns to match all directory names against.

The patterns provided are converted to case sensitive regular expressions, and should be prefixed with ^ (start of string) and suffixed with $ (end of string), if you want to ensure that the whole string matches your pattern, and not just a section of it.

The options; allow and disallow, can be either a string, or array of strings.

{
  "DirectoryName": {
    "level": "error",
    "options": {
      "allow": "",
      "disallow": ""
    }
  }
}

Extension

Allows the user to define allowed and disallowed patterns to match all file extensions against. The extensions are extracted using Node's path.extname, and so will include only the last period and following characters e.g.

All of the following files will be tested against .ts:

index.ts
index.d.ts
index.min.ts

If you want to enforce checking of the .min.ts section, you should use the FileName rule.

The patterns provided are converted to case sensitive regular expressions, and should be prefixed with ^ (start of string) and suffixed with $ (end of string), if you want to ensure that the whole string matches your pattern, and not just a section of it.

The options; allow and disallow, can be either a string, or array of strings.

{
  "Extension": {
    "level": "error",
    "options": {
      "allow": "",
      "disallow": ""
    }
  }
}

Path

Allows the user to define allowed and disallowed patterns to match all paths against. The paths will include the root directory that you specified in the command e.g.

If you run:

antler src/

Against the structure:

src/
  foo/
    bar.js

The paths that are checked will be:

src/
src/foo/
src/foo/bar.js

The patterns provided are converted to case sensitive regular expressions, and should be prefixed with ^ (start of string) and suffixed with $ (end of string), if you want to ensure that the whole string matches your pattern, and not just a section of it.

The options; allow and disallow, can be either a string, or array of strings.

{
  "Path": {
    "level": "error",
    "options": {
      "allow": "",
      "disallow": ""
    }
  }
}