From 432e9870184cdbcc2ecc74630c77e99728859f92 Mon Sep 17 00:00:00 2001 From: garyking Date: Fri, 25 Oct 2019 16:26:59 -0400 Subject: [PATCH] Add files for `sloc`. (#39405) --- types/sloc/index.d.ts | 109 +++++++++++++++++++++++++++++++++++++++ types/sloc/sloc-tests.ts | 7 +++ types/sloc/tsconfig.json | 23 +++++++++ types/sloc/tslint.json | 1 + 4 files changed, 140 insertions(+) create mode 100644 types/sloc/index.d.ts create mode 100644 types/sloc/sloc-tests.ts create mode 100644 types/sloc/tsconfig.json create mode 100644 types/sloc/tslint.json diff --git a/types/sloc/index.d.ts b/types/sloc/index.d.ts new file mode 100644 index 0000000000..d48142803e --- /dev/null +++ b/types/sloc/index.d.ts @@ -0,0 +1,109 @@ +// Type definitions for sloc 0.2 +// Project: https://github.com/flosse/sloc#readme +// Definitions by: Gary King +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +declare function sloc(code: string, extension: string, options?: sloc.Options): Record; + +declare namespace sloc { + const keys: Key[]; + + const extensions: Extension[]; + + interface Options { + debug: boolean; + } + + type Extension = + | 'asm' + | 'brs' + | 'c' + | 'cc' + | 'clj' + | 'cljs' + | 'cls' + | 'coffee' + | 'cpp' + | 'cr' + | 'cs' + | 'css' + | 'cxx' + | 'erl' + | 'f90' + | 'f95' + | 'f03' + | 'f08' + | 'f18' + | 'fs' + | 'fsi' + | 'fsx' + | 'go' + | 'groovy' + | 'gs' + | 'h' + | 'handlebars' + | 'hbs' + | 'hpp' + | 'hr' + | 'hs' + | 'html' + | 'htm' + | 'hx' + | 'hxx' + | 'hy' + | 'iced' + | 'ily' + | 'ino' + | 'jade' + | 'java' + | 'jl' + | 'js' + | 'jsx' + | 'mjs' + | 'kt' + | 'kts' + | 'latex' + | 'less' + | 'ly' + | 'lua' + | 'ls' + | 'ml' + | 'mli' + | 'mochi' + | 'monkey' + | 'mustache' + | 'nix' + | 'nim' + | 'nut' + | 'php' + | 'php5' + | 'pl' + | 'py' + | 'r' + | 'rb' + | 'rkt' + | 'rs' + | 'sass' + | 'scala' + | 'scss' + | 'sty' + | 'styl' + | 'svg' + | 'sql' + | 'swift' + | 'tex' + | 'ts' + | 'tsx' + | 'vb' + | 'vue' + | 'xml' + | 'yaml' + | 'm' + | 'mm' + | 'bsl'; + + type Key = 'total' | 'source' | 'comment' | 'single' | 'block' | 'mixed' | 'blockEmpty' | 'empty' | 'todo'; +} + +export = sloc; diff --git a/types/sloc/sloc-tests.ts b/types/sloc/sloc-tests.ts new file mode 100644 index 0000000000..1f931e5468 --- /dev/null +++ b/types/sloc/sloc-tests.ts @@ -0,0 +1,7 @@ +import sloc = require('sloc'); + +const stats = sloc('const a = 1;\nconsole.log(a);', 'js'); +const statsDebugged = sloc('const a = 1;\nconsole.log(a);', 'ts', { debug: true }); + +const keys = sloc.keys; +const extensions = sloc.extensions; diff --git a/types/sloc/tsconfig.json b/types/sloc/tsconfig.json new file mode 100644 index 0000000000..27de434dfb --- /dev/null +++ b/types/sloc/tsconfig.json @@ -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", + "sloc-tests.ts" + ] +} diff --git a/types/sloc/tslint.json b/types/sloc/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sloc/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }