Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Creating a Custom Preset or Config

Henry Zhu edited this page Oct 2, 2015 · 8 revisions

Custom Presets

For regular projects, using the built-in preset/config such as the airbnb, google, or jquery preset may be good enough. However, it may be more useful to share your config files across your company's projects or your own ecosystem of projects.

You can either create an npm package to share, or just link to a local file. Check out npm for examples.

Creating the Config

The shared config file itself doesn't need to change. It is just a regular .jscs.json or .jscsrc file.

// example .jscsrc using a custom preset
// assuming the preset package name is `jscs-config-awesome`
{
  "preset": "awesome",
  "disallowEmptyBlocks": false // an example of disabling a preset rule with false
  "disallowArrowFunctions": null // an example of disabling a preset rule with null
  "disallowCapitalizedComments": null // you can also just null a rule to label it for later
}

Creating the Package

You will need to publish a npm package with your config file (.jscs.json or .jscsrc) as the main file.

It's recommended that the package name starts with jscs-preset- or with jscs-config- to help with searching for presets on npm and as well as making it easier to use in your configs; e.g. "preset": "awesome" instead of "preset": "jscs-preset-awesome".

You can also share multiple presets in one package and use them like ”preset”: “awesome/super-awesome”, provided that you have super-awesome.{json, js} in your package root directory.

// example package.json in `jscs-config-awesome`
{
  “name”: “jscs-config-awesome”, // or "jscs-preset-awesome"
  “version”: “1.0.0,
  “main”: “jscs.json” // or ".jscsrc"
}
Clone this wiki locally