Add textversionjs

Update textversionjs

Add test
Add tsconfig
Add tslint
Update textversionjs

Fixed linting errors
This commit is contained in:
Aaron Osher 2018-06-26 16:46:58 +01:00
parent 4663cef676
commit 1c8d97fc7a
4 changed files with 73 additions and 0 deletions

29
types/textversionjs/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
// Type definitions for textversionjs 1.1
// Project: https://github.com/EDMdesigner/textversionjs
// Definitions by: Aaron Osher <https://github.com/aaronosher>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import * as textVersion from "textversionjs";
=============================================== */
declare function textversionjs(html: string, styleConfig?: textversionjs.styleConfig): string;
declare namespace textversionjs {
type linkProcess = (href: string, linkText: string) => string;
type imgProcess = (src: string, alt: string) => string;
interface styleConfig {
linkProcess?: linkProcess;
imgProcess?: imgProcess;
headingStyle?: 'underline' | 'linebreak' | 'hashify';
listStyle?: 'indentation' | 'linebreak';
uIndentionChar?: string;
oIndentionChar?: string;
listIndentionTabs?: number;
keepNbsps?: boolean;
}
}
export = textversionjs;

View File

@ -0,0 +1,13 @@
import textVersion = require('textversionjs');
// $ExpectType string
textVersion("<h1>Hello World</h1><p>Hello World</p>");
/*
=>
Hello World
===========
Hello World
*/
// $ExpectError
textVersion(1);

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"textversionjs-tests.ts"
]
}

View File

@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"indent": [true, "spaces", 4],
"max-line-length": [true, 100],
"no-any": true
}
}