Skip to content

Instantly share code, notes, and snippets.

@chrisdickinson
Last active December 19, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdickinson/912e891f8dd60d8257e6 to your computer and use it in GitHub Desktop.
Save chrisdickinson/912e891f8dd60d8257e6 to your computer and use it in GitHub Desktop.
// your-linter/index.js:
var jsl = require('jsl')
, linter
var comma_first = require('jsl-comma-first-object')
, no_semicolons = require('jsl-no-semicolon')
, max_line_length = require('jsl-max-line-length')
module.exports = linter = jsl()
linter
.addASTRule('error', comma_first.selector, comma_first)
.addASTRule('error', no_semicolons.selector, no_semicolons)
linter
.addLineRule('error', max_line_length(80))
// OR alternatively:
var one_var_per_var_block = require('jsl-one-var-per-decl');
var semicolons = require('jsl-require-semicolon');
linter
.addASTRule('error', one_var_per_var_block.selector, one_var_per_var_block)
.addASTRule('error', semicolons.selector, semicolons);
// now in your your-linter/bin/your-linter:
require('../index').cli()
// in your-other-module/test.js:
var test = require('tape')
, lint = require('your-linter')
test('passes style guide', lint.test(path.join(__dirname, 'package.json')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment