From add541f4c1900182df9ab9a644fb8587de2bc500 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 28 Oct 2018 14:51:14 +0100 Subject: [PATCH] Refactor code-style --- .prettierignore | 1 + index.js | 10 +++++----- package.json | 23 ++++++++++++++--------- readme.md | 6 +++--- test.js | 34 +++++++++++++--------------------- 5 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..404abb2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +coverage/ diff --git a/index.js b/index.js index e01696f..66e3370 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,8 @@ -'use strict'; +'use strict' -var is = require('unist-util-is'); +var is = require('unist-util-is') -module.exports = isPhrasing; +module.exports = isPhrasing var phrasing = [ 'inlineCode', @@ -17,9 +17,9 @@ var phrasing = [ 'imageReference', 'footnoteReference', 'text' -]; +] /* Check if a node is a phrasing element */ function isPhrasing(node) { - return is(phrasing, node); + return is(phrasing, node) } diff --git a/package.json b/package.json index 6ffd366..2e1ff2a 100644 --- a/package.json +++ b/package.json @@ -23,21 +23,18 @@ "unist-util-is": "^2.1.1" }, "devDependencies": { + "nyc": "^13.0.0", + "prettier": "^1.14.3", "remark-cli": "^6.0.0", "remark-preset-wooorm": "^4.0.0", - "nyc": "^13.0.0", "tape": "^4.4.0", "xo": "^0.23.0" }, "scripts": { - "build-md": "remark . --quiet --frail --output", - "build": "npm run build-md", - "lint": "xo", - "test-api": "node test.js", + "format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", + "test-api": "node test", "test-coverage": "nyc --reporter lcov tape test.js", - "pretest": "npm run lint", - "test": "node test", - "posttest": "npm run test-coverage" + "test": "npm run format && npm run test-coverage" }, "nyc": { "check-coverage": true, @@ -45,8 +42,16 @@ "functions": 100, "branches": 100 }, + "prettier": { + "tabWidth": 2, + "useTabs": false, + "singleQuote": true, + "bracketSpacing": false, + "semi": false, + "trailingComma": "none" + }, "xo": { - "space": true, + "prettier": true, "esnext": false, "rules": { "no-multi-assign": "off" diff --git a/readme.md b/readme.md index 34a673f..6f4d8cd 100644 --- a/readme.md +++ b/readme.md @@ -13,17 +13,17 @@ npm install mdast-util-phrasing ## Usage ```javascript -var phrasing = require('mdast-util-phrasing'); +var phrasing = require('mdast-util-phrasing') phrasing({ type: 'paragraph', children: [{type: 'text', value: 'Alpha'}] -}); //=> false +}) // => false phrasing({ type: 'strong', children: [{type: 'text', value: 'Delta'}] -}); //=> true +}) // => true ``` ## API diff --git a/test.js b/test.js index b74b68e..c79c90a 100644 --- a/test.js +++ b/test.js @@ -1,50 +1,42 @@ -'use strict'; +'use strict' -var test = require('tape'); -var phrasing = require('.'); +var test = require('tape') +var phrasing = require('.') -test('phrasing', function (t) { - t.equal( - phrasing(), - false, - 'should return `false` without node' - ); +test('phrasing', function(t) { + t.equal(phrasing(), false, 'should return `false` without node') - t.equal( - phrasing(null), - false, - 'should return `false` with `null`' - ); + t.equal(phrasing(null), false, 'should return `false` with `null`') t.equal( phrasing({type: 'foo'}), false, 'should return `false` when without known `node`' - ); + ) t.equal( phrasing({type: 'link'}), true, 'should return `true` when with a phrasing `node`' - ); + ) t.equal( phrasing({type: 'strong'}), true, 'should return `true` when with another phrasing `node`' - ); + ) t.equal( phrasing({type: 'paragraph'}), false, 'should return `false` when with a block `node`' - ); + ) t.equal( phrasing({type: 'list'}), false, 'should return `false` when with another block `node`' - ); + ) - t.end(); -}); + t.end() +})