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

twolfson-style

v1.6.1

Published

Lint and style configurations for @twolfson

Downloads

83

Readme

twolfson-style Build status Build status

Lint and style configurations for @twolfson

This was built to create a common versioned location for @twolfson's style choices.

Currently, we are leveraging jscs, a tool for verifying consistent style, and jshint, a tool that performs both linting and style checking.

Getting Started

Install the module with: npm install twolfson-style

Then, install the .jscsrc and .jshintrc to your project's repo:

# Copy over `rc` files
# `./node_modules/.bin/` can be removed if you are in a `npm-run-script` context
./node_modules/.bin/twolfson-style install

# Verify we have added the files
ls .js*
# .jscsrc  .jshintrc

These files can be integrated with jscs and jshint respectively. A common usage is an npm-run-script:

// DEV: By providing a `lib/` instead of `lib/*.js`, both `jscs` and `jshint` recurse the directory (e.g. `lib/hello/world.js`)
"lint": "jshint lib/ test/ && jscs lib/ test/"

// Alternatively, we provide a sugar command to do this:
"lint": "twolfson-style lint lib/ test/"

We provide a precheck utility to prevent critical JS errors before running tests.

// Verifies only critical lint errors (e.g. using an undeclared variable)
"precheck": "twolfson-style precheck lib/ test/"

Documentation

CLI

twolfson-style installs a twolfson-style executable:

$ ./bin/twolfson-style --help

  Usage: twolfson-style [options] [command]

  Commands:

    install [dir]       Install style `rc` configuration files to `dir` or the current directory
    precheck <path...>  Run critical style checks (e.g. using an undeclared variable)
    lint <path...>      Run all of your style checks (Note: you must provide `jshint` and `jscs` on your `$PATH`)

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

install [dir]

The install command copies over the .jscsrc and .jshintrc files to a specified directory, dir, or the current working directory, process.cwd().

Currently, we only provide node styles but in the future, we are considering adding --env browser to alter the styles for browser linting.

# Copy over `rc` files
twolfson-style install

# List our new files
ls .js*
# .jscsrc  .jshintrc

precheck <paths...>

The precheck command checks for critical lint errors (e.g. using an undeclared variable).

twolfson-style precheck docs/precheck.js
# docs/precheck.js: line 1, col 13, 'iWasNeverUndeclared' is not defined.
#
# 1 error

lint <paths...>

The lint command runs jshint and jshint against paths.

We will use the jshint and jscs must be provided on the $PATH.

twolfson-style does not provide jshint and jscs dependencies. If we were to, it would lead to slower releases and annoying one-off upgrades.

twolfson-style lint docs/lint.js
# docs/lint.js: line 2, col 3, Expected '{' and instead saw 'void'.
#
# 1 error

Library versions

The supported jscs and jshint versions are the same as this package's package.json.

package.json

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint and test via npm test.

Donating

Support this project and others by twolfson via gratipay.

Support via Gratipay

Unlicense

As of Nov 20 2014, Todd Wolfson has released this repository and its contents to the public domain.

It has been released under the UNLICENSE.