-
-
Notifications
You must be signed in to change notification settings - Fork 76
TypeScript Boilerplate #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9451f26
ee3d5de
66044e1
7cdd233
d5a13fe
e54eded
dfaaa52
1df214a
70ebea1
443b376
64c2c9a
667a956
4c57b21
83125fa
13f87ac
388a76c
3ef5897
2f9526a
b5ce1b3
aab0378
41f4b7b
0cd7236
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
yarn.lock | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' |
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. |
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed to |
||
"pretest": "npm run build", | ||
EdJoPaTo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"test": "xo && ava" | ||
}, | ||
"main": "dist", | ||
"types": "dist", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer to put non-standard package.json properties at the end. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea here is that it nearly does the same as |
||
"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" | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A goal of mine is to get rid of a lot of the config boilerplate here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. But sadly we are not there yet. It's currently the way to go so until its possible to do it more clean I would like to keep the current state here. That way everyone can see what still has to be done. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# <%= moduleName %> [](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 %>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
EdJoPaTo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function(input: string) { | ||
if (typeof input !== 'string') { | ||
throw new TypeError(`Expected a string, got ${typeof input}`); | ||
} | ||
|
||
return input + ' & rainbows'; | ||
}; |
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); | ||
EdJoPaTo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
t.is(err.message, 'Expected a string, got number'); | ||
|
||
t.is(moduleName('unicorns'), 'unicorns & rainbows'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should open an issue on TypeScript for
tsc
to get a--cleanup
flag or something so we don't needdel dist
.By "we", I'm hoping you can do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of reading through a bunch of TypeScript Issues:
They don't like to delete a folder completely (good summary microsoft/TypeScript#13722) but deleting output files when the source files are gone is an ongoing Issue (microsoft/TypeScript#16057).
Sadly this issue is not planned for one of the next releases (attached as a Milestones).