Skip to content

Commit

Permalink
begin typescript boilerplate
Browse files Browse the repository at this point in the history
see #16
  • Loading branch information
EdJoPaTo committed Feb 19, 2019
1 parent 877e775 commit 9451f26
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 0 deletions.
12 changes: 12 additions & 0 deletions typescript/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

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

[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions typescript/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
3 changes: 3 additions & 0 deletions typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
yarn.lock
dist
1 change: 1 addition & 0 deletions typescript/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions typescript/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
9 changes: 9 additions & 0 deletions typescript/license
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) <%= name %> <<%= email %>> (<%= website %>)

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.
62 changes: 62 additions & 0 deletions typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "<%= moduleName %>",
"version": "0.0.0",
"description": "",
"license": "MIT",
"repository": "<%= githubUsername %>/<%= moduleName %>",
"author": {
"name": "<%= name %>",
"email": "<%= email %>",
"url": "<%= website %>"
},
"engines": {
"node": ">=6"
},
"scripts": {
"build": "del dist && tsc",
"prepare": "npm run build",
"pretest": "npm run build",
"test": "xo && ava"
},
"main": "dist",
"types": "dist",
"files": [
"dist",
"!*.test.*"
],
"keywords": [
""
],
"dependencies": {},
"devDependencies": {
"@sindresorhus/tsconfig": "^0.2.1",
"@types/node": "^11.9.0",
"@typescript-eslint/eslint-plugin": "^1.3.0",
"ava": "^1.2.1",
"del-cli": "^1.1.0",
"eslint-config-xo-typescript": "^0.8.0",
"ts-node": "^8.0.2",
"typescript": "^3.3.3",
"xo": "^0.24.0"
},
"ava": {
"babel": false,
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
},
"xo": {
"extends": "xo-typescript",
"extensions": [
"ts"
],
"rules": {
"@typescript-eslint/promise-function-async": "off",
"ava/no-ignored-test-files": "off"
}
}
}
47 changes: 47 additions & 0 deletions typescript/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# <%= moduleName %> [![Build Status](https://travis-ci.org/<%= githubUsername %>/<%= moduleName %>.svg?branch=master)](https://travis-ci.org/<%= githubUsername %>/<%= moduleName %>)

>

## Install

```
$ npm install <%= moduleName %>
```


## Usage

```js
const <%= camelModuleName %> = require('<%= moduleName %>');

<%= camelModuleName %>('unicorns');
//=> 'unicorns & rainbows'
```


## API

### <%= camelModuleName %>(input, [options])

#### input

Type: `string`

Lorem ipsum.

#### options

Type: `Object`

##### foo

Type: `boolean`<br>
Default: `false`

Lorem ipsum.


## License

MIT © [<%= name %>](https://github.com/<%= githubUsername %>)
9 changes: 9 additions & 0 deletions typescript/source/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

export default function(input: string) {
if (typeof input !== 'string') {
throw new TypeError(`Expected a string, got ${typeof input}`);
}

return input + ' & rainbows';
};
11 changes: 11 additions & 0 deletions typescript/test/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test from 'ava';
import moduleName from '.';

test('title', t => {
const err = t.throws(() => {
moduleName(123);
}, TypeError);
t.is(err.message, 'Expected a string, got number');

t.is(moduleName('unicorns'), 'unicorns & rainbows');
});

0 comments on commit 9451f26

Please sign in to comment.