From d80f628153b536fca62d3fe297cc4a2223ca9dad Mon Sep 17 00:00:00 2001 From: Peter van der Woude Date: Sat, 23 Jun 2018 15:17:17 +1000 Subject: [PATCH 1/6] add new typings for jotform-css.js project --- types/jotform-css.js/index.d.ts | 122 +++++++++++++++++++ types/jotform-css.js/jotform-css.js-tests.ts | 17 +++ types/jotform-css.js/tsconfig.json | 23 ++++ types/jotform-css.js/tslint.json | 79 ++++++++++++ 4 files changed, 241 insertions(+) create mode 100644 types/jotform-css.js/index.d.ts create mode 100644 types/jotform-css.js/jotform-css.js-tests.ts create mode 100644 types/jotform-css.js/tsconfig.json create mode 100644 types/jotform-css.js/tslint.json diff --git a/types/jotform-css.js/index.d.ts b/types/jotform-css.js/index.d.ts new file mode 100644 index 0000000000..e21dae2eb9 --- /dev/null +++ b/types/jotform-css.js/index.d.ts @@ -0,0 +1,122 @@ +// Type definitions for jotform-css.js v1.0.1 +// Project: https://github.com/jotform/css.js +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * intermediate object - needed as a result of the way the libary doesn't explicitly export anything + */ +export interface CssJsGlobal { + cssjs() : CssJs +} + +export interface CssJs { + + /** + * Parses given css string, and returns css object + * keys as selectors and values are css rules + * eliminates all css comments before parsing + * @param {string} css string to be parsed + * @returns {CssJs} css object + */ + parseCSS(css: string): CssJs + + /** + * parses given string containing css directives + * @param {string} rules, css directive string eg color:white; font-size:18px; + * @returns {any[]} an array of objects containing ruleName:ruleValue pairs + */ + parseRules(rules: string): any[] + + /** + * returns the rule having given directive + * @param {string} rules + * @param {string} directive + * @param {string} value + */ + findCorrespondingRule(rules: string, directive: string, value?: string): string | boolean + + /** + * Finds styles that have given selector, compress them and returns them + * @param cssObject + * @param {string} selector + * @param {boolean} contains + */ + findBySelector(cssObject: CssJs, selector: string, contains?: boolean) : CssJs + + /** + * deletes cssObjects having given selector, and returns new array + * @param {CssJs} cssObject + * @param {string} selector + * @returns {CssJs} + */ + deleteBySelector(cssObject: CssJs, selector: string): CssJs + + /** + * Compresses given cssObjectArray and tries to minimize selector redundence + * @param {CssJs} cssObject + * @returns {CssJs} + */ + compressCSS(cssObject: CssJs): CssJs + + /** + * @param {CssJs} css1 + * @param {CssJs} css2 + * @returns {boolean} diff css object contains changed values in css1 in regards to css2, false if same + */ + cssDiff(css1: CssJs, css2: CssJs): boolean + + /** + * @param {CssJs} cssObject target css object array + * @param {CssJs} newArray source array that will be pushed into cssObject parameter + * @param {boolean} reverse [optional], if given true, first parameter will be traversed on reversed order + effectively giving priority to the styles in newArray + */ + intelligentMerge(cssObject: CssJs, newArray: CssJs, reverse?: boolean) : void + + /** + * inserts new css objects into a bigger css object with same selectors grouped together + * @param {CssJs} cssObject array of bigger css object to be pushed into + * @param {CssJs} minimalObject single css object + * @param {boolean} reverse reverse [optional] default is false, if given, cssObject will be reversly traversed + resulting more priority in minimalObject's styles + */ + intelligentCSSPush(cssObject: CssJs, minimalObject: CssJs, reverse?: boolean) : void + + /** + * Filter outs rule objects whose type param equal to DELETED + * @param {string} rules array of rules + */ + compactRules(rules: string[]): string[] + + /** + * Computes string for ace editor using this.css or given cssBase optional parameter + * @param {CssJs} parsedCss + * @param depth + * @returns {string} + */ + getCSSForEditor(parsedCss: CssJs, depth?: number): string + + /** + * Given rules array, returns visually formatted css string to be used inside editor + * @param {string} rules + * @param {null} depth + * @returns {string} + */ + getCSSOfRules(rules: string, depth?: null): string + + /** + * Given css string or objectArray, parses it and then for every selector, + * prepends this.cssPreviewNamespace to prevent css collision issues + * @param {CssJs} parsedCss + * @param {string} prefix + * @returns {CssJs} object in which this css prepended + */ + applyNamespacing(parsedCss: CssJs | string, prefix: string): CssJs + + /** + * @param {string} css the original css string to be stripped out of comments + * @returns {string} cleaned CSS containing no css comments + */ + stripComments(css: string): string +} diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts new file mode 100644 index 0000000000..80f4fd5b54 --- /dev/null +++ b/types/jotform-css.js/jotform-css.js-tests.ts @@ -0,0 +1,17 @@ +let cssjsGlobal = require("../../jotform-css.js") +import { CssJs } from "./index" + +// not all interface methods tested here, below is a sample of code that I've actually used +class TestParser { + public parse(): string { + const parser = new cssjsGlobal.cssjs() as CssJs + + let parsed = parser.parseCSS(".foo { background-color: red }") + parsed = parser.applyNamespacing(parsed, "#id1") + let css = parser.getCSSForEditor(parsed) + return css + } +} + +let parsingTest = new TestParser() +let css = parsingTest.parse() diff --git a/types/jotform-css.js/tsconfig.json b/types/jotform-css.js/tsconfig.json new file mode 100644 index 0000000000..484cc299b5 --- /dev/null +++ b/types/jotform-css.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": ["node"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jotform-css.js-tests.ts" + ] +} diff --git a/types/jotform-css.js/tslint.json b/types/jotform-css.js/tslint.json new file mode 100644 index 0000000000..44e1713d82 --- /dev/null +++ b/types/jotform-css.js/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": true, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": true, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From 5ce60d33addd1ab2787aa531e792c629e53f8ff7 Mon Sep 17 00:00:00 2001 From: Peter van der Woude Date: Sat, 23 Jun 2018 17:09:03 +1000 Subject: [PATCH 2/6] remove node from tsconfig types and use import statement in tests --- types/jotform-css.js/index.d.ts | 9 ++++----- types/jotform-css.js/jotform-css.js-tests.ts | 10 +++++----- types/jotform-css.js/tsconfig.json | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/types/jotform-css.js/index.d.ts b/types/jotform-css.js/index.d.ts index e21dae2eb9..cb6c62b6c0 100644 --- a/types/jotform-css.js/index.d.ts +++ b/types/jotform-css.js/index.d.ts @@ -1,14 +1,13 @@ // Type definitions for jotform-css.js v1.0.1 // Project: https://github.com/jotform/css.js -// Definitions by: My Self +// Definitions by: Peter van der Woude // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// /** - * intermediate object - needed as a result of the way the libary doesn't explicitly export anything + * Thid doesn't get used in the way I intended */ -export interface CssJsGlobal { - cssjs() : CssJs -} +export function cssjs() : CssJs export interface CssJs { diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts index 80f4fd5b54..ad3e45e100 100644 --- a/types/jotform-css.js/jotform-css.js-tests.ts +++ b/types/jotform-css.js/jotform-css.js-tests.ts @@ -1,12 +1,12 @@ -let cssjsGlobal = require("../../jotform-css.js") +import cssjsGlobal = require("../jotform-css.js") import { CssJs } from "./index" // not all interface methods tested here, below is a sample of code that I've actually used class TestParser { - public parse(): string { - const parser = new cssjsGlobal.cssjs() as CssJs + public parse(cssString: string): string { + const parser = new (cssjsGlobal).cssjs() as CssJs - let parsed = parser.parseCSS(".foo { background-color: red }") + let parsed = parser.parseCSS(cssString) parsed = parser.applyNamespacing(parsed, "#id1") let css = parser.getCSSForEditor(parsed) return css @@ -14,4 +14,4 @@ class TestParser { } let parsingTest = new TestParser() -let css = parsingTest.parse() +let css = parsingTest.parse(".foo { background-color: red }") diff --git a/types/jotform-css.js/tsconfig.json b/types/jotform-css.js/tsconfig.json index 484cc299b5..2e6cc5a4f5 100644 --- a/types/jotform-css.js/tsconfig.json +++ b/types/jotform-css.js/tsconfig.json @@ -12,7 +12,7 @@ "typeRoots": [ "../" ], - "types": ["node"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From 4a27679e255152f9ddd06207cc53725a46757440 Mon Sep 17 00:00:00 2001 From: Peter van der Woude Date: Sat, 23 Jun 2018 19:59:36 +1000 Subject: [PATCH 3/6] fix require in the only way I know that works at runtime --- types/jotform-css.js/index.d.ts | 1 + types/jotform-css.js/jotform-css.js-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/jotform-css.js/index.d.ts b/types/jotform-css.js/index.d.ts index cb6c62b6c0..3b748fc176 100644 --- a/types/jotform-css.js/index.d.ts +++ b/types/jotform-css.js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jotform/css.js // Definitions by: Peter van der Woude // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + /// /** diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts index ad3e45e100..73c2d15a43 100644 --- a/types/jotform-css.js/jotform-css.js-tests.ts +++ b/types/jotform-css.js/jotform-css.js-tests.ts @@ -1,10 +1,10 @@ -import cssjsGlobal = require("../jotform-css.js") +let cssjsGlobal = require("jotform-css.js") import { CssJs } from "./index" // not all interface methods tested here, below is a sample of code that I've actually used class TestParser { public parse(cssString: string): string { - const parser = new (cssjsGlobal).cssjs() as CssJs + const parser = new cssjsGlobal.cssjs() as CssJs let parsed = parser.parseCSS(cssString) parsed = parser.applyNamespacing(parsed, "#id1") From 7573138186a935571cf81ef5c76467a2ddfd4f82 Mon Sep 17 00:00:00 2001 From: Peter van der Woude Date: Sat, 23 Jun 2018 20:15:16 +1000 Subject: [PATCH 4/6] correct require reference, this is what I have to use for it to work --- types/jotform-css.js/jotform-css.js-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts index 73c2d15a43..688fa13112 100644 --- a/types/jotform-css.js/jotform-css.js-tests.ts +++ b/types/jotform-css.js/jotform-css.js-tests.ts @@ -1,4 +1,4 @@ -let cssjsGlobal = require("jotform-css.js") +let cssjsGlobal = require("jotform-css.js/css.js") import { CssJs } from "./index" // not all interface methods tested here, below is a sample of code that I've actually used From 1b47d8f2766eba7b3d012477286a8d0c8ad0460e Mon Sep 17 00:00:00 2001 From: Peter van der Woude Date: Mon, 25 Jun 2018 22:47:44 +1000 Subject: [PATCH 5/6] fix tslint and added exports to global and module modifying types --- types/jotform-css.js/index.d.ts | 15 ++-- .../jotform-css.js-global-tests.ts | 5 ++ .../jotform-css.js-module-tests.ts | 9 +++ types/jotform-css.js/jotform-css.js-tests.ts | 21 ++--- types/jotform-css.js/tsconfig.json | 4 +- types/jotform-css.js/tslint.json | 78 +------------------ 6 files changed, 32 insertions(+), 100 deletions(-) create mode 100644 types/jotform-css.js/jotform-css.js-global-tests.ts create mode 100644 types/jotform-css.js/jotform-css.js-module-tests.ts diff --git a/types/jotform-css.js/index.d.ts b/types/jotform-css.js/index.d.ts index 3b748fc176..d24e4d5458 100644 --- a/types/jotform-css.js/index.d.ts +++ b/types/jotform-css.js/index.d.ts @@ -3,15 +3,18 @@ // Definitions by: Peter van der Woude // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +declare global { + const cssjs: CssJsConstructor +} -/** - * Thid doesn't get used in the way I intended - */ -export function cssjs() : CssJs +export interface CssJsConstructor { + new (): CssJs; +} + +export const cssjs : CssJsConstructor; +export default cssjs; export interface CssJs { - /** * Parses given css string, and returns css object * keys as selectors and values are css rules diff --git a/types/jotform-css.js/jotform-css.js-global-tests.ts b/types/jotform-css.js/jotform-css.js-global-tests.ts new file mode 100644 index 0000000000..95cb5f6be0 --- /dev/null +++ b/types/jotform-css.js/jotform-css.js-global-tests.ts @@ -0,0 +1,5 @@ +function addNamespace(cssString: string): string { + const parser = new cssjs(); + const parsed = parser.applyNamespacing(cssString, "#id1"); + return parser.getCSSForEditor(parsed); +} diff --git a/types/jotform-css.js/jotform-css.js-module-tests.ts b/types/jotform-css.js/jotform-css.js-module-tests.ts new file mode 100644 index 0000000000..7f42f0275c --- /dev/null +++ b/types/jotform-css.js/jotform-css.js-module-tests.ts @@ -0,0 +1,9 @@ +import cssjsParser = require("jotform-css.js"); + +function addNamespace(cssString: string): string { + const parser = new cssjsParser.cssjs(); + let parsed = parser.parseCSS(cssString); + parsed = parser.applyNamespacing(parsed, "#id1"); + const css = parser.getCSSForEditor(parsed); + return css; +} diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts index 688fa13112..ad2b619a10 100644 --- a/types/jotform-css.js/jotform-css.js-tests.ts +++ b/types/jotform-css.js/jotform-css.js-tests.ts @@ -1,17 +1,6 @@ -let cssjsGlobal = require("jotform-css.js/css.js") -import { CssJs } from "./index" - -// not all interface methods tested here, below is a sample of code that I've actually used -class TestParser { - public parse(cssString: string): string { - const parser = new cssjsGlobal.cssjs() as CssJs - - let parsed = parser.parseCSS(cssString) - parsed = parser.applyNamespacing(parsed, "#id1") - let css = parser.getCSSForEditor(parsed) - return css - } +// DefinitelyTyped scripts are forcing me to have this, I don't need or want this file +function addNamespace2(cssString: string): string { + const parser = new cssjs(); + const parsed = parser.applyNamespacing(cssString, "#id1"); + return parser.getCSSForEditor(parsed); } - -let parsingTest = new TestParser() -let css = parsingTest.parse(".foo { background-color: red }") diff --git a/types/jotform-css.js/tsconfig.json b/types/jotform-css.js/tsconfig.json index 2e6cc5a4f5..bae12b9a2c 100644 --- a/types/jotform-css.js/tsconfig.json +++ b/types/jotform-css.js/tsconfig.json @@ -18,6 +18,8 @@ }, "files": [ "index.d.ts", - "jotform-css.js-tests.ts" + "jotform-css.js-tests.ts", + "jotform-css.js-global-tests.ts", + "jotform-css.js-module-tests.ts" ] } diff --git a/types/jotform-css.js/tslint.json b/types/jotform-css.js/tslint.json index 44e1713d82..f93cf8562a 100644 --- a/types/jotform-css.js/tslint.json +++ b/types/jotform-css.js/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": true, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": true, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From fb6278ebda05b592af5f293671b343e2ade482ec Mon Sep 17 00:00:00 2001 From: Peter van der Woude Date: Mon, 25 Jun 2018 23:12:48 +1000 Subject: [PATCH 6/6] fix lint etc errors --- types/jotform-css.js/index.d.ts | 89 +++++++------------ types/jotform-css.js/jotform-css.js-tests.ts | 6 -- .../{ => test}/jotform-css.js-global-tests.ts | 0 .../{ => test}/jotform-css.js-module-tests.ts | 0 types/jotform-css.js/tsconfig.json | 5 +- 5 files changed, 36 insertions(+), 64 deletions(-) delete mode 100644 types/jotform-css.js/jotform-css.js-tests.ts rename types/jotform-css.js/{ => test}/jotform-css.js-global-tests.ts (100%) rename types/jotform-css.js/{ => test}/jotform-css.js-module-tests.ts (100%) diff --git a/types/jotform-css.js/index.d.ts b/types/jotform-css.js/index.d.ts index d24e4d5458..1a712868fb 100644 --- a/types/jotform-css.js/index.d.ts +++ b/types/jotform-css.js/index.d.ts @@ -1,17 +1,17 @@ -// Type definitions for jotform-css.js v1.0.1 +// Type definitions for jotform-css.js 1.0 // Project: https://github.com/jotform/css.js // Definitions by: Peter van der Woude // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare global { - const cssjs: CssJsConstructor + const cssjs: CssJsConstructor; } export interface CssJsConstructor { new (): CssJs; } -export const cssjs : CssJsConstructor; +export const cssjs: CssJsConstructor; export default cssjs; export interface CssJs { @@ -19,107 +19,86 @@ export interface CssJs { * Parses given css string, and returns css object * keys as selectors and values are css rules * eliminates all css comments before parsing - * @param {string} css string to be parsed - * @returns {CssJs} css object + * @param css string to be parsed + * @returns css object */ - parseCSS(css: string): CssJs + parseCSS(css: string): CssJs; /** * parses given string containing css directives - * @param {string} rules, css directive string eg color:white; font-size:18px; - * @returns {any[]} an array of objects containing ruleName:ruleValue pairs + * @param rules, css directive string eg color:white; font-size:18px; + * @returns an array of objects containing ruleName:ruleValue pairs */ - parseRules(rules: string): any[] + parseRules(rules: string): any[]; /** * returns the rule having given directive - * @param {string} rules - * @param {string} directive - * @param {string} value */ - findCorrespondingRule(rules: string, directive: string, value?: string): string | boolean + findCorrespondingRule(rules: string, directive: string, value?: string): string | boolean; /** * Finds styles that have given selector, compress them and returns them - * @param cssObject - * @param {string} selector - * @param {boolean} contains */ - findBySelector(cssObject: CssJs, selector: string, contains?: boolean) : CssJs + findBySelector(cssObject: CssJs, selector: string, contains?: boolean): CssJs; /** * deletes cssObjects having given selector, and returns new array - * @param {CssJs} cssObject - * @param {string} selector - * @returns {CssJs} */ - deleteBySelector(cssObject: CssJs, selector: string): CssJs + deleteBySelector(cssObject: CssJs, selector: string): CssJs; /** * Compresses given cssObjectArray and tries to minimize selector redundence - * @param {CssJs} cssObject - * @returns {CssJs} */ - compressCSS(cssObject: CssJs): CssJs + compressCSS(cssObject: CssJs): CssJs; /** - * @param {CssJs} css1 - * @param {CssJs} css2 - * @returns {boolean} diff css object contains changed values in css1 in regards to css2, false if same + * @returns diff css object contains changed values in css1 in regards to css2, false if same */ - cssDiff(css1: CssJs, css2: CssJs): boolean + cssDiff(css1: CssJs, css2: CssJs): boolean; /** - * @param {CssJs} cssObject target css object array - * @param {CssJs} newArray source array that will be pushed into cssObject parameter - * @param {boolean} reverse [optional], if given true, first parameter will be traversed on reversed order - effectively giving priority to the styles in newArray + * @param cssObject target css object array + * @param newArray source array that will be pushed into cssObject parameter + * @param reverse [optional], if given true, first parameter will be traversed on reversed order + * effectively giving priority to the styles in newArray */ - intelligentMerge(cssObject: CssJs, newArray: CssJs, reverse?: boolean) : void + intelligentMerge(cssObject: CssJs, newArray: CssJs, reverse?: boolean): void; /** * inserts new css objects into a bigger css object with same selectors grouped together - * @param {CssJs} cssObject array of bigger css object to be pushed into - * @param {CssJs} minimalObject single css object - * @param {boolean} reverse reverse [optional] default is false, if given, cssObject will be reversly traversed - resulting more priority in minimalObject's styles + * @param cssObject array of bigger css object to be pushed into + * @param minimalObject single css object + * @param reverse reverse [optional] default is false, if given, cssObject will be reversly traversed + * resulting more priority in minimalObject's styles */ - intelligentCSSPush(cssObject: CssJs, minimalObject: CssJs, reverse?: boolean) : void + intelligentCSSPush(cssObject: CssJs, minimalObject: CssJs, reverse?: boolean): void; /** * Filter outs rule objects whose type param equal to DELETED - * @param {string} rules array of rules + * @param rules array of rules */ - compactRules(rules: string[]): string[] + compactRules(rules: string[]): string[]; /** * Computes string for ace editor using this.css or given cssBase optional parameter - * @param {CssJs} parsedCss - * @param depth - * @returns {string} */ - getCSSForEditor(parsedCss: CssJs, depth?: number): string + getCSSForEditor(parsedCss: CssJs, depth?: number): string; /** * Given rules array, returns visually formatted css string to be used inside editor - * @param {string} rules - * @param {null} depth - * @returns {string} */ - getCSSOfRules(rules: string, depth?: null): string + getCSSOfRules(rules: string, depth?: null): string; /** * Given css string or objectArray, parses it and then for every selector, * prepends this.cssPreviewNamespace to prevent css collision issues - * @param {CssJs} parsedCss - * @param {string} prefix - * @returns {CssJs} object in which this css prepended + * @returns object in which this css prepended */ - applyNamespacing(parsedCss: CssJs | string, prefix: string): CssJs + applyNamespacing(parsedCss: CssJs | string, prefix: string): CssJs; /** - * @param {string} css the original css string to be stripped out of comments - * @returns {string} cleaned CSS containing no css comments + * @param css the original css string to be stripped out of comments + * @returns cleaned CSS containing no css comments */ - stripComments(css: string): string + stripComments(css: string): string; } diff --git a/types/jotform-css.js/jotform-css.js-tests.ts b/types/jotform-css.js/jotform-css.js-tests.ts deleted file mode 100644 index ad2b619a10..0000000000 --- a/types/jotform-css.js/jotform-css.js-tests.ts +++ /dev/null @@ -1,6 +0,0 @@ -// DefinitelyTyped scripts are forcing me to have this, I don't need or want this file -function addNamespace2(cssString: string): string { - const parser = new cssjs(); - const parsed = parser.applyNamespacing(cssString, "#id1"); - return parser.getCSSForEditor(parsed); -} diff --git a/types/jotform-css.js/jotform-css.js-global-tests.ts b/types/jotform-css.js/test/jotform-css.js-global-tests.ts similarity index 100% rename from types/jotform-css.js/jotform-css.js-global-tests.ts rename to types/jotform-css.js/test/jotform-css.js-global-tests.ts diff --git a/types/jotform-css.js/jotform-css.js-module-tests.ts b/types/jotform-css.js/test/jotform-css.js-module-tests.ts similarity index 100% rename from types/jotform-css.js/jotform-css.js-module-tests.ts rename to types/jotform-css.js/test/jotform-css.js-module-tests.ts diff --git a/types/jotform-css.js/tsconfig.json b/types/jotform-css.js/tsconfig.json index bae12b9a2c..948e34b5ce 100644 --- a/types/jotform-css.js/tsconfig.json +++ b/types/jotform-css.js/tsconfig.json @@ -18,8 +18,7 @@ }, "files": [ "index.d.ts", - "jotform-css.js-tests.ts", - "jotform-css.js-global-tests.ts", - "jotform-css.js-module-tests.ts" + "test/jotform-css.js-global-tests.ts", + "test/jotform-css.js-module-tests.ts" ] }