Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 18, 2018
1 parent 859df5c commit 24802c5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage/
trim-lines.js
trim-lines.min.js
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
'use strict'

module.exports = trimLines;
module.exports = trimLines

var ws = /[ \t]*\n+[ \t]*/g;
var newline = '\n';
var ws = /[ \t]*\n+[ \t]*/g
var newline = '\n'

function trimLines(value) {
return String(value).replace(ws, newline);
return String(value).replace(ws, newline)
}
36 changes: 22 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,36 @@
"browserify": "^16.0.0",
"esmangle": "^1.0.0",
"nyc": "^11.0.0",
"prettier": "^1.12.0",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.6.3",
"xo": "^0.20.0"
},
"scripts": {
"build-md": "remark . -qfo",
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"build-bundle": "browserify index.js -s trim-lines > trim-lines.js",
"build-mangle": "esmangle trim-lines.js > trim-lines.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
"test": "npm run format && npm run build && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"space": true,
"prettier": true,
"esnext": false,
"rules": {
"no-var": "off",
Expand All @@ -56,9 +63,10 @@
"trim-lines.js"
]
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ npm install trim-lines
## Usage

```js
var trimLines = require('trim-lines');
var trimLines = require('trim-lines')

trimLines(' foo\t\n\n bar \n\tbaz '); //=> ' foo\nbar\nbaz '
trimLines(' foo\t\n\n bar \n\tbaz ') // => ' foo\nbar\nbaz '
```

## API
Expand Down
20 changes: 12 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'use strict';
'use strict'

var test = require('tape');
var trimLines = require('.');
var test = require('tape')
var trimLines = require('.')

test('trimLines(value)', function (t) {
t.equal(trimLines(true), 'true', 'should coerce to string');
t.equal(trimLines(' foo\t\n\n bar \n\tbaz '), ' foo\nbar\nbaz ', 'should work');
t.end();
});
test('trimLines(value)', function(t) {
t.equal(trimLines(true), 'true', 'should coerce to string')
t.equal(
trimLines(' foo\t\n\n bar \n\tbaz '),
' foo\nbar\nbaz ',
'should work'
)
t.end()
})

0 comments on commit 24802c5

Please sign in to comment.