Giter Site home page Giter Site logo

fashion-show's Introduction

fashion-show

Build consistent and versioned styleguides by including and running consistent lint files across projects.

Motivation

Your styleguide should be verisoned and consistent across all of your projects. This means that you should only have ONE .jshintrc and/or .jscsrc file anywhere. But how can this be accomplished easily? By making your own styleguide using fashion-show.

Writing your "requireable" styleguide

A fully working example at indexzero/styleguide. Basically it happens in a few steps:

  • 1. Make a new repository, your-styleguide
  • 2. Add your .elintrc and .jscsrc files:
cd your-styleguide
mkdir dist
mkdir dotfiles
touch dotfiles/.eslintrc
touch dotfiles/.jscsrc

# Also works with jshint
# touch dotfiles/.jshintrc
  • 3. Install fashion-show and your favorite linters: jscs, eslint and jshint are supported.
npm install fashion-show jscs eslint --save
  • 4. "Build" your dotfiles on prepublish (i.e. remove comments)
"scripts": {
  "prepublish": "./node_modules/.bin/fashion-show-build"
}
  • 5. Write a simple wrapper script to "lint"
var path = require('path');

require('fashion-show')({
  commands: ['jscs', 'eslint'],
  rc: path.join(__dirname, '..', 'dist')
}, function (err, code) {
  if (err) { return process.exit(1); }
  process.exit(code);
});
  • 6. Expose that script as a "bin" in your-styleguide
"bin": {
  "your-styleguide": "./bin/your-styleguide"
}
  • 7. Depend on your-styleguide
cd your-styleguide
npm publish
cd some/other/project
npm install your-styleguide --save-dev
  • 8. Use the bin you created on "pretest"
"scripts": {
  "pretest": "your-styleguide lib test"
}

API Documentation

At its core fashion-show will run the CLI versions of the lint tools you choose to use it with. A comparison of JavaScript lint CLI options is available if you're interested in exploring this in depth, but fashion-show has gone to length to pick the best tool for the job where applicable so when you run:

require('fashion-show')(options, function (err, code) {
  if (err) { return process.exit(1); }
  process.exit(code);
});

The list of all available options is:

option name example jshint jscs eslint
commands ['jscs', 'eslint'] --- --- ---
targets ['lib/', 'test/'] ...args ...args ...args
rc '../rc' --config --config --config
fix true --- --fix ---
exts ['.jsx'] --extra-ext --- --ext .js
reporter 'checkstyle' --reporter --reporter --format
format 'checkstyle' --- --- --format
global ['my-global'] --prereq --- --global
binPath node_modules/.bin --- --- ---

All of these options are also configurable through the binary scripts that you define in Step 5 above:

CLI option option name Sample usage
...args targets lib/ test/
-c,--command commands -c jscs
-r,--rc rc -d ~/.lintrcs
-f,--fix fix --fix
-e,--ext exts --ext .jsx
-r,--reporter reporter -r checkstyle
-g,--global global -g my-global

# commands

Array of commands to actually run against. Each item in the Array can be a string command or an object:

{
  'command': 'jscs',
  'args': ['extra', 'jscs', 'specific', 'args']
}

# targets

The set of targets to run the given commands against.

# dist

Directory where all of your lint files is located. It will be default look for .{command}rc: .jscsrc, .jshintrc, .eslintrc

# reporter

Reporter passed to the linters that you are running.

# fix

If enabled will turn on auto fixing in jscs (Currently whitespace rules, EOF rule, and validateIndentation)

# exts

Set of additional extensions that you want to include running lint(s) against.

# global

Set of additional globals that you wish to enable

Tests

Tests are written with mocha and code coverage is provided by istanbul:

npm test
License: MIT

fashion-show's People

Contributors

bboles-godaddy avatar bmeck avatar indexzero avatar jansel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fashion-show's Issues

Add package to npmjs

Really nice module!!

I trying to install "fashon-show" with command, but it doesn't work now.
I think not added to npmjs this package yet. :0

npm install fashion-show --save

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.