Skip to content

Commit f05bc9e

Browse files
committed
boilerplate
1 parent 54dbf16 commit f05bc9e

File tree

8 files changed

+314
-0
lines changed

8 files changed

+314
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
package-lock.json

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Raynos
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

_types/base-tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"types": ["node"],
4+
"target": "es2018",
5+
"lib": ["es2018"],
6+
"noEmit": true,
7+
"module": "commonjs",
8+
"allowJs": true,
9+
"checkJs": true,
10+
"noFallthroughCasesInSwitch": true,
11+
"noImplicitReturns": true,
12+
"noUnusedLocals": true,
13+
"noUnusedParameters": true,
14+
"strict": true,
15+
"maxNodeModuleJsDepth": 0
16+
}
17+
}
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
// TypeScript Version: 3.0
2+
3+
export = tape;
4+
5+
/**
6+
* Create a new test with an optional name string and optional opts object.
7+
* cb(t) fires with the new test object t once all preceeding tests have finished.
8+
* Tests execute serially.
9+
*/
10+
declare function tape(name: string | tape.TestOptions, cb?: tape.TestCase): void;
11+
declare function tape(name: string, opts: tape.TestOptions, cb: tape.TestCase): void;
12+
declare function tape(cb: tape.TestCase): void;
13+
14+
declare namespace tape {
15+
/* eslint-disable-next-line @typescript-eslint/no-invalid-void-type */
16+
type TestCase = (test: Test) => void | Promise<void>;
17+
18+
/**
19+
* Available opts options for the tape function.
20+
*/
21+
interface TestOptions {
22+
skip?: boolean; // See tape.skip.
23+
timeout?: number; // Set a timeout for the test, after which it will fail. See tape.timeoutAfter.
24+
}
25+
26+
/**
27+
* Options for the createStream function.
28+
*/
29+
interface StreamOptions {
30+
objectMode?: boolean;
31+
}
32+
33+
/**
34+
* Generate a new test that will be skipped over.
35+
*/
36+
function skip(name: string | TestOptions, cb: TestCase): void;
37+
function skip(name: string | TestCase): void;
38+
function skip(name: string, opts: TestOptions, cb: TestCase): void;
39+
40+
/**
41+
* The onFinish hook will get invoked when ALL tape tests have finished right before tape is about to print the test summary.
42+
*/
43+
function onFinish(cb: () => void): void;
44+
45+
/**
46+
* Like test(name?, opts?, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored.
47+
*/
48+
function only(name: string | TestOptions, cb?: TestCase): void;
49+
function only(name: string, opts: TestOptions, cb: TestCase): void;
50+
function only(cb: TestCase): void;
51+
52+
/**
53+
* Create a new test harness instance, which is a function like test(), but with a new pending stack and test state.
54+
*/
55+
function createHarness(): typeof tape;
56+
/**
57+
* Create a stream of output, bypassing the default output stream that writes messages to console.log().
58+
* By default stream will be a text stream of TAP output, but you can get an object stream instead by setting opts.objectMode to true.
59+
*/
60+
function createStream(opts?: StreamOptions): NodeJS.ReadableStream;
61+
62+
interface Test {
63+
/**
64+
* Create a subtest with a new test handle st from cb(st) inside the current test.
65+
* cb(st) will only fire when t finishes.
66+
* Additional tests queued up after t will not be run until all subtests finish.
67+
*/
68+
test(name: string, cb: TestCase): void;
69+
test(name: string, opts: TestOptions, cb: TestCase): void;
70+
71+
/**
72+
* Declare that n assertions should be run. end() will be called automatically after the nth assertion.
73+
* If there are any more assertions after the nth, or after end() is called, they will generate errors.
74+
*/
75+
plan(n: number): void;
76+
77+
/**
78+
* Declare the end of a test explicitly.
79+
* If err is passed in t.end will assert that it is falsey.
80+
*/
81+
end(err?: unknown): void;
82+
83+
/**
84+
* Generate a failing assertion with a message msg.
85+
*/
86+
fail(msg?: string): void;
87+
88+
/**
89+
* Generate a passing assertion with a message msg.
90+
*/
91+
pass(msg?: string): void;
92+
93+
/**
94+
* Automatically timeout the test after X ms.
95+
*/
96+
timeoutAfter(ms: number): void;
97+
98+
/**
99+
* Generate an assertion that will be skipped over.
100+
*/
101+
skip(msg?: string): void;
102+
103+
/**
104+
* Assert that value is truthy with an optional description message msg.
105+
*/
106+
ok(value: unknown, msg?: string): void;
107+
true(value: unknown, msg?: string): void;
108+
assert(value: unknown, msg?: string): void;
109+
110+
/**
111+
* Assert that value is falsy with an optional description message msg.
112+
*/
113+
notOk(value: unknown, msg?: string): void;
114+
false(value: unknown, msg?: string): void;
115+
notok(value: unknown, msg?: string): void;
116+
117+
/**
118+
* Assert that err is falsy.
119+
* If err is non-falsy, use its err.message as the description message.
120+
*/
121+
error(err: unknown, msg?: string): void;
122+
ifError(err: unknown, msg?: string): void;
123+
ifErr(err: unknown, msg?: string): void;
124+
iferror(err: unknown, msg?: string): void;
125+
126+
/**
127+
* Assert that a === b with an optional description msg.
128+
*/
129+
equal<T>(actual: T, expected: T, msg?: string): void;
130+
equals<T>(actual: T, expected: T, msg?: string): void;
131+
isEqual<T>(actual: T, expected: T, msg?: string): void;
132+
is<T>(actual: T, expected: T, msg?: string): void;
133+
strictEqual<T>(actual: T, expected: T, msg?: string): void;
134+
strictEquals<T>(actual: T, expected: T, msg?: string): void;
135+
136+
/**
137+
* Assert that a !== b with an optional description msg.
138+
*/
139+
notEqual(actual: unknown, expected: unknown, msg?: string): void;
140+
notEquals(actual: unknown, expected: unknown, msg?: string): void;
141+
notStrictEqual(actual: unknown, expected: unknown, msg?: string): void;
142+
notStrictEquals(actual: unknown, expected: unknown, msg?: string): void;
143+
isNotEqual(actual: unknown, expected: unknown, msg?: string): void;
144+
isNot(actual: unknown, expected: unknown, msg?: string): void;
145+
not(actual: unknown, expected: unknown, msg?: string): void;
146+
doesNotEqual(actual: unknown, expected: unknown, msg?: string): void;
147+
isInequal(actual: unknown, expected: unknown, msg?: string): void;
148+
149+
/**
150+
* Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg.
151+
*/
152+
deepEqual<T>(actual: T, expected: T, msg?: string): void;
153+
deepEquals<T>(actual: T, expected: T, msg?: string): void;
154+
isEquivalent<T>(actual: T, expected: T, msg?: string): void;
155+
same<T>(actual: T, expected: T, msg?: string): void;
156+
157+
/**
158+
* Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg.
159+
*/
160+
notDeepEqual(actual: unknown, expected: unknown, msg?: string): void;
161+
notEquivalent(actual: unknown, expected: unknown, msg?: string): void;
162+
notDeeply(actual: unknown, expected: unknown, msg?: string): void;
163+
notSame(actual: unknown, expected: unknown, msg?: string): void;
164+
isNotDeepEqual(actual: unknown, expected: unknown, msg?: string): void;
165+
isNotDeeply(actual: unknown, expected: unknown, msg?: string): void;
166+
isNotEquivalent(actual: unknown, expected: unknown, msg?: string): void;
167+
isInequivalent(actual: unknown, expected: unknown, msg?: string): void;
168+
169+
/**
170+
* Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg.
171+
*/
172+
deepLooseEqual(actual: unknown, expected: unknown, msg?: string): void;
173+
looseEqual(actual: unknown, expected: unknown, msg?: string): void;
174+
looseEquals(actual: unknown, expected: unknown, msg?: string): void;
175+
176+
/**
177+
* Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg.
178+
*/
179+
notDeepLooseEqual(actual: unknown, expected: unknown, msg?: string): void;
180+
notLooseEqual(actual: unknown, expected: unknown, msg?: string): void;
181+
notLooseEquals(actual: unknown, expected: unknown, msg?: string): void;
182+
183+
/**
184+
* Assert that the function call fn() throws an exception.
185+
* expected, if present, must be a RegExp or Function, which is used to test the exception object.
186+
*/
187+
throws(fn: () => void, msg?: string): void;
188+
throws(fn: () => void, exceptionExpected: RegExp | typeof Error, msg?: string): void;
189+
190+
/**
191+
* Assert that the function call fn() does not throw an exception.
192+
*/
193+
doesNotThrow(fn: () => void, msg?: string): void;
194+
doesNotThrow(fn: () => void, exceptionExpected: RegExp | typeof Error, msg?: string): void;
195+
196+
/**
197+
* Print a message without breaking the tap output.
198+
* (Useful when using e.g. tap-colorize where output is buffered & console.log will print in incorrect order vis-a-vis tap output.)
199+
*/
200+
comment(msg: string): void;
201+
}
202+
}

jsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "./_types/base-tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"paths": {
6+
"@pre-bundled/tape": ["./_types/pre-bundled__tape"],
7+
"*" : ["./_types/*"]
8+
}
9+
},
10+
"include": [
11+
"src/*.js",
12+
"test/*.js",
13+
"_types/**/*.d.ts"
14+
]
15+
}

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "lean.js",
3+
"version": "0.0.1",
4+
"description": "A lean subset of JavaScript for no-bullshit daily development.",
5+
"main": "src/index.js",
6+
"scripts": {
7+
"tsc": "npr tsc -p jsconfig.json --maxNodeModuleJsDepth 0",
8+
"lint": "npr tsdocstandard",
9+
"test": "npm run tsc && npm run lint && node test/index.js && npm run type-coverage",
10+
"type-coverage": "npr type-coverage -p jsconfig.json --ignore-catch --strict --at-least 100"
11+
},
12+
"author": "Raynos <[email protected]>",
13+
"repository": "git://github.com/Raynos/lean.js.git",
14+
"homepage": "https://github.com/Raynos/lean.js",
15+
"bugs": {
16+
"url": "https://github.com/Raynos/lean.js/issues",
17+
"email": "[email protected]"
18+
},
19+
"contributors": [
20+
{
21+
"name": "Raynos"
22+
}
23+
],
24+
"licenses": [
25+
{
26+
"type": "MIT",
27+
"url": "http://github.com/Raynos/lean.js/raw/master/LICENSE"
28+
}
29+
],
30+
"binDependencies": {
31+
"tsdocstandard": "16.1.0",
32+
"type-coverage": "2.13.3",
33+
"typescript": "4.0.3"
34+
},
35+
"devDependencies": {
36+
"@pre-bundled/tape": "4.11.0",
37+
"@types/node": "14.14.21",
38+
"npm-bin-deps": "1.10.1"
39+
},
40+
"dependencies": {}
41+
}

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict'
2+
3+
async function validateFile () {
4+
5+
}
6+
exports.validateFile = validateFile

test/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
const tape = require('@pre-bundled/tape')
4+
5+
const lean = require('../src/index.js')
6+
7+
tape('first test', (t) => {
8+
t.equal(typeof lean.validateFile, 'function')
9+
t.end()
10+
})

0 commit comments

Comments
 (0)