Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 28, 2018
1 parent 70bd919 commit add541f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 38 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage/
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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)
}
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,35 @@
"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,
"lines": 100,
"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"
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 13 additions & 21 deletions test.js
Original file line number Diff line number Diff line change
@@ -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()
})

0 comments on commit add541f

Please sign in to comment.