Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougherty committed Dec 10, 2017
0 parents commit 7a67bcf
Show file tree
Hide file tree
Showing 8 changed files with 3,233 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,yml,md,babelrc,eslintrc,remarkrc}]
indent_style = space
indent_size = 2
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
.DS_Store
Thumbs.db
.idea/
.vscode/
*.sublime-project
*.sublime-workspace
*.log
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
cache:
directories:
- node_modules
node_js:
- 8
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License

Copyright 2017 Brad Dougherty (https://brad.is), contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# mrm-task-xo

[![Build Status](https://travis-ci.org/bdougherty/mrm-task-xo.svg)](https://travis-ci.org/bdougherty/mrm-task-xo)

> [Mrm](https://github.com/sapegin/mrm) task that adds [xo](https://github.com/sindresorhus/xo).
## What it does

* Updates the npm test script to run xo
* Adds specified configuration to `package.json`
* Installs xo

## Usage

```
mrm xo
mrm xo --config:xoExtends=bdougherty --config:xoExtends=foo
```

## Options

### `xoSpace` (optional, default: `false`)

Set it to `true` to get 2-space indentation or specify the number of spaces.

This option is set automatically if you have the `indent` option set in your [mrm config](https://github.com/sapegin/mrm#configuration).

This option exists for pragmatic reasons, but I would strongly recommend you read [“Why tabs are superior”](http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/).

### `xoSemicolon` (optional, default: `true`)

Set it to `false` to enforce no-semicolon style.

### `xoPlugins` (optional)

Include third-party [plugins](https://eslint.org/docs/user-guide/configuring.html#configuring-plugins).

### `xoExtends` (optional)

Use one or more [shareable configs](https://eslint.org/docs/developer-guide/shareable-configs.html) or [plugin configs](https://eslint.org/docs/user-guide/configuring#using-the-configuration-from-a-plugin) to override any of the default rules.

## License

MIT © [Brad Dougherty](https://brad.is)
44 changes: 44 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

const { packageJson, install } = require('mrm-core');

function task(config) {
const { indent, xoSpace, xoSemicolon, xoPlugins, xoExtends } = config.defaults({
xoSpace: false,
xoSemicolon: true
}).values();

const packages = ['xo'];
const pkg = packageJson()
.prependScript('test', 'xo')
.unset('xo.space')
.unset('xo.semicolon');

if (xoSpace !== false || indent !== 'tab') {
pkg.set('xo.space', xoSpace || indent);
}

if (xoSemicolon === false) {
pkg.set('xo.semicolon', false);
}

if (xoPlugins) {
const pluginArray = [].concat(xoPlugins);

pkg.set('xo.plugins', pluginArray);
packages.push(...pluginArray.map((plugin) => `eslint-plugin-${plugin}`));
}

if (xoExtends) {
const extendsArray = [].concat(xoExtends);

pkg.set('xo.extends', xoExtends);
packages.push(...extendsArray.map((config) => `eslint-config-${config}`));
}

pkg.save();
install(packages);
}

task.description = 'Adds xo to the project';
module.exports = task;
Loading

0 comments on commit 7a67bcf

Please sign in to comment.