diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/tslint/lib | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) |
remove node_modules
Diffstat (limited to 'node_modules/tslint/lib')
384 files changed, 0 insertions, 29295 deletions
diff --git a/node_modules/tslint/lib/configs/all.d.ts b/node_modules/tslint/lib/configs/all.d.ts deleted file mode 100644 index bcaf0a190..000000000 --- a/node_modules/tslint/lib/configs/all.d.ts +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export declare const rules: { - "adjacent-overload-signatures": boolean; - "ban-types": { - options: string[][]; - }; - "member-access": (string | boolean)[]; - "member-ordering": (boolean | { - "order": string; - "alphabetize": boolean; - })[]; - "no-any": boolean; - "no-empty-interface": boolean; - "no-import-side-effect": boolean; - "no-inferrable-types": (string | boolean)[]; - "no-internal-module": boolean; - "no-magic-numbers": boolean; - "no-namespace": boolean; - "no-non-null-assertion": boolean; - "no-reference": boolean; - "no-this-assignment": boolean; - "no-var-requires": boolean; - "only-arrow-functions": boolean; - "prefer-for-of": boolean; - "prefer-readonly": boolean; - "promise-function-async": boolean; - "typedef": (string | boolean)[]; - "typedef-whitespace": (boolean | { - "call-signature": string; - "index-signature": string; - "parameter": string; - "property-declaration": string; - "variable-declaration": string; - })[]; - "unified-signatures": boolean; - "await-promise": boolean; - "ban-comma-operator": boolean; - "curly": boolean; - "forin": boolean; - "label-position": boolean; - "no-arg": boolean; - "no-bitwise": boolean; - "no-conditional-assignment": boolean; - "no-console": boolean; - "no-construct": boolean; - "no-debugger": boolean; - "no-duplicate-super": boolean; - "no-duplicate-switch-case": boolean; - "no-duplicate-variable": (string | boolean)[]; - "no-dynamic-delete": boolean; - "no-empty": boolean; - "no-eval": boolean; - "no-floating-promises": boolean; - "no-for-in-array": boolean; - "no-implicit-dependencies": boolean; - "no-inferred-empty-object-type": boolean; - "no-invalid-template-strings": boolean; - "no-misused-new": boolean; - "no-null-keyword": boolean; - "no-object-literal-type-assertion": boolean; - "no-return-await": boolean; - "no-shadowed-variable": boolean; - "no-string-literal": boolean; - "no-string-throw": boolean; - "no-sparse-arrays": boolean; - "no-submodule-imports": boolean; - "no-unbound-method": boolean; - "no-unnecessary-class": (string | boolean)[]; - "no-unsafe-any": boolean; - "no-unsafe-finally": boolean; - "no-unused-expression": boolean; - "no-unused-variable": boolean; - "no-use-before-declare": boolean; - "no-var-keyword": boolean; - "no-void-expression": boolean; - "prefer-conditional-expression": boolean; - "radix": boolean; - "restrict-plus-operands": boolean; - "strict-boolean-expressions": boolean; - "strict-type-predicates": boolean; - "switch-default": boolean; - "triple-equals": boolean; - "use-default-type-parameter": boolean; - "use-isnan": boolean; - "cyclomatic-complexity": boolean; - "eofline": boolean; - "indent": (string | boolean)[]; - "linebreak-style": (string | boolean)[]; - "max-classes-per-file": (number | boolean)[]; - "max-file-line-count": (number | boolean)[]; - "max-line-length": (number | boolean)[]; - "no-default-export": boolean; - "no-duplicate-imports": boolean; - "no-irregular-whitespace": boolean; - "no-mergeable-namespace": boolean; - "no-parameter-reassignment": boolean; - "no-require-imports": boolean; - "no-trailing-whitespace": boolean; - "object-literal-sort-keys": boolean; - "prefer-const": boolean; - "trailing-comma": (boolean | { - "multiline": string; - "singleline": string; - })[]; - "align": (string | boolean)[]; - "array-type": (string | boolean)[]; - "arrow-parens": boolean; - "arrow-return-shorthand": (string | boolean)[]; - "binary-expression-operand-order": boolean; - "callable-types": boolean; - "class-name": boolean; - "comment-format": (string | boolean)[]; - "completed-docs": boolean; - "deprecation": boolean; - "encoding": boolean; - "file-name-casing": (string | boolean)[]; - "import-spacing": boolean; - "interface-name": boolean; - "interface-over-type-literal": boolean; - "jsdoc-format": (string | boolean)[]; - "match-default-export-name": boolean; - "new-parens": boolean; - "newline-before-return": boolean; - "newline-per-chained-call": boolean; - "no-angle-bracket-type-assertion": boolean; - "no-boolean-literal-compare": boolean; - "no-consecutive-blank-lines": boolean; - "no-parameter-properties": boolean; - "no-redundant-jsdoc": boolean; - "no-reference-import": boolean; - "no-unnecessary-callback-wrapper": boolean; - "no-unnecessary-initializer": boolean; - "no-unnecessary-qualifier": boolean; - "no-unnecessary-type-assertion": boolean; - "number-literal-format": boolean; - "object-literal-key-quotes": (string | boolean)[]; - "object-literal-shorthand": boolean; - "one-line": (string | boolean)[]; - "one-variable-per-declaration": boolean; - "ordered-imports": (boolean | { - "import-sources-order": string; - "named-imports-order": string; - "module-source-path": string; - })[]; - "prefer-function-over-method": boolean; - "prefer-method-signature": boolean; - "prefer-object-spread": boolean; - "prefer-switch": boolean; - "prefer-template": boolean; - "prefer-while": boolean; - "quotemark": (string | boolean)[]; - "return-undefined": boolean; - "semicolon": (string | boolean)[]; - "space-before-function-paren": (boolean | { - "anonymous": string; - "asyncArrow": string; - "constructor": string; - "method": string; - "named": string; - })[]; - "space-within-parens": (number | boolean)[]; - "switch-final-break": boolean; - "type-literal-delimiter": boolean; - "variable-name": (string | boolean)[]; - "whitespace": (string | boolean)[]; -}; -export declare const RULES_EXCLUDED_FROM_ALL_CONFIG: string[]; -export declare const jsRules: { - [key: string]: any; -}; diff --git a/node_modules/tslint/lib/configs/all.js b/node_modules/tslint/lib/configs/all.js deleted file mode 100644 index 2a5f24307..000000000 --- a/node_modules/tslint/lib/configs/all.js +++ /dev/null @@ -1,280 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var path_1 = require("path"); -var ruleLoader_1 = require("../ruleLoader"); -var utils_1 = require("../utils"); -// tslint:disable object-literal-sort-keys -// tslint:disable object-literal-key-quotes -exports.rules = { - // TypeScript Specific - "adjacent-overload-signatures": true, - "ban-types": { - options: [ - ["Object", "Avoid using the `Object` type. Did you mean `object`?"], - ["Function", "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."], - ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"], - ["Number", "Avoid using the `Number` type. Did you mean `number`?"], - ["String", "Avoid using the `String` type. Did you mean `string`?"], - ["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"], - ], - }, - "member-access": [true, "check-accessor", "check-constructor", "check-parameter-property"], - "member-ordering": [true, { - "order": "statics-first", - "alphabetize": true, - }], - "no-any": true, - "no-empty-interface": true, - "no-import-side-effect": true, - // Technically this is not the strictest setting, but don't want to conflict with "typedef" - "no-inferrable-types": [true, "ignore-params"], - "no-internal-module": true, - "no-magic-numbers": true, - "no-namespace": true, - "no-non-null-assertion": true, - "no-reference": true, - "no-this-assignment": true, - "no-var-requires": true, - "only-arrow-functions": true, - "prefer-for-of": true, - "prefer-readonly": true, - "promise-function-async": true, - "typedef": [ - true, - "call-signature", - "arrow-call-signature", - "parameter", - "arrow-parameter", - "property-declaration", - "variable-declaration", - "member-variable-declaration", - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace", - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace", - }, - ], - "unified-signatures": true, - // Functionality - "await-promise": true, - // "ban": no sensible default - "ban-comma-operator": true, - "curly": true, - "forin": true, - // "import-blacklist": no sensible default - "label-position": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-console": true, - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-duplicate-switch-case": true, - "no-duplicate-variable": [ - true, - "check-parameters", - ], - "no-dynamic-delete": true, - "no-empty": true, - "no-eval": true, - "no-floating-promises": true, - "no-for-in-array": true, - "no-implicit-dependencies": true, - "no-inferred-empty-object-type": true, - "no-invalid-template-strings": true, - // "no-invalid-this": Won't this be deprecated? - "no-misused-new": true, - "no-null-keyword": true, - "no-object-literal-type-assertion": true, - "no-return-await": true, - "no-shadowed-variable": true, - "no-string-literal": true, - "no-string-throw": true, - "no-sparse-arrays": true, - "no-submodule-imports": true, - "no-unbound-method": true, - "no-unnecessary-class": [true, "allow-empty-class"], - "no-unsafe-any": true, - "no-unsafe-finally": true, - "no-unused-expression": true, - "no-unused-variable": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "no-void-expression": true, - "prefer-conditional-expression": true, - "radix": true, - "restrict-plus-operands": true, - "strict-boolean-expressions": true, - "strict-type-predicates": true, - "switch-default": true, - "triple-equals": true, - "use-default-type-parameter": true, - "use-isnan": true, - // Maintainability - "cyclomatic-complexity": true, - "eofline": true, - "indent": [true, "spaces"], - "linebreak-style": [true, "LF"], - "max-classes-per-file": [true, 1], - "max-file-line-count": [true, 1000], - "max-line-length": [true, 120], - "no-default-export": true, - "no-duplicate-imports": true, - "no-irregular-whitespace": true, - "no-mergeable-namespace": true, - "no-parameter-reassignment": true, - "no-require-imports": true, - "no-trailing-whitespace": true, - "object-literal-sort-keys": true, - "prefer-const": true, - "trailing-comma": [true, { - "multiline": "always", - "singleline": "never", - }], - // Style - "align": [ - true, - "parameters", - "arguments", - "statements", - "elements", - "members", - ], - "array-type": [true, "array-simple"], - "arrow-parens": true, - "arrow-return-shorthand": [true, "multiline"], - "binary-expression-operand-order": true, - "callable-types": true, - "class-name": true, - "comment-format": [ - true, - "check-space", - "check-uppercase", - ], - "completed-docs": true, - // "file-header": No sensible default - "deprecation": true, - "encoding": true, - "file-name-casing": [true, "camel-case"], - "import-spacing": true, - "interface-name": true, - "interface-over-type-literal": true, - "jsdoc-format": [true, "check-multiline-start"], - "match-default-export-name": true, - "new-parens": true, - "newline-before-return": true, - "newline-per-chained-call": true, - "no-angle-bracket-type-assertion": true, - "no-boolean-literal-compare": true, - "no-consecutive-blank-lines": true, - "no-parameter-properties": true, - "no-redundant-jsdoc": true, - "no-reference-import": true, - "no-unnecessary-callback-wrapper": true, - "no-unnecessary-initializer": true, - "no-unnecessary-qualifier": true, - "no-unnecessary-type-assertion": true, - "number-literal-format": true, - "object-literal-key-quotes": [true, "consistent-as-needed"], - "object-literal-shorthand": true, - "one-line": [ - true, - "check-catch", - "check-else", - "check-finally", - "check-open-brace", - "check-whitespace", - ], - "one-variable-per-declaration": true, - "ordered-imports": [true, { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "module-source-path": "full", - }], - "prefer-function-over-method": true, - "prefer-method-signature": true, - "prefer-object-spread": true, - "prefer-switch": true, - "prefer-template": true, - "prefer-while": true, - "quotemark": [ - true, - "double", - "avoid-escape", - "avoid-template", - ], - "return-undefined": true, - "semicolon": [true, "always"], - "space-before-function-paren": [true, { - "anonymous": "never", - "asyncArrow": "always", - "constructor": "never", - "method": "never", - "named": "never", - }], - "space-within-parens": [true, 0], - "switch-final-break": true, - "type-literal-delimiter": true, - "variable-name": [ - true, - "ban-keywords", - "check-format", - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-module", - "check-separator", - "check-type", - "check-typecast", - "check-preblock", - "check-type-operator", - "check-rest-spread", - ], -}; -exports.RULES_EXCLUDED_FROM_ALL_CONFIG = ["ban", "fileHeader", "importBlacklist", "noInvalidThis", "noSwitchCaseFallThrough", "typeofCompare"]; -// Exclude typescript-only rules from jsRules, otherwise it's identical. -exports.jsRules = {}; -for (var key in exports.rules) { - if (!utils_1.hasOwnProperty(exports.rules, key)) { - continue; - } - var Rule = ruleLoader_1.findRule(key, path_1.join(__dirname, "..", "rules")); - if (Rule === undefined) { - throw new Error("Couldn't find rule '" + key + "'."); - } - if (!Rule.metadata.typescriptOnly) { - exports.jsRules[key] = exports.rules[key]; - } -} diff --git a/node_modules/tslint/lib/configs/latest.d.ts b/node_modules/tslint/lib/configs/latest.d.ts deleted file mode 100644 index af4a4e9bd..000000000 --- a/node_modules/tslint/lib/configs/latest.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export declare const rules: { - "align": { - options: string[]; - }; - "no-invalid-template-strings": boolean; - "no-sparse-arrays": boolean; - "no-object-literal-type-assertion": boolean; - "prefer-conditional-expression": boolean; - "prefer-object-spread": boolean; - "no-duplicate-variable": (string | boolean)[]; - "no-this-assignment": boolean; - "no-duplicate-imports": boolean; - "space-within-parens": (number | boolean)[]; - "no-submodule-imports": boolean; - "whitespace": { - options: string[]; - }; - "ban-comma-operator": boolean; - "jsdoc-format": { - options: string; - }; - "no-duplicate-switch-case": boolean; - "no-implicit-dependencies": boolean; - "no-return-await": boolean; -}; -declare const xtends = "tslint:recommended"; -export { xtends as extends }; diff --git a/node_modules/tslint/lib/configs/latest.js b/node_modules/tslint/lib/configs/latest.js deleted file mode 100644 index 681ad1c98..000000000 --- a/node_modules/tslint/lib/configs/latest.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -// tslint:disable object-literal-sort-keys -// tslint:disable:object-literal-key-quotes -exports.rules = { - // added in v5.1 - "align": { - options: [ - "parameters", - "statements", - "members", - ], - }, - "no-invalid-template-strings": true, - "no-sparse-arrays": true, - // added in v5.2 - "no-object-literal-type-assertion": true, - // added in v5.3 - "prefer-conditional-expression": true, - "prefer-object-spread": true, - // added in v5.4 - "no-duplicate-variable": [ - true, - "check-parameters", - ], - // added in v5.5 - "no-this-assignment": true, - // added in v5.6 - "no-duplicate-imports": true, - "space-within-parens": [true, 0], - "no-submodule-imports": true, - // added in v5.7 - "whitespace": { - options: [ - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type", - "check-typecast", - "check-type-operator", - "check-rest-spread", - ], - }, - // added in v5.8 - "ban-comma-operator": true, - "jsdoc-format": { - options: "check-multiline-start", - }, - "no-duplicate-switch-case": true, - "no-implicit-dependencies": true, - "no-return-await": true, -}; -// tslint:enable object-literal-sort-keys -// work around "extends" being a keyword -var xtends = "tslint:recommended"; -exports.extends = xtends; diff --git a/node_modules/tslint/lib/configs/recommended.d.ts b/node_modules/tslint/lib/configs/recommended.d.ts deleted file mode 100644 index ecbbf0a1b..000000000 --- a/node_modules/tslint/lib/configs/recommended.d.ts +++ /dev/null @@ -1,237 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export declare const rules: { - "adjacent-overload-signatures": boolean; - "align": { - options: string[]; - }; - "array-type": { - options: string[]; - }; - "arrow-parens": boolean; - "arrow-return-shorthand": boolean; - "ban-types": { - options: string[][]; - }; - "callable-types": boolean; - "class-name": boolean; - "comment-format": { - options: string[]; - }; - "curly": boolean; - "cyclomatic-complexity": boolean; - "eofline": boolean; - "forin": boolean; - "import-spacing": boolean; - "indent": { - options: string[]; - }; - "interface-name": { - options: string[]; - }; - "interface-over-type-literal": boolean; - "jsdoc-format": boolean; - "label-position": boolean; - "max-classes-per-file": { - options: number[]; - }; - "max-line-length": { - options: number[]; - }; - "member-access": boolean; - "member-ordering": { - options: { - order: string; - }; - }; - "new-parens": boolean; - "no-angle-bracket-type-assertion": boolean; - "no-any": boolean; - "no-arg": boolean; - "no-bitwise": boolean; - "no-conditional-assignment": boolean; - "no-consecutive-blank-lines": boolean; - "no-console": boolean; - "no-construct": boolean; - "no-debugger": boolean; - "no-duplicate-super": boolean; - "no-empty": boolean; - "no-empty-interface": boolean; - "no-eval": boolean; - "no-internal-module": boolean; - "no-invalid-this": boolean; - "no-misused-new": boolean; - "no-namespace": boolean; - "no-parameter-properties": boolean; - "no-reference": boolean; - "no-reference-import": boolean; - "no-shadowed-variable": boolean; - "no-string-literal": boolean; - "no-string-throw": boolean; - "no-switch-case-fall-through": boolean; - "no-trailing-whitespace": boolean; - "no-unnecessary-initializer": boolean; - "no-unsafe-finally": boolean; - "no-unused-expression": boolean; - "no-use-before-declare": boolean; - "no-var-keyword": boolean; - "no-var-requires": boolean; - "object-literal-key-quotes": { - options: string[]; - }; - "object-literal-shorthand": boolean; - "object-literal-sort-keys": boolean; - "one-line": { - options: string[]; - }; - "one-variable-per-declaration": { - options: string[]; - }; - "only-arrow-functions": { - options: string[]; - }; - "ordered-imports": { - options: { - "import-sources-order": string; - "module-source-path": string; - "named-imports-order": string; - }; - }; - "prefer-const": boolean; - "prefer-for-of": boolean; - "quotemark": { - options: string[]; - }; - "radix": boolean; - "semicolon": { - options: string[]; - }; - "space-before-function-paren": { - options: { - anonymous: string; - asyncArrow: string; - constructor: string; - method: string; - named: string; - }; - }; - "trailing-comma": { - options: { - multiline: string; - singleline: string; - }; - }; - "triple-equals": { - options: string[]; - }; - "typedef": boolean; - "typedef-whitespace": { - options: { - "call-signature": string; - "index-signature": string; - "parameter": string; - "property-declaration": string; - "variable-declaration": string; - }[]; - }; - "typeof-compare": boolean; - "unified-signatures": boolean; - "use-isnan": boolean; - "variable-name": { - options: string[]; - }; - "whitespace": { - options: string[]; - }; -}; -export declare const jsRules: { - "align": { - options: string[]; - }; - "class-name": boolean; - "curly": boolean; - "eofline": boolean; - "forin": boolean; - "import-spacing": boolean; - "indent": { - options: string[]; - }; - "jsdoc-format": boolean; - "label-position": boolean; - "max-line-length": { - options: number[]; - }; - "new-parens": boolean; - "no-arg": boolean; - "no-bitwise": boolean; - "no-conditional-assignment": boolean; - "no-consecutive-blank-lines": boolean; - "no-console": boolean; - "no-construct": boolean; - "no-debugger": boolean; - "no-duplicate-super": boolean; - "no-duplicate-variable": boolean; - "no-empty": boolean; - "no-eval": boolean; - "no-reference": boolean; - "no-shadowed-variable": boolean; - "no-string-literal": boolean; - "no-string-throw": boolean; - "no-switch-case-fall-through": boolean; - "no-trailing-whitespace": boolean; - "no-unused-expression": boolean; - "no-use-before-declare": boolean; - "object-literal-sort-keys": boolean; - "one-line": { - options: string[]; - }; - "one-variable-per-declaration": { - options: string[]; - }; - "quotemark": { - options: string[]; - }; - "radix": boolean; - "semicolon": { - options: string[]; - }; - "space-before-function-paren": { - options: { - anonymous: string; - asyncArrow: string; - constructor: string; - method: string; - named: string; - }; - }; - "trailing-comma": { - options: { - multiline: string; - singleline: string; - }; - }; - "triple-equals": { - options: string[]; - }; - "use-isnan": boolean; - "variable-name": { - options: string[]; - }; - "whitespace": { - options: string[]; - }; -}; diff --git a/node_modules/tslint/lib/configs/recommended.js b/node_modules/tslint/lib/configs/recommended.js deleted file mode 100644 index 853115ccc..000000000 --- a/node_modules/tslint/lib/configs/recommended.js +++ /dev/null @@ -1,306 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.rules = { - "adjacent-overload-signatures": true, - "align": { - options: [ - "parameters", - "statements", - ], - }, - "array-type": { - options: ["array-simple"], - }, - "arrow-parens": true, - "arrow-return-shorthand": true, - "ban-types": { - options: [ - ["Object", "Avoid using the `Object` type. Did you mean `object`?"], - ["Function", "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."], - ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"], - ["Number", "Avoid using the `Number` type. Did you mean `number`?"], - ["String", "Avoid using the `String` type. Did you mean `string`?"], - ["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"], - ], - }, - "callable-types": true, - "class-name": true, - "comment-format": { - options: ["check-space"], - }, - "curly": true, - "cyclomatic-complexity": false, - "eofline": true, - "forin": true, - "import-spacing": true, - "indent": { - options: ["spaces"], - }, - "interface-name": { - options: ["always-prefix"], - }, - "interface-over-type-literal": true, - "jsdoc-format": true, - "label-position": true, - "max-classes-per-file": { - options: [1], - }, - "max-line-length": { - options: [120], - }, - "member-access": true, - "member-ordering": { - options: { - order: "statics-first", - }, - }, - "new-parens": true, - "no-angle-bracket-type-assertion": true, - "no-any": false, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": true, - "no-console": true, - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-empty": true, - "no-empty-interface": true, - "no-eval": true, - "no-internal-module": true, - "no-invalid-this": false, - "no-misused-new": true, - "no-namespace": true, - "no-parameter-properties": false, - "no-reference": true, - "no-reference-import": true, - "no-shadowed-variable": true, - "no-string-literal": true, - "no-string-throw": true, - "no-switch-case-fall-through": false, - "no-trailing-whitespace": true, - "no-unnecessary-initializer": true, - "no-unsafe-finally": true, - "no-unused-expression": true, - // disable this rule as it is very heavy performance-wise and not that useful - "no-use-before-declare": false, - "no-var-keyword": true, - "no-var-requires": true, - "object-literal-key-quotes": { - options: ["consistent-as-needed"], - }, - "object-literal-shorthand": true, - "object-literal-sort-keys": true, - "one-line": { - options: [ - "check-catch", - "check-else", - "check-finally", - "check-open-brace", - "check-whitespace", - ], - }, - "one-variable-per-declaration": { - options: ["ignore-for-loop"], - }, - "only-arrow-functions": { - options: [ - "allow-declarations", - "allow-named-functions", - ], - }, - "ordered-imports": { - options: { - "import-sources-order": "case-insensitive", - "module-source-path": "full", - "named-imports-order": "case-insensitive", - }, - }, - "prefer-const": true, - "prefer-for-of": true, - "quotemark": { - options: [ - "double", - "avoid-escape", - ], - }, - "radix": true, - "semicolon": { - options: ["always"], - }, - "space-before-function-paren": { - options: { - anonymous: "never", - asyncArrow: "always", - constructor: "never", - method: "never", - named: "never", - }, - }, - "trailing-comma": { - options: { - multiline: "always", - singleline: "never", - }, - }, - "triple-equals": { - options: ["allow-null-check"], - }, - "typedef": false, - "typedef-whitespace": { - options: [ - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace", - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace", - }, - ], - }, - "typeof-compare": false, - "unified-signatures": true, - "use-isnan": true, - "variable-name": { - options: [ - "ban-keywords", - "check-format", - "allow-pascal-case", - ], - }, - "whitespace": { - options: [ - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type", - "check-typecast", - ], - }, -}; -exports.jsRules = { - "align": { - options: [ - "parameters", - "statements", - ], - }, - "class-name": true, - "curly": true, - "eofline": true, - "forin": true, - "import-spacing": true, - "indent": { - options: ["spaces"], - }, - "jsdoc-format": true, - "label-position": true, - "max-line-length": { - options: [120], - }, - "new-parens": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": true, - "no-console": true, - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-duplicate-variable": true, - "no-empty": true, - "no-eval": true, - "no-reference": true, - "no-shadowed-variable": true, - "no-string-literal": true, - "no-string-throw": true, - "no-switch-case-fall-through": false, - "no-trailing-whitespace": true, - "no-unused-expression": true, - // disable this rule as it is very heavy performance-wise and not that useful - "no-use-before-declare": false, - "object-literal-sort-keys": true, - "one-line": { - options: [ - "check-catch", - "check-else", - "check-finally", - "check-open-brace", - "check-whitespace", - ], - }, - "one-variable-per-declaration": { - options: ["ignore-for-loop"], - }, - "quotemark": { - options: [ - "double", - "avoid-escape", - ], - }, - "radix": true, - "semicolon": { - options: ["always"], - }, - "space-before-function-paren": { - options: { - anonymous: "never", - asyncArrow: "always", - constructor: "never", - method: "never", - named: "never", - }, - }, - "trailing-comma": { - options: { - multiline: "always", - singleline: "never", - }, - }, - "triple-equals": { - options: ["allow-null-check"], - }, - "use-isnan": true, - "variable-name": { - options: [ - "ban-keywords", - "check-format", - "allow-pascal-case", - ], - }, - "whitespace": { - options: [ - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type", - "check-typecast", - ], - }, -}; diff --git a/node_modules/tslint/lib/configuration.d.ts b/node_modules/tslint/lib/configuration.d.ts deleted file mode 100644 index ce2b61474..000000000 --- a/node_modules/tslint/lib/configuration.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { IOptions, RuleSeverity } from "./language/rule/rule"; -export interface IConfigurationFile { - /** - * @deprecated property is never set - * - * The severity that is applied to rules in this config file as well as rules - * in any inherited config files which have their severity set to "default". - * Not inherited. - */ - defaultSeverity?: RuleSeverity; - /** - * An array of config files whose rules are inherited by this config file. - */ - extends: string[]; - /** - * Rules that are used to lint to JavaScript files. - */ - jsRules: Map<string, Partial<IOptions>>; - /** - * A subset of the CLI options. - */ - linterOptions?: Partial<{ - exclude: string[]; - }>; - /** - * Directories containing custom rules. Resolved using node module semantics. - */ - rulesDirectory: string[]; - /** - * Rules that are used to lint TypeScript files. - */ - rules: Map<string, Partial<IOptions>>; -} -export interface IConfigurationLoadResult { - path?: string; - results?: IConfigurationFile; -} -export declare const JSON_CONFIG_FILENAME = "tslint.json"; -/** @deprecated use `JSON_CONFIG_FILENAME` or `CONFIG_FILENAMES` instead. */ -export declare const CONFIG_FILENAME = "tslint.json"; -export declare const CONFIG_FILENAMES: string[]; -export declare const DEFAULT_CONFIG: IConfigurationFile; -export declare const EMPTY_CONFIG: IConfigurationFile; -/** - * Searches for a TSLint configuration and returns the data from the config. - * @param configFile A path to a config file, this can be null if the location of a config is not known - * @param inputFilePath A path containing the current file being linted. This is the starting location - * of the search for a configuration. - * @returns Load status for a TSLint configuration object - */ -export declare function findConfiguration(configFile: string | null, inputFilePath: string): IConfigurationLoadResult; -export declare function findConfiguration(configFile: string, inputFilePath?: string): IConfigurationLoadResult; -/** - * Searches for a TSLint configuration and returns the path to it. - * Could return undefined if not configuration is found. - * @param suppliedConfigFilePath A path to an known config file supplied by a user. Pass null here if - * the location of the config file is not known and you want to search for one. - * @param inputFilePath A path to the current file being linted. This is the starting location - * of the search for a configuration. - * @returns An absolute path to a tslint.json or tslint.yml or tslint.yaml file - * or undefined if neither can be found. - */ -export declare function findConfigurationPath(suppliedConfigFilePath: string | null, inputFilePath: string): string | undefined; -export declare function findConfigurationPath(suppliedConfigFilePath: string, inputFilePath?: string): string | undefined; -/** - * Used Node semantics to load a configuration file given configFilePath. - * For example: - * '/path/to/config' will be treated as an absolute path - * './path/to/config' will be treated as a relative path - * 'path/to/config' will attempt to load a to/config file inside a node module named path - * @param configFilePath The configuration to load - * @param originalFilePath (deprecated) The entry point configuration file - * @returns a configuration object for TSLint loaded from the file at configFilePath - */ -export declare function loadConfigurationFromPath(configFilePath?: string, _originalFilePath?: string): IConfigurationFile; -/** Reads the configuration file from disk and parses it as raw JSON, YAML or JS depending on the extension. */ -export declare function readConfigurationFile(filepath: string): RawConfigFile; -export declare function extendConfigurationFile(targetConfig: IConfigurationFile, nextConfigSource: IConfigurationFile): IConfigurationFile; -/** - * returns the absolute path (contrary to what the name implies) - * - * @deprecated use `path.resolve` instead - */ -export declare function getRelativePath(directory?: string | null, relativeTo?: string): string | undefined; -export declare function useAsPath(directory: string): boolean; -/** - * @param directories A path(s) to a directory of custom rules - * @param relativeTo A path that directories provided are relative to. - * For example, if the directories come from a tslint.json file, this path - * should be the path to the tslint.json file. - * @return An array of absolute paths to directories potentially containing rules - */ -export declare function getRulesDirectories(directories?: string | string[], relativeTo?: string): string[]; -export interface RawConfigFile { - extends?: string | string[]; - linterOptions?: IConfigurationFile["linterOptions"]; - rulesDirectory?: string | string[]; - defaultSeverity?: string; - rules?: RawRulesConfig; - jsRules?: RawRulesConfig; -} -export interface RawRulesConfig { - [key: string]: RawRuleConfig; -} -export declare type RawRuleConfig = null | undefined | boolean | any[] | { - severity?: RuleSeverity | "warn" | "none" | "default"; - options?: any; -}; -/** - * Parses a config file and normalizes legacy config settings. - * If `configFileDir` and `readConfig` are provided, this function will load all base configs and reduce them to the final configuration. - * - * @param configFile The raw object read from the JSON of a config file - * @param configFileDir The directory of the config file - * @param readConfig Will be used to load all base configurations while parsing. The function is called with the resolved path. - */ -export declare function parseConfigFile(configFile: RawConfigFile, configFileDir?: string, readConfig?: (path: string) => RawConfigFile): IConfigurationFile; -/** - * Fills in default values for `IOption` properties and outputs an array of `IOption` - */ -export declare function convertRuleOptions(ruleConfiguration: Map<string, Partial<IOptions>>): IOptions[]; diff --git a/node_modules/tslint/lib/configuration.js b/node_modules/tslint/lib/configuration.js deleted file mode 100644 index 1150d68da..000000000 --- a/node_modules/tslint/lib/configuration.js +++ /dev/null @@ -1,471 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var fs = require("fs"); -var yaml = require("js-yaml"); -var os = require("os"); -var path = require("path"); -var resolve = require("resolve"); -var error_1 = require("./error"); -var utils_1 = require("./utils"); -// Note: eslint prefers yaml over json, while tslint prefers json over yaml -// for backward-compatibility. -exports.JSON_CONFIG_FILENAME = "tslint.json"; -/** @deprecated use `JSON_CONFIG_FILENAME` or `CONFIG_FILENAMES` instead. */ -exports.CONFIG_FILENAME = exports.JSON_CONFIG_FILENAME; -exports.CONFIG_FILENAMES = [exports.JSON_CONFIG_FILENAME, "tslint.yaml", "tslint.yml"]; -exports.DEFAULT_CONFIG = { - defaultSeverity: "error", - extends: ["tslint:recommended"], - jsRules: new Map(), - rules: new Map(), - rulesDirectory: [], -}; -exports.EMPTY_CONFIG = { - defaultSeverity: "error", - extends: [], - jsRules: new Map(), - rules: new Map(), - rulesDirectory: [], -}; -var BUILT_IN_CONFIG = /^tslint:(.*)$/; -function findConfiguration(configFile, inputFilePath) { - var configPath = findConfigurationPath(configFile, inputFilePath); - var loadResult = { path: configPath }; - try { - loadResult.results = loadConfigurationFromPath(configPath); - return loadResult; - } - catch (error) { - throw new error_1.FatalError("Failed to load " + configPath + ": " + error.message, error); - } -} -exports.findConfiguration = findConfiguration; -function findConfigurationPath(suppliedConfigFilePath, inputFilePath) { - if (suppliedConfigFilePath != undefined) { - if (!fs.existsSync(suppliedConfigFilePath)) { - throw new error_1.FatalError("Could not find config file at: " + path.resolve(suppliedConfigFilePath)); - } - else { - return path.resolve(suppliedConfigFilePath); - } - } - else { - // convert to dir if it's a file or doesn't exist - var useDirName = false; - try { - var stats = fs.statSync(inputFilePath); - if (stats.isFile()) { - useDirName = true; - } - } - catch (e) { - // throws if file doesn't exist - useDirName = true; - } - if (useDirName) { - inputFilePath = path.dirname(inputFilePath); - } - // search for tslint.json from input file location - var configFilePath = findup(exports.CONFIG_FILENAMES, path.resolve(inputFilePath)); - if (configFilePath !== undefined) { - return configFilePath; - } - // search for tslint.json in home directory - var homeDir = os.homedir(); - for (var _i = 0, CONFIG_FILENAMES_1 = exports.CONFIG_FILENAMES; _i < CONFIG_FILENAMES_1.length; _i++) { - var configFilename = CONFIG_FILENAMES_1[_i]; - configFilePath = path.join(homeDir, configFilename); - if (fs.existsSync(configFilePath)) { - return path.resolve(configFilePath); - } - } - // no path could be found - return undefined; - } -} -exports.findConfigurationPath = findConfigurationPath; -/** - * Find a file by names in a directory or any ancestor directory. - * Will try each filename in filenames before recursing to a parent directory. - * This is case-insensitive, so it can find 'TsLiNt.JsOn' when searching for 'tslint.json'. - */ -function findup(filenames, directory) { - while (true) { - var res = findFile(directory); - if (res !== undefined) { - return path.join(directory, res); - } - var parent = path.dirname(directory); - if (parent === directory) { - return undefined; - } - directory = parent; - } - function findFile(cwd) { - var dirFiles = fs.readdirSync(cwd); - var _loop_1 = function (filename) { - var index = dirFiles.indexOf(filename); - if (index > -1) { - return { value: filename }; - } - // TODO: remove in v6.0.0 - // Try reading in the entire directory and looking for a file with different casing. - var result = dirFiles.find(function (entry) { return entry.toLowerCase() === filename; }); - if (result !== undefined) { - error_1.showWarningOnce("Using mixed case " + filename + " is deprecated. Found: " + path.join(cwd, result)); - return { value: result }; - } - }; - for (var _i = 0, filenames_1 = filenames; _i < filenames_1.length; _i++) { - var filename = filenames_1[_i]; - var state_1 = _loop_1(filename); - if (typeof state_1 === "object") - return state_1.value; - } - return undefined; - } -} -/** - * Used Node semantics to load a configuration file given configFilePath. - * For example: - * '/path/to/config' will be treated as an absolute path - * './path/to/config' will be treated as a relative path - * 'path/to/config' will attempt to load a to/config file inside a node module named path - * @param configFilePath The configuration to load - * @param originalFilePath (deprecated) The entry point configuration file - * @returns a configuration object for TSLint loaded from the file at configFilePath - */ -function loadConfigurationFromPath(configFilePath, _originalFilePath) { - if (configFilePath == undefined) { - return exports.DEFAULT_CONFIG; - } - else { - var resolvedConfigFilePath = resolveConfigurationPath(configFilePath); - var rawConfigFile = readConfigurationFile(resolvedConfigFilePath); - return parseConfigFile(rawConfigFile, path.dirname(resolvedConfigFilePath), readConfigurationFile); - } -} -exports.loadConfigurationFromPath = loadConfigurationFromPath; -/** Reads the configuration file from disk and parses it as raw JSON, YAML or JS depending on the extension. */ -function readConfigurationFile(filepath) { - var resolvedConfigFileExt = path.extname(filepath); - if (/\.(json|ya?ml)/.test(resolvedConfigFileExt)) { - var fileContent = fs.readFileSync(filepath, "utf8").replace(/^\uFEFF/, ""); - try { - if (resolvedConfigFileExt === ".json") { - return JSON.parse(utils_1.stripComments(fileContent)); - } - else { - return yaml.safeLoad(fileContent, { - // Note: yaml.LoadOptions expects a schema value of type "any", - // but this trips up the no-unsafe-any rule. - // tslint:disable-next-line:no-unsafe-any - schema: yaml.JSON_SCHEMA, - strict: true, - }); - } - } - catch (e) { - var error = e; - // include the configuration file being parsed in the error since it may differ from the directly referenced config - throw new Error(error.message + " in " + filepath); - } - } - else { - var rawConfigFile = require(filepath); - // tslint:disable-next-line no-dynamic-delete - delete require.cache[filepath]; - return rawConfigFile; - } -} -exports.readConfigurationFile = readConfigurationFile; -/** - * Resolve configuration file path or node_module reference - * @param filePath Relative ("./path"), absolute ("/path"), node module ("path"), or built-in ("tslint:path") - */ -function resolveConfigurationPath(filePath, relativeTo) { - var matches = filePath.match(BUILT_IN_CONFIG); - var isBuiltInConfig = matches !== null && matches.length > 0; - if (isBuiltInConfig) { - var configName = matches[1]; - try { - return require.resolve("./configs/" + configName); - } - catch (err) { - throw new Error(filePath + " is not a built-in config, try \"tslint:recommended\" instead."); - } - } - var basedir = relativeTo !== undefined ? relativeTo : process.cwd(); - try { - return resolve.sync(filePath, { basedir: basedir }); - } - catch (err) { - try { - return require.resolve(filePath); - } - catch (err) { - throw new Error("Invalid \"extends\" configuration value - could not require \"" + filePath + "\". " + - "Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) " + - "for the approximate method TSLint uses to find the referenced configuration file."); - } - } -} -function extendConfigurationFile(targetConfig, nextConfigSource) { - function combineProperties(targetProperty, nextProperty) { - var combinedProperty = {}; - add(targetProperty); - // next config source overwrites the target config object - add(nextProperty); - return combinedProperty; - function add(property) { - if (property !== undefined) { - for (var name in property) { - if (utils_1.hasOwnProperty(property, name)) { - combinedProperty[name] = property[name]; - } - } - } - } - } - function combineMaps(target, next) { - var combined = new Map(); - target.forEach(function (options, ruleName) { - combined.set(ruleName, options); - }); - next.forEach(function (options, ruleName) { - var combinedRule = combined.get(ruleName); - if (combinedRule !== undefined) { - combined.set(ruleName, combineProperties(combinedRule, options)); - } - else { - combined.set(ruleName, options); - } - }); - return combined; - } - var combinedRulesDirs = targetConfig.rulesDirectory.concat(nextConfigSource.rulesDirectory); - var dedupedRulesDirs = Array.from(new Set(combinedRulesDirs)); - return { - extends: [], - jsRules: combineMaps(targetConfig.jsRules, nextConfigSource.jsRules), - linterOptions: combineProperties(targetConfig.linterOptions, nextConfigSource.linterOptions), - rules: combineMaps(targetConfig.rules, nextConfigSource.rules), - rulesDirectory: dedupedRulesDirs, - }; -} -exports.extendConfigurationFile = extendConfigurationFile; -/** - * returns the absolute path (contrary to what the name implies) - * - * @deprecated use `path.resolve` instead - */ -function getRelativePath(directory, relativeTo) { - if (directory != undefined) { - var basePath = relativeTo !== undefined ? relativeTo : process.cwd(); - return path.resolve(basePath, directory); - } - return undefined; -} -exports.getRelativePath = getRelativePath; -// check if directory should be used as path or if it should be resolved like a module -// matches if directory starts with '/', './', '../', 'node_modules/' or equals '.' or '..' -function useAsPath(directory) { - return /^(?:\.?\.?(?:\/|$)|node_modules\/)/.test(directory); -} -exports.useAsPath = useAsPath; -/** - * @param directories A path(s) to a directory of custom rules - * @param relativeTo A path that directories provided are relative to. - * For example, if the directories come from a tslint.json file, this path - * should be the path to the tslint.json file. - * @return An array of absolute paths to directories potentially containing rules - */ -function getRulesDirectories(directories, relativeTo) { - return utils_1.arrayify(directories) - .map(function (dir) { - if (!useAsPath(dir)) { - try { - return path.dirname(resolve.sync(dir, { basedir: relativeTo })); - } - catch (err) { - // swallow error and fallback to using directory as path - } - } - var absolutePath = relativeTo === undefined ? path.resolve(dir) : path.resolve(relativeTo, dir); - if (absolutePath !== undefined) { - if (!fs.existsSync(absolutePath)) { - throw new error_1.FatalError("Could not find custom rule directory: " + dir); - } - } - return absolutePath; - }); -} -exports.getRulesDirectories = getRulesDirectories; -/** - * Parses the options of a single rule and upgrades legacy settings such as `true`, `[true, "option"]` - * - * @param ruleConfigValue The raw option setting of a rule - */ -function parseRuleOptions(ruleConfigValue, rawDefaultRuleSeverity) { - var ruleArguments; - var defaultRuleSeverity = "error"; - if (rawDefaultRuleSeverity !== undefined) { - switch (rawDefaultRuleSeverity.toLowerCase()) { - case "warn": - case "warning": - defaultRuleSeverity = "warning"; - break; - case "off": - case "none": - defaultRuleSeverity = "off"; - break; - default: - defaultRuleSeverity = "error"; - } - } - var ruleSeverity = defaultRuleSeverity; - if (ruleConfigValue == undefined) { - ruleArguments = []; - ruleSeverity = "off"; - } - else if (Array.isArray(ruleConfigValue)) { - if (ruleConfigValue.length > 0) { - // old style: array - ruleArguments = ruleConfigValue.slice(1); - ruleSeverity = ruleConfigValue[0] === true ? defaultRuleSeverity : "off"; - } - } - else if (typeof ruleConfigValue === "boolean") { - // old style: boolean - ruleArguments = []; - ruleSeverity = ruleConfigValue ? defaultRuleSeverity : "off"; - } - else if (typeof ruleConfigValue === "object") { - if (ruleConfigValue.severity !== undefined) { - switch (ruleConfigValue.severity.toLowerCase()) { - case "default": - ruleSeverity = defaultRuleSeverity; - break; - case "error": - ruleSeverity = "error"; - break; - case "warn": - case "warning": - ruleSeverity = "warning"; - break; - case "off": - case "none": - ruleSeverity = "off"; - break; - default: - console.warn("Invalid severity level: " + ruleConfigValue.severity); - ruleSeverity = defaultRuleSeverity; - } - } - if (ruleConfigValue.options != undefined) { - ruleArguments = utils_1.arrayify(ruleConfigValue.options); - } - } - return { - ruleArguments: ruleArguments, - ruleSeverity: ruleSeverity, - }; -} -/** - * Parses a config file and normalizes legacy config settings. - * If `configFileDir` and `readConfig` are provided, this function will load all base configs and reduce them to the final configuration. - * - * @param configFile The raw object read from the JSON of a config file - * @param configFileDir The directory of the config file - * @param readConfig Will be used to load all base configurations while parsing. The function is called with the resolved path. - */ -function parseConfigFile(configFile, configFileDir, readConfig) { - var defaultSeverity = configFile.defaultSeverity; - if (readConfig === undefined || configFileDir === undefined) { - return parse(configFile, configFileDir); - } - return loadExtendsRecursive(configFile, configFileDir) - .map(function (_a) { - var dir = _a.dir, config = _a.config; - return parse(config, dir); - }) - .reduce(extendConfigurationFile, exports.EMPTY_CONFIG); - /** Read files in order, depth first, and assign `defaultSeverity` (last config in extends wins). */ - function loadExtendsRecursive(raw, dir) { - var configs = []; - for (var _i = 0, _a = utils_1.arrayify(raw.extends); _i < _a.length; _i++) { - var relativePath = _a[_i]; - var resolvedPath = resolveConfigurationPath(relativePath, dir); - var extendedRaw = readConfig(resolvedPath); - configs.push.apply(configs, loadExtendsRecursive(extendedRaw, path.dirname(resolvedPath))); - } - if (raw.defaultSeverity !== undefined) { - defaultSeverity = raw.defaultSeverity; - } - configs.push({ dir: dir, config: raw }); - return configs; - } - function parse(config, dir) { - return { - extends: utils_1.arrayify(config.extends), - jsRules: parseRules(config.jsRules), - linterOptions: parseLinterOptions(config.linterOptions, dir), - rules: parseRules(config.rules), - rulesDirectory: getRulesDirectories(config.rulesDirectory, dir), - }; - } - function parseRules(config) { - var map = new Map(); - if (config !== undefined) { - for (var ruleName in config) { - if (utils_1.hasOwnProperty(config, ruleName)) { - map.set(ruleName, parseRuleOptions(config[ruleName], defaultSeverity)); - } - } - } - return map; - } - function parseLinterOptions(raw, dir) { - if (raw === undefined || raw.exclude === undefined) { - return {}; - } - return { - exclude: utils_1.arrayify(raw.exclude).map(function (pattern) { return dir === undefined ? path.resolve(pattern) : path.resolve(dir, pattern); }), - }; - } -} -exports.parseConfigFile = parseConfigFile; -/** - * Fills in default values for `IOption` properties and outputs an array of `IOption` - */ -function convertRuleOptions(ruleConfiguration) { - var output = []; - ruleConfiguration.forEach(function (_a, ruleName) { - var ruleArguments = _a.ruleArguments, ruleSeverity = _a.ruleSeverity; - var options = { - disabledIntervals: [], - ruleArguments: ruleArguments != undefined ? ruleArguments : [], - ruleName: ruleName, - ruleSeverity: ruleSeverity != undefined ? ruleSeverity : "error", - }; - output.push(options); - }); - return output; -} -exports.convertRuleOptions = convertRuleOptions; diff --git a/node_modules/tslint/lib/enableDisableRules.d.ts b/node_modules/tslint/lib/enableDisableRules.d.ts deleted file mode 100644 index 6a02db83c..000000000 --- a/node_modules/tslint/lib/enableDisableRules.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { RuleFailure } from "./language/rule/rule"; -/** - * regex is: start of string followed by any amount of whitespace - * followed by tslint and colon - * followed by either "enable" or "disable" - * followed optionally by -line or -next-line - * followed by either colon, whitespace or end of string - */ -export declare const ENABLE_DISABLE_REGEX: RegExp; -export declare function removeDisabledFailures(sourceFile: ts.SourceFile, failures: RuleFailure[]): RuleFailure[]; diff --git a/node_modules/tslint/lib/enableDisableRules.js b/node_modules/tslint/lib/enableDisableRules.js deleted file mode 100644 index 1b8d32715..000000000 --- a/node_modules/tslint/lib/enableDisableRules.js +++ /dev/null @@ -1,151 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -// tslint:disable object-literal-sort-keys -var utils = require("tsutils"); -var ts = require("typescript"); -/** - * regex is: start of string followed by any amount of whitespace - * followed by tslint and colon - * followed by either "enable" or "disable" - * followed optionally by -line or -next-line - * followed by either colon, whitespace or end of string - */ -exports.ENABLE_DISABLE_REGEX = /^\s*tslint:(enable|disable)(?:-(line|next-line))?(:|\s|$)/; -function removeDisabledFailures(sourceFile, failures) { - if (failures.length === 0) { - // Usually there won't be failures anyway, so no need to look for "tslint:disable". - return failures; - } - var failingRules = new Set(failures.map(function (f) { return f.getRuleName(); })); - var map = getDisableMap(sourceFile, failingRules); - return failures.filter(function (failure) { - var disabledIntervals = map.get(failure.getRuleName()); - return disabledIntervals === undefined || !disabledIntervals.some(function (_a) { - var pos = _a.pos, end = _a.end; - var failPos = failure.getStartPosition().getPosition(); - var failEnd = failure.getEndPosition().getPosition(); - return failEnd >= pos && (end === -1 || failPos < end); - }); - }); -} -exports.removeDisabledFailures = removeDisabledFailures; -/** - * The map will have an array of TextRange for each disable of a rule in a file. - * (It will have no entry if the rule is never disabled, meaning all arrays are non-empty.) - */ -function getDisableMap(sourceFile, failingRules) { - var map = new Map(); - utils.forEachComment(sourceFile, function (fullText, comment) { - var commentText = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia - ? fullText.substring(comment.pos + 2, comment.end) - : fullText.substring(comment.pos + 2, comment.end - 2); - var parsed = parseComment(commentText); - if (parsed !== undefined) { - var rulesList = parsed.rulesList, isEnabled = parsed.isEnabled, modifier = parsed.modifier; - var switchRange = getSwitchRange(modifier, comment, sourceFile); - if (switchRange !== undefined) { - var rulesToSwitch = rulesList === "all" ? Array.from(failingRules) : rulesList.filter(function (r) { return failingRules.has(r); }); - for (var _i = 0, rulesToSwitch_1 = rulesToSwitch; _i < rulesToSwitch_1.length; _i++) { - var ruleToSwitch = rulesToSwitch_1[_i]; - switchRuleState(ruleToSwitch, isEnabled, switchRange.pos, switchRange.end); - } - } - } - }); - return map; - function switchRuleState(ruleName, isEnable, start, end) { - var disableRanges = map.get(ruleName); - if (isEnable) { - if (disableRanges !== undefined) { - var lastDisable = disableRanges[disableRanges.length - 1]; - if (lastDisable.end === -1) { - lastDisable.end = start; - if (end !== -1) { - // Disable it again after the enable range is over. - disableRanges.push({ pos: end, end: -1 }); - } - } - } - } - else { // disable - if (disableRanges === undefined) { - map.set(ruleName, [{ pos: start, end: end }]); - } - else if (disableRanges[disableRanges.length - 1].end !== -1) { - disableRanges.push({ pos: start, end: end }); - } - } - } -} -/** End will be -1 to indicate no end. */ -function getSwitchRange(modifier, range, sourceFile) { - var lineStarts = sourceFile.getLineStarts(); - switch (modifier) { - case "line": - return { - // start at the beginning of the line where comment starts - pos: getStartOfLinePosition(range.pos), - // end at the beginning of the line following the comment - end: getStartOfLinePosition(range.end, 1), - }; - case "next-line": - // start at the beginning of the line following the comment - var pos = getStartOfLinePosition(range.end, 1); - if (pos === -1) { - // no need to switch anything, there is no next line - return undefined; - } - // end at the beginning of the line following the next line - return { pos: pos, end: getStartOfLinePosition(range.end, 2) }; - default: - // switch rule for the rest of the file - // start at the current position, but skip end position - return { pos: range.pos, end: -1 }; - } - /** Returns -1 for last line. */ - function getStartOfLinePosition(position, lineOffset) { - if (lineOffset === void 0) { lineOffset = 0; } - var line = ts.getLineAndCharacterOfPosition(sourceFile, position).line + lineOffset; - return line >= lineStarts.length ? -1 : lineStarts[line]; - } -} -function parseComment(commentText) { - var match = exports.ENABLE_DISABLE_REGEX.exec(commentText); - if (match === null) { - return undefined; - } - // remove everything matched by the previous regex to get only the specified rules - // split at whitespaces - // filter empty items coming from whitespaces at start, at end or empty list - var rulesList = splitOnSpaces(commentText.substr(match[0].length)); - if (rulesList.length === 0 && match[3] === ":") { - // nothing to do here: an explicit separator was specified but no rules to switch - return undefined; - } - if (rulesList.length === 0 || - rulesList.indexOf("all") !== -1) { - // if list is empty we default to all enabled rules - // if `all` is specified we ignore the other rules and take all enabled rules - rulesList = "all"; - } - return { rulesList: rulesList, isEnabled: match[1] === "enable", modifier: match[2] }; -} -function splitOnSpaces(str) { - return str.split(/\s+/).filter(function (s) { return s !== ""; }); -} diff --git a/node_modules/tslint/lib/error.d.ts b/node_modules/tslint/lib/error.d.ts deleted file mode 100644 index f7c3e798e..000000000 --- a/node_modules/tslint/lib/error.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Generic error typing for EcmaScript errors - * Define `Error` here to avoid using `Error` from @types/node. - * Using the `node` version causes a compilation error when this code is used as an npm library if @types/node is not already imported. - */ -export declare class Error { - name?: string; - message: string; - stack?: string; - constructor(message?: string); -} -/** - * Used to exit the program and display a friendly message without the callstack. - */ -export declare class FatalError extends Error { - message: string; - innerError?: Error | undefined; - static NAME: string; - constructor(message: string, innerError?: Error | undefined); -} -export declare function isError(possibleError: any): possibleError is Error; -export declare function showWarningOnce(message: string): void; -export declare function showRuleCrashWarning(message: string, ruleName: string, fileName: string): void; diff --git a/node_modules/tslint/lib/error.js b/node_modules/tslint/lib/error.js deleted file mode 100644 index c69c35eb0..000000000 --- a/node_modules/tslint/lib/error.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var shownWarnings = new Set(); -/** - * Used to exit the program and display a friendly message without the callstack. - */ -var FatalError = /** @class */ (function (_super) { - tslib_1.__extends(FatalError, _super); - function FatalError(message, innerError) { - var _this = _super.call(this, message) || this; - _this.message = message; - _this.innerError = innerError; - _this.name = FatalError.NAME; - // Fix prototype chain for target ES5 - Object.setPrototypeOf(_this, FatalError.prototype); - return _this; - } - FatalError.NAME = "FatalError"; - return FatalError; -}(Error)); -exports.FatalError = FatalError; -function isError(possibleError) { - return possibleError != undefined && possibleError.message !== undefined; -} -exports.isError = isError; -function showWarningOnce(message) { - if (!shownWarnings.has(message)) { - console.warn(message); - shownWarnings.add(message); - } -} -exports.showWarningOnce = showWarningOnce; -function showRuleCrashWarning(message, ruleName, fileName) { - console.warn("The '" + ruleName + "' rule threw an error in '" + fileName + "':\n" + message); -} -exports.showRuleCrashWarning = showRuleCrashWarning; diff --git a/node_modules/tslint/lib/formatterLoader.d.ts b/node_modules/tslint/lib/formatterLoader.d.ts deleted file mode 100644 index ccda37331..000000000 --- a/node_modules/tslint/lib/formatterLoader.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { FormatterConstructor } from "./index"; -export declare function findFormatter(name: string | FormatterConstructor, formattersDirectory?: string): FormatterConstructor | undefined; diff --git a/node_modules/tslint/lib/formatterLoader.js b/node_modules/tslint/lib/formatterLoader.js deleted file mode 100644 index fa5c9c6f5..000000000 --- a/node_modules/tslint/lib/formatterLoader.js +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var fs = require("fs"); -var path = require("path"); -var resolve = require("resolve"); -var utils_1 = require("./utils"); -var CORE_FORMATTERS_DIRECTORY = path.resolve(__dirname, "formatters"); -function findFormatter(name, formattersDirectory) { - if (typeof name === "function") { - return name; - } - else if (typeof name === "string") { - name = name.trim(); - var camelizedName = utils_1.camelize(name + "Formatter"); - // first check for core formatters - var Formatter = loadFormatter(CORE_FORMATTERS_DIRECTORY, camelizedName, true); - if (Formatter !== undefined) { - return Formatter; - } - // then check for rules within the first level of rulesDirectory - if (formattersDirectory !== undefined) { - Formatter = loadFormatter(formattersDirectory, camelizedName); - if (Formatter !== undefined) { - return Formatter; - } - } - // else try to resolve as module - return loadFormatterModule(name); - } - else { - // If an something else is passed as a name (e.g. object) - throw new Error("Name of type " + typeof name + " is not supported."); - } -} -exports.findFormatter = findFormatter; -function loadFormatter(directory, name, isCore) { - var formatterPath = path.resolve(path.join(directory, name)); - var fullPath; - if (isCore) { - fullPath = formatterPath + ".js"; - if (!fs.existsSync(fullPath)) { - return undefined; - } - } - else { - // Resolve using node's path resolution to allow developers to write custom formatters in TypeScript which can be loaded by TS-Node - try { - fullPath = require.resolve(formatterPath); - } - catch (_a) { - return undefined; - } - } - return require(fullPath).Formatter; -} -function loadFormatterModule(name) { - var src; - try { - // first try to find a module in the dependencies of the currently linted project - src = resolve.sync(name, { basedir: process.cwd() }); - } - catch (_a) { - try { - // if there is no local module, try relative to the installation of TSLint (might be global) - src = require.resolve(name); - } - catch (_b) { - return undefined; - } - } - return require(src).Formatter; -} diff --git a/node_modules/tslint/lib/formatters.d.ts b/node_modules/tslint/lib/formatters.d.ts deleted file mode 100644 index 869625a5a..000000000 --- a/node_modules/tslint/lib/formatters.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export * from "./language/formatter/abstractFormatter"; -export * from "./formatters/index"; diff --git a/node_modules/tslint/lib/formatters.js b/node_modules/tslint/lib/formatters.js deleted file mode 100644 index 0a0105016..000000000 --- a/node_modules/tslint/lib/formatters.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./language/formatter/abstractFormatter"), exports); -tslib_1.__exportStar(require("./formatters/index"), exports); diff --git a/node_modules/tslint/lib/formatters/checkstyleFormatter.d.ts b/node_modules/tslint/lib/formatters/checkstyleFormatter.d.ts deleted file mode 100644 index c47404485..000000000 --- a/node_modules/tslint/lib/formatters/checkstyleFormatter.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; - private escapeXml; -} diff --git a/node_modules/tslint/lib/formatters/checkstyleFormatter.js b/node_modules/tslint/lib/formatters/checkstyleFormatter.js deleted file mode 100644 index ae9c0eb84..000000000 --- a/node_modules/tslint/lib/formatters/checkstyleFormatter.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var output = '<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3">'; - if (failures.length !== 0) { - var failuresSorted = failures.sort(function (a, b) { return a.getFileName().localeCompare(b.getFileName()); }); - var previousFilename = null; - for (var _i = 0, failuresSorted_1 = failuresSorted; _i < failuresSorted_1.length; _i++) { - var failure = failuresSorted_1[_i]; - var severity = failure.getRuleSeverity(); - if (failure.getFileName() !== previousFilename) { - if (previousFilename !== null) { - output += "</file>"; - } - previousFilename = failure.getFileName(); - output += "<file name=\"" + this.escapeXml(failure.getFileName()) + "\">"; - } - output += "<error line=\"" + (failure.getStartPosition().getLineAndCharacter().line + 1) + "\" "; - output += "column=\"" + (failure.getStartPosition().getLineAndCharacter().character + 1) + "\" "; - output += "severity=\"" + severity + "\" "; - output += "message=\"" + this.escapeXml(failure.getFailure()) + "\" "; - // checkstyle parser wants "source" to have structure like <anything>dot<category>dot<type> - output += "source=\"failure.tslint." + this.escapeXml(failure.getRuleName()) + "\" />"; - } - if (previousFilename !== null) { - output += "</file>"; - } - } - output += "</checkstyle>"; - return output; - }; - Formatter.prototype.escapeXml = function (str) { - return str - .replace(/&/g, "&") - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/'/g, "'") - .replace(/"/g, """); - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "checkstyle", - description: "Formats errors as through they were Checkstyle output.", - descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Imitates the XMLLogger from Checkstyle 4.3. All failures have the 'warning' severity."], ["\n Imitates the XMLLogger from Checkstyle 4.3. All failures have the 'warning' severity."]))), - sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <checkstyle version=\"4.3\">\n <file name=\"myFile.ts\">\n <error line=\"1\" column=\"14\" severity=\"warning\" message=\"Missing semicolon\" source=\"failure.tslint.semicolon\" />\n </file>\n </checkstyle>"], ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <checkstyle version=\"4.3\">\n <file name=\"myFile.ts\">\n <error line=\"1\" column=\"14\" severity=\"warning\" message=\"Missing semicolon\" source=\"failure.tslint.semicolon\" />\n </file>\n </checkstyle>"]))), - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/formatters/codeFrameFormatter.d.ts b/node_modules/tslint/lib/formatters/codeFrameFormatter.d.ts deleted file mode 100644 index af3160a3f..000000000 --- a/node_modules/tslint/lib/formatters/codeFrameFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/codeFrameFormatter.js b/node_modules/tslint/lib/formatters/codeFrameFormatter.js deleted file mode 100644 index 906bdcde4..000000000 --- a/node_modules/tslint/lib/formatters/codeFrameFormatter.js +++ /dev/null @@ -1,80 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var codeFrame = require("babel-code-frame"); -var chalk_1 = require("chalk"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - if (typeof failures[0] === "undefined") { - return "\n"; - } - failures = this.sortFailures(failures); - var outputLines = []; - var currentFile; - for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) { - var failure = failures_1[_i]; - var fileName = failure.getFileName(); - // Output the name of each file once - if (currentFile !== fileName) { - outputLines.push(""); - outputLines.push(fileName); - currentFile = fileName; - } - var failureString = failure.getFailure(); - failureString = failure.getRuleSeverity() === "warning" ? chalk_1.default.yellow(failureString) : chalk_1.default.red(failureString); - // Rule - var ruleName = failure.getRuleName(); - ruleName = chalk_1.default.gray("(" + ruleName + ")"); - // Frame - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var frame = codeFrame(failure.getRawLines(), lineAndCharacter.line + 1, // babel-code-frame is 1 index - lineAndCharacter.character, { - forceColor: chalk_1.default.enabled, - highlightCode: true, - }); - // Ouput - outputLines.push(failureString + " " + ruleName); - outputLines.push(frame); - outputLines.push(""); - } - // Removes initial blank line - if (outputLines[0] === "") { - outputLines.shift(); - } - return outputLines.join("\n") + "\n"; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "codeFrame", - description: "Framed formatter which creates a frame of error code.", - descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Prints syntax highlighted code in a frame with a pointer to where\n exactly lint error is happening."], ["\n Prints syntax highlighted code in a frame with a pointer to where\n exactly lint error is happening."]))), - sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n src/components/Payment.tsx\n Parentheses are required around the parameters of an arrow function definition (arrow-parens)\n 21 | public componentDidMount() {\n 22 | this.input.focus();\n > 23 | loadStripe().then(Stripe => Stripe.pay());\n | ^\n 24 | }\n 25 |\n 26 | public render() {"], ["\n src/components/Payment.tsx\n Parentheses are required around the parameters of an arrow function definition (arrow-parens)\n 21 | public componentDidMount() {\n 22 | this.input.focus();\n > 23 | loadStripe().then(Stripe => Stripe.pay());\n | ^\n 24 | }\n 25 |\n 26 | public render() {"]))), - consumer: "human", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/formatters/fileslistFormatter.d.ts b/node_modules/tslint/lib/formatters/fileslistFormatter.d.ts deleted file mode 100644 index af3160a3f..000000000 --- a/node_modules/tslint/lib/formatters/fileslistFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/fileslistFormatter.js b/node_modules/tslint/lib/formatters/fileslistFormatter.js deleted file mode 100644 index 273edfdb0..000000000 --- a/node_modules/tslint/lib/formatters/fileslistFormatter.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - if (failures.length === 0) { - return ""; - } - var files = []; - var currentFile; - for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) { - var failure = failures_1[_i]; - var fileName = failure.getFileName(); - if (fileName !== currentFile) { - files.push(fileName); - currentFile = fileName; - } - } - return files.join("\n") + "\n"; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "filesList", - description: "Lists files containing lint errors.", - sample: "directory/myFile.ts", - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; diff --git a/node_modules/tslint/lib/formatters/index.d.ts b/node_modules/tslint/lib/formatters/index.d.ts deleted file mode 100644 index ea60b24d6..000000000 --- a/node_modules/tslint/lib/formatters/index.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export { Formatter as JsonFormatter } from "./jsonFormatter"; -export { Formatter as PmdFormatter } from "./pmdFormatter"; -export { Formatter as ProseFormatter } from "./proseFormatter"; -export { Formatter as VerboseFormatter } from "./verboseFormatter"; -export { Formatter as StylishFormatter } from "./stylishFormatter"; -export { Formatter as FileslistFormatter } from "./fileslistFormatter"; -export { Formatter as CodeFrameFormatter } from "./codeFrameFormatter"; -export { Formatter as TapFormatter } from "./tapFormatter"; -export { Formatter as JUnitFormatter } from "./junitFormatter"; diff --git a/node_modules/tslint/lib/formatters/index.js b/node_modules/tslint/lib/formatters/index.js deleted file mode 100644 index fd46be3ad..000000000 --- a/node_modules/tslint/lib/formatters/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var jsonFormatter_1 = require("./jsonFormatter"); -exports.JsonFormatter = jsonFormatter_1.Formatter; -var pmdFormatter_1 = require("./pmdFormatter"); -exports.PmdFormatter = pmdFormatter_1.Formatter; -var proseFormatter_1 = require("./proseFormatter"); -exports.ProseFormatter = proseFormatter_1.Formatter; -var verboseFormatter_1 = require("./verboseFormatter"); -exports.VerboseFormatter = verboseFormatter_1.Formatter; -var stylishFormatter_1 = require("./stylishFormatter"); -exports.StylishFormatter = stylishFormatter_1.Formatter; -var fileslistFormatter_1 = require("./fileslistFormatter"); -exports.FileslistFormatter = fileslistFormatter_1.Formatter; -var codeFrameFormatter_1 = require("./codeFrameFormatter"); -exports.CodeFrameFormatter = codeFrameFormatter_1.Formatter; -var tapFormatter_1 = require("./tapFormatter"); -exports.TapFormatter = tapFormatter_1.Formatter; -var junitFormatter_1 = require("./junitFormatter"); -exports.JUnitFormatter = junitFormatter_1.Formatter; diff --git a/node_modules/tslint/lib/formatters/jsonFormatter.d.ts b/node_modules/tslint/lib/formatters/jsonFormatter.d.ts deleted file mode 100644 index af3160a3f..000000000 --- a/node_modules/tslint/lib/formatters/jsonFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/jsonFormatter.js b/node_modules/tslint/lib/formatters/jsonFormatter.js deleted file mode 100644 index 8959636fa..000000000 --- a/node_modules/tslint/lib/formatters/jsonFormatter.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var failuresJSON = failures.map(function (failure) { return failure.toJson(); }); - return JSON.stringify(failuresJSON); - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "json", - description: "Formats errors as simple JSON.", - sample: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n [\n {\n \"endPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n },\n \"failure\": \"Missing semicolon\",\n \"fix\": {\n \"innerStart\": 13,\n \"innerLength\": 0,\n \"innerText\": \";\"\n },\n \"name\": \"myFile.ts\",\n \"ruleName\": \"semicolon\",\n \"startPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n }\n }\n ]"], ["\n [\n {\n \"endPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n },\n \"failure\": \"Missing semicolon\",\n \"fix\": {\n \"innerStart\": 13,\n \"innerLength\": 0,\n \"innerText\": \";\"\n },\n \"name\": \"myFile.ts\",\n \"ruleName\": \"semicolon\",\n \"startPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n }\n }\n ]"]))), - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1; diff --git a/node_modules/tslint/lib/formatters/junitFormatter.d.ts b/node_modules/tslint/lib/formatters/junitFormatter.d.ts deleted file mode 100644 index c47404485..000000000 --- a/node_modules/tslint/lib/formatters/junitFormatter.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; - private escapeXml; -} diff --git a/node_modules/tslint/lib/formatters/junitFormatter.js b/node_modules/tslint/lib/formatters/junitFormatter.js deleted file mode 100644 index 61b91a655..000000000 --- a/node_modules/tslint/lib/formatters/junitFormatter.js +++ /dev/null @@ -1,77 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var output = '<?xml version="1.0" encoding="utf-8"?><testsuites package="tslint">'; - if (failures.length !== 0) { - var failuresSorted = failures.sort(function (a, b) { return a.getFileName().localeCompare(b.getFileName()); }); - var previousFilename = null; - for (var _i = 0, failuresSorted_1 = failuresSorted; _i < failuresSorted_1.length; _i++) { - var failure = failuresSorted_1[_i]; - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var message = this.escapeXml(failure.getFailure()); - var rule = this.escapeXml(failure.getRuleName()); - var severity = failure.getRuleSeverity(); - if (failure.getFileName() !== previousFilename) { - if (previousFilename !== null) { - output += "</testsuite>"; - } - previousFilename = failure.getFileName(); - output += "<testsuite name=\"" + this.escapeXml(failure.getFileName()) + "\">"; - } - output += "<testcase name=\"Line " + (lineAndCharacter.line + 1) + ", "; - output += "Column " + (lineAndCharacter.character + 1) + ": " + rule + "\">"; - output += "<failure type=\"" + severity + "\">" + message + "</failure>"; - output += "</testcase>"; - } - if (previousFilename !== null) { - output += "</testsuite>"; - } - } - output += "</testsuites>"; - return output; - }; - Formatter.prototype.escapeXml = function (str) { - return str - .replace(/&/g, "&") - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/'/g, "'") - .replace(/"/g, """); - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "junit", - description: "Formats errors as through they were JUnit output.", - descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Imitates the JUnit XML Output"], ["\n Imitates the JUnit XML Output"]))), - sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"Line 1, Column 14: semicolon\">\n <failure type=\"warning\">Missing semicolon</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "], ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"Line 1, Column 14: semicolon\">\n <failure type=\"warning\">Missing semicolon</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "]))), - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/formatters/msbuildFormatter.d.ts b/node_modules/tslint/lib/formatters/msbuildFormatter.d.ts deleted file mode 100644 index 6227c2b8c..000000000 --- a/node_modules/tslint/lib/formatters/msbuildFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/msbuildFormatter.js b/node_modules/tslint/lib/formatters/msbuildFormatter.js deleted file mode 100644 index 9edc2d9c6..000000000 --- a/node_modules/tslint/lib/formatters/msbuildFormatter.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var path = require("path"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var utils_1 = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var outputLines = failures.map(function (failure) { - var fileName = path.normalize(failure.getFileName()); - var failureString = failure.getFailure(); - var camelizedRule = utils_1.camelize(failure.getRuleName()); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var positionTuple = "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + ")"; - var severity = failure.getRuleSeverity(); - return "" + fileName + positionTuple + ": " + severity + " " + camelizedRule + ": " + failureString; - }); - return outputLines.join("\n") + "\n"; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "msbuild", - description: "Formats errors for consumption by msbuild.", - descriptionDetails: "The output is compatible with both msbuild and Visual Studio.", - sample: "myFile.ts(1,14): warning: Missing semicolon", - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; diff --git a/node_modules/tslint/lib/formatters/pmdFormatter.d.ts b/node_modules/tslint/lib/formatters/pmdFormatter.d.ts deleted file mode 100644 index af3160a3f..000000000 --- a/node_modules/tslint/lib/formatters/pmdFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/pmdFormatter.js b/node_modules/tslint/lib/formatters/pmdFormatter.js deleted file mode 100644 index a8aac2d6e..000000000 --- a/node_modules/tslint/lib/formatters/pmdFormatter.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var output = "<pmd version=\"tslint\">"; - for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) { - var failure = failures_1[_i]; - var failureString = failure.getFailure() - .replace(/&/g, "&") - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/'/g, "'") - .replace(/"/g, """); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var priority = failure.getRuleSeverity() === "warning" ? 4 : 3; - output += "<file name=\"" + failure.getFileName(); - output += "\"><violation begincolumn=\"" + (lineAndCharacter.character + 1); - output += "\" beginline=\"" + (lineAndCharacter.line + 1); - output += "\" priority=\"" + priority + "\""; - output += " rule=\"" + failureString + "\"></violation></file>"; - } - output += "</pmd>"; - return output; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "pmd", - description: "Formats errors as through they were PMD output.", - descriptionDetails: "Imitates the XML output from PMD. All errors have a priority of 1.", - sample: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"3\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"], ["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"3\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"]))), - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1; diff --git a/node_modules/tslint/lib/formatters/proseFormatter.d.ts b/node_modules/tslint/lib/formatters/proseFormatter.d.ts deleted file mode 100644 index fce71e7e0..000000000 --- a/node_modules/tslint/lib/formatters/proseFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[], fixes?: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/proseFormatter.js b/node_modules/tslint/lib/formatters/proseFormatter.js deleted file mode 100644 index ca73001a3..000000000 --- a/node_modules/tslint/lib/formatters/proseFormatter.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures, fixes) { - if (failures.length === 0 && (fixes === undefined || fixes.length === 0)) { - return "\n"; - } - failures = this.sortFailures(failures); - var fixLines = []; - if (fixes !== undefined) { - var perFileFixes = new Map(); - for (var _i = 0, fixes_1 = fixes; _i < fixes_1.length; _i++) { - var fix = fixes_1[_i]; - var prevFixes = perFileFixes.get(fix.getFileName()); - perFileFixes.set(fix.getFileName(), (prevFixes !== undefined ? prevFixes : 0) + 1); - } - perFileFixes.forEach(function (fixCount, fixedFile) { - fixLines.push("Fixed " + fixCount + " error(s) in " + fixedFile); - }); - fixLines.push(""); // add a blank line between fixes and failures - } - var errorLines = failures.map(function (failure) { - var fileName = failure.getFileName(); - var failureString = failure.getFailure(); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character + 1) + "]"; - return failure.getRuleSeverity().toUpperCase() + ": " + fileName + positionTuple + ": " + failureString; - }); - return fixLines.concat(errorLines).join("\n") + "\n"; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "prose", - description: "The default formatter which outputs simple human-readable messages.", - sample: "ERROR: myFile.ts[1, 14]: Missing semicolon", - consumer: "human", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; diff --git a/node_modules/tslint/lib/formatters/stylishFormatter.d.ts b/node_modules/tslint/lib/formatters/stylishFormatter.d.ts deleted file mode 100644 index 8d5789dca..000000000 --- a/node_modules/tslint/lib/formatters/stylishFormatter.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; - private mapToMessages; - private pad; - private getPositionMaxSize; - private getRuleMaxSize; -} diff --git a/node_modules/tslint/lib/formatters/stylishFormatter.js b/node_modules/tslint/lib/formatters/stylishFormatter.js deleted file mode 100644 index fa039922b..000000000 --- a/node_modules/tslint/lib/formatters/stylishFormatter.js +++ /dev/null @@ -1,112 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var chalk_1 = require("chalk"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - failures = this.sortFailures(failures); - var outputLines = this.mapToMessages(failures); - // Removes initial blank line - if (outputLines[0] === "") { - outputLines.shift(); - } - return outputLines.join("\n") + "\n"; - }; - Formatter.prototype.mapToMessages = function (failures) { - if (failures.length === 0) { - return []; - } - var outputLines = []; - var positionMaxSize = this.getPositionMaxSize(failures); - var ruleMaxSize = this.getRuleMaxSize(failures); - var currentFile; - for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) { - var failure = failures_1[_i]; - var fileName = failure.getFileName(); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var positionTuple = lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1); - // Output the name of each file once - if (currentFile !== fileName) { - outputLines.push(""); - outputLines.push("" + fileName + chalk_1.default.hidden(":" + positionTuple)); - currentFile = fileName; - } - var failureString = failure.getFailure(); - failureString = chalk_1.default.yellow(failureString); - // Rule - var ruleName = failure.getRuleName(); - ruleName = this.pad(ruleName, ruleMaxSize); - ruleName = chalk_1.default.grey(ruleName); - // Lines - positionTuple = this.pad(positionTuple, positionMaxSize); - positionTuple = failure.getRuleSeverity() === "warning" - ? chalk_1.default.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple) - : chalk_1.default.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple); - // Output - var output = positionTuple + " " + ruleName + " " + failureString; - outputLines.push(output); - } - return outputLines; - }; - Formatter.prototype.pad = function (str, len) { - var padder = Array(len + 1).join(" "); - return (str + padder).substring(0, padder.length); - }; - Formatter.prototype.getPositionMaxSize = function (failures) { - var positionMaxSize = 0; - for (var _i = 0, failures_2 = failures; _i < failures_2.length; _i++) { - var failure = failures_2[_i]; - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var positionSize = (lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1)).length; - if (positionSize > positionMaxSize) { - positionMaxSize = positionSize; - } - } - return positionMaxSize; - }; - Formatter.prototype.getRuleMaxSize = function (failures) { - var ruleMaxSize = 0; - for (var _i = 0, failures_3 = failures; _i < failures_3.length; _i++) { - var failure = failures_3[_i]; - var ruleSize = failure.getRuleName().length; - if (ruleSize > ruleMaxSize) { - ruleMaxSize = ruleSize; - } - } - return ruleMaxSize; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "stylish", - description: "Human-readable formatter which creates stylish messages.", - descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."], ["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."]))), - sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n myFile.ts\n 1:14 semicolon Missing semicolon"], ["\n myFile.ts\n 1:14 semicolon Missing semicolon"]))), - consumer: "human", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/formatters/tapFormatter.d.ts b/node_modules/tslint/lib/formatters/tapFormatter.d.ts deleted file mode 100644 index f3b123e11..000000000 --- a/node_modules/tslint/lib/formatters/tapFormatter.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; - private mapToMessages; -} diff --git a/node_modules/tslint/lib/formatters/tapFormatter.js b/node_modules/tslint/lib/formatters/tapFormatter.js deleted file mode 100644 index f834f75f9..000000000 --- a/node_modules/tslint/lib/formatters/tapFormatter.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var output = ["TAP version 13"]; - if (failures.length === 0) { - output = output.concat([ - "1..0 # SKIP No failures", - ]); - } - else { - output = output.concat(["1.." + failures.length]).concat(this.mapToMessages(failures)); - } - return output.join("\n") + "\n"; - }; - Formatter.prototype.mapToMessages = function (failures) { - return failures.map(function (failure, i) { - var fileName = failure.getFileName(); - var failureString = failure.getFailure(); - var ruleName = failure.getRuleName(); - var failureMessage = failure.getFailure(); - var failureSeverity = failure.getRuleSeverity(); - var failureRaw = failure.getRawLines(); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - return Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n not ok ", " - ", "\n ---\n message : ", "\n severity: ", "\n data:\n ruleName: ", "\n fileName: ", "\n line: ", "\n character: ", "\n failureString: ", "\n rawLines: ", "\n ..."], ["\n not ok ", " - ", "\n ---\n message : ", "\n severity: ", "\n data:\n ruleName: ", "\n fileName: ", "\n line: ", "\n character: ", "\n failureString: ", "\n rawLines: ", "\n ..."])), String(i + 1), failureMessage, failureMessage, failureSeverity, ruleName, fileName, String(lineAndCharacter.line), String(lineAndCharacter.character), failureString, failureRaw); - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "tap", - description: "Formats output as TAP stream.", - descriptionDetails: "Provides error messages output in TAP13 format which can be consumed by any TAP formatter.", - sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n TAP version 13\n 1..1\n not ok 1 - Some error\n ---\n message: Variable has any type\n severity: error\n data:\n ruleName: no-any\n fileName: test-file.ts\n line: 10\n character: 10\n failureString: Some error\n rawLines: Some raw output\n ..."], ["\n TAP version 13\n 1..1\n not ok 1 - Some error\n ---\n message: Variable has any type\n severity: error\n data:\n ruleName: no-any\n fileName: test-file.ts\n line: 10\n character: 10\n failureString: Some error\n rawLines: Some raw output\n ..."]))), - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/formatters/verboseFormatter.d.ts b/node_modules/tslint/lib/formatters/verboseFormatter.d.ts deleted file mode 100644 index e1f97432d..000000000 --- a/node_modules/tslint/lib/formatters/verboseFormatter.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; - private mapToMessages; -} diff --git a/node_modules/tslint/lib/formatters/verboseFormatter.js b/node_modules/tslint/lib/formatters/verboseFormatter.js deleted file mode 100644 index eeea7310b..000000000 --- a/node_modules/tslint/lib/formatters/verboseFormatter.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - failures = this.sortFailures(failures); - return this.mapToMessages(failures).join("\n") + "\n"; - }; - Formatter.prototype.mapToMessages = function (failures) { - return failures.map(function (failure) { - var fileName = failure.getFileName(); - var failureString = failure.getFailure(); - var ruleName = failure.getRuleName(); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character + 1) + "]"; - return failure.getRuleSeverity().toUpperCase() + ": (" + ruleName + ") " + fileName + positionTuple + ": " + failureString; - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "verbose", - description: "The human-readable formatter which includes the rule name in messages.", - descriptionDetails: "The output is the same as the prose formatter with the rule name included", - sample: "ERROR: (semicolon) myFile.ts[1, 14]: Missing semicolon", - consumer: "human", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; diff --git a/node_modules/tslint/lib/formatters/vsoFormatter.d.ts b/node_modules/tslint/lib/formatters/vsoFormatter.d.ts deleted file mode 100644 index 6227c2b8c..000000000 --- a/node_modules/tslint/lib/formatters/vsoFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { AbstractFormatter } from "../language/formatter/abstractFormatter"; -import { IFormatterMetadata } from "../language/formatter/formatter"; -import { RuleFailure } from "../language/rule/rule"; -export declare class Formatter extends AbstractFormatter { - static metadata: IFormatterMetadata; - format(failures: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/formatters/vsoFormatter.js b/node_modules/tslint/lib/formatters/vsoFormatter.js deleted file mode 100644 index 5ab0d3604..000000000 --- a/node_modules/tslint/lib/formatters/vsoFormatter.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractFormatter_1 = require("../language/formatter/abstractFormatter"); -var Utils = require("../utils"); -var Formatter = /** @class */ (function (_super) { - tslib_1.__extends(Formatter, _super); - function Formatter() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Formatter.prototype.format = function (failures) { - var outputLines = failures.map(function (failure) { - var fileName = failure.getFileName(); - var failureString = failure.getFailure(); - var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var line = lineAndCharacter.line + 1; - var character = lineAndCharacter.character + 1; - var code = failure.getRuleName(); - var properties = "sourcepath=" + fileName + ";linenumber=" + line + ";columnnumber=" + character + ";code=" + code + ";"; - return "##vso[task.logissue type=warning;" + properties + "]" + failureString; - }); - return outputLines.join("\n") + "\n"; - }; - /* tslint:disable:object-literal-sort-keys */ - Formatter.metadata = { - formatterName: "vso", - description: "Formats output as VSO/TFS logging commands.", - descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Integrates with Visual Studio Online and Team Foundation Server by outputting errors\n as 'warning' logging commands."], ["\n Integrates with Visual Studio Online and Team Foundation Server by outputting errors\n as 'warning' logging commands."]))), - sample: "##vso[task.logissue type=warning;sourcepath=myFile.ts;linenumber=1;columnnumber=14;code=semicolon;]Missing semicolon", - consumer: "machine", - }; - return Formatter; -}(abstractFormatter_1.AbstractFormatter)); -exports.Formatter = Formatter; -var templateObject_1; diff --git a/node_modules/tslint/lib/index.d.ts b/node_modules/tslint/lib/index.d.ts deleted file mode 100644 index 4486f9af8..000000000 --- a/node_modules/tslint/lib/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as Configuration from "./configuration"; -import * as Formatters from "./formatters"; -import { FormatterConstructor } from "./language/formatter/formatter"; -import { RuleFailure } from "./language/rule/rule"; -import * as Rules from "./rules"; -import * as Test from "./test"; -import * as Utils from "./utils"; -export { Configuration, Formatters, Rules, Test, Utils }; -export * from "./linter"; -export * from "./language/rule/rule"; -export * from "./enableDisableRules"; -export * from "./formatterLoader"; -export * from "./ruleLoader"; -export * from "./language/utils"; -export * from "./language/walker"; -export * from "./language/formatter/formatter"; -export interface LintResult { - errorCount: number; - warningCount: number; - failures: RuleFailure[]; - fixes?: RuleFailure[]; - format: string | FormatterConstructor; - output: string; -} -export interface ILinterOptions { - fix: boolean; - formatter?: string | FormatterConstructor; - formattersDirectory?: string; - rulesDirectory?: string | string[]; -} diff --git a/node_modules/tslint/lib/index.js b/node_modules/tslint/lib/index.js deleted file mode 100644 index cb8ac2900..000000000 --- a/node_modules/tslint/lib/index.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var Configuration = require("./configuration"); -exports.Configuration = Configuration; -var Formatters = require("./formatters"); -exports.Formatters = Formatters; -var Rules = require("./rules"); -exports.Rules = Rules; -var Test = require("./test"); -exports.Test = Test; -var Utils = require("./utils"); -exports.Utils = Utils; -tslib_1.__exportStar(require("./linter"), exports); -tslib_1.__exportStar(require("./language/rule/rule"), exports); -tslib_1.__exportStar(require("./enableDisableRules"), exports); -tslib_1.__exportStar(require("./formatterLoader"), exports); -tslib_1.__exportStar(require("./ruleLoader"), exports); -tslib_1.__exportStar(require("./language/utils"), exports); -tslib_1.__exportStar(require("./language/walker"), exports); diff --git a/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts b/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts deleted file mode 100644 index db244af13..000000000 --- a/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { RuleFailure } from "../rule/rule"; -import { IFormatter, IFormatterMetadata } from "./formatter"; -export declare abstract class AbstractFormatter implements IFormatter { - static metadata: IFormatterMetadata; - abstract format(failures: RuleFailure[]): string; - protected sortFailures(failures: RuleFailure[]): RuleFailure[]; -} diff --git a/node_modules/tslint/lib/language/formatter/abstractFormatter.js b/node_modules/tslint/lib/language/formatter/abstractFormatter.js deleted file mode 100644 index 21ecc1064..000000000 --- a/node_modules/tslint/lib/language/formatter/abstractFormatter.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var rule_1 = require("../rule/rule"); -var AbstractFormatter = /** @class */ (function () { - function AbstractFormatter() { - } - AbstractFormatter.prototype.sortFailures = function (failures) { - return failures.slice().sort(rule_1.RuleFailure.compare); - }; - return AbstractFormatter; -}()); -exports.AbstractFormatter = AbstractFormatter; diff --git a/node_modules/tslint/lib/language/formatter/formatter.d.ts b/node_modules/tslint/lib/language/formatter/formatter.d.ts deleted file mode 100644 index 49eb20fbe..000000000 --- a/node_modules/tslint/lib/language/formatter/formatter.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { RuleFailure } from "../rule/rule"; -export interface IFormatterMetadata { - /** - * The name of the formatter. - */ - formatterName: string; - /** - * A short, one line description of what the formatter does. - */ - description: string; - /** - * More elaborate details about the formatter. - */ - descriptionDetails?: string; - /** - * Sample output from the formatter. - */ - sample: string; - /** - * Sample output from the formatter. - */ - consumer: ConsumerType; -} -export declare type ConsumerType = "human" | "machine"; -export interface FormatterConstructor { - new (): IFormatter; -} -export interface IFormatter { - /** - * Formats linter results - * @param failures Linter failures that were not fixed - * @param fixes Fixed linter failures. Available when the `--fix` argument is used on the command line - */ - format(failures: RuleFailure[], fixes?: RuleFailure[]): string; -} diff --git a/node_modules/tslint/lib/language/formatter/formatter.js b/node_modules/tslint/lib/language/formatter/formatter.js deleted file mode 100644 index 1c258a5da..000000000 --- a/node_modules/tslint/lib/language/formatter/formatter.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/tslint/lib/language/rule/abstractRule.d.ts b/node_modules/tslint/lib/language/rule/abstractRule.d.ts deleted file mode 100644 index 65ed4a1b9..000000000 --- a/node_modules/tslint/lib/language/rule/abstractRule.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { IWalker, WalkContext } from "../walker"; -import { IOptions, IRule, IRuleMetadata, RuleFailure, RuleSeverity } from "./rule"; -export declare type NoInfer<T> = T & { - [K in keyof T]: T[K]; -}; -export declare abstract class AbstractRule implements IRule { - private readonly options; - static metadata: IRuleMetadata; - protected readonly ruleArguments: any[]; - protected readonly ruleSeverity: RuleSeverity; - ruleName: string; - constructor(options: IOptions); - getOptions(): IOptions; - abstract apply(sourceFile: ts.SourceFile): RuleFailure[]; - applyWithWalker(walker: IWalker): RuleFailure[]; - isEnabled(): boolean; - protected applyWithFunction(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<void>) => void): RuleFailure[]; - protected applyWithFunction<T>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>) => void, options: NoInfer<T>): RuleFailure[]; - protected applyWithFunction<T, U>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>, programOrChecker: U) => void, options: NoInfer<T>, checker: NoInfer<U>): RuleFailure[]; - /** - * @deprecated - * Failures will be filtered based on `tslint:disable` comments by tslint. - * This method now does nothing. - */ - protected filterFailures(failures: RuleFailure[]): RuleFailure[]; -} diff --git a/node_modules/tslint/lib/language/rule/abstractRule.js b/node_modules/tslint/lib/language/rule/abstractRule.js deleted file mode 100644 index 879ac31b8..000000000 --- a/node_modules/tslint/lib/language/rule/abstractRule.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var walker_1 = require("../walker"); -var AbstractRule = /** @class */ (function () { - function AbstractRule(options) { - this.options = options; - this.ruleName = options.ruleName; - this.ruleArguments = options.ruleArguments; - this.ruleSeverity = options.ruleSeverity; - } - AbstractRule.prototype.getOptions = function () { - return this.options; - }; - AbstractRule.prototype.applyWithWalker = function (walker) { - walker.walk(walker.getSourceFile()); - return walker.getFailures(); - }; - AbstractRule.prototype.isEnabled = function () { - return this.ruleSeverity !== "off"; - }; - AbstractRule.prototype.applyWithFunction = function (sourceFile, walkFn, options, programOrChecker) { - var ctx = new walker_1.WalkContext(sourceFile, this.ruleName, options); - walkFn(ctx, programOrChecker); - return ctx.failures; - }; - /** - * @deprecated - * Failures will be filtered based on `tslint:disable` comments by tslint. - * This method now does nothing. - */ - AbstractRule.prototype.filterFailures = function (failures) { return failures; }; - return AbstractRule; -}()); -exports.AbstractRule = AbstractRule; diff --git a/node_modules/tslint/lib/language/rule/optionallyTypedRule.d.ts b/node_modules/tslint/lib/language/rule/optionallyTypedRule.d.ts deleted file mode 100644 index f12d74f44..000000000 --- a/node_modules/tslint/lib/language/rule/optionallyTypedRule.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { AbstractRule } from "./abstractRule"; -import { ITypedRule, RuleFailure } from "./rule"; -export declare abstract class OptionallyTypedRule extends AbstractRule implements ITypedRule { - abstract applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[]; -} diff --git a/node_modules/tslint/lib/language/rule/optionallyTypedRule.js b/node_modules/tslint/lib/language/rule/optionallyTypedRule.js deleted file mode 100644 index 1aefda55e..000000000 --- a/node_modules/tslint/lib/language/rule/optionallyTypedRule.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var abstractRule_1 = require("./abstractRule"); -var OptionallyTypedRule = /** @class */ (function (_super) { - tslib_1.__extends(OptionallyTypedRule, _super); - function OptionallyTypedRule() { - return _super !== null && _super.apply(this, arguments) || this; - } - return OptionallyTypedRule; -}(abstractRule_1.AbstractRule)); -exports.OptionallyTypedRule = OptionallyTypedRule; diff --git a/node_modules/tslint/lib/language/rule/rule.d.ts b/node_modules/tslint/lib/language/rule/rule.d.ts deleted file mode 100644 index e37861c36..000000000 --- a/node_modules/tslint/lib/language/rule/rule.d.ts +++ /dev/null @@ -1,189 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { IWalker } from "../walker"; -export interface RuleConstructor { - metadata: IRuleMetadata; - new (options: IOptions): IRule; -} -export interface IRuleMetadata { - /** - * The kebab-case name of the rule. - */ - ruleName: string; - /** - * The type of the rule - its overall purpose - */ - type: RuleType; - /** - * A rule deprecation message, if applicable. - */ - deprecationMessage?: string; - /** - * A short, one line description of what the rule does. - */ - description: string; - /** - * More elaborate details about the rule. - */ - descriptionDetails?: string; - /** - * Whether or not the rule will provide fix suggestions. - */ - hasFix?: boolean; - /** - * An explanation of the available options for the rule. - */ - optionsDescription: string; - /** - * Schema of the options the rule accepts. - * The first boolean for whether the rule is enabled or not is already implied. - * This field describes the options after that boolean. - * If null, this rule has no options and is not configurable. - */ - options: any; - /** - * Examples of what a standard config for the rule might look like. - * Using a string[] here is deprecated. Write the options as a JSON object instead. - */ - optionExamples?: Array<true | any[]> | string[]; - /** - * An explanation of why the rule is useful. - */ - rationale?: string; - /** - * Whether or not the rule requires type info to run. - */ - requiresTypeInfo?: boolean; - /** - * Whether or not the rule use for TypeScript only. If `false`, this rule may be used with .js files. - */ - typescriptOnly: boolean; - /** - * Examples demonstrating what the lint rule will pass and fail - */ - codeExamples?: ICodeExample[]; -} -export declare type RuleType = "functionality" | "maintainability" | "style" | "typescript"; -export declare type RuleSeverity = "warning" | "error" | "off"; -export interface ICodeExample { - config: string; - description: string; - pass: string; - fail?: string; -} -export interface IOptions { - ruleArguments: any[]; - ruleSeverity: RuleSeverity; - ruleName: string; - /** - * @deprecated - * Tslint now handles disables itself. - * This will be empty. - */ - disabledIntervals: IDisabledInterval[]; -} -/** - * @deprecated - * These are now handled internally. - */ -export interface IDisabledInterval { - startPosition: number; - endPosition: number; -} -export interface IRule { - getOptions(): IOptions; - isEnabled(): boolean; - apply(sourceFile: ts.SourceFile): RuleFailure[]; - applyWithWalker(walker: IWalker): RuleFailure[]; -} -export interface ITypedRule extends IRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[]; -} -export interface IRuleFailureJson { - endPosition: IRuleFailurePositionJson; - failure: string; - fix?: FixJson; - name: string; - ruleSeverity: string; - ruleName: string; - startPosition: IRuleFailurePositionJson; -} -export interface IRuleFailurePositionJson { - character: number; - line: number; - position: number; -} -export declare function isTypedRule(rule: IRule): rule is ITypedRule; -export interface ReplacementJson { - innerStart: number; - innerLength: number; - innerText: string; -} -export declare class Replacement { - readonly start: number; - readonly length: number; - readonly text: string; - static applyFixes(content: string, fixes: Fix[]): string; - static applyAll(content: string, replacements: Replacement[]): string; - static replaceNode(node: ts.Node, text: string, sourceFile?: ts.SourceFile): Replacement; - static replaceFromTo(start: number, end: number, text: string): Replacement; - static deleteText(start: number, length: number): Replacement; - static deleteFromTo(start: number, end: number): Replacement; - static appendText(start: number, text: string): Replacement; - constructor(start: number, length: number, text: string); - readonly end: number; - apply(content: string): string; - toJson(): ReplacementJson; -} -export declare class RuleFailurePosition { - private readonly position; - private readonly lineAndCharacter; - constructor(position: number, lineAndCharacter: ts.LineAndCharacter); - getPosition(): number; - getLineAndCharacter(): ts.LineAndCharacter; - toJson(): IRuleFailurePositionJson; - equals(ruleFailurePosition: RuleFailurePosition): boolean; -} -export declare type Fix = Replacement | Replacement[]; -export declare type FixJson = ReplacementJson | ReplacementJson[]; -export declare class RuleFailure { - private readonly sourceFile; - private readonly failure; - private readonly ruleName; - private readonly fix?; - private readonly fileName; - private readonly startPosition; - private readonly endPosition; - private readonly rawLines; - private ruleSeverity; - static compare(a: RuleFailure, b: RuleFailure): number; - constructor(sourceFile: ts.SourceFile, start: number, end: number, failure: string, ruleName: string, fix?: Replacement | Replacement[] | undefined); - getFileName(): string; - getRuleName(): string; - getStartPosition(): RuleFailurePosition; - getEndPosition(): RuleFailurePosition; - getFailure(): string; - hasFix(): boolean; - getFix(): Replacement | Replacement[] | undefined; - getRawLines(): string; - getRuleSeverity(): RuleSeverity; - setRuleSeverity(value: RuleSeverity): void; - toJson(): IRuleFailureJson; - equals(ruleFailure: RuleFailure): boolean; - private createFailurePosition; -} diff --git a/node_modules/tslint/lib/language/rule/rule.js b/node_modules/tslint/lib/language/rule/rule.js deleted file mode 100644 index d9c251842..000000000 --- a/node_modules/tslint/lib/language/rule/rule.js +++ /dev/null @@ -1,174 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var utils_1 = require("../../utils"); -function isTypedRule(rule) { - return "applyWithProgram" in rule; -} -exports.isTypedRule = isTypedRule; -var Replacement = /** @class */ (function () { - function Replacement(start, length, text) { - this.start = start; - this.length = length; - this.text = text; - } - Replacement.applyFixes = function (content, fixes) { - return this.applyAll(content, utils_1.flatMap(fixes, utils_1.arrayify)); - }; - Replacement.applyAll = function (content, replacements) { - // sort in reverse so that diffs are properly applied - replacements.sort(function (a, b) { return b.end !== a.end ? b.end - a.end : b.start - a.start; }); - return replacements.reduce(function (text, r) { return r.apply(text); }, content); - }; - Replacement.replaceNode = function (node, text, sourceFile) { - return this.replaceFromTo(node.getStart(sourceFile), node.getEnd(), text); - }; - Replacement.replaceFromTo = function (start, end, text) { - return new Replacement(start, end - start, text); - }; - Replacement.deleteText = function (start, length) { - return new Replacement(start, length, ""); - }; - Replacement.deleteFromTo = function (start, end) { - return new Replacement(start, end - start, ""); - }; - Replacement.appendText = function (start, text) { - return new Replacement(start, 0, text); - }; - Object.defineProperty(Replacement.prototype, "end", { - get: function () { - return this.start + this.length; - }, - enumerable: true, - configurable: true - }); - Replacement.prototype.apply = function (content) { - return content.substring(0, this.start) + this.text + content.substring(this.start + this.length); - }; - Replacement.prototype.toJson = function () { - // tslint:disable object-literal-sort-keys - return { - innerStart: this.start, - innerLength: this.length, - innerText: this.text, - }; - // tslint:enable object-literal-sort-keys - }; - return Replacement; -}()); -exports.Replacement = Replacement; -var RuleFailurePosition = /** @class */ (function () { - function RuleFailurePosition(position, lineAndCharacter) { - this.position = position; - this.lineAndCharacter = lineAndCharacter; - } - RuleFailurePosition.prototype.getPosition = function () { - return this.position; - }; - RuleFailurePosition.prototype.getLineAndCharacter = function () { - return this.lineAndCharacter; - }; - RuleFailurePosition.prototype.toJson = function () { - return { - character: this.lineAndCharacter.character, - line: this.lineAndCharacter.line, - position: this.position, - }; - }; - RuleFailurePosition.prototype.equals = function (ruleFailurePosition) { - var ll = this.lineAndCharacter; - var rr = ruleFailurePosition.lineAndCharacter; - return this.position === ruleFailurePosition.position - && ll.line === rr.line - && ll.character === rr.character; - }; - return RuleFailurePosition; -}()); -exports.RuleFailurePosition = RuleFailurePosition; -var RuleFailure = /** @class */ (function () { - function RuleFailure(sourceFile, start, end, failure, ruleName, fix) { - this.sourceFile = sourceFile; - this.failure = failure; - this.ruleName = ruleName; - this.fix = fix; - this.fileName = sourceFile.fileName; - this.startPosition = this.createFailurePosition(start); - this.endPosition = this.createFailurePosition(end); - this.rawLines = sourceFile.text; - this.ruleSeverity = "error"; - } - RuleFailure.compare = function (a, b) { - if (a.fileName !== b.fileName) { - return a.fileName < b.fileName ? -1 : 1; - } - return a.startPosition.getPosition() - b.startPosition.getPosition(); - }; - RuleFailure.prototype.getFileName = function () { - return this.fileName; - }; - RuleFailure.prototype.getRuleName = function () { - return this.ruleName; - }; - RuleFailure.prototype.getStartPosition = function () { - return this.startPosition; - }; - RuleFailure.prototype.getEndPosition = function () { - return this.endPosition; - }; - RuleFailure.prototype.getFailure = function () { - return this.failure; - }; - RuleFailure.prototype.hasFix = function () { - return this.fix !== undefined; - }; - RuleFailure.prototype.getFix = function () { - return this.fix; - }; - RuleFailure.prototype.getRawLines = function () { - return this.rawLines; - }; - RuleFailure.prototype.getRuleSeverity = function () { - return this.ruleSeverity; - }; - RuleFailure.prototype.setRuleSeverity = function (value) { - this.ruleSeverity = value; - }; - RuleFailure.prototype.toJson = function () { - return { - endPosition: this.endPosition.toJson(), - failure: this.failure, - fix: this.fix === undefined ? undefined : Array.isArray(this.fix) ? this.fix.map(function (r) { return r.toJson(); }) : this.fix.toJson(), - name: this.fileName, - ruleName: this.ruleName, - ruleSeverity: this.ruleSeverity.toUpperCase(), - startPosition: this.startPosition.toJson(), - }; - }; - RuleFailure.prototype.equals = function (ruleFailure) { - return this.failure === ruleFailure.getFailure() - && this.fileName === ruleFailure.getFileName() - && this.startPosition.equals(ruleFailure.getStartPosition()) - && this.endPosition.equals(ruleFailure.getEndPosition()); - }; - RuleFailure.prototype.createFailurePosition = function (position) { - var lineAndCharacter = this.sourceFile.getLineAndCharacterOfPosition(position); - return new RuleFailurePosition(position, lineAndCharacter); - }; - return RuleFailure; -}()); -exports.RuleFailure = RuleFailure; diff --git a/node_modules/tslint/lib/language/rule/typedRule.d.ts b/node_modules/tslint/lib/language/rule/typedRule.d.ts deleted file mode 100644 index a4d1fcca0..000000000 --- a/node_modules/tslint/lib/language/rule/typedRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { AbstractRule } from "./abstractRule"; -import { ITypedRule, RuleFailure } from "./rule"; -export declare abstract class TypedRule extends AbstractRule implements ITypedRule { - apply(): RuleFailure[]; - abstract applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[]; -} diff --git a/node_modules/tslint/lib/language/rule/typedRule.js b/node_modules/tslint/lib/language/rule/typedRule.js deleted file mode 100644 index 83873d49f..000000000 --- a/node_modules/tslint/lib/language/rule/typedRule.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var error_1 = require("../../error"); -var abstractRule_1 = require("./abstractRule"); -var TypedRule = /** @class */ (function (_super) { - tslib_1.__extends(TypedRule, _super); - function TypedRule() { - return _super !== null && _super.apply(this, arguments) || this; - } - TypedRule.prototype.apply = function () { - // if no program is given to the linter, show an error - error_1.showWarningOnce("Warning: The '" + this.ruleName + "' rule requires type information."); - return []; - }; - return TypedRule; -}(abstractRule_1.AbstractRule)); -exports.TypedRule = TypedRule; diff --git a/node_modules/tslint/lib/language/utils.d.ts b/node_modules/tslint/lib/language/utils.d.ts deleted file mode 100644 index 40b4aee16..000000000 --- a/node_modules/tslint/lib/language/utils.d.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { IDisabledInterval, RuleFailure } from "./rule/rule"; -export declare function getSourceFile(fileName: string, source: string): ts.SourceFile; -/** @deprecated See IDisabledInterval. */ -export declare function doesIntersect(failure: RuleFailure, disabledIntervals: IDisabledInterval[]): boolean; -/** - * @returns true if any modifier kinds passed along exist in the given modifiers array - * - * @deprecated use `hasModifier` from `tsutils` - */ -export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...modifierKinds: ts.SyntaxKind[]): boolean; -/** - * Determines if the appropriate bit in the parent (VariableDeclarationList) is set, - * which indicates this is a "let" or "const". - * - * @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils` - */ -export declare function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean; -/** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */ -export declare function isBlockScopedBindingElement(node: ts.BindingElement): boolean; -/** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */ -export declare function getBindingElementVariableDeclaration(node: ts.BindingElement): ts.VariableDeclaration | null; -/** - * Finds a child of a given node with a given kind. - * Note: This uses `node.getChildren()`, which does extra parsing work to include tokens. - * - * @deprecated use `getChildOfKind` from `tsutils` - */ -export declare function childOfKind(node: ts.Node, kind: ts.SyntaxKind): ts.Node | undefined; -/** - * @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself. - * - * @deprecated no longer used, use a `while` loop instead - */ -export declare function someAncestor(node: ts.Node, predicate: (n: ts.Node) => boolean): boolean; -export declare function ancestorWhere<T extends ts.Node = ts.Node>(node: ts.Node, predicate: ((n: ts.Node) => n is T) | ((n: ts.Node) => boolean)): T | undefined; -/** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */ -export declare function isAssignment(node: ts.Node): boolean; -/** - * Bitwise check for node flags. - * - * @deprecated use `isNodeFlagSet` from `tsutils` - */ -export declare function isNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean; -/** - * Bitwise check for combined node flags. - * - * @deprecated no longer used - */ -export declare function isCombinedNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean; -/** - * Bitwise check for combined modifier flags. - * - * @deprecated no longer used - */ -export declare function isCombinedModifierFlagSet(node: ts.Node, flagToCheck: ts.ModifierFlags): boolean; -/** - * Bitwise check for type flags. - * - * @deprecated use `isTypeFlagSet` from `tsutils` - */ -export declare function isTypeFlagSet(type: ts.Type, flagToCheck: ts.TypeFlags): boolean; -/** - * Bitwise check for symbol flags. - * - * @deprecated use `isSymbolFlagSet` from `tsutils` - */ -export declare function isSymbolFlagSet(symbol: ts.Symbol, flagToCheck: ts.SymbolFlags): boolean; -/** - * Bitwise check for object flags. - * Does not work with TypeScript 2.0.x - * - * @deprecated use `isObjectFlagSet` from `tsutils` - */ -export declare function isObjectFlagSet(objectType: ts.ObjectType, flagToCheck: ts.ObjectFlags): boolean; -/** - * @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path. - * - * @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration` - */ -export declare function isNestedModuleDeclaration(decl: ts.ModuleDeclaration): boolean; -export declare function unwrapParentheses(node: ts.Expression): ts.Expression; -/** @deprecated use `isFunctionScopeBoundary` from `tsutils` */ -export declare function isScopeBoundary(node: ts.Node): boolean; -/** @deprecated use `isBlockScopeBoundary` from `tsutils` */ -export declare function isBlockScopeBoundary(node: ts.Node): boolean; -/** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */ -export declare function isLoop(node: ts.Node): node is ts.IterationStatement; -/** - * @returns Whether node is a numeric expression. - */ -export declare function isNumeric(node: ts.Expression): boolean; -export interface TokenPosition { - /** The start of the token including all trivia before it */ - fullStart: number; - /** The start of the token */ - tokenStart: number; - /** The end of the token */ - end: number; -} -export declare type ForEachTokenCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition, parent: ts.Node) => void; -export declare type ForEachCommentCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition) => void; -export declare type FilterCallback = (node: ts.Node) => boolean; -/** - * Iterate over all tokens of `node` - * - * @description JsDoc comments are treated like regular comments and only visited if `skipTrivia` === false. - * - * @param node The node whose tokens should be visited - * @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included - * @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text. - * @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree. - * - * @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils` - */ -export declare function forEachToken(node: ts.Node, skipTrivia: boolean, cb: ForEachTokenCallback, filter?: FilterCallback): void; -/** - * Iterate over all comments owned by `node` or its children - * - * @deprecated use `forEachComment` from `tsutils` - */ -export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback): void; -/** - * Checks if there are any comments between `position` and the next non-trivia token - * - * @param text The text to scan - * @param position The position inside `text` where to start scanning. Make sure that this is a valid start position. - * This value is typically obtained from `node.getFullStart()` or `node.getEnd()` - */ -export declare function hasCommentAfterPosition(text: string, position: number): boolean; -export interface EqualsKind { - isPositive: boolean; - isStrict: boolean; -} -export declare function getEqualsKind(node: ts.BinaryOperatorToken): EqualsKind | undefined; -export declare function isStrictNullChecksEnabled(options: ts.CompilerOptions): boolean; -export declare function isNegativeNumberLiteral(node: ts.Node): node is ts.PrefixUnaryExpression & { - operand: ts.NumericLiteral; -}; -/** Wrapper for compatibility with typescript@<2.3.1 */ -export declare function isWhiteSpace(ch: number): boolean; diff --git a/node_modules/tslint/lib/language/utils.js b/node_modules/tslint/lib/language/utils.js deleted file mode 100644 index aba50291f..000000000 --- a/node_modules/tslint/lib/language/utils.js +++ /dev/null @@ -1,463 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var path = require("path"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -function getSourceFile(fileName, source) { - var normalizedName = path.normalize(fileName).replace(/\\/g, "/"); - return ts.createSourceFile(normalizedName, source, ts.ScriptTarget.ES5, /*setParentNodes*/ true); -} -exports.getSourceFile = getSourceFile; -/** @deprecated See IDisabledInterval. */ -function doesIntersect(failure, disabledIntervals) { - return disabledIntervals.some(function (interval) { - var maxStart = Math.max(interval.startPosition, failure.getStartPosition().getPosition()); - var minEnd = Math.min(interval.endPosition, failure.getEndPosition().getPosition()); - return maxStart <= minEnd; - }); -} -exports.doesIntersect = doesIntersect; -/** - * @returns true if any modifier kinds passed along exist in the given modifiers array - * - * @deprecated use `hasModifier` from `tsutils` - */ -function hasModifier(modifiers) { - var modifierKinds = []; - for (var _i = 1; _i < arguments.length; _i++) { - modifierKinds[_i - 1] = arguments[_i]; - } - if (modifiers === undefined || modifierKinds.length === 0) { - return false; - } - return modifiers.some(function (m) { return modifierKinds.some(function (k) { return m.kind === k; }); }); -} -exports.hasModifier = hasModifier; -/** - * Determines if the appropriate bit in the parent (VariableDeclarationList) is set, - * which indicates this is a "let" or "const". - * - * @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils` - */ -function isBlockScopedVariable(node) { - if (node.kind === ts.SyntaxKind.VariableDeclaration) { - var parent = node.parent; - return parent.kind === ts.SyntaxKind.CatchClause || tsutils_1.isBlockScopedVariableDeclarationList(parent); - } - else { - return tsutils_1.isBlockScopedVariableDeclarationList(node.declarationList); - } -} -exports.isBlockScopedVariable = isBlockScopedVariable; -/** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */ -function isBlockScopedBindingElement(node) { - var variableDeclaration = getBindingElementVariableDeclaration(node); // tslint:disable-line:deprecation - // if no variable declaration, it must be a function param, which is block scoped - return (variableDeclaration === null) || isBlockScopedVariable(variableDeclaration); // tslint:disable-line:deprecation -} -exports.isBlockScopedBindingElement = isBlockScopedBindingElement; -/** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */ -function getBindingElementVariableDeclaration(node) { - var currentParent = node.parent; - while (currentParent.kind !== ts.SyntaxKind.VariableDeclaration) { - if (currentParent.parent === undefined) { - return null; // function parameter, no variable declaration - } - else { - currentParent = currentParent.parent; - } - } - return currentParent; -} -exports.getBindingElementVariableDeclaration = getBindingElementVariableDeclaration; -/** - * Finds a child of a given node with a given kind. - * Note: This uses `node.getChildren()`, which does extra parsing work to include tokens. - * - * @deprecated use `getChildOfKind` from `tsutils` - */ -function childOfKind(node, kind) { - return node.getChildren().find(function (child) { return child.kind === kind; }); -} -exports.childOfKind = childOfKind; -/** - * @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself. - * - * @deprecated no longer used, use a `while` loop instead - */ -function someAncestor(node, predicate) { - return predicate(node) || (node.parent !== undefined && someAncestor(node.parent, predicate)); // tslint:disable-line:deprecation -} -exports.someAncestor = someAncestor; -function ancestorWhere(node, predicate) { - var cur = node; - do { - if (predicate(cur)) { - return cur; - } - cur = cur.parent; - } while (cur !== undefined); - return undefined; -} -exports.ancestorWhere = ancestorWhere; -/** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */ -function isAssignment(node) { - if (node.kind === ts.SyntaxKind.BinaryExpression) { - var binaryExpression = node; - return binaryExpression.operatorToken.kind >= ts.SyntaxKind.FirstAssignment - && binaryExpression.operatorToken.kind <= ts.SyntaxKind.LastAssignment; - } - else { - return false; - } -} -exports.isAssignment = isAssignment; -/** - * Bitwise check for node flags. - * - * @deprecated use `isNodeFlagSet` from `tsutils` - */ -function isNodeFlagSet(node, flagToCheck) { - // tslint:disable-next-line:no-bitwise - return (node.flags & flagToCheck) !== 0; -} -exports.isNodeFlagSet = isNodeFlagSet; -/** - * Bitwise check for combined node flags. - * - * @deprecated no longer used - */ -function isCombinedNodeFlagSet(node, flagToCheck) { - // tslint:disable-next-line:no-bitwise - return (ts.getCombinedNodeFlags(node) & flagToCheck) !== 0; -} -exports.isCombinedNodeFlagSet = isCombinedNodeFlagSet; -/** - * Bitwise check for combined modifier flags. - * - * @deprecated no longer used - */ -function isCombinedModifierFlagSet(node, flagToCheck) { - // tslint:disable-next-line:no-bitwise - return (ts.getCombinedModifierFlags(node) & flagToCheck) !== 0; -} -exports.isCombinedModifierFlagSet = isCombinedModifierFlagSet; -/** - * Bitwise check for type flags. - * - * @deprecated use `isTypeFlagSet` from `tsutils` - */ -function isTypeFlagSet(type, flagToCheck) { - // tslint:disable-next-line:no-bitwise - return (type.flags & flagToCheck) !== 0; -} -exports.isTypeFlagSet = isTypeFlagSet; -/** - * Bitwise check for symbol flags. - * - * @deprecated use `isSymbolFlagSet` from `tsutils` - */ -function isSymbolFlagSet(symbol, flagToCheck) { - // tslint:disable-next-line:no-bitwise - return (symbol.flags & flagToCheck) !== 0; -} -exports.isSymbolFlagSet = isSymbolFlagSet; -/** - * Bitwise check for object flags. - * Does not work with TypeScript 2.0.x - * - * @deprecated use `isObjectFlagSet` from `tsutils` - */ -function isObjectFlagSet(objectType, flagToCheck) { - // tslint:disable-next-line:no-bitwise - return (objectType.objectFlags & flagToCheck) !== 0; -} -exports.isObjectFlagSet = isObjectFlagSet; -/** - * @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path. - * - * @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration` - */ -function isNestedModuleDeclaration(decl) { - // in a declaration expression like 'module a.b.c' - 'a' is the top level module declaration node and 'b' and 'c' - // are nested therefore we can depend that a node's position will only match with its name's position for nested - // nodes - return decl.name.pos === decl.pos; -} -exports.isNestedModuleDeclaration = isNestedModuleDeclaration; -function unwrapParentheses(node) { - while (node.kind === ts.SyntaxKind.ParenthesizedExpression) { - node = node.expression; - } - return node; -} -exports.unwrapParentheses = unwrapParentheses; -/** @deprecated use `isFunctionScopeBoundary` from `tsutils` */ -function isScopeBoundary(node) { - return node.kind === ts.SyntaxKind.FunctionDeclaration - || node.kind === ts.SyntaxKind.FunctionExpression - || node.kind === ts.SyntaxKind.PropertyAssignment - || node.kind === ts.SyntaxKind.ShorthandPropertyAssignment - || node.kind === ts.SyntaxKind.MethodDeclaration - || node.kind === ts.SyntaxKind.Constructor - || node.kind === ts.SyntaxKind.ModuleDeclaration - || node.kind === ts.SyntaxKind.ArrowFunction - || node.kind === ts.SyntaxKind.ParenthesizedExpression - || node.kind === ts.SyntaxKind.ClassDeclaration - || node.kind === ts.SyntaxKind.ClassExpression - || node.kind === ts.SyntaxKind.InterfaceDeclaration - || node.kind === ts.SyntaxKind.GetAccessor - || node.kind === ts.SyntaxKind.SetAccessor - || node.kind === ts.SyntaxKind.SourceFile && ts.isExternalModule(node); -} -exports.isScopeBoundary = isScopeBoundary; -/** @deprecated use `isBlockScopeBoundary` from `tsutils` */ -function isBlockScopeBoundary(node) { - return isScopeBoundary(node) // tslint:disable-line:deprecation - || node.kind === ts.SyntaxKind.Block - || isLoop(node) // tslint:disable-line:deprecation - || node.kind === ts.SyntaxKind.WithStatement - || node.kind === ts.SyntaxKind.SwitchStatement - || node.parent !== undefined - && (node.parent.kind === ts.SyntaxKind.TryStatement - || node.parent.kind === ts.SyntaxKind.IfStatement); -} -exports.isBlockScopeBoundary = isBlockScopeBoundary; -/** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */ -function isLoop(node) { - return node.kind === ts.SyntaxKind.DoStatement - || node.kind === ts.SyntaxKind.WhileStatement - || node.kind === ts.SyntaxKind.ForStatement - || node.kind === ts.SyntaxKind.ForInStatement - || node.kind === ts.SyntaxKind.ForOfStatement; -} -exports.isLoop = isLoop; -/** - * @returns Whether node is a numeric expression. - */ -function isNumeric(node) { - while (tsutils_1.isPrefixUnaryExpression(node) && - (node.operator === ts.SyntaxKind.PlusToken || node.operator === ts.SyntaxKind.MinusToken)) { - node = node.operand; - } - return node.kind === ts.SyntaxKind.NumericLiteral || - tsutils_1.isIdentifier(node) && (node.text === "NaN" || node.text === "Infinity"); -} -exports.isNumeric = isNumeric; -/** - * Iterate over all tokens of `node` - * - * @description JsDoc comments are treated like regular comments and only visited if `skipTrivia` === false. - * - * @param node The node whose tokens should be visited - * @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included - * @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text. - * @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree. - * - * @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils` - */ -function forEachToken(node, skipTrivia, cb, filter) { - // this function will most likely be called with SourceFile anyways, so there is no need for an additional parameter - var sourceFile = node.getSourceFile(); - var fullText = sourceFile.text; - var iterateFn = filter === undefined ? iterateChildren : iterateWithFilter; - var handleTrivia = skipTrivia ? undefined : createTriviaHandler(sourceFile, cb); - iterateFn(node); - // this function is used to save the if condition for the common case where no filter is provided - function iterateWithFilter(child) { - if (filter(child)) { - return iterateChildren(child); - } - } - function iterateChildren(child) { - if (child.kind < ts.SyntaxKind.FirstNode || - // for backwards compatibility to typescript 2.0.10 - // JsxText was no Token, but a Node in that version - child.kind === ts.SyntaxKind.JsxText) { - // we found a token, tokens have no children, stop recursing here - return callback(child); - } - /* Exclude everything contained in JsDoc, it will be handled with the other trivia anyway. - * When we would handle JsDoc tokens like regular ones, we would scan some trivia multiple times. - * Even worse, we would scan for trivia inside the JsDoc comment, which yields unexpected results.*/ - if (child.kind !== ts.SyntaxKind.JSDocComment) { - // recurse into Node's children to find tokens - return child.getChildren(sourceFile).forEach(iterateFn); - } - } - function callback(token) { - var tokenStart = token.getStart(sourceFile); - if (!skipTrivia && tokenStart !== token.pos) { - // we only have to handle trivia before each token, because there is nothing after EndOfFileToken - handleTrivia(token.pos, tokenStart, token); - } - return cb(fullText, token.kind, { tokenStart: tokenStart, fullStart: token.pos, end: token.end }, token.parent); - } -} -exports.forEachToken = forEachToken; -function createTriviaHandler(sourceFile, cb) { - var fullText = sourceFile.text; - var scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText); - /** - * Scan the specified range to get all trivia tokens. - * This includes trailing trivia of the last token and the leading trivia of the current token - */ - function handleTrivia(start, end, token) { - var parent = token.parent; - // prevent false positives by not scanning inside JsxText - if (!canHaveLeadingTrivia(token.kind, parent)) { - return; - } - scanner.setTextPos(start); - var position; - // we only get here if start !== end, so we can scan at least one time - do { - var kind = scanner.scan(); - position = scanner.getTextPos(); - cb(fullText, kind, { tokenStart: scanner.getTokenPos(), end: position, fullStart: start }, parent); - } while (position < end); - } - return handleTrivia; -} -/** - * Iterate over all comments owned by `node` or its children - * - * @deprecated use `forEachComment` from `tsutils` - */ -function forEachComment(node, cb) { - /* Visit all tokens and skip trivia. - Comment ranges between tokens are parsed without the need of a scanner. - forEachToken also does intentionally not pay attention to the correct comment ownership of nodes as it always - scans all trivia before each token, which could include trailing comments of the previous token. - Comment onwership is done right in this function*/ - return forEachToken(node, true, function (fullText, tokenKind, pos, parent) { - // don't search for comments inside JsxText - if (canHaveLeadingTrivia(tokenKind, parent)) { - // Comments before the first token (pos.fullStart === 0) are all considered leading comments, so no need for special treatment - var comments = ts.getLeadingCommentRanges(fullText, pos.fullStart); - if (comments !== undefined) { - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - cb(fullText, comment.kind, { fullStart: pos.fullStart, tokenStart: comment.pos, end: comment.end }); - } - } - } - if (canHaveTrailingTrivia(tokenKind, parent)) { - var comments = ts.getTrailingCommentRanges(fullText, pos.end); - if (comments !== undefined) { - for (var _a = 0, comments_2 = comments; _a < comments_2.length; _a++) { - var comment = comments_2[_a]; - cb(fullText, comment.kind, { fullStart: pos.fullStart, tokenStart: comment.pos, end: comment.end }); - } - } - } - }); -} -exports.forEachComment = forEachComment; -/** Exclude leading positions that would lead to scanning for trivia inside JsxText */ -function canHaveLeadingTrivia(tokenKind, parent) { - switch (tokenKind) { - case ts.SyntaxKind.JsxText: - return false; // there is no trivia before JsxText - case ts.SyntaxKind.OpenBraceToken: - // before a JsxExpression inside a JsxElement's body can only be other JsxChild, but no trivia - return parent.kind !== ts.SyntaxKind.JsxExpression || parent.parent.kind !== ts.SyntaxKind.JsxElement; - case ts.SyntaxKind.LessThanToken: - switch (parent.kind) { - case ts.SyntaxKind.JsxClosingElement: - return false; // would be inside the element body - case ts.SyntaxKind.JsxOpeningElement: - case ts.SyntaxKind.JsxSelfClosingElement: - // there can only be leading trivia if we are at the end of the top level element - return parent.parent.parent.kind !== ts.SyntaxKind.JsxElement; - default: - return true; - } - default: - return true; - } -} -/** Exclude trailing positions that would lead to scanning for trivia inside JsxText */ -function canHaveTrailingTrivia(tokenKind, parent) { - switch (tokenKind) { - case ts.SyntaxKind.JsxText: - // there is no trivia after JsxText - return false; - case ts.SyntaxKind.CloseBraceToken: - // after a JsxExpression inside a JsxElement's body can only be other JsxChild, but no trivia - return parent.kind !== ts.SyntaxKind.JsxExpression || parent.parent.kind !== ts.SyntaxKind.JsxElement; - case ts.SyntaxKind.GreaterThanToken: - switch (parent.kind) { - case ts.SyntaxKind.JsxOpeningElement: - return false; // would be inside the element - case ts.SyntaxKind.JsxClosingElement: - case ts.SyntaxKind.JsxSelfClosingElement: - // there can only be trailing trivia if we are at the end of the top level element - return parent.parent.parent.kind !== ts.SyntaxKind.JsxElement; - default: - return true; - } - default: - return true; - } -} -/** - * Checks if there are any comments between `position` and the next non-trivia token - * - * @param text The text to scan - * @param position The position inside `text` where to start scanning. Make sure that this is a valid start position. - * This value is typically obtained from `node.getFullStart()` or `node.getEnd()` - */ -function hasCommentAfterPosition(text, position) { - return ts.getTrailingCommentRanges(text, position) !== undefined || - ts.getLeadingCommentRanges(text, position) !== undefined; -} -exports.hasCommentAfterPosition = hasCommentAfterPosition; -function getEqualsKind(node) { - switch (node.kind) { - case ts.SyntaxKind.EqualsEqualsToken: - return { isPositive: true, isStrict: false }; - case ts.SyntaxKind.EqualsEqualsEqualsToken: - return { isPositive: true, isStrict: true }; - case ts.SyntaxKind.ExclamationEqualsToken: - return { isPositive: false, isStrict: false }; - case ts.SyntaxKind.ExclamationEqualsEqualsToken: - return { isPositive: false, isStrict: true }; - default: - return undefined; - } -} -exports.getEqualsKind = getEqualsKind; -function isStrictNullChecksEnabled(options) { - return options.strictNullChecks === true || - (options.strict === true && options.strictNullChecks !== false); -} -exports.isStrictNullChecksEnabled = isStrictNullChecksEnabled; -function isNegativeNumberLiteral(node) { - return tsutils_1.isPrefixUnaryExpression(node) && - node.operator === ts.SyntaxKind.MinusToken && - node.operand.kind === ts.SyntaxKind.NumericLiteral; -} -exports.isNegativeNumberLiteral = isNegativeNumberLiteral; -/** Wrapper for compatibility with typescript@<2.3.1 */ -function isWhiteSpace(ch) { - // tslint:disable-next-line - return (ts.isWhiteSpaceLike || ts.isWhiteSpace)(ch); -} -exports.isWhiteSpace = isWhiteSpace; diff --git a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts deleted file mode 100644 index 0fd097cc7..000000000 --- a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { IOptions } from "../rule/rule"; -import { ScopeAwareRuleWalker } from "./scopeAwareRuleWalker"; -/** - * @deprecated See comment on ScopeAwareRuleWalker. - * - * An AST walker that is aware of block scopes in addition to regular scopes. Block scopes - * are a superset of regular scopes (new block scopes are created more frequently in a program). - */ -export declare abstract class BlockScopeAwareRuleWalker<T, U> extends ScopeAwareRuleWalker<T> { - private readonly blockScopeStack; - constructor(sourceFile: ts.SourceFile, options: IOptions); - abstract createBlockScope(node: ts.Node): U; - getAllBlockScopes(): U[]; - getCurrentBlockScope(): U; - getCurrentBlockDepth(): number; - onBlockScopeStart(): void; - onBlockScopeEnd(): void; - findBlockScope(predicate: (scope: U) => boolean): U | undefined; - protected visitNode(node: ts.Node): void; - private isBlockScopeBoundary; -} diff --git a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js deleted file mode 100644 index 2bfe8865f..000000000 --- a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var utils_1 = require("../utils"); -var scopeAwareRuleWalker_1 = require("./scopeAwareRuleWalker"); -// tslint:disable:deprecation (extends deprecated class and uses deprecated utils - doesn't matter because it's deprecated, too) -/** - * @deprecated See comment on ScopeAwareRuleWalker. - * - * An AST walker that is aware of block scopes in addition to regular scopes. Block scopes - * are a superset of regular scopes (new block scopes are created more frequently in a program). - */ -var BlockScopeAwareRuleWalker = /** @class */ (function (_super) { - tslib_1.__extends(BlockScopeAwareRuleWalker, _super); - function BlockScopeAwareRuleWalker(sourceFile, options) { - var _this = _super.call(this, sourceFile, options) || this; - // initialize with global scope if file is not a module - _this.blockScopeStack = ts.isExternalModule(sourceFile) ? [] : [_this.createBlockScope(sourceFile)]; - return _this; - } - // get all block scopes available at this depth - BlockScopeAwareRuleWalker.prototype.getAllBlockScopes = function () { - return this.blockScopeStack; - }; - BlockScopeAwareRuleWalker.prototype.getCurrentBlockScope = function () { - return this.blockScopeStack[this.blockScopeStack.length - 1]; - }; - BlockScopeAwareRuleWalker.prototype.getCurrentBlockDepth = function () { - return this.blockScopeStack.length; - }; - // callback notifier when a block scope begins - BlockScopeAwareRuleWalker.prototype.onBlockScopeStart = function () { - return; - }; - // callback notifier when a block scope ends - BlockScopeAwareRuleWalker.prototype.onBlockScopeEnd = function () { - return; - }; - BlockScopeAwareRuleWalker.prototype.findBlockScope = function (predicate) { - // look through block scopes from local -> global - for (var i = this.blockScopeStack.length - 1; i >= 0; i--) { - if (predicate(this.blockScopeStack[i])) { - return this.blockScopeStack[i]; - } - } - return undefined; - }; - BlockScopeAwareRuleWalker.prototype.visitNode = function (node) { - var isNewBlockScope = this.isBlockScopeBoundary(node); - if (isNewBlockScope) { - this.blockScopeStack.push(this.createBlockScope(node)); - this.onBlockScopeStart(); - } - _super.prototype.visitNode.call(this, node); - if (isNewBlockScope) { - this.onBlockScopeEnd(); - this.blockScopeStack.pop(); - } - }; - BlockScopeAwareRuleWalker.prototype.isBlockScopeBoundary = function (node) { - return utils_1.isBlockScopeBoundary(node); - }; - return BlockScopeAwareRuleWalker; -}(scopeAwareRuleWalker_1.ScopeAwareRuleWalker)); -exports.BlockScopeAwareRuleWalker = BlockScopeAwareRuleWalker; diff --git a/node_modules/tslint/lib/language/walker/index.d.ts b/node_modules/tslint/lib/language/walker/index.d.ts deleted file mode 100644 index db3dc9492..000000000 --- a/node_modules/tslint/lib/language/walker/index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export * from "./blockScopeAwareRuleWalker"; -export * from "./programAwareRuleWalker"; -export * from "./ruleWalker"; -export * from "./scopeAwareRuleWalker"; -export * from "./syntaxWalker"; -export * from "./walkContext"; -export * from "./walker"; diff --git a/node_modules/tslint/lib/language/walker/index.js b/node_modules/tslint/lib/language/walker/index.js deleted file mode 100644 index d4388e27d..000000000 --- a/node_modules/tslint/lib/language/walker/index.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./blockScopeAwareRuleWalker"), exports); -tslib_1.__exportStar(require("./programAwareRuleWalker"), exports); -tslib_1.__exportStar(require("./ruleWalker"), exports); -tslib_1.__exportStar(require("./scopeAwareRuleWalker"), exports); -tslib_1.__exportStar(require("./syntaxWalker"), exports); -tslib_1.__exportStar(require("./walkContext"), exports); -tslib_1.__exportStar(require("./walker"), exports); diff --git a/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts b/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts deleted file mode 100644 index 8f949a03a..000000000 --- a/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { IOptions } from "../rule/rule"; -import { RuleWalker } from "./ruleWalker"; -export declare class ProgramAwareRuleWalker extends RuleWalker { - private readonly program; - private readonly typeChecker; - constructor(sourceFile: ts.SourceFile, options: IOptions, program: ts.Program); - getProgram(): ts.Program; - getTypeChecker(): ts.TypeChecker; -} diff --git a/node_modules/tslint/lib/language/walker/programAwareRuleWalker.js b/node_modules/tslint/lib/language/walker/programAwareRuleWalker.js deleted file mode 100644 index 1a0702441..000000000 --- a/node_modules/tslint/lib/language/walker/programAwareRuleWalker.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ruleWalker_1 = require("./ruleWalker"); -var ProgramAwareRuleWalker = /** @class */ (function (_super) { - tslib_1.__extends(ProgramAwareRuleWalker, _super); - function ProgramAwareRuleWalker(sourceFile, options, program) { - var _this = _super.call(this, sourceFile, options) || this; - _this.program = program; - _this.typeChecker = program.getTypeChecker(); - return _this; - } - ProgramAwareRuleWalker.prototype.getProgram = function () { - return this.program; - }; - ProgramAwareRuleWalker.prototype.getTypeChecker = function () { - return this.typeChecker; - }; - return ProgramAwareRuleWalker; -}(ruleWalker_1.RuleWalker)); -exports.ProgramAwareRuleWalker = ProgramAwareRuleWalker; diff --git a/node_modules/tslint/lib/language/walker/ruleWalker.d.ts b/node_modules/tslint/lib/language/walker/ruleWalker.d.ts deleted file mode 100644 index 9d27e8bcb..000000000 --- a/node_modules/tslint/lib/language/walker/ruleWalker.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { Fix, IOptions, Replacement, RuleFailure } from "../rule/rule"; -import { SyntaxWalker } from "./syntaxWalker"; -import { IWalker } from "./walker"; -export declare class RuleWalker extends SyntaxWalker implements IWalker { - private readonly sourceFile; - private readonly limit; - private readonly options?; - private readonly failures; - private readonly ruleName; - constructor(sourceFile: ts.SourceFile, options: IOptions); - getSourceFile(): ts.SourceFile; - getLineAndCharacterOfPosition(position: number): ts.LineAndCharacter; - getFailures(): RuleFailure[]; - getLimit(): number; - getOptions(): any; - hasOption(option: string): boolean; - /** @deprecated Prefer `addFailureAt` and its variants. */ - createFailure(start: number, width: number, failure: string, fix?: Fix): RuleFailure; - /** @deprecated Prefer `addFailureAt` and its variants. */ - addFailure(failure: RuleFailure): void; - /** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */ - addFailureAt(start: number, width: number, failure: string, fix?: Fix): void; - /** Like `addFailureAt` but uses start and end instead of start and width. */ - addFailureFromStartToEnd(start: number, end: number, failure: string, fix?: Fix): void; - /** Add a failure using a node's span. */ - addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void; - createReplacement(start: number, length: number, text: string): Replacement; - appendText(start: number, text: string): Replacement; - deleteText(start: number, length: number): Replacement; - deleteFromTo(start: number, end: number): Replacement; - getRuleName(): string; -} diff --git a/node_modules/tslint/lib/language/walker/ruleWalker.js b/node_modules/tslint/lib/language/walker/ruleWalker.js deleted file mode 100644 index e0e77504e..000000000 --- a/node_modules/tslint/lib/language/walker/ruleWalker.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var rule_1 = require("../rule/rule"); -var syntaxWalker_1 = require("./syntaxWalker"); -var RuleWalker = /** @class */ (function (_super) { - tslib_1.__extends(RuleWalker, _super); - function RuleWalker(sourceFile, options) { - var _this = _super.call(this) || this; - _this.sourceFile = sourceFile; - _this.failures = []; - _this.options = options.ruleArguments; - _this.limit = _this.sourceFile.getFullWidth(); - _this.ruleName = options.ruleName; - return _this; - } - RuleWalker.prototype.getSourceFile = function () { - return this.sourceFile; - }; - RuleWalker.prototype.getLineAndCharacterOfPosition = function (position) { - return this.sourceFile.getLineAndCharacterOfPosition(position); - }; - RuleWalker.prototype.getFailures = function () { - return this.failures; - }; - RuleWalker.prototype.getLimit = function () { - return this.limit; - }; - RuleWalker.prototype.getOptions = function () { - return this.options; - }; - RuleWalker.prototype.hasOption = function (option) { - if (this.options !== undefined) { - return this.options.indexOf(option) !== -1; - } - else { - return false; - } - }; - /** @deprecated Prefer `addFailureAt` and its variants. */ - RuleWalker.prototype.createFailure = function (start, width, failure, fix) { - var from = (start > this.limit) ? this.limit : start; - var to = ((start + width) > this.limit) ? this.limit : (start + width); - return new rule_1.RuleFailure(this.sourceFile, from, to, failure, this.ruleName, fix); - }; - /** @deprecated Prefer `addFailureAt` and its variants. */ - RuleWalker.prototype.addFailure = function (failure) { - this.failures.push(failure); - }; - /** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */ - RuleWalker.prototype.addFailureAt = function (start, width, failure, fix) { - // tslint:disable-next-line deprecation - this.addFailure(this.createFailure(start, width, failure, fix)); - }; - /** Like `addFailureAt` but uses start and end instead of start and width. */ - RuleWalker.prototype.addFailureFromStartToEnd = function (start, end, failure, fix) { - this.addFailureAt(start, end - start, failure, fix); - }; - /** Add a failure using a node's span. */ - RuleWalker.prototype.addFailureAtNode = function (node, failure, fix) { - this.addFailureAt(node.getStart(this.sourceFile), node.getWidth(this.sourceFile), failure, fix); - }; - RuleWalker.prototype.createReplacement = function (start, length, text) { - return new rule_1.Replacement(start, length, text); - }; - RuleWalker.prototype.appendText = function (start, text) { - return this.createReplacement(start, 0, text); - }; - RuleWalker.prototype.deleteText = function (start, length) { - return this.createReplacement(start, length, ""); - }; - RuleWalker.prototype.deleteFromTo = function (start, end) { - return this.createReplacement(start, end - start, ""); - }; - RuleWalker.prototype.getRuleName = function () { - return this.ruleName; - }; - return RuleWalker; -}(syntaxWalker_1.SyntaxWalker)); -exports.RuleWalker = RuleWalker; diff --git a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts b/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts deleted file mode 100644 index dbb21a9f6..000000000 --- a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { IOptions } from "../rule/rule"; -import { RuleWalker } from "./ruleWalker"; -/** - * @deprecated Prefer to manually maintain any contextual information. - * - * For example, imagine a `no-break` rule that warns on `break` in `for` but not in `switch`: - * - * function walk(ctx: Lint.WalkContext<void>): void { - * let isInFor = false; - * ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void { - * switch (node.kind) { - * case ts.SyntaxKind.Break: - * if (isInFor) { - * ctx.addFailureAtNode(node, "!"); - * } - * break; - * case ts.SyntaxKind.ForStatement: { - * const old = isInFor; - * isInFor = true; - * ts.forEachChild(node, cb); - * isInFor = old; - * break; - * } - * case ts.SyntaxKind.SwitchStatement: { - * const old = isInFor; - * isInFor = false; - * ts.forEachChild(node, cb); - * isInFor = old; - * break; - * } - * default: - * ts.forEachChild(node, cb); - * } - * }); - * } - */ -export declare abstract class ScopeAwareRuleWalker<T> extends RuleWalker { - private readonly scopeStack; - constructor(sourceFile: ts.SourceFile, options: IOptions); - abstract createScope(node: ts.Node): T; - getCurrentScope(): T; - getAllScopes(): T[]; - getCurrentDepth(): number; - onScopeStart(): void; - onScopeEnd(): void; - protected visitNode(node: ts.Node): void; - protected isScopeBoundary(node: ts.Node): boolean; -} diff --git a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js b/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js deleted file mode 100644 index 15cf26478..000000000 --- a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js +++ /dev/null @@ -1,100 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var utils_1 = require("../utils"); -var ruleWalker_1 = require("./ruleWalker"); -/** - * @deprecated Prefer to manually maintain any contextual information. - * - * For example, imagine a `no-break` rule that warns on `break` in `for` but not in `switch`: - * - * function walk(ctx: Lint.WalkContext<void>): void { - * let isInFor = false; - * ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void { - * switch (node.kind) { - * case ts.SyntaxKind.Break: - * if (isInFor) { - * ctx.addFailureAtNode(node, "!"); - * } - * break; - * case ts.SyntaxKind.ForStatement: { - * const old = isInFor; - * isInFor = true; - * ts.forEachChild(node, cb); - * isInFor = old; - * break; - * } - * case ts.SyntaxKind.SwitchStatement: { - * const old = isInFor; - * isInFor = false; - * ts.forEachChild(node, cb); - * isInFor = old; - * break; - * } - * default: - * ts.forEachChild(node, cb); - * } - * }); - * } - */ -var ScopeAwareRuleWalker = /** @class */ (function (_super) { - tslib_1.__extends(ScopeAwareRuleWalker, _super); - function ScopeAwareRuleWalker(sourceFile, options) { - var _this = _super.call(this, sourceFile, options) || this; - // initialize with global scope if file is not a module - _this.scopeStack = ts.isExternalModule(sourceFile) ? [] : [_this.createScope(sourceFile)]; - return _this; - } - ScopeAwareRuleWalker.prototype.getCurrentScope = function () { - return this.scopeStack[this.scopeStack.length - 1]; - }; - // get all scopes available at this depth - ScopeAwareRuleWalker.prototype.getAllScopes = function () { - return this.scopeStack; - }; - ScopeAwareRuleWalker.prototype.getCurrentDepth = function () { - return this.scopeStack.length; - }; - // callback notifier when a scope begins - ScopeAwareRuleWalker.prototype.onScopeStart = function () { - return; - }; - // callback notifier when a scope ends - ScopeAwareRuleWalker.prototype.onScopeEnd = function () { - return; - }; - ScopeAwareRuleWalker.prototype.visitNode = function (node) { - var isNewScope = this.isScopeBoundary(node); - if (isNewScope) { - this.scopeStack.push(this.createScope(node)); - this.onScopeStart(); - } - _super.prototype.visitNode.call(this, node); - if (isNewScope) { - this.onScopeEnd(); - this.scopeStack.pop(); - } - }; - ScopeAwareRuleWalker.prototype.isScopeBoundary = function (node) { - return utils_1.isScopeBoundary(node); // tslint:disable-line:deprecation - }; - return ScopeAwareRuleWalker; -}(ruleWalker_1.RuleWalker)); -exports.ScopeAwareRuleWalker = ScopeAwareRuleWalker; diff --git a/node_modules/tslint/lib/language/walker/syntaxWalker.d.ts b/node_modules/tslint/lib/language/walker/syntaxWalker.d.ts deleted file mode 100644 index 8cc39ef61..000000000 --- a/node_modules/tslint/lib/language/walker/syntaxWalker.d.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -export declare class SyntaxWalker { - walk(node: ts.Node): void; - protected visitAnyKeyword(node: ts.Node): void; - protected visitArrayLiteralExpression(node: ts.ArrayLiteralExpression): void; - protected visitArrayType(node: ts.ArrayTypeNode): void; - protected visitArrowFunction(node: ts.ArrowFunction): void; - protected visitBinaryExpression(node: ts.BinaryExpression): void; - protected visitBindingElement(node: ts.BindingElement): void; - protected visitBindingPattern(node: ts.BindingPattern): void; - protected visitBlock(node: ts.Block): void; - protected visitBreakStatement(node: ts.BreakOrContinueStatement): void; - protected visitCallExpression(node: ts.CallExpression): void; - protected visitCallSignature(node: ts.SignatureDeclaration): void; - protected visitCaseClause(node: ts.CaseClause): void; - protected visitClassDeclaration(node: ts.ClassDeclaration): void; - protected visitClassExpression(node: ts.ClassExpression): void; - protected visitCatchClause(node: ts.CatchClause): void; - protected visitConditionalExpression(node: ts.ConditionalExpression): void; - protected visitConstructSignature(node: ts.ConstructSignatureDeclaration): void; - protected visitConstructorDeclaration(node: ts.ConstructorDeclaration): void; - protected visitConstructorType(node: ts.FunctionOrConstructorTypeNode): void; - protected visitContinueStatement(node: ts.BreakOrContinueStatement): void; - protected visitDebuggerStatement(node: ts.Statement): void; - protected visitDefaultClause(node: ts.DefaultClause): void; - protected visitDoStatement(node: ts.DoStatement): void; - protected visitElementAccessExpression(node: ts.ElementAccessExpression): void; - protected visitEndOfFileToken(node: ts.Node): void; - protected visitEnumDeclaration(node: ts.EnumDeclaration): void; - protected visitEnumMember(node: ts.EnumMember): void; - protected visitExportAssignment(node: ts.ExportAssignment): void; - protected visitExpressionStatement(node: ts.ExpressionStatement): void; - protected visitForStatement(node: ts.ForStatement): void; - protected visitForInStatement(node: ts.ForInStatement): void; - protected visitForOfStatement(node: ts.ForOfStatement): void; - protected visitFunctionDeclaration(node: ts.FunctionDeclaration): void; - protected visitFunctionExpression(node: ts.FunctionExpression): void; - protected visitFunctionType(node: ts.FunctionOrConstructorTypeNode): void; - protected visitGetAccessor(node: ts.AccessorDeclaration): void; - protected visitIdentifier(node: ts.Identifier): void; - protected visitIfStatement(node: ts.IfStatement): void; - protected visitImportDeclaration(node: ts.ImportDeclaration): void; - protected visitImportEqualsDeclaration(node: ts.ImportEqualsDeclaration): void; - protected visitIndexSignatureDeclaration(node: ts.IndexSignatureDeclaration): void; - protected visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void; - protected visitJsxAttribute(node: ts.JsxAttribute): void; - protected visitJsxElement(node: ts.JsxElement): void; - protected visitJsxExpression(node: ts.JsxExpression): void; - protected visitJsxSelfClosingElement(node: ts.JsxSelfClosingElement): void; - protected visitJsxSpreadAttribute(node: ts.JsxSpreadAttribute): void; - protected visitLabeledStatement(node: ts.LabeledStatement): void; - protected visitMethodDeclaration(node: ts.MethodDeclaration): void; - protected visitMethodSignature(node: ts.SignatureDeclaration): void; - protected visitModuleDeclaration(node: ts.ModuleDeclaration): void; - protected visitNamedImports(node: ts.NamedImports): void; - protected visitNamespaceImport(node: ts.NamespaceImport): void; - protected visitNewExpression(node: ts.NewExpression): void; - protected visitNonNullExpression(node: ts.NonNullExpression): void; - protected visitNumericLiteral(node: ts.NumericLiteral): void; - protected visitObjectLiteralExpression(node: ts.ObjectLiteralExpression): void; - protected visitParameterDeclaration(node: ts.ParameterDeclaration): void; - protected visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression): void; - protected visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression): void; - protected visitPropertyAccessExpression(node: ts.PropertyAccessExpression): void; - protected visitPropertyAssignment(node: ts.PropertyAssignment): void; - protected visitPropertyDeclaration(node: ts.PropertyDeclaration): void; - protected visitPropertySignature(node: ts.Node): void; - protected visitRegularExpressionLiteral(node: ts.Node): void; - protected visitReturnStatement(node: ts.ReturnStatement): void; - protected visitSetAccessor(node: ts.AccessorDeclaration): void; - protected visitSourceFile(node: ts.SourceFile): void; - protected visitStringLiteral(node: ts.StringLiteral): void; - protected visitSwitchStatement(node: ts.SwitchStatement): void; - protected visitTemplateExpression(node: ts.TemplateExpression): void; - protected visitThrowStatement(node: ts.ThrowStatement): void; - protected visitTryStatement(node: ts.TryStatement): void; - protected visitTupleType(node: ts.TupleTypeNode): void; - protected visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration): void; - protected visitTypeAssertionExpression(node: ts.TypeAssertion): void; - protected visitTypeLiteral(node: ts.TypeLiteralNode): void; - protected visitTypeReference(node: ts.TypeReferenceNode): void; - protected visitVariableDeclaration(node: ts.VariableDeclaration): void; - protected visitVariableDeclarationList(node: ts.VariableDeclarationList): void; - protected visitVariableStatement(node: ts.VariableStatement): void; - protected visitWhileStatement(node: ts.WhileStatement): void; - protected visitWithStatement(node: ts.WithStatement): void; - protected visitNode(node: ts.Node): void; - protected walkChildren(node: ts.Node): void; -} diff --git a/node_modules/tslint/lib/language/walker/syntaxWalker.js b/node_modules/tslint/lib/language/walker/syntaxWalker.js deleted file mode 100644 index cdef4eaea..000000000 --- a/node_modules/tslint/lib/language/walker/syntaxWalker.js +++ /dev/null @@ -1,539 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var ts = require("typescript"); -var SyntaxWalker = /** @class */ (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.walk = function (node) { - this.visitNode(node); - }; - SyntaxWalker.prototype.visitAnyKeyword = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitArrayType = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitArrowFunction = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitBindingElement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitBindingPattern = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitBlock = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitCallExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitCaseClause = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitClassExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitDefaultClause = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitEndOfFileToken = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitEnumMember = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitForStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitForOfStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitIdentifier = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitImportEqualsDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitIndexSignatureDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitJsxAttribute = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitJsxElement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitJsxExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitJsxSelfClosingElement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitJsxSpreadAttribute = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitMethodDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitNamedImports = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitNamespaceImport = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitNewExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitNonNullExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitNumericLiteral = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitParameterDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitPropertyAccessExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitPropertyAssignment = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitPropertyDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitRegularExpressionLiteral = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitSourceFile = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitStringLiteral = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTemplateExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTupleType = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTypeAliasDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTypeAssertionExpression = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTypeLiteral = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitTypeReference = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitVariableDeclarationList = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.walkChildren(node); - }; - SyntaxWalker.prototype.visitNode = function (node) { - switch (node.kind) { - case ts.SyntaxKind.AnyKeyword: - this.visitAnyKeyword(node); - break; - case ts.SyntaxKind.ArrayBindingPattern: - this.visitBindingPattern(node); - break; - case ts.SyntaxKind.ArrayLiteralExpression: - this.visitArrayLiteralExpression(node); - break; - case ts.SyntaxKind.ArrayType: - this.visitArrayType(node); - break; - case ts.SyntaxKind.ArrowFunction: - this.visitArrowFunction(node); - break; - case ts.SyntaxKind.BinaryExpression: - this.visitBinaryExpression(node); - break; - case ts.SyntaxKind.BindingElement: - this.visitBindingElement(node); - break; - case ts.SyntaxKind.Block: - this.visitBlock(node); - break; - case ts.SyntaxKind.BreakStatement: - this.visitBreakStatement(node); - break; - case ts.SyntaxKind.CallExpression: - this.visitCallExpression(node); - break; - case ts.SyntaxKind.CallSignature: - this.visitCallSignature(node); - break; - case ts.SyntaxKind.CaseClause: - this.visitCaseClause(node); - break; - case ts.SyntaxKind.ClassDeclaration: - this.visitClassDeclaration(node); - break; - case ts.SyntaxKind.ClassExpression: - this.visitClassExpression(node); - break; - case ts.SyntaxKind.CatchClause: - this.visitCatchClause(node); - break; - case ts.SyntaxKind.ConditionalExpression: - this.visitConditionalExpression(node); - break; - case ts.SyntaxKind.ConstructSignature: - this.visitConstructSignature(node); - break; - case ts.SyntaxKind.Constructor: - this.visitConstructorDeclaration(node); - break; - case ts.SyntaxKind.ConstructorType: - this.visitConstructorType(node); - break; - case ts.SyntaxKind.ContinueStatement: - this.visitContinueStatement(node); - break; - case ts.SyntaxKind.DebuggerStatement: - this.visitDebuggerStatement(node); - break; - case ts.SyntaxKind.DefaultClause: - this.visitDefaultClause(node); - break; - case ts.SyntaxKind.DoStatement: - this.visitDoStatement(node); - break; - case ts.SyntaxKind.ElementAccessExpression: - this.visitElementAccessExpression(node); - break; - case ts.SyntaxKind.EndOfFileToken: - this.visitEndOfFileToken(node); - break; - case ts.SyntaxKind.EnumDeclaration: - this.visitEnumDeclaration(node); - break; - case ts.SyntaxKind.EnumMember: - this.visitEnumMember(node); - break; - case ts.SyntaxKind.ExportAssignment: - this.visitExportAssignment(node); - break; - case ts.SyntaxKind.ExpressionStatement: - this.visitExpressionStatement(node); - break; - case ts.SyntaxKind.ForStatement: - this.visitForStatement(node); - break; - case ts.SyntaxKind.ForInStatement: - this.visitForInStatement(node); - break; - case ts.SyntaxKind.ForOfStatement: - this.visitForOfStatement(node); - break; - case ts.SyntaxKind.FunctionDeclaration: - this.visitFunctionDeclaration(node); - break; - case ts.SyntaxKind.FunctionExpression: - this.visitFunctionExpression(node); - break; - case ts.SyntaxKind.FunctionType: - this.visitFunctionType(node); - break; - case ts.SyntaxKind.GetAccessor: - this.visitGetAccessor(node); - break; - case ts.SyntaxKind.Identifier: - this.visitIdentifier(node); - break; - case ts.SyntaxKind.IfStatement: - this.visitIfStatement(node); - break; - case ts.SyntaxKind.ImportDeclaration: - this.visitImportDeclaration(node); - break; - case ts.SyntaxKind.ImportEqualsDeclaration: - this.visitImportEqualsDeclaration(node); - break; - case ts.SyntaxKind.IndexSignature: - this.visitIndexSignatureDeclaration(node); - break; - case ts.SyntaxKind.InterfaceDeclaration: - this.visitInterfaceDeclaration(node); - break; - case ts.SyntaxKind.JsxAttribute: - this.visitJsxAttribute(node); - break; - case ts.SyntaxKind.JsxElement: - this.visitJsxElement(node); - break; - case ts.SyntaxKind.JsxExpression: - this.visitJsxExpression(node); - break; - case ts.SyntaxKind.JsxSelfClosingElement: - this.visitJsxSelfClosingElement(node); - break; - case ts.SyntaxKind.JsxSpreadAttribute: - this.visitJsxSpreadAttribute(node); - break; - case ts.SyntaxKind.LabeledStatement: - this.visitLabeledStatement(node); - break; - case ts.SyntaxKind.MethodDeclaration: - this.visitMethodDeclaration(node); - break; - case ts.SyntaxKind.MethodSignature: - this.visitMethodSignature(node); - break; - case ts.SyntaxKind.ModuleDeclaration: - this.visitModuleDeclaration(node); - break; - case ts.SyntaxKind.NamedImports: - this.visitNamedImports(node); - break; - case ts.SyntaxKind.NamespaceImport: - this.visitNamespaceImport(node); - break; - case ts.SyntaxKind.NewExpression: - this.visitNewExpression(node); - break; - case ts.SyntaxKind.NonNullExpression: - this.visitNonNullExpression(node); - break; - case ts.SyntaxKind.NumericLiteral: - this.visitNumericLiteral(node); - break; - case ts.SyntaxKind.ObjectBindingPattern: - this.visitBindingPattern(node); - break; - case ts.SyntaxKind.ObjectLiteralExpression: - this.visitObjectLiteralExpression(node); - break; - case ts.SyntaxKind.Parameter: - this.visitParameterDeclaration(node); - break; - case ts.SyntaxKind.PostfixUnaryExpression: - this.visitPostfixUnaryExpression(node); - break; - case ts.SyntaxKind.PrefixUnaryExpression: - this.visitPrefixUnaryExpression(node); - break; - case ts.SyntaxKind.PropertyAccessExpression: - this.visitPropertyAccessExpression(node); - break; - case ts.SyntaxKind.PropertyAssignment: - this.visitPropertyAssignment(node); - break; - case ts.SyntaxKind.PropertyDeclaration: - this.visitPropertyDeclaration(node); - break; - case ts.SyntaxKind.PropertySignature: - this.visitPropertySignature(node); - break; - case ts.SyntaxKind.RegularExpressionLiteral: - this.visitRegularExpressionLiteral(node); - break; - case ts.SyntaxKind.ReturnStatement: - this.visitReturnStatement(node); - break; - case ts.SyntaxKind.SetAccessor: - this.visitSetAccessor(node); - break; - case ts.SyntaxKind.SourceFile: - this.visitSourceFile(node); - break; - case ts.SyntaxKind.StringLiteral: - this.visitStringLiteral(node); - break; - case ts.SyntaxKind.SwitchStatement: - this.visitSwitchStatement(node); - break; - case ts.SyntaxKind.TemplateExpression: - this.visitTemplateExpression(node); - break; - case ts.SyntaxKind.ThrowStatement: - this.visitThrowStatement(node); - break; - case ts.SyntaxKind.TryStatement: - this.visitTryStatement(node); - break; - case ts.SyntaxKind.TupleType: - this.visitTupleType(node); - break; - case ts.SyntaxKind.TypeAliasDeclaration: - this.visitTypeAliasDeclaration(node); - break; - case ts.SyntaxKind.TypeAssertionExpression: - this.visitTypeAssertionExpression(node); - break; - case ts.SyntaxKind.TypeLiteral: - this.visitTypeLiteral(node); - break; - case ts.SyntaxKind.TypeReference: - this.visitTypeReference(node); - break; - case ts.SyntaxKind.VariableDeclaration: - this.visitVariableDeclaration(node); - break; - case ts.SyntaxKind.VariableDeclarationList: - this.visitVariableDeclarationList(node); - break; - case ts.SyntaxKind.VariableStatement: - this.visitVariableStatement(node); - break; - case ts.SyntaxKind.WhileStatement: - this.visitWhileStatement(node); - break; - case ts.SyntaxKind.WithStatement: - this.visitWithStatement(node); - break; - default: - this.walkChildren(node); - } - }; - SyntaxWalker.prototype.walkChildren = function (node) { - var _this = this; - ts.forEachChild(node, function (child) { return _this.visitNode(child); }); - }; - return SyntaxWalker; -}()); -exports.SyntaxWalker = SyntaxWalker; diff --git a/node_modules/tslint/lib/language/walker/walkContext.d.ts b/node_modules/tslint/lib/language/walker/walkContext.d.ts deleted file mode 100644 index 38a413f3d..000000000 --- a/node_modules/tslint/lib/language/walker/walkContext.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { Fix, RuleFailure } from "../rule/rule"; -export declare class WalkContext<T> { - readonly sourceFile: ts.SourceFile; - readonly ruleName: string; - readonly options: T; - readonly failures: RuleFailure[]; - constructor(sourceFile: ts.SourceFile, ruleName: string, options: T); - /** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */ - addFailureAt(start: number, width: number, failure: string, fix?: Fix): void; - addFailure(start: number, end: number, failure: string, fix?: Fix): void; - /** Add a failure using a node's span. */ - addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void; -} diff --git a/node_modules/tslint/lib/language/walker/walkContext.js b/node_modules/tslint/lib/language/walker/walkContext.js deleted file mode 100644 index ad0c5e597..000000000 --- a/node_modules/tslint/lib/language/walker/walkContext.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var rule_1 = require("../rule/rule"); -var WalkContext = /** @class */ (function () { - function WalkContext(sourceFile, ruleName, options) { - this.sourceFile = sourceFile; - this.ruleName = ruleName; - this.options = options; - this.failures = []; - } - /** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */ - WalkContext.prototype.addFailureAt = function (start, width, failure, fix) { - this.addFailure(start, start + width, failure, fix); - }; - WalkContext.prototype.addFailure = function (start, end, failure, fix) { - var fileLength = this.sourceFile.end; - this.failures.push(new rule_1.RuleFailure(this.sourceFile, Math.min(start, fileLength), Math.min(end, fileLength), failure, this.ruleName, fix)); - }; - /** Add a failure using a node's span. */ - WalkContext.prototype.addFailureAtNode = function (node, failure, fix) { - this.addFailure(node.getStart(this.sourceFile), node.getEnd(), failure, fix); - }; - return WalkContext; -}()); -exports.WalkContext = WalkContext; diff --git a/node_modules/tslint/lib/language/walker/walker.d.ts b/node_modules/tslint/lib/language/walker/walker.d.ts deleted file mode 100644 index f08b06e75..000000000 --- a/node_modules/tslint/lib/language/walker/walker.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { RuleFailure } from "../rule/rule"; -import { WalkContext } from "./walkContext"; -export interface IWalker { - getSourceFile(): ts.SourceFile; - walk(sourceFile: ts.SourceFile): void; - getFailures(): RuleFailure[]; -} -export declare abstract class AbstractWalker<T> extends WalkContext<T> implements IWalker { - abstract walk(sourceFile: ts.SourceFile): void; - getSourceFile(): ts.SourceFile; - getFailures(): RuleFailure[]; -} diff --git a/node_modules/tslint/lib/language/walker/walker.js b/node_modules/tslint/lib/language/walker/walker.js deleted file mode 100644 index 9b78e7693..000000000 --- a/node_modules/tslint/lib/language/walker/walker.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var walkContext_1 = require("./walkContext"); -var AbstractWalker = /** @class */ (function (_super) { - tslib_1.__extends(AbstractWalker, _super); - function AbstractWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - AbstractWalker.prototype.getSourceFile = function () { - return this.sourceFile; - }; - AbstractWalker.prototype.getFailures = function () { - return this.failures; - }; - return AbstractWalker; -}(walkContext_1.WalkContext)); -exports.AbstractWalker = AbstractWalker; diff --git a/node_modules/tslint/lib/linter.d.ts b/node_modules/tslint/lib/linter.d.ts deleted file mode 100644 index a5d54f758..000000000 --- a/node_modules/tslint/lib/linter.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { findConfiguration, findConfigurationPath, getRulesDirectories, IConfigurationFile, loadConfigurationFromPath } from "./configuration"; -import { ILinterOptions, LintResult } from "./index"; -import { RuleFailure } from "./language/rule/rule"; -/** - * Linter that can lint multiple files in consecutive runs. - */ -export declare class Linter { - private readonly options; - private program?; - static VERSION: string; - static findConfiguration: typeof findConfiguration; - static findConfigurationPath: typeof findConfigurationPath; - static getRulesDirectories: typeof getRulesDirectories; - static loadConfigurationFromPath: typeof loadConfigurationFromPath; - private failures; - private fixes; - /** - * Creates a TypeScript program object from a tsconfig.json file path and optional project directory. - */ - static createProgram(configFile: string, projectDirectory?: string): ts.Program; - /** - * Returns a list of source file names from a TypeScript program. This includes all referenced - * files and excludes declaration (".d.ts") files. - */ - static getFileNames(program: ts.Program): string[]; - constructor(options: ILinterOptions, program?: ts.Program | undefined); - lint(fileName: string, source: string, configuration?: IConfigurationFile): void; - getResult(): LintResult; - private getAllFailures; - private applyAllFixes; - protected applyFixes(sourceFilePath: string, source: string, fixableFailures: RuleFailure[]): string; - private updateProgram; - private applyRule; - private getEnabledRules; - private getSourceFile; -} diff --git a/node_modules/tslint/lib/linter.js b/node_modules/tslint/lib/linter.js deleted file mode 100644 index 4c642d922..000000000 --- a/node_modules/tslint/lib/linter.js +++ /dev/null @@ -1,256 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var fs = require("fs"); -var path = require("path"); -var ts = require("typescript"); -var configuration_1 = require("./configuration"); -var enableDisableRules_1 = require("./enableDisableRules"); -var error_1 = require("./error"); -var formatterLoader_1 = require("./formatterLoader"); -var rule_1 = require("./language/rule/rule"); -var utils = require("./language/utils"); -var ruleLoader_1 = require("./ruleLoader"); -var utils_1 = require("./utils"); -/** - * Linter that can lint multiple files in consecutive runs. - */ -var Linter = /** @class */ (function () { - function Linter(options, program) { - this.options = options; - this.program = program; - this.failures = []; - this.fixes = []; - if (typeof options !== "object") { - throw new Error("Unknown Linter options type: " + typeof options); - } - if (options.configuration != undefined) { - throw new Error("ILinterOptions does not contain the property `configuration` as of version 4. " + - "Did you mean to pass the `IConfigurationFile` object to lint() ? "); - } - } - /** - * Creates a TypeScript program object from a tsconfig.json file path and optional project directory. - */ - Linter.createProgram = function (configFile, projectDirectory) { - if (projectDirectory === void 0) { projectDirectory = path.dirname(configFile); } - var config = ts.readConfigFile(configFile, ts.sys.readFile); - if (config.error !== undefined) { - throw new error_1.FatalError(ts.formatDiagnostics([config.error], { - getCanonicalFileName: function (f) { return f; }, - getCurrentDirectory: process.cwd, - getNewLine: function () { return "\n"; }, - })); - } - var parseConfigHost = { - fileExists: fs.existsSync, - readDirectory: ts.sys.readDirectory, - readFile: function (file) { return fs.readFileSync(file, "utf8"); }, - useCaseSensitiveFileNames: true, - }; - var parsed = ts.parseJsonConfigFileContent(config.config, parseConfigHost, path.resolve(projectDirectory), { noEmit: true }); - if (parsed.errors !== undefined) { - // ignore warnings and 'TS18003: No inputs were found in config file ...' - var errors = parsed.errors.filter(function (d) { return d.category === ts.DiagnosticCategory.Error && d.code !== 18003; }); - if (errors.length !== 0) { - throw new error_1.FatalError(ts.formatDiagnostics(errors, { - getCanonicalFileName: function (f) { return f; }, - getCurrentDirectory: process.cwd, - getNewLine: function () { return "\n"; }, - })); - } - } - var host = ts.createCompilerHost(parsed.options, true); - var program = ts.createProgram(parsed.fileNames, parsed.options, host); - return program; - }; - /** - * Returns a list of source file names from a TypeScript program. This includes all referenced - * files and excludes declaration (".d.ts") files. - */ - Linter.getFileNames = function (program) { - return utils_1.mapDefined(program.getSourceFiles(), function (file) { - return file.fileName.endsWith(".d.ts") || program.isSourceFileFromExternalLibrary(file) - ? undefined - : file.fileName; - }); - }; - Linter.prototype.lint = function (fileName, source, configuration) { - if (configuration === void 0) { configuration = configuration_1.DEFAULT_CONFIG; } - var sourceFile = this.getSourceFile(fileName, source); - var isJs = /\.jsx?$/i.test(fileName); - var enabledRules = this.getEnabledRules(configuration, isJs); - var fileFailures = this.getAllFailures(sourceFile, enabledRules); - if (fileFailures.length === 0) { - // Usual case: no errors. - return; - } - if (this.options.fix && fileFailures.some(function (f) { return f.hasFix(); })) { - fileFailures = this.applyAllFixes(enabledRules, fileFailures, sourceFile, fileName); - } - // add rule severity to failures - var ruleSeverityMap = new Map(enabledRules.map(function (rule) { return [rule.getOptions().ruleName, rule.getOptions().ruleSeverity]; })); - for (var _i = 0, fileFailures_1 = fileFailures; _i < fileFailures_1.length; _i++) { - var failure = fileFailures_1[_i]; - var severity = ruleSeverityMap.get(failure.getRuleName()); - if (severity === undefined) { - throw new Error("Severity for rule '" + failure.getRuleName() + "' not found"); - } - failure.setRuleSeverity(severity); - } - this.failures = this.failures.concat(fileFailures); - }; - Linter.prototype.getResult = function () { - var formatterName = this.options.formatter !== undefined ? this.options.formatter : "prose"; - var Formatter = formatterLoader_1.findFormatter(formatterName, this.options.formattersDirectory); - if (Formatter === undefined) { - throw new Error("formatter '" + formatterName + "' not found"); - } - var formatter = new Formatter(); - var output = formatter.format(this.failures, this.fixes); - var errorCount = this.failures.filter(function (failure) { return failure.getRuleSeverity() === "error"; }).length; - return { - errorCount: errorCount, - failures: this.failures, - fixes: this.fixes, - format: formatterName, - output: output, - warningCount: this.failures.length - errorCount, - }; - }; - Linter.prototype.getAllFailures = function (sourceFile, enabledRules) { - var _this = this; - var failures = utils_1.flatMap(enabledRules, function (rule) { return _this.applyRule(rule, sourceFile); }); - return enableDisableRules_1.removeDisabledFailures(sourceFile, failures); - }; - Linter.prototype.applyAllFixes = function (enabledRules, fileFailures, sourceFile, sourceFileName) { - // When fixing, we need to be careful as a fix in one rule may affect other rules. - // So fix each rule separately. - var source = sourceFile.text; - var _loop_1 = function (rule) { - var hasFixes = fileFailures.some(function (f) { return f.hasFix() && f.getRuleName() === rule.getOptions().ruleName; }); - if (hasFixes) { - // Get new failures in case the file changed. - var updatedFailures = enableDisableRules_1.removeDisabledFailures(sourceFile, this_1.applyRule(rule, sourceFile)); - var fixableFailures = updatedFailures.filter(function (f) { return f.hasFix(); }); - this_1.fixes = this_1.fixes.concat(fixableFailures); - source = this_1.applyFixes(sourceFileName, source, fixableFailures); - sourceFile = this_1.getSourceFile(sourceFileName, source); - } - }; - var this_1 = this; - for (var _i = 0, enabledRules_1 = enabledRules; _i < enabledRules_1.length; _i++) { - var rule = enabledRules_1[_i]; - _loop_1(rule); - } - // If there were fixes, get the *new* list of failures. - return this.getAllFailures(sourceFile, enabledRules); - }; - // Only "protected" because a test directly accesses it. - // tslint:disable-next-line member-ordering - Linter.prototype.applyFixes = function (sourceFilePath, source, fixableFailures) { - var _this = this; - var fixesByFile = createMultiMap(fixableFailures, function (f) { return [f.getFileName(), f.getFix()]; }); - fixesByFile.forEach(function (fileFixes, filePath) { - var fileNewSource; - if (path.resolve(filePath) === path.resolve(sourceFilePath)) { - source = rule_1.Replacement.applyFixes(source, fileFixes); - fileNewSource = source; - } - else { - var oldSource = fs.readFileSync(filePath, "utf-8"); - fileNewSource = rule_1.Replacement.applyFixes(oldSource, fileFixes); - } - fs.writeFileSync(filePath, fileNewSource); - _this.updateProgram(filePath); - }); - return source; - }; - Linter.prototype.updateProgram = function (sourceFilePath) { - if (this.program !== undefined && this.program.getSourceFile(sourceFilePath) !== undefined) { - var options = this.program.getCompilerOptions(); - this.program = ts.createProgram(this.program.getRootFileNames(), options, ts.createCompilerHost(options, true), this.program); - } - }; - Linter.prototype.applyRule = function (rule, sourceFile) { - try { - if (this.program !== undefined && rule_1.isTypedRule(rule)) { - return rule.applyWithProgram(sourceFile, this.program); - } - else { - return rule.apply(sourceFile); - } - } - catch (error) { - if (error_1.isError(error) && error.stack !== undefined) { - error_1.showRuleCrashWarning(error.stack, rule.getOptions().ruleName, sourceFile.fileName); - } - else { - error_1.showRuleCrashWarning(String(error), rule.getOptions().ruleName, sourceFile.fileName); - } - return []; - } - }; - Linter.prototype.getEnabledRules = function (configuration, isJs) { - if (configuration === void 0) { configuration = configuration_1.DEFAULT_CONFIG; } - var ruleOptionsList = configuration_1.convertRuleOptions(isJs ? configuration.jsRules : configuration.rules); - var rulesDirectories = utils_1.arrayify(this.options.rulesDirectory) - .concat(utils_1.arrayify(configuration.rulesDirectory)); - return ruleLoader_1.loadRules(ruleOptionsList, rulesDirectories, isJs); - }; - Linter.prototype.getSourceFile = function (fileName, source) { - if (this.program !== undefined) { - var sourceFile = this.program.getSourceFile(fileName); - if (sourceFile === undefined) { - var INVALID_SOURCE_ERROR = utils_1.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Invalid source file: ", ". Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.\n "], ["\n Invalid source file: ", ". Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.\n "])), fileName); - throw new error_1.FatalError(INVALID_SOURCE_ERROR); - } - return sourceFile; - } - else { - return utils.getSourceFile(fileName, source); - } - }; - Linter.VERSION = "5.11.0"; - Linter.findConfiguration = configuration_1.findConfiguration; - Linter.findConfigurationPath = configuration_1.findConfigurationPath; - Linter.getRulesDirectories = configuration_1.getRulesDirectories; - Linter.loadConfigurationFromPath = configuration_1.loadConfigurationFromPath; - return Linter; -}()); -exports.Linter = Linter; -function createMultiMap(inputs, getPair) { - var map = new Map(); - for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) { - var input = inputs_1[_i]; - var pair = getPair(input); - if (pair !== undefined) { - var k = pair[0], v = pair[1]; - var vs = map.get(k); - if (vs !== undefined) { - vs.push(v); - } - else { - map.set(k, [v]); - } - } - } - return map; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/ruleLoader.d.ts b/node_modules/tslint/lib/ruleLoader.d.ts deleted file mode 100644 index 731933c2a..000000000 --- a/node_modules/tslint/lib/ruleLoader.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { IOptions, IRule, RuleConstructor } from "./language/rule/rule"; -export declare function loadRules(ruleOptionsList: IOptions[], rulesDirectories?: string | string[], isJs?: boolean): IRule[]; -/** @internal private API */ -export declare function findRule(name: string, rulesDirectories?: string | string[]): RuleConstructor | undefined; diff --git a/node_modules/tslint/lib/ruleLoader.js b/node_modules/tslint/lib/ruleLoader.js deleted file mode 100644 index f0da87652..000000000 --- a/node_modules/tslint/lib/ruleLoader.js +++ /dev/null @@ -1,123 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var fs = require("fs"); -var path = require("path"); -var error_1 = require("./error"); -var utils_1 = require("./utils"); -var CORE_RULES_DIRECTORY = path.resolve(__dirname, "rules"); -var cachedRules = new Map(); -function loadRules(ruleOptionsList, rulesDirectories, isJs) { - if (isJs === void 0) { isJs = false; } - var rules = []; - var notFoundRules = []; - var notAllowedInJsRules = []; - for (var _i = 0, ruleOptionsList_1 = ruleOptionsList; _i < ruleOptionsList_1.length; _i++) { - var ruleOptions = ruleOptionsList_1[_i]; - if (ruleOptions.ruleSeverity === "off") { - // Perf: don't bother finding the rule if it's disabled. - continue; - } - var ruleName = ruleOptions.ruleName; - var Rule = findRule(ruleName, rulesDirectories); - if (Rule === undefined) { - notFoundRules.push(ruleName); - } - else if (isJs && Rule.metadata !== undefined && Rule.metadata.typescriptOnly) { - notAllowedInJsRules.push(ruleName); - } - else { - var rule = new Rule(ruleOptions); - if (rule.isEnabled()) { - rules.push(rule); - } - if (Rule.metadata !== undefined && Boolean(Rule.metadata.deprecationMessage)) { - error_1.showWarningOnce(Rule.metadata.ruleName + " is deprecated. " + Rule.metadata.deprecationMessage); - } - } - } - if (notFoundRules.length > 0) { - var warning = utils_1.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Could not find implementations for the following rules specified in the configuration:\n ", "\n Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.\n If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.\n "], ["\n Could not find implementations for the following rules specified in the configuration:\n ", "\n Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.\n If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.\n "])), notFoundRules.join("\n ")); - error_1.showWarningOnce(warning); - } - if (notAllowedInJsRules.length > 0) { - var warning = utils_1.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Following rules specified in configuration couldn't be applied to .js or .jsx files:\n ", "\n Make sure to exclude them from \"jsRules\" section of your tslint.json.\n "], ["\n Following rules specified in configuration couldn't be applied to .js or .jsx files:\n ", "\n Make sure to exclude them from \"jsRules\" section of your tslint.json.\n "])), notAllowedInJsRules.join("\n ")); - error_1.showWarningOnce(warning); - } - if (rules.length === 0) { - var fileType = isJs ? "JavaScript" : "TypeScript"; - error_1.showWarningOnce("No valid rules have been specified for " + fileType + " files"); - } - return rules; -} -exports.loadRules = loadRules; -/** @internal private API */ -function findRule(name, rulesDirectories) { - var camelizedName = transformName(name); - // first check for core rules - var Rule = loadCachedRule(CORE_RULES_DIRECTORY, camelizedName); - return Rule !== undefined ? Rule : - // then check for rules within the first level of rulesDirectory - utils_1.find(utils_1.arrayify(rulesDirectories), function (dir) { return loadCachedRule(dir, camelizedName, true); }); -} -exports.findRule = findRule; -function transformName(name) { - // camelize strips out leading and trailing underscores and dashes, so make sure they aren't passed to camelize - // the regex matches the groups (leading underscores and dashes)(other characters)(trailing underscores and dashes) - var nameMatch = name.match(/^([-_]*)(.*?)([-_]*)$/); - if (nameMatch === null) { - return name + "Rule"; - } - return "" + nameMatch[1] + utils_1.camelize(nameMatch[2]) + nameMatch[3] + "Rule"; -} -/** - * @param directory - An absolute path to a directory of rules - * @param ruleName - A name of a rule in filename format. ex) "someLintRule" - */ -function loadRule(directory, ruleName) { - var ruleFullPath; - try { - // Resolve using node's path resolution to allow developers to write custom rules in TypeScript which can be loaded by TS-Node - ruleFullPath = require.resolve(path.join(directory, ruleName)); - } - catch (_a) { - return "not-found"; - } - return require(ruleFullPath).Rule; -} -function loadCachedRule(directory, ruleName, isCustomPath) { - // use cached value if available - var fullPath = path.join(directory, ruleName); - var cachedRule = cachedRules.get(fullPath); - if (cachedRule !== undefined) { - return cachedRule === "not-found" ? undefined : cachedRule; - } - // treat directory as a relative path (which needs to be resolved) if it's a custom rule directory - var absolutePath = directory; - if (isCustomPath) { - absolutePath = path.resolve(directory); - if (!fs.existsSync(absolutePath)) { - throw new error_1.FatalError("Could not find custom rule directory: " + absolutePath); - } - } - var Rule = loadRule(absolutePath, ruleName); - cachedRules.set(fullPath, Rule); - return Rule === "not-found" ? undefined : Rule; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules.d.ts b/node_modules/tslint/lib/rules.d.ts deleted file mode 100644 index d9ff27de9..000000000 --- a/node_modules/tslint/lib/rules.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export * from "./language/rule/abstractRule"; -export * from "./language/rule/typedRule"; -export * from "./language/rule/optionallyTypedRule"; diff --git a/node_modules/tslint/lib/rules.js b/node_modules/tslint/lib/rules.js deleted file mode 100644 index afbd6463a..000000000 --- a/node_modules/tslint/lib/rules.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./language/rule/abstractRule"), exports); -tslib_1.__exportStar(require("./language/rule/typedRule"), exports); -tslib_1.__exportStar(require("./language/rule/optionallyTypedRule"), exports); diff --git a/node_modules/tslint/lib/rules/adjacentOverloadSignaturesRule.d.ts b/node_modules/tslint/lib/rules/adjacentOverloadSignaturesRule.d.ts deleted file mode 100644 index 967655d2d..000000000 --- a/node_modules/tslint/lib/rules/adjacentOverloadSignaturesRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} -export declare function getOverloadKey(node: ts.SignatureDeclaration): string | undefined; diff --git a/node_modules/tslint/lib/rules/adjacentOverloadSignaturesRule.js b/node_modules/tslint/lib/rules/adjacentOverloadSignaturesRule.js deleted file mode 100644 index 7bba51a80..000000000 --- a/node_modules/tslint/lib/rules/adjacentOverloadSignaturesRule.js +++ /dev/null @@ -1,141 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name) { - return "All '" + name + "' signatures should be adjacent"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "adjacent-overload-signatures", - description: "Enforces function overloads to be consecutive.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: "Improves readability and organization by grouping naturally related items together.", - type: "typescript", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - visitStatements(sourceFile.statements); - return ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ModuleBlock: - visitStatements(node.statements); - break; - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.TypeLiteral: { - var members = node.members; - addFailures(getMisplacedOverloads(members, function (member) { - return utils.isSignatureDeclaration(member) ? getOverloadKey(member) : undefined; - })); - } - } - return ts.forEachChild(node, cb); - }); - function visitStatements(statements) { - addFailures(getMisplacedOverloads(statements, function (statement) { - return utils.isFunctionDeclaration(statement) && statement.name !== undefined ? statement.name.text : undefined; - })); - } - function addFailures(misplacedOverloads) { - for (var _i = 0, misplacedOverloads_1 = misplacedOverloads; _i < misplacedOverloads_1.length; _i++) { - var node = misplacedOverloads_1[_i]; - ctx.addFailureAtNode(node, Rule.FAILURE_STRING(printOverload(node))); - } - } -} -/** 'getOverloadName' may return undefined for nodes that cannot be overloads, e.g. a `const` declaration. */ -function getMisplacedOverloads(overloads, getKey) { - var result = []; - var lastKey; - var seen = new Set(); - for (var _i = 0, overloads_1 = overloads; _i < overloads_1.length; _i++) { - var node = overloads_1[_i]; - if (node.kind === ts.SyntaxKind.SemicolonClassElement) { - continue; - } - var key = getKey(node); - if (key !== undefined) { - if (seen.has(key) && lastKey !== key) { - result.push(node); - } - seen.add(key); - lastKey = key; - } - else { - lastKey = undefined; - } - } - return result; -} -function printOverload(node) { - var info = getOverloadInfo(node); - return typeof info === "string" ? info : info === undefined ? "<unknown>" : info.name; -} -function getOverloadKey(node) { - var info = getOverloadInfo(node); - if (info === undefined) { - return undefined; - } - var _a = typeof info === "string" ? [false, info] : [info.computed, info.name], computed = _a[0], name = _a[1]; - var isStatic = utils.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword); - return (computed ? "0" : "1") + (isStatic ? "0" : "1") + name; -} -exports.getOverloadKey = getOverloadKey; -function getOverloadInfo(node) { - switch (node.kind) { - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.Constructor: - return "constructor"; - case ts.SyntaxKind.CallSignature: - return "()"; - default: { - var name = node.name; - if (name === undefined) { - return undefined; - } - switch (name.kind) { - case ts.SyntaxKind.Identifier: - return name.text; - case ts.SyntaxKind.ComputedPropertyName: - var expression = name.expression; - return utils.isLiteralExpression(expression) ? expression.text : { name: expression.getText(), computed: true }; - default: - return utils.isLiteralExpression(name) ? name.text : undefined; - } - } - } -} diff --git a/node_modules/tslint/lib/rules/alignRule.d.ts b/node_modules/tslint/lib/rules/alignRule.d.ts deleted file mode 100644 index 78cc017cf..000000000 --- a/node_modules/tslint/lib/rules/alignRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_SUFFIX: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/alignRule.js b/node_modules/tslint/lib/rules/alignRule.js deleted file mode 100644 index 702711ffe..000000000 --- a/node_modules/tslint/lib/rules/alignRule.js +++ /dev/null @@ -1,185 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_STATEMENTS = "statements"; -var OPTION_MEMBERS = "members"; -var OPTION_ELEMENTS = "elements"; -var OPTION_PARAMETERS = "parameters"; -var OPTION_ARGUMENTS = "arguments"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new AlignWalker(sourceFile, this.ruleName, { - arguments: this.ruleArguments.indexOf(OPTION_ARGUMENTS) !== -1, - elements: this.ruleArguments.indexOf(OPTION_ELEMENTS) !== -1, - members: this.ruleArguments.indexOf(OPTION_MEMBERS) !== -1, - parameters: this.ruleArguments.indexOf(OPTION_PARAMETERS) !== -1, - statements: this.ruleArguments.indexOf(OPTION_STATEMENTS) !== -1, - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "align", - description: "Enforces vertical alignment.", - hasFix: true, - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps maintain a readable, consistent style in your codebase.\n\n Consistent alignment for code statements helps keep code readable and clear.\n Statements misaligned from the standard can be harder to read and understand."], ["\n Helps maintain a readable, consistent style in your codebase.\n\n Consistent alignment for code statements helps keep code readable and clear.\n Statements misaligned from the standard can be harder to read and understand."]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"` checks alignment of function parameters.\n * `\"", "\"` checks alignment of function call arguments.\n * `\"", "\"` checks alignment of statements.\n * `\"", "\"` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * `\"", "\"` checks alignment of elements of array iterals, array destructuring and tuple types."], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` checks alignment of function parameters.\n * \\`\"", "\"\\` checks alignment of function call arguments.\n * \\`\"", "\"\\` checks alignment of statements.\n * \\`\"", "\"\\` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * \\`\"", "\"\\` checks alignment of elements of array iterals, array destructuring and tuple types."])), OPTION_PARAMETERS, OPTION_ARGUMENTS, OPTION_STATEMENTS, OPTION_MEMBERS, OPTION_ELEMENTS), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_ARGUMENTS, OPTION_ELEMENTS, OPTION_MEMBERS, OPTION_PARAMETERS, OPTION_STATEMENTS], - }, - minLength: 1, - maxLength: 5, - }, - optionExamples: [[true, "parameters", "statements"]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_SUFFIX = " are not aligned"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var AlignWalker = /** @class */ (function (_super) { - tslib_1.__extends(AlignWalker, _super); - function AlignWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - AlignWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (_this.options.statements && tsutils_1.isBlockLike(node)) { - _this.checkAlignment(node.statements.filter(function (s) { return s.kind !== ts.SyntaxKind.EmptyStatement; }), OPTION_STATEMENTS); - } - else { - switch (node.kind) { - case ts.SyntaxKind.NewExpression: - if (node.arguments === undefined) { - break; - } - // falls through - case ts.SyntaxKind.CallExpression: - if (_this.options.arguments) { - _this.checkAlignment(node.arguments, OPTION_ARGUMENTS); - } - break; - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.CallSignature: - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.FunctionType: - case ts.SyntaxKind.ConstructorType: - if (_this.options.parameters) { - _this.checkAlignment(node.parameters, OPTION_PARAMETERS); - } - break; - case ts.SyntaxKind.ArrayLiteralExpression: - case ts.SyntaxKind.ArrayBindingPattern: - if (_this.options.elements) { - _this.checkAlignment(node.elements, OPTION_ELEMENTS); - } - break; - case ts.SyntaxKind.TupleType: - if (_this.options.elements) { - _this.checkAlignment(node.elementTypes, OPTION_ELEMENTS); - } - break; - case ts.SyntaxKind.ObjectLiteralExpression: - if (_this.options.members) { - _this.checkAlignment(node.properties, OPTION_MEMBERS); - } - break; - case ts.SyntaxKind.ObjectBindingPattern: - if (_this.options.members) { - _this.checkAlignment(node.elements, OPTION_MEMBERS); - } - break; - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - if (_this.options.members) { - _this.checkAlignment(node.members.filter(function (m) { return m.kind !== ts.SyntaxKind.SemicolonClassElement; }), OPTION_MEMBERS); - } - break; - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeLiteral: - if (_this.options.members) { - _this.checkAlignment(node.members, OPTION_MEMBERS); - } - } - } - return ts.forEachChild(node, cb); - }; - return cb(sourceFile); - }; - AlignWalker.prototype.checkAlignment = function (nodes, kind) { - if (nodes.length <= 1) { - return; - } - var sourceFile = this.sourceFile; - var pos = getLineAndCharacterWithoutBom(sourceFile, this.getStart(nodes[0])); - var alignToColumn = pos.character; - var line = pos.line; - // skip first node in list - for (var i = 1; i < nodes.length; ++i) { - var node = nodes[i]; - var start = this.getStart(node); - pos = ts.getLineAndCharacterOfPosition(sourceFile, start); - if (line !== pos.line && pos.character !== alignToColumn) { - var diff = alignToColumn - pos.character; - var fix = void 0; - if (diff >= 0) { - fix = Lint.Replacement.appendText(start, " ".repeat(diff)); - } - else if (node.pos <= start + diff && /^\s+$/.test(sourceFile.text.substring(start + diff, start))) { - // only delete text if there is only whitespace - fix = Lint.Replacement.deleteText(start + diff, -diff); - } - this.addFailure(start, Math.max(node.end, start), kind + Rule.FAILURE_STRING_SUFFIX, fix); - } - line = pos.line; - } - }; - AlignWalker.prototype.getStart = function (node) { - return node.kind !== ts.SyntaxKind.OmittedExpression - ? node.getStart(this.sourceFile) - // find the comma token following the OmmitedExpression - : tsutils_1.getNextToken(node, this.sourceFile).getStart(this.sourceFile); - }; - return AlignWalker; -}(Lint.AbstractWalker)); -function getLineAndCharacterWithoutBom(sourceFile, pos) { - var result = ts.getLineAndCharacterOfPosition(sourceFile, pos); - if (result.line === 0 && sourceFile.text[0] === "\uFEFF") { - result.character -= 1; - } - return result; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/arrayTypeRule.d.ts b/node_modules/tslint/lib/rules/arrayTypeRule.d.ts deleted file mode 100644 index d36189fca..000000000 --- a/node_modules/tslint/lib/rules/arrayTypeRule.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_ARRAY: string; - static FAILURE_STRING_GENERIC: string; - static FAILURE_STRING_ARRAY_SIMPLE: string; - static FAILURE_STRING_GENERIC_SIMPLE: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/arrayTypeRule.js b/node_modules/tslint/lib/rules/arrayTypeRule.js deleted file mode 100644 index f04126edf..000000000 --- a/node_modules/tslint/lib/rules/arrayTypeRule.js +++ /dev/null @@ -1,154 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ARRAY = "array"; -var OPTION_GENERIC = "generic"; -var OPTION_ARRAY_SIMPLE = "array-simple"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.ruleArguments[0]); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "array-type", - description: "Requires using either 'T[]' or 'Array<T>' for arrays.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One of the following arguments must be provided:\n\n * `\"", "\"` enforces use of `T[]` for all types T.\n * `\"", "\"` enforces use of `Array<T>` for all types T.\n * `\"", "\"` enforces use of `T[]` if `T` is a simple type (primitive or type reference)."], ["\n One of the following arguments must be provided:\n\n * \\`\"", "\"\\` enforces use of \\`T[]\\` for all types T.\n * \\`\"", "\"\\` enforces use of \\`Array<T>\\` for all types T.\n * \\`\"", "\"\\` enforces use of \\`T[]\\` if \\`T\\` is a simple type (primitive or type reference)."])), OPTION_ARRAY, OPTION_GENERIC, OPTION_ARRAY_SIMPLE), - options: { - type: "string", - enum: [OPTION_ARRAY, OPTION_GENERIC, OPTION_ARRAY_SIMPLE], - }, - optionExamples: [[true, OPTION_ARRAY], [true, OPTION_GENERIC], [true, OPTION_ARRAY_SIMPLE]], - type: "style", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_ARRAY = "Array type using 'Array<T>' is forbidden. Use 'T[]' instead."; - Rule.FAILURE_STRING_GENERIC = "Array type using 'T[]' is forbidden. Use 'Array<T>' instead."; - Rule.FAILURE_STRING_ARRAY_SIMPLE = "Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead."; - Rule.FAILURE_STRING_GENERIC_SIMPLE = "Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, option = ctx.options; - return ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ArrayType: - checkArrayType(node); - break; - case ts.SyntaxKind.TypeReference: - checkTypeReference(node); - } - return ts.forEachChild(node, cb); - }); - function checkArrayType(node) { - var elementType = node.elementType, parent = node.parent; - if (option === "array" || option === "array-simple" && isSimpleType(elementType)) { - return; - } - var failureString = option === "generic" ? Rule.FAILURE_STRING_GENERIC : Rule.FAILURE_STRING_GENERIC_SIMPLE; - var parens = elementType.kind === ts.SyntaxKind.ParenthesizedType ? 1 : 0; - // Add a space if the type is preceded by 'as' and the node has no leading whitespace - var space = parens === 0 && parent.kind === ts.SyntaxKind.AsExpression && node.getStart() === node.getFullStart(); - var fix = [ - new Lint.Replacement(elementType.getStart(), parens, (space ? " " : "") + "Array<"), - // Delete the square brackets and replace with an angle bracket - Lint.Replacement.replaceFromTo(elementType.getEnd() - parens, node.getEnd(), ">"), - ]; - ctx.addFailureAtNode(node, failureString, fix); - } - function checkTypeReference(node) { - var typeName = node.typeName, typeArguments = node.typeArguments; - if (option === "generic" || !isArrayIdentifier(typeName)) { - return; - } - var failureString = option === "array" ? Rule.FAILURE_STRING_ARRAY : Rule.FAILURE_STRING_ARRAY_SIMPLE; - if (typeArguments === undefined || typeArguments.length === 0) { - // Create an 'any' array - ctx.addFailureAtNode(node, failureString, Lint.Replacement.replaceFromTo(node.getStart(), node.getEnd(), "any[]")); - return; - } - if (typeArguments.length !== 1 || (option === "array-simple" && !isSimpleType(typeArguments[0]))) { - return; - } - var type = typeArguments[0]; - var parens = typeNeedsParentheses(type); - ctx.addFailureAtNode(node, failureString, [ - // Delete 'Array<' - Lint.Replacement.replaceFromTo(node.getStart(), type.getStart(), parens ? "(" : ""), - // Delete '>' and replace with '[] - Lint.Replacement.replaceFromTo(type.getEnd(), node.getEnd(), parens ? ")[]" : "[]"), - ]); - } -} -function typeNeedsParentheses(type) { - switch (type.kind) { - case ts.SyntaxKind.UnionType: - case ts.SyntaxKind.FunctionType: - case ts.SyntaxKind.IntersectionType: - case ts.SyntaxKind.TypeOperator: - return true; - default: - return false; - } -} -function isArrayIdentifier(name) { - return name.kind === ts.SyntaxKind.Identifier && name.text === "Array"; -} -function isSimpleType(nodeType) { - switch (nodeType.kind) { - case ts.SyntaxKind.AnyKeyword: - case ts.SyntaxKind.ArrayType: - case ts.SyntaxKind.BooleanKeyword: - case ts.SyntaxKind.NullKeyword: - case ts.SyntaxKind.ObjectKeyword: - case ts.SyntaxKind.UndefinedKeyword: - case ts.SyntaxKind.NumberKeyword: - case ts.SyntaxKind.StringKeyword: - case ts.SyntaxKind.SymbolKeyword: - case ts.SyntaxKind.VoidKeyword: - case ts.SyntaxKind.NeverKeyword: - case ts.SyntaxKind.ThisType: - return true; - case ts.SyntaxKind.TypeReference: - // TypeReferences must be non-generic or be another Array with a simple type - var _a = nodeType, typeName = _a.typeName, typeArguments = _a.typeArguments; - if (typeArguments === undefined) { - return true; - } - switch (typeArguments.length) { - case 0: - return true; - case 1: - return typeName.kind === ts.SyntaxKind.Identifier && typeName.text === "Array" && isSimpleType(typeArguments[0]); - default: - return false; - } - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/arrowParensRule.d.ts b/node_modules/tslint/lib/rules/arrowParensRule.d.ts deleted file mode 100644 index ebb24e383..000000000 --- a/node_modules/tslint/lib/rules/arrowParensRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_MISSING: string; - static FAILURE_STRING_EXISTS: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/arrowParensRule.js b/node_modules/tslint/lib/rules/arrowParensRule.js deleted file mode 100644 index 49f869560..000000000 --- a/node_modules/tslint/lib/rules/arrowParensRule.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var BAN_SINGLE_ARG_PARENS = "ban-single-arg-parens"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - banSingleArgParens: this.ruleArguments.indexOf(BAN_SINGLE_ARG_PARENS) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "arrow-parens", - description: "Requires parentheses around the parameters of arrow function definitions.", - hasFix: true, - rationale: "Maintains stylistic consistency with other arrow function definitions.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then arrow functions with one parameter\n must not have parentheses if removing them is allowed by TypeScript."], ["\n If \\`", "\\` is specified, then arrow functions with one parameter\n must not have parentheses if removing them is allowed by TypeScript."])), BAN_SINGLE_ARG_PARENS), - options: { - type: "string", - enum: [BAN_SINGLE_ARG_PARENS], - }, - optionExamples: [true, [true, BAN_SINGLE_ARG_PARENS]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_MISSING = "Parentheses are required around the parameters of an arrow function definition"; - Rule.FAILURE_STRING_EXISTS = "Parentheses are prohibited around the parameter in this single parameter arrow function"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - function cb(node) { - if (tsutils_1.isArrowFunction(node) && parensAreOptional(node)) { - var openParen = tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenParenToken); - if (openParen === undefined) { - if (!ctx.options.banSingleArgParens) { - var parameter = node.parameters[0]; - var start = parameter.getStart(ctx.sourceFile); - var end = parameter.end; - ctx.addFailure(start, end, Rule.FAILURE_STRING_MISSING, [ - Lint.Replacement.appendText(start, "("), - Lint.Replacement.appendText(end, ")"), - ]); - } - } - else if (ctx.options.banSingleArgParens) { - var closeParen = tsutils_1.getChildOfKind(node, ts.SyntaxKind.CloseParenToken); - var charBeforeOpenParen = ctx.sourceFile.text.substring(openParen.pos - 1, openParen.pos); - var replaceValue = charBeforeOpenParen.match(/[a-z]/i) !== null ? " " : ""; - ctx.addFailureAtNode(node.parameters[0], Rule.FAILURE_STRING_EXISTS, [ - Lint.Replacement.replaceFromTo(openParen.pos, node.parameters[0].getStart(ctx.sourceFile), replaceValue), - Lint.Replacement.deleteFromTo(node.parameters[0].end, closeParen.end), - ]); - } - } - return ts.forEachChild(node, cb); - } - return ts.forEachChild(ctx.sourceFile, cb); -} -function parensAreOptional(node) { - return node.parameters.length === 1 && - node.typeParameters === undefined && - node.type === undefined && - isSimpleParameter(node.parameters[0]); -} -function isSimpleParameter(parameter) { - return parameter.name.kind === ts.SyntaxKind.Identifier - && parameter.dotDotDotToken === undefined - && parameter.initializer === undefined - && parameter.questionToken === undefined - && parameter.type === undefined; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/arrowReturnShorthandRule.d.ts b/node_modules/tslint/lib/rules/arrowReturnShorthandRule.d.ts deleted file mode 100644 index 3cd37b60a..000000000 --- a/node_modules/tslint/lib/rules/arrowReturnShorthandRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(isObjectLiteral: boolean): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/arrowReturnShorthandRule.js b/node_modules/tslint/lib/rules/arrowReturnShorthandRule.js deleted file mode 100644 index 3f869f765..000000000 --- a/node_modules/tslint/lib/rules/arrowReturnShorthandRule.js +++ /dev/null @@ -1,102 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../language/utils"); -var OPTION_MULTILINE = "multiline"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (isObjectLiteral) { - var start = "This arrow function body can be simplified by omitting the curly braces and the keyword 'return'"; - return start + (isObjectLiteral ? ", and wrapping the object literal in parentheses." : "."); - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { multiline: this.ruleArguments.indexOf(OPTION_MULTILINE) !== -1 }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "arrow-return-shorthand", - description: "Suggests to convert `() => { return x; }` to `() => x`.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then this will warn even if the function spans multiple lines."], ["\n If \\`", "\\` is specified, then this will warn even if the function spans multiple lines."])), OPTION_MULTILINE), - options: { - type: "string", - enum: [OPTION_MULTILINE], - }, - optionExamples: [ - true, - [true, OPTION_MULTILINE], - ], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It's unnecessary to include `return` and `{}` brackets in arrow lambdas.\n Leaving them out results in simpler and easier to read code.\n "], ["\n It's unnecessary to include \\`return\\` and \\`{}\\` brackets in arrow lambdas.\n Leaving them out results in simpler and easier to read code.\n "]))), - type: "style", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, multiline = ctx.options.multiline; - return ts.forEachChild(sourceFile, function cb(node) { - if (utils.isArrowFunction(node) && utils.isBlock(node.body)) { - var expr = getSimpleReturnExpression(node.body); - if (expr !== undefined && (multiline || utils.isSameLine(sourceFile, node.body.getStart(sourceFile), node.body.end))) { - var isObjectLiteral = expr.kind === ts.SyntaxKind.ObjectLiteralExpression; - ctx.addFailureAtNode(node.body, Rule.FAILURE_STRING(isObjectLiteral), createFix(node, node.body, expr, sourceFile.text)); - } - } - return ts.forEachChild(node, cb); - }); -} -function createFix(arrowFunction, body, expr, text) { - var statement = expr.parent; - var returnKeyword = utils.getChildOfKind(statement, ts.SyntaxKind.ReturnKeyword); - var arrow = utils.getChildOfKind(arrowFunction, ts.SyntaxKind.EqualsGreaterThanToken); - var openBrace = utils.getChildOfKind(body, ts.SyntaxKind.OpenBraceToken); - var closeBrace = utils.getChildOfKind(body, ts.SyntaxKind.CloseBraceToken); - var semicolon = utils.getChildOfKind(statement, ts.SyntaxKind.SemicolonToken); - var anyComments = hasComments(arrow) || hasComments(openBrace) || hasComments(statement) || hasComments(returnKeyword) || - hasComments(expr) || (semicolon !== undefined && hasComments(semicolon)) || hasComments(closeBrace); - return anyComments ? undefined : (expr.kind === ts.SyntaxKind.ObjectLiteralExpression ? [ - Lint.Replacement.appendText(expr.getStart(), "("), - Lint.Replacement.appendText(expr.getEnd(), ")"), - ] : []).concat([ - // " {" - Lint.Replacement.deleteFromTo(arrow.end, openBrace.end), - // "return " - Lint.Replacement.deleteFromTo(statement.getStart(), expr.getStart()), - // " }" (may include semicolon) - Lint.Replacement.deleteFromTo(expr.end, closeBrace.end), - ]); - function hasComments(node) { - return utils_1.hasCommentAfterPosition(text, node.getEnd()); - } -} -/** Given `{ return x; }`, return `x`. */ -function getSimpleReturnExpression(block) { - return block.statements.length === 1 && block.statements[0].kind === ts.SyntaxKind.ReturnStatement - ? block.statements[0].expression - : undefined; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts b/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts deleted file mode 100644 index e54ae8844..000000000 --- a/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static FAILURE_FOR_AWAIT_OF: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/awaitPromiseRule.js b/node_modules/tslint/lib/rules/awaitPromiseRule.js deleted file mode 100644 index c6eef346f..000000000 --- a/node_modules/tslint/lib/rules/awaitPromiseRule.js +++ /dev/null @@ -1,92 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - var promiseTypes = new Set(["Promise"].concat(this.ruleArguments)); - return this.applyWithFunction(sourceFile, walk, promiseTypes, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "await-promise", - description: "Warns for an awaited value that is not a Promise.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A list of 'string' names of any additional classes that should also be treated as Promises.\n For example, if you are using a class called 'Future' that implements the Thenable interface,\n you might tell the rule to consider type references with the name 'Future' as valid Promise-like\n types. Note that this rule doesn't check for type assignability or compatibility; it just checks\n type reference names.\n "], ["\n A list of 'string' names of any additional classes that should also be treated as Promises.\n For example, if you are using a class called 'Future' that implements the Thenable interface,\n you might tell the rule to consider type references with the name 'Future' as valid Promise-like\n types. Note that this rule doesn't check for type assignability or compatibility; it just checks\n type reference names.\n "]))), - options: { - type: "list", - listType: { - type: "array", - items: { type: "string" }, - }, - }, - optionExamples: [true, [true, "Thenable"]], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n While it is valid JavaScript to await a non-Promise-like value (it will resolve immediately),\n this pattern is often a programmer error and the resulting semantics can be unintuitive.\n\n Awaiting non-Promise-like values often is an indication of programmer error, such as\n forgetting to add parenthesis to call a function that returns a Promise.\n "], ["\n While it is valid JavaScript to await a non-Promise-like value (it will resolve immediately),\n this pattern is often a programmer error and the resulting semantics can be unintuitive.\n\n Awaiting non-Promise-like values often is an indication of programmer error, such as\n forgetting to add parenthesis to call a function that returns a Promise.\n "]))), - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Invalid 'await' of a non-Promise value."; - Rule.FAILURE_FOR_AWAIT_OF = "Invalid 'for-await-of' of a non-AsyncIterable value."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - var promiseTypes = ctx.options; - return ts.forEachChild(ctx.sourceFile, cb); - function cb(node) { - if (tsutils_1.isAwaitExpression(node) && !containsType(tc.getTypeAtLocation(node.expression), isPromiseType)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - else if (tsutils_1.isForOfStatement(node) && node.awaitModifier !== undefined && - !containsType(tc.getTypeAtLocation(node.expression), isAsyncIterable)) { - ctx.addFailureAtNode(node.expression, Rule.FAILURE_FOR_AWAIT_OF); - } - return ts.forEachChild(node, cb); - } - function isPromiseType(name) { - return promiseTypes.has(name); - } -} -function containsType(type, predicate) { - if (tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Any)) { - return true; - } - if (tsutils_1.isTypeReference(type)) { - type = type.target; - } - if (type.symbol !== undefined && predicate(type.symbol.name)) { - return true; - } - if (tsutils_1.isUnionOrIntersectionType(type)) { - return type.types.some(function (t) { return containsType(t, predicate); }); - } - var bases = type.getBaseTypes(); - return bases !== undefined && bases.some(function (t) { return containsType(t, predicate); }); -} -function isAsyncIterable(name) { - return name === "AsyncIterable" || name === "AsyncIterableIterator"; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts b/node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/banCommaOperatorRule.js b/node_modules/tslint/lib/rules/banCommaOperatorRule.js deleted file mode 100644 index e81084295..000000000 --- a/node_modules/tslint/lib/rules/banCommaOperatorRule.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys max-line-length */ - Rule.metadata = { - ruleName: "ban-comma-operator", - description: "Disallows the comma operator to be used.", - descriptionDetails: "[Read more about the comma operator here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator).", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using the comma operator can create a potential for many non-obvious bugs or lead to misunderstanding of code.\n\n ### Examples\n ```\n foo((bar, baz)); // evaluates to 'foo(baz)' because of the extra parens - confusing and not obvious\n ```\n\n ```\n switch (foo) {\n case 1, 2: // equals 'case 2' - probably intended 'case 1: case2:'\n return true;\n case 3:\n return false;\n }\n ```\n\n ```\n let x = (y = 1, z = 2); // x is equal to 2 - this may not be immediately obvious.\n ```\n "], ["\n Using the comma operator can create a potential for many non-obvious bugs or lead to misunderstanding of code.\n\n ### Examples\n \\`\\`\\`\n foo((bar, baz)); // evaluates to 'foo(baz)' because of the extra parens - confusing and not obvious\n \\`\\`\\`\n\n \\`\\`\\`\n switch (foo) {\n case 1, 2: // equals 'case 2' - probably intended 'case 1: case2:'\n return true;\n case 3:\n return false;\n }\n \\`\\`\\`\n\n \\`\\`\\`\n let x = (y = 1, z = 2); // x is equal to 2 - this may not be immediately obvious.\n \\`\\`\\`\n "]))), - options: null, - optionsDescription: "", - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys max-line-length */ - Rule.FAILURE_STRING = "Do not use comma operator here because it can be easily misunderstood or lead to unintended bugs."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.CommaToken && !isForLoopIncrementor(node)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -function isForLoopIncrementor(node) { - var parent = node.parent; - return parent.kind === ts.SyntaxKind.ForStatement && parent.incrementor === node; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/banRule.d.ts b/node_modules/tslint/lib/rules/banRule.d.ts deleted file mode 100644 index 44311c6eb..000000000 --- a/node_modules/tslint/lib/rules/banRule.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(expression: string, messageAddition?: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/banRule.js b/node_modules/tslint/lib/rules/banRule.js deleted file mode 100644 index a87a1f3a7..000000000 --- a/node_modules/tslint/lib/rules/banRule.js +++ /dev/null @@ -1,174 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (expression, messageAddition) { - return "Calls to '" + expression + "' are not allowed." + (messageAddition !== undefined ? " " + messageAddition : ""); - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new BanFunctionWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments))); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "ban", - description: "Bans the use of specific functions or global methods.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A list of banned functions or methods in the following format:\n\n * banning functions:\n * just the name of the function: `\"functionName\"`\n * the name of the function in an array with one element: `[\"functionName\"]`\n * an object in the following format: `{\"name\": \"functionName\", \"message\": \"optional explanation message\"}`\n * banning methods:\n * an array with the object name, method name and optional message: `[\"functionName\", \"methodName\", \"optional message\"]`\n * an object in the following format: `{\"name\": [\"objectName\", \"methodName\"], \"message\": \"optional message\"}`\n * you can also ban deeply nested methods: `{\"name\": [\"foo\", \"bar\", \"baz\"]}` bans `foo.bar.baz()`\n * the first element can contain a wildcard (`*`) that matches everything. `{\"name\": [\"*\", \"forEach\"]}` bans `[].forEach(...)`, `$(...).forEach(...)`, `arr.forEach(...)`, etc.\n "], ["\n A list of banned functions or methods in the following format:\n\n * banning functions:\n * just the name of the function: \\`\"functionName\"\\`\n * the name of the function in an array with one element: \\`[\"functionName\"]\\`\n * an object in the following format: \\`{\"name\": \"functionName\", \"message\": \"optional explanation message\"}\\`\n * banning methods:\n * an array with the object name, method name and optional message: \\`[\"functionName\", \"methodName\", \"optional message\"]\\`\n * an object in the following format: \\`{\"name\": [\"objectName\", \"methodName\"], \"message\": \"optional message\"}\\`\n * you can also ban deeply nested methods: \\`{\"name\": [\"foo\", \"bar\", \"baz\"]}\\` bans \\`foo.bar.baz()\\`\n * the first element can contain a wildcard (\\`*\\`) that matches everything. \\`{\"name\": [\"*\", \"forEach\"]}\\` bans\\\n \\`[].forEach(...)\\`, \\`$(...).forEach(...)\\`, \\`arr.forEach(...)\\`, etc.\n "]))), - options: { - type: "list", - listType: { - anyOf: [ - { - type: "string", - }, - { - type: "array", - items: { type: "string" }, - minLength: 1, - maxLength: 3, - }, - { - type: "object", - properties: { - name: { - anyOf: [ - { type: "string" }, - { type: "array", items: { type: "string" }, minLength: 1 }, - ], - }, - message: { type: "string" }, - }, - required: ["name"], - }, - ], - }, - }, - optionExamples: [ - [ - true, - "eval", - { name: "$", message: "please don't" }, - ["describe", "only"], - { name: ["it", "only"], message: "don't focus tests" }, - { name: ["chai", "assert", "equal"], message: "Use 'strictEqual' instead." }, - { name: ["*", "forEach"], message: "Use a regular for loop instead." }, - ], - ], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(args) { - var functions = []; - var methods = []; - for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { - var arg = args_1[_i]; - if (typeof arg === "string") { - functions.push({ name: arg }); - } - else if (Array.isArray(arg)) { - switch (arg.length) { - case 0: - break; - case 1: - functions.push({ name: arg[0] }); - break; - default: - methods.push({ object: [arg[0]], name: arg[1], message: arg[2] }); - } - } - else if (!Array.isArray(arg.name)) { - functions.push(arg); - } - else { - switch (arg.name.length) { - case 0: - break; - case 1: - functions.push({ name: arg.name[0], message: arg.message }); - break; - default: - methods.push({ name: arg.name[arg.name.length - 1], object: arg.name.slice(0, -1), message: arg.message }); - } - } - } - return { functions: functions, methods: methods }; -} -var BanFunctionWalker = /** @class */ (function (_super) { - tslib_1.__extends(BanFunctionWalker, _super); - function BanFunctionWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - BanFunctionWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (tsutils_1.isCallExpression(node)) { - if (tsutils_1.isIdentifier(node.expression)) { - _this.checkFunctionBan(node.expression); - } - else if (tsutils_1.isPropertyAccessExpression(node.expression)) { - _this.checkForObjectMethodBan(node.expression); - } - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - BanFunctionWalker.prototype.checkForObjectMethodBan = function (expression) { - for (var _i = 0, _a = this.options.methods; _i < _a.length; _i++) { - var ban = _a[_i]; - if (expression.name.text !== ban.name) { - continue; - } - var current = expression.expression; - for (var i = ban.object.length - 1; i > 0; --i) { - if (!tsutils_1.isPropertyAccessExpression(current) || current.name.text !== ban.object[i]) { - continue; - } - current = current.expression; - } - if (ban.object[0] === "*" || - tsutils_1.isIdentifier(current) && current.text === ban.object[0]) { - this.addFailureAtNode(expression, Rule.FAILURE_STRING_FACTORY(ban.object.join(".") + "." + ban.name, ban.message)); - break; - } - } - }; - BanFunctionWalker.prototype.checkFunctionBan = function (name) { - var text = name.text; - for (var _i = 0, _a = this.options.functions; _i < _a.length; _i++) { - var ban = _a[_i]; - if (ban.name === text) { - this.addFailureAtNode(name, Rule.FAILURE_STRING_FACTORY(text, ban.message)); - break; - } - } - }; - return BanFunctionWalker; -}(Lint.AbstractWalker)); -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/banTypesRule.d.ts b/node_modules/tslint/lib/rules/banTypesRule.d.ts deleted file mode 100644 index 931ef3657..000000000 --- a/node_modules/tslint/lib/rules/banTypesRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(typeName: string, messageAddition?: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/banTypesRule.js b/node_modules/tslint/lib/rules/banTypesRule.js deleted file mode 100644 index bcb971f80..000000000 --- a/node_modules/tslint/lib/rules/banTypesRule.js +++ /dev/null @@ -1,75 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (typeName, messageAddition) { - return "Don't use '" + typeName + "' as a type." + (messageAddition !== undefined ? " " + messageAddition : ""); - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.ruleArguments.map(parseOption)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "ban-types", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Bans specific types from being used. Does not ban the\n corresponding runtime objects from being used."], ["\n Bans specific types from being used. Does not ban the\n corresponding runtime objects from being used."]))), - options: { - type: "list", - listType: { - type: "array", - items: { type: "string" }, - minLength: 1, - maxLength: 2, - }, - }, - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n A list of `[\"regex\", \"optional explanation here\"]`, which bans\n types that match `regex`"], ["\n A list of \\`[\"regex\", \"optional explanation here\"]\\`, which bans\n types that match \\`regex\\`"]))), - optionExamples: [[true, ["Object", "Use {} instead."], ["String"]]], - type: "typescript", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOption(_a) { - var pattern = _a[0], message = _a[1]; - return { message: message, pattern: new RegExp("^" + pattern + "$") }; -} -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isTypeReferenceNode(node)) { - var typeName = node.getText(ctx.sourceFile); - for (var _i = 0, _a = ctx.options; _i < _a.length; _i++) { - var ban = _a[_i]; - if (ban.pattern.test(typeName)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_FACTORY(typeName, ban.message)); - break; - } - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/binaryExpressionOperandOrderRule.d.ts b/node_modules/tslint/lib/rules/binaryExpressionOperandOrderRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/binaryExpressionOperandOrderRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/binaryExpressionOperandOrderRule.js b/node_modules/tslint/lib/rules/binaryExpressionOperandOrderRule.js deleted file mode 100644 index 87a6f2bed..000000000 --- a/node_modules/tslint/lib/rules/binaryExpressionOperandOrderRule.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../language/utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "binary-expression-operand-order", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n In a binary expression, a literal should always be on the right-hand side if possible.\n For example, prefer 'x + 1' over '1 + x'."], ["\n In a binary expression, a literal should always be on the right-hand side if possible.\n For example, prefer 'x + 1' over '1 + x'."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Expressions like `1 + x` are sometimes referred to as \"Yoda\" expressions because they read\n opposite to how we would normally speak the expression.\n\n Sticking to a consistent grammar for conditions helps keep code readable and understandable.\n "], ["\n Expressions like \\`1 + x\\` are sometimes referred to as \"Yoda\" expressions because they read\n opposite to how we would normally speak the expression.\n\n Sticking to a consistent grammar for conditions helps keep code readable and understandable.\n "]))), - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Literal expression should be on the right-hand side of a binary expression."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBinaryExpression(node) && isLiteral(node.left) && !isLiteral(node.right) && !isAllowedOrderedOperator(node)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - ts.forEachChild(node, cb); - }); -} -/** Allows certain inherently ordered operators that can't easily be written with the literal on the right. */ -function isAllowedOrderedOperator(node) { - switch (node.operatorToken.kind) { - case ts.SyntaxKind.PlusToken: - // Allow `"foo" + x` but not `1 + x`. - return node.left.kind === ts.SyntaxKind.StringLiteral; - case ts.SyntaxKind.MinusToken: - case ts.SyntaxKind.SlashToken: - case ts.SyntaxKind.PercentToken: - case ts.SyntaxKind.LessThanLessThanToken: - case ts.SyntaxKind.GreaterThanGreaterThanToken: - case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken: - case ts.SyntaxKind.AsteriskAsteriskToken: - case ts.SyntaxKind.InKeyword: - case ts.SyntaxKind.CommaToken: - return true; - default: - return false; - } -} -function isLiteral(node) { - switch (node.kind) { - case ts.SyntaxKind.StringLiteral: - case ts.SyntaxKind.NumericLiteral: - case ts.SyntaxKind.TrueKeyword: - case ts.SyntaxKind.FalseKeyword: - case ts.SyntaxKind.NullKeyword: - return true; - case ts.SyntaxKind.Identifier: - return node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; - case ts.SyntaxKind.PrefixUnaryExpression: - return utils_1.isNegativeNumberLiteral(node); - case ts.SyntaxKind.ParenthesizedExpression: - return isLiteral(node.expression); - default: - return false; - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/callableTypesRule.d.ts b/node_modules/tslint/lib/rules/callableTypesRule.d.ts deleted file mode 100644 index a731d581d..000000000 --- a/node_modules/tslint/lib/rules/callableTypesRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(type: string, sigSuggestion: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/callableTypesRule.js b/node_modules/tslint/lib/rules/callableTypesRule.js deleted file mode 100644 index 3e569fe1c..000000000 --- a/node_modules/tslint/lib/rules/callableTypesRule.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (type, sigSuggestion) { - return type + " has only a call signature \u2014 use `" + sigSuggestion + "` instead."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "callable-types", - description: "An interface or literal type with just a call signature can be written as a function type.", - rationale: "style", - optionsDescription: "Not configurable.", - options: null, - type: "style", - typescriptOnly: true, - hasFix: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if ((tsutils_1.isInterfaceDeclaration(node) && noSupertype(node) || tsutils_1.isTypeLiteralNode(node)) - && node.members.length === 1) { - var member = node.members[0]; - if (tsutils_1.isCallSignatureDeclaration(member) && - // avoid bad parse - member.type !== undefined) { - var suggestion = renderSuggestion(member, node, ctx.sourceFile); - var fixStart = node.kind === ts.SyntaxKind.TypeLiteral - ? node.getStart(ctx.sourceFile) - : tsutils_1.getChildOfKind(node, ts.SyntaxKind.InterfaceKeyword).getStart(ctx.sourceFile); - ctx.addFailureAtNode(member, Rule.FAILURE_STRING_FACTORY(node.kind === ts.SyntaxKind.TypeLiteral ? "Type literal" : "Interface", suggestion), Lint.Replacement.replaceFromTo(fixStart, node.end, suggestion)); - } - } - return ts.forEachChild(node, cb); - }); -} -/** True if there is no supertype or if the supertype is `Function`. */ -function noSupertype(node) { - if (node.heritageClauses === undefined) { - return true; - } - if (node.heritageClauses.length !== 1) { - return false; - } - var expr = node.heritageClauses[0].types[0].expression; - return tsutils_1.isIdentifier(expr) && expr.text === "Function"; -} -function renderSuggestion(call, parent, sourceFile) { - var start = call.getStart(sourceFile); - var colonPos = call.type.pos - 1 - start; - var text = sourceFile.text.substring(start, call.end); - var suggestion = text.substr(0, colonPos) + " =>" + text.substr(colonPos + 1); - if (shouldWrapSuggestion(parent.parent)) { - suggestion = "(" + suggestion + ")"; - } - if (parent.kind === ts.SyntaxKind.InterfaceDeclaration) { - if (parent.typeParameters !== undefined) { - return "type" + sourceFile.text.substring(parent.name.pos, parent.typeParameters.end + 1) + " = " + suggestion; - } - else { - return "type " + parent.name.text + " = " + suggestion; - } - } - return suggestion.endsWith(";") ? suggestion.slice(0, -1) : suggestion; -} -function shouldWrapSuggestion(parent) { - switch (parent.kind) { - case ts.SyntaxKind.UnionType: - case ts.SyntaxKind.IntersectionType: - case ts.SyntaxKind.ArrayType: - return true; - default: - return false; - } -} diff --git a/node_modules/tslint/lib/rules/classNameRule.d.ts b/node_modules/tslint/lib/rules/classNameRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/classNameRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/classNameRule.js b/node_modules/tslint/lib/rules/classNameRule.js deleted file mode 100644 index 3d72541e2..000000000 --- a/node_modules/tslint/lib/rules/classNameRule.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "class-name", - description: "Enforces PascalCased class and interface names.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Makes it easy to differentiate classes from regular variables at a glance.\n\n JavaScript and general programming convention is to refer to classes in PascalCase.\n It's confusing to use camelCase or other conventions for class names.\n "], ["\n Makes it easy to differentiate classes from regular variables at a glance.\n\n JavaScript and general programming convention is to refer to classes in PascalCase.\n It's confusing to use camelCase or other conventions for class names.\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Class name must be in pascal case"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isClassLikeDeclaration(node) && node.name !== undefined || - tsutils_1.isInterfaceDeclaration(node)) { - if (!utils_1.isPascalCased(node.name.text)) { - ctx.addFailureAtNode(node.name, Rule.FAILURE_STRING); - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/commentFormatRule.d.ts b/node_modules/tslint/lib/rules/commentFormatRule.d.ts deleted file mode 100644 index 3f9d070dd..000000000 --- a/node_modules/tslint/lib/rules/commentFormatRule.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static LOWERCASE_FAILURE: string; - static UPPERCASE_FAILURE: string; - static LEADING_SPACE_FAILURE: string; - static IGNORE_WORDS_FAILURE_FACTORY: (words: string[]) => string; - static IGNORE_PATTERN_FAILURE_FACTORY: (pattern: string) => string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/commentFormatRule.js b/node_modules/tslint/lib/rules/commentFormatRule.js deleted file mode 100644 index 050a251dd..000000000 --- a/node_modules/tslint/lib/rules/commentFormatRule.js +++ /dev/null @@ -1,166 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var enableDisableRules_1 = require("../enableDisableRules"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var OPTION_SPACE = "check-space"; -var OPTION_LOWERCASE = "check-lowercase"; -var OPTION_UPPERCASE = "check-uppercase"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "comment-format", - description: "Enforces formatting rules for single-line comments.", - rationale: "Helps maintain a consistent, readable style in your codebase.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Three arguments may be optionally provided:\n\n * `\"check-space\"` requires that all single-line comments must begin with a space, as in `// comment`\n * note that for comments starting with multiple slashes, e.g. `///`, leading slashes are ignored\n * TypeScript reference comments are ignored completely\n * `\"check-lowercase\"` requires that the first non-whitespace character of a comment must be lowercase, if applicable.\n * `\"check-uppercase\"` requires that the first non-whitespace character of a comment must be uppercase, if applicable.\n\n Exceptions to `\"check-lowercase\"` or `\"check-uppercase\"` can be managed with object that may be passed as last argument.\n\n One of two options can be provided in this object:\n\n * `\"ignore-words\"` - array of strings - words that will be ignored at the beginning of the comment.\n * `\"ignore-pattern\"` - string - RegExp pattern that will be ignored at the beginning of the comment.\n "], ["\n Three arguments may be optionally provided:\n\n * \\`\"check-space\"\\` requires that all single-line comments must begin with a space, as in \\`// comment\\`\n * note that for comments starting with multiple slashes, e.g. \\`///\\`, leading slashes are ignored\n * TypeScript reference comments are ignored completely\n * \\`\"check-lowercase\"\\` requires that the first non-whitespace character of a comment must be lowercase, if applicable.\n * \\`\"check-uppercase\"\\` requires that the first non-whitespace character of a comment must be uppercase, if applicable.\n\n Exceptions to \\`\"check-lowercase\"\\` or \\`\"check-uppercase\"\\` can be managed with object that may be passed as last argument.\n\n One of two options can be provided in this object:\n\n * \\`\"ignore-words\"\\` - array of strings - words that will be ignored at the beginning of the comment.\n * \\`\"ignore-pattern\"\\` - string - RegExp pattern that will be ignored at the beginning of the comment.\n "]))), - options: { - type: "array", - items: { - anyOf: [ - { - type: "string", - enum: [ - "check-space", - "check-lowercase", - "check-uppercase", - ], - }, - { - type: "object", - properties: { - "ignore-words": { - type: "array", - items: { - type: "string", - }, - }, - "ignore-pattern": { - type: "string", - }, - }, - minProperties: 1, - maxProperties: 1, - }, - ], - }, - minLength: 1, - maxLength: 4, - }, - optionExamples: [ - [true, "check-space", "check-uppercase"], - [true, "check-lowercase", { "ignore-words": ["TODO", "HACK"] }], - [true, "check-lowercase", { "ignore-pattern": "STD\\w{2,3}\\b" }], - ], - type: "style", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.LOWERCASE_FAILURE = "comment must start with lowercase letter"; - Rule.UPPERCASE_FAILURE = "comment must start with uppercase letter"; - Rule.LEADING_SPACE_FAILURE = "comment must start with a space"; - Rule.IGNORE_WORDS_FAILURE_FACTORY = function (words) { return " or the word(s): " + words.join(", "); }; - Rule.IGNORE_PATTERN_FAILURE_FACTORY = function (pattern) { return " or its start must match the regex pattern \"" + pattern + "\""; }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(options) { - return tslib_1.__assign({ case: options.indexOf(OPTION_LOWERCASE) !== -1 - ? 1 /* Lower */ - : options.indexOf(OPTION_UPPERCASE) !== -1 - ? 2 /* Upper */ - : 0 /* None */, failureSuffix: "", space: options.indexOf(OPTION_SPACE) !== -1 }, composeExceptions(options[options.length - 1])); -} -function composeExceptions(option) { - if (typeof option !== "object") { - return undefined; - } - var ignorePattern = option["ignore-pattern"]; - if (ignorePattern !== undefined) { - return { - exceptions: new RegExp("^\\s*(" + ignorePattern + ")"), - failureSuffix: Rule.IGNORE_PATTERN_FAILURE_FACTORY(ignorePattern), - }; - } - var ignoreWords = option["ignore-words"]; - if (ignoreWords !== undefined && ignoreWords.length !== 0) { - return { - exceptions: new RegExp("^\\s*(?:" + ignoreWords.map(function (word) { return utils_1.escapeRegExp(word.trim()); }).join("|") + ")\\b"), - failureSuffix: Rule.IGNORE_WORDS_FAILURE_FACTORY(ignoreWords), - }; - } - return undefined; -} -function walk(ctx) { - utils.forEachComment(ctx.sourceFile, function (fullText, _a) { - var kind = _a.kind, pos = _a.pos, end = _a.end; - var start = pos + 2; - if (kind !== ts.SyntaxKind.SingleLineCommentTrivia || - // exclude empty comments - start === end || - // exclude /// <reference path="..."> - fullText[start] === "/" && ctx.sourceFile.referencedFiles.some(function (ref) { return ref.pos >= pos && ref.end <= end; })) { - return; - } - // skip all leading slashes - while (fullText[start] === "/") { - ++start; - } - if (start === end) { - return; - } - var commentText = fullText.slice(start, end); - // whitelist //#region and //#endregion and JetBrains IDEs' "//noinspection ..." - if (/^(?:#(?:end)?region|noinspection\s)/.test(commentText)) { - return; - } - if (ctx.options.space && commentText[0] !== " ") { - ctx.addFailure(start, end, Rule.LEADING_SPACE_FAILURE, [Lint.Replacement.appendText(start, " ")]); - } - if (ctx.options.case === 0 /* None */ || - ctx.options.exceptions !== undefined && ctx.options.exceptions.test(commentText) || - enableDisableRules_1.ENABLE_DISABLE_REGEX.test(commentText)) { - return; - } - // search for first non-space character to check if lower or upper - var charPos = commentText.search(/\S/); - if (charPos === -1) { - return; - } - if (ctx.options.case === 1 /* Lower */) { - if (!utils_1.isLowerCase(commentText[charPos])) { - ctx.addFailure(start, end, Rule.LOWERCASE_FAILURE + ctx.options.failureSuffix); - } - } - else if (!utils_1.isUpperCase(commentText[charPos])) { - ctx.addFailure(start, end, Rule.UPPERCASE_FAILURE + ctx.options.failureSuffix); - } - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts deleted file mode 100644 index 57eea1745..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { Visibility } from "../completedDocsRule"; -import { Exclusion } from "./exclusion"; -export interface IBlockExclusionDescriptor { - visibilities?: Visibility[]; -} -export declare class BlockExclusion extends Exclusion<IBlockExclusionDescriptor> { - readonly visibilities: Set<Visibility>; - excludes(node: ts.Node): boolean; -} diff --git a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js deleted file mode 100644 index 99621fa18..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var completedDocsRule_1 = require("../completedDocsRule"); -var exclusion_1 = require("./exclusion"); -var BlockExclusion = /** @class */ (function (_super) { - tslib_1.__extends(BlockExclusion, _super); - function BlockExclusion() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.visibilities = _this.createSet(_this.descriptor.visibilities); - return _this; - } - BlockExclusion.prototype.excludes = function (node) { - if (this.visibilities.has(completedDocsRule_1.ALL)) { - return false; - } - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) { - return !this.visibilities.has(completedDocsRule_1.VISIBILITY_EXPORTED); - } - return !this.visibilities.has(completedDocsRule_1.VISIBILITY_INTERNAL); - }; - return BlockExclusion; -}(exclusion_1.Exclusion)); -exports.BlockExclusion = BlockExclusion; diff --git a/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts deleted file mode 100644 index c2661a18d..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { Location, Privacy } from "../completedDocsRule"; -import { Exclusion } from "./exclusion"; -export interface IClassExclusionDescriptor { - locations?: Location[]; - privacies?: Privacy[]; -} -export declare class ClassExclusion extends Exclusion<IClassExclusionDescriptor> { - readonly locations: Set<Location>; - readonly privacies: Set<Privacy>; - excludes(node: ts.Node): boolean; - private shouldLocationBeDocumented; - private shouldPrivacyBeDocumented; -} diff --git a/node_modules/tslint/lib/rules/completed-docs/classExclusion.js b/node_modules/tslint/lib/rules/completed-docs/classExclusion.js deleted file mode 100644 index 5fffc2e62..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/classExclusion.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var completedDocsRule_1 = require("../completedDocsRule"); -var exclusion_1 = require("./exclusion"); -var ClassExclusion = /** @class */ (function (_super) { - tslib_1.__extends(ClassExclusion, _super); - function ClassExclusion() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.locations = _this.createSet(_this.descriptor.locations); - _this.privacies = _this.createSet(_this.descriptor.privacies); - return _this; - } - ClassExclusion.prototype.excludes = function (node) { - return !(this.shouldLocationBeDocumented(node) - && this.shouldPrivacyBeDocumented(node)); - }; - ClassExclusion.prototype.shouldLocationBeDocumented = function (node) { - if (this.locations.has(completedDocsRule_1.ALL)) { - return true; - } - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) { - return this.locations.has(completedDocsRule_1.LOCATION_STATIC); - } - return this.locations.has(completedDocsRule_1.LOCATION_INSTANCE); - }; - ClassExclusion.prototype.shouldPrivacyBeDocumented = function (node) { - if (this.privacies.has(completedDocsRule_1.ALL)) { - return true; - } - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword)) { - return this.privacies.has(completedDocsRule_1.PRIVACY_PRIVATE); - } - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword)) { - return this.privacies.has(completedDocsRule_1.PRIVACY_PROTECTED); - } - return this.privacies.has(completedDocsRule_1.PRIVACY_PUBLIC); - }; - return ClassExclusion; -}(exclusion_1.Exclusion)); -exports.ClassExclusion = ClassExclusion; diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts deleted file mode 100644 index 49c905491..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { All } from "../completedDocsRule"; -import { ExclusionDescriptor } from "./exclusionDescriptors"; -export declare abstract class Exclusion<TDescriptor extends ExclusionDescriptor> { - protected readonly descriptor: Partial<TDescriptor>; - constructor(descriptor?: Partial<TDescriptor>); - abstract excludes(node: ts.Node): boolean; - protected createSet<T extends All | string>(values?: T[]): Set<T>; -} diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusion.js b/node_modules/tslint/lib/rules/completed-docs/exclusion.js deleted file mode 100644 index ff22207c6..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/exclusion.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var completedDocsRule_1 = require("../completedDocsRule"); -var Exclusion = /** @class */ (function () { - function Exclusion(descriptor) { - if (descriptor === void 0) { descriptor = {}; } - this.descriptor = descriptor; - } - Exclusion.prototype.createSet = function (values) { - if (values === undefined || values.length === 0) { - values = [completedDocsRule_1.ALL]; - } - return new Set(values); - }; - return Exclusion; -}()); -exports.Exclusion = Exclusion; diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts deleted file mode 100644 index 9fa377421..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { DocType } from "../completedDocsRule"; -import { IBlockExclusionDescriptor } from "./blockExclusion"; -import { IClassExclusionDescriptor } from "./classExclusion"; -import { ITagExclusionDescriptor } from "./tagExclusion"; -export declare type ExclusionDescriptor = IBlockExclusionDescriptor | IClassExclusionDescriptor | ITagExclusionDescriptor; -export declare type InputExclusionDescriptor = boolean | ExclusionDescriptor; -export interface IExclusionDescriptors { - [type: string]: ExclusionDescriptor; -} -export declare type IInputExclusionDescriptors = DocType | { - [type: string]: InputExclusionDescriptor; -}; diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js deleted file mode 100644 index 1c258a5da..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts deleted file mode 100644 index 3148a1ee6..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { DocType } from "../completedDocsRule"; -import { Exclusion } from "./exclusion"; -import { IInputExclusionDescriptors } from "./exclusionDescriptors"; -export declare type ExclusionsMap = Map<DocType, Array<Exclusion<any>>>; -export declare class ExclusionFactory { - constructExclusionsMap(ruleArguments: IInputExclusionDescriptors[]): ExclusionsMap; - private addRequirements; - private createRequirementsForDocType; -} diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js deleted file mode 100644 index 6b8f5f35a..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var utils_1 = require("../../utils"); -var blockExclusion_1 = require("./blockExclusion"); -var classExclusion_1 = require("./classExclusion"); -var tagExclusion_1 = require("./tagExclusion"); -var ExclusionFactory = /** @class */ (function () { - function ExclusionFactory() { - } - ExclusionFactory.prototype.constructExclusionsMap = function (ruleArguments) { - var exclusionsMap = new Map(); - for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) { - var ruleArgument = ruleArguments_1[_i]; - this.addRequirements(exclusionsMap, ruleArgument); - } - return exclusionsMap; - }; - ExclusionFactory.prototype.addRequirements = function (exclusionsMap, descriptors) { - if (typeof descriptors === "string") { - exclusionsMap.set(descriptors, this.createRequirementsForDocType(descriptors, {})); - return; - } - for (var docType in descriptors) { - if (utils_1.hasOwnProperty(descriptors, docType)) { - exclusionsMap.set(docType, this.createRequirementsForDocType(docType, descriptors[docType])); - } - } - }; - ExclusionFactory.prototype.createRequirementsForDocType = function (docType, descriptor) { - var requirements = []; - if (docType === "methods" || docType === "properties") { - requirements.push(new classExclusion_1.ClassExclusion(descriptor)); - } - else { - requirements.push(new blockExclusion_1.BlockExclusion(descriptor)); - } - if (descriptor.tags !== undefined) { - requirements.push(new tagExclusion_1.TagExclusion(descriptor)); - } - return requirements; - }; - return ExclusionFactory; -}()); -exports.ExclusionFactory = ExclusionFactory; diff --git a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts deleted file mode 100644 index 57fd0cf8d..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import { Exclusion } from "./exclusion"; -export interface ITagExclusionDescriptor { - tags?: { - content: IContentTags; - existence: string[]; - }; -} -export interface IContentTags { - [i: string]: string; -} -export declare class TagExclusion extends Exclusion<ITagExclusionDescriptor> { - private readonly contentTags; - private readonly existenceTags; - excludes(node: ts.Node): boolean; - private getDocumentationNode; - private parseTagsWithContents; -} diff --git a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js deleted file mode 100644 index 78e9babe7..000000000 --- a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var exclusion_1 = require("./exclusion"); -var TagExclusion = /** @class */ (function (_super) { - tslib_1.__extends(TagExclusion, _super); - function TagExclusion() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.contentTags = _this.descriptor.tags === undefined - ? {} - : _this.descriptor.tags.content; - _this.existenceTags = new Set(_this.descriptor.tags !== undefined && _this.descriptor.tags.existence !== undefined - ? _this.descriptor.tags.existence - : undefined); - return _this; - } - TagExclusion.prototype.excludes = function (node) { - var documentationNode = this.getDocumentationNode(node); - var tagsWithContents = this.parseTagsWithContents(documentationNode.getFullText()); - for (var _i = 0, tagsWithContents_1 = tagsWithContents; _i < tagsWithContents_1.length; _i++) { - var tagWithContent = tagsWithContents_1[_i]; - if (this.existenceTags.has(tagWithContent[0])) { - return true; - } - var matcherBody = this.contentTags[tagWithContent[0]]; - if (matcherBody === undefined) { - continue; - } - if (new RegExp(matcherBody).test(tagWithContent[1])) { - return true; - } - } - return false; - }; - TagExclusion.prototype.getDocumentationNode = function (node) { - if (node.kind === ts.SyntaxKind.VariableDeclaration) { - return node.parent; - } - return node; - }; - TagExclusion.prototype.parseTagsWithContents = function (nodeText) { - if (nodeText === undefined) { - return []; - } - var docMatches = nodeText.match((/\/\*\*\s*\n([^\*]*(\*[^\/])?)*\*\//)); - if (docMatches === null || docMatches.length === 0) { - return []; - } - var lines = docMatches[0].match(/[\r\n\s]*\*\s*@.*[\r\n\s]/g); - if (lines === null) { - return []; - } - return lines - .map(function (line) { - var body = line.substring(line.indexOf("@")); - var firstSpaceIndex = body.search(/\s/); - return [ - body.substring(1, firstSpaceIndex), - body.substring(firstSpaceIndex).trim(), - ]; - }); - }; - return TagExclusion; -}(exclusion_1.Exclusion)); -exports.TagExclusion = TagExclusion; diff --git a/node_modules/tslint/lib/rules/completedDocsRule.d.ts b/node_modules/tslint/lib/rules/completedDocsRule.d.ts deleted file mode 100644 index d876d8c64..000000000 --- a/node_modules/tslint/lib/rules/completedDocsRule.d.ts +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -import { IInputExclusionDescriptors } from "./completed-docs/exclusionDescriptors"; -export declare const ALL = "all"; -export declare const ARGUMENT_CLASSES = "classes"; -export declare const ARGUMENT_ENUMS = "enums"; -export declare const ARGUMENT_ENUM_MEMBERS = "enum-members"; -export declare const ARGUMENT_FUNCTIONS = "functions"; -export declare const ARGUMENT_INTERFACES = "interfaces"; -export declare const ARGUMENT_METHODS = "methods"; -export declare const ARGUMENT_NAMESPACES = "namespaces"; -export declare const ARGUMENT_PROPERTIES = "properties"; -export declare const ARGUMENT_TYPES = "types"; -export declare const ARGUMENT_VARIABLES = "variables"; -export declare const DESCRIPTOR_TAGS = "tags"; -export declare const DESCRIPTOR_LOCATIONS = "locations"; -export declare const DESCRIPTOR_PRIVACIES = "privacies"; -export declare const DESCRIPTOR_VISIBILITIES = "visibilities"; -export declare const LOCATION_INSTANCE = "instance"; -export declare const LOCATION_STATIC = "static"; -export declare const PRIVACY_PRIVATE = "private"; -export declare const PRIVACY_PROTECTED = "protected"; -export declare const PRIVACY_PUBLIC = "public"; -export declare const TAGS_FOR_CONTENT = "content"; -export declare const TAGS_FOR_EXISTENCE = "existence"; -export declare const VISIBILITY_EXPORTED = "exported"; -export declare const VISIBILITY_INTERNAL = "internal"; -export declare type All = typeof ALL; -export declare type DocType = All | typeof ARGUMENT_CLASSES | typeof ARGUMENT_ENUMS | typeof ARGUMENT_ENUM_MEMBERS | typeof ARGUMENT_FUNCTIONS | typeof ARGUMENT_INTERFACES | typeof ARGUMENT_METHODS | typeof ARGUMENT_NAMESPACES | typeof ARGUMENT_PROPERTIES | typeof ARGUMENT_TYPES | typeof ARGUMENT_VARIABLES; -export declare type Location = All | typeof LOCATION_INSTANCE | typeof LOCATION_STATIC; -export declare type Privacy = All | typeof PRIVACY_PRIVATE | typeof PRIVACY_PROTECTED | typeof PRIVACY_PUBLIC; -export declare type Visibility = All | typeof VISIBILITY_EXPORTED | typeof VISIBILITY_INTERNAL; -export declare class Rule extends Lint.Rules.TypedRule { - static FAILURE_STRING_EXIST: string; - static defaultArguments: IInputExclusionDescriptors; - static ARGUMENT_DESCRIPTOR_BLOCK: { - properties: { - [DESCRIPTOR_TAGS]: { - properties: { - [TAGS_FOR_CONTENT]: { - items: { - type: string; - }; - type: string; - }; - [TAGS_FOR_EXISTENCE]: { - items: { - type: string; - }; - type: string; - }; - }; - }; - [DESCRIPTOR_VISIBILITIES]: { - enum: string[]; - type: string; - }; - }; - type: string; - }; - static ARGUMENT_DESCRIPTOR_CLASS: { - properties: { - [DESCRIPTOR_TAGS]: { - properties: { - [TAGS_FOR_CONTENT]: { - items: { - type: string; - }; - type: string; - }; - [TAGS_FOR_EXISTENCE]: { - items: { - type: string; - }; - type: string; - }; - }; - }; - [DESCRIPTOR_LOCATIONS]: { - enum: string[]; - type: string; - }; - [DESCRIPTOR_PRIVACIES]: { - enum: string[]; - type: string; - }; - }; - type: string; - }; - static metadata: Lint.IRuleMetadata; - private readonly exclusionFactory; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; - private getExclusionsMap; -} diff --git a/node_modules/tslint/lib/rules/completedDocsRule.js b/node_modules/tslint/lib/rules/completedDocsRule.js deleted file mode 100644 index 9333c44ac..000000000 --- a/node_modules/tslint/lib/rules/completedDocsRule.js +++ /dev/null @@ -1,344 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; -var ts = require("typescript"); -var Lint = require("../index"); -var exclusionFactory_1 = require("./completed-docs/exclusionFactory"); -exports.ALL = "all"; -exports.ARGUMENT_CLASSES = "classes"; -exports.ARGUMENT_ENUMS = "enums"; -exports.ARGUMENT_ENUM_MEMBERS = "enum-members"; -exports.ARGUMENT_FUNCTIONS = "functions"; -exports.ARGUMENT_INTERFACES = "interfaces"; -exports.ARGUMENT_METHODS = "methods"; -exports.ARGUMENT_NAMESPACES = "namespaces"; -exports.ARGUMENT_PROPERTIES = "properties"; -exports.ARGUMENT_TYPES = "types"; -exports.ARGUMENT_VARIABLES = "variables"; -exports.DESCRIPTOR_TAGS = "tags"; -exports.DESCRIPTOR_LOCATIONS = "locations"; -exports.DESCRIPTOR_PRIVACIES = "privacies"; -exports.DESCRIPTOR_VISIBILITIES = "visibilities"; -exports.LOCATION_INSTANCE = "instance"; -exports.LOCATION_STATIC = "static"; -exports.PRIVACY_PRIVATE = "private"; -exports.PRIVACY_PROTECTED = "protected"; -exports.PRIVACY_PUBLIC = "public"; -exports.TAGS_FOR_CONTENT = "content"; -exports.TAGS_FOR_EXISTENCE = "existence"; -exports.VISIBILITY_EXPORTED = "exported"; -exports.VISIBILITY_INTERNAL = "internal"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /* tslint:enable:object-literal-sort-keys */ - _this.exclusionFactory = new exclusionFactory_1.ExclusionFactory(); - return _this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - var options = this.getOptions(); - var exclusionsMap = this.getExclusionsMap(options.ruleArguments); - return this.applyWithFunction(sourceFile, walk, exclusionsMap, program.getTypeChecker()); - }; - Rule.prototype.getExclusionsMap = function (ruleArguments) { - if (ruleArguments.length === 0) { - ruleArguments = [Rule.defaultArguments]; - } - return this.exclusionFactory.constructExclusionsMap(ruleArguments); - }; - Rule.FAILURE_STRING_EXIST = "Documentation must exist for "; - Rule.defaultArguments = (_a = {}, - _a[exports.ARGUMENT_CLASSES] = true, - _a[exports.ARGUMENT_FUNCTIONS] = true, - _a[exports.ARGUMENT_METHODS] = (_b = {}, - _b[exports.DESCRIPTOR_TAGS] = (_c = {}, - _c[exports.TAGS_FOR_CONTENT] = { - see: ".*", - }, - _c[exports.TAGS_FOR_EXISTENCE] = [ - "deprecated", - "inheritdoc", - ], - _c), - _b), - _a[exports.ARGUMENT_PROPERTIES] = (_d = {}, - _d[exports.DESCRIPTOR_TAGS] = (_e = {}, - _e[exports.TAGS_FOR_CONTENT] = { - see: ".*", - }, - _e[exports.TAGS_FOR_EXISTENCE] = [ - "deprecated", - "inheritdoc", - ], - _e), - _d), - _a); - Rule.ARGUMENT_DESCRIPTOR_BLOCK = { - properties: (_f = {}, - _f[exports.DESCRIPTOR_TAGS] = { - properties: (_g = {}, - _g[exports.TAGS_FOR_CONTENT] = { - items: { - type: "string", - }, - type: "object", - }, - _g[exports.TAGS_FOR_EXISTENCE] = { - items: { - type: "string", - }, - type: "array", - }, - _g), - }, - _f[exports.DESCRIPTOR_VISIBILITIES] = { - enum: [ - exports.ALL, - exports.VISIBILITY_EXPORTED, - exports.VISIBILITY_INTERNAL, - ], - type: "string", - }, - _f), - type: "object", - }; - Rule.ARGUMENT_DESCRIPTOR_CLASS = { - properties: (_h = {}, - _h[exports.DESCRIPTOR_TAGS] = { - properties: (_j = {}, - _j[exports.TAGS_FOR_CONTENT] = { - items: { - type: "string", - }, - type: "object", - }, - _j[exports.TAGS_FOR_EXISTENCE] = { - items: { - type: "string", - }, - type: "array", - }, - _j), - }, - _h[exports.DESCRIPTOR_LOCATIONS] = { - enum: [ - exports.ALL, - exports.LOCATION_INSTANCE, - exports.LOCATION_STATIC, - ], - type: "string", - }, - _h[exports.DESCRIPTOR_PRIVACIES] = { - enum: [ - exports.ALL, - exports.PRIVACY_PRIVATE, - exports.PRIVACY_PROTECTED, - exports.PRIVACY_PUBLIC, - ], - type: "string", - }, - _h), - type: "object", - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "completed-docs", - description: "Enforces JSDoc comments for important items be filled out.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n `true` to enable for `[", "]`,\n or an array with each item in one of two formats:\n\n * `string` to enable for that type\n * `object` keying types to when their documentation is required:\n * `\"", "\"` and `\"", "\"` may specify:\n * `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * Other types may specify `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * All types may also provide `\"", "\"`\n with members specifying tags that allow the docs to not have a body.\n * `\"", "\"`: Object mapping tags to `RegExp` bodies content allowed to count as complete docs.\n * `\"", "\"`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`"], ["\n \\`true\\` to enable for \\`[", "]\\`,\n or an array with each item in one of two formats:\n\n * \\`string\\` to enable for that type\n * \\`object\\` keying types to when their documentation is required:\n * \\`\"", "\"\\` and \\`\"", "\"\\` may specify:\n * \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * Other types may specify \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * All types may also provide \\`\"", "\"\\`\n with members specifying tags that allow the docs to not have a body.\n * \\`\"", "\"\\`: Object mapping tags to \\`RegExp\\` bodies content allowed to count as complete docs.\n * \\`\"", "\"\\`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`"])), Object.keys(Rule.defaultArguments).join(", "), exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.DESCRIPTOR_PRIVACIES, exports.ALL, exports.PRIVACY_PRIVATE, exports.PRIVACY_PROTECTED, exports.PRIVACY_PUBLIC, exports.DESCRIPTOR_LOCATIONS, exports.ALL, exports.LOCATION_INSTANCE, exports.LOCATION_STATIC, exports.DESCRIPTOR_VISIBILITIES, exports.ALL, exports.VISIBILITY_EXPORTED, exports.VISIBILITY_INTERNAL, exports.DESCRIPTOR_TAGS, exports.TAGS_FOR_CONTENT, exports.TAGS_FOR_EXISTENCE, exports.ARGUMENT_CLASSES, exports.ARGUMENT_ENUMS, exports.ARGUMENT_ENUM_MEMBERS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES), - options: { - type: "array", - items: { - anyOf: [ - { - options: [ - exports.ARGUMENT_CLASSES, - exports.ARGUMENT_ENUMS, - exports.ARGUMENT_FUNCTIONS, - exports.ARGUMENT_INTERFACES, - exports.ARGUMENT_METHODS, - exports.ARGUMENT_NAMESPACES, - exports.ARGUMENT_PROPERTIES, - exports.ARGUMENT_TYPES, - exports.ARGUMENT_VARIABLES, - ], - type: "string", - }, - { - type: "object", - properties: (_k = {}, - _k[exports.ARGUMENT_CLASSES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_ENUMS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_ENUM_MEMBERS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_FUNCTIONS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_INTERFACES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_METHODS] = Rule.ARGUMENT_DESCRIPTOR_CLASS, - _k[exports.ARGUMENT_NAMESPACES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_PROPERTIES] = Rule.ARGUMENT_DESCRIPTOR_CLASS, - _k[exports.ARGUMENT_TYPES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k[exports.ARGUMENT_VARIABLES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK, - _k), - }, - ], - }, - }, - optionExamples: [ - true, - [true, exports.ARGUMENT_ENUMS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_METHODS], - [ - true, - (_l = {}, - _l[exports.ARGUMENT_ENUMS] = true, - _l[exports.ARGUMENT_FUNCTIONS] = (_m = {}, - _m[exports.DESCRIPTOR_VISIBILITIES] = [exports.VISIBILITY_EXPORTED], - _m), - _l[exports.ARGUMENT_METHODS] = (_o = {}, - _o[exports.DESCRIPTOR_LOCATIONS] = exports.LOCATION_INSTANCE, - _o[exports.DESCRIPTOR_PRIVACIES] = [exports.PRIVACY_PUBLIC, exports.PRIVACY_PROTECTED], - _o), - _l[exports.ARGUMENT_PROPERTIES] = (_p = {}, - _p[exports.DESCRIPTOR_TAGS] = (_q = {}, - _q[exports.TAGS_FOR_CONTENT] = { - see: ["#.*"], - }, - _q[exports.TAGS_FOR_EXISTENCE] = ["inheritdoc"], - _q), - _p), - _l), - ], - ], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Helps ensure important components are documented.\n\n Note: use this rule sparingly. It's better to have self-documenting names on components with single, consice responsibilities.\n Comments that only restate the names of variables add nothing to code, and can easily become outdated.\n "], ["\n Helps ensure important components are documented.\n\n Note: use this rule sparingly. It's better to have self-documenting names on components with single, consice responsibilities.\n Comments that only restate the names of variables add nothing to code, and can easily become outdated.\n "]))), - type: "style", - typescriptOnly: false, - requiresTypeInfo: true, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -var modifierAliases = { - export: "exported", -}; -function walk(context, typeChecker) { - return ts.forEachChild(context.sourceFile, cb); - function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ClassDeclaration: - checkNode(node, exports.ARGUMENT_CLASSES); - break; - case ts.SyntaxKind.EnumDeclaration: - checkNode(node, exports.ARGUMENT_ENUMS); - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - // Enum members don't have modifiers, so use the parent - // enum declaration when checking the requirements. - checkNode(member, exports.ARGUMENT_ENUM_MEMBERS, node); - } - break; - case ts.SyntaxKind.FunctionDeclaration: - checkNode(node, exports.ARGUMENT_FUNCTIONS); - break; - case ts.SyntaxKind.InterfaceDeclaration: - checkNode(node, exports.ARGUMENT_INTERFACES); - break; - case ts.SyntaxKind.MethodDeclaration: - if (node.parent.kind !== ts.SyntaxKind.ObjectLiteralExpression) { - checkNode(node, exports.ARGUMENT_METHODS); - } - break; - case ts.SyntaxKind.ModuleDeclaration: - checkNode(node, exports.ARGUMENT_NAMESPACES); - break; - case ts.SyntaxKind.PropertyDeclaration: - checkNode(node, exports.ARGUMENT_PROPERTIES); - break; - case ts.SyntaxKind.TypeAliasDeclaration: - checkNode(node, exports.ARGUMENT_TYPES); - break; - case ts.SyntaxKind.VariableStatement: - // Only check variables at the namespace/module-level or file-level - // and not variables declared inside functions and other things. - switch (node.parent.kind) { - case ts.SyntaxKind.SourceFile: - case ts.SyntaxKind.ModuleBlock: - for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { - var declaration = _c[_b]; - checkNode(declaration, exports.ARGUMENT_VARIABLES, node); - } - } - break; - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - if (node.parent.kind !== ts.SyntaxKind.ObjectLiteralExpression) { - checkNode(node, exports.ARGUMENT_PROPERTIES); - } - } - return ts.forEachChild(node, cb); - } - function checkNode(node, nodeType, requirementNode) { - if (requirementNode === void 0) { requirementNode = node; } - var name = node.name; - if (name === undefined) { - return; - } - var exclusions = context.options.get(nodeType); - if (exclusions === undefined) { - return; - } - for (var _i = 0, exclusions_1 = exclusions; _i < exclusions_1.length; _i++) { - var exclusion = exclusions_1[_i]; - if (exclusion.excludes(requirementNode)) { - return; - } - } - var symbol = typeChecker.getSymbolAtLocation(name); - if (symbol === undefined) { - return; - } - var comments = symbol.getDocumentationComment(typeChecker); - checkComments(node, describeNode(nodeType), comments, requirementNode); - } - function checkComments(node, nodeDescriptor, comments, requirementNode) { - if (comments.map(function (comment) { return comment.text; }).join("").trim() === "") { - addDocumentationFailure(node, nodeDescriptor, requirementNode); - } - } - function addDocumentationFailure(node, nodeType, requirementNode) { - var start = node.getStart(); - var width = node.getText().split(/\r|\n/g)[0].length; - var description = describeDocumentationFailure(requirementNode, nodeType); - context.addFailureAt(start, width, description); - } -} -function describeDocumentationFailure(node, nodeType) { - var description = Rule.FAILURE_STRING_EXIST; - if (node.modifiers !== undefined) { - description += node.modifiers.map(function (modifier) { return describeModifier(modifier.kind); }).join(" ") + " "; - } - return "" + description + nodeType + "."; -} -function describeModifier(kind) { - var description = ts.SyntaxKind[kind].toLowerCase().split("keyword")[0]; - var alias = modifierAliases[description]; - return alias !== undefined ? alias : description; -} -function describeNode(nodeType) { - return nodeType.replace("-", " "); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/curlyRule.d.ts b/node_modules/tslint/lib/rules/curlyRule.d.ts deleted file mode 100644 index 13fc07684..000000000 --- a/node_modules/tslint/lib/rules/curlyRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_AS_NEEDED: string; - static FAILURE_STRING_FACTORY(kind: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/curlyRule.js b/node_modules/tslint/lib/rules/curlyRule.js deleted file mode 100644 index c6421dd83..000000000 --- a/node_modules/tslint/lib/rules/curlyRule.js +++ /dev/null @@ -1,157 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var curly_examples_1 = require("./code-examples/curly.examples"); -var OPTION_AS_NEEDED = "as-needed"; -var OPTION_IGNORE_SAME_LINE = "ignore-same-line"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING_FACTORY = function (kind) { - return kind + " statements must be braced"; - }; - Rule.prototype.apply = function (sourceFile) { - if (this.ruleArguments.indexOf(OPTION_AS_NEEDED) !== -1) { - return this.applyWithFunction(sourceFile, walkAsNeeded); - } - return this.applyWithWalker(new CurlyWalker(sourceFile, this.ruleName, { - ignoreSameLine: this.ruleArguments.indexOf(OPTION_IGNORE_SAME_LINE) !== -1, - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "curly", - description: "Enforces braces for `if`/`for`/`do`/`while` statements.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ```ts\n if (foo === bar)\n foo++;\n bar++;\n ```\n\n In the code above, the author almost certainly meant for both `foo++` and `bar++`\n to be executed only if `foo === bar`. However, they forgot braces and `bar++` will be executed\n no matter what. This rule could prevent such a mistake."], ["\n \\`\\`\\`ts\n if (foo === bar)\n foo++;\n bar++;\n \\`\\`\\`\n\n In the code above, the author almost certainly meant for both \\`foo++\\` and \\`bar++\\`\n to be executed only if \\`foo === bar\\`. However, they forgot braces and \\`bar++\\` will be executed\n no matter what. This rule could prevent such a mistake."]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n One of the following options may be provided:\n\n * `\"", "\"` forbids any unnecessary curly braces.\n * `\"", "\"` skips checking braces for control-flow statements\n that are on one line and start on the same line as their control-flow keyword\n "], ["\n One of the following options may be provided:\n\n * \\`\"", "\"\\` forbids any unnecessary curly braces.\n * \\`\"", "\"\\` skips checking braces for control-flow statements\n that are on one line and start on the same line as their control-flow keyword\n "])), OPTION_AS_NEEDED, OPTION_IGNORE_SAME_LINE), - options: { - type: "array", - items: { - type: "string", - enum: [ - OPTION_AS_NEEDED, - OPTION_IGNORE_SAME_LINE, - ], - }, - }, - optionExamples: [ - true, - [true, OPTION_IGNORE_SAME_LINE], - [true, OPTION_AS_NEEDED], - ], - type: "functionality", - typescriptOnly: false, - hasFix: true, - codeExamples: curly_examples_1.codeExamples, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_AS_NEEDED = "Block contains only one statement; remove the curly braces."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walkAsNeeded(ctx) { - ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBlock(node) && isBlockUnnecessary(node)) { - ctx.addFailureAt(node.statements.pos - 1, 1, Rule.FAILURE_STRING_AS_NEEDED); - } - ts.forEachChild(node, cb); - }); -} -function isBlockUnnecessary(node) { - var parent = node.parent; - if (node.statements.length !== 1) { - return false; - } - var statement = node.statements[0]; - if (tsutils_1.isIterationStatement(parent)) { - return true; - } - /* - Watch out for this case: - if (so) { - if (also) - foo(); - } else - bar(); - */ - return tsutils_1.isIfStatement(parent) && !(tsutils_1.isIfStatement(statement) - && statement.elseStatement === undefined - && parent.thenStatement === node - && parent.elseStatement !== undefined); -} -var CurlyWalker = /** @class */ (function (_super) { - tslib_1.__extends(CurlyWalker, _super); - function CurlyWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - CurlyWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (tsutils_1.isIterationStatement(node)) { - _this.checkStatement(node.statement, node, 0, node.end); - } - else if (tsutils_1.isIfStatement(node)) { - _this.checkStatement(node.thenStatement, node, 0); - if (node.elseStatement !== undefined && node.elseStatement.kind !== ts.SyntaxKind.IfStatement) { - _this.checkStatement(node.elseStatement, node, 5); - } - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - CurlyWalker.prototype.checkStatement = function (statement, node, childIndex, end) { - if (end === void 0) { end = statement.end; } - var sameLine = tsutils_1.isSameLine(this.sourceFile, statement.pos, statement.end); - if (statement.kind !== ts.SyntaxKind.Block && - !(this.options.ignoreSameLine && sameLine)) { - var token = node.getChildAt(childIndex, this.sourceFile); - var tokenText = ts.tokenToString(token.kind); - this.addFailure(token.end - tokenText.length, end, Rule.FAILURE_STRING_FACTORY(tokenText), this.createMissingBraceFix(statement, node, sameLine)); - } - }; - /** Generate the necessary replacement to add braces to a statement that needs them. */ - CurlyWalker.prototype.createMissingBraceFix = function (statement, node, sameLine) { - if (sameLine) { - return [ - Lint.Replacement.appendText(statement.pos, " {"), - Lint.Replacement.appendText(statement.end, " }"), - ]; - } - else { - var match = /\n([\t ])/.exec(node.getFullText(this.sourceFile)); // determine which character to use (tab or space) - var indentation = match === null ? - "" : - // indentation should match start of statement - match[1].repeat(ts.getLineAndCharacterOfPosition(this.sourceFile, node.getStart(this.sourceFile)).character); - var maybeCarriageReturn = this.sourceFile.text[this.sourceFile.getLineEndOfPosition(node.pos) - 1] === "\r" ? "\r" : ""; - return [ - Lint.Replacement.appendText(statement.pos, " {"), - Lint.Replacement.appendText(statement.end, maybeCarriageReturn + "\n" + indentation + "}"), - ]; - } - }; - return CurlyWalker; -}(Lint.AbstractWalker)); -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/cyclomaticComplexityRule.d.ts b/node_modules/tslint/lib/rules/cyclomaticComplexityRule.d.ts deleted file mode 100644 index 9ca72563a..000000000 --- a/node_modules/tslint/lib/rules/cyclomaticComplexityRule.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static DEFAULT_THRESHOLD: number; - static MINIMUM_THRESHOLD: number; - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(expected: number, actual: number, name?: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; - isEnabled(): boolean; - private readonly threshold; -} diff --git a/node_modules/tslint/lib/rules/cyclomaticComplexityRule.js b/node_modules/tslint/lib/rules/cyclomaticComplexityRule.js deleted file mode 100644 index 80a665f47..000000000 --- a/node_modules/tslint/lib/rules/cyclomaticComplexityRule.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (expected, actual, name) { - return "The function" + (name === undefined ? "" : " " + name) + " has a cyclomatic complexity of " + - (actual + " which is higher than the threshold of " + expected); - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { threshold: this.threshold }); - }; - Rule.prototype.isEnabled = function () { - // Disable the rule if the option is provided but non-numeric or less than the minimum. - var isThresholdValid = typeof this.threshold === "number" && this.threshold >= Rule.MINIMUM_THRESHOLD; - return _super.prototype.isEnabled.call(this) && isThresholdValid; - }; - Object.defineProperty(Rule.prototype, "threshold", { - get: function () { - if (this.ruleArguments[0] !== undefined) { - return this.ruleArguments[0]; - } - return Rule.DEFAULT_THRESHOLD; - }, - enumerable: true, - configurable: true - }); - Rule.DEFAULT_THRESHOLD = 20; - Rule.MINIMUM_THRESHOLD = 2; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "cyclomatic-complexity", - description: "Enforces a threshold of cyclomatic complexity.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Cyclomatic complexity is assessed for each function of any type. A starting value of 0\n is assigned and this value is then incremented for every statement which can branch the\n control flow within the function. The following statements and expressions contribute\n to cyclomatic complexity:\n * `catch`\n * `if` and `? :`\n * `||` and `&&` due to short-circuit evaluation\n * `for`, `for in` and `for of` loops\n * `while` and `do while` loops\n * `case` clauses that contain statements"], ["\n Cyclomatic complexity is assessed for each function of any type. A starting value of 0\n is assigned and this value is then incremented for every statement which can branch the\n control flow within the function. The following statements and expressions contribute\n to cyclomatic complexity:\n * \\`catch\\`\n * \\`if\\` and \\`? :\\`\n * \\`||\\` and \\`&&\\` due to short-circuit evaluation\n * \\`for\\`, \\`for in\\` and \\`for of\\` loops\n * \\`while\\` and \\`do while\\` loops\n * \\`case\\` clauses that contain statements"]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Cyclomatic complexity is a code metric which indicates the level of complexity in a\n function. High cyclomatic complexity indicates confusing code which may be prone to\n errors or difficult to modify.\n\n It's better to have smaller, single-purpose functions with self-documenting names."], ["\n Cyclomatic complexity is a code metric which indicates the level of complexity in a\n function. High cyclomatic complexity indicates confusing code which may be prone to\n errors or difficult to modify.\n\n It's better to have smaller, single-purpose functions with self-documenting names."]))), - optionsDescription: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n An optional upper limit for cyclomatic complexity can be specified. If no limit option\n is provided a default value of ", " will be used."], ["\n An optional upper limit for cyclomatic complexity can be specified. If no limit option\n is provided a default value of ", " will be used."])), Rule.DEFAULT_THRESHOLD), - options: { - type: "number", - minimum: Rule.MINIMUM_THRESHOLD, - }, - optionExamples: [true, [true, 20]], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var threshold = ctx.options.threshold; - var complexity = 0; - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isFunctionScopeBoundary(node)) { - var old = complexity; - complexity = 1; - ts.forEachChild(node, cb); - if (complexity > threshold) { - var name = node.name; - var nameStr = name !== undefined && tsutils_1.isIdentifier(name) ? name.text : undefined; - ctx.addFailureAtNode(node, Rule.FAILURE_STRING(threshold, complexity, nameStr)); - } - complexity = old; - } - else { - if (increasesComplexity(node)) { - complexity++; - } - return ts.forEachChild(node, cb); - } - }); -} -function increasesComplexity(node) { - switch (node.kind) { - case ts.SyntaxKind.CaseClause: - return node.statements.length > 0; - case ts.SyntaxKind.CatchClause: - case ts.SyntaxKind.ConditionalExpression: - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.ForOfStatement: - case ts.SyntaxKind.IfStatement: - case ts.SyntaxKind.WhileStatement: - return true; - case ts.SyntaxKind.BinaryExpression: - switch (node.operatorToken.kind) { - case ts.SyntaxKind.BarBarToken: - case ts.SyntaxKind.AmpersandAmpersandToken: - return true; - default: - return false; - } - default: - return false; - } -} -var templateObject_1, templateObject_2, templateObject_3; diff --git a/node_modules/tslint/lib/rules/deprecationRule.d.ts b/node_modules/tslint/lib/rules/deprecationRule.d.ts deleted file mode 100644 index cf627b138..000000000 --- a/node_modules/tslint/lib/rules/deprecationRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string, message: string): string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/deprecationRule.js b/node_modules/tslint/lib/rules/deprecationRule.js deleted file mode 100644 index 619783700..000000000 --- a/node_modules/tslint/lib/rules/deprecationRule.js +++ /dev/null @@ -1,229 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name, message) { - return name + " is deprecated" + (message === "" ? "." : ": " + message.trim()); - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "deprecation", - description: "Warns when deprecated APIs are used.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["Any usage of an identifier\n with the @deprecated JSDoc annotation will trigger a warning.\n See http://usejsdoc.org/tags-deprecated.html"], ["Any usage of an identifier\n with the @deprecated JSDoc annotation will trigger a warning.\n See http://usejsdoc.org/tags-deprecated.html"]))), - rationale: "Deprecated APIs should be avoided, and usage updated.", - optionsDescription: "", - options: null, - optionExamples: [true], - type: "maintainability", - typescriptOnly: false, - requiresTypeInfo: true, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isIdentifier(node)) { - if (!isDeclaration(node)) { - var deprecation = getDeprecation(node, tc); - if (deprecation !== undefined) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING(node.text, deprecation)); - } - } - } - else { - switch (node.kind) { - case ts.SyntaxKind.ImportDeclaration: - case ts.SyntaxKind.ImportEqualsDeclaration: - case ts.SyntaxKind.ExportDeclaration: - case ts.SyntaxKind.ExportAssignment: - return; - } - return ts.forEachChild(node, cb); - } - }); -} -function isDeclaration(identifier) { - var parent = identifier.parent; - switch (parent.kind) { - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeParameter: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.LabeledStatement: - case ts.SyntaxKind.JsxAttribute: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.PropertySignature: - case ts.SyntaxKind.TypeAliasDeclaration: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - case ts.SyntaxKind.EnumDeclaration: - case ts.SyntaxKind.ModuleDeclaration: - return true; - case ts.SyntaxKind.VariableDeclaration: - case ts.SyntaxKind.Parameter: - case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.EnumMember: - case ts.SyntaxKind.ImportEqualsDeclaration: - return parent.name === identifier; - case ts.SyntaxKind.PropertyAssignment: - return parent.name === identifier && - !tsutils_1.isReassignmentTarget(identifier.parent.parent); - case ts.SyntaxKind.BindingElement: - // return true for `b` in `const {a: b} = obj"` - return parent.name === identifier && - parent.propertyName !== undefined; - default: - return false; - } -} -function getCallExpresion(node) { - var parent = node.parent; - if (tsutils_1.isPropertyAccessExpression(parent) && parent.name === node) { - node = parent; - parent = node.parent; - } - return tsutils_1.isTaggedTemplateExpression(parent) || (tsutils_1.isCallExpression(parent) || tsutils_1.isNewExpression(parent)) && parent.expression === node - ? parent - : undefined; -} -function getDeprecation(node, tc) { - var callExpression = getCallExpresion(node); - if (callExpression !== undefined) { - var result = getSignatureDeprecation(tc.getResolvedSignature(callExpression)); - if (result !== undefined) { - return result; - } - } - var symbol; - var parent = node.parent; - if (parent.kind === ts.SyntaxKind.BindingElement) { - symbol = tc.getTypeAtLocation(parent.parent).getProperty(node.text); - } - else if (tsutils_1.isPropertyAssignment(parent) && parent.name === node || - tsutils_1.isShorthandPropertyAssignment(parent) && parent.name === node && tsutils_1.isReassignmentTarget(node)) { - symbol = tc.getPropertySymbolOfDestructuringAssignment(node); - } - else { - symbol = tc.getSymbolAtLocation(node); - } - if (symbol !== undefined && tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) { - symbol = tc.getAliasedSymbol(symbol); - } - if (symbol === undefined || - // if this is a CallExpression and the declaration is a function or method, - // stop here to avoid collecting JsDoc of all overload signatures - callExpression !== undefined && isFunctionOrMethod(symbol.declarations)) { - return undefined; - } - return getSymbolDeprecation(symbol); -} -function findDeprecationTag(tags) { - for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { - var tag = tags_1[_i]; - if (tag.name === "deprecated") { - return tag.text === undefined ? "" : tag.text; - } - } - return undefined; -} -function getSymbolDeprecation(symbol) { - if (symbol.getJsDocTags !== undefined) { - return findDeprecationTag(symbol.getJsDocTags()); - } - // for compatibility with typescript@<2.3.0 - return getDeprecationFromDeclarations(symbol.declarations); -} -function getSignatureDeprecation(signature) { - if (signature === undefined) { - return undefined; - } - if (signature.getJsDocTags !== undefined) { - return findDeprecationTag(signature.getJsDocTags()); - } - // for compatibility with typescript@<2.3.0 - return signature.declaration === undefined ? undefined : getDeprecationFromDeclaration(signature.declaration); -} -function getDeprecationFromDeclarations(declarations) { - if (declarations === undefined) { - return undefined; - } - var declaration; - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - declaration = declarations_1[_i]; - if (tsutils_1.isBindingElement(declaration)) { - declaration = tsutils_1.getDeclarationOfBindingElement(declaration); - } - if (tsutils_1.isVariableDeclaration(declaration)) { - declaration = declaration.parent; - } - if (tsutils_1.isVariableDeclarationList(declaration)) { - declaration = declaration.parent; - } - var result = getDeprecationFromDeclaration(declaration); - if (result !== undefined) { - return result; - } - } - return undefined; -} -function getDeprecationFromDeclaration(declaration) { - for (var _i = 0, _a = tsutils_1.getJsDoc(declaration); _i < _a.length; _i++) { - var comment = _a[_i]; - if (comment.tags === undefined) { - continue; - } - for (var _b = 0, _c = comment.tags; _b < _c.length; _b++) { - var tag = _c[_b]; - if (tag.tagName.text === "deprecated") { - return tag.comment === undefined ? "" : tag.comment; - } - } - } - return undefined; -} -function isFunctionOrMethod(declarations) { - if (declarations === undefined || declarations.length === 0) { - return false; - } - switch (declarations[0].kind) { - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.MethodSignature: - return true; - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/encodingRule.d.ts b/node_modules/tslint/lib/rules/encodingRule.d.ts deleted file mode 100644 index e45243ff0..000000000 --- a/node_modules/tslint/lib/rules/encodingRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -import { Encoding } from "../utils"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(actual: Encoding): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/encodingRule.js b/node_modules/tslint/lib/rules/encodingRule.js deleted file mode 100644 index 3fcd46590..000000000 --- a/node_modules/tslint/lib/rules/encodingRule.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var fs = require("fs"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (actual) { - return "This file is encoded as " + showEncoding(actual) + " instead of UTF-8."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "encoding", - description: "Enforces UTF-8 file encoding.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: ["true"], - type: "style", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var encoding = detectEncoding(ctx.sourceFile.fileName); - if (encoding !== "utf8") { - ctx.addFailure(0, 1, Rule.FAILURE_STRING(encoding)); - } -} -function showEncoding(encoding) { - switch (encoding) { - case "utf8": - return "UTF-8"; - case "utf8-bom": - return "UTF-8 with byte-order marker (BOM)"; - case "utf16le": - return "UTF-16 (little-endian)"; - case "utf16be": - return "UTF-16 (big-endian)"; - } -} -function detectEncoding(fileName) { - var fd = fs.openSync(fileName, "r"); - var maxBytesRead = 3; // Only need 3 bytes to detect the encoding. - var buffer = Buffer.allocUnsafe(maxBytesRead); - var bytesRead = fs.readSync(fd, buffer, /*offset*/ 0, /*length*/ maxBytesRead, /*position*/ 0); - fs.closeSync(fd); - return utils_1.detectBufferEncoding(buffer, bytesRead); -} diff --git a/node_modules/tslint/lib/rules/eoflineRule.d.ts b/node_modules/tslint/lib/rules/eoflineRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/eoflineRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/eoflineRule.js b/node_modules/tslint/lib/rules/eoflineRule.js deleted file mode 100644 index a235ef7f2..000000000 --- a/node_modules/tslint/lib/rules/eoflineRule.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var length = sourceFile.text.length; - if (length === 0 || // if the file is empty, it "ends with a newline", so don't return a failure - sourceFile.text[length - 1] === "\n") { - return []; - } - var fix; - var lines = sourceFile.getLineStarts(); - if (lines.length > 1) { - fix = Lint.Replacement.appendText(length, sourceFile.text[lines[1] - 2] === "\r" ? "\r\n" : "\n"); - } - return [new Lint.RuleFailure(sourceFile, length, length, Rule.FAILURE_STRING, this.ruleName, fix)]; - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "eofline", - description: "Ensures the file ends with a newline.", - descriptionDetails: "Fix for single-line files is not supported.", - rationale: "It is a [standard convention](https://stackoverflow.com/q/729692/3124288) to end files with a newline.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - hasFix: true, - type: "maintainability", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "file should end with a newline"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; diff --git a/node_modules/tslint/lib/rules/fileHeaderRule.d.ts b/node_modules/tslint/lib/rules/fileHeaderRule.d.ts deleted file mode 100644 index e4cf6ec2c..000000000 --- a/node_modules/tslint/lib/rules/fileHeaderRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; - private createComment; -} diff --git a/node_modules/tslint/lib/rules/fileHeaderRule.js b/node_modules/tslint/lib/rules/fileHeaderRule.js deleted file mode 100644 index eca48adc5..000000000 --- a/node_modules/tslint/lib/rules/fileHeaderRule.js +++ /dev/null @@ -1,89 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var text = sourceFile.text; - var headerFormat = new RegExp(this.ruleArguments[0]); - var textToInsert = this.ruleArguments[1]; - // ignore shebang if it exists - var offset = text.startsWith("#!") ? text.indexOf("\n") : 0; - // returns the text of the first comment or undefined - var commentText = ts.forEachLeadingCommentRange(text, offset, function (pos, end, kind) { return text.substring(pos + 2, kind === ts.SyntaxKind.SingleLineCommentTrivia ? end : end - 2); }); - if (commentText === undefined || !headerFormat.test(commentText)) { - var isErrorAtStart = offset === 0; - if (!isErrorAtStart) { - ++offset; // show warning in next line after shebang - } - var leadingNewlines = isErrorAtStart ? 0 : 1; - var trailingNewlines = isErrorAtStart ? 2 : 1; - var fix = textToInsert !== undefined - ? Lint.Replacement.appendText(offset, this.createComment(sourceFile, textToInsert, leadingNewlines, trailingNewlines)) - : undefined; - return [new Lint.RuleFailure(sourceFile, offset, offset, Rule.FAILURE_STRING, this.ruleName, fix)]; - } - return []; - }; - Rule.prototype.createComment = function (sourceFile, commentText, leadingNewlines, trailingNewlines) { - if (leadingNewlines === void 0) { leadingNewlines = 1; } - if (trailingNewlines === void 0) { trailingNewlines = 1; } - var maybeCarriageReturn = sourceFile.text[sourceFile.getLineEndOfPosition(0)] === "\r" ? "\r" : ""; - var lineEnding = maybeCarriageReturn + "\n"; - return lineEnding.repeat(leadingNewlines) + [ - "/*!" - ].concat(commentText.split(/\r?\n/g).map(function (line) { return (" * " + line).replace(/\s+$/, ""); }), [ - " */", - ]).join(lineEnding) + lineEnding.repeat(trailingNewlines); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "file-header", - description: "Enforces a certain header comment for all files, matched by a regular expression.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n The first option, which is mandatory, is a regular expression that all headers should match.\n The second argument, which is optional, is a string that should be inserted as a header comment\n if fixing is enabled and no header that matches the first argument is found."], ["\n The first option, which is mandatory, is a regular expression that all headers should match.\n The second argument, which is optional, is a string that should be inserted as a header comment\n if fixing is enabled and no header that matches the first argument is found."]))), - options: { - type: "array", - items: [ - { - type: "string", - }, - { - type: "string", - }, - ], - additionalItems: false, - minLength: 1, - maxLength: 2, - }, - optionExamples: [[true, "Copyright \\d{4}", "Copyright 2017"]], - hasFix: true, - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "missing file header"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/forinRule.d.ts b/node_modules/tslint/lib/rules/forinRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/forinRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/forinRule.js b/node_modules/tslint/lib/rules/forinRule.js deleted file mode 100644 index dfeab4b10..000000000 --- a/node_modules/tslint/lib/rules/forinRule.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "forin", - description: "Requires a `for ... in` statement to be filtered with an `if` statement.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ```ts\n for (let key in someObject) {\n if (someObject.hasOwnProperty(key)) {\n // code here\n }\n }\n ```\n Prevents accidental iteration over properties inherited from an object's prototype.\n See [MDN's `for...in`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)\n documentation for more information about `for...in` loops.\n\n Also consider using a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n or [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\n if you're storing collections of objects.\n Using `Object`s can cause occasional edge case bugs, such as if a key is named \"hasOwnProperty\".\n "], ["\n \\`\\`\\`ts\n for (let key in someObject) {\n if (someObject.hasOwnProperty(key)) {\n // code here\n }\n }\n \\`\\`\\`\n Prevents accidental iteration over properties inherited from an object's prototype.\n See [MDN's \\`for...in\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)\n documentation for more information about \\`for...in\\` loops.\n\n Also consider using a [\\`Map\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n or [\\`Set\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\n if you're storing collections of objects.\n Using \\`Object\\`s can cause occasional edge case bugs, such as if a key is named \"hasOwnProperty\".\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "for (... in ...) statements must be filtered with an if statement"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isForInStatement(node) && tsutils_1.isBlock(node.statement) && !isFiltered(node.statement)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -function isFiltered(_a) { - var statements = _a.statements; - switch (statements.length) { - case 0: return true; - case 1: return statements[0].kind === ts.SyntaxKind.IfStatement; - default: - return statements[0].kind === ts.SyntaxKind.IfStatement && nodeIsContinue(statements[0].thenStatement); - } -} -function nodeIsContinue(node) { - return node.kind === ts.SyntaxKind.ContinueStatement || - tsutils_1.isBlock(node) && node.statements.length === 1 && node.statements[0].kind === ts.SyntaxKind.ContinueStatement; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/importBlacklistRule.d.ts b/node_modules/tslint/lib/rules/importBlacklistRule.d.ts deleted file mode 100644 index 5c64ffe7a..000000000 --- a/node_modules/tslint/lib/rules/importBlacklistRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - isEnabled(): boolean; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/importBlacklistRule.js b/node_modules/tslint/lib/rules/importBlacklistRule.js deleted file mode 100644 index eb1dce21f..000000000 --- a/node_modules/tslint/lib/rules/importBlacklistRule.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.isEnabled = function () { - return _super.prototype.isEnabled.call(this) && this.ruleArguments.length > 0; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.ruleArguments); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "import-blacklist", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows importing the specified modules directly via `import` and `require`.\n Instead only sub modules may be imported from that module."], ["\n Disallows importing the specified modules directly via \\`import\\` and \\`require\\`.\n Instead only sub modules may be imported from that module."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Some libraries allow importing their submodules instead of the entire module.\n This is good practise as it avoids loading unused modules."], ["\n Some libraries allow importing their submodules instead of the entire module.\n This is good practise as it avoids loading unused modules."]))), - optionsDescription: "A list of blacklisted modules.", - options: { - type: "array", - items: { - type: "string", - }, - minLength: 1, - }, - optionExamples: [true, [true, "rxjs", "lodash"]], - type: "functionality", - typescriptOnly: false, - }; - Rule.FAILURE_STRING = "This import is blacklisted, import a submodule instead"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 63 /* All */); _i < _a.length; _i++) { - var name = _a[_i]; - if (ctx.options.indexOf(name.text) !== -1) { - ctx.addFailure(name.getStart(ctx.sourceFile) + 1, name.end - 1, Rule.FAILURE_STRING); - } - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/importSpacingRule.d.ts b/node_modules/tslint/lib/rules/importSpacingRule.d.ts deleted file mode 100644 index b1e1f6d7b..000000000 --- a/node_modules/tslint/lib/rules/importSpacingRule.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static ADD_SPACE_AFTER_IMPORT: string; - static TOO_MANY_SPACES_AFTER_IMPORT: string; - static ADD_SPACE_AFTER_STAR: string; - static TOO_MANY_SPACES_AFTER_STAR: string; - static ADD_SPACE_AFTER_FROM: string; - static TOO_MANY_SPACES_AFTER_FROM: string; - static ADD_SPACE_BEFORE_FROM: string; - static TOO_MANY_SPACES_BEFORE_FROM: string; - static NO_LINE_BREAKS: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/importSpacingRule.js b/node_modules/tslint/lib/rules/importSpacingRule.js deleted file mode 100644 index 51304ba3a..000000000 --- a/node_modules/tslint/lib/rules/importSpacingRule.js +++ /dev/null @@ -1,140 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var LINE_BREAK_REGEX = /\r?\n/; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new Walker(sourceFile, this.ruleName, undefined)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "import-spacing", - description: "Ensures proper spacing between import statement keywords", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: false, - }; - Rule.ADD_SPACE_AFTER_IMPORT = "Add space after 'import'"; - Rule.TOO_MANY_SPACES_AFTER_IMPORT = "Too many spaces after 'import'"; - Rule.ADD_SPACE_AFTER_STAR = "Add space after '*'"; - Rule.TOO_MANY_SPACES_AFTER_STAR = "Too many spaces after '*'"; - Rule.ADD_SPACE_AFTER_FROM = "Add space after 'from'"; - Rule.TOO_MANY_SPACES_AFTER_FROM = "Too many spaces after 'from'"; - Rule.ADD_SPACE_BEFORE_FROM = "Add space before 'from'"; - Rule.TOO_MANY_SPACES_BEFORE_FROM = "Too many spaces before 'from'"; - Rule.NO_LINE_BREAKS = "Line breaks are not allowed in import declaration"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var Walker = /** @class */ (function (_super) { - tslib_1.__extends(Walker, _super); - function Walker() { - return _super !== null && _super.apply(this, arguments) || this; - } - Walker.prototype.walk = function (_a) { - var statements = _a.statements; - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (!tsutils_1.isImportDeclaration(statement)) { - continue; - } - var importClause = statement.importClause; - if (importClause === undefined) { - this.checkModuleWithSideEffect(statement); - } - else { - this.checkImportClause(statement, importClause); - var namedBindings = importClause.namedBindings; - if (namedBindings !== undefined && tsutils_1.isNamespaceImport(namedBindings)) { - this.checkNamespaceImport(namedBindings); - } - } - } - }; - Walker.prototype.checkImportClause = function (node, importClause) { - var text = node.getText(this.sourceFile); - var nodeStart = node.getStart(this.sourceFile); - var importKeywordEnd = nodeStart + "import".length; - var moduleSpecifierStart = node.moduleSpecifier.getStart(this.sourceFile); - var importClauseEnd = importClause.getEnd(); - var importClauseStart = importClause.getStart(this.sourceFile); - if (importKeywordEnd === importClauseStart) { - this.addFailureAt(nodeStart, "import".length, Rule.ADD_SPACE_AFTER_IMPORT); - } - else if (importClauseStart > importKeywordEnd + 1) { - this.addFailure(nodeStart, importClauseStart, Rule.TOO_MANY_SPACES_AFTER_IMPORT); - } - var fromString = text.substring(importClauseEnd - nodeStart, moduleSpecifierStart - nodeStart); - if (/from$/.test(fromString)) { - this.addFailureAt(importClauseEnd, fromString.length, Rule.ADD_SPACE_AFTER_FROM); - } - else if (/from\s{2,}$/.test(fromString)) { - this.addFailureAt(importClauseEnd, fromString.length, Rule.TOO_MANY_SPACES_AFTER_FROM); - } - if (/^\s{2,}from/.test(fromString)) { - this.addFailureAt(importClauseEnd, fromString.length, Rule.TOO_MANY_SPACES_BEFORE_FROM); - } - else if (/^from/.test(fromString)) { - this.addFailureAt(importClauseEnd, fromString.length, Rule.ADD_SPACE_BEFORE_FROM); - } - var beforeImportClauseText = text.substring(0, importClauseStart - nodeStart); - var afterImportClauseText = text.substring(importClauseEnd - nodeStart); - if (LINE_BREAK_REGEX.test(beforeImportClauseText)) { - this.addFailure(nodeStart, importClauseStart - 1, Rule.NO_LINE_BREAKS); - } - if (LINE_BREAK_REGEX.test(afterImportClauseText)) { - this.addFailure(importClauseEnd, node.getEnd(), Rule.NO_LINE_BREAKS); - } - }; - Walker.prototype.checkNamespaceImport = function (node) { - var text = node.getText(this.sourceFile); - if (text.indexOf("*as") > -1) { - this.addFailureAtNode(node, Rule.ADD_SPACE_AFTER_STAR); - } - else if (/\*\s{2,}as/.test(text)) { - this.addFailureAtNode(node, Rule.TOO_MANY_SPACES_AFTER_STAR); - } - else if (LINE_BREAK_REGEX.test(text)) { - this.addFailureAtNode(node, Rule.NO_LINE_BREAKS); - } - }; - Walker.prototype.checkModuleWithSideEffect = function (node) { - var nodeStart = node.getStart(this.sourceFile); - var moduleSpecifierStart = node.moduleSpecifier.getStart(this.sourceFile); - if (nodeStart + "import".length + 1 < moduleSpecifierStart) { - this.addFailure(nodeStart, moduleSpecifierStart, Rule.TOO_MANY_SPACES_AFTER_IMPORT); - } - else if (nodeStart + "import".length === moduleSpecifierStart) { - this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ImportKeyword, this.sourceFile), Rule.ADD_SPACE_AFTER_IMPORT); - } - if (LINE_BREAK_REGEX.test(node.getText())) { - this.addFailureAtNode(node, Rule.NO_LINE_BREAKS); - } - }; - return Walker; -}(Lint.AbstractWalker)); diff --git a/node_modules/tslint/lib/rules/indentRule.d.ts b/node_modules/tslint/lib/rules/indentRule.d.ts deleted file mode 100644 index 1355845f9..000000000 --- a/node_modules/tslint/lib/rules/indentRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(expected: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/indentRule.js b/node_modules/tslint/lib/rules/indentRule.js deleted file mode 100644 index 13ebe62ad..000000000 --- a/node_modules/tslint/lib/rules/indentRule.js +++ /dev/null @@ -1,126 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_USE_TABS = "tabs"; -var OPTION_USE_SPACES = "spaces"; -var OPTION_INDENT_SIZE_2 = 2; -var OPTION_INDENT_SIZE_4 = 4; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (expected) { - return expected + " indentation expected"; - }; - Rule.prototype.apply = function (sourceFile) { - var options = parseOptions(this.ruleArguments); - return options === undefined ? [] : this.applyWithFunction(sourceFile, walk, options); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "indent", - description: "Enforces indentation with tabs or spaces.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using only one of tabs or spaces for indentation leads to more consistent editor behavior,\n cleaner diffs in version control, and easier programmatic manipulation."], ["\n Using only one of tabs or spaces for indentation leads to more consistent editor behavior,\n cleaner diffs in version control, and easier programmatic manipulation."]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n One of the following arguments must be provided:\n\n * `", "` enforces consistent spaces.\n * `", "` enforces consistent tabs.\n\n A second optional argument specifies indentation size:\n\n * `", "` enforces 2 space indentation.\n * `", "` enforces 4 space indentation.\n\n Indentation size is **required** for auto-fixing, but not for rule checking.\n\n **NOTE**: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.\n "], ["\n One of the following arguments must be provided:\n\n * \\`", "\\` enforces consistent spaces.\n * \\`", "\\` enforces consistent tabs.\n\n A second optional argument specifies indentation size:\n\n * \\`", "\\` enforces 2 space indentation.\n * \\`", "\\` enforces 4 space indentation.\n\n Indentation size is **required** for auto-fixing, but not for rule checking.\n\n **NOTE**: auto-fixing will only convert invalid indent whitespace to the desired type, it will not fix invalid whitespace sizes.\n "])), OPTION_USE_SPACES, OPTION_USE_TABS, OPTION_INDENT_SIZE_2.toString(), OPTION_INDENT_SIZE_4.toString()), - options: { - type: "array", - items: [ - { - type: "string", - enum: [OPTION_USE_TABS, OPTION_USE_SPACES], - }, - { - type: "number", - enum: [OPTION_INDENT_SIZE_2, OPTION_INDENT_SIZE_4], - }, - ], - minLength: 0, - maxLength: 5, - }, - optionExamples: [ - [true, OPTION_USE_SPACES], - [true, OPTION_USE_SPACES, OPTION_INDENT_SIZE_4], - [true, OPTION_USE_TABS, OPTION_INDENT_SIZE_2], - ], - hasFix: true, - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(ruleArguments) { - var type = ruleArguments[0]; - if (type !== OPTION_USE_TABS && type !== OPTION_USE_SPACES) { - return undefined; - } - var size = ruleArguments[1]; - return { - size: size === OPTION_INDENT_SIZE_2 || size === OPTION_INDENT_SIZE_4 ? size : undefined, - tabs: type === OPTION_USE_TABS, - }; -} -function walk(ctx) { - var sourceFile = ctx.sourceFile, _a = ctx.options, tabs = _a.tabs, size = _a.size; - var regExp = tabs ? new RegExp(" ".repeat(size === undefined ? 1 : size)) : /\t/; - var failure = Rule.FAILURE_STRING(tabs ? "tab" : size === undefined ? "space" : size + " space"); - for (var _i = 0, _b = tsutils_1.getLineRanges(sourceFile); _i < _b.length; _i++) { - var _c = _b[_i], pos = _c.pos, contentLength = _c.contentLength; - if (contentLength === 0) { - continue; - } - var line = sourceFile.text.substr(pos, contentLength); - var indentEnd = line.search(/\S/); - if (indentEnd === 0) { - continue; - } - if (indentEnd === -1) { - indentEnd = contentLength; - } - var whitespace = line.slice(0, indentEnd); - if (!regExp.test(whitespace)) { - continue; - } - var token = tsutils_1.getTokenAtPosition(sourceFile, pos); - if (token.kind !== ts.SyntaxKind.JsxText && - (pos >= token.getStart(sourceFile) || tsutils_1.isPositionInComment(sourceFile, pos, token))) { - continue; - } - ctx.addFailureAt(pos, indentEnd, failure, createFix(pos, whitespace, tabs, size)); - } -} -function createFix(lineStart, fullLeadingWhitespace, tabs, size) { - if (size === undefined) { - return undefined; - } - var replaceRegExp = tabs - // we want to find every group of `size` spaces, plus up to one 'incomplete' group - ? new RegExp("^( {" + size + "})+( {1," + (size - 1) + "})?", "g") - : /\t/g; - var replacement = fullLeadingWhitespace.replace(replaceRegExp, function (match) { - return (tabs ? "\t" : " ".repeat(size)).repeat(Math.ceil(match.length / size)); - }); - return new Lint.Replacement(lineStart, fullLeadingWhitespace.length, replacement); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/interfaceNameRule.d.ts b/node_modules/tslint/lib/rules/interfaceNameRule.d.ts deleted file mode 100644 index 382e0ae01..000000000 --- a/node_modules/tslint/lib/rules/interfaceNameRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static FAILURE_STRING_NO_PREFIX: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/interfaceNameRule.js b/node_modules/tslint/lib/rules/interfaceNameRule.js deleted file mode 100644 index 2255d3bf5..000000000 --- a/node_modules/tslint/lib/rules/interfaceNameRule.js +++ /dev/null @@ -1,75 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var OPTION_ALWAYS = "always-prefix"; -var OPTION_NEVER = "never-prefix"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { never: this.ruleArguments.indexOf(OPTION_NEVER) !== -1 }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "interface-name", - description: "Requires interface names to begin with a capital 'I'", - rationale: "Makes it easy to differentiate interfaces from regular classes at a glance.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One of the following two options must be provided:\n\n * `\"", "\"` requires interface names to start with an \"I\"\n * `\"", "\"` requires interface names to not have an \"I\" prefix"], ["\n One of the following two options must be provided:\n\n * \\`\"", "\"\\` requires interface names to start with an \"I\"\n * \\`\"", "\"\\` requires interface names to not have an \"I\" prefix"])), OPTION_ALWAYS, OPTION_NEVER), - options: { - type: "string", - enum: [OPTION_ALWAYS, OPTION_NEVER], - }, - optionExamples: [[true, OPTION_ALWAYS], [true, OPTION_NEVER]], - type: "style", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "interface name must start with a capitalized I"; - Rule.FAILURE_STRING_NO_PREFIX = 'interface name must not have an "I" prefix'; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var never = ctx.options.never; - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (utils.isInterfaceDeclaration(node)) { - var name = node.name; - if (never && hasPrefixI(name.text)) { - ctx.addFailureAtNode(name, Rule.FAILURE_STRING_NO_PREFIX); - } - else if (!never && name.text[0] !== "I") { - ctx.addFailureAtNode(name, Rule.FAILURE_STRING); - } - } - else { - return ts.forEachChild(node, cb); - } - }); -} -function hasPrefixI(name) { - // Allow IndexedDB interfaces - return name.length >= 2 && name[0] === "I" && utils_1.isUpperCase(name[1]) && !name.startsWith("IDB"); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/interfaceOverTypeLiteralRule.d.ts b/node_modules/tslint/lib/rules/interfaceOverTypeLiteralRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/interfaceOverTypeLiteralRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/interfaceOverTypeLiteralRule.js b/node_modules/tslint/lib/rules/interfaceOverTypeLiteralRule.js deleted file mode 100644 index fa4c0977b..000000000 --- a/node_modules/tslint/lib/rules/interfaceOverTypeLiteralRule.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "interface-over-type-literal", - description: "Prefer an interface declaration over a type literal (`type T = { ... }`)", - rationale: "Interfaces are generally preferred over type literals because interfaces can be implemented, extended and merged.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use an interface instead of a type literal."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isTypeAliasDeclaration(node) && tsutils_1.isTypeLiteralNode(node.type)) { - var typeKeyword = tsutils_1.getChildOfKind(node, ts.SyntaxKind.TypeKeyword, ctx.sourceFile); - var fix = [ - // "type" -> "interface" - new Lint.Replacement(typeKeyword.end - 4, 4, "interface"), - // remove "=" and trivia up to the open curly brace of the type literal - Lint.Replacement.deleteFromTo(node.type.pos - 1, node.type.members.pos - 1), - ]; - // remove trailing semicolon if exists - if (ctx.sourceFile.text[node.end - 1] === ";") { - fix.push(Lint.Replacement.deleteText(node.end - 1, 1)); - } - ctx.addFailureAtNode(node.name, Rule.FAILURE_STRING, fix); - } - return ts.forEachChild(node, cb); - }); -} diff --git a/node_modules/tslint/lib/rules/jsdocFormatRule.d.ts b/node_modules/tslint/lib/rules/jsdocFormatRule.d.ts deleted file mode 100644 index e7f2a30fd..000000000 --- a/node_modules/tslint/lib/rules/jsdocFormatRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static ALIGNMENT_FAILURE_STRING: string; - static FORMAT_FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/jsdocFormatRule.js b/node_modules/tslint/lib/rules/jsdocFormatRule.js deleted file mode 100644 index e484d4d81..000000000 --- a/node_modules/tslint/lib/rules/jsdocFormatRule.js +++ /dev/null @@ -1,111 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_CHECK_MULTILINE_START = "check-multiline-start"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - firstLineOfMultiline: this.ruleArguments.indexOf(OPTION_CHECK_MULTILINE_START) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "jsdoc-format", - description: "Enforces basic format rules for JSDoc comments.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n The following rules are enforced for JSDoc comments (comments starting with `/**`):\n\n * each line contains an asterisk and asterisks must be aligned\n * each asterisk must be followed by either a space or a newline (except for the first and the last)\n * the only characters before the asterisk on each line must be whitespace characters\n * one line comments must start with `/** ` and end with `*/`\n * multiline comments don't allow text after `/** ` in the first line (with option `\"", "\"`)\n "], ["\n The following rules are enforced for JSDoc comments (comments starting with \\`/**\\`):\n\n * each line contains an asterisk and asterisks must be aligned\n * each asterisk must be followed by either a space or a newline (except for the first and the last)\n * the only characters before the asterisk on each line must be whitespace characters\n * one line comments must start with \\`/** \\` and end with \\`*/\\`\n * multiline comments don't allow text after \\`/** \\` in the first line (with option \\`\"", "\"\\`)\n "])), OPTION_CHECK_MULTILINE_START), - rationale: "Helps maintain a consistent, readable style for JSDoc comments.", - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n You can optionally specify the option `\"", "\"` to enforce the first line of a\n multiline JSDoc comment to be empty.\n "], ["\n You can optionally specify the option \\`\"", "\"\\` to enforce the first line of a\n multiline JSDoc comment to be empty.\n "])), OPTION_CHECK_MULTILINE_START), - options: { - type: "array", - minItems: 0, - maxItems: 1, - items: { - type: "string", - enum: [OPTION_CHECK_MULTILINE_START], - }, - }, - optionExamples: [true, [true, OPTION_CHECK_MULTILINE_START]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.ALIGNMENT_FAILURE_STRING = "asterisks in jsdoc must be aligned"; - Rule.FORMAT_FAILURE_STRING = "jsdoc is not formatted correctly on this line"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return utils.forEachComment(ctx.sourceFile, function (fullText, _a) { - var kind = _a.kind, pos = _a.pos, end = _a.end; - if (kind !== ts.SyntaxKind.MultiLineCommentTrivia || - fullText[pos + 2] !== "*" || fullText[pos + 3] === "*" || fullText[pos + 3] === "/") { - return; - } - var lines = fullText.slice(pos + 3, end - 2).split("\n"); - var firstLine = lines[0]; - if (lines.length === 1) { - if (firstLine[0] !== " " || !firstLine.endsWith(" ")) { - ctx.addFailure(pos, end, Rule.FORMAT_FAILURE_STRING); - } - return; - } - var alignColumn = getAlignColumn(ctx.sourceFile, pos + 1); - if (ctx.options.firstLineOfMultiline && /\S/.test(firstLine)) { - // first line of multiline JSDoc should be empty, i.e. only contain whitespace - ctx.addFailureAt(pos, firstLine.length + 3, Rule.FORMAT_FAILURE_STRING); - } - var lineStart = pos + firstLine.length + 4; // +3 for the comment start "/**" and +1 for the newline - var endIndex = lines.length - 1; - for (var i = 1; i < endIndex; ++i) { - var line = lines[i].endsWith("\r") ? lines[i].slice(0, -1) : lines[i]; - // regex is: start of string, followed by any amount of whitespace, followed by *, - // followed by either a space or the end of the string - if (!/^\s*\*(?: |$)/.test(line)) { - ctx.addFailureAt(lineStart, line.length, Rule.FORMAT_FAILURE_STRING); - } - if (line.indexOf("*") !== alignColumn) { - ctx.addFailureAt(lineStart, line.length, Rule.ALIGNMENT_FAILURE_STRING); - } - lineStart += lines[i].length + 1; // + 1 for the splitted-out newline - } - var lastLine = lines[endIndex]; - // last line should only consist of whitespace - if (lastLine.search(/\S/) !== -1) { - ctx.addFailure(lineStart, end, Rule.FORMAT_FAILURE_STRING); - } - if (lastLine.length !== alignColumn) { - ctx.addFailure(lineStart, end, Rule.ALIGNMENT_FAILURE_STRING); - } - }); -} -function getAlignColumn(sourceFile, pos) { - var result = ts.getLineAndCharacterOfPosition(sourceFile, pos); - // handle files starting with BOM - return result.line === 0 && sourceFile.text[0] === "\uFEFF" - ? result.character - 1 - : result.character; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/labelPositionRule.d.ts b/node_modules/tslint/lib/rules/labelPositionRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/labelPositionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/labelPositionRule.js b/node_modules/tslint/lib/rules/labelPositionRule.js deleted file mode 100644 index ae8fdb6b6..000000000 --- a/node_modules/tslint/lib/rules/labelPositionRule.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "label-position", - description: "Only allows labels in sensible locations.", - descriptionDetails: "This rule only allows labels to be on `do/for/while/switch` statements.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Labels in JavaScript only can be used in conjunction with `break` or `continue`,\n constructs meant to be used for loop flow control. While you can theoretically use\n labels on any block statement in JS, it is considered poor code structure to do so."], ["\n Labels in JavaScript only can be used in conjunction with \\`break\\` or \\`continue\\`,\n constructs meant to be used for loop flow control. While you can theoretically use\n labels on any block statement in JS, it is considered poor code structure to do so."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "unexpected label on statement"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isLabeledStatement(node) && !isLabelable(node.statement)) { - ctx.addFailureAtNode(node.label, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -function isLabelable(node) { - switch (node.kind) { - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.ForOfStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.SwitchStatement: - return true; - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/linebreakStyleRule.d.ts b/node_modules/tslint/lib/rules/linebreakStyleRule.d.ts deleted file mode 100644 index cbd593ead..000000000 --- a/node_modules/tslint/lib/rules/linebreakStyleRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_CRLF: string; - static FAILURE_LF: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/linebreakStyleRule.js b/node_modules/tslint/lib/rules/linebreakStyleRule.js deleted file mode 100644 index c32179dc8..000000000 --- a/node_modules/tslint/lib/rules/linebreakStyleRule.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var Lint = require("../index"); -var OPTION_LINEBREAK_STYLE_CRLF = "CRLF"; -var OPTION_LINEBREAK_STYLE_LF = "LF"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.ruleArguments.indexOf(OPTION_LINEBREAK_STYLE_CRLF) !== -1); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "linebreak-style", - description: "Enforces a consistent linebreak style.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One of the following options must be provided:\n\n * `\"", "\"` requires LF (`\\n`) linebreaks\n * `\"", "\"` requires CRLF (`\\r\\n`) linebreaks"], ["\n One of the following options must be provided:\n\n * \\`\"", "\"\\` requires LF (\\`\\\\n\\`) linebreaks\n * \\`\"", "\"\\` requires CRLF (\\`\\\\r\\\\n\\`) linebreaks"])), OPTION_LINEBREAK_STYLE_LF, OPTION_LINEBREAK_STYLE_CRLF), - options: { - type: "string", - enum: [OPTION_LINEBREAK_STYLE_LF, OPTION_LINEBREAK_STYLE_CRLF], - }, - optionExamples: [[true, OPTION_LINEBREAK_STYLE_LF], [true, OPTION_LINEBREAK_STYLE_CRLF]], - type: "maintainability", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_CRLF = "Expected linebreak to be '" + OPTION_LINEBREAK_STYLE_CRLF + "'"; - Rule.FAILURE_LF = "Expected linebreak to be '" + OPTION_LINEBREAK_STYLE_LF + "'"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var expectedCr = ctx.options; - var sourceText = ctx.sourceFile.text; - var lineStarts = ctx.sourceFile.getLineStarts(); - for (var i = 1; i < lineStarts.length; ++i) { - var lineEnd = lineStarts[i] - 1; - if (sourceText[lineEnd - 1] === "\r") { - if (!expectedCr) { - ctx.addFailure(lineStarts[i - 1], lineEnd - 1, Rule.FAILURE_LF, Lint.Replacement.deleteText(lineEnd - 1, 1)); - } - } - else if (expectedCr) { - ctx.addFailure(lineStarts[i - 1], lineEnd, Rule.FAILURE_CRLF, Lint.Replacement.appendText(lineEnd, "\r")); - } - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/matchDefaultExportNameRule.d.ts b/node_modules/tslint/lib/rules/matchDefaultExportNameRule.d.ts deleted file mode 100644 index d1a2e58b3..000000000 --- a/node_modules/tslint/lib/rules/matchDefaultExportNameRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(importName: string, exportName: string): string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/matchDefaultExportNameRule.js b/node_modules/tslint/lib/rules/matchDefaultExportNameRule.js deleted file mode 100644 index 050a512b3..000000000 --- a/node_modules/tslint/lib/rules/matchDefaultExportNameRule.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (importName, exportName) { - return "Expected import '" + importName + "' to match the default export '" + exportName + "'."; - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "match-default-export-name", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Requires that a default import have the same name as the declaration it imports.\n Does nothing for anonymous default exports."], ["\n Requires that a default import have the same name as the declaration it imports.\n Does nothing for anonymous default exports."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - requiresTypeInfo: true, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - for (var _i = 0, _a = ctx.sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (!tsutils_1.isImportDeclaration(statement) || - statement.importClause === undefined || statement.importClause.name === undefined) { - continue; - } - var defaultImport = statement.importClause.name; - var symbol = tc.getSymbolAtLocation(defaultImport); - if (symbol === undefined || !tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) { - continue; - } - var declarations = tc.getAliasedSymbol(symbol).declarations; - if (declarations !== undefined && declarations.length !== 0) { - var name = declarations[0].name; - if (name !== undefined && name.kind === ts.SyntaxKind.Identifier && name.text !== defaultImport.text) { - ctx.addFailureAtNode(defaultImport, Rule.FAILURE_STRING(defaultImport.text, name.text)); - } - } - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/maxClassesPerFileRule.d.ts b/node_modules/tslint/lib/rules/maxClassesPerFileRule.d.ts deleted file mode 100644 index c698645cf..000000000 --- a/node_modules/tslint/lib/rules/maxClassesPerFileRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(maxCount: number): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/maxClassesPerFileRule.js b/node_modules/tslint/lib/rules/maxClassesPerFileRule.js deleted file mode 100644 index 36963d30c..000000000 --- a/node_modules/tslint/lib/rules/maxClassesPerFileRule.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_EXCLUDE_CLASS_EXPRESSIONS = "exclude-class-expressions"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (maxCount) { - var maxClassWord = maxCount === 1 ? "class per file is" : "classes per file are"; - return "A maximum of " + maxCount + " " + maxClassWord + " allowed."; - }; - Rule.prototype.apply = function (sourceFile) { - var argument = this.ruleArguments[0]; - var maxClasses = isNaN(argument) || argument > 0 ? argument : 1; - return this.applyWithFunction(sourceFile, walk, { - excludeClassExpressions: this.ruleArguments.indexOf(OPTION_EXCLUDE_CLASS_EXPRESSIONS) !== -1, - maxClasses: maxClasses, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "max-classes-per-file", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A file may not contain more than the specified number of classes"], ["\n A file may not contain more than the specified number of classes"]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Ensures that files have a single responsibility so that that classes each exist in their own files"], ["\n Ensures that files have a single responsibility so that that classes each exist in their own files"]))), - optionsDescription: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n The one required argument is an integer indicating the maximum number of classes that can appear in a\n file. An optional argument `\"exclude-class-expressions\"` can be provided to exclude class expressions\n from the overall class count."], ["\n The one required argument is an integer indicating the maximum number of classes that can appear in a\n file. An optional argument \\`\"exclude-class-expressions\"\\` can be provided to exclude class expressions\n from the overall class count."]))), - options: { - type: "array", - items: [ - { - type: "number", - minimum: 1, - }, - { - type: "string", - enum: [OPTION_EXCLUDE_CLASS_EXPRESSIONS], - }, - ], - additionalItems: false, - minLength: 1, - maxLength: 2, - }, - optionExamples: [[true, 1], [true, 5, OPTION_EXCLUDE_CLASS_EXPRESSIONS]], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, _a = ctx.options, maxClasses = _a.maxClasses, excludeClassExpressions = _a.excludeClassExpressions; - var classes = 0; - return ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isClassDeclaration(node) || (!excludeClassExpressions && tsutils_1.isClassExpression(node))) { - classes++; - if (classes > maxClasses) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING(maxClasses)); - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1, templateObject_2, templateObject_3; diff --git a/node_modules/tslint/lib/rules/maxFileLineCountRule.d.ts b/node_modules/tslint/lib/rules/maxFileLineCountRule.d.ts deleted file mode 100644 index 6cca9f698..000000000 --- a/node_modules/tslint/lib/rules/maxFileLineCountRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(lineCount: number, lineLimit: number): string; - isEnabled(): boolean; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/maxFileLineCountRule.js b/node_modules/tslint/lib/rules/maxFileLineCountRule.js deleted file mode 100644 index 6bd801d8c..000000000 --- a/node_modules/tslint/lib/rules/maxFileLineCountRule.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (lineCount, lineLimit) { - return "This file has " + lineCount + " lines, which exceeds the maximum of " + lineLimit + " lines allowed. " + - "Consider breaking this file up into smaller parts"; - }; - Rule.prototype.isEnabled = function () { - return _super.prototype.isEnabled.call(this) && this.ruleArguments[0] > 0; - }; - Rule.prototype.apply = function (sourceFile) { - var lineLimit = this.ruleArguments[0]; - var lineCount = sourceFile.getLineStarts().length; - if (lineCount <= lineLimit) { - return []; - } - var len = sourceFile.text.length; - return [new Lint.RuleFailure(sourceFile, len - 1, len, Rule.FAILURE_STRING(lineCount, lineLimit), this.ruleName)]; - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "max-file-line-count", - description: "Requires files to remain under a certain number of lines", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Limiting the number of lines allowed in a file allows files to remain small,\n single purpose, and maintainable."], ["\n Limiting the number of lines allowed in a file allows files to remain small,\n single purpose, and maintainable."]))), - optionsDescription: "An integer indicating the maximum number of lines.", - options: { - type: "number", - minimum: "1", - }, - optionExamples: [[true, 300]], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/maxLineLengthRule.d.ts b/node_modules/tslint/lib/rules/maxLineLengthRule.d.ts deleted file mode 100644 index 15227fef4..000000000 --- a/node_modules/tslint/lib/rules/maxLineLengthRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(lineLimit: number): string; - isEnabled(): boolean; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; - private getRuleOptions; -} diff --git a/node_modules/tslint/lib/rules/maxLineLengthRule.js b/node_modules/tslint/lib/rules/maxLineLengthRule.js deleted file mode 100644 index 465efcbed..000000000 --- a/node_modules/tslint/lib/rules/maxLineLengthRule.js +++ /dev/null @@ -1,104 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (lineLimit) { - return "Exceeds maximum line length of " + lineLimit; - }; - Rule.prototype.isEnabled = function () { - var limit = this.getRuleOptions().limit; - return _super.prototype.isEnabled.call(this) && (limit > 0); - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.getRuleOptions()); - }; - Rule.prototype.getRuleOptions = function () { - var argument = this.ruleArguments[0]; - var options = { limit: 0 }; - if (typeof argument === "number") { - options.limit = argument; - } - else { - options = argument; - var ignorePattern = argument["ignore-pattern"]; - options.ignorePattern = (typeof ignorePattern === "string") ? - new RegExp((ignorePattern)) : undefined; - } - options.limit = Number(options.limit); // user can pass a string instead of number - return options; - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "max-line-length", - description: "Requires lines to be under a certain max length.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Limiting the length of a line of code improves code readability.\n It also makes comparing code side-by-side easier and improves compatibility with\n various editors, IDEs, and diff viewers."], ["\n Limiting the length of a line of code improves code readability.\n It also makes comparing code side-by-side easier and improves compatibility with\n various editors, IDEs, and diff viewers."]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It can take one argument, which can be any of the following:\n * integer indicating maximum length of lines.\n * object with keys:\n * `limit` - number < 0 defining max line length\n * `ignore-pattern` - string defining ignore pattern for this rule, being parsed by `new RegExp()`.\n For example:\n * `// ` pattern will ignore all in-line comments.\n * `^import ` pattern will ignore all import statements.\n * `^export {(.*?)}` pattern will ignore all multiple export statements.\n * `class [a-zA-Z]+ implements ` pattern will ignore all class declarations implementing interfaces.\n * `^import |^export {(.*?)}|class [a-zA-Z]+ implements |// ` pattern will ignore all the cases listed above.\n "], ["\n It can take one argument, which can be any of the following:\n * integer indicating maximum length of lines.\n * object with keys:\n * \\`limit\\` - number < 0 defining max line length\n * \\`ignore-pattern\\` - string defining ignore pattern for this rule, being parsed by \\`new RegExp()\\`.\n For example:\n * \\`\\/\\/ \\` pattern will ignore all in-line comments.\n * \\`^import \\` pattern will ignore all import statements.\n * \\`^export \\{(.*?)\\}\\` pattern will ignore all multiple export statements.\n * \\`class [a-zA-Z]+ implements \\` pattern will ignore all class declarations implementing interfaces.\n * \\`^import |^export \\{(.*?)\\}|class [a-zA-Z]+ implements |// \\` pattern will ignore all the cases listed above.\n "]))), - options: { - type: "array", - items: { - oneOf: [ - { - type: "number", - }, - { - type: "object", - properties: { - "limit": { type: "number" }, - "ignore-pattern": { type: "string" }, - }, - additionalProperties: false, - }, - ], - }, - minLength: 1, - maxLength: 2, - }, - optionExamples: [[true, 120], [true, { - "limit": 120, - "ignore-pattern": "^import |^export \{(.*?)\}" - }]], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var limit = ctx.options.limit; - var ignorePattern = ctx.options.ignorePattern; - for (var _i = 0, _a = tsutils_1.getLineRanges(ctx.sourceFile); _i < _a.length; _i++) { - var line = _a[_i]; - if (line.contentLength <= limit) { - continue; - } - var lineContent = ctx.sourceFile.text.substr(line.pos, line.contentLength); - if (ignorePattern !== undefined && ignorePattern.test(lineContent)) { - continue; - } - ctx.addFailureAt(line.pos, line.contentLength, Rule.FAILURE_STRING_FACTORY(limit)); - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/memberAccessRule.d.ts b/node_modules/tslint/lib/rules/memberAccessRule.d.ts deleted file mode 100644 index 74b4e23b6..000000000 --- a/node_modules/tslint/lib/rules/memberAccessRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_NO_PUBLIC: string; - static FAILURE_STRING_FACTORY(memberType: string, memberName: string | undefined): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/memberAccessRule.js b/node_modules/tslint/lib/rules/memberAccessRule.js deleted file mode 100644 index 80b90dcad..000000000 --- a/node_modules/tslint/lib/rules/memberAccessRule.js +++ /dev/null @@ -1,160 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var error_1 = require("../error"); -var Lint = require("../index"); -var OPTION_NO_PUBLIC = "no-public"; -var OPTION_CHECK_ACCESSOR = "check-accessor"; -var OPTION_CHECK_CONSTRUCTOR = "check-constructor"; -var OPTION_CHECK_PARAMETER_PROPERTY = "check-parameter-property"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING_FACTORY = function (memberType, memberName) { - memberName = memberName === undefined ? "" : " '" + memberName + "'"; - return "The " + memberType + memberName + " must be marked either 'private', 'public', or 'protected'"; - }; - Rule.prototype.apply = function (sourceFile) { - var options = this.ruleArguments; - var noPublic = options.indexOf(OPTION_NO_PUBLIC) !== -1; - var checkAccessor = options.indexOf(OPTION_CHECK_ACCESSOR) !== -1; - var checkConstructor = options.indexOf(OPTION_CHECK_CONSTRUCTOR) !== -1; - var checkParameterProperty = options.indexOf(OPTION_CHECK_PARAMETER_PROPERTY) !== -1; - if (noPublic) { - if (checkAccessor || checkConstructor || checkParameterProperty) { - error_1.showWarningOnce("Warning: " + this.ruleName + " - If 'no-public' is present, it should be the only option."); - return []; - } - checkAccessor = checkConstructor = checkParameterProperty = true; - } - return this.applyWithFunction(sourceFile, walk, { - checkAccessor: checkAccessor, - checkConstructor: checkConstructor, - checkParameterProperty: checkParameterProperty, - noPublic: noPublic, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "member-access", - description: "Requires explicit visibility declarations for class members.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Explicit visibility declarations can make code more readable and accessible for those new to TS.\n\n Other languages such as C# default to `private`, unlike TypeScript's default of `public`.\n Members lacking a visibility declaration may be an indication of an accidental leak of class internals.\n "], ["\n Explicit visibility declarations can make code more readable and accessible for those new to TS.\n\n Other languages such as C# default to \\`private\\`, unlike TypeScript's default of \\`public\\`.\n Members lacking a visibility declaration may be an indication of an accidental leak of class internals.\n "]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n These arguments may be optionally provided:\n\n * `\"no-public\"` forbids public accessibility to be specified, because this is the default.\n * `\"check-accessor\"` enforces explicit visibility on get/set accessors\n * `\"check-constructor\"` enforces explicit visibility on constructors\n * `\"check-parameter-property\"` enforces explicit visibility on parameter properties"], ["\n These arguments may be optionally provided:\n\n * \\`\"no-public\"\\` forbids public accessibility to be specified, because this is the default.\n * \\`\"check-accessor\"\\` enforces explicit visibility on get/set accessors\n * \\`\"check-constructor\"\\` enforces explicit visibility on constructors\n * \\`\"check-parameter-property\"\\` enforces explicit visibility on parameter properties"]))), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_NO_PUBLIC, OPTION_CHECK_ACCESSOR, OPTION_CHECK_CONSTRUCTOR, OPTION_CHECK_PARAMETER_PROPERTY], - }, - minLength: 0, - maxLength: 4, - }, - optionExamples: [true, [true, OPTION_NO_PUBLIC], [true, OPTION_CHECK_ACCESSOR]], - type: "typescript", - typescriptOnly: true, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_NO_PUBLIC = "'public' is implicit."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var _a = ctx.options, noPublic = _a.noPublic, checkAccessor = _a.checkAccessor, checkConstructor = _a.checkConstructor, checkParameterProperty = _a.checkParameterProperty; - return ts.forEachChild(ctx.sourceFile, function recur(node) { - if (tsutils_1.isClassLikeDeclaration(node)) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var child = _a[_i]; - if (shouldCheck(child)) { - check(child); - } - if (checkParameterProperty && tsutils_1.isConstructorDeclaration(child) && child.body !== undefined) { - for (var _b = 0, _c = child.parameters; _b < _c.length; _b++) { - var param = _c[_b]; - if (tsutils_1.isParameterProperty(param)) { - check(param); - } - } - } - } - } - return ts.forEachChild(node, recur); - }); - function shouldCheck(node) { - switch (node.kind) { - case ts.SyntaxKind.Constructor: - return checkConstructor; - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - return checkAccessor; - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.PropertyDeclaration: - return true; - default: - return false; - } - } - function check(node) { - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword)) { - return; - } - var publicKeyword = tsutils_1.getModifier(node, ts.SyntaxKind.PublicKeyword); - if (noPublic && publicKeyword !== undefined) { - // public is not optional for parameter property without the readonly modifier - if (node.kind !== ts.SyntaxKind.Parameter || tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ReadonlyKeyword)) { - var start = publicKeyword.end - "public".length; - ctx.addFailure(start, publicKeyword.end, Rule.FAILURE_STRING_NO_PUBLIC, Lint.Replacement.deleteFromTo(start, tsutils_1.getNextToken(publicKeyword, ctx.sourceFile).getStart(ctx.sourceFile))); - } - } - if (!noPublic && publicKeyword === undefined) { - var nameNode = node.kind === ts.SyntaxKind.Constructor - ? tsutils_1.getChildOfKind(node, ts.SyntaxKind.ConstructorKeyword, ctx.sourceFile) - : node.name !== undefined ? node.name : node; - var memberName = node.name !== undefined && node.name.kind === ts.SyntaxKind.Identifier ? node.name.text : undefined; - ctx.addFailureAtNode(nameNode, Rule.FAILURE_STRING_FACTORY(typeToString(node), memberName), Lint.Replacement.appendText(getInsertionPosition(node, ctx.sourceFile), "public ")); - } - } -} -function getInsertionPosition(member, sourceFile) { - var node = member.decorators === undefined ? member : tsutils_1.getTokenAtPosition(member, member.decorators.end, sourceFile); - return node.getStart(sourceFile); -} -function typeToString(node) { - switch (node.kind) { - case ts.SyntaxKind.MethodDeclaration: - return "class method"; - case ts.SyntaxKind.PropertyDeclaration: - return "class property"; - case ts.SyntaxKind.Constructor: - return "class constructor"; - case ts.SyntaxKind.GetAccessor: - return "get property accessor"; - case ts.SyntaxKind.SetAccessor: - return "set property accessor"; - case ts.SyntaxKind.Parameter: - return "parameter property"; - default: - throw new Error("unhandled node type " + ts.SyntaxKind[node.kind]); - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/memberOrderingRule.d.ts b/node_modules/tslint/lib/rules/memberOrderingRule.d.ts deleted file mode 100644 index dc5c8a97a..000000000 --- a/node_modules/tslint/lib/rules/memberOrderingRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_ALPHABETIZE(prevName: string, curName: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/memberOrderingRule.js b/node_modules/tslint/lib/rules/memberOrderingRule.js deleted file mode 100644 index a9752e3a4..000000000 --- a/node_modules/tslint/lib/rules/memberOrderingRule.js +++ /dev/null @@ -1,615 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var error_1 = require("../error"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var OPTION_ORDER = "order"; -var OPTION_ALPHABETIZE = "alphabetize"; -var MemberKind; -(function (MemberKind) { - MemberKind[MemberKind["publicStaticField"] = 0] = "publicStaticField"; - MemberKind[MemberKind["publicStaticMethod"] = 1] = "publicStaticMethod"; - MemberKind[MemberKind["protectedStaticField"] = 2] = "protectedStaticField"; - MemberKind[MemberKind["protectedStaticMethod"] = 3] = "protectedStaticMethod"; - MemberKind[MemberKind["privateStaticField"] = 4] = "privateStaticField"; - MemberKind[MemberKind["privateStaticMethod"] = 5] = "privateStaticMethod"; - MemberKind[MemberKind["publicInstanceField"] = 6] = "publicInstanceField"; - MemberKind[MemberKind["protectedInstanceField"] = 7] = "protectedInstanceField"; - MemberKind[MemberKind["privateInstanceField"] = 8] = "privateInstanceField"; - MemberKind[MemberKind["publicConstructor"] = 9] = "publicConstructor"; - MemberKind[MemberKind["protectedConstructor"] = 10] = "protectedConstructor"; - MemberKind[MemberKind["privateConstructor"] = 11] = "privateConstructor"; - MemberKind[MemberKind["publicInstanceMethod"] = 12] = "publicInstanceMethod"; - MemberKind[MemberKind["protectedInstanceMethod"] = 13] = "protectedInstanceMethod"; - MemberKind[MemberKind["privateInstanceMethod"] = 14] = "privateInstanceMethod"; -})(MemberKind || (MemberKind = {})); -var PRESETS = new Map([ - ["fields-first", [ - "public-static-field", - "protected-static-field", - "private-static-field", - "public-instance-field", - "protected-instance-field", - "private-instance-field", - "constructor", - "public-static-method", - "protected-static-method", - "private-static-method", - "public-instance-method", - "protected-instance-method", - "private-instance-method", - ]], - ["instance-sandwich", [ - "public-static-field", - "protected-static-field", - "private-static-field", - "public-instance-field", - "protected-instance-field", - "private-instance-field", - "constructor", - "public-instance-method", - "protected-instance-method", - "private-instance-method", - "public-static-method", - "protected-static-method", - "private-static-method", - ]], - ["statics-first", [ - "public-static-field", - "public-static-method", - "protected-static-field", - "protected-static-method", - "private-static-field", - "private-static-method", - "public-instance-field", - "protected-instance-field", - "private-instance-field", - "constructor", - "public-instance-method", - "protected-instance-method", - "private-instance-method", - ]], -]); -var PRESET_NAMES = Array.from(PRESETS.keys()); -var allMemberKindNames = utils_1.mapDefined(Object.keys(MemberKind), function (key) { - var mk = MemberKind[key]; - return typeof mk === "number" ? MemberKind[mk].replace(/[A-Z]/g, function (cap) { return "-" + cap.toLowerCase(); }) : undefined; -}); -function namesMarkdown(names) { - return names.map(function (name) { return "* `" + name + "`"; }).join("\n "); -} -var optionsDescription = Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One argument, which is an object, must be provided. It should contain an `order` property.\n The `order` property should have a value of one of the following strings:\n\n ", "\n\n Alternatively, the value for `order` maybe be an array consisting of the following strings:\n\n ", "\n\n You can also omit the access modifier to refer to \"public-\", \"protected-\", and \"private-\" all at once; for example, \"static-field\".\n\n You can also make your own categories by using an object instead of a string:\n\n {\n \"name\": \"static non-private\",\n \"kinds\": [\n \"public-static-field\",\n \"protected-static-field\",\n \"public-static-method\",\n \"protected-static-method\"\n ]\n }\n\n The '", "' option will enforce that members within the same category should be alphabetically sorted by name."], ["\n One argument, which is an object, must be provided. It should contain an \\`order\\` property.\n The \\`order\\` property should have a value of one of the following strings:\n\n ", "\n\n Alternatively, the value for \\`order\\` maybe be an array consisting of the following strings:\n\n ", "\n\n You can also omit the access modifier to refer to \"public-\", \"protected-\", and \"private-\" all at once; for example, \"static-field\".\n\n You can also make your own categories by using an object instead of a string:\n\n {\n \"name\": \"static non-private\",\n \"kinds\": [\n \"public-static-field\",\n \"protected-static-field\",\n \"public-static-method\",\n \"protected-static-method\"\n ]\n }\n\n The '", "' option will enforce that members within the same category should be alphabetically sorted by name."])), namesMarkdown(PRESET_NAMES), namesMarkdown(allMemberKindNames), OPTION_ALPHABETIZE); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING_ALPHABETIZE = function (prevName, curName) { - return show(curName) + " should come alphabetically before " + show(prevName); - function show(s) { - return s === "" ? "Computed property" : "'" + s + "'"; - } - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.prototype.apply = function (sourceFile) { - var options; - try { - options = parseOptions(this.ruleArguments); - } - catch (e) { - error_1.showWarningOnce("Warning: " + this.ruleName + " - " + e.message); - return []; - } - return this.applyWithWalker(new MemberOrderingWalker(sourceFile, this.ruleName, options)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "member-ordering", - description: "Enforces member ordering.", - hasFix: true, - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to `member-ordering` is to keep related groups of classes together.\n Instead of creating classes with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "], ["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to \\`member-ordering\\` is to keep related groups of classes together.\n Instead of creating classes with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "]))), - optionsDescription: optionsDescription, - options: { - type: "object", - properties: { - order: { - oneOf: [ - { - type: "string", - enum: PRESET_NAMES, - }, - { - type: "array", - items: { - type: "string", - enum: allMemberKindNames, - }, - maxLength: 13, - }, - ], - }, - }, - additionalProperties: false, - }, - optionExamples: [ - [true, { order: "fields-first" }], - [true, { - order: [ - "public-static-field", - "public-instance-field", - "public-constructor", - "private-static-field", - "private-instance-field", - "private-constructor", - "public-instance-method", - "protected-instance-method", - "private-instance-method", - ], - }], - [true, { - order: [ - { - name: "static non-private", - kinds: [ - "public-static-field", - "protected-static-field", - "public-static-method", - "protected-static-method", - ], - }, - "constructor", - ], - }], - ], - type: "typescript", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var MemberOrderingWalker = /** @class */ (function (_super) { - tslib_1.__extends(MemberOrderingWalker, _super); - function MemberOrderingWalker() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.fixes = []; - return _this; - } - MemberOrderingWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - // NB: iterate through children first! - ts.forEachChild(node, cb); - switch (node.kind) { - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeLiteral: - _this.checkMembers(node.members); - } - }; - ts.forEachChild(sourceFile, cb); - // assign Replacements which have not been merged into surrounding ones to their RuleFailures. - this.fixes.forEach(function (_a) { - var failure = _a[0], replacement = _a[1]; - failure.getFix().push(replacement); - }); - }; - /** - * Check wether the passed members adhere to the configured order. If not, RuleFailures are generated and a single - * Lint.Replacement is generated, which replaces the entire NodeArray with a correctly sorted one. The Replacement - * is not immediately added to a RuleFailure, as incorrectly sorted nodes can be nested (e.g. a class declaration - * in a method implementation), but instead temporarily stored in `this.fixes`. Nested Replacements are manually - * merged, as TSLint doesn't handle overlapping ones. For this reason it is important that the recursion happens - * before the checkMembers call in this.walk(). - */ - MemberOrderingWalker.prototype.checkMembers = function (members) { - var _this = this; - var prevRank = -1; - var prevName; - var failureExists = false; - for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { - var member = members_1[_i]; - var rank = this.memberRank(member); - if (rank === -1) { - // no explicit ordering for this kind of node specified, so continue - continue; - } - if (rank < prevRank) { - var nodeType = this.rankName(rank); - var prevNodeType = this.rankName(prevRank); - var lowerRank = this.findLowerRank(members, rank); - var locationHint = lowerRank !== -1 - ? "after " + this.rankName(lowerRank) + "s" - : "at the beginning of the class/interface"; - var errorLine1 = "Declaration of " + nodeType + " not allowed after declaration of " + prevNodeType + ". " + - ("Instead, this should come " + locationHint + "."); - // add empty array as fix so we can add a replacement later. (fix itself is readonly) - this.addFailureAtNode(member, errorLine1, []); - failureExists = true; - } - else { - if (this.options.alphabetize && member.name !== undefined) { - if (rank !== prevRank) { - // No alphabetical ordering between different ranks - prevName = undefined; - } - var curName = nameString(member.name); - if (prevName !== undefined && caseInsensitiveLess(curName, prevName)) { - this.addFailureAtNode(member.name, Rule.FAILURE_STRING_ALPHABETIZE(this.findLowerName(members, rank, curName), curName), []); - failureExists = true; - } - else { - prevName = curName; - } - } - // keep track of last good node - prevRank = rank; - } - } - if (failureExists) { - var sortedMemberIndexes = members.map(function (_, i) { return i; }).sort(function (ai, bi) { - var a = members[ai]; - var b = members[bi]; - // first, sort by member rank - var rankDiff = _this.memberRank(a) - _this.memberRank(b); - if (rankDiff !== 0) { - return rankDiff; - } - // then lexicographically if alphabetize == true - if (_this.options.alphabetize && a.name !== undefined && b.name !== undefined) { - var aName = nameString(a.name); - var bName = nameString(b.name); - var nameDiff = aName.localeCompare(bName); - if (nameDiff !== 0) { - return nameDiff; - } - } - // finally, sort by position in original NodeArray so the sort remains stable. - return ai - bi; - }); - var splits_1 = getSplitIndexes(members, this.sourceFile.text); - var sortedMembersText = sortedMemberIndexes.map(function (i) { - var start = splits_1[i]; - var end = splits_1[i + 1]; - var nodeText = _this.sourceFile.text.substring(start, end); - while (true) { - // check if there are previous fixes which we need to merge into this one - // if yes, remove it from the list so that we do not return overlapping Replacements - var fixIndex = arrayFindLastIndex(_this.fixes, function (_a) { - var r = _a[1]; - return r.start >= start && r.start + r.length <= end; - }); - if (fixIndex === -1) { - break; - } - var fix = _this.fixes.splice(fixIndex, 1)[0]; - var replacement = fix[1]; - nodeText = applyReplacementOffset(nodeText, replacement, start); - } - return nodeText; - }); - // instead of assigning the fix immediately to the last failure, we temporarily store it in `this.fixes`, - // in case a containing node needs to be fixed too. We only "add" the fix to the last failure, although - // it fixes all failures in this NodeArray, as TSLint doesn't handle duplicate Replacements. - this.fixes.push([ - arrayLast(this.failures), - Lint.Replacement.replaceFromTo(splits_1[0], arrayLast(splits_1), sortedMembersText.join("")), - ]); - } - }; - /** Finds the lowest name higher than 'targetName'. */ - MemberOrderingWalker.prototype.findLowerName = function (members, targetRank, targetName) { - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; - if (member.name === undefined || this.memberRank(member) !== targetRank) { - continue; - } - var name = nameString(member.name); - if (caseInsensitiveLess(targetName, name)) { - return name; - } - } - throw new Error("Expected to find a name"); - }; - /** Finds the highest existing rank lower than `targetRank`. */ - MemberOrderingWalker.prototype.findLowerRank = function (members, targetRank) { - var max = -1; - for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { - var member = members_3[_i]; - var rank = this.memberRank(member); - if (rank !== -1 && rank < targetRank) { - max = Math.max(max, rank); - } - } - return max; - }; - MemberOrderingWalker.prototype.memberRank = function (member) { - var optionName = getMemberKind(member); - if (optionName === undefined) { - return -1; - } - return this.options.order.findIndex(function (category) { return category.has(optionName); }); - }; - MemberOrderingWalker.prototype.rankName = function (rank) { - return this.options.order[rank].name; - }; - return MemberOrderingWalker; -}(Lint.AbstractWalker)); -function caseInsensitiveLess(a, b) { - return a.toLowerCase() < b.toLowerCase(); -} -function memberKindForConstructor(access) { - return MemberKind[access + "Constructor"]; -} -function memberKindForMethodOrField(access, membership, kind) { - return MemberKind[access + membership + kind]; -} -var allAccess = ["public", "protected", "private"]; -function memberKindFromName(name) { - var kind = MemberKind[Lint.Utils.camelize(name)]; - return typeof kind === "number" ? [kind] : allAccess.map(addModifier); - function addModifier(modifier) { - var modifiedKind = MemberKind[Lint.Utils.camelize(modifier + "-" + name)]; - if (typeof modifiedKind !== "number") { - throw new Error("Bad member kind: " + name); - } - return modifiedKind; - } -} -function getMemberKind(member) { - var accessLevel = tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.PrivateKeyword) ? "private" - : tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.ProtectedKeyword) ? "protected" - : "public"; - switch (member.kind) { - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.ConstructSignature: - return memberKindForConstructor(accessLevel); - case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.PropertySignature: - return methodOrField(isFunctionLiteral(member.initializer)); - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.MethodSignature: - return methodOrField(true); - default: - return undefined; - } - function methodOrField(isMethod) { - var membership = tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.StaticKeyword) ? "Static" : "Instance"; - return memberKindForMethodOrField(accessLevel, membership, isMethod ? "Method" : "Field"); - } -} -var MemberCategory = /** @class */ (function () { - function MemberCategory(name, kinds) { - this.name = name; - this.kinds = kinds; - } - MemberCategory.prototype.has = function (kind) { return this.kinds.has(kind); }; - return MemberCategory; -}()); -function parseOptions(options) { - var _a = getOptionsJson(options), orderJson = _a.order, alphabetize = _a.alphabetize; - var order = orderJson.map(function (cat) { return typeof cat === "string" - ? new MemberCategory(cat.replace(/-/g, " "), new Set(memberKindFromName(cat))) - : new MemberCategory(cat.name, new Set(utils_1.flatMap(cat.kinds, memberKindFromName))); }); - return { order: order, alphabetize: alphabetize }; -} -function getOptionsJson(allOptions) { - if (allOptions == undefined || allOptions.length === 0 || allOptions[0] == undefined) { - throw new Error("Got empty options"); - } - var firstOption = allOptions[0]; - if (typeof firstOption !== "object") { - // Undocumented direct string option. Deprecate eventually. - return { order: convertFromOldStyleOptions(allOptions), alphabetize: false }; // presume allOptions to be string[] - } - return { order: categoryFromOption(firstOption[OPTION_ORDER]), alphabetize: firstOption[OPTION_ALPHABETIZE] === true }; -} -function categoryFromOption(orderOption) { - if (Array.isArray(orderOption)) { - return orderOption; - } - var preset = PRESETS.get(orderOption); - if (preset === undefined) { - throw new Error("Bad order: " + JSON.stringify(orderOption)); - } - return preset; -} -/** - * Convert from undocumented old-style options. - * This is designed to mimic the old behavior and should be removed eventually. - */ -function convertFromOldStyleOptions(options) { - var categories = [{ name: "member", kinds: allMemberKindNames }]; - if (hasOption("variables-before-functions")) { - categories = splitOldStyleOptions(categories, function (kind) { return kind.includes("field"); }, "field", "method"); - } - if (hasOption("static-before-instance")) { - categories = splitOldStyleOptions(categories, function (kind) { return kind.includes("static"); }, "static", "instance"); - } - if (hasOption("public-before-private")) { - // 'protected' is considered public - categories = splitOldStyleOptions(categories, function (kind) { return !kind.includes("private"); }, "public", "private"); - } - return categories; - function hasOption(x) { - return options.indexOf(x) !== -1; - } -} -function splitOldStyleOptions(categories, filter, a, b) { - var newCategories = []; - var _loop_1 = function (cat) { - var yes = []; - var no = []; - for (var _i = 0, _a = cat.kinds; _i < _a.length; _i++) { - var kind = _a[_i]; - if (filter(kind)) { - yes.push(kind); - } - else { - no.push(kind); - } - } - var augmentName = function (s) { - if (a === "field") { - // Replace "member" with "field"/"method" instead of augmenting. - return s; - } - return s + " " + cat.name; - }; - newCategories.push({ name: augmentName(a), kinds: yes }); - newCategories.push({ name: augmentName(b), kinds: no }); - }; - for (var _i = 0, categories_1 = categories; _i < categories_1.length; _i++) { - var cat = categories_1[_i]; - _loop_1(cat); - } - return newCategories; -} -function isFunctionLiteral(node) { - if (node === undefined) { - return false; - } - switch (node.kind) { - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.FunctionExpression: - return true; - default: - return false; - } -} -function nameString(name) { - switch (name.kind) { - case ts.SyntaxKind.Identifier: - case ts.SyntaxKind.StringLiteral: - case ts.SyntaxKind.NumericLiteral: - return name.text; - default: - return ""; - } -} -/** - * Returns the last element of an array. (Or undefined). - */ -function arrayLast(array) { - return array[array.length - 1]; -} -/** - * Array.prototype.findIndex, but the last index. - */ -function arrayFindLastIndex(array, predicate) { - for (var i = array.length; i-- > 0;) { - if (predicate(array[i], i, array)) { - return i; - } - } - return -1; -} -/** - * Applies a Replacement to a part of the text which starts at offset. - * See also Replacement.apply - */ -function applyReplacementOffset(content, replacement, offset) { - return content.substring(0, replacement.start - offset) - + replacement.text - + content.substring(replacement.start - offset + replacement.length); -} -/** - * Get the indexes of the boundaries between nodes in the node array. The following points must be taken into account: - * - Trivia should stay with its corresponding node (comments on the same line following the token belong to the - * previous token, the rest to the next). - * - Reordering the subtexts should not result in code being commented out due to being moved between a "//" and - * the following newline. - * - The end of one node must be the start of the next, otherwise the intravening whitespace will be lost when - * reordering. - * - * Hence, the boundaries are chosen to be _after_ the newline following the node, or the beginning of the next token, - * if that comes first. - */ -function getSplitIndexes(members, text) { - var result = members.map(function (member) { return getNextSplitIndex(text, member.getFullStart()); }); - result.push(getNextSplitIndex(text, arrayLast(members).getEnd())); - return result; -} -/** - * Calculates the index after the newline following pos, or the beginning of the next token, whichever comes first. - * See also getSplitIndexes. - * This method is a modified version of TypeScript's internal iterateCommentRanges function. - */ -function getNextSplitIndex(text, pos) { - scan: while (pos >= 0 && pos < text.length) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos++; - } - // falls through - case 10 /* lineFeed */: - pos++; - // split is after new line - return pos; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - // skip whitespace - pos++; - continue; - case 47 /* slash */: - var nextChar = text.charCodeAt(pos + 1); - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var isSingleLineComment = nextChar === 47 /* slash */; - pos += 2; - if (isSingleLineComment) { - while (pos < text.length) { - if (ts.isLineBreak(text.charCodeAt(pos))) { - // the comment ends here, go back to default logic to handle parsing new line and result - continue scan; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - continue scan; - } - pos++; - } - } - // if we arrive here, it's because pos == text.length - return pos; - } - break scan; - default: - // skip whitespace: - if (ch > 127 /* maxAsciiCharacter */ && (ts.isWhiteSpaceLike(ch))) { - pos++; - continue; - } - break scan; - } - } - return pos; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/newParensRule.d.ts b/node_modules/tslint/lib/rules/newParensRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/newParensRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/newParensRule.js b/node_modules/tslint/lib/rules/newParensRule.js deleted file mode 100644 index f0a82ad08..000000000 --- a/node_modules/tslint/lib/rules/newParensRule.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "new-parens", - description: "Requires parentheses when invoking a constructor via the `new` keyword.", - rationale: "Maintains stylistic consistency with other function calls.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Parentheses are required when invoking a constructor"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.NewExpression && node.arguments === undefined) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} diff --git a/node_modules/tslint/lib/rules/newlineBeforeReturnRule.d.ts b/node_modules/tslint/lib/rules/newlineBeforeReturnRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/newlineBeforeReturnRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/newlineBeforeReturnRule.js b/node_modules/tslint/lib/rules/newlineBeforeReturnRule.js deleted file mode 100644 index aed998980..000000000 --- a/node_modules/tslint/lib/rules/newlineBeforeReturnRule.js +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NewlineBeforeReturnWalker(sourceFile, this.ruleName, undefined)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "newline-before-return", - description: "Enforces blank line before return when not the only line in the block.", - rationale: "Helps maintain a readable style in your codebase.", - optionsDescription: "Not configurable.", - options: {}, - optionExamples: [true], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Missing blank line before return"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NewlineBeforeReturnWalker = /** @class */ (function (_super) { - tslib_1.__extends(NewlineBeforeReturnWalker, _super); - function NewlineBeforeReturnWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NewlineBeforeReturnWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (node.kind === ts.SyntaxKind.ReturnStatement) { - _this.visitReturnStatement(node); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - NewlineBeforeReturnWalker.prototype.visitReturnStatement = function (node) { - var prev = tsutils_1.getPreviousStatement(node); - if (prev === undefined) { - // return is not within a block (e.g. the only child of an IfStatement) or the first statement of the block - // no need to check for preceding newline - return; - } - var start = node.getStart(this.sourceFile); - var line = ts.getLineAndCharacterOfPosition(this.sourceFile, start).line; - var comments = ts.getLeadingCommentRanges(this.sourceFile.text, node.pos); - if (comments !== undefined) { - // check for blank lines between comments - for (var i = comments.length - 1; i >= 0; --i) { - var endLine = ts.getLineAndCharacterOfPosition(this.sourceFile, comments[i].end).line; - if (endLine < line - 1) { - return; - } - start = comments[i].pos; - line = ts.getLineAndCharacterOfPosition(this.sourceFile, start).line; - } - } - var prevLine = ts.getLineAndCharacterOfPosition(this.sourceFile, prev.end).line; - if (prevLine >= line - 1) { - // Previous statement is on the same or previous line - this.addFailure(start, start, Rule.FAILURE_STRING); - } - }; - return NewlineBeforeReturnWalker; -}(Lint.AbstractWalker)); diff --git a/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.d.ts b/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js b/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js deleted file mode 100644 index 2cb4f24b6..000000000 --- a/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-angle-bracket-type-assertion", - description: "Requires the use of `as Type` for type assertions instead of `<Type>`.", - hasFix: true, - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Both formats of type assertions have the same effect, but only `as` type assertions\n work in `.tsx` files. This rule ensures that you have a consistent type assertion style\n across your codebase."], ["\n Both formats of type assertions have the same effect, but only \\`as\\` type assertions\n work in \\`.tsx\\` files. This rule ensures that you have a consistent type assertion style\n across your codebase."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isTypeAssertion(node)) { - var expression = node.expression; - var start = node.getStart(ctx.sourceFile); - var addParens = needsParens(node); - var replaceText = " as " + node.type.getText(ctx.sourceFile) + (addParens ? ")" : ""); - while (tsutils_1.isTypeAssertion(expression)) { - replaceText = " as " + expression.type.getText(ctx.sourceFile) + replaceText; - expression = expression.expression; - } - ctx.addFailure(start, node.end, Rule.FAILURE_STRING, [ - Lint.Replacement.appendText(node.end, replaceText), - Lint.Replacement.replaceFromTo(start, expression.getStart(ctx.sourceFile), addParens ? "(" : ""), - ]); - return cb(expression); - } - return ts.forEachChild(node, cb); - }); -} -function needsParens(node) { - var parent = node.parent; - return tsutils_1.isBinaryExpression(parent) && - (parent.operatorToken.kind === ts.SyntaxKind.AmpersandToken || parent.operatorToken.kind === ts.SyntaxKind.BarToken); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noAnyRule.d.ts b/node_modules/tslint/lib/rules/noAnyRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noAnyRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noAnyRule.js b/node_modules/tslint/lib/rules/noAnyRule.js deleted file mode 100644 index bd424bf9f..000000000 --- a/node_modules/tslint/lib/rules/noAnyRule.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-any", - description: "Disallows usages of `any` as a type declaration.", - hasFix: false, - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using `any` as a type declaration nullifies the compile-time benefits of the type system.\n\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type `{}`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use `<T>` template types for generic type handling.\n\n Also see the `no-unsafe-any` rule.\n "], ["\n Using \\`any\\` as a type declaration nullifies the compile-time benefits of the type system.\n\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type \\`{}\\`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use \\`<T>\\` template types for generic type handling.\n\n Also see the \\`no-unsafe-any\\` rule.\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.AnyKeyword) { - var start = node.end - 3; - return ctx.addFailure(start, node.end, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noArgRule.d.ts b/node_modules/tslint/lib/rules/noArgRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noArgRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noArgRule.js b/node_modules/tslint/lib/rules/noArgRule.js deleted file mode 100644 index 6036f84dc..000000000 --- a/node_modules/tslint/lib/rules/noArgRule.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-arg", - description: "Disallows use of `arguments.callee`.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using `arguments.callee` makes various performance optimizations impossible.\n See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee)\n for more details on why to avoid `arguments.callee`."], ["\n Using \\`arguments.callee\\` makes various performance optimizations impossible.\n See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee)\n for more details on why to avoid \\`arguments.callee\\`."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Access to arguments.callee is forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isPropertyAccessExpression(node) && - node.name.text === "callee" && - node.expression.kind === ts.SyntaxKind.Identifier && node.expression.text === "arguments") { - return ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noBitwiseRule.d.ts b/node_modules/tslint/lib/rules/noBitwiseRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noBitwiseRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noBitwiseRule.js b/node_modules/tslint/lib/rules/noBitwiseRule.js deleted file mode 100644 index edd086133..000000000 --- a/node_modules/tslint/lib/rules/noBitwiseRule.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-bitwise", - description: "Disallows bitwise operators.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Specifically, the following bitwise operators are banned:\n `&`, `&=`, `|`, `|=`,\n `^`, `^=`, `<<`, `<<=`,\n `>>`, `>>=`, `>>>`, `>>>=`, and `~`.\n This rule does not ban the use of `&` and `|` for intersection and union types."], ["\n Specifically, the following bitwise operators are banned:\n \\`&\\`, \\`&=\\`, \\`|\\`, \\`|=\\`,\n \\`^\\`, \\`^=\\`, \\`<<\\`, \\`<<=\\`,\n \\`>>\\`, \\`>>=\\`, \\`>>>\\`, \\`>>>=\\`, and \\`~\\`.\n This rule does not ban the use of \\`&\\` and \\`|\\` for intersection and union types."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Bitwise operators are often typos - for example `bool1 & bool2` instead of `bool1 && bool2`.\n They also can be an indicator of overly clever code which decreases maintainability."], ["\n Bitwise operators are often typos - for example \\`bool1 & bool2\\` instead of \\`bool1 && bool2\\`.\n They also can be an indicator of overly clever code which decreases maintainability."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Forbidden bitwise operation"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.BinaryExpression) { - switch (node.operatorToken.kind) { - case ts.SyntaxKind.AmpersandToken: - case ts.SyntaxKind.AmpersandEqualsToken: - case ts.SyntaxKind.BarToken: - case ts.SyntaxKind.BarEqualsToken: - case ts.SyntaxKind.CaretToken: - case ts.SyntaxKind.CaretEqualsToken: - case ts.SyntaxKind.LessThanLessThanToken: - case ts.SyntaxKind.LessThanLessThanEqualsToken: - case ts.SyntaxKind.GreaterThanGreaterThanToken: - case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken: - case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken: - case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - } - else if (node.kind === ts.SyntaxKind.PrefixUnaryExpression && - node.operator === ts.SyntaxKind.TildeToken) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noBooleanLiteralCompareRule.d.ts b/node_modules/tslint/lib/rules/noBooleanLiteralCompareRule.d.ts deleted file mode 100644 index 5f2dd1ccd..000000000 --- a/node_modules/tslint/lib/rules/noBooleanLiteralCompareRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(negate: boolean): string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noBooleanLiteralCompareRule.js b/node_modules/tslint/lib/rules/noBooleanLiteralCompareRule.js deleted file mode 100644 index efe5027c1..000000000 --- a/node_modules/tslint/lib/rules/noBooleanLiteralCompareRule.js +++ /dev/null @@ -1,123 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (negate) { - return "This expression is unnecessarily compared to a boolean. Just " + (negate ? "negate it" : "use it directly") + "."; - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-boolean-literal-compare", - description: "Warns on comparison to a boolean literal, as in `x === true`.", - hasFix: true, - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Comparing boolean values to boolean literals is unnecessary, as those expressions will result in booleans too.\n Just use the boolean values directly or negate them.\n "], ["\n Comparing boolean values to boolean literals is unnecessary, as those expressions will result in booleans too.\n Just use the boolean values directly or negate them.\n "]))), - type: "style", - typescriptOnly: true, - requiresTypeInfo: true, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (utils.isBinaryExpression(node)) { - var cmp = getBooleanComparison(node, checker); - if (cmp !== undefined) { - ctx.addFailureAtNode(cmp.expression, Rule.FAILURE_STRING(cmp.negate), fix(node, cmp)); - } - } - return ts.forEachChild(node, cb); - }); -} -function getBooleanComparison(node, checker) { - var cmp = deconstructComparison(node); - return cmp === undefined || !utils.isTypeFlagSet(checker.getTypeAtLocation(cmp.expression), ts.TypeFlags.Boolean) ? undefined : cmp; -} -function fix(node, _a) { - var negate = _a.negate, expression = _a.expression; - var deleted = node.left === expression - ? Lint.Replacement.deleteFromTo(node.left.end, node.end) - : Lint.Replacement.deleteFromTo(node.getStart(), node.right.getStart()); - if (!negate) { - return deleted; - } - else if (needsParenthesesForNegate(expression)) { - return [ - deleted, - Lint.Replacement.appendText(node.getStart(), "!("), - Lint.Replacement.appendText(node.getEnd(), ")"), - ]; - } - else { - return [ - deleted, - Lint.Replacement.appendText(node.getStart(), "!"), - ]; - } -} -function needsParenthesesForNegate(node) { - switch (node.kind) { - case ts.SyntaxKind.AsExpression: - case ts.SyntaxKind.BinaryExpression: - return true; - default: - return false; - } -} -function deconstructComparison(node) { - var left = node.left, operatorToken = node.operatorToken, right = node.right; - var eq = Lint.getEqualsKind(operatorToken); - if (eq === undefined) { - return undefined; - } - var leftValue = booleanFromExpression(left); - if (leftValue !== undefined) { - return { negate: leftValue !== eq.isPositive, expression: right }; - } - var rightValue = booleanFromExpression(right); - if (rightValue !== undefined) { - return { negate: rightValue !== eq.isPositive, expression: left }; - } - return undefined; -} -function booleanFromExpression(node) { - switch (node.kind) { - case ts.SyntaxKind.TrueKeyword: - return true; - case ts.SyntaxKind.FalseKeyword: - return false; - default: - return undefined; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts b/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts deleted file mode 100644 index 06b7c4bbe..000000000 --- a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js b/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js deleted file mode 100644 index 7e004cb58..000000000 --- a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-conditional-assignment", - description: "Disallows any type of assignment in conditionals.", - descriptionDetails: "This applies to `do-while`, `for`, `if`, and `while` statements and conditional (ternary) expressions.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Assignments in conditionals are often typos:\n for example `if (var1 = var2)` instead of `if (var1 == var2)`.\n They also can be an indicator of overly clever code which decreases maintainability."], ["\n Assignments in conditionals are often typos:\n for example \\`if (var1 = var2)\\` instead of \\`if (var1 == var2)\\`.\n They also can be an indicator of overly clever code which decreases maintainability."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Assignments in conditional expressions are forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var checking = 0; - return ts.forEachChild(ctx.sourceFile, cb); - function cb(node) { - var kind = node.kind; - if (!tsutils_1.isNodeKind(kind)) { - return; // return early for tokens - } - switch (kind) { - case ts.SyntaxKind.ConditionalExpression: - check(node.condition); - cb(node.whenTrue); - cb(node.whenFalse); - return; - case ts.SyntaxKind.IfStatement: - check(node.expression); - cb(node.thenStatement); - maybeCallback(cb, node.elseStatement); - return; - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.WhileStatement: - check(node.expression); - cb(node.statement); - return; - case ts.SyntaxKind.ForStatement: - maybeCallback(cb, node.initializer); - maybeCallback(check, node.condition); - maybeCallback(cb, node.incrementor); - cb(node.statement); - return; - } - if (checking !== 0) { - switch (kind) { - case ts.SyntaxKind.BinaryExpression: - if (tsutils_1.isAssignmentKind(node.operatorToken.kind)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - cb(node.left); - cb(node.right); - return; - case ts.SyntaxKind.ParenthesizedExpression: - case ts.SyntaxKind.NonNullExpression: - case ts.SyntaxKind.AsExpression: - case ts.SyntaxKind.TypeAssertionExpression: - return cb(node.expression); - case ts.SyntaxKind.PrefixUnaryExpression: - return cb(node.operand); - default: - return noCheck(node); - } - } - return ts.forEachChild(node, cb); - } - function check(node) { - ++checking; - cb(node); - --checking; - } - function noCheck(node) { - var old = checking; - checking = 0; - ts.forEachChild(node, cb); - checking = old; - } -} -function maybeCallback(cb, node) { - if (node !== undefined) { - cb(node); - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noConsecutiveBlankLinesRule.d.ts b/node_modules/tslint/lib/rules/noConsecutiveBlankLinesRule.d.ts deleted file mode 100644 index 9a2716053..000000000 --- a/node_modules/tslint/lib/rules/noConsecutiveBlankLinesRule.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static DEFAULT_ALLOWED_BLANKS: number; - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(allowed: number): string; - /** - * Disable the rule if the option is provided but non-numeric or less than the minimum. - */ - isEnabled(): boolean; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} -export declare function getTemplateRanges(sourceFile: ts.SourceFile): ts.TextRange[]; diff --git a/node_modules/tslint/lib/rules/noConsecutiveBlankLinesRule.js b/node_modules/tslint/lib/rules/noConsecutiveBlankLinesRule.js deleted file mode 100644 index a52a03d15..000000000 --- a/node_modules/tslint/lib/rules/noConsecutiveBlankLinesRule.js +++ /dev/null @@ -1,128 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (allowed) { - return allowed === 1 - ? "Consecutive blank lines are forbidden" - : "Exceeds the " + allowed + " allowed consecutive blank lines"; - }; - /** - * Disable the rule if the option is provided but non-numeric or less than the minimum. - */ - Rule.prototype.isEnabled = function () { - var option = this.ruleArguments[0]; - return _super.prototype.isEnabled.call(this) && (option === undefined || option > 0); - }; - Rule.prototype.apply = function (sourceFile) { - var limit = this.ruleArguments[0]; - return this.applyWithFunction(sourceFile, walk, limit !== undefined ? limit : Rule.DEFAULT_ALLOWED_BLANKS); - }; - Rule.DEFAULT_ALLOWED_BLANKS = 1; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-consecutive-blank-lines", - description: "Disallows one or more blank lines in a row.", - hasFix: true, - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps maintain a readable style in your codebase.\n\n Extra blank lines take up extra space and add little to a semantic understanding of the code.\n It can be harder to read through files when fewer components can fit into the screen.\n If you find a file is so large you feel a need to split them up with extra blank lines or comments,\n consider splitting your file into smaller files.\n "], ["\n Helps maintain a readable style in your codebase.\n\n Extra blank lines take up extra space and add little to a semantic understanding of the code.\n It can be harder to read through files when fewer components can fit into the screen.\n If you find a file is so large you feel a need to split them up with extra blank lines or comments,\n consider splitting your file into smaller files.\n "]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n An optional number of maximum allowed sequential blanks can be specified. If no value\n is provided, a default of ", " will be used."], ["\n An optional number of maximum allowed sequential blanks can be specified. If no value\n is provided, a default of ", " will be used."])), Rule.DEFAULT_ALLOWED_BLANKS), - options: { - type: "number", - minimum: "1", - }, - optionExamples: [true, [true, 2]], - type: "style", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceText = ctx.sourceFile.text; - var threshold = ctx.options + 1; - var possibleFailures = []; - var consecutiveBlankLines = 0; - for (var _i = 0, _a = utils.getLineRanges(ctx.sourceFile); _i < _a.length; _i++) { - var line = _a[_i]; - if (line.contentLength === 0 || sourceText.substr(line.pos, line.contentLength).search(/\S/) === -1) { - ++consecutiveBlankLines; - if (consecutiveBlankLines === threshold) { - possibleFailures.push({ - end: line.end, - pos: line.pos, - }); - } - else if (consecutiveBlankLines > threshold) { - possibleFailures[possibleFailures.length - 1].end = line.end; - } - } - else { - consecutiveBlankLines = 0; - } - } - if (possibleFailures.length === 0) { - return; - } - var failureString = Rule.FAILURE_STRING_FACTORY(ctx.options); - var templateRanges = getTemplateRanges(ctx.sourceFile); - var _loop_1 = function (possibleFailure) { - if (!templateRanges.some(function (template) { return template.pos < possibleFailure.pos && possibleFailure.pos < template.end; })) { - ctx.addFailureAt(possibleFailure.pos, 1, failureString, [ - Lint.Replacement.deleteFromTo( - // special handling for fixing blank lines at the end of the file - // to fix this we need to cut off the line break of the last allowed blank line, too - possibleFailure.end === sourceText.length ? getStartOfLineBreak(sourceText, possibleFailure.pos) : possibleFailure.pos, possibleFailure.end), - ]); - } - }; - for (var _b = 0, possibleFailures_1 = possibleFailures; _b < possibleFailures_1.length; _b++) { - var possibleFailure = possibleFailures_1[_b]; - _loop_1(possibleFailure); - } -} -function getStartOfLineBreak(sourceText, pos) { - return sourceText[pos - 2] === "\r" ? pos - 1 : pos - 1; -} -function getTemplateRanges(sourceFile) { - var intervals = []; - var cb = function (node) { - if (node.kind >= ts.SyntaxKind.FirstTemplateToken && - node.kind <= ts.SyntaxKind.LastTemplateToken) { - intervals.push({ - end: node.end, - pos: node.getStart(sourceFile), - }); - } - else { - return ts.forEachChild(node, cb); - } - }; - ts.forEachChild(sourceFile, cb); - return intervals; -} -exports.getTemplateRanges = getTemplateRanges; -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noConsoleRule.d.ts b/node_modules/tslint/lib/rules/noConsoleRule.d.ts deleted file mode 100644 index 44d692363..000000000 --- a/node_modules/tslint/lib/rules/noConsoleRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(method: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noConsoleRule.js b/node_modules/tslint/lib/rules/noConsoleRule.js deleted file mode 100644 index 0a2eeb42e..000000000 --- a/node_modules/tslint/lib/rules/noConsoleRule.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (method) { - return "Calls to 'console." + method + "' are not allowed."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.ruleArguments); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-console", - description: "Bans the use of specified `console` methods.", - rationale: "In general, \`console\` methods aren't appropriate for production code.", - optionsDescription: "A list of method names to ban. If no method names are provided, all console methods are banned.", - options: { - type: "array", - items: { type: "string" }, - }, - optionExamples: [[true, "log", "error"]], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isPropertyAccessExpression(node) && - tsutils_1.isIdentifier(node.expression) && - node.expression.text === "console" && - (ctx.options.length === 0 || ctx.options.indexOf(node.name.text) !== -1)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_FACTORY(node.name.text)); - } - return ts.forEachChild(node, cb); - }); -} diff --git a/node_modules/tslint/lib/rules/noConstructRule.d.ts b/node_modules/tslint/lib/rules/noConstructRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noConstructRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noConstructRule.js b/node_modules/tslint/lib/rules/noConstructRule.js deleted file mode 100644 index 9d7391b3a..000000000 --- a/node_modules/tslint/lib/rules/noConstructRule.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-construct", - description: "Disallows access to the constructors of `String`, `Number`, and `Boolean`.", - descriptionDetails: "Disallows constructor use such as `new Number(foo)` but does not disallow `Number(foo)`.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n There is little reason to use `String`, `Number`, or `Boolean` as constructors.\n In almost all cases, the regular function-call version is more appropriate.\n [More details](http://stackoverflow.com/q/4719320/3124288) are available on StackOverflow."], ["\n There is little reason to use \\`String\\`, \\`Number\\`, or \\`Boolean\\` as constructors.\n In almost all cases, the regular function-call version is more appropriate.\n [More details](http://stackoverflow.com/q/4719320/3124288) are available on StackOverflow."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Forbidden constructor, use a literal or simple function call instead"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isNewExpression(node) && node.expression.kind === ts.SyntaxKind.Identifier) { - switch (node.expression.text) { - case "Boolean": - case "String": - case "Number": - ctx.addFailure(node.getStart(ctx.sourceFile), node.expression.end, Rule.FAILURE_STRING); - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noDebuggerRule.d.ts b/node_modules/tslint/lib/rules/noDebuggerRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noDebuggerRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noDebuggerRule.js b/node_modules/tslint/lib/rules/noDebuggerRule.js deleted file mode 100644 index 591c32862..000000000 --- a/node_modules/tslint/lib/rules/noDebuggerRule.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-debugger", - description: "Disallows `debugger` statements.", - rationale: "In general, \`debugger\` statements aren't appropriate for production code.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use of debugger statements is forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.DebuggerStatement) { - return ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} diff --git a/node_modules/tslint/lib/rules/noDefaultExportRule.d.ts b/node_modules/tslint/lib/rules/noDefaultExportRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/noDefaultExportRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noDefaultExportRule.js b/node_modules/tslint/lib/rules/noDefaultExportRule.js deleted file mode 100644 index 099290b2d..000000000 --- a/node_modules/tslint/lib/rules/noDefaultExportRule.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-default-export", - description: "Disallows default exports in ES6-style modules.", - descriptionDetails: "Use named exports instead.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Named imports/exports [promote clarity](https://github.com/palantir/tslint/issues/1182#issue-151780453).\n In addition, current tooling differs on the correct way to handle default imports/exports.\n Avoiding them all together can help avoid tooling bugs and conflicts."], ["\n Named imports/exports [promote clarity](https://github.com/palantir/tslint/issues/1182#issue-151780453).\n In addition, current tooling differs on the correct way to handle default imports/exports.\n Avoiding them all together can help avoid tooling bugs and conflicts."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "maintainability", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use of default exports is forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - if (ctx.sourceFile.isDeclarationFile || !ts.isExternalModule(ctx.sourceFile)) { - return; - } - for (var _i = 0, _a = ctx.sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (statement.kind === ts.SyntaxKind.ExportAssignment) { - if (!statement.isExportEquals) { - ctx.addFailureAtNode(statement.getChildAt(1, ctx.sourceFile), Rule.FAILURE_STRING); - } - } - else if (statement.modifiers !== undefined && statement.modifiers.length >= 2 && - statement.modifiers[0].kind === ts.SyntaxKind.ExportKeyword && - statement.modifiers[1].kind === ts.SyntaxKind.DefaultKeyword) { - ctx.addFailureAtNode(statement.modifiers[1], Rule.FAILURE_STRING); - } - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noDuplicateImportsRule.d.ts b/node_modules/tslint/lib/rules/noDuplicateImportsRule.d.ts deleted file mode 100644 index 37804b2d0..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateImportsRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(module: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noDuplicateImportsRule.js b/node_modules/tslint/lib/rules/noDuplicateImportsRule.js deleted file mode 100644 index d30d74b4c..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateImportsRule.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING = function (module) { - return "Multiple imports from '" + module + "' can be combined into one."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-duplicate-imports", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows multiple import statements from the same module."], ["\n Disallows multiple import statements from the same module."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Using a single import statement per module will make the code clearer because you can see everything being imported\n from that module on one line."], ["\n Using a single import statement per module will make the code clearer because you can see everything being imported\n from that module on one line."]))), - optionsDescription: "Not configurable", - options: null, - optionExamples: [true], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - walkWorker(ctx, ctx.sourceFile.statements, new Set()); -} -function walkWorker(ctx, statements, seen) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (tsutils_1.isImportDeclaration(statement) && tsutils_1.isLiteralExpression(statement.moduleSpecifier)) { - var text = statement.moduleSpecifier.text; - if (seen.has(text)) { - ctx.addFailureAtNode(statement, Rule.FAILURE_STRING(text)); - } - seen.add(text); - } - if (tsutils_1.isModuleDeclaration(statement) && statement.body !== undefined && statement.name.kind === ts.SyntaxKind.StringLiteral) { - // If this is a module augmentation, re-use `seen` since those imports could be moved outside. - // If this is an ambient module, create a fresh `seen` - // because they should have separate imports to avoid becoming augmentations. - walkWorker(ctx, statement.body.statements, ts.isExternalModule(ctx.sourceFile) ? seen : new Set()); - } - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noDuplicateSuperRule.d.ts b/node_modules/tslint/lib/rules/noDuplicateSuperRule.d.ts deleted file mode 100644 index eb78370a5..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateSuperRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_DUPLICATE: string; - static FAILURE_STRING_LOOP: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noDuplicateSuperRule.js b/node_modules/tslint/lib/rules/noDuplicateSuperRule.js deleted file mode 100644 index b1e545f48..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateSuperRule.js +++ /dev/null @@ -1,164 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-duplicate-super", - description: "Warns if 'super()' appears twice in a constructor.", - rationale: "The second call to 'super()' will fail at runtime.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_DUPLICATE = "Multiple calls to 'super()' found. It must be called only once."; - Rule.FAILURE_STRING_LOOP = "'super()' called in a loop. It must be called only once."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isConstructorDeclaration(node) && node.body !== undefined) { - getSuperForNode(node.body); - } - return ts.forEachChild(node, cb); - }); - function getSuperForNode(node) { - if (tsutils_1.isIterationStatement(node)) { - var bodySuper = combineSequentialChildren(node); - if (typeof bodySuper === "number") { - return 0 /* NoSuper */; - } - if (!bodySuper.break) { - ctx.addFailureAtNode(bodySuper.node, Rule.FAILURE_STRING_LOOP); - } - return tslib_1.__assign({}, bodySuper, { break: false }); - } - switch (node.kind) { - case ts.SyntaxKind.ReturnStatement: - case ts.SyntaxKind.ThrowStatement: - return 1 /* Return */; - case ts.SyntaxKind.BreakStatement: - return 2 /* Break */; - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - // 'super()' is bound differently inside, so ignore. - return 0 /* NoSuper */; - case ts.SyntaxKind.SuperKeyword: - return node.parent.kind === ts.SyntaxKind.CallExpression && node.parent.expression === node - ? { node: node.parent, break: false } - : 0 /* NoSuper */; - case ts.SyntaxKind.ConditionalExpression: { - var _a = node, condition = _a.condition, whenTrue = _a.whenTrue, whenFalse = _a.whenFalse; - var inCondition = getSuperForNode(condition); - var inBranches = worse(getSuperForNode(whenTrue), getSuperForNode(whenFalse)); - if (typeof inCondition !== "number" && typeof inBranches !== "number") { - addDuplicateFailure(inCondition.node, inBranches.node); - } - return worse(inCondition, inBranches); - } - case ts.SyntaxKind.IfStatement: { - var _b = node, thenStatement = _b.thenStatement, elseStatement = _b.elseStatement; - return worse(getSuperForNode(thenStatement), elseStatement !== undefined ? getSuperForNode(elseStatement) : 0 /* NoSuper */); - } - case ts.SyntaxKind.SwitchStatement: - return getSuperForSwitch(node); - default: - return combineSequentialChildren(node); - } - } - function getSuperForSwitch(node) { - // 'super()' from any clause. Used to track whether 'super()' happens in the switch at all. - var foundSingle; - // 'super()' from the previous clause if it did not 'break;'. - var fallthroughSingle; - for (var _i = 0, _a = node.caseBlock.clauses; _i < _a.length; _i++) { - var clause = _a[_i]; - var clauseSuper = combineSequentialChildren(clause); - switch (clauseSuper) { - case 0 /* NoSuper */: - break; - case 2 /* Break */: - fallthroughSingle = undefined; - break; - case 1 /* Return */: - return 0 /* NoSuper */; - default: - if (fallthroughSingle !== undefined) { - addDuplicateFailure(fallthroughSingle, clauseSuper.node); - } - if (!clauseSuper.break) { - fallthroughSingle = clauseSuper.node; - } - foundSingle = clauseSuper.node; - } - } - return foundSingle !== undefined ? { node: foundSingle, break: false } : 0 /* NoSuper */; - } - /** - * Combines children that come one after another. - * (As opposed to if/else, switch, or loops, which need their own handling.) - */ - function combineSequentialChildren(node) { - var seenSingle; - var res = ts.forEachChild(node, function (child) { - var childSuper = getSuperForNode(child); - switch (childSuper) { - case 0 /* NoSuper */: - return undefined; - case 2 /* Break */: - if (seenSingle !== undefined) { - return tslib_1.__assign({}, seenSingle, { break: true }); - } - return childSuper; - case 1 /* Return */: - return childSuper; - default: - if (seenSingle !== undefined && !seenSingle.break) { - addDuplicateFailure(seenSingle.node, childSuper.node); - } - seenSingle = childSuper; - return undefined; - } - }); - return res !== undefined ? res : seenSingle !== undefined ? seenSingle : 0 /* NoSuper */; - } - function addDuplicateFailure(a, b) { - ctx.addFailure(a.getStart(), b.end, Rule.FAILURE_STRING_DUPLICATE); - } -} -// If/else run separately, so return the branch more likely to result in eventual errors. -function worse(a, b) { - return typeof a === "number" - ? typeof b === "number" ? (a < b ? b : a) : b - : typeof b === "number" ? a : a.break ? b : a; -} diff --git a/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts b/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts deleted file mode 100644 index af720ee58..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static readonly FAILURE_STRING_FACTORY: (text: string) => string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js b/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js deleted file mode 100644 index 18b026a9d..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - Rule.metadata = { - description: "Prevents duplicate cases in switch statements.", - optionExamples: [true], - options: null, - optionsDescription: "", - ruleName: "no-duplicate-switch-case", - type: "functionality", - typescriptOnly: false, - }; - Rule.FAILURE_STRING_FACTORY = function (text) { return "Duplicate switch case: '" + text + "'."; }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.CaseBlock) { - visitCaseBlock(node); - } - ts.forEachChild(node, cb); - }); - function visitCaseBlock(node) { - var previousCases = new Set(); - for (var _i = 0, _a = node.clauses; _i < _a.length; _i++) { - var clause = _a[_i]; - if (clause.kind === ts.SyntaxKind.DefaultClause) { - continue; - } - var text = clause.expression.getText(ctx.sourceFile); - if (!previousCases.has(text)) { - previousCases.add(text); - continue; - } - ctx.addFailureAtNode(clause.expression, Rule.FAILURE_STRING_FACTORY(text)); - } - } -} diff --git a/node_modules/tslint/lib/rules/noDuplicateVariableRule.d.ts b/node_modules/tslint/lib/rules/noDuplicateVariableRule.d.ts deleted file mode 100644 index 699da0464..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateVariableRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noDuplicateVariableRule.js b/node_modules/tslint/lib/rules/noDuplicateVariableRule.js deleted file mode 100644 index 54a053387..000000000 --- a/node_modules/tslint/lib/rules/noDuplicateVariableRule.js +++ /dev/null @@ -1,110 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_CHECK_PARAMETERS = "check-parameters"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name) { - return "Duplicate variable: '" + name + "'"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoDuplicateVariableWalker(sourceFile, this.ruleName, { - parameters: this.ruleArguments.indexOf(OPTION_CHECK_PARAMETERS) !== -1, - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-duplicate-variable", - description: "Disallows duplicate variable declarations in the same block scope.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n This rule is only useful when using the `var` keyword -\n the compiler will detect redeclarations of `let` and `const` variables."], ["\n This rule is only useful when using the \\`var\\` keyword -\n the compiler will detect redeclarations of \\`let\\` and \\`const\\` variables."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n A variable can be reassigned if necessary -\n there's no good reason to have a duplicate variable declaration."], ["\n A variable can be reassigned if necessary -\n there's no good reason to have a duplicate variable declaration."]))), - optionsDescription: "You can specify `\"" + OPTION_CHECK_PARAMETERS + "\"` to check for variables with the same name as a parameter.", - options: { - type: "string", - enum: [OPTION_CHECK_PARAMETERS], - }, - optionExamples: [ - true, - [true, OPTION_CHECK_PARAMETERS], - ], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoDuplicateVariableWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoDuplicateVariableWalker, _super); - function NoDuplicateVariableWalker() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.scope = new Set(); - return _this; - } - NoDuplicateVariableWalker.prototype.walk = function (sourceFile) { - var _this = this; - this.scope = new Set(); - var cb = function (node) { - if (utils.isFunctionScopeBoundary(node)) { - var oldScope = _this.scope; - _this.scope = new Set(); - ts.forEachChild(node, cb); - _this.scope = oldScope; - return; - } - if (_this.options.parameters && utils.isParameterDeclaration(node)) { - _this.handleBindingName(node.name, false); - } - else if (utils.isVariableDeclarationList(node) && !utils.isBlockScopedVariableDeclarationList(node)) { - for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - _this.handleBindingName(variable.name, true); - } - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - NoDuplicateVariableWalker.prototype.handleBindingName = function (name, check) { - if (name.kind === ts.SyntaxKind.Identifier) { - if (check && this.scope.has(name.text)) { - this.addFailureAtNode(name, Rule.FAILURE_STRING(name.text)); - } - else { - this.scope.add(name.text); - } - } - else { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var e = _a[_i]; - if (e.kind !== ts.SyntaxKind.OmittedExpression) { - this.handleBindingName(e.name, check); - } - } - } - }; - return NoDuplicateVariableWalker; -}(Lint.AbstractWalker)); -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.d.ts b/node_modules/tslint/lib/rules/noEmptyInterfaceRule.d.ts deleted file mode 100644 index 99a5b06b6..000000000 --- a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static FAILURE_STRING_FOR_EXTENDS: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js b/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js deleted file mode 100644 index f23f3aade..000000000 --- a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-empty-interface", - description: "Forbids empty interfaces.", - rationale: "An empty interface is equivalent to its supertype (or `{}`).", - optionsDescription: "Not configurable.", - options: null, - type: "typescript", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "An empty interface is equivalent to `{}`."; - Rule.FAILURE_STRING_FOR_EXTENDS = "An interface declaring no members is equivalent to its supertype."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isInterfaceDeclaration(node) && - node.members.length === 0 && - (node.heritageClauses === undefined || extendsOneTypeWithoutTypeArguments(node.heritageClauses[0]))) { - return ctx.addFailureAtNode(node.name, node.heritageClauses !== undefined ? Rule.FAILURE_STRING_FOR_EXTENDS : Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -function extendsOneTypeWithoutTypeArguments(_a) { - var types = _a.types; - switch (types.length) { - case 0: - return true; // don't crash on empty extends list - case 1: - return types[0].typeArguments === undefined; // allow interfaces that provide type arguments for the extended type - default: - return false; // allow interfaces extending more than one types - } -} diff --git a/node_modules/tslint/lib/rules/noEmptyRule.d.ts b/node_modules/tslint/lib/rules/noEmptyRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noEmptyRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noEmptyRule.js b/node_modules/tslint/lib/rules/noEmptyRule.js deleted file mode 100644 index ee79f5f8b..000000000 --- a/node_modules/tslint/lib/rules/noEmptyRule.js +++ /dev/null @@ -1,108 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var ALLOW_EMPTY_CATCH = "allow-empty-catch"; -var ALLOW_EMPTY_FUNCTIONS = "allow-empty-functions"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - allowEmptyCatch: this.ruleArguments.indexOf(ALLOW_EMPTY_CATCH) !== -1, - allowEmptyFunctions: this.ruleArguments.indexOf(ALLOW_EMPTY_FUNCTIONS) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-empty", - description: "Disallows empty blocks.", - descriptionDetails: "Blocks with a comment inside are not considered empty.", - rationale: "Empty blocks are often indicators of missing code.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then catch blocks are allowed to be empty.\n If `", "` is specified, then function definitions are allowed to be empty."], ["\n If \\`", "\\` is specified, then catch blocks are allowed to be empty.\n If \\`", "\\` is specified, then function definitions are allowed to be empty."])), ALLOW_EMPTY_CATCH, ALLOW_EMPTY_FUNCTIONS), - options: { - type: "array", - items: { - anyOf: [ - { - type: "string", - enum: [ALLOW_EMPTY_CATCH], - }, - { - type: "string", - enum: [ALLOW_EMPTY_FUNCTIONS], - }, - ], - }, - }, - optionExamples: [ - true, - [true, ALLOW_EMPTY_CATCH], - [true, ALLOW_EMPTY_FUNCTIONS], - [true, ALLOW_EMPTY_CATCH, ALLOW_EMPTY_FUNCTIONS], - ], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "block is empty"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.Block && - node.statements.length === 0 && - !isExcluded(node.parent, ctx.options)) { - var start = node.getStart(ctx.sourceFile); - // Block always starts with open brace. Adding 1 to its start gives us the end of the brace, - // which can be used to conveniently check for comments between braces - if (Lint.hasCommentAfterPosition(ctx.sourceFile.text, start + 1)) { - return; - } - return ctx.addFailure(start, node.end, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -function isExcluded(node, options) { - if (options.allowEmptyCatch && node.kind === ts.SyntaxKind.CatchClause) { - return true; - } - if (options.allowEmptyFunctions && - (node.kind === ts.SyntaxKind.MethodDeclaration || - node.kind === ts.SyntaxKind.FunctionDeclaration || - node.kind === ts.SyntaxKind.FunctionExpression || - node.kind === ts.SyntaxKind.ArrowFunction)) { - return true; - } - return tsutils_1.isConstructorDeclaration(node) && - ( - /* If constructor is private or protected, the block is allowed to be empty. - The constructor is there on purpose to disallow instantiation from outside the class */ - /* The public modifier does not serve a purpose here. It can only be used to allow instantiation of a base class where - the super constructor is protected. But then the block would not be empty, because of the call to super() */ - tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ProtectedKeyword) || - node.parameters.some(tsutils_1.isParameterProperty)); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noEvalRule.d.ts b/node_modules/tslint/lib/rules/noEvalRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noEvalRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noEvalRule.js b/node_modules/tslint/lib/rules/noEvalRule.js deleted file mode 100644 index 386914433..000000000 --- a/node_modules/tslint/lib/rules/noEvalRule.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-eval", - description: "Disallows `eval` function invocations.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n `eval()` is dangerous as it allows arbitrary code execution with full privileges. There are\n [alternatives](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)\n for most of the use cases for `eval()`."], ["\n \\`eval()\\` is dangerous as it allows arbitrary code execution with full privileges. There are\n [alternatives](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval)\n for most of the use cases for \\`eval()\\`."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "forbidden eval"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isCallExpression(node) && - node.expression.kind === ts.SyntaxKind.Identifier && node.expression.text === "eval") { - ctx.addFailureAtNode(node.expression, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noFloatingPromisesRule.d.ts b/node_modules/tslint/lib/rules/noFloatingPromisesRule.d.ts deleted file mode 100644 index 8b31e4da7..000000000 --- a/node_modules/tslint/lib/rules/noFloatingPromisesRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noFloatingPromisesRule.js b/node_modules/tslint/lib/rules/noFloatingPromisesRule.js deleted file mode 100644 index f6d8c1e0d..000000000 --- a/node_modules/tslint/lib/rules/noFloatingPromisesRule.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, ["Promise"].concat(this.ruleArguments), program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-floating-promises", - description: "Promises returned by functions must be handled appropriately.", - descriptionDetails: "Unhandled Promises can cause unexpected behavior, such as resolving at unexpected times.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A list of 'string' names of any additional classes that should also be handled as Promises.\n "], ["\n A list of \\'string\\' names of any additional classes that should also be handled as Promises.\n "]))), - options: { - type: "list", - listType: { - type: "array", - items: { type: "string" }, - }, - }, - optionExamples: [true, [true, "JQueryPromise"]], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Creating a Promise and not storing or returning it may let other code run independently of its result.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use `no-unused-expression` in addition to this rule to reveal even more floating promises.\n "], ["\n Creating a Promise and not storing or returning it may let other code run independently of its result.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use \\`no-unused-expression\\` in addition to this rule to reveal even more floating promises.\n "]))), - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Promises must be handled appropriately"; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isExpressionStatement(node)) { - var expression = node.expression; - if (tsutils_1.isCallExpression(expression) && - !isPromiseCatchCall(expression) && - !isPromiseThenCallWithRejectionHandler(expression)) { - var symbol = tc.getTypeAtLocation(expression).symbol; - if (symbol !== undefined && ctx.options.indexOf(symbol.name) !== -1) { - ctx.addFailureAtNode(expression, Rule.FAILURE_STRING); - } - } - } - return ts.forEachChild(node, cb); - }); -} -function isPromiseCatchCall(expression) { - return tsutils_1.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === "catch"; -} -function isPromiseThenCallWithRejectionHandler(expression) { - return tsutils_1.isPropertyAccessExpression(expression.expression) && - expression.expression.name.text === "then" && - expression.arguments.length >= 2; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noForInArrayRule.d.ts b/node_modules/tslint/lib/rules/noForInArrayRule.d.ts deleted file mode 100644 index 8b31e4da7..000000000 --- a/node_modules/tslint/lib/rules/noForInArrayRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noForInArrayRule.js b/node_modules/tslint/lib/rules/noForInArrayRule.js deleted file mode 100644 index 726001716..000000000 --- a/node_modules/tslint/lib/rules/noForInArrayRule.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-for-in-array", - description: "Disallows iterating over an array with a for-in loop.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A for-in loop (`for (var k in o)`) iterates over the properties of an Object.\n\n While it is legal to use for-in loops with array types, it is not common.\n for-in will iterate over the indices of the array as strings, omitting any \"holes\" in\n the array.\n\n More common is to use for-of, which iterates over the values of an array.\n If you want to iterate over the indices, alternatives include:\n\n array.forEach((value, index) => { ... });\n for (const [index, value] of array.entries()) { ... }\n for (let i = 0; i < array.length; i++) { ... }\n "], ["\n A for-in loop (\\`for (var k in o)\\`) iterates over the properties of an Object.\n\n While it is legal to use for-in loops with array types, it is not common.\n for-in will iterate over the indices of the array as strings, omitting any \"holes\" in\n the array.\n\n More common is to use for-of, which iterates over the values of an array.\n If you want to iterate over the indices, alternatives include:\n\n array.forEach((value, index) => { ... });\n for (const [index, value] of array.entries()) { ... }\n for (let i = 0; i < array.length; i++) { ... }\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - requiresTypeInfo: true, - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "for-in loops over arrays are forbidden. Use for-of or array.forEach instead."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.ForInStatement) { - var type = checker.getTypeAtLocation(node.expression); - if (type.symbol !== undefined && type.symbol.name === "Array" || - // tslint:disable-next-line:no-bitwise - (type.flags & ts.TypeFlags.StringLike) !== 0) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts b/node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts deleted file mode 100644 index 41a47d70a..000000000 --- a/node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(module: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noImplicitDependenciesRule.js b/node_modules/tslint/lib/rules/noImplicitDependenciesRule.js deleted file mode 100644 index 6aa697a33..000000000 --- a/node_modules/tslint/lib/rules/noImplicitDependenciesRule.js +++ /dev/null @@ -1,153 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var builtins = require("builtin-modules"); -var fs = require("fs"); -var path = require("path"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_DEV = "dev"; -var OPTION_OPTIONAL = "optional"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (module) { - return "Module '" + module + "' is not listed as dependency in package.json"; - }; - Rule.prototype.apply = function (sourceFile) { - var whitelist = this.ruleArguments.find(function (arg) { return Array.isArray(arg); }); - if (whitelist === null || whitelist === undefined) { - whitelist = []; - } - return this.applyWithFunction(sourceFile, walk, { - dev: this.ruleArguments.indexOf(OPTION_DEV) !== -1, - optional: this.ruleArguments.indexOf(OPTION_OPTIONAL) !== -1, - whitelist: whitelist, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-implicit-dependencies", - description: "Disallows importing modules that are not listed as dependency in the project's package.json", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows importing transient dependencies and modules installed above your package's root directory.\n "], ["\n Disallows importing transient dependencies and modules installed above your package's root directory.\n "]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n By default the rule looks at `\"dependencies\"` and `\"peerDependencies\"`.\n By adding the `\"", "\"` option the rule also looks at `\"devDependencies\"`.\n By adding the `\"", "\"` option the rule also looks at `\"optionalDependencies\"`.\n An array of whitelisted modules can be added to skip checking their existence in package.json.\n "], ["\n By default the rule looks at \\`\"dependencies\"\\` and \\`\"peerDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule also looks at \\`\"devDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule also looks at \\`\"optionalDependencies\"\\`.\n An array of whitelisted modules can be added to skip checking their existence in package.json.\n "])), OPTION_DEV, OPTION_OPTIONAL), - options: { - type: "array", - items: [ - { - type: "string", - enum: [OPTION_DEV, OPTION_OPTIONAL], - }, - { - type: "array", - }, - ], - minItems: 0, - maxItems: 3, - }, - optionExamples: [ - true, - [true, OPTION_DEV], - [true, OPTION_OPTIONAL], - [true, ["src", "app"]], - ], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var options = ctx.options; - var dependencies; - var whitelist = new Set(options.whitelist); - for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 63 /* All */); _i < _a.length; _i++) { - var name = _a[_i]; - if (!ts.isExternalModuleNameRelative(name.text)) { - var packageName = getPackageName(name.text); - if (!whitelist.has(packageName) && builtins.indexOf(packageName) === -1 && !hasDependency(packageName)) { - ctx.addFailureAtNode(name, Rule.FAILURE_STRING_FACTORY(packageName)); - } - } - } - function hasDependency(module) { - if (dependencies === undefined) { - dependencies = getDependencies(ctx.sourceFile.fileName, options); - } - return dependencies.has(module); - } -} -function getPackageName(name) { - var parts = name.split(/\//g); - if (name[0] !== "@") { - return parts[0]; - } - return parts[0] + "/" + parts[1]; -} -function getDependencies(fileName, options) { - var result = new Set(); - var packageJsonPath = findPackageJson(path.resolve(path.dirname(fileName))); - if (packageJsonPath !== undefined) { - try { - // don't use require here to avoid caching - // remove BOM from file content before parsing - var content = JSON.parse(fs.readFileSync(packageJsonPath, "utf8").replace(/^\uFEFF/, "")); - if (content.dependencies !== undefined) { - addDependencies(result, content.dependencies); - } - if (content.peerDependencies !== undefined) { - addDependencies(result, content.peerDependencies); - } - if (options.dev && content.devDependencies !== undefined) { - addDependencies(result, content.devDependencies); - } - if (options.optional && content.optionalDependencies !== undefined) { - addDependencies(result, content.optionalDependencies); - } - } - catch (_a) { - // treat malformed package.json files as empty - } - } - return result; -} -function addDependencies(result, dependencies) { - for (var name in dependencies) { - if (dependencies.hasOwnProperty(name)) { - result.add(name); - } - } -} -function findPackageJson(current) { - var prev; - do { - var fileName = path.join(current, "package.json"); - if (fs.existsSync(fileName)) { - return fileName; - } - prev = current; - current = path.dirname(current); - } while (prev !== current); - return undefined; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noImportSideEffectRule.d.ts b/node_modules/tslint/lib/rules/noImportSideEffectRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noImportSideEffectRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noImportSideEffectRule.js b/node_modules/tslint/lib/rules/noImportSideEffectRule.js deleted file mode 100644 index 104a8f0e2..000000000 --- a/node_modules/tslint/lib/rules/noImportSideEffectRule.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var _a; -var utils = require("tsutils"); -var Lint = require("../index"); -var OPTION_IGNORE_MODULE = "ignore-module"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var patternConfig = this.ruleArguments[this.ruleArguments.length - 1]; - var ignorePattern = patternConfig === undefined ? undefined : new RegExp(patternConfig[OPTION_IGNORE_MODULE]); - return this.applyWithFunction(sourceFile, walk, ignorePattern); - }; - Rule.metadata = { - description: "Avoid import statements with side-effect.", - optionExamples: [true, [true, (_a = {}, _a[OPTION_IGNORE_MODULE] = "(\\.html|\\.css)$", _a)]], - options: { - items: { - properties: { - "ignore-module": { - type: "string", - }, - }, - type: "object", - }, - maxLength: 1, - minLength: 0, - type: "array", - }, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One argument may be optionally provided:\n\n * `", "` allows to specify a regex and ignore modules which it matches."], ["\n One argument may be optionally provided:\n\n * \\`", "\\` allows to specify a regex and ignore modules which it matches."])), OPTION_IGNORE_MODULE), - rationale: "Imports with side effects may have behavior which is hard for static verification.", - ruleName: "no-import-side-effect", - type: "typescript", - typescriptOnly: false, - }; - Rule.FAILURE_STRING = "import with explicit side-effect"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var ignorePattern = ctx.options, sourceFile = ctx.sourceFile; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (!utils.isImportDeclaration(statement)) { - continue; - } - var importClause = statement.importClause, moduleSpecifier = statement.moduleSpecifier; - if (importClause !== undefined || !utils.isStringLiteral(moduleSpecifier)) { - continue; - } - if (ignorePattern === undefined || !ignorePattern.test(moduleSpecifier.text)) { - ctx.addFailureAtNode(statement, Rule.FAILURE_STRING); - } - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noInferrableTypesRule.d.ts b/node_modules/tslint/lib/rules/noInferrableTypesRule.d.ts deleted file mode 100644 index c8caca0f9..000000000 --- a/node_modules/tslint/lib/rules/noInferrableTypesRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(type: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noInferrableTypesRule.js b/node_modules/tslint/lib/rules/noInferrableTypesRule.js deleted file mode 100644 index dc87eb9ff..000000000 --- a/node_modules/tslint/lib/rules/noInferrableTypesRule.js +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_IGNORE_PARMS = "ignore-params"; -var OPTION_IGNORE_PROPERTIES = "ignore-properties"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (type) { - return "Type " + type + " trivially inferred from a " + type + " literal, remove type annotation"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoInferrableTypesWalker(sourceFile, this.ruleName, { - ignoreParameters: this.ruleArguments.indexOf(OPTION_IGNORE_PARMS) !== -1, - ignoreProperties: this.ruleArguments.indexOf(OPTION_IGNORE_PROPERTIES) !== -1, - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-inferrable-types", - description: "Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.", - rationale: "Explicit types where they can be easily inferred by the compiler make code more verbose.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Two arguments may be optionally provided:\n\n * `", "` allows specifying an inferrable type annotation for function params.\n This can be useful when combining with the `typedef` rule.\n * `", "` allows specifying an inferrable type annotation for class properties."], ["\n Two arguments may be optionally provided:\n\n * \\`", "\\` allows specifying an inferrable type annotation for function params.\n This can be useful when combining with the \\`typedef\\` rule.\n * \\`", "\\` allows specifying an inferrable type annotation for class properties."])), OPTION_IGNORE_PARMS, OPTION_IGNORE_PROPERTIES), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_IGNORE_PARMS, OPTION_IGNORE_PROPERTIES], - }, - minLength: 0, - maxLength: 2, - }, - hasFix: true, - optionExamples: [ - true, - [true, OPTION_IGNORE_PARMS], - [true, OPTION_IGNORE_PARMS, OPTION_IGNORE_PROPERTIES], - ], - type: "typescript", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoInferrableTypesWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoInferrableTypesWalker, _super); - function NoInferrableTypesWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoInferrableTypesWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (shouldCheck(node, _this.options)) { - var name = node.name, type = node.type, initializer = node.initializer; - if (type !== undefined && initializer !== undefined - && typeIsInferrable(type.kind, initializer)) { - var fix = Lint.Replacement.deleteFromTo(name.end, type.end); - _this.addFailureAtNode(type, Rule.FAILURE_STRING_FACTORY(ts.tokenToString(type.kind)), fix); - } - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - return NoInferrableTypesWalker; -}(Lint.AbstractWalker)); -function shouldCheck(node, _a) { - var ignoreParameters = _a.ignoreParameters, ignoreProperties = _a.ignoreProperties; - switch (node.kind) { - case ts.SyntaxKind.Parameter: - return !ignoreParameters && - !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ReadonlyKeyword) && - // "ignore-properties" also works for parameter properties - !(ignoreProperties && node.modifiers !== undefined); - case ts.SyntaxKind.PropertyDeclaration: - return !ignoreProperties && !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ReadonlyKeyword); - case ts.SyntaxKind.VariableDeclaration: - return true; - default: - return false; - } -} -function typeIsInferrable(type, initializer) { - switch (type) { - case ts.SyntaxKind.BooleanKeyword: - return initializer.kind === ts.SyntaxKind.TrueKeyword || initializer.kind === ts.SyntaxKind.FalseKeyword; - case ts.SyntaxKind.NumberKeyword: - return Lint.isNumeric(initializer); - case ts.SyntaxKind.StringKeyword: - switch (initializer.kind) { - case ts.SyntaxKind.StringLiteral: - case ts.SyntaxKind.NoSubstitutionTemplateLiteral: - case ts.SyntaxKind.TemplateExpression: - return true; - default: - return false; - } - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noInferredEmptyObjectTypeRule.d.ts b/node_modules/tslint/lib/rules/noInferredEmptyObjectTypeRule.d.ts deleted file mode 100644 index 6103d1624..000000000 --- a/node_modules/tslint/lib/rules/noInferredEmptyObjectTypeRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static EMPTY_INTERFACE_INSTANCE: string; - static EMPTY_INTERFACE_FUNCTION: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noInferredEmptyObjectTypeRule.js b/node_modules/tslint/lib/rules/noInferredEmptyObjectTypeRule.js deleted file mode 100644 index 0d8bd858a..000000000 --- a/node_modules/tslint/lib/rules/noInferredEmptyObjectTypeRule.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithWalker(new NoInferredEmptyObjectTypeRule(sourceFile, this.ruleName, program.getTypeChecker())); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-inferred-empty-object-type", - description: "Disallow type inference of {} (empty object type) at function and constructor call sites", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n When function or constructor may be called with a type parameter but one isn't supplied or inferrable,\n TypeScript defaults to `{}`.\n This is often undesirable as the call is meant to be of a more specific type.\n "], ["\n When function or constructor may be called with a type parameter but one isn't supplied or inferrable,\n TypeScript defaults to \\`{}\\`.\n This is often undesirable as the call is meant to be of a more specific type.\n "]))), - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.EMPTY_INTERFACE_INSTANCE = "Explicit type parameter needs to be provided to the constructor"; - Rule.EMPTY_INTERFACE_FUNCTION = "Explicit type parameter needs to be provided to the function call"; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -var NoInferredEmptyObjectTypeRule = /** @class */ (function (_super) { - tslib_1.__extends(NoInferredEmptyObjectTypeRule, _super); - function NoInferredEmptyObjectTypeRule(sourceFile, ruleName, checker) { - var _this = _super.call(this, sourceFile, ruleName, undefined) || this; - _this.checker = checker; - return _this; - } - NoInferredEmptyObjectTypeRule.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (node.kind === ts.SyntaxKind.CallExpression) { - _this.checkCallExpression(node); - } - else if (node.kind === ts.SyntaxKind.NewExpression) { - _this.checkNewExpression(node); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - NoInferredEmptyObjectTypeRule.prototype.checkNewExpression = function (node) { - var _this = this; - if (node.typeArguments === undefined) { - var type = this.checker.getTypeAtLocation(node); - if (tsutils_1.isTypeReference(type) && type.typeArguments !== undefined && - type.typeArguments.some(function (a) { return tsutils_1.isObjectType(a) && _this.isEmptyObjectInterface(a); })) { - this.addFailureAtNode(node, Rule.EMPTY_INTERFACE_INSTANCE); - } - } - }; - NoInferredEmptyObjectTypeRule.prototype.checkCallExpression = function (node) { - if (node.typeArguments !== undefined) { - return; - } - var callSig = this.checker.getResolvedSignature(node); - if (callSig === undefined) { - return; - } - var retType = this.checker.getReturnTypeOfSignature(callSig); - if (tsutils_1.isObjectType(retType) && this.isEmptyObjectInterface(retType)) { - this.addFailureAtNode(node, Rule.EMPTY_INTERFACE_FUNCTION); - } - }; - NoInferredEmptyObjectTypeRule.prototype.isEmptyObjectInterface = function (objType) { - var _this = this; - return tsutils_1.isObjectFlagSet(objType, ts.ObjectFlags.Anonymous) && - objType.getProperties().length === 0 && - objType.getNumberIndexType() === undefined && - objType.getStringIndexType() === undefined && - objType.getCallSignatures().every(function (signature) { - var type = _this.checker.getReturnTypeOfSignature(signature); - return tsutils_1.isObjectType(type) && _this.isEmptyObjectInterface(type); - }); - }; - return NoInferredEmptyObjectTypeRule; -}(Lint.AbstractWalker)); -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noInternalModuleRule.d.ts b/node_modules/tslint/lib/rules/noInternalModuleRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noInternalModuleRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noInternalModuleRule.js b/node_modules/tslint/lib/rules/noInternalModuleRule.js deleted file mode 100644 index 965b8c259..000000000 --- a/node_modules/tslint/lib/rules/noInternalModuleRule.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoInternalModuleWalker(sourceFile, this.ruleName, undefined)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-internal-module", - description: "Disallows internal `module`", - rationale: "Using `module` leads to a confusion of concepts with external modules. Use the newer `namespace` keyword instead.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: true, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "The internal 'module' syntax is deprecated, use the 'namespace' keyword instead."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoInternalModuleWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoInternalModuleWalker, _super); - function NoInternalModuleWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoInternalModuleWalker.prototype.walk = function (sourceFile) { - return this.checkStatements(sourceFile.statements); - }; - NoInternalModuleWalker.prototype.checkStatements = function (statements) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (statement.kind === ts.SyntaxKind.ModuleDeclaration) { - this.checkModuleDeclaration(statement); - } - } - }; - NoInternalModuleWalker.prototype.checkModuleDeclaration = function (node, nested) { - if (!nested && - node.name.kind === ts.SyntaxKind.Identifier && - !tsutils_1.isNodeFlagSet(node, ts.NodeFlags.Namespace) && - // augmenting global uses a special syntax that is allowed - // see https://github.com/Microsoft/TypeScript/pull/6213 - !tsutils_1.isNodeFlagSet(node, ts.NodeFlags.GlobalAugmentation)) { - var end = node.name.pos; - var start = end - "module".length; - this.addFailure(start, end, Rule.FAILURE_STRING, Lint.Replacement.replaceFromTo(start, end, "namespace")); - } - if (node.body !== undefined) { - switch (node.body.kind) { - case ts.SyntaxKind.ModuleBlock: - return this.checkStatements(node.body.statements); - case ts.SyntaxKind.ModuleDeclaration: - return this.checkModuleDeclaration(node.body, true); - } - } - }; - return NoInternalModuleWalker; -}(Lint.AbstractWalker)); diff --git a/node_modules/tslint/lib/rules/noInvalidTemplateStringsRule.d.ts b/node_modules/tslint/lib/rules/noInvalidTemplateStringsRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noInvalidTemplateStringsRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noInvalidTemplateStringsRule.js b/node_modules/tslint/lib/rules/noInvalidTemplateStringsRule.js deleted file mode 100644 index 5dd00a4d3..000000000 --- a/node_modules/tslint/lib/rules/noInvalidTemplateStringsRule.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-invalid-template-strings", - description: "Warns on use of `\${` in non-template strings.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: "Interpolation will only work for template strings.", - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Interpolation will only work for template strings."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (utils.isStringLiteral(node)) { - check(node); - } - return ts.forEachChild(node, cb); - }); - function check(node) { - var text = node.getText(ctx.sourceFile); - var findTemplateStrings = /\\*\$\{/g; - var instance = findTemplateStrings.exec(text); - while (instance !== null) { - var matchLength = instance[0].length; - var backslashCount = matchLength - 2; - var instanceIsEscaped = backslashCount % 2 === 1; - if (!instanceIsEscaped) { - var start = node.getStart() + (instance.index + backslashCount); - ctx.addFailureAt(start, 2, Rule.FAILURE_STRING); - } - instance = findTemplateStrings.exec(text); - } - } -} diff --git a/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts b/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts deleted file mode 100644 index f3c779344..000000000 --- a/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from ".."; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_OUTSIDE: string; - static FAILURE_STRING_INSIDE: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noInvalidThisRule.js b/node_modules/tslint/lib/rules/noInvalidThisRule.js deleted file mode 100644 index 1a427d9c2..000000000 --- a/node_modules/tslint/lib/rules/noInvalidThisRule.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require(".."); -var OPTION_FUNCTION_IN_METHOD = "check-function-in-method"; -var DEPRECATED_OPTION_FUNCTION_IN_METHOD = "no-this-in-function-in-method"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var _this = this; - var hasOption = function (name) { return _this.ruleArguments.indexOf(name) !== -1; }; - var checkFuncInMethod = hasOption(DEPRECATED_OPTION_FUNCTION_IN_METHOD) || hasOption(OPTION_FUNCTION_IN_METHOD); - return this.applyWithFunction(sourceFile, walk, checkFuncInMethod); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-invalid-this", - description: "Disallows using the `this` keyword outside of classes.", - rationale: "See [the rule's author's rationale here.](https://github.com/palantir/tslint/pull/1105#issue-147549402)", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One argument may be optionally provided:\n\n * `", "` disallows using the `this` keyword in functions within class methods."], ["\n One argument may be optionally provided:\n\n * \\`", "\\` disallows using the \\`this\\` keyword in functions within class methods."])), OPTION_FUNCTION_IN_METHOD), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_FUNCTION_IN_METHOD], - }, - minLength: 0, - maxLength: 1, - }, - optionExamples: [true, [true, OPTION_FUNCTION_IN_METHOD]], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_OUTSIDE = "the \"this\" keyword is disallowed outside of a class body"; - Rule.FAILURE_STRING_INSIDE = "the \"this\" keyword is disallowed in function bodies inside class methods, " + - "use arrow functions instead"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, checkFuncInMethod = ctx.options; - var inClass = false; - var inFunctionInClass = false; - ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - if (!inClass) { - inClass = true; - ts.forEachChild(node, cb); - inClass = false; - return; - } - break; - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - if (node.parameters.some(tsutils_1.isThisParameter)) { - return; - } - if (inClass) { - inFunctionInClass = true; - ts.forEachChild(node, cb); - inFunctionInClass = false; - return; - } - break; - case ts.SyntaxKind.ThisKeyword: - if (!inClass) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_OUTSIDE); - } - else if (checkFuncInMethod && inFunctionInClass) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_INSIDE); - } - return; - } - ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noIrregularWhitespaceRule.d.ts b/node_modules/tslint/lib/rules/noIrregularWhitespaceRule.d.ts deleted file mode 100644 index 5f3621472..000000000 --- a/node_modules/tslint/lib/rules/noIrregularWhitespaceRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} -export declare const IRREGULAR_WHITESPACE_REGEX: RegExp; diff --git a/node_modules/tslint/lib/rules/noIrregularWhitespaceRule.js b/node_modules/tslint/lib/rules/noIrregularWhitespaceRule.js deleted file mode 100644 index d041cf4b4..000000000 --- a/node_modules/tslint/lib/rules/noIrregularWhitespaceRule.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-irregular-whitespace", - description: "Disallow irregular whitespace within a file, including strings and comments.", - hasFix: true, - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Irregular whitespace not allowed"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -/* Inspired by: https://github.com/eslint/eslint/blob/master/lib/rules/no-irregular-whitespace.js */ -/* tslint:disable:max-line-length */ -exports.IRREGULAR_WHITESPACE_REGEX = /[\u000b\u000c\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]+/mg; -/* tslint:enable:max-line-length */ -function walk(ctx) { - exports.IRREGULAR_WHITESPACE_REGEX.lastIndex = 0; - var match; - // tslint:disable-next-line no-conditional-assignment - while ((match = exports.IRREGULAR_WHITESPACE_REGEX.exec(ctx.sourceFile.text)) !== null) { - var start = match.index; - var len = match[0].length; - var fix = new Lint.Replacement(start, len, " ".repeat(len)); - ctx.addFailureAt(start, len, Rule.FAILURE_STRING, fix); - } -} diff --git a/node_modules/tslint/lib/rules/noMagicNumbersRule.d.ts b/node_modules/tslint/lib/rules/noMagicNumbersRule.d.ts deleted file mode 100644 index 67db20943..000000000 --- a/node_modules/tslint/lib/rules/noMagicNumbersRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static ALLOWED_NODES: Set<ts.SyntaxKind>; - static DEFAULT_ALLOWED: number[]; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noMagicNumbersRule.js b/node_modules/tslint/lib/rules/noMagicNumbersRule.js deleted file mode 100644 index 4678c4f73..000000000 --- a/node_modules/tslint/lib/rules/noMagicNumbersRule.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var tsutils_1 = require("tsutils"); -var Lint = require("../index"); -var utils_1 = require("../language/utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoMagicNumbersWalker(sourceFile, this.ruleName, this.ruleArguments.length > 0 ? this.ruleArguments : Rule.DEFAULT_ALLOWED)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-magic-numbers", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows the use constant number values outside of variable assignments.\n When no list of allowed values is specified, -1, 0 and 1 are allowed by default."], ["\n Disallows the use constant number values outside of variable assignments.\n When no list of allowed values is specified, -1, 0 and 1 are allowed by default."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Magic numbers should be avoided as they often lack documentation.\n Forcing them to be stored in variables gives them implicit documentation.\n "], ["\n Magic numbers should be avoided as they often lack documentation.\n Forcing them to be stored in variables gives them implicit documentation.\n "]))), - optionsDescription: "A list of allowed numbers.", - options: { - type: "array", - items: { - type: "number", - }, - minLength: 1, - }, - optionExamples: [true, [true, 1, 2, 3]], - type: "typescript", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "'magic numbers' are not allowed"; - Rule.ALLOWED_NODES = new Set([ - ts.SyntaxKind.ExportAssignment, - ts.SyntaxKind.FirstAssignment, - ts.SyntaxKind.LastAssignment, - ts.SyntaxKind.PropertyAssignment, - ts.SyntaxKind.ShorthandPropertyAssignment, - ts.SyntaxKind.VariableDeclaration, - ts.SyntaxKind.VariableDeclarationList, - ts.SyntaxKind.EnumMember, - ts.SyntaxKind.PropertyDeclaration, - ts.SyntaxKind.Parameter, - ]); - Rule.DEFAULT_ALLOWED = [-1, 0, 1]; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoMagicNumbersWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoMagicNumbersWalker, _super); - function NoMagicNumbersWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoMagicNumbersWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (tsutils_1.isCallExpression(node) && tsutils_1.isIdentifier(node.expression) && node.expression.text === "parseInt") { - return node.arguments.length === 0 ? undefined : cb(node.arguments[0]); - } - if (node.kind === ts.SyntaxKind.NumericLiteral) { - return _this.checkNumericLiteral(node, node.text); - } - if (utils_1.isNegativeNumberLiteral(node)) { - return _this.checkNumericLiteral(node, "-" + node.operand.text); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - NoMagicNumbersWalker.prototype.checkNumericLiteral = function (node, num) { - /* Using Object.is() to differentiate between pos/neg zero */ - if (!Rule.ALLOWED_NODES.has(node.parent.kind) && - !this.options.some(function (allowedNum) { return Object.is(allowedNum, parseFloat(num)); })) { - this.addFailureAtNode(node, Rule.FAILURE_STRING); - } - }; - return NoMagicNumbersWalker; -}(Lint.AbstractWalker)); -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noMergeableNamespaceRule.d.ts b/node_modules/tslint/lib/rules/noMergeableNamespaceRule.d.ts deleted file mode 100644 index fb9e9ae80..000000000 --- a/node_modules/tslint/lib/rules/noMergeableNamespaceRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static failureStringFactory(name: string, seenBeforeLine: number): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noMergeableNamespaceRule.js b/node_modules/tslint/lib/rules/noMergeableNamespaceRule.js deleted file mode 100644 index 09eb11ee8..000000000 --- a/node_modules/tslint/lib/rules/noMergeableNamespaceRule.js +++ /dev/null @@ -1,92 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.failureStringFactory = function (name, seenBeforeLine) { - return "Mergeable namespace '" + name + "' found. Merge its contents with the namespace on line " + seenBeforeLine + "."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new Walker(sourceFile, this.ruleName, undefined)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-mergeable-namespace", - description: "Disallows mergeable namespaces in the same file.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "maintainability", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var Walker = /** @class */ (function (_super) { - tslib_1.__extends(Walker, _super); - function Walker() { - return _super !== null && _super.apply(this, arguments) || this; - } - Walker.prototype.walk = function (node) { - return this.checkStatements(node.statements); - }; - Walker.prototype.checkStatements = function (statements) { - var seen = new Map(); - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; - if (statement.kind !== ts.SyntaxKind.ModuleDeclaration) { - continue; - } - var name = statement.name; - if (name.kind === ts.SyntaxKind.Identifier) { - var text = name.text; - var prev = seen.get(text); - if (prev !== undefined) { - this.addFailureAtNode(name, Rule.failureStringFactory(text, this.getLineOfNode(prev.name))); - } - seen.set(text, statement); - } - // Recursively check in all module declarations - this.checkModuleDeclaration(statement); - } - }; - Walker.prototype.checkModuleDeclaration = function (decl) { - var body = decl.body; - if (body === undefined) { - return; - } - switch (body.kind) { - case ts.SyntaxKind.ModuleBlock: - this.checkStatements(body.statements); - break; - case ts.SyntaxKind.ModuleDeclaration: - this.checkModuleDeclaration(body); - } - }; - Walker.prototype.getLineOfNode = function (node) { - return ts.getLineAndCharacterOfPosition(this.sourceFile, node.pos).line + 1; - }; - return Walker; -}(Lint.AbstractWalker)); diff --git a/node_modules/tslint/lib/rules/noMisusedNewRule.d.ts b/node_modules/tslint/lib/rules/noMisusedNewRule.d.ts deleted file mode 100644 index 9d47972ab..000000000 --- a/node_modules/tslint/lib/rules/noMisusedNewRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_INTERFACE: string; - static FAILURE_STRING_CLASS: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noMisusedNewRule.js b/node_modules/tslint/lib/rules/noMisusedNewRule.js deleted file mode 100644 index 8a26af86c..000000000 --- a/node_modules/tslint/lib/rules/noMisusedNewRule.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-misused-new", - description: "Warns on apparent attempts to define constructors for interfaces or `new` for classes.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Interfaces in TypeScript aren't meant to describe constructors on their implementations.\n The `new` descriptor is primarily for describing JavaScript libraries.\n If you're trying to describe a function known to be a class, it's typically better to `declare class`.\n "], ["\n Interfaces in TypeScript aren't meant to describe constructors on their implementations.\n The \\`new\\` descriptor is primarily for describing JavaScript libraries.\n If you're trying to describe a function known to be a class, it's typically better to \\`declare class\\`.\n "]))), - type: "functionality", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_INTERFACE = "Interfaces cannot be constructed, only classes. Did you mean `declare class`?"; - Rule.FAILURE_STRING_CLASS = '`new` in a class is a method named "new". Did you mean `constructor`?'; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isMethodSignature(node)) { - if (tsutils_1.getPropertyName(node.name) === "constructor") { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_INTERFACE); - } - } - else if (tsutils_1.isMethodDeclaration(node)) { - if (node.body === undefined && - tsutils_1.getPropertyName(node.name) === "new" && - returnTypeMatchesParent(node.parent, node)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_CLASS); - } - } - else if (tsutils_1.isConstructSignatureDeclaration(node)) { - if (returnTypeMatchesParent(node.parent, node)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_INTERFACE); - } - } - return ts.forEachChild(node, cb); - }); -} -function returnTypeMatchesParent(parent, decl) { - if (parent.name === undefined || decl.type === undefined || !tsutils_1.isTypeReferenceNode(decl.type)) { - return false; - } - return decl.type.typeName.kind === ts.SyntaxKind.Identifier && decl.type.typeName.text === parent.name.text; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noNamespaceRule.d.ts b/node_modules/tslint/lib/rules/noNamespaceRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/noNamespaceRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noNamespaceRule.js b/node_modules/tslint/lib/rules/noNamespaceRule.js deleted file mode 100644 index 602e49c91..000000000 --- a/node_modules/tslint/lib/rules/noNamespaceRule.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALLOW_DECLARATIONS = "allow-declarations"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - allowDeclarations: this.ruleArguments.indexOf(OPTION_ALLOW_DECLARATIONS) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-namespace", - description: "Disallows use of internal \`module\`s and \`namespace\`s.", - descriptionDetails: "This rule still allows the use of `declare module ... {}`", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ES6-style external modules are the standard way to modularize code.\n Using `module {}` and `namespace {}` are outdated ways to organize TypeScript code."], ["\n ES6-style external modules are the standard way to modularize code.\n Using \\`module {}\\` and \\`namespace {}\\` are outdated ways to organize TypeScript code."]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n One argument may be optionally provided:\n\n * `", "` allows `declare namespace ... {}` to describe external APIs."], ["\n One argument may be optionally provided:\n\n * \\`", "\\` allows \\`declare namespace ... {}\\` to describe external APIs."])), OPTION_ALLOW_DECLARATIONS), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_ALLOW_DECLARATIONS], - }, - minLength: 0, - maxLength: 1, - }, - optionExamples: [true, [true, OPTION_ALLOW_DECLARATIONS]], - type: "typescript", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "'namespace' and 'module' are disallowed"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - // Ignore all .d.ts files by returning and not walking their ASTs. - // .d.ts declarations do not have the Ambient flag set, but are still declarations. - if (ctx.sourceFile.isDeclarationFile && ctx.options.allowDeclarations) { - return; - } - for (var _i = 0, _a = ctx.sourceFile.statements; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.kind === ts.SyntaxKind.ModuleDeclaration) { - if (node.name.kind !== ts.SyntaxKind.StringLiteral && - !tsutils_1.isNodeFlagSet(node, ts.NodeFlags.GlobalAugmentation) && - (!ctx.options.allowDeclarations || !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword))) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - } - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noNonNullAssertionRule.d.ts b/node_modules/tslint/lib/rules/noNonNullAssertionRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noNonNullAssertionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noNonNullAssertionRule.js b/node_modules/tslint/lib/rules/noNonNullAssertionRule.js deleted file mode 100644 index f9b2b7857..000000000 --- a/node_modules/tslint/lib/rules/noNonNullAssertionRule.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-non-null-assertion", - description: "Disallows non-null assertions using the `!` postfix operator.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using non-null assertion cancels the benefits of the strict null checking mode.\n\n Instead of assuming objects exist:\n\n ```\n function foo(instance: MyClass | undefined) {\n instance!.doWork();\n }\n ```\n\n Either inform the strict type system that the object must exist:\n\n ```\n function foo(instance: MyClass) {\n instance.doWork();\n }\n ```\n\n Or verify that the instance exists, which will inform the type checker:\n\n ```\n function foo(instance: MyClass | undefined) {\n if (instance !== undefined) {\n instance.doWork();\n }\n }\n ```\n "], ["\n Using non-null assertion cancels the benefits of the strict null checking mode.\n\n Instead of assuming objects exist:\n\n \\`\\`\\`\n function foo(instance: MyClass | undefined) {\n instance!.doWork();\n }\n \\`\\`\\`\n\n Either inform the strict type system that the object must exist:\n\n \\`\\`\\`\n function foo(instance: MyClass) {\n instance.doWork();\n }\n \\`\\`\\`\n\n Or verify that the instance exists, which will inform the type checker:\n\n \\`\\`\\`\n function foo(instance: MyClass | undefined) {\n if (instance !== undefined) {\n instance.doWork();\n }\n }\n \\`\\`\\`\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Forbidden non null assertion"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.NonNullExpression) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noNullKeywordRule.d.ts b/node_modules/tslint/lib/rules/noNullKeywordRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noNullKeywordRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noNullKeywordRule.js b/node_modules/tslint/lib/rules/noNullKeywordRule.js deleted file mode 100644 index 5967586d1..000000000 --- a/node_modules/tslint/lib/rules/noNullKeywordRule.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -// with due reference to https://github.com/Microsoft/TypeScript/blob/7813121c4d77e50aad0eed3152ef1f1156c7b574/scripts/tslint/noNullRule.ts -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-null-keyword", - description: "Disallows use of the `null` keyword literal.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Instead of having the dual concepts of `null` and`undefined` in a codebase,\n this rule ensures that only `undefined` is used.\n\n JavaScript originally intended `undefined` to refer to a value that doesn't yet exist,\n while `null` was meant to refer to a value that does exist but points to nothing.\n That's confusing.\n `undefined` is the default value when object members don't exist, and is the return value\n for newer native collection APIs such as `Map.get` when collection values don't exist.\n\n ```\n const myObject = {};\n myObject.doesNotExist; // undefined\n ```\n\n ```\n const myMap = new Map<string, number>();\n myMap.get(\"doesNotExist\"); // undefined\n ```\n\n To remove confusion over the two similar values, it's better to stick with just `undefined`.\n "], ["\n Instead of having the dual concepts of \\`null\\` and\\`undefined\\` in a codebase,\n this rule ensures that only \\`undefined\\` is used.\n\n JavaScript originally intended \\`undefined\\` to refer to a value that doesn't yet exist,\n while \\`null\\` was meant to refer to a value that does exist but points to nothing.\n That's confusing.\n \\`undefined\\` is the default value when object members don't exist, and is the return value\n for newer native collection APIs such as \\`Map.get\\` when collection values don't exist.\n\n \\`\\`\\`\n const myObject = {};\n myObject.doesNotExist; // undefined\n \\`\\`\\`\n\n \\`\\`\\`\n const myMap = new Map<string, number>();\n myMap.get(\"doesNotExist\"); // undefined\n \\`\\`\\`\n\n To remove confusion over the two similar values, it's better to stick with just \\`undefined\\`.\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use 'undefined' instead of 'null'"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, cb); - function cb(node) { - if (tsutils_1.isTypeNodeKind(node.kind)) { - return; // skip type nodes - } - if (node.kind !== ts.SyntaxKind.NullKeyword) { - return ts.forEachChild(node, cb); - } - var parent = node.parent; - var eq; - if (tsutils_1.isBinaryExpression(parent)) { - eq = Lint.getEqualsKind(parent.operatorToken); - } - if (eq === undefined) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - else if (!eq.isStrict) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING, Lint.Replacement.replaceNode(node, "undefined", ctx.sourceFile)); - } - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noObjectLiteralTypeAssertionRule.d.ts b/node_modules/tslint/lib/rules/noObjectLiteralTypeAssertionRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noObjectLiteralTypeAssertionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noObjectLiteralTypeAssertionRule.js b/node_modules/tslint/lib/rules/noObjectLiteralTypeAssertionRule.js deleted file mode 100644 index 1cad0a6d3..000000000 --- a/node_modules/tslint/lib/rules/noObjectLiteralTypeAssertionRule.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-object-literal-type-assertion", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Forbids an object literal to appear in a type assertion expression.\n Casting to `any` is still allowed."], ["\n Forbids an object literal to appear in a type assertion expression.\n Casting to \\`any\\` is still allowed."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Always prefer `const x: T = { ... };` to `const x = { ... } as T;`.\n The type assertion in the latter case is either unnecessary or hides an error.\n The compiler will warn for excess properties with this syntax, but not missing required fields.\n For example: `const x: { foo: number } = {}` will fail to compile, but\n `const x = {} as { foo: number }` will succeed."], ["\n Always prefer \\`const x: T = { ... };\\` to \\`const x = { ... } as T;\\`.\n The type assertion in the latter case is either unnecessary or hides an error.\n The compiler will warn for excess properties with this syntax, but not missing required fields.\n For example: \\`const x: { foo: number } = {}\\` will fail to compile, but\n \\`const x = {} as { foo: number }\\` will succeed."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Type assertion on object literals is forbidden, use a type annotation instead."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isAssertionExpression(node) && node.type.kind !== ts.SyntaxKind.AnyKeyword && - tsutils_1.isObjectLiteralExpression(tsutils_1.isParenthesizedExpression(node.expression) ? node.expression.expression : node.expression)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noParameterPropertiesRule.d.ts b/node_modules/tslint/lib/rules/noParameterPropertiesRule.d.ts deleted file mode 100644 index 5fc47f394..000000000 --- a/node_modules/tslint/lib/rules/noParameterPropertiesRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(ident: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noParameterPropertiesRule.js b/node_modules/tslint/lib/rules/noParameterPropertiesRule.js deleted file mode 100644 index 193a7f4d6..000000000 --- a/node_modules/tslint/lib/rules/noParameterPropertiesRule.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (ident) { - return "Property '" + ident + "' cannot be declared in the constructor"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-parameter-properties", - description: "Disallows parameter properties in class constructors.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Parameter properties can be confusing to those new to TS as they are less explicit\n than other ways of declaring and initializing class members.\n\n It can be cleaner to keep member variable declarations in one list directly only the class\n (instead of mixed between direct class members and constructor parameter properties).\n "], ["\n Parameter properties can be confusing to those new to TS as they are less explicit\n than other ways of declaring and initializing class members.\n\n It can be cleaner to keep member variable declarations in one list directly only the class\n (instead of mixed between direct class members and constructor parameter properties).\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.Constructor) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - if (tsutils_1.isParameterProperty(parameter)) { - ctx.addFailure(parameter.getStart(ctx.sourceFile), parameter.name.pos, Rule.FAILURE_STRING_FACTORY(parameter.name.getText(ctx.sourceFile))); - } - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noParameterReassignmentRule.d.ts b/node_modules/tslint/lib/rules/noParameterReassignmentRule.d.ts deleted file mode 100644 index db71bc3dc..000000000 --- a/node_modules/tslint/lib/rules/noParameterReassignmentRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noParameterReassignmentRule.js b/node_modules/tslint/lib/rules/noParameterReassignmentRule.js deleted file mode 100644 index 0006201c8..000000000 --- a/node_modules/tslint/lib/rules/noParameterReassignmentRule.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name) { - return "Reassigning parameter '" + name + "' is forbidden."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-parameter-reassignment", - description: "Disallows reassigning parameters.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - tsutils_1.collectVariableUsage(ctx.sourceFile).forEach(function (variable, identifier) { - if (!isParameter(identifier.parent)) { - return; - } - for (var _i = 0, _a = variable.uses; _i < _a.length; _i++) { - var use = _a[_i]; - if (tsutils_1.isReassignmentTarget(use.location)) { - ctx.addFailureAtNode(use.location, Rule.FAILURE_STRING(identifier.text)); - } - } - }); -} -function isParameter(node) { - switch (node.kind) { - case ts.SyntaxKind.Parameter: - return true; - case ts.SyntaxKind.BindingElement: - return tsutils_1.getDeclarationOfBindingElement(node).kind === ts.SyntaxKind.Parameter; - default: - return false; - } -} diff --git a/node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts b/node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts deleted file mode 100644 index 70451bcfa..000000000 --- a/node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_REDUNDANT_TYPE: string; - static FAILURE_STRING_REDUNDANT_TAG(tagName: string): string; - static FAILURE_STRING_NO_COMMENT(tagName: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noRedundantJsdocRule.js b/node_modules/tslint/lib/rules/noRedundantJsdocRule.js deleted file mode 100644 index 3d6eaae71..000000000 --- a/node_modules/tslint/lib/rules/noRedundantJsdocRule.js +++ /dev/null @@ -1,138 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING_REDUNDANT_TAG = function (tagName) { - return "JSDoc tag '@" + tagName + "' is redundant in TypeScript code."; - }; - Rule.FAILURE_STRING_NO_COMMENT = function (tagName) { - return "'@" + tagName + "' is redundant in TypeScript code if it has no description."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-redundant-jsdoc", - description: "Forbids JSDoc which duplicates TypeScript functionality.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_REDUNDANT_TYPE = "Type annotation in JSDoc is redundant in TypeScript code."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - // Intentionally exclude EndOfFileToken: it can have JSDoc, but it is only relevant in JavaScript files - return sourceFile.statements.forEach(function cb(node) { - if (tsutils_1.canHaveJsDoc(node)) { - for (var _i = 0, _a = tsutils_1.getJsDoc(node, sourceFile); _i < _a.length; _i++) { - var tags = _a[_i].tags; - if (tags !== undefined) { - for (var _b = 0, tags_1 = tags; _b < tags_1.length; _b++) { - var tag = tags_1[_b]; - checkTag(tag); - } - } - } - } - return ts.forEachChild(node, cb); - }); - function checkTag(tag) { - switch (tag.kind) { - case ts.SyntaxKind.JSDocTag: - if (redundantTags.has(tag.tagName.text)) { - ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_REDUNDANT_TAG(tag.tagName.text)); - } - break; - case ts.SyntaxKind.JSDocAugmentsTag: - // OK - break; - case ts.SyntaxKind.JSDocClassTag: - case ts.SyntaxKind.JSDocTypeTag: - case ts.SyntaxKind.JSDocTypedefTag: - case ts.SyntaxKind.JSDocPropertyTag: - // Always redundant - ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_REDUNDANT_TAG(tag.tagName.text)); - break; - case ts.SyntaxKind.JSDocTemplateTag: - if (tag.comment === undefined || tag.comment === "") { - ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_NO_COMMENT(tag.tagName.text)); - } - break; - case ts.SyntaxKind.JSDocReturnTag: - case ts.SyntaxKind.JSDocParameterTag: { - var _a = tag, typeExpression = _a.typeExpression, comment = _a.comment; - if (typeExpression !== undefined) { - ctx.addFailureAtNode(typeExpression, Rule.FAILURE_STRING_REDUNDANT_TYPE); - } - if (comment === undefined || comment === "") { - // Redundant if no documentation - ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_NO_COMMENT(tag.tagName.text)); - } - break; - } - default: - throw new Error("Unexpected tag kind: " + ts.SyntaxKind[tag.kind]); - } - } -} -var redundantTags = new Set([ - "abstract", - "access", - "class", - "constant", - "constructs", - "default", - "enum", - "exports", - "function", - "global", - "implements", - "interface", - "instance", - "member", - "memberof", - "mixes", - "mixin", - "module", - "name", - "namespace", - "override", - "private", - "property", - "protected", - "public", - "readonly", - "requires", - "static", - "this", -]); diff --git a/node_modules/tslint/lib/rules/noReferenceImportRule.d.ts b/node_modules/tslint/lib/rules/noReferenceImportRule.d.ts deleted file mode 100644 index eeda34db8..000000000 --- a/node_modules/tslint/lib/rules/noReferenceImportRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(moduleReference: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noReferenceImportRule.js b/node_modules/tslint/lib/rules/noReferenceImportRule.js deleted file mode 100644 index 108addd75..000000000 --- a/node_modules/tslint/lib/rules/noReferenceImportRule.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (moduleReference) { - return "No need to reference \"" + moduleReference + "\", since it is imported."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-reference-import", - description: 'Don\'t `<reference types="foo" />` if you import `foo` anyway.', - optionsDescription: "Not configurable.", - options: null, - type: "style", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - if (ctx.sourceFile.typeReferenceDirectives.length === 0) { - return; - } - var imports = new Set(tsutils_1.findImports(ctx.sourceFile, 3 /* AllStaticImports */).map(function (name) { return name.text; })); - for (var _i = 0, _a = ctx.sourceFile.typeReferenceDirectives; _i < _a.length; _i++) { - var ref = _a[_i]; - if (imports.has(ref.fileName)) { - ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING(ref.fileName)); - } - } -} diff --git a/node_modules/tslint/lib/rules/noReferenceRule.d.ts b/node_modules/tslint/lib/rules/noReferenceRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/noReferenceRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noReferenceRule.js b/node_modules/tslint/lib/rules/noReferenceRule.js deleted file mode 100644 index 5fec96c3b..000000000 --- a/node_modules/tslint/lib/rules/noReferenceRule.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-reference", - description: "Disallows `/// <reference path=>` imports (use ES6-style imports instead).", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using `/// <reference path=>` comments to load other files is outdated.\n Use ES6-style imports to reference other files."], ["\n Using \\`/// <reference path=>\\` comments to load other files is outdated.\n Use ES6-style imports to reference other files."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "<reference> is not allowed, use imports"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - for (var _i = 0, _a = ctx.sourceFile.referencedFiles; _i < _a.length; _i++) { - var ref = _a[_i]; - ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING); - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noRequireImportsRule.d.ts b/node_modules/tslint/lib/rules/noRequireImportsRule.d.ts deleted file mode 100644 index 06b7c4bbe..000000000 --- a/node_modules/tslint/lib/rules/noRequireImportsRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noRequireImportsRule.js b/node_modules/tslint/lib/rules/noRequireImportsRule.js deleted file mode 100644 index 7fd8037f2..000000000 --- a/node_modules/tslint/lib/rules/noRequireImportsRule.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-require-imports", - description: "Disallows invocation of `require()`.", - rationale: "Prefer the newer ES6-style imports over `require()`.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "maintainability", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "require() style import is forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 18 /* AllRequireLike */); _i < _a.length; _i++) { - var name = _a[_i]; - ctx.addFailureAtNode(name.parent, Rule.FAILURE_STRING); - } -} diff --git a/node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts b/node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noReturnAwaitRule.js b/node_modules/tslint/lib/rules/noReturnAwaitRule.js deleted file mode 100644 index 4e354dca6..000000000 --- a/node_modules/tslint/lib/rules/noReturnAwaitRule.js +++ /dev/null @@ -1,110 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-return-await", - description: "Disallows unnecessary `return await`.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n An async function always wraps the return value in a Promise.\n Using `return await` just adds extra time before the overreaching promise is resolved without changing the semantics.\n "], ["\n An async function always wraps the return value in a Promise.\n Using \\`return await\\` just adds extra time before the overreaching promise is resolved without changing the semantics.\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Unnecessary 'await'."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.AwaitExpression && isUnnecessaryAwait(node)) { - var expression = node.expression; - var keywordStart = expression.pos - "await".length; - ctx.addFailure(keywordStart, expression.pos, Rule.FAILURE_STRING, Lint.Replacement.deleteFromTo(keywordStart, expression.getStart(ctx.sourceFile))); - } - return ts.forEachChild(node, cb); - }); -} -function isUnnecessaryAwait(node) { - while (true) { - var parent = node.parent; - outer: switch (parent.kind) { - case ts.SyntaxKind.ArrowFunction: - return true; - case ts.SyntaxKind.ReturnStatement: - return !isInsideTryBlock(parent.parent); - case ts.SyntaxKind.ParenthesizedExpression: - break; - case ts.SyntaxKind.ConditionalExpression: - if (parent.condition === node) { - return false; - } - break; - case ts.SyntaxKind.BinaryExpression: - if (parent.right === node) { - switch (parent.operatorToken.kind) { - case ts.SyntaxKind.AmpersandAmpersandToken: - case ts.SyntaxKind.BarBarToken: - case ts.SyntaxKind.CommaToken: - break outer; - } - } - return false; - default: - return false; - } - node = parent; - } -} -function isInsideTryBlock(node) { - while (node.parent !== undefined) { - if (tsutils_1.isFunctionScopeBoundary(node)) { - return false; - } - if (tsutils_1.isTryStatement(node.parent)) { - if ( - // statements inside the try block always have an error handler, either catch or finally - node.parent.tryBlock === node || - // statement inside the catch block only have an error handler if there is a finally block - node.parent.finallyBlock !== undefined && node.parent.catchClause === node) { - return true; - } - node = node.parent.parent; - } - else { - node = node.parent; - } - } - return false; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noShadowedVariableRule.d.ts b/node_modules/tslint/lib/rules/noShadowedVariableRule.d.ts deleted file mode 100644 index 759d5fafb..000000000 --- a/node_modules/tslint/lib/rules/noShadowedVariableRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noShadowedVariableRule.js b/node_modules/tslint/lib/rules/noShadowedVariableRule.js deleted file mode 100644 index 7ada497cc..000000000 --- a/node_modules/tslint/lib/rules/noShadowedVariableRule.js +++ /dev/null @@ -1,321 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (name) { - return "Shadowed name: '" + name + "'"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoShadowedVariableWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments[0]))); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-shadowed-variable", - description: "Disallows shadowing variable declarations.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Shadowing a variable masks access to it and obscures to what value an identifier actually refers.\n For example, in the following code, it can be confusing why the filter is likely never true:\n\n ```\n const findNeighborsWithin = (instance: MyClass, instances: MyClass[]): MyClass[] => {\n return instances.filter((instance) => instance.neighbors.includes(instance));\n };\n ```\n "], ["\n Shadowing a variable masks access to it and obscures to what value an identifier actually refers.\n For example, in the following code, it can be confusing why the filter is likely never true:\n\n \\`\\`\\`\n const findNeighborsWithin = (instance: MyClass, instances: MyClass[]): MyClass[] => {\n return instances.filter((instance) => instance.neighbors.includes(instance));\n };\n \\`\\`\\`\n "]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are `\"class\"`, `\"enum\"`, `\"function\"`, `\"import\"`, `\"interface\"`, `\"namespace\"`, `\"typeAlias\"`\n and `\"typeParameter\"`. Just set the value to `false` for the check you want to disable.\n All checks default to `true`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n\n The option `\"temporalDeadZone\"` defaults to `true` which shows errors when shadowing block scoped declarations in their\n temporal dead zone. When set to `false` parameters, classes, enums and variables declared\n with `let` or `const` are not considered shadowed if the shadowing occurs within their\n [temporal dead zone](http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified).\n\n The following example shows how the `\"temporalDeadZone\"` option changes the linting result:\n\n ```ts\n function fn(value) {\n if (value) {\n const tmp = value; // no error on this line if \"temporalDeadZone\" is false\n return tmp;\n }\n let tmp = undefined;\n if (!value) {\n const tmp = value; // this line always contains an error\n return tmp;\n }\n }\n ```\n "], ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are \\`\"class\"\\`, \\`\"enum\"\\`, \\`\"function\"\\`, \\`\"import\"\\`, \\`\"interface\"\\`, \\`\"namespace\"\\`, \\`\"typeAlias\"\\`\n and \\`\"typeParameter\"\\`. Just set the value to \\`false\\` for the check you want to disable.\n All checks default to \\`true\\`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n\n The option \\`\"temporalDeadZone\"\\` defaults to \\`true\\` which shows errors when shadowing block scoped declarations in their\n temporal dead zone. When set to \\`false\\` parameters, classes, enums and variables declared\n with \\`let\\` or \\`const\\` are not considered shadowed if the shadowing occurs within their\n [temporal dead zone](http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified).\n\n The following example shows how the \\`\"temporalDeadZone\"\\` option changes the linting result:\n\n \\`\\`\\`ts\n function fn(value) {\n if (value) {\n const tmp = value; // no error on this line if \"temporalDeadZone\" is false\n return tmp;\n }\n let tmp = undefined;\n if (!value) {\n const tmp = value; // this line always contains an error\n return tmp;\n }\n }\n \\`\\`\\`\n "]))), - options: { - type: "object", - properties: { - class: { type: "boolean" }, - enum: { type: "boolean" }, - function: { type: "boolean" }, - import: { type: "boolean" }, - interface: { type: "boolean" }, - namespace: { type: "boolean" }, - typeAlias: { type: "boolean" }, - typeParameter: { type: "boolean" }, - temporalDeadZone: { type: "boolean" }, - }, - }, - optionExamples: [ - true, - [true, { class: true, enum: true, function: true, interface: false, namespace: true, typeAlias: false, typeParameter: false }], - ], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(option) { - return tslib_1.__assign({ class: true, enum: true, function: true, import: true, interface: true, namespace: true, temporalDeadZone: true, typeAlias: true, typeParameter: true }, option); -} -var Scope = /** @class */ (function () { - function Scope(functionScope) { - this.variables = new Map(); - this.variablesSeen = new Map(); - this.reassigned = new Set(); - // if no functionScope is provided we are in the process of creating a new function scope, which for consistency links to itself - this.functionScope = functionScope !== undefined ? functionScope : this; - } - Scope.prototype.addVariable = function (identifier, blockScoped, tdz) { - if (blockScoped === void 0) { blockScoped = true; } - if (tdz === void 0) { tdz = false; } - // block scoped variables go to the block scope, function scoped variables to the containing function scope - var scope = blockScoped ? this : this.functionScope; - var list = scope.variables.get(identifier.text); - var variableInfo = { - identifier: identifier, - tdz: tdz, - }; - if (list === undefined) { - scope.variables.set(identifier.text, [variableInfo]); - } - else { - list.push(variableInfo); - } - }; - return Scope; -}()); -var NoShadowedVariableWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoShadowedVariableWalker, _super); - function NoShadowedVariableWalker() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.scope = new Scope(); - return _this; - } - NoShadowedVariableWalker.prototype.walk = function (sourceFile) { - var _this = this; - if (sourceFile.isDeclarationFile) { - return; - } - this.scope = new Scope(); - var cb = function (node) { - var parentScope = _this.scope; - if ((_this.options.function && tsutils_1.isFunctionExpression(node) || _this.options.class && tsutils_1.isClassExpression(node)) && - node.name !== undefined) { - /* special handling for named function and class expressions: - technically the name of the function is only visible inside of it, - but variables with the same name declared inside don't cause compiler errors. - Therefore we add an additional function scope only for the function name to avoid merging with other declarations */ - var functionScope = new Scope(); - functionScope.addVariable(node.name, false); - _this.scope = new Scope(); - if (tsutils_1.isClassExpression(node)) { - _this.visitClassLikeDeclaration(node, functionScope, cb); - } - else { - ts.forEachChild(node, cb); - } - _this.onScopeEnd(functionScope); - _this.scope = functionScope; - _this.onScopeEnd(parentScope); - _this.scope = parentScope; - return; - } - /* Visit decorators before entering a function scope. - In the AST decorators are children of the declaration they decorate, but we don't want to warn for the following code: - @decorator((param) => param) - function foo(param) {} - */ - if (node.decorators !== undefined) { - for (var _i = 0, _a = node.decorators; _i < _a.length; _i++) { - var decorator = _a[_i]; - ts.forEachChild(decorator, cb); - } - } - var boundary = tsutils_1.isScopeBoundary(node); - if (boundary === 2 /* Block */) { - _this.scope = new Scope(parentScope.functionScope); - } - else if (boundary === 1 /* Function */) { - _this.scope = new Scope(); - } - switch (node.kind) { - case ts.SyntaxKind.Decorator: - return; // handled above - case ts.SyntaxKind.VariableDeclarationList: - _this.handleVariableDeclarationList(node); - break; - case ts.SyntaxKind.TypeParameter: - if (_this.options.typeParameter) { - _this.scope.addVariable(node.name); - } - break; - case ts.SyntaxKind.FunctionDeclaration: - if (_this.options.function && node.name !== undefined) { - parentScope.addVariable(node.name, false); - } - break; - case ts.SyntaxKind.ClassDeclaration: - if (_this.options.class && node.name !== undefined) { - parentScope.addVariable(node.name, true, true); - } - // falls through - case ts.SyntaxKind.ClassExpression: - _this.visitClassLikeDeclaration(node, parentScope, cb); - _this.onScopeEnd(parentScope); - _this.scope = parentScope; - return; - case ts.SyntaxKind.TypeAliasDeclaration: - if (_this.options.typeAlias) { - parentScope.addVariable(node.name); - } - break; - case ts.SyntaxKind.EnumDeclaration: - if (_this.options.enum) { - parentScope.addVariable(node.name, true, true); - } - break; - case ts.SyntaxKind.InterfaceDeclaration: - if (_this.options.interface) { - parentScope.addVariable(node.name); - } - break; - case ts.SyntaxKind.Parameter: - if (node.parent.kind !== ts.SyntaxKind.IndexSignature && - !tsutils_1.isThisParameter(node) && - tsutils_1.isFunctionWithBody(node.parent)) { - _this.handleBindingName(node.name, false, true); - } - break; - case ts.SyntaxKind.ModuleDeclaration: - if (_this.options.namespace && - node.parent.kind !== ts.SyntaxKind.ModuleDeclaration && - node.name.kind === ts.SyntaxKind.Identifier && - !tsutils_1.isNodeFlagSet(node, ts.NodeFlags.GlobalAugmentation)) { - parentScope.addVariable(node.name, false); - } - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) { - _this.onScopeEnd(parentScope); - _this.scope = parentScope; - return; // don't check any ambient declaration blocks - } - break; - case ts.SyntaxKind.ImportClause: - if (_this.options.import && node.name !== undefined) { - _this.scope.addVariable(node.name, false); - } - break; - case ts.SyntaxKind.NamespaceImport: - case ts.SyntaxKind.ImportSpecifier: - case ts.SyntaxKind.ImportEqualsDeclaration: - if (_this.options.import) { - _this.scope.addVariable(node.name, false); - } - } - if (boundary !== 0 /* None */) { - ts.forEachChild(node, cb); - _this.onScopeEnd(parentScope); - _this.scope = parentScope; - } - else { - return ts.forEachChild(node, cb); - } - }; - ts.forEachChild(sourceFile, cb); - this.onScopeEnd(); - }; - NoShadowedVariableWalker.prototype.visitClassLikeDeclaration = function (declaration, parentScope, cb) { - var _this = this; - var currentScope = this.scope; - ts.forEachChild(declaration, function (node) { - if (!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) { - return cb(node); - } - /* Don't treat static members as children of the class' scope. That avoid shadowed type parameter warnings on static members. - class C<T> { - static method<T>() {} - } - */ - _this.scope = parentScope; - cb(node); - _this.scope = currentScope; - }); - }; - NoShadowedVariableWalker.prototype.handleVariableDeclarationList = function (node) { - var blockScoped = tsutils_1.isBlockScopedVariableDeclarationList(node); - for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - this.handleBindingName(variable.name, blockScoped); - } - }; - NoShadowedVariableWalker.prototype.handleBindingName = function (node, blockScoped, tdz) { - if (tdz === void 0) { tdz = blockScoped; } - if (node.kind === ts.SyntaxKind.Identifier) { - this.scope.addVariable(node, blockScoped, tdz); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== ts.SyntaxKind.OmittedExpression) { - this.handleBindingName(element.name, blockScoped, tdz); - } - } - } - }; - NoShadowedVariableWalker.prototype.onScopeEnd = function (parent) { - var _this = this; - var _a = this.scope, variables = _a.variables, variablesSeen = _a.variablesSeen; - variablesSeen.forEach(function (identifiers, name) { - var declarationsInScope = variables.get(name); - var _loop_1 = function (identifier) { - if (declarationsInScope !== undefined && - (_this.options.temporalDeadZone || - // check if any of the declaration either has no temporal dead zone or is declared before the identifier - declarationsInScope.some(function (declaration) { return !declaration.tdz || declaration.identifier.pos < identifier.pos; }))) { - _this.addFailureAtNode(identifier, Rule.FAILURE_STRING_FACTORY(name)); - } - else if (parent !== undefined) { - addOneToList(parent.variablesSeen, name, identifier); - } - }; - for (var _i = 0, identifiers_1 = identifiers; _i < identifiers_1.length; _i++) { - var identifier = identifiers_1[_i]; - _loop_1(identifier); - } - }); - if (parent !== undefined) { - variables.forEach(function (identifiers, name) { - addToList(parent.variablesSeen, name, identifiers); - }); - } - }; - return NoShadowedVariableWalker; -}(Lint.AbstractWalker)); -function addToList(map, name, variables) { - var list = map.get(name); - if (list === undefined) { - list = []; - map.set(name, list); - } - for (var _i = 0, variables_1 = variables; _i < variables_1.length; _i++) { - var variable = variables_1[_i]; - list.push(variable.identifier); - } -} -function addOneToList(map, name, identifier) { - var list = map.get(name); - if (list === undefined) { - map.set(name, [identifier]); - } - else { - list.push(identifier); - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noSparseArraysRule.d.ts b/node_modules/tslint/lib/rules/noSparseArraysRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noSparseArraysRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noSparseArraysRule.js b/node_modules/tslint/lib/rules/noSparseArraysRule.js deleted file mode 100644 index 387b4cc50..000000000 --- a/node_modules/tslint/lib/rules/noSparseArraysRule.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-sparse-arrays", - description: "Forbids array literals to contain missing elements.", - rationale: "Missing elements are probably an accidentally duplicated comma.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Array has a missing element."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (!utils.isArrayLiteralExpression(node)) { - if (utils.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) { - // Ignore LHS of assignments. - traverseExpressionsInLHS(node.left, cb); - return cb(node.right); - } - else { - return ts.forEachChild(node, cb); - } - } - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (utils.isOmittedExpression(element)) { - // Node has an empty range, so just use range starting at `element.pos`. - ctx.addFailureAt(element.pos, 1, Rule.FAILURE_STRING); - } - else { - ts.forEachChild(element, cb); - } - } - }); -} -/** Traverse the LHS of an `=` expression, calling `cb` embedded default value, but ignoring binding patterns. */ -function traverseExpressionsInLHS(node, cb) { - switch (node.kind) { - case ts.SyntaxKind.ParenthesizedExpression: - traverseExpressionsInLHS(node.expression, cb); - break; - case ts.SyntaxKind.ArrayLiteralExpression: - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var e = _a[_i]; - traverseExpressionsInLHS(e, cb); - } - break; - case ts.SyntaxKind.ObjectLiteralExpression: - for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { - var o = _c[_b]; - traverseExpressionsInLHS(o, cb); - } - break; - case ts.SyntaxKind.BinaryExpression: { - var _d = node, left = _d.left, operatorToken = _d.operatorToken, right = _d.right; - if (operatorToken.kind === ts.SyntaxKind.EqualsToken) { - traverseExpressionsInLHS(left, cb); - cb(right); - } - } - } -} diff --git a/node_modules/tslint/lib/rules/noStringLiteralRule.d.ts b/node_modules/tslint/lib/rules/noStringLiteralRule.d.ts deleted file mode 100644 index 06cb02d5e..000000000 --- a/node_modules/tslint/lib/rules/noStringLiteralRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static id(input: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noStringLiteralRule.js b/node_modules/tslint/lib/rules/noStringLiteralRule.js deleted file mode 100644 index c0669cf83..000000000 --- a/node_modules/tslint/lib/rules/noStringLiteralRule.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.id = function (input) { - return input; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-string-literal", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Forbids unnecessary string literal property access.\n Allows `obj[\"prop-erty\"]` (can't be a regular property access).\n Disallows `obj[\"property\"]` (should be `obj.property`)."], ["\n Forbids unnecessary string literal property access.\n Allows \\`obj[\"prop-erty\"]\\` (can't be a regular property access).\n Disallows \\`obj[\"property\"]\\` (should be \\`obj.property\\`)."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n If `--noImplicitAny` is turned off,\n property access via a string literal will be 'any' if the property does not exist."], ["\n If \\`--noImplicitAny\\` is turned off,\n property access via a string literal will be 'any' if the property does not exist."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "object access via string literals is disallowed"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isElementAccessExpression(node)) { - var argument = node.argumentExpression; - if (argument !== undefined && tsutils_1.isStringLiteral(argument) && tsutils_1.isValidPropertyAccess(argument.text)) { - // typescript@<2.5.0 has an extra underscore in escaped identifier text content, - // to avoid fixing issue `expr['__foo'] → expr.___foo`, unescapeIdentifier() is to be used - // As of typescript@3, unescapeIdentifier() removed, thus check in runtime, if the method exists - // tslint:disable-next-line no-unsafe-any strict-boolean-expressions - var unescapeIdentifier = ts.unescapeIdentifier || Rule.id; - var propertyName = unescapeIdentifier(argument.text); - ctx.addFailureAtNode(argument, Rule.FAILURE_STRING, - // expr['foo'] -> expr.foo - Lint.Replacement.replaceFromTo(node.expression.end, node.end, "." + propertyName)); - } - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noStringThrowRule.d.ts b/node_modules/tslint/lib/rules/noStringThrowRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/noStringThrowRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noStringThrowRule.js b/node_modules/tslint/lib/rules/noStringThrowRule.js deleted file mode 100644 index 84c314db1..000000000 --- a/node_modules/tslint/lib/rules/noStringThrowRule.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var noStringThrowRule_examples_1 = require("./code-examples/noStringThrowRule.examples"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-string-throw", - description: "Flags throwing plain strings or concatenations of strings.", - hasFix: true, - options: null, - optionExamples: [true], - optionsDescription: "Not configurable.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Example \u2013 Doing it right\n\n ```ts\n // throwing an Error from typical function, whether sync or async\n if (!productToAdd) {\n throw new Error(\"How can I add new product when no value provided?\");\n }\n ```\n\n Example \u2013 Anti Pattern\n\n ```ts\n // throwing a string lacks any stack trace information and other important data properties\n if (!productToAdd) {\n throw (\"How can I add new product when no value provided?\");\n }\n ```\n\n Only Error objects contain a `.stack` member equivalent to the current stack trace.\n Primitives such as strings do not.\n "], ["\n Example \u2013 Doing it right\n\n \\`\\`\\`ts\n // throwing an Error from typical function, whether sync or async\n if (!productToAdd) {\n throw new Error(\"How can I add new product when no value provided?\");\n }\n \\`\\`\\`\n\n Example \u2013 Anti Pattern\n\n \\`\\`\\`ts\n // throwing a string lacks any stack trace information and other important data properties\n if (!productToAdd) {\n throw (\"How can I add new product when no value provided?\");\n }\n \\`\\`\\`\n\n Only Error objects contain a \\`.stack\\` member equivalent to the current stack trace.\n Primitives such as strings do not.\n "]))), - codeExamples: noStringThrowRule_examples_1.codeExamples, - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Throwing plain strings (not instances of Error) gives no stack traces"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isThrowStatement(node)) { - var expression = node.expression; - if (isString(expression)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING, [ - Lint.Replacement.appendText(expression.getStart(sourceFile), "new Error("), - Lint.Replacement.appendText(expression.getEnd(), ")"), - ]); - } - } - return ts.forEachChild(node, cb); - }); -} -function isString(node) { - switch (node.kind) { - case ts.SyntaxKind.StringLiteral: - case ts.SyntaxKind.NoSubstitutionTemplateLiteral: - case ts.SyntaxKind.TemplateExpression: - return true; - case ts.SyntaxKind.BinaryExpression: { - var _a = node, operatorToken = _a.operatorToken, left = _a.left, right = _a.right; - return operatorToken.kind === ts.SyntaxKind.PlusToken && (isString(left) || isString(right)); - } - case ts.SyntaxKind.ParenthesizedExpression: - return isString(node.expression); - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noSubmoduleImportsRule.d.ts b/node_modules/tslint/lib/rules/noSubmoduleImportsRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/noSubmoduleImportsRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js b/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js deleted file mode 100644 index 1e053483a..000000000 --- a/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, this.ruleArguments); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-submodule-imports", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows importing any submodule."], ["\n Disallows importing any submodule."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Submodules of some packages are treated as private APIs and the import\n paths may change without deprecation periods. It's best to stick with\n top-level package exports."], ["\n Submodules of some packages are treated as private APIs and the import\n paths may change without deprecation periods. It's best to stick with\n top-level package exports."]))), - optionsDescription: "A list of whitelisted package or submodule names.", - options: { - type: "array", - items: { - type: "string", - }, - }, - optionExamples: [true, [true, "rxjs", "@angular/platform-browser", "@angular/core/testing"]], - type: "functionality", - typescriptOnly: false, - }; - Rule.FAILURE_STRING = "Submodule import paths from this package are disallowed; import from the root instead"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 63 /* All */); _i < _a.length; _i++) { - var name = _a[_i]; - if (!ts.isExternalModuleNameRelative(name.text) && - isSubmodulePath(name.text) && - !isWhitelisted(name.text, ctx.options)) { - ctx.addFailureAtNode(name, Rule.FAILURE_STRING); - } - } -} -function isWhitelisted(path, whitelist) { - for (var _i = 0, whitelist_1 = whitelist; _i < whitelist_1.length; _i++) { - var option = whitelist_1[_i]; - if (path === option || path.startsWith(option + "/")) { - return true; - } - } - return false; -} -function isSubmodulePath(path) { - return path.split("/").length > (path[0] === "@" ? 2 : 1); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noSwitchCaseFallThroughRule.d.ts b/node_modules/tslint/lib/rules/noSwitchCaseFallThroughRule.d.ts deleted file mode 100644 index 46b8a7ad1..000000000 --- a/node_modules/tslint/lib/rules/noSwitchCaseFallThroughRule.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(keyword: ts.SyntaxKind): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} -export declare class NoSwitchCaseFallThroughWalker extends Lint.AbstractWalker<void> { - walk(sourceFile: ts.SourceFile): void | undefined; - private visitSwitchStatement; - private isFallThroughAllowed; -} diff --git a/node_modules/tslint/lib/rules/noSwitchCaseFallThroughRule.js b/node_modules/tslint/lib/rules/noSwitchCaseFallThroughRule.js deleted file mode 100644 index 428da3e3f..000000000 --- a/node_modules/tslint/lib/rules/noSwitchCaseFallThroughRule.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (keyword) { - return "expected a 'break' before '" + ts.tokenToString(keyword) + "'"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoSwitchCaseFallThroughWalker(sourceFile, this.ruleName, undefined)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-switch-case-fall-through", - description: "Disallows falling through case statements.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n For example, the following is not allowed:\n\n ```ts\n switch(foo) {\n case 1:\n someFunc(foo);\n case 2:\n someOtherFunc(foo);\n }\n ```\n\n However, fall through is allowed when case statements are consecutive or\n a magic `/* falls through */` comment is present. The following is valid:\n\n ```ts\n switch(foo) {\n case 1:\n someFunc(foo);\n /* falls through */\n case 2:\n case 3:\n someOtherFunc(foo);\n }\n ```"], ["\n For example, the following is not allowed:\n\n \\`\\`\\`ts\n switch(foo) {\n case 1:\n someFunc(foo);\n case 2:\n someOtherFunc(foo);\n }\n \\`\\`\\`\n\n However, fall through is allowed when case statements are consecutive or\n a magic \\`/* falls through */\\` comment is present. The following is valid:\n\n \\`\\`\\`ts\n switch(foo) {\n case 1:\n someFunc(foo);\n /* falls through */\n case 2:\n case 3:\n someOtherFunc(foo);\n }\n \\`\\`\\`"]))), - rationale: "Fall though in switch statements is often unintentional and a bug.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoSwitchCaseFallThroughWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoSwitchCaseFallThroughWalker, _super); - function NoSwitchCaseFallThroughWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoSwitchCaseFallThroughWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (utils.isSwitchStatement(node)) { - _this.visitSwitchStatement(node); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - NoSwitchCaseFallThroughWalker.prototype.visitSwitchStatement = function (_a) { - var _this = this; - var clauses = _a.caseBlock.clauses; - clauses.forEach(function (clause, i) { - if (i !== clauses.length - 1 - && clause.statements.length !== 0 - && !utils.endsControlFlow(clause) - && !_this.isFallThroughAllowed(clause)) { - var keyword = clauses[i + 1].getChildAt(0); - _this.addFailureAtNode(keyword, Rule.FAILURE_STRING(keyword.kind)); - } - }); - }; - NoSwitchCaseFallThroughWalker.prototype.isFallThroughAllowed = function (clause) { - var _this = this; - var comments = ts.getLeadingCommentRanges(this.sourceFile.text, clause.end); - return comments !== undefined && - comments.some(function (comment) { return /^\s*falls through\b/i.test(_this.sourceFile.text.slice(comment.pos + 2, comment.end)); }); - }; - return NoSwitchCaseFallThroughWalker; -}(Lint.AbstractWalker)); -exports.NoSwitchCaseFallThroughWalker = NoSwitchCaseFallThroughWalker; -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noThisAssignmentRule.d.ts b/node_modules/tslint/lib/rules/noThisAssignmentRule.d.ts deleted file mode 100644 index da606e4b6..000000000 --- a/node_modules/tslint/lib/rules/noThisAssignmentRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_BINDINGS: string; - static FAILURE_STRING_FACTORY_IDENTIFIERS(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noThisAssignmentRule.js b/node_modules/tslint/lib/rules/noThisAssignmentRule.js deleted file mode 100644 index df581bdb8..000000000 --- a/node_modules/tslint/lib/rules/noThisAssignmentRule.js +++ /dev/null @@ -1,128 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var _a, _b; -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var ALLOW_THIS_DESTRUCTURING = "allow-destructuring"; -var ALLOWED_THIS_NAMES = "allowed-names"; -var parseConfigOptions = function (configOptions) { - var allowedNames = []; - var allowDestructuring = false; - if (configOptions !== undefined) { - allowDestructuring = !!configOptions[ALLOW_THIS_DESTRUCTURING]; - if (configOptions[ALLOWED_THIS_NAMES] !== undefined) { - allowedNames.push.apply(allowedNames, configOptions[ALLOWED_THIS_NAMES]); - } - } - return { allowedNames: allowedNames, allowDestructuring: allowDestructuring }; -}; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING_FACTORY_IDENTIFIERS = function (name) { - return "Assigning `this` reference to local variable not allowed: " + name + "."; - }; - Rule.prototype.apply = function (sourceFile) { - var options = parseConfigOptions(this.ruleArguments[0]); - var noThisAssignmentWalker = new NoThisAssignmentWalker(sourceFile, this.ruleName, options); - return this.applyWithWalker(noThisAssignmentWalker); - }; - Rule.metadata = { - description: "Disallows unnecessary references to `this`.", - optionExamples: [ - true, - [ - true, - (_a = {}, - _a[ALLOWED_THIS_NAMES] = ["^self$"], - _a[ALLOW_THIS_DESTRUCTURING] = true, - _a), - ], - ], - options: { - additionalProperties: false, - properties: (_b = {}, - _b[ALLOW_THIS_DESTRUCTURING] = { - type: "boolean", - }, - _b[ALLOWED_THIS_NAMES] = { - listType: "string", - type: "list", - }, - _b), - type: "object", - }, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Two options may be provided on an object:\n\n * `", "` allows using destructuring to access members of `this` (e.g. `{ foo, bar } = this;`).\n * `", "` may be specified as a list of regular expressions to match allowed variable names."], ["\n Two options may be provided on an object:\n\n * \\`", "\\` allows using destructuring to access members of \\`this\\` (e.g. \\`{ foo, bar } = this;\\`).\n * \\`", "\\` may be specified as a list of regular expressions to match allowed variable names."])), ALLOW_THIS_DESTRUCTURING, ALLOWED_THIS_NAMES), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Assigning a variable to `this` instead of properly using arrow lambdas may be a symptom of pre-ES6 practices\n or not managing scope well.\n\n Instead of storing a reference to `this` and using it inside a `function () {`:\n\n ```\n const self = this;\n\n setTimeout(function () {\n self.doWork();\n });\n ```\n\n Use `() =>` arrow lambdas, as they preserve `this` scope for you:\n\n ```\n setTimeout(() => {\n this.doWork();\n });\n ```\n "], ["\n Assigning a variable to \\`this\\` instead of properly using arrow lambdas may be a symptom of pre-ES6 practices\n or not managing scope well.\n\n Instead of storing a reference to \\`this\\` and using it inside a \\`function () {\\`:\n\n \\`\\`\\`\n const self = this;\n\n setTimeout(function () {\n self.doWork();\n });\n \\`\\`\\`\n\n Use \\`() =>\\` arrow lambdas, as they preserve \\`this\\` scope for you:\n\n \\`\\`\\`\n setTimeout(() => {\n this.doWork();\n });\n \\`\\`\\`\n "]))), - ruleName: "no-this-assignment", - type: "functionality", - typescriptOnly: false, - }; - Rule.FAILURE_STRING_BINDINGS = "Don't assign members of `this` to local variables."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoThisAssignmentWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoThisAssignmentWalker, _super); - function NoThisAssignmentWalker() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.allowedThisNameTesters = _this.options.allowedNames.map(function (allowedThisName) { return new RegExp(allowedThisName); }); - _this.visitNode = function (node) { - if (utils.isVariableDeclaration(node)) { - _this.visitVariableDeclaration(node); - } - ts.forEachChild(node, _this.visitNode); - }; - return _this; - } - NoThisAssignmentWalker.prototype.walk = function (sourceFile) { - ts.forEachChild(sourceFile, this.visitNode); - }; - NoThisAssignmentWalker.prototype.visitVariableDeclaration = function (node) { - if (node.initializer === undefined || node.initializer.kind !== ts.SyntaxKind.ThisKeyword) { - return; - } - switch (node.name.kind) { - case ts.SyntaxKind.Identifier: - if (this.variableNameIsBanned(node.name.text)) { - this.addFailureAtNode(node, Rule.FAILURE_STRING_FACTORY_IDENTIFIERS(node.name.text)); - } - break; - default: - if (!this.options.allowDestructuring) { - this.addFailureAtNode(node, Rule.FAILURE_STRING_BINDINGS); - } - } - }; - NoThisAssignmentWalker.prototype.variableNameIsBanned = function (name) { - for (var _i = 0, _a = this.allowedThisNameTesters; _i < _a.length; _i++) { - var tester = _a[_i]; - if (tester.test(name)) { - return false; - } - } - return true; - }; - return NoThisAssignmentWalker; -}(Lint.AbstractWalker)); -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.d.ts b/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js b/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js deleted file mode 100644 index 44041143b..000000000 --- a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js +++ /dev/null @@ -1,132 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var noConsecutiveBlankLinesRule_1 = require("./noConsecutiveBlankLinesRule"); -var OPTION_IGNORE_COMMENTS = "ignore-comments"; -var OPTION_IGNORE_JSDOC = "ignore-jsdoc"; -var OPTION_IGNORE_TEMPLATE_STRINGS = "ignore-template-strings"; -var OPTION_IGNORE_BLANK_LINES = "ignore-blank-lines"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var ignoreComments = this.ruleArguments.indexOf(OPTION_IGNORE_COMMENTS) !== -1; - return this.applyWithFunction(sourceFile, walk, { - ignoreBlankLines: this.ruleArguments.indexOf(OPTION_IGNORE_BLANK_LINES) !== -1, - ignoreComments: ignoreComments, - ignoreJsDoc: ignoreComments || this.ruleArguments.indexOf(OPTION_IGNORE_JSDOC) !== -1, - ignoreTemplates: this.ruleArguments.indexOf(OPTION_IGNORE_TEMPLATE_STRINGS) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-trailing-whitespace", - description: "Disallows trailing whitespace at the end of a line.", - rationale: "Keeps version control diffs clean as it prevents accidental whitespace from being committed.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Possible settings are:\n\n * `\"", "\"`: Allows trailing whitespace in template strings.\n * `\"", "\"`: Allows trailing whitespace in comments.\n * `\"", "\"`: Allows trailing whitespace only in JSDoc comments.\n * `\"", "\"`: Allows trailing whitespace on empty lines."], ["\n Possible settings are:\n\n * \\`\"", "\"\\`: Allows trailing whitespace in template strings.\n * \\`\"", "\"\\`: Allows trailing whitespace in comments.\n * \\`\"", "\"\\`: Allows trailing whitespace only in JSDoc comments.\n * \\`\"", "\"\\`: Allows trailing whitespace on empty lines."])), OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_BLANK_LINES), - hasFix: true, - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_BLANK_LINES], - }, - }, - optionExamples: [ - true, - [true, OPTION_IGNORE_COMMENTS], - [true, OPTION_IGNORE_JSDOC], - ], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "trailing whitespace"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var possibleFailures = []; - var sourceFile = ctx.sourceFile; - var text = sourceFile.text; - for (var _i = 0, _a = tsutils_1.getLineRanges(sourceFile); _i < _a.length; _i++) { - var line = _a[_i]; - // \s matches any whitespace character (equal to [\r\n\t\f\v ]) - var match = text.substr(line.pos, line.contentLength).match(/\s+$/); - if (match !== null && !(ctx.options.ignoreBlankLines && match.index === 0)) { - possibleFailures.push({ - end: line.pos + line.contentLength, - pos: line.pos + match.index, - }); - } - } - if (possibleFailures.length === 0) { - return; - } - var excludedRanges = ctx.options.ignoreTemplates - ? ctx.options.ignoreJsDoc ? getExcludedRanges(sourceFile, ctx.options) : noConsecutiveBlankLinesRule_1.getTemplateRanges(sourceFile) - : ctx.options.ignoreJsDoc ? getExcludedComments(sourceFile, ctx.options) : []; - var _loop_1 = function (possibleFailure) { - if (!excludedRanges.some(function (range) { return range.pos < possibleFailure.pos && possibleFailure.pos < range.end; })) { - ctx.addFailure(possibleFailure.pos, possibleFailure.end, Rule.FAILURE_STRING, Lint.Replacement.deleteFromTo(possibleFailure.pos, possibleFailure.end)); - } - }; - for (var _b = 0, possibleFailures_1 = possibleFailures; _b < possibleFailures_1.length; _b++) { - var possibleFailure = possibleFailures_1[_b]; - _loop_1(possibleFailure); - } -} -function getExcludedRanges(sourceFile, options) { - var intervals = []; - tsutils_1.forEachTokenWithTrivia(sourceFile, function (text, kind, range) { - if (kind >= ts.SyntaxKind.FirstTemplateToken && kind <= ts.SyntaxKind.LastTemplateToken) { - intervals.push(range); - } - else if (options.ignoreComments) { - if (kind === ts.SyntaxKind.SingleLineCommentTrivia || kind === ts.SyntaxKind.MultiLineCommentTrivia) { - intervals.push(range); - } - } - else if (options.ignoreJsDoc) { - if (isJsDoc(text, kind, range)) { - intervals.push(range); - } - } - }); - return intervals; -} -function getExcludedComments(sourceFile, options) { - var intervals = []; - tsutils_1.forEachComment(sourceFile, function (text, comment) { - if (options.ignoreComments || - options.ignoreJsDoc && isJsDoc(text, comment.kind, comment)) { - intervals.push(comment); - } - }); - return intervals; -} -function isJsDoc(sourceText, kind, range) { - return kind === ts.SyntaxKind.MultiLineCommentTrivia && sourceText[range.pos + 2] === "*" && sourceText[range.pos + 3] !== "*"; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noUnboundMethodRule.d.ts b/node_modules/tslint/lib/rules/noUnboundMethodRule.d.ts deleted file mode 100644 index 4df32174e..000000000 --- a/node_modules/tslint/lib/rules/noUnboundMethodRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnboundMethodRule.js b/node_modules/tslint/lib/rules/noUnboundMethodRule.js deleted file mode 100644 index d8085193a..000000000 --- a/node_modules/tslint/lib/rules/noUnboundMethodRule.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_IGNORE_STATIC = "ignore-static"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, { - ignoreStatic: this.ruleArguments.indexOf(OPTION_IGNORE_STATIC) !== -1, - }, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unbound-method", - description: "Warns when a method is used outside of a method call.", - optionsDescription: "You may optionally pass \"" + OPTION_IGNORE_STATIC + "\" to ignore static methods.", - options: { - type: "string", - enum: [OPTION_IGNORE_STATIC], - }, - optionExamples: [true, [true, OPTION_IGNORE_STATIC]], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Class functions don't preserve the class scope when passed as standalone variables.\n For example, this code will log the global scope (`window`/`global`), not the class instance:\n\n ```\n class MyClass {\n public log(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const log = instance.log;\n\n log();\n ```\n\n You need to either use an arrow lambda (`() => {...}`) or call the function with the correct scope.\n\n ```\n class MyClass {\n public logArrowBound = (): void => {\n console.log(bound);\n };\n\n public logManualBind(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const logArrowBound = instance.logArrowBound;\n const logManualBind = instance.logManualBind.bind(instance);\n\n logArrowBound();\n logManualBind();\n ```\n "], ["\n Class functions don't preserve the class scope when passed as standalone variables.\n For example, this code will log the global scope (\\`window\\`/\\`global\\`), not the class instance:\n\n \\`\\`\\`\n class MyClass {\n public log(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const log = instance.log;\n\n log();\n \\`\\`\\`\n\n You need to either use an arrow lambda (\\`() => {...}\\`) or call the function with the correct scope.\n\n \\`\\`\\`\n class MyClass {\n public logArrowBound = (): void => {\n console.log(bound);\n };\n\n public logManualBind(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const logArrowBound = instance.logArrowBound;\n const logManualBind = instance.logManualBind.bind(instance);\n\n logArrowBound();\n logManualBind();\n \\`\\`\\`\n "]))), - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Avoid referencing unbound methods which may cause unintentional scoping of 'this'."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isPropertyAccessExpression(node) && !isSafeUse(node)) { - var symbol = tc.getSymbolAtLocation(node); - var declaration = symbol === undefined ? undefined : symbol.valueDeclaration; - if (declaration !== undefined && isMethod(declaration, ctx.options.ignoreStatic)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - } - return ts.forEachChild(node, cb); - }); -} -function isMethod(node, ignoreStatic) { - switch (node.kind) { - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.MethodSignature: - return !(ignoreStatic && tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)); - default: - return false; - } -} -function isSafeUse(node) { - var parent = node.parent; - switch (parent.kind) { - case ts.SyntaxKind.CallExpression: - return parent.expression === node; - case ts.SyntaxKind.TaggedTemplateExpression: - return parent.tag === node; - // E.g. `obj.method.bind(obj) or obj.method["prop"]`. - case ts.SyntaxKind.PropertyAccessExpression: - case ts.SyntaxKind.ElementAccessExpression: - return true; - // Allow most binary operators, but don't allow e.g. `myArray.forEach(obj.method || otherObj.otherMethod)`. - case ts.SyntaxKind.BinaryExpression: - return parent.operatorToken.kind !== ts.SyntaxKind.BarBarToken; - case ts.SyntaxKind.NonNullExpression: - case ts.SyntaxKind.AsExpression: - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.ParenthesizedExpression: - return isSafeUse(parent); - // Allow use in conditions - case ts.SyntaxKind.ConditionalExpression: - return parent.condition === node; - case ts.SyntaxKind.IfStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.PrefixUnaryExpression: - return true; - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noUnnecessaryCallbackWrapperRule.d.ts b/node_modules/tslint/lib/rules/noUnnecessaryCallbackWrapperRule.d.ts deleted file mode 100644 index 00469f0ca..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryCallbackWrapperRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(cbText: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnnecessaryCallbackWrapperRule.js b/node_modules/tslint/lib/rules/noUnnecessaryCallbackWrapperRule.js deleted file mode 100644 index ecc2337ed..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryCallbackWrapperRule.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (cbText) { - return "No need to wrap '" + cbText + "' in another function. Just use it directly."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unnecessary-callback-wrapper", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Replaces `x => f(x)` with just `f`.\n To catch more cases, enable `only-arrow-functions` and `arrow-return-shorthand` too."], ["\n Replaces \\`x => f(x)\\` with just \\`f\\`.\n To catch more cases, enable \\`only-arrow-functions\\` and \\`arrow-return-shorthand\\` too."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n There's generally no reason to wrap a function with a callback wrapper if it's directly called anyway.\n Doing so creates extra inline lambdas that slow the runtime down.\n "], ["\n There's generally no reason to wrap a function with a callback wrapper if it's directly called anyway.\n Doing so creates extra inline lambdas that slow the runtime down.\n "]))), - type: "style", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, cb); - function cb(node) { - if (tsutils_1.isArrowFunction(node) && !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) && - tsutils_1.isCallExpression(node.body) && tsutils_1.isIdentifier(node.body.expression) && - isRedundantCallback(node.parameters, node.body.arguments, node.body.expression)) { - var start = node.getStart(ctx.sourceFile); - ctx.addFailure(start, node.end, Rule.FAILURE_STRING(node.body.expression.text), [ - Lint.Replacement.deleteFromTo(start, node.body.getStart(ctx.sourceFile)), - Lint.Replacement.deleteFromTo(node.body.expression.end, node.end), - ]); - } - else { - return ts.forEachChild(node, cb); - } - } -} -function isRedundantCallback(parameters, args, expression) { - if (parameters.length !== args.length) { - return false; - } - for (var i = 0; i < parameters.length; ++i) { - var _a = parameters[i], dotDotDotToken = _a.dotDotDotToken, name = _a.name; - var arg = args[i]; - if (dotDotDotToken !== undefined) { - if (!tsutils_1.isSpreadElement(arg)) { - return false; - } - arg = arg.expression; - } - if (!tsutils_1.isIdentifier(name) || !tsutils_1.isIdentifier(arg) || name.text !== arg.text - // If the invoked expression is one of the parameters, bail. - || expression.text === name.text) { - return false; - } - } - return true; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts b/node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts deleted file mode 100644 index afaa33e43..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_CONSTRUCTOR_ONLY: string; - static FAILURE_STATIC_ONLY: string; - static FAILURE_EMPTY_CLASS: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnnecessaryClassRule.js b/node_modules/tslint/lib/rules/noUnnecessaryClassRule.js deleted file mode 100644 index 950dbda43..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryClassRule.js +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var tsutils_1 = require("tsutils"); -var OPTION__ALLOW_CONSTRUCTOR_ONLY = "allow-constructor-only"; -var OPTION__ALLOW_EMPTY_CLASS = "allow-empty-class"; -var OPTION__ALLOW_STATIC_ONLY = "allow-static-only"; -function parseOptions(options) { - return { - allowConstructorOnly: options.indexOf(OPTION__ALLOW_CONSTRUCTOR_ONLY) !== -1, - allowEmptyClass: options.indexOf(OPTION__ALLOW_EMPTY_CLASS) !== -1, - allowStaticOnly: options.indexOf(OPTION__ALLOW_STATIC_ONLY) !== -1, - }; -} -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new NoUnnecessaryClassWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments))); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unnecessary-class", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows classes that are not strictly necessary."], ["\n Disallows classes that are not strictly necessary."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Users who come from a Java-style OO language may wrap\n their utility functions in an extra class, instead of\n putting them at the top level."], ["\n Users who come from a Java-style OO language may wrap\n their utility functions in an extra class, instead of\n putting them at the top level."]))), - optionsDescription: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n Three arguments may be optionally provided:\n\n * `\"allow-constructor-only\"` ignores classes whose members are constructors.\n * `\"allow-empty-class\"` ignores `class DemoClass {}`.\n * `\"allow-static-only\"` ignores classes whose members are static."], ["\n Three arguments may be optionally provided:\n\n * \\`\"allow-constructor-only\"\\` ignores classes whose members are constructors.\n * \\`\"allow-empty-class\"\\` ignores \\`class DemoClass {}\\`.\n * \\`\"allow-static-only\"\\` ignores classes whose members are static."]))), - options: { - type: "array", - items: { - type: "string", - }, - minLength: 0, - maxLength: 3, - }, - optionExamples: [true, ["allow-empty-class", "allow-constructor-only"]], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_CONSTRUCTOR_ONLY = "Every member of this class is a constructor. Use functions instead."; - Rule.FAILURE_STATIC_ONLY = "Every member of this class is static. Use namespaces or plain objects instead."; - Rule.FAILURE_EMPTY_CLASS = "This class has no members."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var NoUnnecessaryClassWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoUnnecessaryClassWalker, _super); - function NoUnnecessaryClassWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoUnnecessaryClassWalker.prototype.walk = function (sourceFile) { - var _this = this; - var checkIfUnnecessaryClass = function (node) { - if (tsutils_1.isClassDeclaration(node) && !hasExtendsClause(node)) { - _this.checkMembers(node); - } - return ts.forEachChild(node, checkIfUnnecessaryClass); - }; - ts.forEachChild(sourceFile, checkIfUnnecessaryClass); - }; - NoUnnecessaryClassWalker.prototype.checkMembers = function (node) { - if (node.members.length === 0) { - if (!this.options.allowEmptyClass) { - this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ClassKeyword), Rule.FAILURE_EMPTY_CLASS); - } - return; - } - var allMembersAreConstructors = node.members.every(tsutils_1.isConstructorDeclaration); - if (allMembersAreConstructors && - !this.options.allowConstructorOnly && - !node.members.some(isConstructorWithShorthandProps)) { - this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ClassKeyword, this.sourceFile), Rule.FAILURE_CONSTRUCTOR_ONLY); - } - if (!allMembersAreConstructors && - !this.options.allowStaticOnly && - !node.members.some(isNonStaticMember)) { - this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ClassKeyword, this.sourceFile), Rule.FAILURE_STATIC_ONLY); - } - }; - return NoUnnecessaryClassWalker; -}(Lint.AbstractWalker)); -function isNonStaticMember(member) { - return (isConstructorWithShorthandProps(member) || - (!tsutils_1.isConstructorDeclaration(member) && !tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.StaticKeyword))); -} -function hasExtendsClause(declaration) { - return (declaration.heritageClauses !== undefined && - declaration.heritageClauses[0].token === ts.SyntaxKind.ExtendsKeyword); -} -function isConstructorWithShorthandProps(member) { - return tsutils_1.isConstructorDeclaration(member) && member.parameters.some(tsutils_1.isParameterProperty); -} -var templateObject_1, templateObject_2, templateObject_3; diff --git a/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.d.ts b/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.d.ts deleted file mode 100644 index 05f0e2842..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static FAILURE_STRING_PARAMETER: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.js b/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.js deleted file mode 100644 index 110938857..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryInitializerRule.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unnecessary-initializer", - description: "Forbids a 'var'/'let' statement or destructuring initializer to be initialized to 'undefined'.", - hasFix: true, - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Values in JavaScript default to `undefined`.\n There's no need to do so manually.\n "], ["\n Values in JavaScript default to \\`undefined\\`.\n There's no need to do so manually.\n "]))), - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Unnecessary initialization to 'undefined'."; - Rule.FAILURE_STRING_PARAMETER = "Use an optional parameter instead of initializing to 'undefined'. " + - "Also, the type declaration does not need to include '| undefined'."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - ts.forEachChild(ctx.sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.BindingElement: - checkInitializer(node); - break; - case ts.SyntaxKind.VariableDeclaration: - if (!tsutils_1.isBindingPattern(node.name) && !tsutils_1.isNodeFlagSet(node.parent, ts.NodeFlags.Const)) { - checkInitializer(node); - } - break; - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.Constructor: { - var parameters_1 = node.parameters; - parameters_1.forEach(function (parameter, i) { - if (isUndefined(parameter.initializer)) { - if (parametersAllOptionalAfter(parameters_1, i)) { - // No fix since they may want to remove '| undefined' from the type. - ctx.addFailureAtNode(parameter, Rule.FAILURE_STRING_PARAMETER); - } - else { - failWithFix(parameter); - } - } - }); - } - } - ts.forEachChild(node, cb); - }); - function checkInitializer(node) { - if (isUndefined(node.initializer)) { - failWithFix(node); - } - } - function failWithFix(node) { - var fix = Lint.Replacement.deleteFromTo(tsutils_1.getChildOfKind(node, ts.SyntaxKind.EqualsToken).pos, node.end); - ctx.addFailureAtNode(node, Rule.FAILURE_STRING, fix); - } -} -function parametersAllOptionalAfter(parameters, idx) { - for (var i = idx + 1; i < parameters.length; i++) { - if (parameters[i].questionToken !== undefined) { - return true; - } - if (parameters[i].initializer === undefined) { - return false; - } - } - return true; -} -function isUndefined(node) { - return node !== undefined && - node.kind === ts.SyntaxKind.Identifier && - node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.d.ts b/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.d.ts deleted file mode 100644 index a6143341f..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string): string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js b/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js deleted file mode 100644 index 2c89620b7..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name) { - return "Qualifier is unnecessary since '" + name + "' is in scope."; - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unnecessary-qualifier", - description: "Warns when a namespace qualifier (`A.x`) is unnecessary.", - hasFix: true, - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - requiresTypeInfo: true, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - var namespacesInScope = []; - ts.forEachChild(ctx.sourceFile, cb); - function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ModuleDeclaration: - case ts.SyntaxKind.EnumDeclaration: - namespacesInScope.push(node); - ts.forEachChild(node, cb); - namespacesInScope.pop(); - break; - case ts.SyntaxKind.QualifiedName: - var _a = node, left = _a.left, right = _a.right; - visitNamespaceAccess(node, left, right); - break; - case ts.SyntaxKind.PropertyAccessExpression: - var _b = node, expression = _b.expression, name = _b.name; - if (utils.isEntityNameExpression(expression)) { - visitNamespaceAccess(node, expression, name); - break; - } - // falls through - default: - ts.forEachChild(node, cb); - } - } - function visitNamespaceAccess(node, qualifier, name) { - if (qualifierIsUnnecessary(qualifier, name)) { - var fix = Lint.Replacement.deleteFromTo(qualifier.getStart(), name.getStart()); - ctx.addFailureAtNode(qualifier, Rule.FAILURE_STRING(qualifier.getText()), fix); - } - else { - // Only look for nested qualifier errors if we didn't already fail on the outer qualifier. - ts.forEachChild(node, cb); - } - } - function qualifierIsUnnecessary(qualifier, name) { - var namespaceSymbol = checker.getSymbolAtLocation(qualifier); - if (namespaceSymbol === undefined || !symbolIsNamespaceInScope(namespaceSymbol)) { - return false; - } - var accessedSymbol = checker.getSymbolAtLocation(name); - if (accessedSymbol === undefined) { - return false; - } - // If the symbol in scope is different, the qualifier is necessary. - var fromScope = getSymbolInScope(qualifier, accessedSymbol.flags, name.text); - return fromScope === undefined || symbolsAreEqual(accessedSymbol, fromScope); - } - function getSymbolInScope(node, flags, name) { - // TODO:PERF `getSymbolsInScope` gets a long list. Is there a better way? - var scope = checker.getSymbolsInScope(node, flags); - return scope.find(function (scopeSymbol) { return scopeSymbol.name === name; }); - } - function symbolIsNamespaceInScope(symbol) { - var symbolDeclarations = symbol.getDeclarations(); - if (symbolDeclarations === undefined) { - return false; - } - else if (symbolDeclarations.some(function (decl) { return namespacesInScope.some(function (ns) { return ns === decl; }); })) { - return true; - } - var alias = tryGetAliasedSymbol(symbol, checker); - return alias !== undefined && symbolIsNamespaceInScope(alias); - } - function symbolsAreEqual(accessed, inScope) { - if (checker.getExportSymbolOfSymbol !== undefined) { - inScope = checker.getExportSymbolOfSymbol(inScope); - return accessed === inScope; - } - return accessed === inScope || - // For compatibility with typescript@2.5: compare declarations because the symbols don't have the same reference - Lint.Utils.arraysAreEqual(accessed.declarations, inScope.declarations, function (a, b) { return a === b; }); - } -} -function tryGetAliasedSymbol(symbol, checker) { - return utils.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias) ? checker.getAliasedSymbol(symbol) : undefined; -} diff --git a/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.d.ts b/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.d.ts deleted file mode 100644 index 8b31e4da7..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js b/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js deleted file mode 100644 index ca3a278e0..000000000 --- a/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithWalker(new Walker(sourceFile, this.ruleName, this.ruleArguments, program.getTypeChecker())); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unnecessary-type-assertion", - description: "Warns if a type assertion does not change the type of an expression.", - options: { - type: "list", - listType: { - type: "array", - items: { type: "string" }, - }, - }, - optionsDescription: "A list of whitelisted assertion types to ignore", - type: "typescript", - hasFix: true, - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "This assertion is unnecessary since it does not change the type of the expression."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -var Walker = /** @class */ (function (_super) { - tslib_1.__extends(Walker, _super); - function Walker(sourceFile, ruleName, options, checker) { - var _this = _super.call(this, sourceFile, ruleName, options) || this; - _this.checker = checker; - return _this; - } - Walker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - switch (node.kind) { - case ts.SyntaxKind.NonNullExpression: - _this.checkNonNullAssertion(node); - break; - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.AsExpression: - _this.verifyCast(node); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - Walker.prototype.checkNonNullAssertion = function (node) { - var type = this.checker.getTypeAtLocation(node.expression); - if (type === this.checker.getNonNullableType(type)) { - this.addFailureAtNode(node, Rule.FAILURE_STRING, Lint.Replacement.deleteFromTo(node.expression.end, node.end)); - } - }; - Walker.prototype.verifyCast = function (node) { - if (this.options.indexOf(node.type.getText(this.sourceFile)) !== -1) { - return; - } - var castType = this.checker.getTypeAtLocation(node); - if (tsutils_1.isTypeFlagSet(castType, ts.TypeFlags.Literal) || - tsutils_1.isObjectType(castType) && (tsutils_1.isObjectFlagSet(castType, ts.ObjectFlags.Tuple) || couldBeTupleType(castType))) { - // It's not always safe to remove a cast to a literal type or tuple - // type, as those types are sometimes widened without the cast. - return; - } - var uncastType = this.checker.getTypeAtLocation(node.expression); - if (uncastType === castType) { - this.addFailureAtNode(node, Rule.FAILURE_STRING, node.kind === ts.SyntaxKind.TypeAssertionExpression - ? Lint.Replacement.deleteFromTo(node.getStart(), node.expression.getStart()) - : Lint.Replacement.deleteFromTo(node.expression.end, node.end)); - } - }; - return Walker; -}(Lint.AbstractWalker)); -/** - * Sometimes tuple types don't have ObjectFlags.Tuple set, like when they're being matched against an inferred type. - * So, in addition, check if there are integer properties 0..n and no other numeric keys - */ -function couldBeTupleType(type) { - var properties = type.getProperties(); - if (properties.length === 0) { - return false; - } - var i = 0; - for (; i < properties.length; ++i) { - var name = properties[i].name; - if (String(i) !== name) { - if (i === 0) { - // if there are no integer properties, this is not a tuple - return false; - } - break; - } - } - for (; i < properties.length; ++i) { - if (String(+properties[i].name) === properties[i].name) { - return false; // if there are any other numeric properties, this is not a tuple - } - } - return true; -} diff --git a/node_modules/tslint/lib/rules/noUnsafeAnyRule.d.ts b/node_modules/tslint/lib/rules/noUnsafeAnyRule.d.ts deleted file mode 100644 index 4df32174e..000000000 --- a/node_modules/tslint/lib/rules/noUnsafeAnyRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnsafeAnyRule.js b/node_modules/tslint/lib/rules/noUnsafeAnyRule.js deleted file mode 100644 index 301b55b48..000000000 --- a/node_modules/tslint/lib/rules/noUnsafeAnyRule.js +++ /dev/null @@ -1,408 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithWalker(new NoUnsafeAnyWalker(sourceFile, this.ruleName, program.getTypeChecker())); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unsafe-any", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Warns when using an expression of type 'any' in a dynamic way.\n Uses are only allowed if they would work for `{} | null | undefined`.\n Type casts and tests are allowed.\n Expressions that work on all values (such as `\"\" + x`) are allowed."], ["\n Warns when using an expression of type 'any' in a dynamic way.\n Uses are only allowed if they would work for \\`{} | null | undefined\\`.\n Type casts and tests are allowed.\n Expressions that work on all values (such as \\`\"\" + x\\`) are allowed."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type `{}`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use `<T>` template types for generic type handling.\n\n Also see the `no-any` rule.\n "], ["\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type \\`{}\\`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use \\`<T>\\` template types for generic type handling.\n\n Also see the \\`no-any\\` rule.\n "]))), - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Unsafe use of expression of type 'any'."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -var NoUnsafeAnyWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoUnsafeAnyWalker, _super); - function NoUnsafeAnyWalker(sourceFile, ruleName, checker) { - var _this = _super.call(this, sourceFile, ruleName, undefined) || this; - _this.checker = checker; - /** Wraps `visitNode` with the correct `this` binding and discards the return value to prevent `forEachChild` from returning early */ - _this.visitNodeCallback = function (node) { return void _this.visitNode(node); }; - return _this; - } - NoUnsafeAnyWalker.prototype.walk = function (sourceFile) { - if (sourceFile.isDeclarationFile) { - return; // Not possible in a declaration file. - } - sourceFile.statements.forEach(this.visitNodeCallback); - }; - NoUnsafeAnyWalker.prototype.visitNode = function (node, anyOk) { - switch (node.kind) { - case ts.SyntaxKind.ParenthesizedExpression: - // Don't warn on a parenthesized expression, warn on its contents. - return this.visitNode(node.expression, anyOk); - case ts.SyntaxKind.LabeledStatement: - // Ignore label - return this.visitNode(node.statement); - // ignore labels - case ts.SyntaxKind.BreakStatement: - case ts.SyntaxKind.ContinueStatement: - // Ignore types - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeAliasDeclaration: - case ts.SyntaxKind.TypeParameter: - case ts.SyntaxKind.IndexSignature: - // Ignore imports - case ts.SyntaxKind.ImportEqualsDeclaration: - case ts.SyntaxKind.ImportDeclaration: - case ts.SyntaxKind.ExportDeclaration: - case ts.SyntaxKind.ExportAssignment: - return false; - case ts.SyntaxKind.ThisKeyword: - case ts.SyntaxKind.Identifier: - return anyOk ? false : this.check(node); - // Recurse through these, but ignore the immediate child because it is allowed to be 'any'. - case ts.SyntaxKind.DeleteExpression: - case ts.SyntaxKind.ExpressionStatement: - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.AsExpression: - case ts.SyntaxKind.TemplateSpan: // Allow stringification (works on all values). Note: tagged templates handled differently. - case ts.SyntaxKind.ThrowStatement: - case ts.SyntaxKind.TypeOfExpression: - case ts.SyntaxKind.VoidExpression: - return this.visitNode(node.expression, true); - case ts.SyntaxKind.PropertyAssignment: { - var _a = node, name = _a.name, initializer = _a.initializer; - this.visitNode(name, /*anyOk*/ true); - if (tsutils_1.isReassignmentTarget(node.parent)) { - return this.visitNode(initializer, true); - } - return this.checkContextualType(initializer, true); - } - case ts.SyntaxKind.ShorthandPropertyAssignment: { - var _b = node, name = _b.name, objectAssignmentInitializer = _b.objectAssignmentInitializer; - if (objectAssignmentInitializer !== undefined) { - return this.checkContextualType(objectAssignmentInitializer); - } - return this.checkContextualType(name, true); - } - case ts.SyntaxKind.PropertyDeclaration: { - var _c = node, name = _c.name, initializer = _c.initializer; - this.visitNode(name, true); - return initializer !== undefined && - this.visitNode(initializer, isPropertyAny(node, this.checker)); - } - case ts.SyntaxKind.SpreadAssignment: - return this.visitNode(node.expression, - // allow any in object spread, but not in object rest - !tsutils_1.isReassignmentTarget(node.parent)); - case ts.SyntaxKind.ComputedPropertyName: - return this.visitNode(node.expression, true); - case ts.SyntaxKind.TaggedTemplateExpression: { - var _d = node, tag = _d.tag, template = _d.template; - if (template.kind === ts.SyntaxKind.TemplateExpression) { - for (var _i = 0, _e = template.templateSpans; _i < _e.length; _i++) { - var expression = _e[_i].expression; - this.checkContextualType(expression); - } - } - // Also check the template expression itself - if (this.visitNode(tag)) { - return true; - } - return anyOk ? false : this.check(node); - } - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.NewExpression: { - var _f = node, expression = _f.expression, args = _f.arguments; - if (args !== undefined) { - for (var _g = 0, args_1 = args; _g < args_1.length; _g++) { - var arg = args_1[_g]; - this.checkContextualType(arg); - } - } - if (this.visitNode(expression)) { - return true; - } - // Also check the call expression itself - return anyOk ? false : this.check(node); - } - case ts.SyntaxKind.PropertyAccessExpression: - // Don't warn for right hand side; this is redundant if we warn for the access itself. - if (this.visitNode(node.expression)) { - return true; - } - return anyOk ? false : this.check(node); - case ts.SyntaxKind.ElementAccessExpression: { - var _h = node, expression = _h.expression, argumentExpression = _h.argumentExpression; - if (argumentExpression !== undefined) { - this.visitNode(argumentExpression, true); - } - if (this.visitNode(expression)) { - return true; - } - return anyOk ? false : this.check(node); - } - case ts.SyntaxKind.ReturnStatement: { - var expression = node.expression; - return expression !== undefined && this.checkContextualType(expression, true); - } - case ts.SyntaxKind.SwitchStatement: { - var _j = node, expression = _j.expression, clauses = _j.caseBlock.clauses; - // Allow `switch (x) {}` where `x` is any - this.visitNode(expression, /*anyOk*/ true); - for (var _k = 0, clauses_1 = clauses; _k < clauses_1.length; _k++) { - var clause = clauses_1[_k]; - if (clause.kind === ts.SyntaxKind.CaseClause) { - // Allow `case x:` where `x` is any - this.visitNode(clause.expression, /*anyOk*/ true); - } - for (var _l = 0, _m = clause.statements; _l < _m.length; _l++) { - var statement = _m[_l]; - this.visitNode(statement); - } - } - return false; - } - case ts.SyntaxKind.ModuleDeclaration: { - // In `declare global { ... }`, don't mark `global` as unsafe any. - var body = node.body; - return body !== undefined && this.visitNode(body); - } - case ts.SyntaxKind.IfStatement: { - var _o = node, expression = _o.expression, thenStatement = _o.thenStatement, elseStatement = _o.elseStatement; - this.visitNode(expression, true); // allow truthyness check - this.visitNode(thenStatement); - return elseStatement !== undefined && this.visitNode(elseStatement); - } - case ts.SyntaxKind.PrefixUnaryExpression: { - var _p = node, operator = _p.operator, operand = _p.operand; - this.visitNode(operand, operator === ts.SyntaxKind.ExclamationToken); // allow falsyness check - return false; - } - case ts.SyntaxKind.ForStatement: { - var _q = node, initializer = _q.initializer, condition = _q.condition, incrementor = _q.incrementor, statement = _q.statement; - if (initializer !== undefined) { - this.visitNode(initializer, true); - } - if (condition !== undefined) { - this.visitNode(condition, true); - } // allow truthyness check - if (incrementor !== undefined) { - this.visitNode(incrementor, true); - } - return this.visitNode(statement); - } - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.WhileStatement: - this.visitNode(node.expression, true); - return this.visitNode(node.statement); - case ts.SyntaxKind.ConditionalExpression: { - var _r = node, condition = _r.condition, whenTrue = _r.whenTrue, whenFalse = _r.whenFalse; - this.visitNode(condition, true); - var left = this.visitNode(whenTrue, anyOk); - return this.visitNode(whenFalse, anyOk) || left; - } - case ts.SyntaxKind.VariableDeclaration: - case ts.SyntaxKind.Parameter: - return this.checkVariableOrParameterDeclaration(node); - case ts.SyntaxKind.BinaryExpression: - return this.checkBinaryExpression(node, anyOk); - case ts.SyntaxKind.AwaitExpression: - this.visitNode(node.expression); - return anyOk ? false : this.check(node); - case ts.SyntaxKind.YieldExpression: - return this.checkYieldExpression(node, anyOk); - case ts.SyntaxKind.ClassExpression: - case ts.SyntaxKind.ClassDeclaration: - this.checkClassLikeDeclaration(node); - return false; - case ts.SyntaxKind.ArrayLiteralExpression: { - for (var _s = 0, _t = node.elements; _s < _t.length; _s++) { - var element = _t[_s]; - this.checkContextualType(element, true); - } - return false; - } - case ts.SyntaxKind.JsxExpression: - return node.expression !== undefined && - this.checkContextualType(node.expression); - } - if (tsutils_1.isTypeNodeKind(node.kind) || tsutils_1.isTokenKind(node.kind)) { - return false; - } - return ts.forEachChild(node, this.visitNodeCallback); - }; - NoUnsafeAnyWalker.prototype.check = function (node) { - if (!isNodeAny(node, this.checker)) { - return false; - } - this.addFailureAtNode(node, Rule.FAILURE_STRING); - return true; - }; - NoUnsafeAnyWalker.prototype.checkContextualType = function (node, allowIfNoContextualType) { - var type = this.checker.getContextualType(node); - return this.visitNode(node, type === undefined && allowIfNoContextualType || isAny(type)); - }; - // Allow `const x = foo;` and `const x: any = foo`, but not `const x: Foo = foo;`. - NoUnsafeAnyWalker.prototype.checkVariableOrParameterDeclaration = function (_a) { - var name = _a.name, type = _a.type, initializer = _a.initializer; - this.checkBindingName(name); - // Always allow the LHS to be `any`. Just don't allow RHS to be `any` when LHS isn't. - return initializer !== undefined && - this.visitNode(initializer, - /*anyOk*/ - name.kind === ts.SyntaxKind.Identifier && (type === undefined || type.kind === ts.SyntaxKind.AnyKeyword) || - type !== undefined && type.kind === ts.SyntaxKind.AnyKeyword); - }; - NoUnsafeAnyWalker.prototype.checkBinaryExpression = function (node, anyOk) { - var allowAnyLeft = false; - var allowAnyRight = false; - switch (node.operatorToken.kind) { - case ts.SyntaxKind.ExclamationEqualsEqualsToken: - case ts.SyntaxKind.ExclamationEqualsToken: - case ts.SyntaxKind.EqualsEqualsEqualsToken: - case ts.SyntaxKind.EqualsEqualsToken: - case ts.SyntaxKind.CommaToken: // Allow `any, any` - case ts.SyntaxKind.BarBarToken: // Allow `any || any` - case ts.SyntaxKind.AmpersandAmpersandToken: // Allow `any && any` - allowAnyLeft = allowAnyRight = true; - break; - case ts.SyntaxKind.InstanceOfKeyword: // Allow test - allowAnyLeft = true; - break; - case ts.SyntaxKind.EqualsToken: - // Allow assignment if the lhs is also *any*. - allowAnyLeft = true; - allowAnyRight = isNodeAny(node.left, this.checker); - break; - case ts.SyntaxKind.PlusToken: // Allow implicit stringification - case ts.SyntaxKind.PlusEqualsToken: - allowAnyLeft = allowAnyRight = isStringLike(node.left, this.checker) - || (isStringLike(node.right, this.checker) && node.operatorToken.kind === ts.SyntaxKind.PlusToken); - } - this.visitNode(node.left, allowAnyLeft); - this.visitNode(node.right, allowAnyRight); - return anyOk ? false : this.check(node); - }; - NoUnsafeAnyWalker.prototype.checkYieldExpression = function (node, anyOk) { - if (node.expression !== undefined) { - this.checkContextualType(node.expression, true); - } - if (anyOk) { - return false; - } - this.addFailureAtNode(node, Rule.FAILURE_STRING); - return true; - }; - NoUnsafeAnyWalker.prototype.checkClassLikeDeclaration = function (node) { - if (node.decorators !== undefined) { - node.decorators.forEach(this.visitNodeCallback); - } - if (node.heritageClauses !== undefined) { - node.heritageClauses.forEach(this.visitNodeCallback); - } - return node.members.forEach(this.visitNodeCallback); - }; - NoUnsafeAnyWalker.prototype.checkBindingName = function (node) { - if (node.kind !== ts.SyntaxKind.Identifier) { - if (isNodeAny(node, this.checker)) { - this.addFailureAtNode(node, Rule.FAILURE_STRING); - } - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind !== ts.SyntaxKind.OmittedExpression) { - if (element.propertyName !== undefined && element.propertyName.kind === ts.SyntaxKind.ComputedPropertyName) { - this.visitNode(element.propertyName.expression); - } - this.checkBindingName(element.name); - if (element.initializer !== undefined) { - this.checkContextualType(element.initializer); - } - } - } - } - }; - return NoUnsafeAnyWalker; -}(Lint.AbstractWalker)); -/** Check if property has no type annotation in this class and the base class */ -function isPropertyAny(node, checker) { - if (!isNodeAny(node.name, checker) || node.name.kind === ts.SyntaxKind.ComputedPropertyName) { - return false; - } - for (var _i = 0, _a = checker.getBaseTypes(checker.getTypeAtLocation(node.parent)); _i < _a.length; _i++) { - var base = _a[_i]; - var prop = base.getProperty(node.name.text); - if (prop !== undefined && prop.declarations !== undefined) { - return isAny(checker.getTypeOfSymbolAtLocation(prop, prop.declarations[0])); - } - } - return true; -} -function isNodeAny(node, checker) { - var symbol = checker.getSymbolAtLocation(node); - if (symbol !== undefined && tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) { - symbol = checker.getAliasedSymbol(symbol); - } - if (symbol !== undefined) { - // NamespaceModule is a type-only namespace without runtime value, its type is 'any' when used as 'ns.Type' -> avoid error - if (tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.NamespaceModule)) { - return false; - } - if (tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Type)) { - return isAny(checker.getDeclaredTypeOfSymbol(symbol)); - } - } - // Lowercase JSX elements are assumed to be allowed by design - if (isJsxNativeElement(node)) { - return false; - } - return isAny(checker.getTypeAtLocation(node)); -} -var jsxElementTypes = new Set([ - ts.SyntaxKind.JsxClosingElement, - ts.SyntaxKind.JsxOpeningElement, - ts.SyntaxKind.JsxSelfClosingElement, -]); -function isJsxNativeElement(node) { - if (!tsutils_1.isIdentifier(node) || node.parent === undefined) { - return false; - } - // TypeScript <=2.1 incorrectly parses JSX fragments - if (node.text === "") { - return true; - } - return jsxElementTypes.has(node.parent.kind) && utils_1.isLowerCase(node.text[0]); -} -function isStringLike(expr, checker) { - return tsutils_1.isTypeFlagSet(checker.getTypeAtLocation(expr), ts.TypeFlags.StringLike); -} -function isAny(type) { - return type !== undefined && tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Any); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noUnsafeFinallyRule.d.ts b/node_modules/tslint/lib/rules/noUnsafeFinallyRule.d.ts deleted file mode 100644 index 760aa26c0..000000000 --- a/node_modules/tslint/lib/rules/noUnsafeFinallyRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnsafeFinallyRule.js b/node_modules/tslint/lib/rules/noUnsafeFinallyRule.js deleted file mode 100644 index 7fae6d742..000000000 --- a/node_modules/tslint/lib/rules/noUnsafeFinallyRule.js +++ /dev/null @@ -1,136 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name) { - return "'" + name + "' statements in finally blocks are forbidden."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unsafe-finally", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows control flow statements, such as `return`, `continue`,\n `break` and `throws` in finally blocks."], ["\n Disallows control flow statements, such as \\`return\\`, \\`continue\\`,\n \\`break\\` and \\`throws\\` in finally blocks."]))), - descriptionDetails: "", - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n When used inside `finally` blocks, control flow statements,\n such as `return`, `continue`, `break` and `throws`\n override any other control flow statements in the same try/catch scope.\n This is confusing and unexpected behavior."], ["\n When used inside \\`finally\\` blocks, control flow statements,\n such as \\`return\\`, \\`continue\\`, \\`break\\` and \\`throws\\`\n override any other control flow statements in the same try/catch scope.\n This is confusing and unexpected behavior."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var inFinally = false; - ts.forEachChild(ctx.sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.TryStatement: - var _a = node, tryBlock = _a.tryBlock, catchClause = _a.catchClause, finallyBlock = _a.finallyBlock; - ts.forEachChild(tryBlock, cb); - if (catchClause !== undefined) { - ts.forEachChild(catchClause, cb); - } - if (finallyBlock !== undefined) { - var old = inFinally; - inFinally = true; - cb(finallyBlock); - inFinally = old; - } - break; - case ts.SyntaxKind.BreakStatement: - case ts.SyntaxKind.ContinueStatement: - case ts.SyntaxKind.ThrowStatement: - case ts.SyntaxKind.ReturnStatement: - if (inFinally && !jumpIsLocalToFinallyBlock(node)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING(printJumpKind(node))); - } - // falls through - default: - return ts.forEachChild(node, cb); - } - }); -} -function jumpIsLocalToFinallyBlock(jump) { - var isBreakOrContinue = utils.isBreakOrContinueStatement(jump); - var label = isBreakOrContinue ? jump.label : undefined; - var node = jump; - // This should only be called inside a finally block, so we'll eventually reach the TryStatement case and return. - while (true) { - var parent = node.parent; - switch (parent.kind) { - case ts.SyntaxKind.TryStatement: - if (parent.finallyBlock === node) { - return false; - } - break; - case ts.SyntaxKind.SwitchStatement: - if (jump.kind === ts.SyntaxKind.BreakStatement && label === undefined) { - return true; - } - break; - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.ForOfStatement: - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: - if (isBreakOrContinue && label === undefined) { - return true; - } - break; - case ts.SyntaxKind.LabeledStatement: { - var text = parent.label.text; - if (label !== undefined && label.text === text) { - return true; - } - break; - } - default: - if (utils.isFunctionScopeBoundary(parent)) { - // Haven't seen TryStatement yet, so the function is inside it. - // No jump statement can escape a function, so the jump is local. - return true; - } - } - node = parent; - } -} -function printJumpKind(node) { - switch (node.kind) { - case ts.SyntaxKind.BreakStatement: - return "break"; - case ts.SyntaxKind.ContinueStatement: - return "continue"; - case ts.SyntaxKind.ThrowStatement: - return "throw"; - case ts.SyntaxKind.ReturnStatement: - return "return"; - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noUnusedExpressionRule.d.ts b/node_modules/tslint/lib/rules/noUnusedExpressionRule.d.ts deleted file mode 100644 index cb4dfbb50..000000000 --- a/node_modules/tslint/lib/rules/noUnusedExpressionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnusedExpressionRule.js b/node_modules/tslint/lib/rules/noUnusedExpressionRule.js deleted file mode 100644 index 6e3794a53..000000000 --- a/node_modules/tslint/lib/rules/noUnusedExpressionRule.js +++ /dev/null @@ -1,214 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var ALLOW_FAST_NULL_CHECKS = "allow-fast-null-checks"; -var ALLOW_NEW = "allow-new"; -var ALLOW_TAGGED_TEMPLATE = "allow-tagged-template"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - allowFastNullChecks: this.ruleArguments.indexOf(ALLOW_FAST_NULL_CHECKS) !== -1, - allowNew: this.ruleArguments.indexOf(ALLOW_NEW) !== -1, - allowTaggedTemplate: this.ruleArguments.indexOf(ALLOW_TAGGED_TEMPLATE) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unused-expression", - description: "Disallows unused expression statements.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Unused expressions are expression statements which are not assignments or function calls\n (and thus usually no-ops)."], ["\n Unused expressions are expression statements which are not assignments or function calls\n (and thus usually no-ops)."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Detects potential errors where an assignment or function call was intended."], ["\n Detects potential errors where an assignment or function call was intended."]))), - optionsDescription: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n Two arguments may be optionally provided:\n\n * `", "` allows to use logical operators to perform fast null checks and perform\n method or function calls for side effects (e.g. `e && e.preventDefault()`).\n * `", "` allows 'new' expressions for side effects (e.g. `new ModifyGlobalState();`.\n * `", "` allows tagged templates for side effects (e.g. `this.add\\`foo\\`;`."], ["\n Two arguments may be optionally provided:\n\n * \\`", "\\` allows to use logical operators to perform fast null checks and perform\n method or function calls for side effects (e.g. \\`e && e.preventDefault()\\`).\n * \\`", "\\` allows 'new' expressions for side effects (e.g. \\`new ModifyGlobalState();\\`.\n * \\`", "\\` allows tagged templates for side effects (e.g. \\`this.add\\\\\\`foo\\\\\\`;\\`."])), ALLOW_FAST_NULL_CHECKS, ALLOW_NEW, ALLOW_TAGGED_TEMPLATE), - options: { - type: "array", - items: { - type: "string", - enum: [ALLOW_FAST_NULL_CHECKS, ALLOW_NEW, ALLOW_TAGGED_TEMPLATE], - }, - minLength: 0, - maxLength: 3, - }, - optionExamples: [true, [true, ALLOW_FAST_NULL_CHECKS]], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "unused expression, expected an assignment or function call"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var checking = false; - var allowFastNullChecks = true; - return ts.forEachChild(ctx.sourceFile, cb); - function cb(node) { - if (checking) { - if (tsutils_1.isParenthesizedExpression(node) || tsutils_1.isVoidExpression(node)) { - return cb(node.expression); - } - else if (tsutils_1.isConditionalExpression(node)) { - noCheck(node.condition, cb); - return both(node.whenTrue, node.whenFalse); - } - else if (tsutils_1.isBinaryExpression(node)) { - switch (node.operatorToken.kind) { - case ts.SyntaxKind.CommaToken: - if (isIndirectEval(node)) { - return false; - } - return both(node.left, node.right); - case ts.SyntaxKind.AmpersandAmpersandToken: - case ts.SyntaxKind.BarBarToken: - if (allowFastNullChecks) { - noCheck(node.left, cb); - return cb(node.right); - } - } - } - noCheck(node, forEachChild); - return isUnusedExpression(node, ctx.options); - } - if (tsutils_1.isExpressionStatement(node)) { - allowFastNullChecks = ctx.options.allowFastNullChecks; - if (!isDirective(node)) { - check(node.expression, node); - } - allowFastNullChecks = true; - return false; - } - else if (tsutils_1.isVoidExpression(node)) { - // allow `void 0` and `void(0)` - if (!isLiteralZero(tsutils_1.isParenthesizedExpression(node.expression) ? node.expression.expression : node.expression)) { - check(node.expression); - } - return false; - } - else if (tsutils_1.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.CommaToken && !isIndirectEval(node)) { - check(node.left); - return cb(node.right); - } - return ts.forEachChild(node, cb); - } - function forEachChild(node) { - return ts.forEachChild(node, cb); - } - function check(node, failNode) { - checking = true; - if (cb(node)) { - ctx.addFailureAtNode(failNode === undefined ? node : failNode, Rule.FAILURE_STRING); - } - checking = false; - } - function noCheck(node, callback) { - var old = allowFastNullChecks; - checking = false; - allowFastNullChecks = true; - callback(node); - allowFastNullChecks = old; - checking = true; - } - function both(one, two) { - if (cb(one)) { - if (cb(two)) { - return true; - } - else { - ctx.addFailureAtNode(one, Rule.FAILURE_STRING); - } - } - else if (cb(two)) { - ctx.addFailureAtNode(two, Rule.FAILURE_STRING); - } - return false; - } -} -function isUnusedExpression(node, options) { - switch (node.kind) { - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.YieldExpression: - case ts.SyntaxKind.DeleteExpression: - case ts.SyntaxKind.AwaitExpression: - case ts.SyntaxKind.PostfixUnaryExpression: - return false; - case ts.SyntaxKind.NewExpression: - return !options.allowNew; - case ts.SyntaxKind.TaggedTemplateExpression: - return !options.allowTaggedTemplate; - case ts.SyntaxKind.BinaryExpression: - return !tsutils_1.isAssignmentKind(node.operatorToken.kind); - case ts.SyntaxKind.PrefixUnaryExpression: - return node.operator !== ts.SyntaxKind.PlusPlusToken && - node.operator !== ts.SyntaxKind.MinusMinusToken; - default: - return true; - } -} -function isLiteralZero(node) { - return tsutils_1.isNumericLiteral(node) && node.text === "0"; -} -function isIndirectEval(node) { - return tsutils_1.isIdentifier(node.right) && node.right.text === "eval" && - isLiteralZero(node.left) && - node.parent.kind === ts.SyntaxKind.ParenthesizedExpression && - node.parent.parent.kind === ts.SyntaxKind.CallExpression; -} -function isDirective(node) { - if (node.expression.kind !== ts.SyntaxKind.StringLiteral || !canContainDirective(node.parent)) { - return false; - } - var parent = node.parent; - // check if all previous statements in block are also directives - for (var i = parent.statements.indexOf(node) - 1; i >= 0; --i) { - var statement = parent.statements[i]; - if (!tsutils_1.isExpressionStatement(statement) || statement.expression.kind !== ts.SyntaxKind.StringLiteral) { - return false; - } - } - return true; -} -function canContainDirective(node) { - switch (node.kind) { - case ts.SyntaxKind.SourceFile: - case ts.SyntaxKind.ModuleBlock: - return true; - case ts.SyntaxKind.Block: - switch (node.parent.kind) { - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - return true; - default: - return false; - } - default: - return false; - } -} -var templateObject_1, templateObject_2, templateObject_3; diff --git a/node_modules/tslint/lib/rules/noUnusedVariableRule.d.ts b/node_modules/tslint/lib/rules/noUnusedVariableRule.d.ts deleted file mode 100644 index 566348792..000000000 --- a/node_modules/tslint/lib/rules/noUnusedVariableRule.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUnusedVariableRule.js b/node_modules/tslint/lib/rules/noUnusedVariableRule.js deleted file mode 100644 index 8a7d7b5af..000000000 --- a/node_modules/tslint/lib/rules/noUnusedVariableRule.js +++ /dev/null @@ -1,420 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var semver = require("semver"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_CHECK_PARAMETERS = "check-parameters"; -var OPTION_IGNORE_PATTERN = "ignore-pattern"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments), program); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-unused-variable", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."], ["\n Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."]))), - descriptionDetails: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n In addition to avoiding compilation errors, this rule may still be useful if you\n wish to have `tslint` automatically remove unused imports, variables, functions,\n and private class members, when using TSLint's `--fix` option."], ["\n In addition to avoiding compilation errors, this rule may still be useful if you\n wish to have \\`tslint\\` automatically remove unused imports, variables, functions,\n and private class members, when using TSLint's \\`--fix\\` option."]))), - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n Three optional arguments may be optionally provided:\n\n * `\"check-parameters\"` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n * `{\"ignore-pattern\": \"pattern\"}` where pattern is a case-sensitive regexp.\n Variable names and imports that match the pattern will be ignored."], ["\n Three optional arguments may be optionally provided:\n\n * \\`\"check-parameters\"\\` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n * \\`{\"ignore-pattern\": \"pattern\"}\\` where pattern is a case-sensitive regexp.\n Variable names and imports that match the pattern will be ignored."]))), - options: { - type: "array", - items: { - oneOf: [ - { - type: "string", - enum: ["check-parameters"], - }, - { - type: "object", - properties: { - "ignore-pattern": { type: "string" }, - }, - additionalProperties: false, - }, - ], - }, - minLength: 0, - maxLength: 3, - }, - optionExamples: [true, [true, { "ignore-pattern": "^_" }]], - rationale: Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n Variables that are declared and not used anywhere in code are likely an error due to incomplete refactoring.\n Such variables take up space in the code, are mild performance pains, and can lead to confusion by readers.\n "], ["\n Variables that are declared and not used anywhere in code are likely an error due to incomplete refactoring.\n Such variables take up space in the code, are mild performance pains, and can lead to confusion by readers.\n "]))), - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - deprecationMessage: semver.gte(ts.version, "2.9.0-dev.0") - ? "Since TypeScript 2.9. Please use the built-in compiler checks instead." - : undefined, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function parseOptions(options) { - var checkParameters = options.indexOf(OPTION_CHECK_PARAMETERS) !== -1; - var ignorePattern; - for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { - var o = options_1[_i]; - if (typeof o === "object") { - // tslint:disable-next-line no-unsafe-any - var ignore = o[OPTION_IGNORE_PATTERN]; - if (ignore != undefined) { - ignorePattern = new RegExp(ignore); - break; - } - } - } - return { checkParameters: checkParameters, ignorePattern: ignorePattern }; -} -function walk(ctx, program) { - var sourceFile = ctx.sourceFile, _a = ctx.options, checkParameters = _a.checkParameters, ignorePattern = _a.ignorePattern; - var unusedCheckedProgram = getUnusedCheckedProgram(program, checkParameters); - var diagnostics = ts.getPreEmitDiagnostics(unusedCheckedProgram, sourceFile); - var checker = unusedCheckedProgram.getTypeChecker(); // Doesn't matter which program is used for this. - var declaration = program.getCompilerOptions().declaration; - // If all specifiers in an import are unused, we elide the entire import. - var importSpecifierFailures = new Map(); - for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) { - var diag = diagnostics_1[_i]; - if (diag.start === undefined) { - continue; - } - var kind = getUnusedDiagnostic(diag); - if (kind === undefined) { - continue; - } - var failure = ts.flattenDiagnosticMessageText(diag.messageText, "\n"); - // BUG: this means imports / destructures with all (2+) unused variables don't respect ignore pattern - if (ignorePattern !== undefined && kind !== 2 /* DECLARATION */ && kind !== 3 /* ALL_DESTRUCTURES */) { - var varName = /'(.*)'/.exec(failure)[1]; - if (ignorePattern.test(varName)) { - continue; - } - } - if (kind === 0 /* VARIABLE_OR_PARAMETER */ || kind === 2 /* DECLARATION */) { - var importNames = findImports(diag.start, sourceFile, kind); - if (importNames.length > 0) { - for (var _b = 0, importNames_1 = importNames; _b < importNames_1.length; _b++) { - var importName = importNames_1[_b]; - if (declaration && isImportUsed(importName, sourceFile, checker)) { - continue; - } - if (importSpecifierFailures.has(importName)) { - throw new Error("Should not get 2 errors for the same import."); - } - importSpecifierFailures.set(importName, failure); - } - continue; - } - } - ctx.addFailureAt(diag.start, diag.length, failure); - } - if (importSpecifierFailures.size !== 0) { - addImportSpecifierFailures(ctx, importSpecifierFailures, sourceFile); - } -} -/** - * Handle import-specifier failures separately. - * - If all of the import specifiers in an import are unused, add a combined failure for them all. - * - Unused imports are fixable. - */ -function addImportSpecifierFailures(ctx, failures, sourceFile) { - forEachImport(sourceFile, function (importNode) { - if (importNode.kind === ts.SyntaxKind.ImportEqualsDeclaration) { - tryRemoveAll(importNode.name); - return; - } - if (importNode.importClause === undefined) { - // Error node - return; - } - var _a = importNode.importClause, defaultName = _a.name, namedBindings = _a.namedBindings; - if (namedBindings !== undefined && namedBindings.kind === ts.SyntaxKind.NamespaceImport) { - tryRemoveAll(namedBindings.name); - return; - } - var allNamedBindingsAreFailures = namedBindings === undefined || namedBindings.elements.every(function (e) { return failures.has(e.name); }); - if (namedBindings !== undefined && allNamedBindingsAreFailures) { - for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { - var e = _b[_i]; - failures.delete(e.name); - } - } - if ((defaultName === undefined || failures.has(defaultName)) && allNamedBindingsAreFailures) { - if (defaultName !== undefined) { - failures.delete(defaultName); - } - removeAll(importNode, "All imports on this line are unused."); - return; - } - if (defaultName !== undefined) { - var failure = tryDelete(defaultName); - if (failure !== undefined) { - var start = defaultName.getStart(); - var end = namedBindings !== undefined ? namedBindings.getStart() : importNode.moduleSpecifier.getStart(); - var fix = Lint.Replacement.deleteFromTo(start, end); - ctx.addFailureAtNode(defaultName, failure, fix); - } - } - if (namedBindings !== undefined) { - if (allNamedBindingsAreFailures) { - var start = defaultName !== undefined ? defaultName.getEnd() : namedBindings.getStart(); - var fix = Lint.Replacement.deleteFromTo(start, namedBindings.getEnd()); - var failure = "All named bindings are unused."; - ctx.addFailureAtNode(namedBindings, failure, fix); - } - else { - var elements = namedBindings.elements; - for (var i = 0; i < elements.length; i++) { - var element = elements[i]; - var failure = tryDelete(element.name); - if (failure === undefined) { - continue; - } - var prevElement = elements[i - 1]; - var nextElement = elements[i + 1]; - var start = prevElement !== undefined ? prevElement.getEnd() : element.getStart(); - var end = nextElement !== undefined && prevElement == undefined ? nextElement.getStart() : element.getEnd(); - var fix = Lint.Replacement.deleteFromTo(start, end); - ctx.addFailureAtNode(element.name, failure, fix); - } - } - } - function tryRemoveAll(name) { - var failure = tryDelete(name); - if (failure !== undefined) { - removeAll(name, failure); - } - } - function removeAll(errorNode, failure) { - var start = importNode.getStart(); - var end = importNode.getEnd(); - utils.forEachToken(importNode, function (token) { - ts.forEachTrailingCommentRange(ctx.sourceFile.text, token.end, function (_, commentEnd, __) { - end = commentEnd; - }); - }, ctx.sourceFile); - if (isEntireLine(start, end)) { - end = getNextLineStart(end); - } - var fix = Lint.Replacement.deleteFromTo(start, end); - ctx.addFailureAtNode(errorNode, failure, fix); - } - function isEntireLine(start, end) { - return ctx.sourceFile.getLineAndCharacterOfPosition(start).character === 0 && - ctx.sourceFile.getLineEndOfPosition(end) === end; - } - function getNextLineStart(position) { - var nextLine = ctx.sourceFile.getLineAndCharacterOfPosition(position).line + 1; - var lineStarts = ctx.sourceFile.getLineStarts(); - if (nextLine < lineStarts.length) { - return lineStarts[nextLine]; - } - else { - return position; - } - } - }); - if (failures.size !== 0) { - throw new Error("Should have revisited all import specifier failures."); - } - function tryDelete(name) { - var failure = failures.get(name); - if (failure !== undefined) { - failures.delete(name); - return failure; - } - return undefined; - } -} -/** - * Ignore this import if it's used as an implicit type somewhere. - * Workround for https://github.com/Microsoft/TypeScript/issues/9944 - */ -function isImportUsed(importSpecifier, sourceFile, checker) { - var importedSymbol = checker.getSymbolAtLocation(importSpecifier); - if (importedSymbol === undefined) { - return false; - } - var symbol = checker.getAliasedSymbol(importedSymbol); - if (!utils.isSymbolFlagSet(symbol, ts.SymbolFlags.Type)) { - return false; - } - return ts.forEachChild(sourceFile, function cb(child) { - if (isImportLike(child)) { - return false; - } - var type = getImplicitType(child, checker); - // TODO: checker.typeEquals https://github.com/Microsoft/TypeScript/issues/13502 - if (type !== undefined && checker.typeToString(type) === checker.symbolToString(symbol)) { - return true; - } - return ts.forEachChild(child, cb); - }) === true; -} -function getImplicitType(node, checker) { - if ((utils.isPropertyDeclaration(node) || utils.isVariableDeclaration(node)) && - node.type === undefined && node.name.kind === ts.SyntaxKind.Identifier || - utils.isBindingElement(node) && node.name.kind === ts.SyntaxKind.Identifier) { - return checker.getTypeAtLocation(node); - } - else if (utils.isSignatureDeclaration(node) && node.type === undefined) { - var sig = checker.getSignatureFromDeclaration(node); - return sig === undefined ? undefined : sig.getReturnType(); - } - else { - return undefined; - } -} -function isImportLike(node) { - return node.kind === ts.SyntaxKind.ImportDeclaration || node.kind === ts.SyntaxKind.ImportEqualsDeclaration; -} -function forEachImport(sourceFile, f) { - return ts.forEachChild(sourceFile, function (child) { - if (isImportLike(child)) { - var res = f(child); - if (res !== undefined) { - return res; - } - } - return undefined; - }); -} -function findImports(pos, sourceFile, kind) { - var imports = forEachImport(sourceFile, function (i) { - if (!isInRange(i, pos)) { - return undefined; - } - if (i.kind === ts.SyntaxKind.ImportEqualsDeclaration) { - return [i.name]; - } - else { - if (i.importClause === undefined) { - // Error node - return undefined; - } - var _a = i.importClause, defaultName = _a.name, namedBindings = _a.namedBindings; - if (namedBindings !== undefined && namedBindings.kind === ts.SyntaxKind.NamespaceImport) { - return [namedBindings.name]; - } - // Starting from TS2.8, when all imports in an import node are not used, - // TS emits only 1 diagnostic object for the whole line as opposed - // to the previous behavior of outputting a diagnostic with kind == 6192 - // (UnusedKind.VARIABLE_OR_PARAMETER) for every unused import. - // From TS2.8, in the case of none of the imports in a line being used, - // the single diagnostic TS outputs are different between the 1 import - // and 2+ imports cases: - // - 1 import in node: - // - diagnostic has kind == 6133 (UnusedKind.VARIABLE_OR_PARAMETER) - // - the text range is the whole node (`import { ... } from "..."`) - // whereas pre-TS2.8, the text range was for the import node. so - // `name.getStart()` won't equal `pos` like in pre-TS2.8 - // - 2+ imports in node: - // - diagnostic has kind == 6192 (UnusedKind.DECLARATION) - // - we know that all of these are unused - if (kind === 2 /* DECLARATION */) { - var imp = []; - if (defaultName !== undefined) { - imp.push(defaultName); - } - if (namedBindings !== undefined) { - imp.push.apply(imp, namedBindings.elements.map(function (el) { return el.name; })); - } - return imp.length > 0 ? imp : undefined; - } - else if (defaultName !== undefined && (isInRange(defaultName, pos) || namedBindings === undefined // defaultName is the only option - )) { - return [defaultName]; - } - else if (namedBindings !== undefined) { - if (namedBindings.elements.length === 1) { - return [namedBindings.elements[0].name]; - } - for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { - var element = _b[_i]; - if (isInRange(element, pos)) { - return [element.name]; - } - } - } - } - return undefined; - }); - return imports !== undefined ? imports : []; -} -function isInRange(range, pos) { - return range.pos <= pos && range.end >= pos; -} -function getUnusedDiagnostic(diag) { - // https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json - switch (diag.code) { - case 6133: // Pre TS 2.9 "'{0}' is declared but never used. - // TS 2.9+ "'{0}' is declared but its value is never read." - case 6196: // TS 2.9+ "'{0}' is declared but never used." - return 0 /* VARIABLE_OR_PARAMETER */; - case 6138: - return 1 /* PROPERTY */; // "Property '{0}' is declared but never used." - case 6192: - return 2 /* DECLARATION */; // "All imports in import declaration are unused." - case 6198: - return 3 /* ALL_DESTRUCTURES */; // "All destructured elements are unused." - default: - return undefined; - } -} -var programToUnusedCheckedProgram = new WeakMap(); -function getUnusedCheckedProgram(program, checkParameters) { - // Assuming checkParameters will always have the same value, so only lookup by program. - var checkedProgram = programToUnusedCheckedProgram.get(program); - if (checkedProgram !== undefined) { - return checkedProgram; - } - checkedProgram = makeUnusedCheckedProgram(program, checkParameters); - programToUnusedCheckedProgram.set(program, checkedProgram); - return checkedProgram; -} -function makeUnusedCheckedProgram(program, checkParameters) { - var originalOptions = program.getCompilerOptions(); - var options = tslib_1.__assign({}, originalOptions, { noEmit: true, noUnusedLocals: true, noUnusedParameters: originalOptions.noUnusedParameters || checkParameters }); - var sourceFilesByName = new Map(program.getSourceFiles().map(function (s) { return [getCanonicalFileName(s.fileName), s]; })); - // tslint:disable object-literal-sort-keys - return ts.createProgram(Array.from(sourceFilesByName.keys()), options, { - fileExists: function (f) { return sourceFilesByName.has(getCanonicalFileName(f)); }, - readFile: function (f) { return sourceFilesByName.get(getCanonicalFileName(f)).text; }, - getSourceFile: function (f) { return sourceFilesByName.get(getCanonicalFileName(f)); }, - getDefaultLibFileName: function () { return ts.getDefaultLibFileName(options); }, - writeFile: function () { return undefined; }, - getCurrentDirectory: function () { return ""; }, - getDirectories: function () { return []; }, - getCanonicalFileName: getCanonicalFileName, - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getNewLine: function () { return "\n"; }, - }); - // tslint:enable object-literal-sort-keys - // We need to be careful with file system case sensitivity - function getCanonicalFileName(fileName) { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } -} -var templateObject_1, templateObject_2, templateObject_3, templateObject_4; diff --git a/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.d.ts b/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.d.ts deleted file mode 100644 index 558e2645c..000000000 --- a/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(name: string): string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.js b/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.js deleted file mode 100644 index a9a849483..000000000 --- a/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.js +++ /dev/null @@ -1,100 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var tsutils_1 = require("tsutils"); -var Lint = require("../index"); -var noUseBeforeDeclare_examples_1 = require("./code-examples/noUseBeforeDeclare.examples"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (name) { - return "variable '" + name + "' used before declaration"; - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-use-before-declare", - description: "Disallows usage of variables before their declaration.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n This rule is primarily useful when using the `var` keyword since the compiler will\n automatically detect if a block-scoped `let` and `const` variable is used before\n declaration. Since most modern TypeScript doesn't use `var`, this rule is generally\n discouraged and is kept around for legacy purposes. It is slow to compute, is not\n enabled in the built-in configuration presets, and should not be used to inform TSLint\n design decisions.\n "], ["\n This rule is primarily useful when using the \\`var\\` keyword since the compiler will\n automatically detect if a block-scoped \\`let\\` and \\`const\\` variable is used before\n declaration. Since most modern TypeScript doesn't use \\`var\\`, this rule is generally\n discouraged and is kept around for legacy purposes. It is slow to compute, is not\n enabled in the built-in configuration presets, and should not be used to inform TSLint\n design decisions.\n "]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - requiresTypeInfo: true, - codeExamples: noUseBeforeDeclare_examples_1.codeExamples, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - return ts.forEachChild(ctx.sourceFile, function recur(node) { - switch (node.kind) { - case ts.SyntaxKind.TypeReference: - // Ignore types. - return; - case ts.SyntaxKind.PropertyAccessExpression: - // Ignore `y` in `x.y`, but recurse to `x`. - return recur(node.expression); - case ts.SyntaxKind.Identifier: - if (isPropNameInBinding(node)) { - return; - } - return checkIdentifier(node, checker.getSymbolAtLocation(node)); - case ts.SyntaxKind.ExportSpecifier: - return checkIdentifier(node.name, checker.getExportSpecifierLocalTargetSymbol(node)); - default: - return ts.forEachChild(node, recur); - } - }); - function checkIdentifier(node, symbol) { - var declarations = symbol === undefined ? undefined : symbol.declarations; - if (declarations === undefined || declarations.length === 0) { - return; - } - var declaredBefore = declarations.some(function (decl) { - switch (decl.kind) { - case ts.SyntaxKind.FunctionDeclaration: - // Functions may be declared later. - return true; - default: - // Use `<=` in case this *is* the declaration. - // If it's a global declared in a different file, OK. - return decl.pos <= node.pos || decl.getSourceFile() !== ctx.sourceFile; - } - }); - if (!declaredBefore) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING(node.text)); - } - } - /** - * Destructured vars/args w/ rename are declared later in the source. - * var { x: y } = { x: 43 }; - */ - function isPropNameInBinding(node) { - return node.parent !== undefined && tsutils_1.isBindingElement(node.parent) && node.parent.propertyName === node; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noVarKeywordRule.d.ts b/node_modules/tslint/lib/rules/noVarKeywordRule.d.ts deleted file mode 100644 index 06b7c4bbe..000000000 --- a/node_modules/tslint/lib/rules/noVarKeywordRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noVarKeywordRule.js b/node_modules/tslint/lib/rules/noVarKeywordRule.js deleted file mode 100644 index 73a2964a5..000000000 --- a/node_modules/tslint/lib/rules/noVarKeywordRule.js +++ /dev/null @@ -1,72 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-var-keyword", - description: "Disallows usage of the `var` keyword.", - descriptionDetails: "Use `let` or `const` instead.", - hasFix: true, - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Declaring variables using `var` has several edge case behaviors that make `var` unsuitable for modern code.\n Variables declared by `var` have their parent function block as their scope, ignoring other control flow statements.\n `var`s have declaration \"hoisting\" (similar to `function`s) and can appear to be used before declaration.\n\n Variables declared by `const` and `let` instead have as their scope the block in which they are defined,\n and are not allowed to used before declaration or be re-declared with another `const` or `let`.\n "], ["\n Declaring variables using \\`var\\` has several edge case behaviors that make \\`var\\` unsuitable for modern code.\n Variables declared by \\`var\\` have their parent function block as their scope, ignoring other control flow statements.\n \\`var\\`s have declaration \"hoisting\" (similar to \\`function\\`s) and can appear to be used before declaration.\n\n Variables declared by \\`const\\` and \\`let\\` instead have as their scope the block in which they are defined,\n and are not allowed to used before declaration or be re-declared with another \\`const\\` or \\`let\\`.\n "]))), - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Forbidden 'var' keyword, use 'let' or 'const' instead"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - return ts.forEachChild(sourceFile, function cb(node) { - var parent = node.parent; - if (tsutils_1.isVariableDeclarationList(node) - && !tsutils_1.isBlockScopedVariableDeclarationList(node) - // If !isVariableStatement, this is inside of a for loop. - && (!tsutils_1.isVariableStatement(parent) || !isGlobalVarDeclaration(parent))) { - var start = node.getStart(sourceFile); - var width = "var".length; - // Don't apply fix in a declaration file, because may have meant 'const'. - var fix = sourceFile.isDeclarationFile ? undefined : new Lint.Replacement(start, width, "let"); - ctx.addFailureAt(start, width, Rule.FAILURE_STRING, fix); - } - return ts.forEachChild(node, cb); - }); -} -// Allow `declare var x: number;` or `declare global { var x: number; }` -function isGlobalVarDeclaration(node) { - var parent = node.parent; - return tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword) - || parent.kind === ts.SyntaxKind.ModuleBlock && tsutils_1.isNodeFlagSet(parent.parent, ts.NodeFlags.GlobalAugmentation); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/noVarRequiresRule.d.ts b/node_modules/tslint/lib/rules/noVarRequiresRule.d.ts deleted file mode 100644 index cb4dfbb50..000000000 --- a/node_modules/tslint/lib/rules/noVarRequiresRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noVarRequiresRule.js b/node_modules/tslint/lib/rules/noVarRequiresRule.js deleted file mode 100644 index 567235b1c..000000000 --- a/node_modules/tslint/lib/rules/noVarRequiresRule.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2014 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var requiresWalker = new NoVarRequiresWalker(sourceFile, this.getOptions()); - return this.applyWithWalker(requiresWalker); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-var-requires", - description: "Disallows the use of require statements except in import statements.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n In other words, the use of forms such as `var module = require(\"module\")` are banned.\n Instead use ES2015-style imports or `import foo = require('foo')` imports."], ["\n In other words, the use of forms such as \\`var module = require(\"module\")\\` are banned.\n Instead use ES2015-style imports or \\`import foo = require('foo')\\` imports."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n AMD-style `require([])` and CommonJS-style `require(\"\")` statements are environment-specific\n and more difficult to statically analyze.\n\n ES2015-style `import`s are part of the JavaScript language specfication and recommended as the path going forward.\n TypeScript will compile them to environment-specific forms as needed.\n "], ["\n AMD-style \\`require([])\\` and CommonJS-style \\`require(\"\")\\` statements are environment-specific\n and more difficult to statically analyze.\n\n ES2015-style \\`import\\`s are part of the JavaScript language specfication and recommended as the path going forward.\n TypeScript will compile them to environment-specific forms as needed.\n "]))), - type: "typescript", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "require statement not part of an import statement"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -// tslint:disable-next-line:deprecation -var NoVarRequiresWalker = /** @class */ (function (_super) { - tslib_1.__extends(NoVarRequiresWalker, _super); - function NoVarRequiresWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - NoVarRequiresWalker.prototype.createScope = function () { - return {}; - }; - NoVarRequiresWalker.prototype.visitCallExpression = function (node) { - var expression = node.expression; - if (this.getCurrentDepth() <= 1 && expression.kind === ts.SyntaxKind.Identifier) { - var identifierName = expression.text; - if (identifierName === "require") { - // if we're calling (invoking) require, then it's not part of an import statement - this.addFailureAtNode(node, Rule.FAILURE_STRING); - } - } - _super.prototype.visitCallExpression.call(this, node); - }; - return NoVarRequiresWalker; -}(Lint.ScopeAwareRuleWalker)); -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/noVoidExpressionRule.d.ts b/node_modules/tslint/lib/rules/noVoidExpressionRule.d.ts deleted file mode 100644 index 8b31e4da7..000000000 --- a/node_modules/tslint/lib/rules/noVoidExpressionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/noVoidExpressionRule.js b/node_modules/tslint/lib/rules/noVoidExpressionRule.js deleted file mode 100644 index 96742a87d..000000000 --- a/node_modules/tslint/lib/rules/noVoidExpressionRule.js +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND = "ignore-arrow-function-shorthand"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - var ignoreArrowFunctionShorthand = this.ruleArguments.indexOf(OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND) !== -1; - return this.applyWithFunction(sourceFile, walk, { ignoreArrowFunctionShorthand: ignoreArrowFunctionShorthand }, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "no-void-expression", - description: "Requires expressions of type `void` to appear in statement position.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is provided, `() => returnsVoid()` will be allowed.\n Otherwise, it must be written as `() => { returnsVoid(); }`."], ["\n If \\`", "\\` is provided, \\`() => returnsVoid()\\` will be allowed.\n Otherwise, it must be written as \\`() => { returnsVoid(); }\\`."])), OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_IGNORE_ARROW_FUNCTION_SHORTHAND], - }, - minLength: 0, - maxLength: 1, - }, - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It's misleading returning the results of an expression whose type is `void`.\n Attempting to do so is likely a symptom of expecting a different return type from a function.\n For example, the following code will log `undefined` but looks like it logs a value:\n\n ```\n const performWork = (): void => {\n workFirst();\n workSecond();\n };\n\n console.log(performWork());\n ```\n "], ["\n It's misleading returning the results of an expression whose type is \\`void\\`.\n Attempting to do so is likely a symptom of expecting a different return type from a function.\n For example, the following code will log \\`undefined\\` but looks like it logs a value:\n\n \\`\\`\\`\n const performWork = (): void => {\n workFirst();\n workSecond();\n };\n\n console.log(performWork());\n \\`\\`\\`\n "]))), - requiresTypeInfo: true, - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Expression has type `void`. Put it on its own line as a statement."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - var sourceFile = ctx.sourceFile, ignoreArrowFunctionShorthand = ctx.options.ignoreArrowFunctionShorthand; - return ts.forEachChild(sourceFile, function cb(node) { - if (isPossiblyVoidExpression(node) - && !isParentAllowedVoid(node) - && tsutils_1.isTypeFlagSet(checker.getTypeAtLocation(node), ts.TypeFlags.Void)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); - function isParentAllowedVoid(node) { - switch (node.parent.kind) { - case ts.SyntaxKind.ExpressionStatement: - return true; - case ts.SyntaxKind.ArrowFunction: - return ignoreArrowFunctionShorthand; - default: - return false; - } - } -} -function isPossiblyVoidExpression(node) { - switch (node.kind) { - case ts.SyntaxKind.AwaitExpression: - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.TaggedTemplateExpression: - return true; - default: - return false; - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/numberLiteralFormatRule.d.ts b/node_modules/tslint/lib/rules/numberLiteralFormatRule.d.ts deleted file mode 100644 index a83b51361..000000000 --- a/node_modules/tslint/lib/rules/numberLiteralFormatRule.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_LEADING_0: string; - static FAILURE_STRING_TRAILING_0: string; - static FAILURE_STRING_TRAILING_DECIMAL: string; - static FAILURE_STRING_LEADING_DECIMAL: string; - static FAILURE_STRING_NOT_UPPERCASE: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/numberLiteralFormatRule.js b/node_modules/tslint/lib/rules/numberLiteralFormatRule.js deleted file mode 100644 index 3b313b693..000000000 --- a/node_modules/tslint/lib/rules/numberLiteralFormatRule.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "number-literal-format", - description: "Checks that decimal literals should begin with '0.' instead of just '.', and should not end with a trailing '0'.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps keep a consistent style with numeric literals.\n Non-standard literals are more difficult to scan through and can be a symptom of typos.\n "], ["\n Helps keep a consistent style with numeric literals.\n Non-standard literals are more difficult to scan through and can be a symptom of typos.\n "]))), - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_LEADING_0 = "Number literal should not have a leading '0'."; - Rule.FAILURE_STRING_TRAILING_0 = "Number literal should not have a trailing '0'."; - Rule.FAILURE_STRING_TRAILING_DECIMAL = "Number literal should not end in '.'."; - Rule.FAILURE_STRING_LEADING_DECIMAL = "Number literal should begin with '0.' and not just '.'."; - Rule.FAILURE_STRING_NOT_UPPERCASE = "Hexadecimal number literal should be uppercase."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - return ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isNumericLiteral(node)) { - return check(node); - } - return ts.forEachChild(node, cb); - }); - function check(node) { - // Apparently the number literal '0.0' has a '.text' of '0', so use '.getText()' instead. - var text = node.getText(sourceFile); - if (text.length <= 1) { - return; - } - if (text.startsWith("0")) { - // Hex/octal/binary number can't have decimal point or exponent, so no other errors possible. - switch (text[1]) { - case "x": - if (!utils_1.isUpperCase(text.slice(2))) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_NOT_UPPERCASE); - } - return; - case "o": - case "b": - return; - case ".": - break; - default: - ctx.addFailureAtNode(node, Rule.FAILURE_STRING_LEADING_0); - return; - } - } - var _a = text.split(/e/i), num = _a[0], exp = _a[1]; - if (exp !== undefined && (exp.startsWith("-0") || exp.startsWith("0"))) { - ctx.addFailureAt(node.getEnd() - exp.length, exp.length, Rule.FAILURE_STRING_LEADING_0); - } - if (!num.includes(".")) { - return; - } - if (num.startsWith(".")) { - fail(Rule.FAILURE_STRING_LEADING_DECIMAL); - } - if (num.endsWith(".")) { - fail(Rule.FAILURE_STRING_TRAILING_DECIMAL); - } - // Allow '10', but not '1.0' - if (num.endsWith("0")) { - fail(Rule.FAILURE_STRING_TRAILING_0); - } - function fail(message) { - ctx.addFailureAt(node.getStart(sourceFile), num.length, message); - } - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/objectLiteralKeyQuotesRule.d.ts b/node_modules/tslint/lib/rules/objectLiteralKeyQuotesRule.d.ts deleted file mode 100644 index c6c00d0d7..000000000 --- a/node_modules/tslint/lib/rules/objectLiteralKeyQuotesRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static INCONSISTENT_PROPERTY: string; - static UNNEEDED_QUOTES(name: string): string; - static UNQUOTED_PROPERTY(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/objectLiteralKeyQuotesRule.js b/node_modules/tslint/lib/rules/objectLiteralKeyQuotesRule.js deleted file mode 100644 index 2462c06d0..000000000 --- a/node_modules/tslint/lib/rules/objectLiteralKeyQuotesRule.js +++ /dev/null @@ -1,150 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALWAYS = "always"; -var OPTION_AS_NEEDED = "as-needed"; -var OPTION_CONSISTENT = "consistent"; -var OPTION_CONSISTENT_AS_NEEDED = "consistent-as-needed"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.UNNEEDED_QUOTES = function (name) { - return "Unnecessarily quoted property '" + name + "' found."; - }; - Rule.UNQUOTED_PROPERTY = function (name) { - return "Unquoted property '" + name + "' found."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new ObjectLiteralKeyQuotesWalker(sourceFile, this.ruleName, { - option: this.ruleArguments.length === 0 ? "always" : this.ruleArguments[0], - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "object-literal-key-quotes", - description: "Enforces consistent object literal property quote style.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Object literal property names can be defined in two ways: using literals or using strings.\n For example, these two objects are equivalent:\n\n var object1 = {\n property: true\n };\n\n var object2 = {\n \"property\": true\n };\n\n In many cases, it doesn\u2019t matter if you choose to use an identifier instead of a string\n or vice-versa. Even so, you might decide to enforce a consistent style in your code.\n\n This rules lets you enforce consistent quoting of property names. Either they should always\n be quoted (default behavior) or quoted only as needed (\"as-needed\")."], ["\n Object literal property names can be defined in two ways: using literals or using strings.\n For example, these two objects are equivalent:\n\n var object1 = {\n property: true\n };\n\n var object2 = {\n \"property\": true\n };\n\n In many cases, it doesn\u2019t matter if you choose to use an identifier instead of a string\n or vice-versa. Even so, you might decide to enforce a consistent style in your code.\n\n This rules lets you enforce consistent quoting of property names. Either they should always\n be quoted (default behavior) or quoted only as needed (\"as-needed\")."]))), - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Possible settings are:\n\n * `\"", "\"`: Property names should always be quoted. (This is the default.)\n * `\"", "\"`: Only property names which require quotes may be quoted (e.g. those with spaces in them).\n * `\"", "\"`: Property names should either all be quoted or unquoted.\n * `\"", "\"`: If any property name requires quotes, then all properties must be quoted. Otherwise, no\n property names may be quoted.\n\n For ES6, computed property names (`{[name]: value}`) and methods (`{foo() {}}`) never need\n to be quoted."], ["\n Possible settings are:\n\n * \\`\"", "\"\\`: Property names should always be quoted. (This is the default.)\n * \\`\"", "\"\\`: Only property names which require quotes may be quoted (e.g. those with spaces in them).\n * \\`\"", "\"\\`: Property names should either all be quoted or unquoted.\n * \\`\"", "\"\\`: If any property name requires quotes, then all properties must be quoted. Otherwise, no\n property names may be quoted.\n\n For ES6, computed property names (\\`{[name]: value}\\`) and methods (\\`{foo() {}}\\`) never need\n to be quoted."])), OPTION_ALWAYS, OPTION_AS_NEEDED, OPTION_CONSISTENT, OPTION_CONSISTENT_AS_NEEDED), - options: { - type: "string", - enum: [OPTION_ALWAYS, OPTION_AS_NEEDED, OPTION_CONSISTENT, OPTION_CONSISTENT_AS_NEEDED], - }, - optionExamples: [[true, OPTION_AS_NEEDED], [true, OPTION_ALWAYS]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.INCONSISTENT_PROPERTY = "All property names in this object literal must be consistently quoted or unquoted."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var ObjectLiteralKeyQuotesWalker = /** @class */ (function (_super) { - tslib_1.__extends(ObjectLiteralKeyQuotesWalker, _super); - function ObjectLiteralKeyQuotesWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - ObjectLiteralKeyQuotesWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (tsutils_1.isObjectLiteralExpression(node)) { - var propertyNames = Lint.Utils.mapDefined(node.properties, mapPropertyName); - outer: switch (_this.options.option) { - case "always": - for (var _i = 0, propertyNames_1 = propertyNames; _i < propertyNames_1.length; _i++) { - var name = propertyNames_1[_i]; - if (name.kind !== ts.SyntaxKind.StringLiteral) { - _this.reportMissing(name); - } - } - break; - case "as-needed": - for (var _a = 0, propertyNames_2 = propertyNames; _a < propertyNames_2.length; _a++) { - var name = propertyNames_2[_a]; - if (name.kind === ts.SyntaxKind.StringLiteral && tsutils_1.isValidPropertyName(name.text)) { - _this.reportUnnecessary(name); - } - } - break; - case "consistent": - if (hasInconsistentQuotes(propertyNames)) { - // No fix -- don't know if they would want to add quotes or remove them. - _this.addFailureAt(node.getStart(_this.sourceFile), 1, Rule.INCONSISTENT_PROPERTY); - } - break; - case "consistent-as-needed": - for (var _b = 0, propertyNames_3 = propertyNames; _b < propertyNames_3.length; _b++) { - var name = propertyNames_3[_b]; - if (name.kind === ts.SyntaxKind.StringLiteral && !tsutils_1.isValidPropertyName(name.text)) { - for (var _c = 0, propertyNames_4 = propertyNames; _c < propertyNames_4.length; _c++) { - var propertyName = propertyNames_4[_c]; - if (propertyName.kind !== ts.SyntaxKind.StringLiteral) { - _this.reportMissing(propertyName); - } - } - break outer; - } - } - for (var _d = 0, propertyNames_5 = propertyNames; _d < propertyNames_5.length; _d++) { - var name = propertyNames_5[_d]; - if (name.kind === ts.SyntaxKind.StringLiteral) { - _this.reportUnnecessary(name); - } - } - } - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - ObjectLiteralKeyQuotesWalker.prototype.reportMissing = function (node) { - var start = node.getStart(this.sourceFile); - this.addFailure(start, node.end, Rule.UNQUOTED_PROPERTY(node.text), Lint.Replacement.replaceFromTo(start, node.end, "\"" + node.text + "\"")); - }; - ObjectLiteralKeyQuotesWalker.prototype.reportUnnecessary = function (node) { - this.addFailureAtNode(node, Rule.UNNEEDED_QUOTES(node.text), Lint.Replacement.replaceNode(node, node.text, this.sourceFile)); - }; - return ObjectLiteralKeyQuotesWalker; -}(Lint.AbstractWalker)); -function mapPropertyName(property) { - if (property.kind === ts.SyntaxKind.ShorthandPropertyAssignment || - property.kind === ts.SyntaxKind.SpreadAssignment || - property.name.kind === ts.SyntaxKind.ComputedPropertyName) { - return undefined; - } - return property.name; -} -function hasInconsistentQuotes(properties) { - if (properties.length < 2) { - return false; - } - var quoted = properties[0].kind === ts.SyntaxKind.StringLiteral; - for (var i = 1; i < properties.length; ++i) { - if (quoted !== (properties[i].kind === ts.SyntaxKind.StringLiteral)) { - return true; - } - } - return false; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts b/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts deleted file mode 100644 index 368e5eb99..000000000 --- a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from ".."; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static LONGHAND_PROPERTY: string; - static LONGHAND_METHOD: string; - static SHORTHAND_ASSIGNMENT: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js b/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js deleted file mode 100644 index e770d72e6..000000000 --- a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js +++ /dev/null @@ -1,104 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require(".."); -var OPTION_NEVER = "never"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, this.ruleArguments.indexOf(OPTION_NEVER) === -1 - ? enforceShorthandWalker - : disallowShorthandWalker); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "object-literal-shorthand", - description: "Enforces/disallows use of ES6 object literal shorthand.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If the 'never' option is provided, any shorthand object literal syntax will cause a failure."], ["\n If the \\'never\\' option is provided, any shorthand object literal syntax will cause a failure."]))), - options: { - type: "string", - enum: [OPTION_NEVER], - }, - optionExamples: [true, [true, OPTION_NEVER]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.LONGHAND_PROPERTY = "Expected property shorthand in object literal "; - Rule.LONGHAND_METHOD = "Expected method shorthand in object literal "; - Rule.SHORTHAND_ASSIGNMENT = "Shorthand property assignments have been disallowed."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function disallowShorthandWalker(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isShorthandPropertyAssignment(node)) { - ctx.addFailureAtNode(node.name, Rule.SHORTHAND_ASSIGNMENT, Lint.Replacement.appendText(node.getStart(ctx.sourceFile), node.name.text + ": ")); - } - else if (tsutils_1.isMethodDeclaration(node) && node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression) { - ctx.addFailureAtNode(node.name, Rule.SHORTHAND_ASSIGNMENT, fixShorthandMethodDeclaration(node, ctx.sourceFile)); - } - return ts.forEachChild(node, cb); - }); -} -function enforceShorthandWalker(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isPropertyAssignment(node)) { - if (node.name.kind === ts.SyntaxKind.Identifier && - tsutils_1.isIdentifier(node.initializer) && - node.name.text === node.initializer.text) { - ctx.addFailureAtNode(node, Rule.LONGHAND_PROPERTY + "('{" + node.name.text + "}').", Lint.Replacement.deleteFromTo(node.name.end, node.end)); - } - else if (tsutils_1.isFunctionExpression(node.initializer) && - // allow named function expressions - node.initializer.name === undefined) { - var _a = handleLonghandMethod(node.name, node.initializer, ctx.sourceFile), name = _a[0], fix = _a[1]; - ctx.addFailure(node.getStart(ctx.sourceFile), tsutils_1.getChildOfKind(node.initializer, ts.SyntaxKind.OpenParenToken, ctx.sourceFile).pos, Rule.LONGHAND_METHOD + "('{" + name + "() {...}}').", fix); - } - } - return ts.forEachChild(node, cb); - }); -} -function fixShorthandMethodDeclaration(node, sourceFile) { - var isGenerator = node.asteriskToken !== undefined; - var isAsync = tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword); - return Lint.Replacement.replaceFromTo(node.getStart(sourceFile), node.name.end, node.name.getText(sourceFile) + ":" + (isAsync ? " async" : "") + " function" + (isGenerator ? "*" : "")); -} -function handleLonghandMethod(name, initializer, sourceFile) { - var nameStart = name.getStart(sourceFile); - var fix = Lint.Replacement.deleteFromTo(name.end, tsutils_1.getChildOfKind(initializer, ts.SyntaxKind.OpenParenToken).pos); - var prefix = ""; - if (initializer.asteriskToken !== undefined) { - prefix = "*"; - } - if (tsutils_1.hasModifier(initializer.modifiers, ts.SyntaxKind.AsyncKeyword)) { - prefix = "async " + prefix; - } - if (prefix !== "") { - fix = [fix, Lint.Replacement.appendText(nameStart, prefix)]; - } - return [prefix + sourceFile.text.substring(nameStart, name.end), fix]; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.d.ts b/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.d.ts deleted file mode 100644 index 9d03fd582..000000000 --- a/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.OptionallyTypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_ALPHABETICAL(name: string): string; - static FAILURE_STRING_USE_DECLARATION_ORDER(propName: string, typeName: string | undefined): string; - static FAILURE_STRING_SHORTHAND_FIRST(name: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js b/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js deleted file mode 100644 index 88bdd7cc9..000000000 --- a/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js +++ /dev/null @@ -1,209 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_IGNORE_CASE = "ignore-case"; -var OPTION_MATCH_DECLARATION_ORDER = "match-declaration-order"; -var OPTION_SHORTHAND_FIRST = "shorthand-first"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_ALPHABETICAL = function (name) { - return "The key '" + name + "' is not sorted alphabetically"; - }; - Rule.FAILURE_STRING_USE_DECLARATION_ORDER = function (propName, typeName) { - var type = typeName === undefined ? "its type declaration" : "'" + typeName + "'"; - return "The key '" + propName + "' is not in the same order as it is in " + type + "."; - }; - Rule.FAILURE_STRING_SHORTHAND_FIRST = function (name) { - return "The shorthand property '" + name + "' should appear before normal properties"; - }; - Rule.prototype.apply = function (sourceFile) { - var options = parseOptions(this.ruleArguments); - if (options.matchDeclarationOrder) { - throw new Error(this.ruleName + " needs type info to use \"" + OPTION_MATCH_DECLARATION_ORDER + "\"."); - } - return this.applyWithFunction(sourceFile, walk, options); - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments), program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "object-literal-sort-keys", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Checks ordering of keys in object literals.\n\n When using the default alphabetical ordering, additional blank lines may be used to group\n object properties together while keeping the elements within each group in alphabetical order.\n "], ["\n Checks ordering of keys in object literals.\n\n When using the default alphabetical ordering, additional blank lines may be used to group\n object properties together while keeping the elements within each group in alphabetical order.\n "]))), - rationale: "Useful in preventing merge conflicts", - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n By default, this rule checks that keys are in alphabetical order.\n The following may optionally be passed:\n\n * \"", "\" will compare keys in a case insensitive way.\n * \"", "\" will prefer to use the key ordering of the contextual type of the object literal, as in:\n\n interface I { foo: number; bar: number; }\n const obj: I = { foo: 1, bar: 2 };\n\n If a contextual type is not found, alphabetical ordering will be used instead.\n * \"", "\" will enforce shorthand properties to appear first, as in:\n\n const obj = { a, c, b: true };\n "], ["\n By default, this rule checks that keys are in alphabetical order.\n The following may optionally be passed:\n\n * \"", "\" will compare keys in a case insensitive way.\n * \"", "\" will prefer to use the key ordering of the contextual type of the object literal, as in:\n\n interface I { foo: number; bar: number; }\n const obj: I = { foo: 1, bar: 2 };\n\n If a contextual type is not found, alphabetical ordering will be used instead.\n * \"", "\" will enforce shorthand properties to appear first, as in:\n\n const obj = { a, c, b: true };\n "])), OPTION_IGNORE_CASE, OPTION_MATCH_DECLARATION_ORDER, OPTION_SHORTHAND_FIRST), - options: { - type: "string", - enum: [OPTION_IGNORE_CASE, OPTION_MATCH_DECLARATION_ORDER, OPTION_SHORTHAND_FIRST], - }, - optionExamples: [ - true, - [true, OPTION_IGNORE_CASE, OPTION_MATCH_DECLARATION_ORDER, OPTION_SHORTHAND_FIRST], - ], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.OptionallyTypedRule)); -exports.Rule = Rule; -function parseOptions(ruleArguments) { - return { - ignoreCase: has(OPTION_IGNORE_CASE), - matchDeclarationOrder: has(OPTION_MATCH_DECLARATION_ORDER), - shorthandFirst: has(OPTION_SHORTHAND_FIRST), - }; - function has(name) { - return ruleArguments.indexOf(name) !== -1; - } -} -function walk(ctx, checker) { - var sourceFile = ctx.sourceFile, _a = ctx.options, ignoreCase = _a.ignoreCase, matchDeclarationOrder = _a.matchDeclarationOrder, shorthandFirst = _a.shorthandFirst; - ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isObjectLiteralExpression(node) && node.properties.length > 1) { - check(node); - } - ts.forEachChild(node, cb); - }); - function check(node) { - if (matchDeclarationOrder) { - var type = getContextualType(node, checker); - // If type has an index signature, we can't check ordering. - // If type has call/construct signatures, it can't be satisfied by an object literal anyway. - if (type !== undefined - && type.members.every(function (m) { return m.kind === ts.SyntaxKind.PropertySignature || m.kind === ts.SyntaxKind.MethodSignature; })) { - checkMatchesDeclarationOrder(node, type, type.members); - return; - } - } - checkAlphabetical(node); - } - function checkAlphabetical(node) { - if (tsutils_1.isSameLine(ctx.sourceFile, node.properties.pos, node.end)) { - return; - } - var lastKey; - var lastPropertyWasShorthand; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - switch (property.kind) { - case ts.SyntaxKind.SpreadAssignment: - lastKey = undefined; // reset at spread - lastPropertyWasShorthand = undefined; // reset at spread - break; - case ts.SyntaxKind.ShorthandPropertyAssignment: - case ts.SyntaxKind.PropertyAssignment: - if (shorthandFirst) { - if (property.kind === ts.SyntaxKind.ShorthandPropertyAssignment) { - if (lastPropertyWasShorthand === false) { - ctx.addFailureAtNode(property.name, Rule.FAILURE_STRING_SHORTHAND_FIRST(property.name.text)); - return; // only show warning on first out-of-order property - } - lastPropertyWasShorthand = true; - } - else { - if (lastPropertyWasShorthand === true) { - lastKey = undefined; // reset on change from shorthand to normal - } - lastPropertyWasShorthand = false; - } - } - if (property.name.kind === ts.SyntaxKind.Identifier || - property.name.kind === ts.SyntaxKind.StringLiteral) { - var key = ignoreCase ? property.name.text.toLowerCase() : property.name.text; - // comparison with undefined is expected - if (lastKey > key && !hasBlankLineBefore(ctx.sourceFile, property)) { - ctx.addFailureAtNode(property.name, Rule.FAILURE_STRING_ALPHABETICAL(property.name.text)); - return; // only show warning on first out-of-order property - } - lastKey = key; - } - } - } - } - function checkMatchesDeclarationOrder(_a, type, members) { - var properties = _a.properties; - var memberIndex = 0; - outer: for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { - var prop = properties_1[_i]; - if (prop.kind === ts.SyntaxKind.SpreadAssignment) { - memberIndex = 0; - continue; - } - if (prop.name.kind === ts.SyntaxKind.ComputedPropertyName) { - continue; - } - var propName = prop.name.text; - for (; memberIndex !== members.length; memberIndex++) { - var memberName = members[memberIndex].name; - if (memberName.kind !== ts.SyntaxKind.ComputedPropertyName && propName === memberName.text) { - continue outer; - } - } - // This We didn't find the member we were looking for past the previous member, - // so it must have come before it and is therefore out of order. - ctx.addFailureAtNode(prop.name, Rule.FAILURE_STRING_USE_DECLARATION_ORDER(propName, getTypeName(type))); - // Don't bother with multiple errors. - break; - } - } -} -function hasBlankLineBefore(sourceFile, element) { - var comments = ts.getLeadingCommentRanges(sourceFile.text, element.pos); - if (comments === undefined) { - comments = []; // it will be easier to work with an empty array down below... - } - var elementStart = comments.length > 0 ? comments[comments.length - 1].end : element.getFullStart(); - // either the element itself, or one of its leading comments must have an extra new line before them - return hasDoubleNewLine(sourceFile, elementStart) || comments.some(function (comment) { - var commentLine = ts.getLineAndCharacterOfPosition(sourceFile, comment.pos).line; - var commentLineStartPosition = ts.getPositionOfLineAndCharacter(sourceFile, commentLine, 0); - return hasDoubleNewLine(sourceFile, commentLineStartPosition - 4); - }); -} -function hasDoubleNewLine(sourceFile, position) { - return /(\r?\n){2}/.test(sourceFile.text.slice(position, position + 4)); -} -function getTypeName(t) { - var parent = t.parent; - return t.kind === ts.SyntaxKind.InterfaceDeclaration - ? t.name.text - : tsutils_1.isTypeAliasDeclaration(parent) - ? parent.name.text - : undefined; -} -function getContextualType(node, checker) { - var c = checker.getContextualType(node); - if (c === undefined || c.symbol === undefined) { - return undefined; - } - var declarations = c.symbol.declarations; - if (declarations === undefined || declarations.length !== 1) { - return undefined; - } - var decl = declarations[0]; - return tsutils_1.isInterfaceDeclaration(decl) || tsutils_1.isTypeLiteralNode(decl) ? decl : undefined; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/oneLineRule.d.ts b/node_modules/tslint/lib/rules/oneLineRule.d.ts deleted file mode 100644 index cb45e35bb..000000000 --- a/node_modules/tslint/lib/rules/oneLineRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static WHITESPACE_FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/oneLineRule.js b/node_modules/tslint/lib/rules/oneLineRule.js deleted file mode 100644 index 1d0dccf92..000000000 --- a/node_modules/tslint/lib/rules/oneLineRule.js +++ /dev/null @@ -1,154 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_BRACE = "check-open-brace"; -var OPTION_CATCH = "check-catch"; -var OPTION_ELSE = "check-else"; -var OPTION_FINALLY = "check-finally"; -var OPTION_WHITESPACE = "check-whitespace"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new OneLineWalker(sourceFile, this.ruleName, { - brace: this.ruleArguments.indexOf(OPTION_BRACE) !== -1, - catch: this.ruleArguments.indexOf(OPTION_CATCH) !== -1, - else: this.ruleArguments.indexOf(OPTION_ELSE) !== -1, - finally: this.ruleArguments.indexOf(OPTION_FINALLY) !== -1, - whitespace: this.ruleArguments.indexOf(OPTION_WHITESPACE) !== -1, - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "one-line", - description: "Requires the specified tokens to be on the same line as the expression preceding them.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"` checks that `catch` is on the same line as the closing brace for `try`.\n * `\"", "\"` checks that `finally` is on the same line as the closing brace for `catch`.\n * `\"", "\"` checks that `else` is on the same line as the closing brace for `if`.\n * `\"", "\"` checks that an open brace falls on the same line as its preceding expression.\n * `\"", "\"` checks preceding whitespace for the specified tokens."], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` checks that \\`catch\\` is on the same line as the closing brace for \\`try\\`.\n * \\`\"", "\"\\` checks that \\`finally\\` is on the same line as the closing brace for \\`catch\\`.\n * \\`\"", "\"\\` checks that \\`else\\` is on the same line as the closing brace for \\`if\\`.\n * \\`\"", "\"\\` checks that an open brace falls on the same line as its preceding expression.\n * \\`\"", "\"\\` checks preceding whitespace for the specified tokens."])), OPTION_CATCH, OPTION_FINALLY, OPTION_ELSE, OPTION_BRACE, OPTION_WHITESPACE), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_CATCH, OPTION_FINALLY, OPTION_ELSE, OPTION_BRACE, OPTION_WHITESPACE], - }, - minLength: 0, - maxLength: 5, - }, - optionExamples: [[true, OPTION_CATCH, OPTION_FINALLY, OPTION_ELSE]], - type: "style", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.WHITESPACE_FAILURE_STRING = "missing whitespace"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var OneLineWalker = /** @class */ (function (_super) { - tslib_1.__extends(OneLineWalker, _super); - function OneLineWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - OneLineWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - switch (node.kind) { - case ts.SyntaxKind.Block: - if (!tsutils_1.isBlockLike(node.parent)) { - _this.check({ pos: node.pos, end: node.statements.pos }); - } - break; - case ts.SyntaxKind.CaseBlock: - _this.check({ pos: node.pos, end: node.clauses.pos }); - break; - case ts.SyntaxKind.ModuleBlock: - _this.check({ pos: node.pos, end: node.statements.pos }); - break; - case ts.SyntaxKind.EnumDeclaration: - _this.check({ pos: node.name.end, end: node.members.pos }); - break; - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: { - var openBrace = tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenBraceToken, sourceFile); - if (openBrace !== undefined) { - _this.check(openBrace); - } - break; - } - case ts.SyntaxKind.IfStatement: { - var _a = node, thenStatement = _a.thenStatement, elseStatement = _a.elseStatement; - if (elseStatement !== undefined && thenStatement.kind === ts.SyntaxKind.Block) { - _this.check({ pos: thenStatement.end, end: elseStatement.pos }, "else"); - } - break; - } - case ts.SyntaxKind.TryStatement: { - var _b = node, finallyBlock = _b.finallyBlock, catchClause = _b.catchClause, tryBlock = _b.tryBlock; - if (catchClause !== undefined) { - _this.check(catchClause.getChildAt(0, sourceFile), "catch"); - if (finallyBlock !== undefined) { - _this.check({ pos: catchClause.end, end: finallyBlock.pos }, "finally"); - } - } - else if (finallyBlock !== undefined) { - _this.check({ pos: tryBlock.end, end: finallyBlock.pos }, "finally"); - } - break; - } - case ts.SyntaxKind.BinaryExpression: { - var _c = node, operatorToken = _c.operatorToken, right = _c.right; - if (operatorToken.kind === ts.SyntaxKind.EqualsToken && tsutils_1.isObjectLiteralExpression(right)) { - _this.check({ pos: right.pos, end: right.properties.pos }); - } - break; - } - case ts.SyntaxKind.VariableDeclaration: { - var initializer = node.initializer; - if (initializer !== undefined && tsutils_1.isObjectLiteralExpression(initializer)) { - _this.check({ pos: initializer.pos, end: initializer.properties.pos }); - } - break; - } - case ts.SyntaxKind.TypeAliasDeclaration: { - var type = node.type; - if (type.kind === ts.SyntaxKind.MappedType || type.kind === ts.SyntaxKind.TypeLiteral) { - _this.check(type.getChildAt(0, sourceFile)); - } - } - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - OneLineWalker.prototype.check = function (range, kind) { - var tokenStart = range.end - (kind === undefined ? 1 : kind.length); - if (this.options[kind === undefined ? "brace" : kind] && !tsutils_1.isSameLine(this.sourceFile, range.pos, tokenStart)) { - this.addFailure(tokenStart, range.end, "misplaced " + (kind === undefined ? "opening brace" : "'" + kind + "'"), Lint.Replacement.replaceFromTo(range.pos, tokenStart, this.options.whitespace ? " " : "")); - } - else if (this.options.whitespace && range.pos === tokenStart) { - this.addFailure(tokenStart, range.end, Rule.WHITESPACE_FAILURE_STRING, Lint.Replacement.appendText(range.pos, " ")); - } - }; - return OneLineWalker; -}(Lint.AbstractWalker)); -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/oneVariablePerDeclarationRule.d.ts b/node_modules/tslint/lib/rules/oneVariablePerDeclarationRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/oneVariablePerDeclarationRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/oneVariablePerDeclarationRule.js b/node_modules/tslint/lib/rules/oneVariablePerDeclarationRule.js deleted file mode 100644 index 502f282e0..000000000 --- a/node_modules/tslint/lib/rules/oneVariablePerDeclarationRule.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_IGNORE_FOR_LOOP = "ignore-for-loop"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { ignoreForLoop: this.ruleArguments.indexOf(OPTION_IGNORE_FOR_LOOP) !== -1 }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "one-variable-per-declaration", - description: "Disallows multiple variable definitions in the same declaration statement.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One argument may be optionally provided:\n\n * `", "` allows multiple variable definitions in a for loop declaration."], ["\n One argument may be optionally provided:\n\n * \\`", "\\` allows multiple variable definitions in a for loop declaration."])), OPTION_IGNORE_FOR_LOOP), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_IGNORE_FOR_LOOP], - }, - minLength: 0, - maxLength: 1, - }, - optionExamples: [true, [true, OPTION_IGNORE_FOR_LOOP]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Multiple variable declarations in the same statement are forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isVariableStatement(node) && node.declarationList.declarations.length > 1) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - else if (tsutils_1.isForStatement(node) && !ctx.options.ignoreForLoop) { - var initializer = node.initializer; - if (initializer !== undefined - && initializer.kind === ts.SyntaxKind.VariableDeclarationList - && initializer.declarations.length > 1) { - ctx.addFailureAtNode(initializer, Rule.FAILURE_STRING); - } - } - ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.d.ts b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js deleted file mode 100644 index 672c59bb8..000000000 --- a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALLOW_DECLARATIONS = "allow-declarations"; -var OPTION_ALLOW_NAMED_FUNCTIONS = "allow-named-functions"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "only-arrow-functions", - description: "Disallows traditional (non-arrow) function expressions.", - rationale: "Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Two arguments may be optionally provided:\n\n * `\"", "\"` allows standalone function declarations.\n * `\"", "\"` allows the expression `function foo() {}` but not `function() {}`.\n "], ["\n Two arguments may be optionally provided:\n\n * \\`\"", "\"\\` allows standalone function declarations.\n * \\`\"", "\"\\` allows the expression \\`function foo() {}\\` but not \\`function() {}\\`.\n "])), OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS], - }, - minLength: 0, - maxLength: 1, - }, - optionExamples: [true, [true, OPTION_ALLOW_DECLARATIONS, OPTION_ALLOW_NAMED_FUNCTIONS]], - type: "typescript", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "non-arrow functions are forbidden"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(ruleArguments) { - return { - allowDeclarations: hasOption(OPTION_ALLOW_DECLARATIONS), - allowNamedFunctions: hasOption(OPTION_ALLOW_NAMED_FUNCTIONS), - }; - function hasOption(name) { - return ruleArguments.indexOf(name) !== -1; - } -} -function walk(ctx) { - var sourceFile = ctx.sourceFile, _a = ctx.options, allowDeclarations = _a.allowDeclarations, allowNamedFunctions = _a.allowNamedFunctions; - return ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.FunctionDeclaration: - if (allowDeclarations) { - break; - } - // falls through - case ts.SyntaxKind.FunctionExpression: { - var f = node; - if (!(allowNamedFunctions && f.name !== undefined) && !functionIsExempt(f)) { - ctx.addFailureAtNode(utils.getChildOfKind(node, ts.SyntaxKind.FunctionKeyword, ctx.sourceFile), Rule.FAILURE_STRING); - } - } - } - return ts.forEachChild(node, cb); - }); -} -/** Generator functions and functions using `this` are allowed. */ -function functionIsExempt(node) { - return node.asteriskToken !== undefined || - node.parameters.length !== 0 && utils.isThisParameter(node.parameters[0]) || - node.body !== undefined && ts.forEachChild(node, usesThis) === true; -} -function usesThis(node) { - return node.kind === ts.SyntaxKind.ThisKeyword || !utils.hasOwnThisReference(node) && ts.forEachChild(node, usesThis); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/orderedImportsRule.d.ts b/node_modules/tslint/lib/rules/orderedImportsRule.d.ts deleted file mode 100644 index 5b624b3e0..000000000 --- a/node_modules/tslint/lib/rules/orderedImportsRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static IMPORT_SOURCES_NOT_GROUPED: string; - static IMPORT_SOURCES_UNORDERED: string; - static NAMED_IMPORTS_UNORDERED: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/orderedImportsRule.js b/node_modules/tslint/lib/rules/orderedImportsRule.js deleted file mode 100644 index 51a5ea82d..000000000 --- a/node_modules/tslint/lib/rules/orderedImportsRule.js +++ /dev/null @@ -1,438 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new Walker(sourceFile, this.ruleName, parseOptions(this.ruleArguments))); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "ordered-imports", - description: "Requires that import statements be alphabetized and grouped.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Enforce a consistent ordering for ES6 imports:\n - Named imports must be alphabetized (i.e. \"import {A, B, C} from \"foo\";\")\n - The exact ordering can be controlled by the named-imports-order option.\n - \"longName as name\" imports are ordered by \"longName\".\n - Import sources must be alphabetized within groups, i.e.:\n import * as foo from \"a\";\n import * as bar from \"b\";\n - Groups of imports are delineated by blank lines. You can use these to group imports\n however you like, e.g. by first- vs. third-party or thematically or can you can\n enforce a grouping of third-party, parent directories and the current directory."], ["\n Enforce a consistent ordering for ES6 imports:\n - Named imports must be alphabetized (i.e. \"import {A, B, C} from \"foo\";\")\n - The exact ordering can be controlled by the named-imports-order option.\n - \"longName as name\" imports are ordered by \"longName\".\n - Import sources must be alphabetized within groups, i.e.:\n import * as foo from \"a\";\n import * as bar from \"b\";\n - Groups of imports are delineated by blank lines. You can use these to group imports\n however you like, e.g. by first- vs. third-party or thematically or can you can\n enforce a grouping of third-party, parent directories and the current directory."]))), - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n You may set the `\"import-sources-order\"` option to control the ordering of source\n imports (the `\"foo\"` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"import-sources-order\"` are:\n\n * `\"case-insensitive'`: Correct order is `\"Bar\"`, `\"baz\"`, `\"Foo\"`. (This is the default.)\n * `\"lowercase-first\"`: Correct order is `\"baz\"`, `\"Bar\"`, `\"Foo\"`.\n * `\"lowercase-last\"`: Correct order is `\"Bar\"`, `\"Foo\"`, `\"baz\"`.\n * `\"any\"`: Allow any order.\n\n You may set the `\"grouped-imports\"` option to control the grouping of source\n imports (the `\"foo\"` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"grouped-imports\"` are:\n\n * `false`: Do not enforce grouping. (This is the default.)\n * `true`: Group source imports by `\"bar\"`, `\"../baz\"`, `\"./foo\"`.\n\n You may set the `\"named-imports-order\"` option to control the ordering of named\n imports (the `{A, B, C}` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"named-imports-order\"` are:\n\n * `\"case-insensitive'`: Correct order is `{A, b, C}`. (This is the default.)\n * `\"lowercase-first\"`: Correct order is `{b, A, C}`.\n * `\"lowercase-last\"`: Correct order is `{A, C, b}`.\n * `\"any\"`: Allow any order.\n\n You may set the `\"module-source-path\"` option to control the ordering of imports based full path\n or just the module name\n\n Possible values for `\"module-source-path\"` are:\n\n * `\"full'`: Correct order is `\"./a/Foo\"`, `\"./b/baz\"`, `\"./c/Bar\"`. (This is the default.)\n * `\"basename\"`: Correct order is `\"./c/Bar\"`, `\"./b/baz\"`, `\"./a/Foo\"`.\n\n "], ["\n You may set the \\`\"import-sources-order\"\\` option to control the ordering of source\n imports (the \\`\"foo\"\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"import-sources-order\"\\` are:\n\n * \\`\"case-insensitive'\\`: Correct order is \\`\"Bar\"\\`, \\`\"baz\"\\`, \\`\"Foo\"\\`. (This is the default.)\n * \\`\"lowercase-first\"\\`: Correct order is \\`\"baz\"\\`, \\`\"Bar\"\\`, \\`\"Foo\"\\`.\n * \\`\"lowercase-last\"\\`: Correct order is \\`\"Bar\"\\`, \\`\"Foo\"\\`, \\`\"baz\"\\`.\n * \\`\"any\"\\`: Allow any order.\n\n You may set the \\`\"grouped-imports\"\\` option to control the grouping of source\n imports (the \\`\"foo\"\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"grouped-imports\"\\` are:\n\n * \\`false\\`: Do not enforce grouping. (This is the default.)\n * \\`true\\`: Group source imports by \\`\"bar\"\\`, \\`\"../baz\"\\`, \\`\"./foo\"\\`.\n\n You may set the \\`\"named-imports-order\"\\` option to control the ordering of named\n imports (the \\`{A, B, C}\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"named-imports-order\"\\` are:\n\n * \\`\"case-insensitive'\\`: Correct order is \\`{A, b, C}\\`. (This is the default.)\n * \\`\"lowercase-first\"\\`: Correct order is \\`{b, A, C}\\`.\n * \\`\"lowercase-last\"\\`: Correct order is \\`{A, C, b}\\`.\n * \\`\"any\"\\`: Allow any order.\n\n You may set the \\`\"module-source-path\"\\` option to control the ordering of imports based full path\n or just the module name\n\n Possible values for \\`\"module-source-path\"\\` are:\n\n * \\`\"full'\\`: Correct order is \\`\"./a/Foo\"\\`, \\`\"./b/baz\"\\`, \\`\"./c/Bar\"\\`. (This is the default.)\n * \\`\"basename\"\\`: Correct order is \\`\"./c/Bar\"\\`, \\`\"./b/baz\"\\`, \\`\"./a/Foo\"\\`.\n\n "]))), - options: { - type: "object", - properties: { - "grouped-imports": { - type: "boolean", - }, - "import-sources-order": { - type: "string", - enum: ["case-insensitive", "lowercase-first", "lowercase-last", "any"], - }, - "named-imports-order": { - type: "string", - enum: ["case-insensitive", "lowercase-first", "lowercase-last", "any"], - }, - "module-source-path": { - type: "string", - enum: ["full", "basename"], - }, - }, - additionalProperties: false, - }, - optionExamples: [ - true, - [true, { "import-sources-order": "lowercase-last", "named-imports-order": "lowercase-first" }], - ], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.IMPORT_SOURCES_NOT_GROUPED = "Import sources of different groups must be sorted by: libraries, parent directories, current directory."; - Rule.IMPORT_SOURCES_UNORDERED = "Import sources within a group must be alphabetized."; - Rule.NAMED_IMPORTS_UNORDERED = "Named imports must be alphabetized."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var TRANSFORMS = new Map([ - ["any", function () { return ""; }], - ["case-insensitive", function (x) { return x.toLowerCase(); }], - ["lowercase-first", flipCase], - ["lowercase-last", function (x) { return x; }], - ["full", function (x) { return x; }], - ["basename", function (x) { - if (!ts.isExternalModuleNameRelative(x)) { - return x; - } - var splitIndex = x.lastIndexOf("/"); - if (splitIndex === -1) { - return x; - } - return x.substr(splitIndex + 1); - }], -]); -var ImportType; -(function (ImportType) { - ImportType[ImportType["LIBRARY_IMPORT"] = 1] = "LIBRARY_IMPORT"; - ImportType[ImportType["PARENT_DIRECTORY_IMPORT"] = 2] = "PARENT_DIRECTORY_IMPORT"; - ImportType[ImportType["CURRENT_DIRECTORY_IMPORT"] = 3] = "CURRENT_DIRECTORY_IMPORT"; -})(ImportType || (ImportType = {})); -function parseOptions(ruleArguments) { - var optionSet = ruleArguments[0]; - var _a = optionSet === undefined ? {} : optionSet, _b = _a["grouped-imports"], isGrouped = _b === void 0 ? false : _b, _c = _a["import-sources-order"], sources = _c === void 0 ? "case-insensitive" : _c, _d = _a["named-imports-order"], named = _d === void 0 ? "case-insensitive" : _d, _e = _a["module-source-path"], path = _e === void 0 ? "full" : _e; - return { - groupedImports: isGrouped, - importSourcesOrderTransform: TRANSFORMS.get(sources), - moduleSourcePath: TRANSFORMS.get(path), - namedImportsOrderTransform: TRANSFORMS.get(named), - }; -} -var Walker = /** @class */ (function (_super) { - tslib_1.__extends(Walker, _super); - function Walker() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.importsBlocks = [new ImportsBlock()]; - _this.nextType = ImportType.LIBRARY_IMPORT; - return _this; - } - Object.defineProperty(Walker.prototype, "currentImportsBlock", { - get: function () { - return this.importsBlocks[this.importsBlocks.length - 1]; - }, - enumerable: true, - configurable: true - }); - Walker.prototype.walk = function (sourceFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - this.checkStatement(statement); - } - this.endBlock(); - if (this.options.groupedImports) { - this.checkBlocksGrouping(); - } - }; - Walker.prototype.checkStatement = function (statement) { - if (!(tsutils_1.isImportDeclaration(statement) || tsutils_1.isImportEqualsDeclaration(statement)) || - /\r?\n\r?\n/.test(this.sourceFile.text.slice(statement.getFullStart(), statement.getStart(this.sourceFile)))) { - this.endBlock(); - } - if (tsutils_1.isImportDeclaration(statement)) { - this.checkImportDeclaration(statement); - } - else if (tsutils_1.isImportEqualsDeclaration(statement)) { - this.checkImportEqualsDeclaration(statement); - } - else if (tsutils_1.isModuleDeclaration(statement)) { - var body = moduleDeclarationBody(statement); - if (body !== undefined) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var subStatement = _a[_i]; - this.checkStatement(subStatement); - } - this.endBlock(); - } - } - }; - Walker.prototype.checkImportDeclaration = function (node) { - if (!tsutils_1.isStringLiteral(node.moduleSpecifier)) { - // Ignore grammar error - return; - } - var source = this.options.importSourcesOrderTransform(removeQuotes(node.moduleSpecifier.text)); - this.checkSource(source, node); - var importClause = node.importClause; - if (importClause !== undefined && importClause.namedBindings !== undefined && tsutils_1.isNamedImports(importClause.namedBindings)) { - this.checkNamedImports(importClause.namedBindings); - } - }; - Walker.prototype.checkImportEqualsDeclaration = function (node) { - // only allowed `import x = require('y');` - var moduleReference = node.moduleReference; - if (!tsutils_1.isExternalModuleReference(moduleReference)) { - return; - } - var expression = moduleReference.expression; - if (expression === undefined || !tsutils_1.isStringLiteral(expression)) { - return; - } - var source = this.options.importSourcesOrderTransform(removeQuotes(expression.text)); - this.checkSource(source, node); - }; - Walker.prototype.checkSource = function (source, node) { - var currentSource = this.options.moduleSourcePath(source); - var previousSource = this.currentImportsBlock.getLastImportSource(); - this.currentImportsBlock.addImportDeclaration(this.sourceFile, node, currentSource); - if (previousSource !== null && compare(currentSource, previousSource) === -1) { - this.lastFix = []; - this.addFailureAtNode(node, Rule.IMPORT_SOURCES_UNORDERED, this.lastFix); - } - }; - Walker.prototype.endBlock = function () { - if (this.lastFix !== undefined) { - var replacement = this.currentImportsBlock.getReplacement(); - if (replacement !== undefined) { - this.lastFix.push(replacement); - } - this.lastFix = undefined; - } - this.importsBlocks.push(new ImportsBlock()); - }; - Walker.prototype.checkNamedImports = function (node) { - var _this = this; - var imports = node.elements; - var pair = findUnsortedPair(imports, this.options.namedImportsOrderTransform); - if (pair !== undefined) { - var a = pair[0], b = pair[1]; - var sortedDeclarations = sortByKey(imports, function (x) { - return _this.options.namedImportsOrderTransform(x.getText()); - }).map(function (x) { return x.getText(); }); - // replace in reverse order to preserve earlier offsets - for (var i = imports.length - 1; i >= 0; i--) { - var start = imports[i].getStart(); - var length = imports[i].getText().length; - // replace the named imports one at a time to preserve whitespace - this.currentImportsBlock.replaceNamedImports(start, length, sortedDeclarations[i]); - } - this.lastFix = []; - this.addFailure(a.getStart(), b.getEnd(), Rule.NAMED_IMPORTS_UNORDERED, this.lastFix); - } - }; - Walker.prototype.checkBlocksGrouping = function () { - this.importsBlocks.some(this.checkBlockGroups, this); - }; - Walker.prototype.checkBlockGroups = function (importsBlock) { - var oddImportDeclaration = this.getOddImportDeclaration(importsBlock); - if (oddImportDeclaration !== undefined) { - this.addFailureAtNode(oddImportDeclaration.node, Rule.IMPORT_SOURCES_NOT_GROUPED, this.getReplacements()); - return true; - } - return false; - }; - Walker.prototype.getOddImportDeclaration = function (importsBlock) { - var importDeclarations = importsBlock.getImportDeclarations(); - if (importDeclarations.length === 0) { - return undefined; - } - var type = importDeclarations[0].type; - if (type < this.nextType) { - return importDeclarations[0]; - } - else { - this.nextType = type; - return importDeclarations.find(function (importDeclaration) { return importDeclaration.type !== type; }); - } - }; - Walker.prototype.getReplacements = function () { - var _a; - var importDeclarationsList = this.importsBlocks - .map(function (block) { return block.getImportDeclarations(); }) - .filter(function (imports) { return imports.length > 0; }); - var allImportDeclarations = (_a = []).concat.apply(_a, importDeclarationsList); - var replacements = this.getReplacementsForExistingImports(importDeclarationsList); - var startOffset = allImportDeclarations.length === 0 ? 0 : allImportDeclarations[0].nodeStartOffset; - replacements.push(Lint.Replacement.appendText(startOffset, this.getGroupedImports(allImportDeclarations))); - return replacements; - }; - Walker.prototype.getReplacementsForExistingImports = function (importDeclarationsList) { - var _this = this; - return importDeclarationsList.map(function (items, index) { - var start = items[0].nodeStartOffset; - if (index > 0) { - var prevItems = importDeclarationsList[index - 1]; - var last = prevItems[prevItems.length - 1]; - if (/[\r\n]+/.test(_this.sourceFile.text.slice(last.nodeEndOffset, start))) { - // remove whitespace between blocks - start = last.nodeEndOffset; - } - } - return Lint.Replacement.deleteFromTo(start, items[items.length - 1].nodeEndOffset); - }); - }; - Walker.prototype.getGroupedImports = function (importDeclarations) { - return [ImportType.LIBRARY_IMPORT, ImportType.PARENT_DIRECTORY_IMPORT, ImportType.CURRENT_DIRECTORY_IMPORT] - .map(function (type) { - var imports = importDeclarations.filter(function (importDeclaration) { return importDeclaration.type === type; }); - return getSortedImportDeclarationsAsText(imports); - }) - .filter(function (text) { return text.length > 0; }) - .join(this.getEolChar()); - }; - Walker.prototype.getEolChar = function () { - var lineEnd = this.sourceFile.getLineEndOfPosition(0); - var newLine; - if (lineEnd > 0) { - if (lineEnd > 1 && this.sourceFile.text[lineEnd - 1] === "\r") { - newLine = "\r\n"; - } - else if (this.sourceFile.text[lineEnd] === "\n") { - newLine = "\n"; - } - } - return newLine === undefined ? ts.sys.newLine : newLine; - }; - return Walker; -}(Lint.AbstractWalker)); -var ImportsBlock = /** @class */ (function () { - function ImportsBlock() { - this.importDeclarations = []; - } - ImportsBlock.prototype.addImportDeclaration = function (sourceFile, node, sourcePath) { - var start = this.getStartOffset(node); - var end = this.getEndOffset(sourceFile, node); - var text = sourceFile.text.substring(start, end); - var type = this.getImportType(sourcePath); - if (start > node.getStart() || end === 0) { - // skip block if any statements don't end with a newline to simplify implementation - this.importDeclarations = []; - return; - } - this.importDeclarations.push({ - node: node, - nodeEndOffset: end, - nodeStartOffset: start, - sourcePath: sourcePath, - text: text, - type: type, - }); - }; - ImportsBlock.prototype.getImportDeclarations = function () { - return this.importDeclarations; - }; - // replaces the named imports on the most recent import declaration - ImportsBlock.prototype.replaceNamedImports = function (fileOffset, length, replacement) { - var importDeclaration = this.getLastImportDeclaration(); - if (importDeclaration === undefined) { - // nothing to replace. This can happen if the block is skipped - return; - } - var start = fileOffset - importDeclaration.nodeStartOffset; - if (start < 0 || start + length > importDeclaration.node.getEnd()) { - throw new Error("Unexpected named import position"); - } - var initialText = importDeclaration.text; - importDeclaration.text = initialText.substring(0, start) + replacement + initialText.substring(start + length); - }; - ImportsBlock.prototype.getLastImportSource = function () { - if (this.importDeclarations.length === 0) { - return null; - } - return this.getLastImportDeclaration().sourcePath; - }; - // creates a Lint.Replacement object with ordering fixes for the entire block - ImportsBlock.prototype.getReplacement = function () { - if (this.importDeclarations.length === 0) { - return undefined; - } - var fixedText = getSortedImportDeclarationsAsText(this.importDeclarations); - var start = this.importDeclarations[0].nodeStartOffset; - var end = this.getLastImportDeclaration().nodeEndOffset; - return new Lint.Replacement(start, end - start, fixedText); - }; - // gets the offset immediately after the end of the previous declaration to include comment above - ImportsBlock.prototype.getStartOffset = function (node) { - if (this.importDeclarations.length === 0) { - return node.getStart(); - } - return this.getLastImportDeclaration().nodeEndOffset; - }; - // gets the offset of the end of the import's line, including newline, to include comment to the right - ImportsBlock.prototype.getEndOffset = function (sourceFile, node) { - return sourceFile.text.indexOf("\n", node.end) + 1; - }; - ImportsBlock.prototype.getLastImportDeclaration = function () { - return this.importDeclarations[this.importDeclarations.length - 1]; - }; - ImportsBlock.prototype.getImportType = function (sourcePath) { - if (sourcePath.charAt(0) === ".") { - if (sourcePath.charAt(1) === ".") { - return ImportType.PARENT_DIRECTORY_IMPORT; - } - else { - return ImportType.CURRENT_DIRECTORY_IMPORT; - } - } - else { - return ImportType.LIBRARY_IMPORT; - } - }; - return ImportsBlock; -}()); -// Convert aBcD --> AbCd -function flipCase(str) { - return Array.from(str).map(function (char) { - if (char >= "a" && char <= "z") { - return char.toUpperCase(); - } - else if (char >= "A" && char <= "Z") { - return char.toLowerCase(); - } - return char; - }).join(""); -} -// After applying a transformation, are the nodes sorted according to the text they contain? -// If not, return the pair of nodes which are out of order. -function findUnsortedPair(xs, transform) { - for (var i = 1; i < xs.length; i++) { - if (transform(xs[i].getText()) < transform(xs[i - 1].getText())) { - return [xs[i - 1], xs[i]]; - } - } - return undefined; -} -function compare(a, b) { - function isLow(value) { - return value[0] === "." || value[0] === "/"; - } - if (isLow(a) && !isLow(b)) { - return 1; - } - else if (!isLow(a) && isLow(b)) { - return -1; - } - else if (a > b) { - return 1; - } - else if (a < b) { - return -1; - } - return 0; -} -function removeQuotes(value) { - // strip out quotes - if (value.length > 1 && (value[0] === "'" || value[0] === "\"")) { - value = value.substr(1, value.length - 2); - } - return value; -} -function getSortedImportDeclarationsAsText(importDeclarations) { - var sortedDeclarations = sortByKey(importDeclarations.slice(), function (x) { return x.sourcePath; }); - return sortedDeclarations.map(function (x) { return x.text; }).join(""); -} -function sortByKey(xs, getSortKey) { - return xs.slice().sort(function (a, b) { return compare(getSortKey(a), getSortKey(b)); }); -} -function moduleDeclarationBody(node) { - var body = node.body; - while (body !== undefined && body.kind === ts.SyntaxKind.ModuleDeclaration) { - body = body.body; - } - return body !== undefined && body.kind === ts.SyntaxKind.ModuleBlock ? body : undefined; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/preferConditionalExpressionRule.d.ts b/node_modules/tslint/lib/rules/preferConditionalExpressionRule.d.ts deleted file mode 100644 index bf0307d56..000000000 --- a/node_modules/tslint/lib/rules/preferConditionalExpressionRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(assigned: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferConditionalExpressionRule.js b/node_modules/tslint/lib/rules/preferConditionalExpressionRule.js deleted file mode 100644 index cd7a5ea33..000000000 --- a/node_modules/tslint/lib/rules/preferConditionalExpressionRule.js +++ /dev/null @@ -1,112 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_CHECK_ELSE_IF = "check-else-if"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (assigned) { - return "Use a conditional expression instead of assigning to '" + assigned + "' in multiple places."; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - checkElseIf: this.ruleArguments.indexOf(OPTION_CHECK_ELSE_IF) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-conditional-expression", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Recommends to use a conditional expression instead of assigning to the same thing in each branch of an if statement."], ["\n Recommends to use a conditional expression instead of assigning to the same thing in each branch of an if statement."]))), - rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n This reduces duplication and can eliminate an unnecessary variable declaration."], ["\n This reduces duplication and can eliminate an unnecessary variable declaration."]))), - optionsDescription: "If `" + OPTION_CHECK_ELSE_IF + "` is specified, the rule also checks nested if-else-if statements.", - options: { - type: "string", - enum: [OPTION_CHECK_ELSE_IF], - }, - optionExamples: [true, [true, OPTION_CHECK_ELSE_IF]], - type: "functionality", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, checkElseIf = ctx.options.checkElseIf; - return ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isIfStatement(node)) { - var assigned = detectAssignment(node, sourceFile, checkElseIf); - if (assigned !== undefined) { - ctx.addFailureAtNode(node.getChildAt(0, sourceFile), Rule.FAILURE_STRING(assigned.getText(sourceFile))); - } - if (assigned !== undefined || !checkElseIf) { - // Be careful not to fail again for the "else if" - do { - ts.forEachChild(node.expression, cb); - ts.forEachChild(node.thenStatement, cb); - if (node.elseStatement === undefined) { - return; - } - node = node.elseStatement; - while (tsutils_1.isBlock(node) && node.statements.length === 1) { - node = node.statements[0]; - } - } while (tsutils_1.isIfStatement(node)); - } - } - return ts.forEachChild(node, cb); - }); -} -/** - * @param inElse `undefined` when this is the top level if statement, `false` when inside the then branch, `true` when inside else - */ -function detectAssignment(statement, sourceFile, checkElseIf, inElse) { - if (tsutils_1.isIfStatement(statement)) { - if (inElse === false || !checkElseIf && inElse || statement.elseStatement === undefined) { - return undefined; - } - var then = detectAssignment(statement.thenStatement, sourceFile, checkElseIf, false); - if (then === undefined) { - return undefined; - } - var elze = detectAssignment(statement.elseStatement, sourceFile, checkElseIf, true); - return elze !== undefined && nodeEquals(then, elze, sourceFile) ? then : undefined; - } - else if (tsutils_1.isBlock(statement)) { - return statement.statements.length === 1 - ? detectAssignment(statement.statements[0], sourceFile, checkElseIf, inElse) - : undefined; - } - else if (tsutils_1.isExpressionStatement(statement) && tsutils_1.isBinaryExpression(statement.expression)) { - var _a = statement.expression, kind = _a.operatorToken.kind, left = _a.left, right = _a.right; - return kind === ts.SyntaxKind.EqualsToken && tsutils_1.isSameLine(sourceFile, right.getStart(sourceFile), right.end) ? left : undefined; - } - else { - return undefined; - } -} -function nodeEquals(a, b, sourceFile) { - return a.getText(sourceFile) === b.getText(sourceFile); -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/preferConstRule.d.ts b/node_modules/tslint/lib/rules/preferConstRule.d.ts deleted file mode 100644 index 66430863b..000000000 --- a/node_modules/tslint/lib/rules/preferConstRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_FACTORY(identifier: string, blockScoped: boolean): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferConstRule.js b/node_modules/tslint/lib/rules/preferConstRule.js deleted file mode 100644 index 5d88718de..000000000 --- a/node_modules/tslint/lib/rules/preferConstRule.js +++ /dev/null @@ -1,316 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils = require("tsutils"); -var OPTION_DESTRUCTURING_ALL = "all"; -var OPTION_DESTRUCTURING_ANY = "any"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_FACTORY = function (identifier, blockScoped) { - return "Identifier '" + identifier + "' is never reassigned; use 'const' instead of '" + (blockScoped ? "let" : "var") + "'."; - }; - Rule.prototype.apply = function (sourceFile) { - var options = { - destructuringAll: this.ruleArguments.length !== 0 && - this.ruleArguments[0].destructuring === OPTION_DESTRUCTURING_ALL, - }; - var preferConstWalker = new PreferConstWalker(sourceFile, this.ruleName, options); - return this.applyWithWalker(preferConstWalker); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-const", - description: "Requires that variable declarations use `const` instead of `let` and `var` if possible.", - descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If a variable is only assigned to once when it is declared, it should be declared using 'const'"], ["\n If a variable is only assigned to once when it is declared, it should be declared using 'const'"]))), - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n An optional object containing the property \"destructuring\" with two possible values:\n\n * \"", "\" (default) - If any variable in destructuring can be const, this rule warns for those variables.\n * \"", "\" - Only warns if all variables in destructuring can be const."], ["\n An optional object containing the property \"destructuring\" with two possible values:\n\n * \"", "\" (default) - If any variable in destructuring can be const, this rule warns for those variables.\n * \"", "\" - Only warns if all variables in destructuring can be const."])), OPTION_DESTRUCTURING_ANY, OPTION_DESTRUCTURING_ALL), - options: { - type: "object", - properties: { - destructuring: { - type: "string", - enum: [OPTION_DESTRUCTURING_ALL, OPTION_DESTRUCTURING_ANY], - }, - }, - }, - optionExamples: [ - true, - [true, { destructuring: OPTION_DESTRUCTURING_ALL }], - ], - type: "maintainability", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var Scope = /** @class */ (function () { - function Scope(functionScope) { - this.variables = new Map(); - this.reassigned = new Set(); - // if no functionScope is provided we are in the process of creating a new function scope, which for consistency links to itself - this.functionScope = functionScope === undefined ? this : functionScope; - } - Scope.prototype.addVariable = function (identifier, declarationInfo, destructuringInfo) { - // block scoped variables go to the block scope, function scoped variables to the containing function scope - var scope = declarationInfo.isBlockScoped ? this : this.functionScope; - scope.variables.set(identifier.text, { - declarationInfo: declarationInfo, - destructuringInfo: destructuringInfo, - identifier: identifier, - reassigned: false, - }); - }; - return Scope; -}()); -var PreferConstWalker = /** @class */ (function (_super) { - tslib_1.__extends(PreferConstWalker, _super); - function PreferConstWalker() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.scope = new Scope(); - return _this; - } - PreferConstWalker.prototype.walk = function (sourceFile) { - var _this = this; - // don't check anything on declaration files - if (sourceFile.isDeclarationFile) { - return; - } - this.scope = new Scope(); - var cb = function (node) { - var savedScope = _this.scope; - var boundary = utils.isScopeBoundary(node); - if (boundary !== 0 /* None */) { - if (boundary === 1 /* Function */) { - if (node.kind === ts.SyntaxKind.ModuleDeclaration && utils.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) { - // don't check ambient namespaces - return; - } - _this.scope = new Scope(); - if (utils.isFunctionDeclaration(node) || - utils.isMethodDeclaration(node) || - utils.isFunctionExpression(node) || - utils.isArrowFunction(node) || - utils.isConstructorDeclaration(node)) { - // special handling for function parameters - // each parameter initializer can only reassign preceding parameters of variables of the containing scope - if (node.body !== undefined) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - cb(param); - _this.settle(savedScope); - } - cb(node.body); - _this.onScopeEnd(savedScope); - } - _this.scope = savedScope; - return; - } - } - else { - _this.scope = new Scope(_this.scope.functionScope); - if ((utils.isForInStatement(node) || utils.isForOfStatement(node)) && - node.initializer.kind !== ts.SyntaxKind.VariableDeclarationList) { - _this.handleExpression(node.initializer); - } - } - } - if (node.kind === ts.SyntaxKind.VariableDeclarationList) { - _this.handleVariableDeclaration(node); - } - else if (node.kind === ts.SyntaxKind.CatchClause) { - if (node.variableDeclaration !== undefined) { - _this.handleBindingName(node.variableDeclaration.name, { - canBeConst: false, - isBlockScoped: true, - }); - } - } - else if (node.kind === ts.SyntaxKind.Parameter) { - if (node.parent.kind !== ts.SyntaxKind.IndexSignature) { - _this.handleBindingName(node.name, { - canBeConst: false, - isBlockScoped: true, - }); - } - } - else if (utils.isPostfixUnaryExpression(node) || - utils.isPrefixUnaryExpression(node) && - (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator === ts.SyntaxKind.MinusMinusToken)) { - if (utils.isIdentifier(node.operand)) { - _this.scope.reassigned.add(node.operand.text); - } - } - else if (utils.isBinaryExpression(node) && utils.isAssignmentKind(node.operatorToken.kind)) { - _this.handleExpression(node.left); - } - if (boundary !== 0 /* None */) { - ts.forEachChild(node, cb); - _this.onScopeEnd(savedScope); - _this.scope = savedScope; - } - else { - return ts.forEachChild(node, cb); - } - }; - if (ts.isExternalModule(sourceFile)) { - ts.forEachChild(sourceFile, cb); - this.onScopeEnd(); - } - else { - return ts.forEachChild(sourceFile, cb); - } - }; - PreferConstWalker.prototype.handleExpression = function (node) { - switch (node.kind) { - case ts.SyntaxKind.Identifier: - this.scope.reassigned.add(node.text); - break; - case ts.SyntaxKind.ParenthesizedExpression: - this.handleExpression(node.expression); - break; - case ts.SyntaxKind.ArrayLiteralExpression: - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (element.kind === ts.SyntaxKind.SpreadElement) { - this.handleExpression(element.expression); - } - else { - this.handleExpression(element); - } - } - break; - case ts.SyntaxKind.ObjectLiteralExpression: - for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { - var property = _c[_b]; - switch (property.kind) { - case ts.SyntaxKind.ShorthandPropertyAssignment: - this.scope.reassigned.add(property.name.text); - break; - case ts.SyntaxKind.SpreadAssignment: - if (property.name !== undefined) { - this.scope.reassigned.add(property.name.text); - } - else { - // handle `...(variable)` - this.handleExpression(property.expression); - } - break; - default: - this.handleExpression(property.initializer); - } - } - } - }; - PreferConstWalker.prototype.handleBindingName = function (name, declarationInfo) { - var _this = this; - if (name.kind === ts.SyntaxKind.Identifier) { - this.scope.addVariable(name, declarationInfo); - } - else { - var destructuringInfo_1 = { - reassignedSiblings: false, - }; - utils.forEachDestructuringIdentifier(name, function (declaration) { return _this.scope.addVariable(declaration.name, declarationInfo, destructuringInfo_1); }); - } - }; - PreferConstWalker.prototype.handleVariableDeclaration = function (declarationList) { - var declarationInfo; - var kind = utils.getVariableDeclarationKind(declarationList); - if (kind === 2 /* Const */ || - utils.hasModifier(declarationList.parent.modifiers, ts.SyntaxKind.ExportKeyword, ts.SyntaxKind.DeclareKeyword)) { - declarationInfo = { - canBeConst: false, - isBlockScoped: kind !== 0 /* Var */, - }; - } - else { - declarationInfo = { - allInitialized: declarationList.parent.kind === ts.SyntaxKind.ForOfStatement || - declarationList.parent.kind === ts.SyntaxKind.ForInStatement || - declarationList.declarations.every(function (declaration) { return declaration.initializer !== undefined; }), - canBeConst: true, - declarationList: declarationList, - isBlockScoped: kind === 1 /* Let */, - isForLoop: declarationList.parent.kind === ts.SyntaxKind.ForStatement || - declarationList.parent.kind === ts.SyntaxKind.ForOfStatement, - reassignedSiblings: false, - }; - } - for (var _i = 0, _a = declarationList.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - this.handleBindingName(declaration.name, declarationInfo); - } - }; - PreferConstWalker.prototype.settle = function (parent) { - var _a = this.scope, variables = _a.variables, reassigned = _a.reassigned; - reassigned.forEach(function (name) { - var variableInfo = variables.get(name); - if (variableInfo !== undefined) { - if (variableInfo.declarationInfo.canBeConst) { - variableInfo.reassigned = true; - variableInfo.declarationInfo.reassignedSiblings = true; - if (variableInfo.destructuringInfo !== undefined) { - variableInfo.destructuringInfo.reassignedSiblings = true; - } - } - } - else if (parent !== undefined) { - // if the reassigned variable was not declared in this scope we defer to the parent scope - parent.reassigned.add(name); - } - }); - reassigned.clear(); - }; - PreferConstWalker.prototype.onScopeEnd = function (parent) { - var _this = this; - this.settle(parent); - var appliedFixes = new Set(); - this.scope.variables.forEach(function (info, name) { - if (info.declarationInfo.canBeConst && - !info.reassigned && - // don't add failures for reassigned variables in for loop initializer - !(info.declarationInfo.reassignedSiblings && info.declarationInfo.isForLoop) && - // if {destructuring: "all"} is set, only add a failure if all variables in a destructuring assignment can be const - (!_this.options.destructuringAll || - info.destructuringInfo === undefined || - !info.destructuringInfo.reassignedSiblings)) { - var fix = void 0; - // only apply fixes if the VariableDeclarationList has no reassigned variables - // and the variable is block scoped aka `let` and initialized - if (info.declarationInfo.allInitialized && - !info.declarationInfo.reassignedSiblings && - info.declarationInfo.isBlockScoped && - !appliedFixes.has(info.declarationInfo.declarationList)) { - fix = new Lint.Replacement(info.declarationInfo.declarationList.getStart(_this.sourceFile), 3, "const"); - // add only one fixer per VariableDeclarationList - appliedFixes.add(info.declarationInfo.declarationList); - } - _this.addFailureAtNode(info.identifier, Rule.FAILURE_STRING_FACTORY(name, info.declarationInfo.isBlockScoped), fix); - } - }); - }; - return PreferConstWalker; -}(Lint.AbstractWalker)); -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/preferForOfRule.d.ts b/node_modules/tslint/lib/rules/preferForOfRule.d.ts deleted file mode 100644 index bd1fcddd6..000000000 --- a/node_modules/tslint/lib/rules/preferForOfRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferForOfRule.js b/node_modules/tslint/lib/rules/preferForOfRule.js deleted file mode 100644 index a738d3774..000000000 --- a/node_modules/tslint/lib/rules/preferForOfRule.js +++ /dev/null @@ -1,166 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../language/utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-for-of", - description: "Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.", - rationale: "A for(... of ...) loop is easier to implement and read when the index is not needed.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Expected a 'for-of' loop instead of a 'for' loop with this simple iteration"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - var variables; - return ts.forEachChild(sourceFile, function cb(node) { - if (utils.isForStatement(node)) { - visitForStatement(node); - } - return ts.forEachChild(node, cb); - }); - function visitForStatement(node) { - var arrayNodeInfo = getForLoopHeaderInfo(node); - if (arrayNodeInfo === undefined) { - return; - } - var indexVariable = arrayNodeInfo.indexVariable, arrayExpr = arrayNodeInfo.arrayExpr; - if (variables === undefined) { - variables = utils.collectVariableUsage(sourceFile); - } - for (var _i = 0, _a = variables.get(indexVariable).uses; _i < _a.length; _i++) { - var location = _a[_i].location; - if (location.pos < node.initializer.end || location.pos >= node.end || // bail out on use outside of for loop - location.pos >= node.statement.pos && // only check uses in loop body - isNonSimpleIncrementorUse(location, arrayExpr, sourceFile)) { - return; - } - } - ctx.addFailure(node.getStart(sourceFile), node.statement.pos, Rule.FAILURE_STRING); - } -} -function isNonSimpleIncrementorUse(node, arrayExpr, sourceFile) { - // check if iterator is used for something other than reading data from array - var parent = node.parent; - return !utils.isElementAccessExpression(parent) - // `a[i] = ...` or similar - || utils.isReassignmentTarget(parent) - // `b[i]` - || !nodeEquals(arrayExpr, utils_1.unwrapParentheses(parent.expression), sourceFile); -} -function nodeEquals(a, b, sourceFile) { - return a.getText(sourceFile) === b.getText(sourceFile); -} -// returns the iterator and array of a `for` loop if the `for` loop is basic. -function getForLoopHeaderInfo(forLoop) { - var initializer = forLoop.initializer, condition = forLoop.condition, incrementor = forLoop.incrementor; - if (initializer === undefined || condition === undefined || incrementor === undefined) { - return undefined; - } - // Must start with `var i = 0;` or `let i = 0;` - if (!utils.isVariableDeclarationList(initializer) || initializer.declarations.length !== 1) { - return undefined; - } - var _a = initializer.declarations[0], indexVariable = _a.name, indexInit = _a.initializer; - if (indexVariable.kind !== ts.SyntaxKind.Identifier || indexInit === undefined || !isNumber(indexInit, "0")) { - return undefined; - } - // Must end with `i++` - if (!isIncremented(incrementor, indexVariable.text)) { - return undefined; - } - // Condition must be `i < arr.length;` - if (!utils.isBinaryExpression(condition)) { - return undefined; - } - var left = condition.left, operatorToken = condition.operatorToken, right = condition.right; - if (!isIdentifierNamed(left, indexVariable.text) || - operatorToken.kind !== ts.SyntaxKind.LessThanToken || - !utils.isPropertyAccessExpression(right)) { - return undefined; - } - var arrayExpr = right.expression, name = right.name; - if (name.text !== "length") { - return undefined; - } - return { indexVariable: indexVariable, arrayExpr: arrayExpr }; -} -function isIncremented(node, indexVariableName) { - switch (node.kind) { - case ts.SyntaxKind.PrefixUnaryExpression: - case ts.SyntaxKind.PostfixUnaryExpression: { - var _a = node, operator = _a.operator, operand = _a.operand; - // `++x` or `x++` - return operator === ts.SyntaxKind.PlusPlusToken && isVar(operand); - } - case ts.SyntaxKind.BinaryExpression: - var _b = node, operatorToken = _b.operatorToken, updatedVar = _b.left, rhs = _b.right; - if (!isVar(updatedVar)) { - return false; - } - switch (operatorToken.kind) { - case ts.SyntaxKind.PlusEqualsToken: - // x += 1 - return isOne(rhs); - case ts.SyntaxKind.EqualsToken: { - if (!utils.isBinaryExpression(rhs)) { - return false; - } - var rhsOp = rhs.operatorToken, left = rhs.left, right = rhs.right; - // `x = 1 + x` or `x = x + 1` - return rhsOp.kind === ts.SyntaxKind.PlusToken && (isVar(left) && isOne(right) || isOne(left) && isVar(right)); - } - default: - return false; - } - default: - return false; - } - function isVar(id) { - return isIdentifierNamed(id, indexVariableName); - } -} -function isIdentifierNamed(node, text) { - return utils.isIdentifier(node) && node.text === text; -} -function isOne(node) { - return isNumber(node, "1"); -} -function isNumber(node, value) { - return utils.isNumericLiteral(node) && node.text === value; -} diff --git a/node_modules/tslint/lib/rules/preferFunctionOverMethodRule.d.ts b/node_modules/tslint/lib/rules/preferFunctionOverMethodRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/preferFunctionOverMethodRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferFunctionOverMethodRule.js b/node_modules/tslint/lib/rules/preferFunctionOverMethodRule.js deleted file mode 100644 index c18d09317..000000000 --- a/node_modules/tslint/lib/rules/preferFunctionOverMethodRule.js +++ /dev/null @@ -1,111 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALLOW_PUBLIC = "allow-public"; -var OPTION_ALLOW_PROTECTED = "allow-protected"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new PreferFunctionOverMethodWalker(sourceFile, this.ruleName, { - allowProtected: this.ruleArguments.indexOf(OPTION_ALLOW_PROTECTED) !== -1, - allowPublic: this.ruleArguments.indexOf(OPTION_ALLOW_PUBLIC) !== -1, - })); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-function-over-method", - description: "Warns for class methods that do not use 'this'.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n \"", "\" excludes checking of public methods.\n \"", "\" excludes checking of protected methods."], ["\n \"", "\" excludes checking of public methods.\n \"", "\" excludes checking of protected methods."])), OPTION_ALLOW_PUBLIC, OPTION_ALLOW_PROTECTED), - options: { - type: "string", - enum: [OPTION_ALLOW_PUBLIC, OPTION_ALLOW_PROTECTED], - }, - optionExamples: [ - true, - [true, OPTION_ALLOW_PUBLIC, OPTION_ALLOW_PROTECTED], - ], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Class method does not use 'this'. Use a function instead."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var PreferFunctionOverMethodWalker = /** @class */ (function (_super) { - tslib_1.__extends(PreferFunctionOverMethodWalker, _super); - function PreferFunctionOverMethodWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - PreferFunctionOverMethodWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - if (tsutils_1.isMethodDeclaration(node) && !_this.isExempt(node)) { - // currentScope is always undefined here, so we don't need to save it and just set it to undefined afterwards - _this.currentScope = { - isThisUsed: false, - name: tsutils_1.getPropertyName(node.name), - }; - ts.forEachChild(node, cb); - if (!_this.currentScope.isThisUsed) { - _this.addFailureAtNode(node.name, Rule.FAILURE_STRING); - } - _this.currentScope = undefined; - } - else if (tsutils_1.hasOwnThisReference(node)) { - var scope = _this.currentScope; - _this.currentScope = undefined; - ts.forEachChild(node, cb); - _this.currentScope = scope; - } - else if (_this.currentScope !== undefined && - (node.kind === ts.SyntaxKind.ThisKeyword && !isRecursiveCall(node, _this.currentScope.name) || - node.kind === ts.SyntaxKind.SuperKeyword)) { - _this.currentScope.isThisUsed = true; - } - else { - return ts.forEachChild(node, cb); - } - }; - return ts.forEachChild(sourceFile, cb); - }; - PreferFunctionOverMethodWalker.prototype.isExempt = function (node) { - // TODO: handle the override keyword once it lands in the language - return node.body === undefined || // exclude abstract methods and overload signatures - // exclude object methods - node.parent.kind !== ts.SyntaxKind.ClassDeclaration && node.parent.kind !== ts.SyntaxKind.ClassExpression || - tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword) || - this.options.allowProtected && tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword) || - this.options.allowPublic && (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword) || - !tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword)); - }; - return PreferFunctionOverMethodWalker; -}(Lint.AbstractWalker)); -function isRecursiveCall(node, name) { - return name !== undefined && - node.parent.kind === ts.SyntaxKind.PropertyAccessExpression && - node.parent.name.text === name; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/preferMethodSignatureRule.d.ts b/node_modules/tslint/lib/rules/preferMethodSignatureRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/preferMethodSignatureRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferMethodSignatureRule.js b/node_modules/tslint/lib/rules/preferMethodSignatureRule.js deleted file mode 100644 index 4a22ff3ed..000000000 --- a/node_modules/tslint/lib/rules/preferMethodSignatureRule.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-method-signature", - description: "Prefer `foo(): void` over `foo: () => void` in interfaces and types.", - hasFix: true, - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use a method signature instead of a property signature of function type."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isPropertySignature(node)) { - var type = node.type; - if (type !== undefined && tsutils_1.isFunctionTypeNode(type)) { - ctx.addFailureAtNode(node.name, Rule.FAILURE_STRING, type.type === undefined ? undefined : [ - Lint.Replacement.deleteFromTo(type.pos - 1, type.getStart()), - Lint.Replacement.replaceFromTo(type.parameters.end + 1, type.type.pos, ":"), - ]); - } - } - return ts.forEachChild(node, cb); - }); -} diff --git a/node_modules/tslint/lib/rules/preferObjectSpreadRule.d.ts b/node_modules/tslint/lib/rules/preferObjectSpreadRule.d.ts deleted file mode 100644 index 7b6f9ea32..000000000 --- a/node_modules/tslint/lib/rules/preferObjectSpreadRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static ASSIGNMENT_FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferObjectSpreadRule.js b/node_modules/tslint/lib/rules/preferObjectSpreadRule.js deleted file mode 100644 index 8cd5005be..000000000 --- a/node_modules/tslint/lib/rules/preferObjectSpreadRule.js +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-object-spread", - description: "Enforces the use of the ES2015 object spread operator over `Object.assign()` where appropriate.", - rationale: "Object spread allows for better type checking and inference.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - hasFix: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use the object spread operator instead."; - Rule.ASSIGNMENT_FAILURE_STRING = "'Object.assign' returns the first argument. Prefer object spread if you want a new object."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isCallExpression(node) && node.arguments.length !== 0 && - tsutils_1.isPropertyAccessExpression(node.expression) && node.expression.name.text === "assign" && - tsutils_1.isIdentifier(node.expression.expression) && node.expression.expression.text === "Object" && - !ts.isFunctionLike(node.arguments[0]) && - // Object.assign(...someArray) cannot be written as object spread - !node.arguments.some(tsutils_1.isSpreadElement) && - /** - * @TODO - * Remove !node.arguments.some(isThisKeyword) when typescript get's - * support for spread types. - * PR: https://github.com/Microsoft/TypeScript/issues/10727 - */ - !node.arguments.some(isThisKeyword)) { - if (node.arguments[0].kind === ts.SyntaxKind.ObjectLiteralExpression) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING, createFix(node, ctx.sourceFile)); - } - else if (tsutils_1.isExpressionValueUsed(node) && !tsutils_1.hasSideEffects(node.arguments[0], 2 /* Constructor */)) { - ctx.addFailureAtNode(node, Rule.ASSIGNMENT_FAILURE_STRING, createFix(node, ctx.sourceFile)); - } - } - return ts.forEachChild(node, cb); - }); -} -function createFix(node, sourceFile) { - var args = node.arguments; - var objectNeedsParens = node.parent.kind === ts.SyntaxKind.ArrowFunction; - var fix = [ - Lint.Replacement.replaceFromTo(node.getStart(sourceFile), args[0].getStart(sourceFile), (objectNeedsParens ? "(" : "") + "{"), - new Lint.Replacement(node.end - 1, 1, "}" + (objectNeedsParens ? ")" : "")), - ]; - for (var i = 0; i < args.length; ++i) { - var arg = args[i]; - if (tsutils_1.isObjectLiteralExpression(arg)) { - if (arg.properties.length === 0) { - var end = arg.end; - if (i !== args.length - 1) { - end = args[i + 1].getStart(sourceFile); - } - else if (args.hasTrailingComma) { - end = args.end; - } - // remove empty object iteral and the following comma if exists - fix.push(Lint.Replacement.deleteFromTo(arg.getStart(sourceFile), end)); - } - else { - fix.push( - // remove open brace - Lint.Replacement.deleteText(arg.getStart(sourceFile), 1), - // remove trailing comma if exists and close brace - Lint.Replacement.deleteFromTo(arg.properties[arg.properties.length - 1].end, arg.end)); - } - } - else { - var parens = needsParens(arg); - fix.push(Lint.Replacement.appendText(arg.getStart(sourceFile), parens ? "...(" : "...")); - if (parens) { - fix.push(Lint.Replacement.appendText(arg.end, ")")); - } - } - } - return fix; -} -function isThisKeyword(node) { - return node.kind === ts.SyntaxKind.ThisKeyword; -} -function needsParens(node) { - switch (node.kind) { - case ts.SyntaxKind.ConditionalExpression: - case ts.SyntaxKind.BinaryExpression: - return true; - default: - return false; - } -} diff --git a/node_modules/tslint/lib/rules/preferSwitchRule.d.ts b/node_modules/tslint/lib/rules/preferSwitchRule.d.ts deleted file mode 100644 index 65ed5c49f..000000000 --- a/node_modules/tslint/lib/rules/preferSwitchRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferSwitchRule.js b/node_modules/tslint/lib/rules/preferSwitchRule.js deleted file mode 100644 index 6291ac4cc..000000000 --- a/node_modules/tslint/lib/rules/preferSwitchRule.js +++ /dev/null @@ -1,140 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var _a, _b; -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_MIN_CASES = "min-cases"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var minCases = 3; - if (this.ruleArguments.length !== 0) { - var obj = this.ruleArguments[0]; - minCases = obj[OPTION_MIN_CASES]; - } - return this.applyWithFunction(sourceFile, walk, minCases); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-switch", - description: "Prefer a `switch` statement to an `if` statement with simple `===` comparisons.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n An optional object with the property '", "'.\n This is the number cases needed before a switch statement is recommended.\n Defaults to 3."], ["\n An optional object with the property '", "'.\n This is the number cases needed before a switch statement is recommended.\n Defaults to 3."])), OPTION_MIN_CASES), - options: { - type: "object", - properties: (_a = {}, - _a[OPTION_MIN_CASES] = { type: "number" }, - _a), - }, - optionExamples: [true, [true, (_b = {}, _b[OPTION_MIN_CASES] = 2, _b)]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use a switch statement instead of using multiple '===' checks."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var minCases = ctx.options, sourceFile = ctx.sourceFile; - return ts.forEachChild(sourceFile, function cb(node) { - if (utils.isIfStatement(node) && check(node, sourceFile, minCases)) { - var expression = node.expression, thenStatement = node.thenStatement, elseStatement = node.elseStatement; - ctx.addFailureAtNode(expression, Rule.FAILURE_STRING); - // Be careful not to fail again for the "else if" - ts.forEachChild(expression, cb); - ts.forEachChild(thenStatement, cb); - if (elseStatement !== undefined) { - ts.forEachChild(elseStatement, cb); - } - } - else { - return ts.forEachChild(node, cb); - } - }); -} -function check(node, sourceFile, minCases) { - var switchVariable; - var casesSeen = 0; - var couldBeSwitch = everyCase(node, function (expr) { - casesSeen++; - if (switchVariable !== undefined) { - return nodeEquals(expr, switchVariable, sourceFile); - } - else { - switchVariable = expr; - return true; - } - }); - return couldBeSwitch && casesSeen >= minCases; -} -function everyCase(_a, test) { - var expression = _a.expression, elseStatement = _a.elseStatement; - if (!everyCondition(expression, test)) { - return false; - } - return elseStatement === undefined || !utils.isIfStatement(elseStatement) || everyCase(elseStatement, test); -} -function everyCondition(node, test) { - if (!utils.isBinaryExpression(node)) { - return false; - } - var operatorToken = node.operatorToken, left = node.left, right = node.right; - switch (operatorToken.kind) { - case ts.SyntaxKind.BarBarToken: - return everyCondition(left, test) && everyCondition(right, test); - case ts.SyntaxKind.EqualsEqualsEqualsToken: - return isSimple(left) && isSimple(right) && test(left); - default: - return false; - } -} -function nodeEquals(a, b, sourceFile) { - return a.getText(sourceFile) === b.getText(sourceFile); -} -function isSimple(node) { - switch (node.kind) { - case ts.SyntaxKind.PropertyAccessExpression: - return isSimple(node.expression); - case ts.SyntaxKind.PrefixUnaryExpression: - switch (node.operator) { - case ts.SyntaxKind.PlusPlusToken: - case ts.SyntaxKind.MinusMinusToken: - return false; - default: - return isSimple(node.operand); - } - case ts.SyntaxKind.Identifier: - case ts.SyntaxKind.NumericLiteral: - case ts.SyntaxKind.StringLiteral: - case ts.SyntaxKind.ThisKeyword: - case ts.SyntaxKind.NoSubstitutionTemplateLiteral: - case ts.SyntaxKind.TrueKeyword: - case ts.SyntaxKind.FalseKeyword: - case ts.SyntaxKind.NullKeyword: - return true; - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/preferTemplateRule.d.ts b/node_modules/tslint/lib/rules/preferTemplateRule.d.ts deleted file mode 100644 index e6719dbf7..000000000 --- a/node_modules/tslint/lib/rules/preferTemplateRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - static FAILURE_STRING_MULTILINE: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/preferTemplateRule.js b/node_modules/tslint/lib/rules/preferTemplateRule.js deleted file mode 100644 index 6b065d719..000000000 --- a/node_modules/tslint/lib/rules/preferTemplateRule.js +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_SINGLE_CONCAT = "allow-single-concat"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - if (sourceFile.isDeclarationFile) { - return []; // Not possible in a declaration file - } - var allowSingleConcat = this.ruleArguments.indexOf(OPTION_SINGLE_CONCAT) !== -1; - return this.applyWithFunction(sourceFile, walk, { allowSingleConcat: allowSingleConcat }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "prefer-template", - description: "Prefer a template expression over string literal concatenation.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then a single concatenation (`x + y`) is allowed, but not more (`x + y + z`)."], ["\n If \\`", "\\` is specified, then a single concatenation (\\`x + y\\`) is allowed, but not more (\\`x + y + z\\`)."])), OPTION_SINGLE_CONCAT), - options: { - type: "string", - enum: [OPTION_SINGLE_CONCAT], - }, - optionExamples: [true, [true, OPTION_SINGLE_CONCAT]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Use a template literal instead of concatenating with a string literal."; - Rule.FAILURE_STRING_MULTILINE = "Use a multiline template literal instead of concatenating string literals with newlines."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var allowSingleConcat = ctx.options.allowSingleConcat; - return ts.forEachChild(ctx.sourceFile, function cb(node) { - var failure = getError(node, allowSingleConcat); - if (failure !== undefined) { - ctx.addFailureAtNode(node, failure); - } - else { - return ts.forEachChild(node, cb); - } - }); -} -function getError(node, allowSingleConcat) { - if (!isPlusExpression(node)) { - return undefined; - } - var left = node.left, right = node.right; - var l = isStringLike(left); - var r = isStringLike(right); - if (l && r) { - // They're both strings. - // If they're joined by a newline, recommend a template expression instead. - // Otherwise ignore. ("a" + "b", probably writing a long newline-less string on many lines.) - return containsNewline(left) || containsNewline(right) ? Rule.FAILURE_STRING_MULTILINE : undefined; - } - else if (!l && !r) { - // Watch out for `"a" + b + c`. Parsed as `("a" + b) + c`. - return containsAnyStringLiterals(left) ? Rule.FAILURE_STRING : undefined; - } - else if (l) { - // `"x" + y` - return !allowSingleConcat ? Rule.FAILURE_STRING : undefined; - } - else { - // `? + "b"` - // If LHS consists of only string literals (as in `"a" + "b" + "c"`, allow it.) - return !containsOnlyStringLiterals(left) && (!allowSingleConcat || isPlusExpression(left)) ? Rule.FAILURE_STRING : undefined; - } -} -function containsNewline(node) { - if (node.kind === ts.SyntaxKind.TemplateExpression) { - return node.templateSpans.some(function (_a) { - var text = _a.literal.text; - return text.includes("\n"); - }); - } - else { - return node.text.includes("\n"); - } -} -function containsOnlyStringLiterals(node) { - return isPlusExpression(node) && isStringLike(node.right) && (isStringLike(node.left) || containsAnyStringLiterals(node.left)); -} -function containsAnyStringLiterals(node) { - return isPlusExpression(node) && (isStringLike(node.right) || isStringLike(node.left) || containsAnyStringLiterals(node.left)); -} -function isPlusExpression(node) { - return tsutils_1.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken; -} -function isStringLike(node) { - switch (node.kind) { - case ts.SyntaxKind.StringLiteral: - case ts.SyntaxKind.NoSubstitutionTemplateLiteral: - case ts.SyntaxKind.TemplateExpression: - return true; - default: - return false; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/promiseFunctionAsyncRule.d.ts b/node_modules/tslint/lib/rules/promiseFunctionAsyncRule.d.ts deleted file mode 100644 index 8b31e4da7..000000000 --- a/node_modules/tslint/lib/rules/promiseFunctionAsyncRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/promiseFunctionAsyncRule.js b/node_modules/tslint/lib/rules/promiseFunctionAsyncRule.js deleted file mode 100644 index 61a97fde0..000000000 --- a/node_modules/tslint/lib/rules/promiseFunctionAsyncRule.js +++ /dev/null @@ -1,110 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var _a; -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_FUNCTION_DECLARATION = "check-function-declaration"; -var OPTION_FUNCTION_EXPRESSION = "check-function-expression"; -var OPTION_ARROW_FUNCTION = "check-arrow-function"; -var OPTION_METHOD_DECLARATION = "check-method-declaration"; -var KIND_FOR_OPTION = (_a = {}, - _a[OPTION_FUNCTION_DECLARATION] = ts.SyntaxKind.FunctionDeclaration, - _a[OPTION_FUNCTION_EXPRESSION] = ts.SyntaxKind.FunctionExpression, - _a[OPTION_ARROW_FUNCTION] = ts.SyntaxKind.ArrowFunction, - _a[OPTION_METHOD_DECLARATION] = ts.SyntaxKind.MethodDeclaration, - _a); -function parseOptions(ruleArguments) { - if (ruleArguments.length === 0) { - ruleArguments = Object.keys(KIND_FOR_OPTION); - } - var enabledKinds = new Set(); - for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) { - var arg = ruleArguments_1[_i]; - enabledKinds.add(KIND_FOR_OPTION[arg]); - } - return enabledKinds; -} -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments), program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "promise-function-async", - description: "Requires any function or method that returns a promise to be marked async.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Ensures that each function is only capable of 1) returning a rejected promise, or 2)\n throwing an Error object. In contrast, non-`async` `Promise`-returning functions\n are technically capable of either. This practice removes a requirement for consuming\n code to handle both cases.\n\n If no optional arguments are provided then all function types are checked,\n otherwise the specific function types are checked:\n\n * `\"", "\"` check function declarations.\n * `\"", "\"` check function expressions.\n * `\"", "\"` check arrow functions.\n * `\"", "\"` check method declarations.\n "], ["\n Ensures that each function is only capable of 1) returning a rejected promise, or 2)\n throwing an Error object. In contrast, non-\\`async\\` \\`Promise\\`-returning functions\n are technically capable of either. This practice removes a requirement for consuming\n code to handle both cases.\n\n If no optional arguments are provided then all function types are checked,\n otherwise the specific function types are checked:\n\n * \\`\"", "\"\\` check function declarations.\n * \\`\"", "\"\\` check function expressions.\n * \\`\"", "\"\\` check arrow functions.\n * \\`\"", "\"\\` check method declarations.\n "])), OPTION_FUNCTION_DECLARATION, OPTION_FUNCTION_EXPRESSION, OPTION_ARROW_FUNCTION, OPTION_METHOD_DECLARATION), - optionsDescription: "Not configurable.", - options: { - type: "array", - items: { - type: "string", - enum: [ - OPTION_FUNCTION_DECLARATION, - OPTION_FUNCTION_EXPRESSION, - OPTION_ARROW_FUNCTION, - OPTION_METHOD_DECLARATION, - ], - }, - minLength: 0, - maxLength: 4, - }, - optionExamples: [true, - [true, OPTION_FUNCTION_DECLARATION, OPTION_METHOD_DECLARATION]], - type: "typescript", - typescriptOnly: false, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "functions that return promises must be async"; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - var sourceFile = ctx.sourceFile, options = ctx.options; - return ts.forEachChild(sourceFile, function cb(node) { - if (options.has(node.kind)) { - switch (node.kind) { - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.FunctionDeclaration: - if (node.body === undefined) { - break; - } - // falls through - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.ArrowFunction: - if (!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) - && returnsPromise(node, tc)) { - ctx.addFailure(node.getStart(sourceFile), node.body.pos, Rule.FAILURE_STRING); - } - } - } - return ts.forEachChild(node, cb); - }); -} -function returnsPromise(node, tc) { - var type = tc.getReturnTypeOfSignature(tc.getTypeAtLocation(node).getCallSignatures()[0]); - return type.symbol !== undefined && type.symbol.name === "Promise"; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/quotemarkRule.d.ts b/node_modules/tslint/lib/rules/quotemarkRule.d.ts deleted file mode 100644 index c4f5cdecb..000000000 --- a/node_modules/tslint/lib/rules/quotemarkRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(actual: string, expected: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/quotemarkRule.js b/node_modules/tslint/lib/rules/quotemarkRule.js deleted file mode 100644 index e4ab69552..000000000 --- a/node_modules/tslint/lib/rules/quotemarkRule.js +++ /dev/null @@ -1,121 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_SINGLE = "single"; -var OPTION_DOUBLE = "double"; -var OPTION_JSX_SINGLE = "jsx-single"; -var OPTION_JSX_DOUBLE = "jsx-double"; -var OPTION_AVOID_TEMPLATE = "avoid-template"; -var OPTION_AVOID_ESCAPE = "avoid-escape"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (actual, expected) { - return actual + " should be " + expected; - }; - Rule.prototype.apply = function (sourceFile) { - var args = this.ruleArguments; - var quoteMark = getQuotemarkPreference(args) === OPTION_SINGLE ? "'" : '"'; - return this.applyWithFunction(sourceFile, walk, { - avoidEscape: hasArg(OPTION_AVOID_ESCAPE), - avoidTemplate: hasArg(OPTION_AVOID_TEMPLATE), - jsxQuoteMark: hasArg(OPTION_JSX_SINGLE) ? "'" : hasArg(OPTION_JSX_DOUBLE) ? '"' : quoteMark, - quoteMark: quoteMark, - }); - function hasArg(name) { - return args.indexOf(name) !== -1; - } - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "quotemark", - description: "Requires single or double quotes for string literals.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"` enforces single quotes.\n * `\"", "\"` enforces double quotes.\n * `\"", "\"` enforces single quotes for JSX attributes.\n * `\"", "\"` enforces double quotes for JSX attributes.\n * `\"", "\"` forbids single-line untagged template strings that do not contain string interpolations.\n * `\"", "\"` allows you to use the \"other\" quotemark in cases where escaping would normally be required.\n For example, `[true, \"", "\", \"", "\"]` would not report a failure on the string literal\n `'Hello \"World\"'`."], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` enforces single quotes.\n * \\`\"", "\"\\` enforces double quotes.\n * \\`\"", "\"\\` enforces single quotes for JSX attributes.\n * \\`\"", "\"\\` enforces double quotes for JSX attributes.\n * \\`\"", "\"\\` forbids single-line untagged template strings that do not contain string interpolations.\n * \\`\"", "\"\\` allows you to use the \"other\" quotemark in cases where escaping would normally be required.\n For example, \\`[true, \"", "\", \"", "\"]\\` would not report a failure on the string literal\n \\`'Hello \"World\"'\\`."])), OPTION_SINGLE, OPTION_DOUBLE, OPTION_JSX_SINGLE, OPTION_JSX_DOUBLE, OPTION_AVOID_TEMPLATE, OPTION_AVOID_ESCAPE, OPTION_DOUBLE, OPTION_AVOID_ESCAPE), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_SINGLE, OPTION_DOUBLE, OPTION_JSX_SINGLE, OPTION_JSX_DOUBLE, OPTION_AVOID_ESCAPE, OPTION_AVOID_TEMPLATE], - }, - minLength: 0, - maxLength: 5, - }, - optionExamples: [ - [true, OPTION_SINGLE, OPTION_AVOID_ESCAPE, OPTION_AVOID_TEMPLATE], - [true, OPTION_SINGLE, OPTION_JSX_DOUBLE], - ], - type: "style", - typescriptOnly: false, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, options = ctx.options; - ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isStringLiteral(node) - || options.avoidTemplate && tsutils_1.isNoSubstitutionTemplateLiteral(node) - && node.parent.kind !== ts.SyntaxKind.TaggedTemplateExpression - && tsutils_1.isSameLine(sourceFile, node.getStart(sourceFile), node.end)) { - var expectedQuoteMark = node.parent.kind === ts.SyntaxKind.JsxAttribute ? options.jsxQuoteMark : options.quoteMark; - var actualQuoteMark = sourceFile.text[node.end - 1]; - if (actualQuoteMark === expectedQuoteMark) { - return; - } - var fixQuoteMark = expectedQuoteMark; - var needsQuoteEscapes = node.text.includes(expectedQuoteMark); - if (needsQuoteEscapes && options.avoidEscape) { - if (node.kind === ts.SyntaxKind.StringLiteral) { - return; - } - // If expecting double quotes, fix a template `a "quote"` to `a 'quote'` anyway, - // always preferring *some* quote mark over a template. - fixQuoteMark = expectedQuoteMark === '"' ? "'" : '"'; - if (node.text.includes(fixQuoteMark)) { - return; - } - } - var start = node.getStart(sourceFile); - var text = sourceFile.text.substring(start + 1, node.end - 1); - if (needsQuoteEscapes) { - text = text.replace(new RegExp(fixQuoteMark, "g"), "\\" + fixQuoteMark); - } - text = text.replace(new RegExp("\\\\" + actualQuoteMark, "g"), actualQuoteMark); - return ctx.addFailure(start, node.end, Rule.FAILURE_STRING(actualQuoteMark, fixQuoteMark), new Lint.Replacement(start, node.end - start, fixQuoteMark + text + fixQuoteMark)); - } - ts.forEachChild(node, cb); - }); -} -function getQuotemarkPreference(args) { - for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { - var arg = args_1[_i]; - if (arg === OPTION_SINGLE || arg === OPTION_DOUBLE) { - return arg; - } - } - return undefined; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/radixRule.d.ts b/node_modules/tslint/lib/rules/radixRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/radixRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/radixRule.js b/node_modules/tslint/lib/rules/radixRule.js deleted file mode 100644 index e5548c558..000000000 --- a/node_modules/tslint/lib/rules/radixRule.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "radix", - description: "Requires the radix parameter to be specified when calling `parseInt`.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n From [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt):\n > Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior.\n > Different implementations produce different results when a radix is not specified, usually defaulting the value to 10."], ["\n From [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt):\n > Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior.\n > Different implementations produce different results when a radix is not specified, usually defaulting the value to 10."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Missing radix parameter"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function isParseInt(expression) { - return tsutils_1.isIdentifier(expression) && expression.text === "parseInt"; -} -function isPropertyAccessParseInt(expression) { - return tsutils_1.isPropertyAccessExpression(expression) && expression.name.text === "parseInt"; -} -function isPropertyAccessOfIdentifier(expression, identifers) { - return tsutils_1.isPropertyAccessExpression(expression) && tsutils_1.isIdentifier(expression.expression) && - identifers.some(function (identifer) { return expression.expression.text === identifer; }); -} -function isPropertyAccessOfProperty(expression, identifers) { - return tsutils_1.isPropertyAccessExpression(expression) && tsutils_1.isPropertyAccessExpression(expression.expression) && - identifers.some(function (identifer) { return expression.expression.name.text === identifer; }); -} -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isCallExpression(node) && node.arguments.length === 1 && - ( - // parseInt("123") - isParseInt(node.expression) || - // window.parseInt("123") || global.parseInt("123") || Number.parseInt("123") - isPropertyAccessParseInt(node.expression) && - isPropertyAccessOfIdentifier(node.expression, ["global", "window", "Number"]) || - // window.Number.parseInt("123") || global.Number.parseInt("123") - isPropertyAccessParseInt(node.expression) && - isPropertyAccessOfProperty(node.expression, ["Number"]) && - isPropertyAccessOfIdentifier(node.expression.expression, ["global", "window"]))) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts deleted file mode 100644 index 5867be53a..000000000 --- a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static INVALID_TYPES_ERROR: string; - static SUGGEST_TEMPLATE_LITERALS: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js deleted file mode 100644 index e05bd3fff..000000000 --- a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "restrict-plus-operands", - description: "When adding two variables, operands must both be of type number or of type string.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.INVALID_TYPES_ERROR = "Operands of '+' operation must either be both strings or both numbers"; - Rule.SUGGEST_TEMPLATE_LITERALS = ", consider using template literals"; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, tc) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken) { - var leftType = getBaseTypeOfLiteralType(tc.getTypeAtLocation(node.left)); - var rightType = getBaseTypeOfLiteralType(tc.getTypeAtLocation(node.right)); - if (leftType === "invalid" || rightType === "invalid" || leftType !== rightType) { - if (leftType === "string" || rightType === "string") { - return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR + Rule.SUGGEST_TEMPLATE_LITERALS); - } - else { - return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR); - } - } - } - return ts.forEachChild(node, cb); - }); -} -function getBaseTypeOfLiteralType(type) { - if (tsutils_1.isTypeFlagSet(type, ts.TypeFlags.StringLiteral) || tsutils_1.isTypeFlagSet(type, ts.TypeFlags.String)) { - return "string"; - } - else if (tsutils_1.isTypeFlagSet(type, ts.TypeFlags.NumberLiteral) || tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Number)) { - return "number"; - } - else if (tsutils_1.isUnionType(type) && !tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Enum)) { - var types = type.types.map(getBaseTypeOfLiteralType); - return allSame(types) ? types[0] : "invalid"; - } - else if (tsutils_1.isTypeFlagSet(type, ts.TypeFlags.EnumLiteral)) { - // Compatibility for TypeScript pre-2.4, which used EnumLiteralType instead of LiteralType - getBaseTypeOfLiteralType(type.baseType); - } - return "invalid"; -} -function allSame(array) { - return array.every(function (value) { return value === array[0]; }); -} diff --git a/node_modules/tslint/lib/rules/returnUndefinedRule.d.ts b/node_modules/tslint/lib/rules/returnUndefinedRule.d.ts deleted file mode 100644 index 4d6862114..000000000 --- a/node_modules/tslint/lib/rules/returnUndefinedRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_VALUE_RETURN: string; - static FAILURE_STRING_VOID_RETURN: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/returnUndefinedRule.js b/node_modules/tslint/lib/rules/returnUndefinedRule.js deleted file mode 100644 index ab3da43ce..000000000 --- a/node_modules/tslint/lib/rules/returnUndefinedRule.js +++ /dev/null @@ -1,151 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "return-undefined", - description: "Prefer `return;` in void functions and `return undefined;` in value-returning functions.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: false, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_VALUE_RETURN = "Value-returning function should use `return undefined;`, not just `return;`."; - Rule.FAILURE_STRING_VOID_RETURN = "`void` function should use `return;`, not `return undefined;`."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isReturnStatement(node)) { - check(node); - } - return ts.forEachChild(node, cb); - }); - function check(node) { - var actualReturnKind = returnKindFromReturn(node); - if (actualReturnKind === undefined) { - return; - } - var functionReturningFrom = Lint.ancestorWhere(node, isFunctionLike); - if (functionReturningFrom === undefined) { - // Return outside of function is invalid - return; - } - var returnKindFromType = getReturnKind(functionReturningFrom, checker); - if (returnKindFromType !== undefined && returnKindFromType !== actualReturnKind) { - ctx.addFailureAtNode(node, returnKindFromType === ReturnKind.Void - ? Rule.FAILURE_STRING_VOID_RETURN - : Rule.FAILURE_STRING_VALUE_RETURN); - } - } -} -function returnKindFromReturn(node) { - if (node.expression === undefined) { - return ReturnKind.Void; - } - else if (tsutils_1.isIdentifier(node.expression) && node.expression.text === "undefined") { - return ReturnKind.Value; - } - else { - return undefined; - } -} -var ReturnKind; -(function (ReturnKind) { - ReturnKind[ReturnKind["Void"] = 0] = "Void"; - ReturnKind[ReturnKind["Value"] = 1] = "Value"; -})(ReturnKind || (ReturnKind = {})); -function getReturnKind(node, checker) { - switch (node.kind) { - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.SetAccessor: - return ReturnKind.Void; - case ts.SyntaxKind.GetAccessor: - return ReturnKind.Value; - } - var contextual = isFunctionExpressionLike(node) && node.type === undefined - ? tryGetReturnType(checker.getContextualType(node), checker) - : undefined; - var returnType = contextual !== undefined ? contextual : tryGetReturnType(checker.getTypeAtLocation(node), checker); - if (returnType === undefined || tsutils_1.isTypeFlagSet(returnType, ts.TypeFlags.Any)) { - return undefined; - } - if ((tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) ? isEffectivelyVoidPromise : isEffectivelyVoid)(returnType)) { - return ReturnKind.Void; - } - return ReturnKind.Value; -} -/** True for `void`, `undefined`, Promise<void>, or `void | undefined | Promise<void>`. */ -function isEffectivelyVoidPromise(type) { - // Would need access to `checker.getPromisedTypeOfPromise` to do this properly. - // Assume that the return type is the global Promise (since this is an async function) and get its type argument. - // tslint:disable-next-line no-bitwise - return tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Void | ts.TypeFlags.Undefined) || - tsutils_1.isUnionType(type) && type.types.every(isEffectivelyVoidPromise) || - tsutils_1.isTypeReference(type) && type.typeArguments !== undefined && type.typeArguments.length === 1 && - isEffectivelyVoidPromise(type.typeArguments[0]); -} -/** True for `void`, `undefined`, or `void | undefined`. */ -function isEffectivelyVoid(type) { - // tslint:disable-next-line no-bitwise - return tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Void | ts.TypeFlags.Undefined) || - tsutils_1.isUnionType(type) && type.types.every(isEffectivelyVoid); -} -function tryGetReturnType(fnType, checker) { - if (fnType === undefined) { - return undefined; - } - var sigs = checker.getSignaturesOfType(fnType, ts.SignatureKind.Call); - if (sigs.length !== 1) { - return undefined; - } - return checker.getReturnTypeOfSignature(sigs[0]); -} -function isFunctionLike(node) { - switch (node.kind) { - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - return true; - default: - return false; - } -} -function isFunctionExpressionLike(node) { - return node.kind === ts.SyntaxKind.FunctionExpression || node.kind === ts.SyntaxKind.ArrowFunction; -} diff --git a/node_modules/tslint/lib/rules/semicolonRule.d.ts b/node_modules/tslint/lib/rules/semicolonRule.d.ts deleted file mode 100644 index 2f56b6ba7..000000000 --- a/node_modules/tslint/lib/rules/semicolonRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_MISSING: string; - static FAILURE_STRING_COMMA: string; - static FAILURE_STRING_UNNECESSARY: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/semicolonRule.js b/node_modules/tslint/lib/rules/semicolonRule.js deleted file mode 100644 index 9e20e960a..000000000 --- a/node_modules/tslint/lib/rules/semicolonRule.js +++ /dev/null @@ -1,329 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALWAYS = "always"; -var OPTION_NEVER = "never"; -var OPTION_IGNORE_BOUND_CLASS_METHODS = "ignore-bound-class-methods"; -var OPTION_STRICT_BOUND_CLASS_METHODS = "strict-bound-class-methods"; -var OPTION_IGNORE_INTERFACES = "ignore-interfaces"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var options = { - boundClassMethods: this.ruleArguments.indexOf(OPTION_STRICT_BOUND_CLASS_METHODS) !== -1 - ? 2 /* Strict */ - : this.ruleArguments.indexOf(OPTION_IGNORE_BOUND_CLASS_METHODS) !== -1 - ? 1 /* Ignore */ - : 0 /* Default */, - interfaces: this.ruleArguments.indexOf(OPTION_IGNORE_INTERFACES) === -1, - }; - var Walker = this.ruleArguments.indexOf(OPTION_NEVER) === -1 ? SemicolonAlwaysWalker : SemicolonNeverWalker; - return this.applyWithWalker(new Walker(sourceFile, this.ruleName, options)); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "semicolon", - description: "Enforces consistent semicolon usage at the end of every statement.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One of the following arguments must be provided:\n\n * `\"", "\"` enforces semicolons at the end of every statement.\n * `\"", "\"` disallows semicolons at the end of every statement except for when they are necessary.\n\n The following arguments may be optionally provided:\n\n * `\"", "\"` skips checking semicolons at the end of interface members.\n * `\"", "\"` skips checking semicolons at the end of bound class methods.\n * `\"", "\"` disables any special handling of bound class methods and treats them as any\n other assignment. This option overrides `\"", "\"`.\n "], ["\n One of the following arguments must be provided:\n\n * \\`\"", "\"\\` enforces semicolons at the end of every statement.\n * \\`\"", "\"\\` disallows semicolons at the end of every statement except for when they are necessary.\n\n The following arguments may be optionally provided:\n\n * \\`\"", "\"\\` skips checking semicolons at the end of interface members.\n * \\`\"", "\"\\` skips checking semicolons at the end of bound class methods.\n * \\`\"", "\"\\` disables any special handling of bound class methods and treats them as any\n other assignment. This option overrides \\`\"", "\"\\`.\n "])), OPTION_ALWAYS, OPTION_NEVER, OPTION_IGNORE_INTERFACES, OPTION_IGNORE_BOUND_CLASS_METHODS, OPTION_STRICT_BOUND_CLASS_METHODS, OPTION_IGNORE_BOUND_CLASS_METHODS), - options: { - type: "array", - items: [ - { - type: "string", - enum: [OPTION_ALWAYS, OPTION_NEVER], - }, - { - type: "string", - enum: [OPTION_IGNORE_INTERFACES], - }, - ], - additionalItems: false, - }, - optionExamples: [ - [true, OPTION_ALWAYS], - [true, OPTION_NEVER], - [true, OPTION_ALWAYS, OPTION_IGNORE_INTERFACES], - [true, OPTION_ALWAYS, OPTION_IGNORE_BOUND_CLASS_METHODS], - ], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_MISSING = "Missing semicolon"; - Rule.FAILURE_STRING_COMMA = "Properties should be separated by semicolons"; - Rule.FAILURE_STRING_UNNECESSARY = "Unnecessary semicolon"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var SemicolonWalker = /** @class */ (function (_super) { - tslib_1.__extends(SemicolonWalker, _super); - function SemicolonWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - SemicolonWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - _this.visitNode(node); - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - SemicolonWalker.prototype.visitNode = function (node) { - switch (node.kind) { - case ts.SyntaxKind.SemicolonClassElement: - return this.reportUnnecessary(node.end); - case ts.SyntaxKind.EmptyStatement: - return this.checkEmptyStatement(node); - case ts.SyntaxKind.PropertyDeclaration: - return this.visitPropertyDeclaration(node); - } - }; - SemicolonWalker.prototype.reportUnnecessary = function (pos, noFix) { - this.addFailure(pos - 1, pos, Rule.FAILURE_STRING_UNNECESSARY, noFix ? undefined : Lint.Replacement.deleteText(pos - 1, 1)); - }; - SemicolonWalker.prototype.checkSemicolonOrLineBreak = function (node) { - if (this.sourceFile.text[node.end - 1] !== ";") { - return; - } - var nextToken = utils.getNextToken(node, this.sourceFile); - switch (nextToken.kind) { - case ts.SyntaxKind.EndOfFileToken: - case ts.SyntaxKind.CloseBraceToken: - return this.reportUnnecessary(node.end); - default: - if (!utils.isSameLine(this.sourceFile, node.end, nextToken.end)) { - this.reportUnnecessary(node.end); - } - } - }; - SemicolonWalker.prototype.checkUnnecessary = function (node) { - if (this.sourceFile.text[node.end - 1] !== ";") { - return; - } - var lastToken = utils.getPreviousToken(node.getLastToken(this.sourceFile), this.sourceFile); - // yield does not continue on the next line if there is no yielded expression - if (lastToken.kind === ts.SyntaxKind.YieldKeyword && lastToken.parent.kind === ts.SyntaxKind.YieldExpression || - // arrow functions with block as body don't continue on the next line - lastToken.kind === ts.SyntaxKind.CloseBraceToken && lastToken.parent.kind === ts.SyntaxKind.Block && - lastToken.parent.parent.kind === ts.SyntaxKind.ArrowFunction) { - return this.checkSemicolonOrLineBreak(node); - } - var nextToken = utils.getNextToken(node, this.sourceFile); - switch (nextToken.kind) { - case ts.SyntaxKind.OpenParenToken: - case ts.SyntaxKind.OpenBracketToken: - case ts.SyntaxKind.PlusToken: - case ts.SyntaxKind.MinusToken: - case ts.SyntaxKind.RegularExpressionLiteral: - case ts.SyntaxKind.LessThanToken: - case ts.SyntaxKind.NoSubstitutionTemplateLiteral: - case ts.SyntaxKind.TemplateHead: - break; - case ts.SyntaxKind.CloseBraceToken: - case ts.SyntaxKind.EndOfFileToken: - return this.reportUnnecessary(node.end); - default: - if (!utils.isSameLine(this.sourceFile, node.end, nextToken.end)) { - this.reportUnnecessary(node.end); - } - } - }; - SemicolonWalker.prototype.checkEmptyStatement = function (node) { - // An empty statement is only ever useful when it is the only statement inside a loop - if (!utils.isIterationStatement(node.parent)) { - var parentKind = node.parent.kind; - // don't remove empty statement if it is a direct child of if, with or a LabeledStatement - // otherwise this would unintentionally change control flow - var noFix = parentKind === ts.SyntaxKind.IfStatement || - parentKind === ts.SyntaxKind.LabeledStatement || - parentKind === ts.SyntaxKind.WithStatement; - this.reportUnnecessary(node.end, noFix); - } - }; - SemicolonWalker.prototype.visitPropertyDeclaration = function (node) { - // check if this is a multi-line arrow function - if (this.options.boundClassMethods !== 2 /* Strict */ && - node.initializer !== undefined && - node.initializer.kind === ts.SyntaxKind.ArrowFunction && - !utils.isSameLine(this.sourceFile, node.getStart(this.sourceFile), node.end)) { - if (this.options.boundClassMethods === 0 /* Default */) { - this.checkUnnecessary(node); - } - } - else { - this.checkPropertyDeclaration(node); - } - }; - return SemicolonWalker; -}(Lint.AbstractWalker)); -var SemicolonAlwaysWalker = /** @class */ (function (_super) { - tslib_1.__extends(SemicolonAlwaysWalker, _super); - function SemicolonAlwaysWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - SemicolonAlwaysWalker.prototype.visitNode = function (node) { - switch (node.kind) { - case ts.SyntaxKind.VariableStatement: - case ts.SyntaxKind.ExpressionStatement: - case ts.SyntaxKind.ReturnStatement: - case ts.SyntaxKind.BreakStatement: - case ts.SyntaxKind.ContinueStatement: - case ts.SyntaxKind.ThrowStatement: - case ts.SyntaxKind.ImportEqualsDeclaration: - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.ExportAssignment: - case ts.SyntaxKind.TypeAliasDeclaration: - case ts.SyntaxKind.ImportDeclaration: - case ts.SyntaxKind.ExportDeclaration: - case ts.SyntaxKind.DebuggerStatement: - return this.checkMissing(node); - case ts.SyntaxKind.ModuleDeclaration: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.FunctionDeclaration: - // check shorthand module declarations and method / function signatures - if (node.body === undefined) { - this.checkMissing(node); - } - break; - case ts.SyntaxKind.InterfaceDeclaration: - if (this.options.interfaces) { - this.checkInterface(node); - } - break; - default: - return _super.prototype.visitNode.call(this, node); - } - }; - SemicolonAlwaysWalker.prototype.checkPropertyDeclaration = function (node) { - return this.checkMissing(node); - }; - SemicolonAlwaysWalker.prototype.checkMissing = function (node) { - if (this.sourceFile.text[node.end - 1] !== ";") { - this.reportMissing(node.end); - } - }; - SemicolonAlwaysWalker.prototype.reportMissing = function (pos) { - this.addFailureAt(pos, 0, Rule.FAILURE_STRING_MISSING, Lint.Replacement.appendText(pos, ";")); - }; - SemicolonAlwaysWalker.prototype.checkInterface = function (node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (this.sourceFile.text[member.end - 1]) { - case ";": break; - case ",": - this.addFailureAt(member.end - 1, 1, Rule.FAILURE_STRING_COMMA, new Lint.Replacement(member.end - 1, 1, ";")); - break; - default: - this.reportMissing(member.end); - } - } - }; - return SemicolonAlwaysWalker; -}(SemicolonWalker)); -var SemicolonNeverWalker = /** @class */ (function (_super) { - tslib_1.__extends(SemicolonNeverWalker, _super); - function SemicolonNeverWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - SemicolonNeverWalker.prototype.visitNode = function (node) { - switch (node.kind) { - case ts.SyntaxKind.ExpressionStatement: - case ts.SyntaxKind.ThrowStatement: - case ts.SyntaxKind.ExportAssignment: - return this.checkUnnecessary(node); - case ts.SyntaxKind.VariableStatement: - return this.checkVariableStatement(node); - case ts.SyntaxKind.ReturnStatement: - if (node.expression === undefined) { - // return does not continue on the next line if the is no returned expression - return this.checkSemicolonOrLineBreak(node); - } - return this.checkUnnecessary(node); - case ts.SyntaxKind.TypeAliasDeclaration: - case ts.SyntaxKind.ImportEqualsDeclaration: - case ts.SyntaxKind.ImportDeclaration: - case ts.SyntaxKind.ExportDeclaration: - case ts.SyntaxKind.DebuggerStatement: - case ts.SyntaxKind.BreakStatement: - case ts.SyntaxKind.ContinueStatement: - case ts.SyntaxKind.DoStatement: - return this.checkSemicolonOrLineBreak(node); - case ts.SyntaxKind.ModuleDeclaration: - // shorthand module declaration - if (node.body === undefined) { - this.checkShorthandModuleDeclaration(node); - } - break; - case ts.SyntaxKind.MethodDeclaration: - // check method signature - if (node.body === undefined) { - this.checkSemicolonOrLineBreak(node); - } - break; - case ts.SyntaxKind.FunctionDeclaration: - // check function signature - if (node.body === undefined) { - this.checkSemicolonOrLineBreak(node); - } - break; - case ts.SyntaxKind.InterfaceDeclaration: - if (this.options.interfaces) { - this.checkInterface(node); - } - break; - default: - return _super.prototype.visitNode.call(this, node); - } - }; - SemicolonNeverWalker.prototype.checkPropertyDeclaration = function (node) { - if (node.initializer === undefined) { - return this.checkSemicolonOrLineBreak(node); - } - return this.checkUnnecessary(node); - }; - SemicolonNeverWalker.prototype.checkVariableStatement = function (node) { - var declarations = node.declarationList.declarations; - if (declarations[declarations.length - 1].initializer === undefined) { - // variable declaration does not continue on the next line if it has no initializer - return this.checkSemicolonOrLineBreak(node); - } - return this.checkUnnecessary(node); - }; - SemicolonNeverWalker.prototype.checkShorthandModuleDeclaration = function (node) { - var nextStatement = utils.getNextStatement(node); - if (nextStatement === undefined || nextStatement.kind !== ts.SyntaxKind.Block) { - this.checkSemicolonOrLineBreak(node); - } - }; - SemicolonNeverWalker.prototype.checkInterface = function (node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - this.checkSemicolonOrLineBreak(member); - } - }; - return SemicolonNeverWalker; -}(SemicolonWalker)); -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.d.ts b/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.d.ts deleted file mode 100644 index 3806be5e9..000000000 --- a/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static INVALID_WHITESPACE_ERROR: string; - static MISSING_WHITESPACE_ERROR: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js b/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js deleted file mode 100644 index 2d7e934fa..000000000 --- a/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var ALWAYS_OR_NEVER = { - enum: ["always", "never"], - type: "string", -}; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments[0])); - }; - Rule.metadata = { - description: "Require or disallow a space before function parenthesis", - hasFix: true, - optionExamples: [ - true, - [true, "always"], - [true, "never"], - [true, { anonymous: "always", named: "never", asyncArrow: "always" }], - ], - options: { - properties: { - anonymous: ALWAYS_OR_NEVER, - asyncArrow: ALWAYS_OR_NEVER, - constructor: ALWAYS_OR_NEVER, - method: ALWAYS_OR_NEVER, - named: ALWAYS_OR_NEVER, - }, - type: "object", - }, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One argument which is an object which may contain the keys `anonymous`, `named`, and `asyncArrow`\n These should be set to either `\"always\"` or `\"never\"`.\n\n * `\"anonymous\"` checks before the opening paren in anonymous functions\n * `\"named\"` checks before the opening paren in named functions\n * `\"asyncArrow\"` checks before the opening paren in async arrow functions\n * `\"method\"` checks before the opening paren in class methods\n * `\"constructor\"` checks before the opening paren in class constructors\n "], ["\n One argument which is an object which may contain the keys \\`anonymous\\`, \\`named\\`, and \\`asyncArrow\\`\n These should be set to either \\`\"always\"\\` or \\`\"never\"\\`.\n\n * \\`\"anonymous\"\\` checks before the opening paren in anonymous functions\n * \\`\"named\"\\` checks before the opening paren in named functions\n * \\`\"asyncArrow\"\\` checks before the opening paren in async arrow functions\n * \\`\"method\"\\` checks before the opening paren in class methods\n * \\`\"constructor\"\\` checks before the opening paren in class constructors\n "]))), - ruleName: "space-before-function-paren", - type: "style", - typescriptOnly: false, - }; - Rule.INVALID_WHITESPACE_ERROR = "Spaces before function parens are disallowed"; - Rule.MISSING_WHITESPACE_ERROR = "Missing whitespace before function parens"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var optionNames = ["anonymous", "asyncArrow", "constructor", "method", "named"]; -function parseOptions(json) { - // Need to specify constructor or it will be Object - var options = { constructor: undefined }; - for (var _i = 0, optionNames_1 = optionNames; _i < optionNames_1.length; _i++) { - var optionName = optionNames_1[_i]; - options[optionName] = typeof json === "object" ? json[optionName] : json === undefined ? "always" : json; - } - return options; -} -function walk(ctx) { - var options = ctx.options, sourceFile = ctx.sourceFile; - ts.forEachChild(sourceFile, function cb(node) { - var option = getOption(node, options); - if (option !== undefined) { - check(node, option); - } - ts.forEachChild(node, cb); - }); - function check(node, option) { - var openParen = tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenParenToken, sourceFile); - // openParen may be missing for an async arrow function `async x => ...`. - if (openParen === undefined) { - return; - } - var hasSpace = Lint.isWhiteSpace(sourceFile.text.charCodeAt(openParen.end - 2)); - if (hasSpace && option === "never") { - var pos = openParen.getStart() - 1; - ctx.addFailureAt(pos, 1, Rule.INVALID_WHITESPACE_ERROR, Lint.Replacement.deleteText(pos, 1)); - } - else if (!hasSpace && option === "always") { - var pos = openParen.getStart(); - ctx.addFailureAt(pos, 1, Rule.MISSING_WHITESPACE_ERROR, Lint.Replacement.appendText(pos, " ")); - } - } -} -function getOption(node, options) { - switch (node.kind) { - case ts.SyntaxKind.ArrowFunction: - return !hasTypeParameters(node) && tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) - ? options.asyncArrow : undefined; - case ts.SyntaxKind.Constructor: - return options.constructor; - case ts.SyntaxKind.FunctionDeclaration: - // name is optional for function declaration which is default export (TS will emit error in other cases). - // Can be handled in the same way as function expression. - case ts.SyntaxKind.FunctionExpression: { - var functionName = node.name; - var hasName = functionName !== undefined && functionName.text !== ""; - return hasName ? options.named : !hasTypeParameters(node) ? options.anonymous : undefined; - } - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - return options.method; - default: - return undefined; - } -} -function hasTypeParameters(node) { - return node.typeParameters !== undefined; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/spaceWithinParensRule.d.ts b/node_modules/tslint/lib/rules/spaceWithinParensRule.d.ts deleted file mode 100644 index 37eb73ffd..000000000 --- a/node_modules/tslint/lib/rules/spaceWithinParensRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_NO_SPACE: string; - static FAILURE_NEEDS_SPACE(count: number): string; - static FAILURE_NO_EXTRA_SPACE(count: number): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/spaceWithinParensRule.js b/node_modules/tslint/lib/rules/spaceWithinParensRule.js deleted file mode 100644 index c53cc75ce..000000000 --- a/node_modules/tslint/lib/rules/spaceWithinParensRule.js +++ /dev/null @@ -1,158 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_NEEDS_SPACE = function (count) { - return "Needs " + count + " whitespace" + (count > 1 ? "s" : "") + " within parentheses"; - }; - Rule.FAILURE_NO_EXTRA_SPACE = function (count) { - return "No more than " + count + " whitespace" + (count > 1 ? "s" : "") + " within parentheses allowed"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new SpaceWithinParensWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments[0]))); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "space-within-parens", - description: "Enforces spaces within parentheses or disallow them. Empty parentheses () are always allowed.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n You may enforce the amount of whitespace within parentheses.\n "], ["\n You may enforce the amount of whitespace within parentheses.\n "]))), - options: { type: "number", min: 0 }, - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_NO_SPACE = "Whitespace within parentheses is not allowed"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(whitespaceSize) { - var size = 0; - if (typeof whitespaceSize === "number") { - if (whitespaceSize >= 0) { - size = whitespaceSize; - } - } - else if (typeof whitespaceSize === "string") { - var parsedSize = parseInt(whitespaceSize, 10); - if (!Number.isNaN(parsedSize) && parsedSize >= 0) { - size = parsedSize; - } - } - return { - size: size, - }; -} -var SpaceWithinParensWalker = /** @class */ (function (_super) { - tslib_1.__extends(SpaceWithinParensWalker, _super); - function SpaceWithinParensWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - SpaceWithinParensWalker.prototype.walk = function (sourceFile) { - var _this = this; - tsutils_1.forEachToken(sourceFile, function (token) { - if (token.kind === ts.SyntaxKind.OpenParenToken) { - if (sourceFile.text.charAt(token.end) !== ")") { - _this.checkOpenParenToken(token); - } - } - else if (token.kind === ts.SyntaxKind.CloseParenToken) { - if (sourceFile.text.charAt(token.end - 2) !== "(") { - _this.checkCloseParenToken(token); - } - } - }); - }; - SpaceWithinParensWalker.prototype.checkOpenParenToken = function (tokenNode) { - var currentPos = tokenNode.end; - var currentChar = this.sourceFile.text.charCodeAt(currentPos); - var allowedSpaceCount = this.options.size; - while (ts.isWhiteSpaceSingleLine(currentChar)) { - ++currentPos; - currentChar = this.sourceFile.text.charCodeAt(currentPos); - } - if (!ts.isLineBreak(currentChar)) { - var whitespaceCount = currentPos - tokenNode.end; - if (whitespaceCount !== allowedSpaceCount) { - var length = 0; - var pos = tokenNode.end; - if (whitespaceCount > allowedSpaceCount) { - pos += allowedSpaceCount; - length = whitespaceCount - allowedSpaceCount; - } - else if (whitespaceCount > 0 && whitespaceCount < allowedSpaceCount) { - pos += allowedSpaceCount - whitespaceCount; - } - this.addFailureAtWithFix(pos, length, whitespaceCount); - } - } - }; - SpaceWithinParensWalker.prototype.checkCloseParenToken = function (tokenNode) { - var currentPos = tokenNode.end - 2; - var currentChar = this.sourceFile.text.charCodeAt(currentPos); - var allowedSpaceCount = this.options.size; - while (ts.isWhiteSpaceSingleLine(currentChar)) { - --currentPos; - currentChar = this.sourceFile.text.charCodeAt(currentPos); - } - /** - * Number 40 is open parenthese char code, we skip this cause - * it's already been caught by `checkOpenParenToken` - */ - if (!ts.isLineBreak(currentChar) && currentChar !== 40) { - var whitespaceCount = tokenNode.end - currentPos - 2; - if (whitespaceCount !== allowedSpaceCount) { - var length = 0; - var pos = currentPos + 1; - if (whitespaceCount > allowedSpaceCount) { - length = whitespaceCount - allowedSpaceCount; - } - this.addFailureAtWithFix(pos, length, whitespaceCount); - } - } - }; - SpaceWithinParensWalker.prototype.addFailureAtWithFix = function (position, length, whitespaceCount) { - var lintMsg; - var lintFix; - var allowedSpaceCount = this.options.size; - if (allowedSpaceCount === 0) { - lintMsg = Rule.FAILURE_NO_SPACE; - lintFix = Lint.Replacement.deleteText(position, length); - } - else if (allowedSpaceCount > whitespaceCount) { - lintMsg = Rule.FAILURE_NEEDS_SPACE(allowedSpaceCount - whitespaceCount); - var whitespace = " ".repeat(allowedSpaceCount - whitespaceCount); - lintFix = Lint.Replacement.appendText(position, whitespace); - } - else { - lintMsg = Rule.FAILURE_NO_EXTRA_SPACE(allowedSpaceCount); - lintFix = Lint.Replacement.deleteText(position, whitespaceCount - allowedSpaceCount); - } - this.addFailureAt(position, length, lintMsg, lintFix); - }; - return SpaceWithinParensWalker; -}(Lint.AbstractWalker)); -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.d.ts b/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.d.ts deleted file mode 100644 index 10d7c24dc..000000000 --- a/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} -export declare type Location = ts.PrefixUnaryExpression | ts.IfStatement | ts.WhileStatement | ts.DoStatement | ts.ForStatement | ts.ConditionalExpression | ts.BinaryExpression; -export declare const enum TypeFailure { - AlwaysTruthy = 0, - AlwaysFalsy = 1, - String = 2, - Number = 3, - Null = 4, - Undefined = 5, - Enum = 6, - Mixes = 7 -} -declare module "typescript" { - interface IntrinsicType extends ts.Type { - intrinsicName: string; - } -} diff --git a/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js b/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js deleted file mode 100644 index dc3dd9227..000000000 --- a/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js +++ /dev/null @@ -1,375 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALLOW_NULL_UNION = "allow-null-union"; -var OPTION_ALLOW_UNDEFINED_UNION = "allow-undefined-union"; -var OPTION_ALLOW_STRING = "allow-string"; -var OPTION_ALLOW_NUMBER = "allow-number"; -var OPTION_ALLOW_MIX = "allow-mix"; -var OPTION_ALLOW_BOOLEAN_OR_UNDEFINED = "allow-boolean-or-undefined"; -// tslint:disable object-literal-sort-keys -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - var options = parseOptions(this.ruleArguments, Lint.isStrictNullChecksEnabled(program.getCompilerOptions())); - return this.applyWithFunction(sourceFile, walk, options, program.getTypeChecker()); - }; - Rule.metadata = { - ruleName: "strict-boolean-expressions", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Restricts the types allowed in boolean expressions. By default only booleans are allowed.\n\n The following nodes are checked:\n\n * Arguments to the `!`, `&&`, and `||` operators\n * The condition in a conditional expression (`cond ? x : y`)\n * Conditions for `if`, `for`, `while`, and `do-while` statements."], ["\n Restricts the types allowed in boolean expressions. By default only booleans are allowed.\n\n The following nodes are checked:\n\n * Arguments to the \\`!\\`, \\`&&\\`, and \\`||\\` operators\n * The condition in a conditional expression (\\`cond ? x : y\\`)\n * Conditions for \\`if\\`, \\`for\\`, \\`while\\`, and \\`do-while\\` statements."]))), - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n These options may be provided:\n\n * `", "` allows union types containing `null`.\n - It does *not* allow `null` itself.\n - Without the '--strictNullChecks' compiler option, this will allow anything other than a string, number, or enum.\n * `", "` allows union types containing `undefined`.\n - It does *not* allow `undefined` itself.\n - Without the '--strictNullChecks' compiler option, this will allow anything other than a string, number, or enum.\n * `", "` allows strings.\n - It does *not* allow unions containing `string`.\n - It does *not* allow string literal types.\n * `", "` allows numbers.\n - It does *not* allow unions containing `number`.\n - It does *not* allow enums or number literal types.\n * `", "` allows multiple of the above to appear together.\n - For example, `string | number` or `RegExp | null | undefined` would normally not be allowed.\n - A type like `\"foo\" | \"bar\" | undefined` is always allowed, because it has only one way to be false.\n * `", "` allows `boolean | undefined`.\n - Also allows `true | false | undefined`.\n - Does not allow `false | undefined`.\n - This option is a subset of `", "`, so you don't need to enable both options at the same time.\n "], ["\n These options may be provided:\n\n * \\`", "\\` allows union types containing \\`null\\`.\n - It does *not* allow \\`null\\` itself.\n - Without the '--strictNullChecks' compiler option, this will allow anything other than a string, number, or enum.\n * \\`", "\\` allows union types containing \\`undefined\\`.\n - It does *not* allow \\`undefined\\` itself.\n - Without the '--strictNullChecks' compiler option, this will allow anything other than a string, number, or enum.\n * \\`", "\\` allows strings.\n - It does *not* allow unions containing \\`string\\`.\n - It does *not* allow string literal types.\n * \\`", "\\` allows numbers.\n - It does *not* allow unions containing \\`number\\`.\n - It does *not* allow enums or number literal types.\n * \\`", "\\` allows multiple of the above to appear together.\n - For example, \\`string | number\\` or \\`RegExp | null | undefined\\` would normally not be allowed.\n - A type like \\`\"foo\" | \"bar\" | undefined\\` is always allowed, because it has only one way to be false.\n * \\`", "\\` allows \\`boolean | undefined\\`.\n - Also allows \\`true | false | undefined\\`.\n - Does not allow \\`false | undefined\\`.\n - This option is a subset of \\`", "\\`, so you don't need to enable both options at the same time.\n "])), OPTION_ALLOW_NULL_UNION, OPTION_ALLOW_UNDEFINED_UNION, OPTION_ALLOW_STRING, OPTION_ALLOW_NUMBER, OPTION_ALLOW_MIX, OPTION_ALLOW_BOOLEAN_OR_UNDEFINED, OPTION_ALLOW_UNDEFINED_UNION), - options: { - type: "array", - items: { - type: "string", - enum: [ - OPTION_ALLOW_NULL_UNION, - OPTION_ALLOW_UNDEFINED_UNION, - OPTION_ALLOW_STRING, - OPTION_ALLOW_NUMBER, - OPTION_ALLOW_BOOLEAN_OR_UNDEFINED, - ], - }, - minLength: 0, - maxLength: 5, - }, - optionExamples: [ - true, - [true, OPTION_ALLOW_NULL_UNION, OPTION_ALLOW_UNDEFINED_UNION, OPTION_ALLOW_STRING, OPTION_ALLOW_NUMBER], - [true, OPTION_ALLOW_BOOLEAN_OR_UNDEFINED], - ], - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function parseOptions(ruleArguments, strictNullChecks) { - return { - strictNullChecks: strictNullChecks, - allowNullUnion: has(OPTION_ALLOW_NULL_UNION), - allowUndefinedUnion: has(OPTION_ALLOW_UNDEFINED_UNION), - allowString: has(OPTION_ALLOW_STRING), - allowNumber: has(OPTION_ALLOW_NUMBER), - allowMix: has(OPTION_ALLOW_MIX), - allowBooleanOrUndefined: has(OPTION_ALLOW_BOOLEAN_OR_UNDEFINED), - }; - function has(name) { - return ruleArguments.indexOf(name) !== -1; - } -} -function walk(ctx, checker) { - var sourceFile = ctx.sourceFile, options = ctx.options; - ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.BinaryExpression: { - var b_1 = node; - if (binaryBooleanExpressionKind(b_1) !== undefined) { - var left = b_1.left, right = b_1.right; - var checkHalf = function (expr) { - // If it's another boolean binary expression, we'll check it when recursing. - if (!isBooleanBinaryExpression(expr)) { - checkExpression(expr, b_1); - } - }; - checkHalf(left); - checkHalf(right); - } - break; - } - case ts.SyntaxKind.PrefixUnaryExpression: { - var _a = node, operator = _a.operator, operand = _a.operand; - if (operator === ts.SyntaxKind.ExclamationToken) { - checkExpression(operand, node); - } - break; - } - case ts.SyntaxKind.IfStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: { - var c = node; - // If it's a boolean binary expression, we'll check it when recursing. - if (!isBooleanBinaryExpression(c.expression)) { - checkExpression(c.expression, c); - } - break; - } - case ts.SyntaxKind.ConditionalExpression: - checkExpression(node.condition, node); - break; - case ts.SyntaxKind.ForStatement: { - var condition = node.condition; - if (condition !== undefined) { - checkExpression(condition, node); - } - } - } - return ts.forEachChild(node, cb); - }); - function checkExpression(node, location) { - var type = checker.getTypeAtLocation(node); - var failure = getTypeFailure(type, options); - if (failure !== undefined) { - if (failure === 0 /* AlwaysTruthy */ && - !options.strictNullChecks && - (options.allowNullUnion || options.allowUndefinedUnion)) { - // OK; It might be null/undefined. - return; - } - ctx.addFailureAtNode(node, showFailure(location, failure, isUnionType(type), options)); - } - } -} -function getTypeFailure(type, options) { - if (isUnionType(type)) { - return handleUnion(type, options); - } - var kind = getKind(type); - var failure = failureForKind(kind, /*isInUnion*/ false, options); - if (failure !== undefined) { - return failure; - } - switch (triState(kind)) { - case true: - // Allow 'any'. Allow 'true' itself, but not any other always-truthy type. - // tslint:disable-next-line no-bitwise - return tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Any | ts.TypeFlags.BooleanLiteral) ? undefined : 0 /* AlwaysTruthy */; - case false: - // Allow 'false' itself, but not any other always-falsy type - return tsutils_1.isTypeFlagSet(type, ts.TypeFlags.BooleanLiteral) ? undefined : 1 /* AlwaysFalsy */; - case undefined: - return undefined; - } -} -function isBooleanUndefined(type) { - var isTruthy = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var ty = _a[_i]; - if (tsutils_1.isTypeFlagSet(ty, ts.TypeFlags.Boolean)) { - isTruthy = true; - } - else if (tsutils_1.isTypeFlagSet(ty, ts.TypeFlags.BooleanLiteral)) { - isTruthy = isTruthy || ty.intrinsicName === "true"; - } - else if (!tsutils_1.isTypeFlagSet(ty, ts.TypeFlags.Void | ts.TypeFlags.Undefined)) { // tslint:disable-line:no-bitwise - return undefined; - } - } - return isTruthy; -} -function handleUnion(type, options) { - if (options.allowBooleanOrUndefined) { - switch (isBooleanUndefined(type)) { - case true: - return undefined; - case false: - return 1 /* AlwaysFalsy */; - } - } - // Tracks whether it's possibly truthy. - var anyTruthy = false; - // Counts falsy kinds to see if there's a mix. Also tracks whether it's possibly falsy. - var seenFalsy = 0; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var ty = _a[_i]; - var kind = getKind(ty); - var failure = failureForKind(kind, /*isInUnion*/ true, options); - if (failure !== undefined) { - return failure; - } - switch (triState(kind)) { - case true: - anyTruthy = true; - break; - case false: - seenFalsy++; - break; - default: - anyTruthy = true; - seenFalsy++; - } - } - return seenFalsy === 0 ? 0 /* AlwaysTruthy */ - : !anyTruthy ? 1 /* AlwaysFalsy */ - : !options.allowMix && seenFalsy > 1 ? 7 /* Mixes */ : undefined; -} -/** Fails if a kind of falsiness is not allowed. */ -function failureForKind(kind, isInUnion, options) { - switch (kind) { - case 0 /* String */: - case 1 /* FalseStringLiteral */: - return options.allowString ? undefined : 2 /* String */; - case 2 /* Number */: - case 3 /* FalseNumberLiteral */: - return options.allowNumber ? undefined : 3 /* Number */; - case 8 /* Enum */: - return 6 /* Enum */; - case 6 /* Null */: - return isInUnion && !options.allowNullUnion ? 4 /* Null */ : undefined; - case 7 /* Undefined */: - return isInUnion && !options.allowUndefinedUnion ? 5 /* Undefined */ : undefined; - default: - return undefined; - } -} -/** Divides a type into always true, always false, or unknown. */ -function triState(kind) { - switch (kind) { - case 0 /* String */: - case 2 /* Number */: - case 4 /* Boolean */: - case 8 /* Enum */: - return undefined; - case 6 /* Null */: - case 7 /* Undefined */: - case 3 /* FalseNumberLiteral */: - case 1 /* FalseStringLiteral */: - case 5 /* FalseBooleanLiteral */: - return false; - case 9 /* AlwaysTruthy */: - return true; - } -} -function getKind(type) { - return is(ts.TypeFlags.String) ? 0 /* String */ - : is(ts.TypeFlags.Number) ? 2 /* Number */ - : is(ts.TypeFlags.Boolean) ? 4 /* Boolean */ - : is(ts.TypeFlags.Null) ? 6 /* Null */ - : is(ts.TypeFlags.Undefined | ts.TypeFlags.Void) ? 7 /* Undefined */ - : is(ts.TypeFlags.EnumLike) ? 8 /* Enum */ - : is(ts.TypeFlags.NumberLiteral) ? - (numberLiteralIsZero(type) ? 3 /* FalseNumberLiteral */ : 9 /* AlwaysTruthy */) - : is(ts.TypeFlags.StringLiteral) ? - (stringLiteralIsEmpty(type) ? 1 /* FalseStringLiteral */ : 9 /* AlwaysTruthy */) - : is(ts.TypeFlags.BooleanLiteral) ? - (type.intrinsicName === "true" ? 9 /* AlwaysTruthy */ : 5 /* FalseBooleanLiteral */) - : 9 /* AlwaysTruthy */; - function is(flags) { - return tsutils_1.isTypeFlagSet(type, flags); - } -} -function numberLiteralIsZero(type) { - // for compatibility with typescript@<2.4.0 - return type.value !== undefined ? type.value === 0 : type.text === "0"; -} -function stringLiteralIsEmpty(type) { - // for compatibility with typescript@<2.4.0 - return (type.value !== undefined ? type.value : type.text) === ""; -} -/** Matches `&&` and `||` operators. */ -function isBooleanBinaryExpression(node) { - return node.kind === ts.SyntaxKind.BinaryExpression && binaryBooleanExpressionKind(node) !== undefined; -} -function binaryBooleanExpressionKind(node) { - switch (node.operatorToken.kind) { - case ts.SyntaxKind.AmpersandAmpersandToken: - return "&&"; - case ts.SyntaxKind.BarBarToken: - return "||"; - default: - return undefined; - } -} -function stringOr(parts) { - switch (parts.length) { - case 1: - return parts[0]; - case 2: - return parts[0] + " or " + parts[1]; - default: - var res = ""; - for (var i = 0; i < parts.length - 1; i++) { - res += parts[i] + ", "; - } - return res + "or " + parts[parts.length - 1]; - } -} -function isUnionType(type) { - return tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Union) && !tsutils_1.isTypeFlagSet(type, ts.TypeFlags.Enum); -} -function showLocation(n) { - switch (n.kind) { - case ts.SyntaxKind.PrefixUnaryExpression: - return "operand for the '!' operator"; - case ts.SyntaxKind.ConditionalExpression: - return "condition"; - case ts.SyntaxKind.ForStatement: - return "'for' condition"; - case ts.SyntaxKind.IfStatement: - return "'if' condition"; - case ts.SyntaxKind.WhileStatement: - return "'while' condition"; - case ts.SyntaxKind.DoStatement: - return "'do-while' condition"; - case ts.SyntaxKind.BinaryExpression: - return "operand for the '" + binaryBooleanExpressionKind(n) + "' operator"; - } -} -function showFailure(location, ty, unionType, options) { - var expectedTypes = showExpectedTypes(options); - var expected = expectedTypes.length === 1 - ? "Only " + expectedTypes[0] + "s are allowed" - : "Allowed types are " + stringOr(expectedTypes); - var tyFail = showTypeFailure(ty, unionType, options.strictNullChecks); - return "This type is not allowed in the " + showLocation(location) + " because it " + tyFail + ". " + expected + "."; -} -function showExpectedTypes(options) { - var parts = ["boolean"]; - if (options.allowNullUnion) { - parts.push("null-union"); - } - if (options.allowUndefinedUnion) { - parts.push("undefined-union"); - } - if (options.allowString) { - parts.push("string"); - } - if (options.allowNumber) { - parts.push("number"); - } - if (options.allowBooleanOrUndefined) { - parts.push("boolean-or-undefined"); - } - return parts; -} -function showTypeFailure(ty, unionType, strictNullChecks) { - var is = unionType ? "could be" : "is"; - switch (ty) { - case 0 /* AlwaysTruthy */: - return strictNullChecks - ? "is always truthy" - : "is always truthy. It may be null/undefined, but neither " + - ("'" + OPTION_ALLOW_NULL_UNION + "' nor '" + OPTION_ALLOW_UNDEFINED_UNION + "' is set"); - case 1 /* AlwaysFalsy */: return "is always falsy"; - case 2 /* String */: return is + " a string"; - case 3 /* Number */: return is + " a number"; - case 4 /* Null */: return is + " null"; - case 5 /* Undefined */: return is + " undefined"; - case 6 /* Enum */: return is + " an enum"; - case 7 /* Mixes */: return "unions more than one truthy/falsy type"; - } -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/strictTypePredicatesRule.d.ts b/node_modules/tslint/lib/rules/strictTypePredicatesRule.d.ts deleted file mode 100644 index 1ad0fb902..000000000 --- a/node_modules/tslint/lib/rules/strictTypePredicatesRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_BAD_TYPEOF: string; - static FAILURE_STRING(value: boolean): string; - static FAILURE_STRICT_PREFER_STRICT_EQUALS(value: "null" | "undefined", isPositive: boolean): string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/strictTypePredicatesRule.js b/node_modules/tslint/lib/rules/strictTypePredicatesRule.js deleted file mode 100644 index 0a4c1a41e..000000000 --- a/node_modules/tslint/lib/rules/strictTypePredicatesRule.js +++ /dev/null @@ -1,229 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var error_1 = require("../error"); -var Lint = require("../index"); -// tslint:disable:no-bitwise -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.FAILURE_STRING = function (value) { - return "Expression is always " + value + "."; - }; - Rule.FAILURE_STRICT_PREFER_STRICT_EQUALS = function (value, isPositive) { - return "Use '" + (isPositive ? "===" : "!==") + " " + value + "' instead."; - }; - Rule.prototype.applyWithProgram = function (sourceFile, program) { - if (!Lint.isStrictNullChecksEnabled(program.getCompilerOptions())) { - error_1.showWarningOnce("strict-type-predicates does not work without --strictNullChecks"); - return []; - } - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "strict-type-predicates", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Warns for type predicates that are always true or always false.\n Works for 'typeof' comparisons to constants (e.g. 'typeof foo === \"string\"'), and equality comparison to 'null'/'undefined'.\n (TypeScript won't let you compare '1 === 2', but it has an exception for '1 === undefined'.)\n Does not yet work for 'instanceof'.\n Does *not* warn for 'if (x.y)' where 'x.y' is always truthy. For that, see strict-boolean-expressions.\n\n This rule requires `strictNullChecks` to work properly."], ["\n Warns for type predicates that are always true or always false.\n Works for 'typeof' comparisons to constants (e.g. 'typeof foo === \"string\"'), and equality comparison to 'null'/'undefined'.\n (TypeScript won't let you compare '1 === 2', but it has an exception for '1 === undefined'.)\n Does not yet work for 'instanceof'.\n Does *not* warn for 'if (x.y)' where 'x.y' is always truthy. For that, see strict-boolean-expressions.\n\n This rule requires \\`strictNullChecks\\` to work properly."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_BAD_TYPEOF = "Bad comparison for 'typeof'."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBinaryExpression(node)) { - var equals = Lint.getEqualsKind(node.operatorToken); - if (equals !== undefined) { - checkEquals(node, equals); - } - } - return ts.forEachChild(node, cb); - }); - function checkEquals(node, _a) { - var isStrict = _a.isStrict, isPositive = _a.isPositive; - var exprPred = getTypePredicate(node, isStrict); - if (exprPred === undefined) { - return; - } - if (exprPred.kind === 2 /* TypeofTypo */) { - fail(Rule.FAILURE_STRING_BAD_TYPEOF); - return; - } - var exprType = checker.getTypeAtLocation(exprPred.expression); - // TODO: could use checker.getBaseConstraintOfType to help with type parameters, but it's not publicly exposed. - if (tsutils_1.isTypeFlagSet(exprType, ts.TypeFlags.Any | ts.TypeFlags.TypeParameter)) { - return; - } - switch (exprPred.kind) { - case 0 /* Plain */: { - var predicate = exprPred.predicate, isNullOrUndefined = exprPred.isNullOrUndefined; - var value = getConstantBoolean(exprType, predicate); - // 'null'/'undefined' are the only two values *not* assignable to '{}'. - if (value !== undefined && (isNullOrUndefined || !isEmptyType(checker, exprType))) { - fail(Rule.FAILURE_STRING(value === isPositive)); - } - break; - } - case 1 /* NonStructNullUndefined */: { - var result = testNonStrictNullUndefined(exprType); - if (result !== undefined) { - fail(typeof result === "boolean" - ? Rule.FAILURE_STRING(result === isPositive) - : Rule.FAILURE_STRICT_PREFER_STRICT_EQUALS(result, isPositive)); - } - } - } - function fail(failure) { - ctx.addFailureAtNode(node, failure); - } - } -} -/** Detects a type predicate given `left === right`. */ -function getTypePredicate(node, isStrictEquals) { - var left = node.left, right = node.right; - var lr = getTypePredicateOneWay(left, right, isStrictEquals); - return lr !== undefined ? lr : getTypePredicateOneWay(right, left, isStrictEquals); -} -/** Only gets the type predicate if the expression is on the left. */ -function getTypePredicateOneWay(left, right, isStrictEquals) { - switch (right.kind) { - case ts.SyntaxKind.TypeOfExpression: - var expression = right.expression; - if (!tsutils_1.isLiteralExpression(left)) { - if (tsutils_1.isIdentifier(left) && left.text === "undefined" || - left.kind === ts.SyntaxKind.NullKeyword || - left.kind === ts.SyntaxKind.TrueKeyword || - left.kind === ts.SyntaxKind.FalseKeyword) { - return { kind: 2 /* TypeofTypo */ }; - } - return undefined; - } - var predicate = getTypePredicateForKind(left.text); - return predicate === undefined - ? { kind: 2 /* TypeofTypo */ } - : { kind: 0 /* Plain */, expression: expression, predicate: predicate, isNullOrUndefined: left.text === "undefined" }; - case ts.SyntaxKind.NullKeyword: - return nullOrUndefined(ts.TypeFlags.Null); - case ts.SyntaxKind.Identifier: - if (right.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) { - return nullOrUndefined(undefinedFlags); - } - return undefined; - default: - return undefined; - } - function nullOrUndefined(flags) { - return isStrictEquals - ? { kind: 0 /* Plain */, expression: left, predicate: flagPredicate(flags), isNullOrUndefined: true } - : { kind: 1 /* NonStructNullUndefined */, expression: left }; - } -} -function isEmptyType(checker, type) { - return checker.typeToString(type) === "{}"; -} -var undefinedFlags = ts.TypeFlags.Undefined | ts.TypeFlags.Void; -function getTypePredicateForKind(kind) { - switch (kind) { - case "undefined": - return flagPredicate(undefinedFlags); - case "boolean": - return flagPredicate(ts.TypeFlags.BooleanLike); - case "number": - return flagPredicate(ts.TypeFlags.NumberLike); - case "string": - return flagPredicate(ts.TypeFlags.StringLike); - case "symbol": - return flagPredicate(ts.TypeFlags.ESSymbol); - case "function": - return isFunction; - case "object": - // It's an object if it's not any of the above. - var allFlags_1 = ts.TypeFlags.Undefined | ts.TypeFlags.Void | ts.TypeFlags.BooleanLike | - ts.TypeFlags.NumberLike | ts.TypeFlags.StringLike | ts.TypeFlags.ESSymbol; - return function (type) { return !tsutils_1.isTypeFlagSet(type, allFlags_1) && !isFunction(type); }; - default: - return undefined; - } -} -function flagPredicate(testedFlag) { - return function (type) { return tsutils_1.isTypeFlagSet(type, testedFlag); }; -} -function isFunction(t) { - if (t.getConstructSignatures().length !== 0 || t.getCallSignatures().length !== 0) { - return true; - } - var symbol = t.getSymbol(); - return symbol !== undefined && symbol.getName() === "Function"; -} -/** Returns a boolean value if that should always be the result of a type predicate. */ -function getConstantBoolean(type, predicate) { - var anyTrue = false; - var anyFalse = false; - for (var _i = 0, _a = unionParts(type); _i < _a.length; _i++) { - var ty = _a[_i]; - if (predicate(ty)) { - anyTrue = true; - } - else { - anyFalse = true; - } - if (anyTrue && anyFalse) { - return undefined; - } - } - return anyTrue; -} -/** Returns bool for always/never true, or a string to recommend strict equality. */ -function testNonStrictNullUndefined(type) { - var anyNull = false; - var anyUndefined = false; - var anyOther = false; - for (var _i = 0, _a = unionParts(type); _i < _a.length; _i++) { - var ty = _a[_i]; - if (tsutils_1.isTypeFlagSet(ty, ts.TypeFlags.Null)) { - anyNull = true; - } - else if (tsutils_1.isTypeFlagSet(ty, undefinedFlags)) { - anyUndefined = true; - } - else { - anyOther = true; - } - } - return !anyOther ? true - : anyNull && anyUndefined ? undefined - : anyNull ? "null" - : anyUndefined ? "undefined" - : false; -} -function unionParts(type) { - return tsutils_1.isUnionType(type) ? type.types : [type]; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/switchDefaultRule.d.ts b/node_modules/tslint/lib/rules/switchDefaultRule.d.ts deleted file mode 100644 index 06b7c4bbe..000000000 --- a/node_modules/tslint/lib/rules/switchDefaultRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/switchDefaultRule.js b/node_modules/tslint/lib/rules/switchDefaultRule.js deleted file mode 100644 index 0fc7d1aa6..000000000 --- a/node_modules/tslint/lib/rules/switchDefaultRule.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2015 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "switch-default", - description: "Require a `default` case in all `switch` statements.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Switch statement should include a 'default' case"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (node.kind === ts.SyntaxKind.SwitchStatement && - !node.caseBlock.clauses.some(tsutils_1.isDefaultClause)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - return ts.forEachChild(node, cb); - }); -} diff --git a/node_modules/tslint/lib/rules/switchFinalBreakRule.d.ts b/node_modules/tslint/lib/rules/switchFinalBreakRule.d.ts deleted file mode 100644 index 7c36ce7a5..000000000 --- a/node_modules/tslint/lib/rules/switchFinalBreakRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_ALWAYS: string; - static FAILURE_STRING_NEVER: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/switchFinalBreakRule.js b/node_modules/tslint/lib/rules/switchFinalBreakRule.js deleted file mode 100644 index bc6417eab..000000000 --- a/node_modules/tslint/lib/rules/switchFinalBreakRule.js +++ /dev/null @@ -1,110 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALWAYS = "always"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { always: this.ruleArguments.indexOf(OPTION_ALWAYS) !== -1 }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "switch-final-break", - description: "Checks whether the final clause of a switch statement ends in \`break;\`.", - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If no options are passed, a final 'break;' is forbidden.\n If the \"always\" option is passed this will require a 'break;' to always be present\n unless control flow is escaped in some other way."], ["\n If no options are passed, a final 'break;' is forbidden.\n If the \"always\" option is passed this will require a 'break;' to always be present\n unless control flow is escaped in some other way."]))), - options: { - type: "string", - enum: [ - OPTION_ALWAYS, - ], - }, - optionExamples: [true, [true, OPTION_ALWAYS]], - type: "style", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_ALWAYS = "Final clause in 'switch' statement should end with 'break;'."; - Rule.FAILURE_STRING_NEVER = "Final clause in 'switch' statement should not end with 'break;'."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile, always = ctx.options.always; - ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isSwitchStatement(node)) { - check(node); - } - ts.forEachChild(node, cb); - }); - function check(node) { - var clause = last(node.caseBlock.clauses); - if (clause === undefined) { - return; - } - if (always) { - if (!tsutils_1.endsControlFlow(clause)) { - ctx.addFailureAtNode(clause.getChildAt(0), Rule.FAILURE_STRING_ALWAYS, createAddFix(clause)); - } - return; - } - var lastStatement = getLastStatement(clause); - if (lastStatement === undefined || !tsutils_1.isBreakStatement(lastStatement)) { - return; - } - if (lastStatement.label !== undefined) { - var parent = node.parent; - if (!tsutils_1.isLabeledStatement(parent) || parent.label === lastStatement.label) { - // break jumps somewhere else, don't complain - return; - } - } - ctx.addFailureAtNode(lastStatement, Rule.FAILURE_STRING_NEVER, createRemoveFix(lastStatement)); - } - function createAddFix(clause) { - var lastStatement = getLastStatement(clause); - if (lastStatement === undefined) { - return Lint.Replacement.appendText(clause.end, " break;"); - } - var fullText = lastStatement.getFullText(ctx.sourceFile); - var indentation = fullText.slice(0, fullText.search(/\S+/)); - return Lint.Replacement.appendText(lastStatement.end, indentation + "break;"); - } - function createRemoveFix(lastStatement) { - return Lint.Replacement.replaceFromTo(lastStatement.getFullStart(), lastStatement.end, ""); - } -} -function getLastStatement(clause) { - if (clause.statements.length === 0) { - return undefined; - } - var block = clause.statements[0]; - var statements = clause.statements.length === 1 && tsutils_1.isBlock(block) ? block.statements : clause.statements; - return last(statements); -} -function last(arr) { - return arr[arr.length - 1]; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/trailingCommaRule.d.ts b/node_modules/tslint/lib/rules/trailingCommaRule.d.ts deleted file mode 100644 index 8b60fb6f7..000000000 --- a/node_modules/tslint/lib/rules/trailingCommaRule.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_NEVER: string; - static FAILURE_STRING_FORBIDDEN: string; - static FAILURE_STRING_ALWAYS: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; - isEnabled(): boolean; -} diff --git a/node_modules/tslint/lib/rules/trailingCommaRule.js b/node_modules/tslint/lib/rules/trailingCommaRule.js deleted file mode 100644 index f6270e27c..000000000 --- a/node_modules/tslint/lib/rules/trailingCommaRule.js +++ /dev/null @@ -1,234 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var defaultOptions = fillOptions("ignore"); -function fillOptions(value) { - return { - arrays: value, - exports: value, - functions: value, - imports: value, - objects: value, - typeLiterals: value, - }; -} -function normalizeOptions(options) { - return { multiline: normalize(options.multiline), singleline: normalize(options.singleline), specCompliant: !!options.esSpecCompliant }; -} -function normalize(value) { - return typeof value === "string" ? fillOptions(value) : tslib_1.__assign({}, defaultOptions, value); -} -/* tslint:disable:object-literal-sort-keys */ -var metadataOptionShape = { - anyOf: [ - { - type: "string", - enum: ["always", "never"], - }, - { - type: "object", - properties: fillOptions({ - type: "string", - enum: ["always", "never", "ignore"], - }), - }, - ], -}; -/* tslint:enable:object-literal-sort-keys */ -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - var options = normalizeOptions(this.ruleArguments[0]); - return this.applyWithWalker(new TrailingCommaWalker(sourceFile, this.ruleName, options)); - }; - Rule.prototype.isEnabled = function () { - return _super.prototype.isEnabled.call(this) && this.ruleArguments.length !== 0; - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "trailing-comma", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings,\n named imports and exports and function parameters."], ["\n Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings,\n named imports and exports and function parameters."]))), - hasFix: true, - optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n One argument which is an object with the keys `multiline` and `singleline`.\n Both can be set to a string (`\"always\"` or `\"never\"`) or an object.\n\n The object can contain any of the following keys: `\"arrays\"`, `\"objects\"`, `\"functions\"`,\n `\"imports\"`, `\"exports\"`, and `\"typeLiterals\"`; each key can have one of the following\n values: `\"always\"`, `\"never\"`, and `\"ignore\"`. Any missing keys will default to `\"ignore\"`.\n\n * `\"multiline\"` checks multi-line object literals.\n * `\"singleline\"` checks single-line object literals.\n\n An array is considered \"multiline\" if its closing bracket is on a line\n after the last array element. The same general logic is followed for\n object literals, function typings, named import statements\n and function parameters.\n\n To align this rule with the ECMAScript specification that is implemented in modern JavaScript VMs,\n there is a third option `esSpecCompliant`. Set this option to `true` to disallow trailing comma on\n object and array rest and rest parameters.\n "], ["\n One argument which is an object with the keys \\`multiline\\` and \\`singleline\\`.\n Both can be set to a string (\\`\"always\"\\` or \\`\"never\"\\`) or an object.\n\n The object can contain any of the following keys: \\`\"arrays\"\\`, \\`\"objects\"\\`, \\`\"functions\"\\`,\n \\`\"imports\"\\`, \\`\"exports\"\\`, and \\`\"typeLiterals\"\\`; each key can have one of the following\n values: \\`\"always\"\\`, \\`\"never\"\\`, and \\`\"ignore\"\\`. Any missing keys will default to \\`\"ignore\"\\`.\n\n * \\`\"multiline\"\\` checks multi-line object literals.\n * \\`\"singleline\"\\` checks single-line object literals.\n\n An array is considered \"multiline\" if its closing bracket is on a line\n after the last array element. The same general logic is followed for\n object literals, function typings, named import statements\n and function parameters.\n\n To align this rule with the ECMAScript specification that is implemented in modern JavaScript VMs,\n there is a third option \\`esSpecCompliant\\`. Set this option to \\`true\\` to disallow trailing comma on\n object and array rest and rest parameters.\n "]))), - options: { - type: "object", - properties: { - multiline: metadataOptionShape, - singleline: metadataOptionShape, - esSpecCompliant: { type: "boolean" }, - }, - additionalProperties: false, - }, - optionExamples: [ - [true, { multiline: "always", singleline: "never" }], - [ - true, - { - multiline: { - objects: "always", - arrays: "always", - functions: "never", - typeLiterals: "ignore", - }, - esSpecCompliant: true, - }, - ], - ], - type: "maintainability", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_NEVER = "Unnecessary trailing comma"; - Rule.FAILURE_STRING_FORBIDDEN = "Forbidden trailing comma"; - Rule.FAILURE_STRING_ALWAYS = "Missing trailing comma"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var TrailingCommaWalker = /** @class */ (function (_super) { - tslib_1.__extends(TrailingCommaWalker, _super); - function TrailingCommaWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - TrailingCommaWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - switch (node.kind) { - case ts.SyntaxKind.ArrayLiteralExpression: - _this.checkList(node.elements, node.end, "arrays", isArrayRest); - break; - case ts.SyntaxKind.ArrayBindingPattern: - _this.checkList(node.elements, node.end, "arrays", isDestructuringRest); - break; - case ts.SyntaxKind.ObjectBindingPattern: - _this.checkList(node.elements, node.end, "objects", isDestructuringRest); - break; - case ts.SyntaxKind.NamedImports: - _this.checkList(node.elements, node.end, "imports", noRest); - break; - case ts.SyntaxKind.NamedExports: - _this.checkList(node.elements, node.end, "exports", noRest); - break; - case ts.SyntaxKind.ObjectLiteralExpression: - _this.checkList(node.properties, node.end, "objects", isObjectRest); - break; - case ts.SyntaxKind.EnumDeclaration: - _this.checkList(node.members, node.end, "objects", noRest); - break; - case ts.SyntaxKind.NewExpression: - if (node.arguments === undefined) { - break; - } - // falls through - case ts.SyntaxKind.CallExpression: - _this.checkList(node.arguments, node.end, "functions", noRest); - break; - case ts.SyntaxKind.ArrowFunction: - // don't check arrow functions without parens around the parameter - if (tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenParenToken, _this.sourceFile) === undefined) { - break; - } - // falls through - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.SetAccessor: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.ConstructorType: - case ts.SyntaxKind.FunctionType: - case ts.SyntaxKind.CallSignature: - _this.checkList(node.parameters, tsutils_1.getChildOfKind(node, ts.SyntaxKind.CloseParenToken, _this.sourceFile).end, "functions", isRestParameter); - break; - case ts.SyntaxKind.TypeLiteral: - _this.checkTypeLiteral(node); - break; - default: - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - TrailingCommaWalker.prototype.checkTypeLiteral = function (node) { - var members = node.members; - if (members.length === 0) { - return; - } - var sourceText = this.sourceFile.text; - for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { - var member = members_1[_i]; - // PropertySignature in TypeLiteral can end with semicolon or comma. If one ends with a semicolon don't check for trailing comma - if (sourceText[member.end - 1] === ";") { - return; - } - } - // The trailing comma is part of the last member and therefore not present as hasTrailingComma on the NodeArray - var hasTrailingComma = sourceText[members.end - 1] === ","; - return this.checkComma(hasTrailingComma, members, node.end, "typeLiterals", noRest); - }; - TrailingCommaWalker.prototype.checkList = function (list, closeElementPos, optionKey, isRest) { - if (list.length === 0) { - return; - } - return this.checkComma(list.hasTrailingComma, list, closeElementPos, optionKey, isRest); - }; - /* Expects `list.length !== 0` */ - TrailingCommaWalker.prototype.checkComma = function (hasTrailingComma, list, closeTokenPos, optionKey, isRest) { - var last = list[list.length - 1]; - if (this.options.specCompliant && isRest(last)) { - if (hasTrailingComma) { - this.addFailureAt(list.end - 1, 1, Rule.FAILURE_STRING_FORBIDDEN, Lint.Replacement.deleteText(list.end - 1, 1)); - } - return; - } - var options = tsutils_1.isSameLine(this.sourceFile, last.end, closeTokenPos) - ? this.options.singleline - : this.options.multiline; - var option = options[optionKey]; - if (option === "always" && !hasTrailingComma) { - this.addFailureAt(list.end, 0, Rule.FAILURE_STRING_ALWAYS, Lint.Replacement.appendText(list.end, ",")); - } - else if (option === "never" && hasTrailingComma) { - this.addFailureAt(list.end - 1, 1, Rule.FAILURE_STRING_NEVER, Lint.Replacement.deleteText(list.end - 1, 1)); - } - }; - return TrailingCommaWalker; -}(Lint.AbstractWalker)); -function isRestParameter(node) { - return node.dotDotDotToken !== undefined; -} -function isDestructuringRest(node) { - return node.kind === ts.SyntaxKind.BindingElement && node.dotDotDotToken !== undefined; -} -function isObjectRest(node) { - return node.kind === ts.SyntaxKind.SpreadAssignment && tsutils_1.isReassignmentTarget(node.expression); -} -function isArrayRest(node) { - return node.kind === ts.SyntaxKind.SpreadElement && tsutils_1.isReassignmentTarget(node); -} -function noRest() { - return false; -} -var templateObject_1, templateObject_2; diff --git a/node_modules/tslint/lib/rules/tripleEqualsRule.d.ts b/node_modules/tslint/lib/rules/tripleEqualsRule.d.ts deleted file mode 100644 index 1d2d9cb96..000000000 --- a/node_modules/tslint/lib/rules/tripleEqualsRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static EQ_FAILURE_STRING: string; - static NEQ_FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/tripleEqualsRule.js b/node_modules/tslint/lib/rules/tripleEqualsRule.js deleted file mode 100644 index a5b1fbbf7..000000000 --- a/node_modules/tslint/lib/rules/tripleEqualsRule.js +++ /dev/null @@ -1,86 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_ALLOW_NULL_CHECK = "allow-null-check"; -var OPTION_ALLOW_UNDEFINED_CHECK = "allow-undefined-check"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, { - allowNull: this.ruleArguments.indexOf(OPTION_ALLOW_NULL_CHECK) !== -1, - allowUndefined: this.ruleArguments.indexOf(OPTION_ALLOW_UNDEFINED_CHECK) !== -1, - }); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "triple-equals", - description: "Requires `===` and `!==` in place of `==` and `!=`.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Two arguments may be optionally provided:\n\n * `\"allow-null-check\"` allows `==` and `!=` when comparing to `null`.\n * `\"allow-undefined-check\"` allows `==` and `!=` when comparing to `undefined`."], ["\n Two arguments may be optionally provided:\n\n * \\`\"allow-null-check\"\\` allows \\`==\\` and \\`!=\\` when comparing to \\`null\\`.\n * \\`\"allow-undefined-check\"\\` allows \\`==\\` and \\`!=\\` when comparing to \\`undefined\\`."]))), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_ALLOW_NULL_CHECK, OPTION_ALLOW_UNDEFINED_CHECK], - }, - minLength: 0, - maxLength: 2, - }, - optionExamples: [ - true, - [true, "allow-null-check"], - [true, "allow-undefined-check"], - ], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.EQ_FAILURE_STRING = "== should be ==="; - Rule.NEQ_FAILURE_STRING = "!= should be !=="; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBinaryExpression(node)) { - if ((node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsToken || - node.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsToken) && - !(isExpressionAllowed(node.right, ctx.options) || isExpressionAllowed(node.left, ctx.options))) { - ctx.addFailureAtNode(node.operatorToken, node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsToken - ? Rule.EQ_FAILURE_STRING - : Rule.NEQ_FAILURE_STRING); - } - } - return ts.forEachChild(node, cb); - }); -} -function isExpressionAllowed(node, options) { - if (node.kind === ts.SyntaxKind.NullKeyword) { - return options.allowNull; - } - return options.allowUndefined && - node.kind === ts.SyntaxKind.Identifier && - node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/typeLiteralDelimiterRule.d.ts b/node_modules/tslint/lib/rules/typeLiteralDelimiterRule.d.ts deleted file mode 100644 index 38389b0de..000000000 --- a/node_modules/tslint/lib/rules/typeLiteralDelimiterRule.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_MISSING: string; - static FAILURE_STRING_COMMA: string; - static FAILURE_STRING_TRAILING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/typeLiteralDelimiterRule.js b/node_modules/tslint/lib/rules/typeLiteralDelimiterRule.js deleted file mode 100644 index cfbe088d9..000000000 --- a/node_modules/tslint/lib/rules/typeLiteralDelimiterRule.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "type-literal-delimiter", - description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Checks that type literal members are separated by semicolons.\n Enforces a trailing semicolon for multiline type literals."], ["\n Checks that type literal members are separated by semicolons.\n Enforces a trailing semicolon for multiline type literals."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "style", - typescriptOnly: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_MISSING = "Expected type literal to use ';' to separate members."; - Rule.FAILURE_STRING_COMMA = "Expected type literal to use ';' instead of ','."; - Rule.FAILURE_STRING_TRAILING = "Did not expect single-line type literal to have a trailing ';'."; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - ts.forEachChild(sourceFile, function cb(node) { - if (tsutils_1.isTypeLiteralNode(node)) { - check(node); - } - ts.forEachChild(node, cb); - }); - function check(node) { - node.members.forEach(function (member, idx) { - var end = member.end - 1; - // Trailing delimiter should be ommitted for a single-line type literal. - var shouldOmit = idx === node.members.length - 1 && tsutils_1.isSameLine(sourceFile, node.getStart(sourceFile), node.getEnd()); - var delimiter = sourceFile.text[end]; - switch (delimiter) { - case ";": - if (shouldOmit) { - fail(Rule.FAILURE_STRING_TRAILING); - } - break; - case ",": - fail(Rule.FAILURE_STRING_COMMA); - break; - default: - if (!shouldOmit) { - fail(Rule.FAILURE_STRING_MISSING); - } - } - function fail(failure) { - ctx.addFailureAt(end, 1, failure); - } - }); - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/typedefRule.d.ts b/node_modules/tslint/lib/rules/typedefRule.d.ts deleted file mode 100644 index fc68d04af..000000000 --- a/node_modules/tslint/lib/rules/typedefRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} -export declare function isNodeArray(nodeOrArray: ts.Node | ts.NodeArray<ts.Node>): nodeOrArray is ts.NodeArray<ts.Node>; diff --git a/node_modules/tslint/lib/rules/typedefRule.js b/node_modules/tslint/lib/rules/typedefRule.js deleted file mode 100644 index 1f1bfb51e..000000000 --- a/node_modules/tslint/lib/rules/typedefRule.js +++ /dev/null @@ -1,196 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_CALL_SIGNATURE = "call-signature"; -var OPTION_ARROW_CALL_SIGNATURE = "arrow-call-signature"; -var OPTION_PARAMETER = "parameter"; -var OPTION_ARROW_PARAMETER = "arrow-parameter"; -var OPTION_PROPERTY_DECLARATION = "property-declaration"; -var OPTION_VARIABLE_DECLARATION = "variable-declaration"; -var OPTION_MEMBER_VARIABLE_DECLARATION = "member-variable-declaration"; -var OPTION_OBJECT_DESTRUCTURING = "object-destructuring"; -var OPTION_ARRAY_DESTRUCTURING = "array-destructuring"; -function parseOptions(ruleArguments) { - var options = {}; - for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) { - var arg = ruleArguments_1[_i]; - options[arg] = true; - } - return options; -} -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.prototype.apply = function (sourceFile) { - return this.applyWithWalker(new TypedefWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments))); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "typedef", - description: "Requires type definitions to exist.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Several arguments may be optionally provided:\n\n * `\"", "\"` checks return type of functions.\n * `\"", "\"` checks return type of arrow functions.\n * `\"", "\"` checks type specifier of function parameters for non-arrow functions.\n * `\"", "\"` checks type specifier of function parameters for arrow functions.\n * `\"", "\"` checks return types of interface properties.\n * `\"", "\"` checks non-binding variable declarations.\n * `\"", "\"` checks member variable declarations.\n * `\"", "\"` checks object destructuring declarations.\n * `\"", "\"` checks array destructuring declarations."], ["\n Several arguments may be optionally provided:\n\n * \\`\"", "\"\\` checks return type of functions.\n * \\`\"", "\"\\` checks return type of arrow functions.\n * \\`\"", "\"\\` checks type specifier of function parameters for non-arrow functions.\n * \\`\"", "\"\\` checks type specifier of function parameters for arrow functions.\n * \\`\"", "\"\\` checks return types of interface properties.\n * \\`\"", "\"\\` checks non-binding variable declarations.\n * \\`\"", "\"\\` checks member variable declarations.\n * \\`\"", "\"\\` checks object destructuring declarations.\n * \\`\"", "\"\\` checks array destructuring declarations."])), OPTION_CALL_SIGNATURE, OPTION_ARROW_CALL_SIGNATURE, OPTION_PARAMETER, OPTION_ARROW_PARAMETER, OPTION_PROPERTY_DECLARATION, OPTION_VARIABLE_DECLARATION, OPTION_MEMBER_VARIABLE_DECLARATION, OPTION_OBJECT_DESTRUCTURING, OPTION_ARRAY_DESTRUCTURING), - options: { - type: "array", - items: { - type: "string", - enum: [ - OPTION_CALL_SIGNATURE, - OPTION_ARROW_CALL_SIGNATURE, - OPTION_PARAMETER, - OPTION_ARROW_PARAMETER, - OPTION_PROPERTY_DECLARATION, - OPTION_VARIABLE_DECLARATION, - OPTION_MEMBER_VARIABLE_DECLARATION, - OPTION_OBJECT_DESTRUCTURING, - OPTION_ARRAY_DESTRUCTURING, - ], - }, - minLength: 0, - maxLength: 7, - }, - optionExamples: [[true, OPTION_CALL_SIGNATURE, OPTION_PARAMETER, OPTION_MEMBER_VARIABLE_DECLARATION]], - type: "typescript", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var TypedefWalker = /** @class */ (function (_super) { - tslib_1.__extends(TypedefWalker, _super); - function TypedefWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - TypedefWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - switch (node.kind) { - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.MethodSignature: { - var _a = node, name = _a.name, parameters = _a.parameters, type = _a.type; - _this.checkTypeAnnotation("call-signature", name !== undefined ? name : parameters, type, name); - break; - } - case ts.SyntaxKind.ArrowFunction: - _this.checkArrowFunction(node); - break; - case ts.SyntaxKind.Parameter: - _this.checkParameter(node); - break; - case ts.SyntaxKind.PropertyDeclaration: - _this.checkPropertyDeclaration(node); - break; - case ts.SyntaxKind.PropertySignature: { - var _b = node, name = _b.name, type = _b.type; - _this.checkTypeAnnotation("property-declaration", name, type, name); - break; - } - case ts.SyntaxKind.VariableDeclaration: - _this.checkVariableDeclaration(node); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - TypedefWalker.prototype.checkArrowFunction = function (_a) { - var parent = _a.parent, parameters = _a.parameters, type = _a.type; - if (parent.kind !== ts.SyntaxKind.CallExpression && !isTypedPropertyDeclaration(parent)) { - this.checkTypeAnnotation("arrow-call-signature", parameters, type); - } - }; - TypedefWalker.prototype.checkParameter = function (_a) { - var parent = _a.parent, name = _a.name, type = _a.type; - var isArrowFunction = parent.kind === ts.SyntaxKind.ArrowFunction; - var option = (function () { - if (!isArrowFunction) { - return "parameter"; - } - else if (isTypedPropertyDeclaration(parent.parent)) { - return undefined; - } - else if (utils.isPropertyDeclaration(parent.parent)) { - return "member-variable-declaration"; - } - else { - return "arrow-parameter"; - } - })(); - if (option !== undefined) { - this.checkTypeAnnotation(option, name, type, name); - } - }; - TypedefWalker.prototype.checkPropertyDeclaration = function (_a) { - var initializer = _a.initializer, name = _a.name, type = _a.type; - // If this is an arrow function, it doesn't need to have a typedef on the property declaration - // as the typedefs can be on the function's parameters instead - if (initializer === undefined || initializer.kind !== ts.SyntaxKind.ArrowFunction) { - this.checkTypeAnnotation("member-variable-declaration", name, type, name); - } - }; - TypedefWalker.prototype.checkVariableDeclaration = function (_a) { - var parent = _a.parent, name = _a.name, type = _a.type; - // variable declarations should always have a grandparent, but check that to be on the safe side. - // catch statements will be the parent of the variable declaration - // for-in/for-of loops will be the gradparent of the variable declaration - if (parent.kind === ts.SyntaxKind.CatchClause - || parent.parent.kind === ts.SyntaxKind.ForInStatement - || parent.parent.kind === ts.SyntaxKind.ForOfStatement) { - return; - } - var option = (function () { - switch (name.kind) { - case ts.SyntaxKind.ObjectBindingPattern: - return "object-destructuring"; - case ts.SyntaxKind.ArrayBindingPattern: - return "array-destructuring"; - default: - return "variable-declaration"; - } - })(); - this.checkTypeAnnotation(option, name, type, name); - }; - TypedefWalker.prototype.checkTypeAnnotation = function (option, location, typeAnnotation, name) { - if (this.options[option] === true && typeAnnotation === undefined) { - var failure = "expected " + option + (name === undefined ? "" : ": '" + name.getText() + "'") + " to have a typedef"; - if (isNodeArray(location)) { - this.addFailure(location.pos - 1, location.end + 1, failure); - } - else { - this.addFailureAtNode(location, failure); - } - } - }; - return TypedefWalker; -}(Lint.AbstractWalker)); -function isTypedPropertyDeclaration(node) { - return utils.isPropertyDeclaration(node) && node.type !== undefined; -} -function isNodeArray(nodeOrArray) { - return Array.isArray(nodeOrArray); -} -exports.isNodeArray = isNodeArray; -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/typedefWhitespaceRule.d.ts b/node_modules/tslint/lib/rules/typedefWhitespaceRule.d.ts deleted file mode 100644 index a62a0ba69..000000000 --- a/node_modules/tslint/lib/rules/typedefWhitespaceRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING(option: string, location: "before" | "after", type: string): string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/typedefWhitespaceRule.js b/node_modules/tslint/lib/rules/typedefWhitespaceRule.js deleted file mode 100644 index be87083de..000000000 --- a/node_modules/tslint/lib/rules/typedefWhitespaceRule.js +++ /dev/null @@ -1,198 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -/* tslint:disable:object-literal-sort-keys */ -var SPACE_OPTIONS = { - type: "string", - enum: ["nospace", "onespace", "space"], -}; -var SPACE_OBJECT = { - type: "object", - properties: { - "call-signature": SPACE_OPTIONS, - "index-signature": SPACE_OPTIONS, - "parameter": SPACE_OPTIONS, - "property-declaration": SPACE_OPTIONS, - "variable-declaration": SPACE_OPTIONS, - }, - additionalProperties: false, -}; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = function (option, location, type) { - return "expected " + option + " " + location + " colon in " + type; - }; - Rule.prototype.apply = function (sourceFile) { - var args = this.ruleArguments; - var options = { - left: args[0], - right: args[1], - }; - return this.applyWithWalker(new TypedefWhitespaceWalker(sourceFile, this.ruleName, options)); - }; - Rule.metadata = { - ruleName: "typedef-whitespace", - description: "Requires or disallows whitespace for type definitions.", - descriptionDetails: "Determines if a space is required or not before the colon in a type specifier.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Two arguments which are both objects.\n The first argument specifies how much space should be to the _left_ of a typedef colon.\n The second argument specifies how much space should be to the _right_ of a typedef colon.\n Each key should have a value of `\"onespace\"`, `\"space\"` or `\"nospace\"`.\n Possible keys are:\n\n * `\"call-signature\"` checks return type of functions.\n * `\"index-signature\"` checks index type specifier of indexers.\n * `\"parameter\"` checks function parameters.\n * `\"property-declaration\"` checks object property declarations.\n * `\"variable-declaration\"` checks variable declaration."], ["\n Two arguments which are both objects.\n The first argument specifies how much space should be to the _left_ of a typedef colon.\n The second argument specifies how much space should be to the _right_ of a typedef colon.\n Each key should have a value of \\`\"onespace\"\\`, \\`\"space\"\\` or \\`\"nospace\"\\`.\n Possible keys are:\n\n * \\`\"call-signature\"\\` checks return type of functions.\n * \\`\"index-signature\"\\` checks index type specifier of indexers.\n * \\`\"parameter\"\\` checks function parameters.\n * \\`\"property-declaration\"\\` checks object property declarations.\n * \\`\"variable-declaration\"\\` checks variable declaration."]))), - options: { - type: "array", - items: [SPACE_OBJECT, SPACE_OBJECT], - additionalItems: false, - }, - optionExamples: [ - [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace", - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace", - }, - ], - ], - type: "typescript", - typescriptOnly: true, - hasFix: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -var TypedefWhitespaceWalker = /** @class */ (function (_super) { - tslib_1.__extends(TypedefWhitespaceWalker, _super); - function TypedefWhitespaceWalker() { - return _super !== null && _super.apply(this, arguments) || this; - } - TypedefWhitespaceWalker.prototype.walk = function (sourceFile) { - var _this = this; - var cb = function (node) { - var optionType = getOptionType(node); - if (optionType !== undefined) { - _this.checkSpace(node, optionType); - } - return ts.forEachChild(node, cb); - }; - return ts.forEachChild(sourceFile, cb); - }; - TypedefWhitespaceWalker.prototype.checkSpace = function (node, key) { - if (!("type" in node) || node.type === undefined) { - return; - } - var _a = this.options, left = _a.left, right = _a.right; - var colon = tsutils_1.getChildOfKind(node, ts.SyntaxKind.ColonToken, this.sourceFile); - if (right !== undefined && right[key] !== undefined) { - this.checkRight(colon.end, right[key], key); - } - if (left !== undefined && left[key] !== undefined) { - this.checkLeft(colon.end - 1, left[key], key); - } - }; - TypedefWhitespaceWalker.prototype.checkRight = function (colonEnd, option, key) { - var pos = colonEnd; - var text = this.sourceFile.text; - var current = text.charCodeAt(pos); - if (ts.isLineBreak(current)) { - return; - } - while (ts.isWhiteSpaceSingleLine(current)) { - ++pos; - current = text.charCodeAt(pos); - } - return this.validateWhitespace(colonEnd, pos, option, "after", key); - }; - TypedefWhitespaceWalker.prototype.checkLeft = function (colonStart, option, key) { - var pos = colonStart; - var text = this.sourceFile.text; - var current = text.charCodeAt(pos - 1); - while (ts.isWhiteSpaceSingleLine(current)) { - --pos; - current = text.charCodeAt(pos - 1); - } - if (ts.isLineBreak(current)) { - return; - } - return this.validateWhitespace(pos, colonStart, option, "before", key); - }; - TypedefWhitespaceWalker.prototype.validateWhitespace = function (start, end, option, location, key) { - switch (option) { - case "nospace": - if (start !== end) { - this.addFailure(start, end, Rule.FAILURE_STRING(option, location, key), Lint.Replacement.deleteFromTo(start, end)); - } - break; - case "space": - if (start === end) { - this.addFailure(end, end, Rule.FAILURE_STRING(option, location, key), Lint.Replacement.appendText(end, " ")); - } - break; - case "onespace": - switch (end - start) { - case 0: - this.addFailure(end, end, Rule.FAILURE_STRING(option, location, key), Lint.Replacement.appendText(end, " ")); - break; - case 1: - break; - default: - this.addFailure(start + 1, end, Rule.FAILURE_STRING(option, location, key), Lint.Replacement.deleteFromTo(start + 1, end)); - } - } - }; - return TypedefWhitespaceWalker; -}(Lint.AbstractWalker)); -function getOptionType(node) { - switch (node.kind) { - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.CallSignature: - return "call-signature"; - case ts.SyntaxKind.IndexSignature: - return "index-signature"; - case ts.SyntaxKind.VariableDeclaration: - return "variable-declaration"; - case ts.SyntaxKind.Parameter: - return "parameter"; - case ts.SyntaxKind.PropertySignature: - case ts.SyntaxKind.PropertyDeclaration: - return "property-declaration"; - default: - return undefined; - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/typeofCompareRule.d.ts b/node_modules/tslint/lib/rules/typeofCompareRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/typeofCompareRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/typeofCompareRule.js b/node_modules/tslint/lib/rules/typeofCompareRule.js deleted file mode 100644 index 9a6b5f2d9..000000000 --- a/node_modules/tslint/lib/rules/typeofCompareRule.js +++ /dev/null @@ -1,80 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var LEGAL_TYPEOF_RESULTS = new Set(["undefined", "string", "boolean", "number", "function", "object", "symbol"]); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "typeof-compare", - description: "Makes sure result of `typeof` is compared to correct string values", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - deprecationMessage: !/^2\.1\./.test(ts.version) - ? "Starting from TypeScript 2.2 the compiler includes this check which makes this rule redundant." - : "", - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "'typeof' expression must be compared to one of: " + Array.from(LEGAL_TYPEOF_RESULTS).map(function (x) { return "\"" + x + "\""; }).join(", "); - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils.isBinaryExpression(node)) { - var operatorToken = node.operatorToken, left = node.left, right = node.right; - if (Lint.getEqualsKind(operatorToken) !== undefined && (isFaultyTypeof(left, right) || isFaultyTypeof(right, left))) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING); - } - } - ts.forEachChild(node, cb); - }); -} -function isFaultyTypeof(left, right) { - return left.kind === ts.SyntaxKind.TypeOfExpression && isFaultyTypeofResult(right); -} -function isFaultyTypeofResult(node) { - switch (node.kind) { - case ts.SyntaxKind.StringLiteral: - return !LEGAL_TYPEOF_RESULTS.has(node.text); - case ts.SyntaxKind.Identifier: - return node.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword; - case ts.SyntaxKind.NullKeyword: - case ts.SyntaxKind.NumericLiteral: - case ts.SyntaxKind.TrueKeyword: - case ts.SyntaxKind.FalseKeyword: - case ts.SyntaxKind.ObjectLiteralExpression: - case ts.SyntaxKind.ArrayLiteralExpression: - return true; - default: - return false; - } -} diff --git a/node_modules/tslint/lib/rules/unifiedSignaturesRule.d.ts b/node_modules/tslint/lib/rules/unifiedSignaturesRule.d.ts deleted file mode 100644 index 08c051e01..000000000 --- a/node_modules/tslint/lib/rules/unifiedSignaturesRule.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_OMITTING_SINGLE_PARAMETER(otherLine?: number): string; - static FAILURE_STRING_OMITTING_REST_PARAMETER(otherLine?: number): string; - static FAILURE_STRING_SINGLE_PARAMETER_DIFFERENCE(otherLine: number | undefined, type1: string, type2: string): string; - private static FAILURE_STRING_START; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/unifiedSignaturesRule.js b/node_modules/tslint/lib/rules/unifiedSignaturesRule.js deleted file mode 100644 index c0f8f0d2e..000000000 --- a/node_modules/tslint/lib/rules/unifiedSignaturesRule.js +++ /dev/null @@ -1,310 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var adjacentOverloadSignaturesRule_1 = require("./adjacentOverloadSignaturesRule"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING_OMITTING_SINGLE_PARAMETER = function (otherLine) { - return this.FAILURE_STRING_START(otherLine) + " with an optional parameter."; - }; - Rule.FAILURE_STRING_OMITTING_REST_PARAMETER = function (otherLine) { - return this.FAILURE_STRING_START(otherLine) + " with a rest parameter."; - }; - Rule.FAILURE_STRING_SINGLE_PARAMETER_DIFFERENCE = function (otherLine, type1, type2) { - return this.FAILURE_STRING_START(otherLine) + " taking `" + type1 + " | " + type2 + "`."; - }; - Rule.FAILURE_STRING_START = function (otherLine) { - // For only 2 overloads we don't need to specify which is the other one. - var overloads = otherLine === undefined ? "These overloads" : "This overload and the one on line " + otherLine; - return overloads + " can be combined into one signature"; - }; - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "unified-signatures", - description: "Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "typescript", - typescriptOnly: true, - }; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - var sourceFile = ctx.sourceFile; - checkStatements(sourceFile.statements); - return ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ModuleBlock: - checkStatements(node.statements); - break; - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.ClassDeclaration: { - var _a = node, members = _a.members, typeParameters = _a.typeParameters; - checkMembers(members, typeParameters); - break; - } - case ts.SyntaxKind.TypeLiteral: - checkMembers(node.members); - } - return ts.forEachChild(node, cb); - }); - function checkStatements(statements) { - addFailures(checkOverloads(statements, undefined, function (statement) { - if (utils.isFunctionDeclaration(statement)) { - var body = statement.body, name = statement.name; - return body === undefined && name !== undefined ? { signature: statement, key: name.text } : undefined; - } - else { - return undefined; - } - })); - } - function checkMembers(members, typeParameters) { - addFailures(checkOverloads(members, typeParameters, function (member) { - switch (member.kind) { - case ts.SyntaxKind.CallSignature: - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.MethodSignature: - break; - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.Constructor: - if (member.body !== undefined) { - return undefined; - } - break; - default: - return undefined; - } - var signature = member; - var key = adjacentOverloadSignaturesRule_1.getOverloadKey(signature); - return key === undefined ? undefined : { signature: signature, key: key }; - })); - } - function addFailures(failures) { - for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) { - var failure = failures_1[_i]; - var unify = failure.unify, only2 = failure.only2; - switch (unify.kind) { - case "single-parameter-difference": { - var p0 = unify.p0, p1 = unify.p1; - var lineOfOtherOverload = only2 ? undefined : getLine(p0.getStart()); - ctx.addFailureAtNode(p1, Rule.FAILURE_STRING_SINGLE_PARAMETER_DIFFERENCE(lineOfOtherOverload, typeText(p0), typeText(p1))); - break; - } - case "extra-parameter": { - var extraParameter = unify.extraParameter, otherSignature = unify.otherSignature; - var lineOfOtherOverload = only2 ? undefined : getLine(otherSignature.pos); - ctx.addFailureAtNode(extraParameter, extraParameter.dotDotDotToken !== undefined - ? Rule.FAILURE_STRING_OMITTING_REST_PARAMETER(lineOfOtherOverload) - : Rule.FAILURE_STRING_OMITTING_SINGLE_PARAMETER(lineOfOtherOverload)); - } - } - } - } - function getLine(pos) { - return ts.getLineAndCharacterOfPosition(sourceFile, pos).line + 1; - } -} -function checkOverloads(signatures, typeParameters, getOverload) { - var result = []; - var isTypeParameter = getIsTypeParameter(typeParameters); - for (var _i = 0, _a = collectOverloads(signatures, getOverload); _i < _a.length; _i++) { - var overloads = _a[_i]; - if (overloads.length === 2) { - var unify = compareSignatures(overloads[0], overloads[1], isTypeParameter); - if (unify !== undefined) { - result.push({ unify: unify, only2: true }); - } - } - else { - forEachPair(overloads, function (a, b) { - var unify = compareSignatures(a, b, isTypeParameter); - if (unify !== undefined) { - result.push({ unify: unify, only2: false }); - } - }); - } - } - return result; -} -function compareSignatures(a, b, isTypeParameter) { - if (!signaturesCanBeUnified(a, b, isTypeParameter)) { - return undefined; - } - return a.parameters.length === b.parameters.length - ? signaturesDifferBySingleParameter(a.parameters, b.parameters) - : signaturesDifferByOptionalOrRestParameter(a.parameters, b.parameters); -} -function signaturesCanBeUnified(a, b, isTypeParameter) { - // Must return the same type. - return typesAreEqual(a.type, b.type) && - // Must take the same type parameters. - utils_1.arraysAreEqual(a.typeParameters, b.typeParameters, typeParametersAreEqual) && - // If one uses a type parameter (from outside) and the other doesn't, they shouldn't be joined. - signatureUsesTypeParameter(a, isTypeParameter) === signatureUsesTypeParameter(b, isTypeParameter); -} -/** Detect `a(x: number, y: number, z: number)` and `a(x: number, y: string, z: number)`. */ -function signaturesDifferBySingleParameter(types1, types2) { - var index = getIndexOfFirstDifference(types1, types2, parametersAreEqual); - if (index === undefined) { - return undefined; - } - // If remaining arrays are equal, the signatures differ by just one parameter type - if (!utils_1.arraysAreEqual(types1.slice(index + 1), types2.slice(index + 1), parametersAreEqual)) { - return undefined; - } - var a = types1[index]; - var b = types2[index]; - // Can unify `a?: string` and `b?: number`. Can't unify `...args: string[]` and `...args: number[]`. - // See https://github.com/Microsoft/TypeScript/issues/5077 - return parametersHaveEqualSigils(a, b) && a.dotDotDotToken === undefined - ? { kind: "single-parameter-difference", p0: a, p1: b } - : undefined; -} -/** - * Detect `a(): void` and `a(x: number): void`. - * Returns the parameter declaration (`x: number` in this example) that should be optional/rest, and overload it's a part of. - */ -function signaturesDifferByOptionalOrRestParameter(sig1, sig2) { - var minLength = Math.min(sig1.length, sig2.length); - var longer = sig1.length < sig2.length ? sig2 : sig1; - var shorter = sig1.length < sig2.length ? sig1 : sig2; - // If one is has 2+ parameters more than the other, they must all be optional/rest. - // Differ by optional parameters: f() and f(x), f() and f(x, ?y, ...z) - // Not allowed: f() and f(x, y) - for (var i = minLength + 1; i < longer.length; i++) { - if (!parameterMayBeMissing(longer[i])) { - return undefined; - } - } - for (var i = 0; i < minLength; i++) { - if (!typesAreEqual(sig1[i].type, sig2[i].type)) { - return undefined; - } - } - if (minLength > 0 && shorter[minLength - 1].dotDotDotToken !== undefined) { - return undefined; - } - return { kind: "extra-parameter", extraParameter: longer[longer.length - 1], otherSignature: shorter }; -} -/** Given type parameters, returns a function to test whether a type is one of those parameters. */ -function getIsTypeParameter(typeParameters) { - if (typeParameters === undefined) { - return function () { return false; }; - } - var set = new Set(); - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var t = typeParameters_1[_i]; - set.add(t.getText()); - } - return function (typeName) { return set.has(typeName); }; -} -/** True if any of the outer type parameters are used in a signature. */ -function signatureUsesTypeParameter(sig, isTypeParameter) { - return sig.parameters.some(function (p) { return p.type !== undefined && typeContainsTypeParameter(p.type) === true; }); - function typeContainsTypeParameter(type) { - if (utils.isTypeReferenceNode(type)) { - var typeName = type.typeName; - if (typeName.kind === ts.SyntaxKind.Identifier && isTypeParameter(typeName.text)) { - return true; - } - } - return ts.forEachChild(type, typeContainsTypeParameter); - } -} -/** - * Given all signatures, collects an array of arrays of signatures which are all overloads. - * Does not rely on overloads being adjacent. This is similar to code in adjacentOverloadSignaturesRule.ts, but not the same. - */ -function collectOverloads(nodes, getOverload) { - var map = new Map(); - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var sig = nodes_1[_i]; - var overload = getOverload(sig); - if (overload === undefined) { - continue; - } - var signature = overload.signature, key = overload.key; - var overloads = map.get(key); - if (overloads !== undefined) { - overloads.push(signature); - } - else { - map.set(key, [signature]); - } - } - return Array.from(map.values()); -} -function parametersAreEqual(a, b) { - return parametersHaveEqualSigils(a, b) && typesAreEqual(a.type, b.type); -} -/** True for optional/rest parameters. */ -function parameterMayBeMissing(p) { - return p.dotDotDotToken !== undefined || p.questionToken !== undefined; -} -/** False if one is optional and the other isn't, or one is a rest parameter and the other isn't. */ -function parametersHaveEqualSigils(a, b) { - return (a.dotDotDotToken !== undefined) === (b.dotDotDotToken !== undefined) && - (a.questionToken !== undefined) === (b.questionToken !== undefined); -} -function typeParametersAreEqual(a, b) { - return a.name.text === b.name.text && typesAreEqual(a.constraint, b.constraint); -} -function typesAreEqual(a, b) { - // TODO: Could traverse AST so that formatting differences don't affect this. - return a === b || a !== undefined && b !== undefined && a.getText() === b.getText(); -} -/** Returns the first index where `a` and `b` differ. */ -function getIndexOfFirstDifference(a, b, equal) { - for (var i = 0; i < a.length && i < b.length; i++) { - if (!equal(a[i], b[i])) { - return i; - } - } - return undefined; -} -/** Calls `action` for every pair of values in `values`. */ -function forEachPair(values, action) { - for (var i = 0; i < values.length; i++) { - for (var j = i + 1; j < values.length; j++) { - var result = action(values[i], values[j]); - if (result !== undefined) { - return result; - } - } - } - return undefined; -} -function typeText(_a) { - var type = _a.type; - return type === undefined ? "any" : type.getText(); -} diff --git a/node_modules/tslint/lib/rules/useDefaultTypeParameterRule.d.ts b/node_modules/tslint/lib/rules/useDefaultTypeParameterRule.d.ts deleted file mode 100644 index 4df32174e..000000000 --- a/node_modules/tslint/lib/rules/useDefaultTypeParameterRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.TypedRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/useDefaultTypeParameterRule.js b/node_modules/tslint/lib/rules/useDefaultTypeParameterRule.js deleted file mode 100644 index d07faac42..000000000 --- a/node_modules/tslint/lib/rules/useDefaultTypeParameterRule.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2017 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.applyWithProgram = function (sourceFile, program) { - return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker()); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "use-default-type-parameter", - description: "Warns if an explicitly specified type argument is the default for that type parameter.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: ["true"], - type: "functionality", - typescriptOnly: true, - requiresTypeInfo: true, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "This is the default value for this type parameter, so it can be omitted."; - return Rule; -}(Lint.Rules.TypedRule)); -exports.Rule = Rule; -function walk(ctx, checker) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - var argsAndParams = getArgsAndParameters(node, checker); - if (argsAndParams !== undefined) { - checkArgsAndParameters(argsAndParams); - } - return ts.forEachChild(node, cb); - }); - function checkArgsAndParameters(_a) { - var typeArguments = _a.typeArguments, typeParameters = _a.typeParameters; - // Just check the last one. Must specify previous type parameters if the last one is specified. - var i = typeArguments.length - 1; - var arg = typeArguments[i]; - var param = typeParameters[i]; - // TODO: would like checker.areTypesEquivalent. https://github.com/Microsoft/TypeScript/issues/13502 - if (param.default !== undefined && param.default.getText() === arg.getText()) { - ctx.addFailureAtNode(arg, Rule.FAILURE_STRING, createFix()); - } - function createFix() { - if (i === 0) { - return Lint.Replacement.deleteFromTo(typeArguments.pos - 1, typeArguments.end + 1); - } - else { - return Lint.Replacement.deleteFromTo(typeArguments[i - 1].end, arg.end); - } - } - } -} -function getArgsAndParameters(node, checker) { - switch (node.kind) { - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.NewExpression: - case ts.SyntaxKind.TypeReference: - case ts.SyntaxKind.ExpressionWithTypeArguments: - var decl = node; - var typeArguments = decl.typeArguments; - if (typeArguments === undefined) { - return undefined; - } - var typeParameters = decl.kind === ts.SyntaxKind.TypeReference - ? typeParamsFromType(decl.typeName, checker) - : decl.kind === ts.SyntaxKind.ExpressionWithTypeArguments - ? typeParamsFromType(decl.expression, checker) - : typeParamsFromCall(node, checker); - return typeParameters === undefined ? undefined : { typeArguments: typeArguments, typeParameters: typeParameters }; - default: - return undefined; - } -} -function typeParamsFromCall(node, checker) { - var sig = checker.getResolvedSignature(node); - var sigDecl = sig === undefined ? undefined : sig.getDeclaration(); - if (sigDecl === undefined) { - return node.kind === ts.SyntaxKind.NewExpression ? typeParamsFromType(node.expression, checker) : undefined; - } - return sigDecl.typeParameters === undefined ? undefined : sigDecl.typeParameters; -} -function typeParamsFromType(type, checker) { - var sym = getAliasedSymbol(checker.getSymbolAtLocation(type), checker); - if (sym === undefined || sym.declarations === undefined) { - return undefined; - } - return utils_1.find(sym.declarations, function (decl) { - return tsutils_1.isClassLikeDeclaration(decl) || tsutils_1.isTypeAliasDeclaration(decl) || tsutils_1.isInterfaceDeclaration(decl) ? decl.typeParameters : undefined; - }); -} -function getAliasedSymbol(symbol, checker) { - if (symbol === undefined) { - return undefined; - } - return tsutils_1.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias) ? checker.getAliasedSymbol(symbol) : symbol; -} diff --git a/node_modules/tslint/lib/rules/useIsnanRule.d.ts b/node_modules/tslint/lib/rules/useIsnanRule.d.ts deleted file mode 100644 index f4050b9de..000000000 --- a/node_modules/tslint/lib/rules/useIsnanRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/useIsnanRule.js b/node_modules/tslint/lib/rules/useIsnanRule.js deleted file mode 100644 index cd5de673a..000000000 --- a/node_modules/tslint/lib/rules/useIsnanRule.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk); - }; - /* tslint:disable:object-literal-sort-keys */ - Rule.metadata = { - ruleName: "use-isnan", - description: "Enforces use of the `isNaN()` function to check for NaN references instead of a comparison to the `NaN` constant.", - rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Since `NaN !== NaN`, comparisons with regular operators will produce unexpected results.\n So, instead of `if (myVar === NaN)`, do `if (isNaN(myVar))`."], ["\n Since \\`NaN !== NaN\\`, comparisons with regular operators will produce unexpected results.\n So, instead of \\`if (myVar === NaN)\\`, do \\`if (isNaN(myVar))\\`."]))), - optionsDescription: "Not configurable.", - options: null, - optionExamples: [true], - type: "functionality", - typescriptOnly: false, - }; - /* tslint:enable:object-literal-sort-keys */ - Rule.FAILURE_STRING = "Found an invalid comparison for NaN: "; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function walk(ctx) { - return ts.forEachChild(ctx.sourceFile, function cb(node) { - if (tsutils_1.isBinaryExpression(node)) { - switch (node.operatorToken.kind) { - case ts.SyntaxKind.LessThanToken: - case ts.SyntaxKind.GreaterThanToken: - case ts.SyntaxKind.LessThanEqualsToken: - case ts.SyntaxKind.GreaterThanEqualsToken: - case ts.SyntaxKind.EqualsEqualsToken: - case ts.SyntaxKind.ExclamationEqualsToken: - case ts.SyntaxKind.EqualsEqualsEqualsToken: - case ts.SyntaxKind.ExclamationEqualsEqualsToken: - if (isExpressionNaN(node.right) || isExpressionNaN(node.left)) { - ctx.addFailureAtNode(node, Rule.FAILURE_STRING + node.getText(ctx.sourceFile)); - } - } - } - return ts.forEachChild(node, cb); - }); -} -function isExpressionNaN(node) { - return node.kind === ts.SyntaxKind.Identifier && node.text === "NaN"; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/variableNameRule.d.ts b/node_modules/tslint/lib/rules/variableNameRule.d.ts deleted file mode 100644 index 548ff0300..000000000 --- a/node_modules/tslint/lib/rules/variableNameRule.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static KEYWORD_FAILURE: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/variableNameRule.js b/node_modules/tslint/lib/rules/variableNameRule.js deleted file mode 100644 index d33afc53b..000000000 --- a/node_modules/tslint/lib/rules/variableNameRule.js +++ /dev/null @@ -1,178 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -// tslint:disable object-literal-sort-keys -var tsutils_1 = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var utils_1 = require("../utils"); -var BANNED_KEYWORDS = ["any", "Number", "number", "String", "string", "Boolean", "boolean", "Undefined", "undefined"]; -var bannedKeywordsSet = new Set(BANNED_KEYWORDS); -var bannedKeywordsStr = BANNED_KEYWORDS.map(function (kw) { return "`" + kw + "`"; }).join(", "); -var OPTION_LEADING_UNDERSCORE = "allow-leading-underscore"; -var OPTION_TRAILING_UNDERSCORE = "allow-trailing-underscore"; -var OPTION_BAN_KEYWORDS = "ban-keywords"; -var OPTION_CHECK_FORMAT = "check-format"; -var OPTION_ALLOW_PASCAL_CASE = "allow-pascal-case"; -var OPTION_ALLOW_SNAKE_CASE = "allow-snake-case"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments)); - }; - Rule.metadata = { - ruleName: "variable-name", - description: "Checks variable names for various errors.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"`: allows only lowerCamelCased or UPPER_CASED variable names\n * `\"", "\"` allows underscores at the beginning (only has an effect if \"check-format\" specified)\n * `\"", "\"` allows underscores at the end. (only has an effect if \"check-format\" specified)\n * `\"", "\"` allows PascalCase in addition to lowerCamelCase.\n * `\"", "\"` allows snake_case in addition to lowerCamelCase.\n * `\"", "\"`: disallows the use of certain TypeScript keywords as variable or parameter names.\n * These are: ", ""], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\`: allows only lowerCamelCased or UPPER_CASED variable names\n * \\`\"", "\"\\` allows underscores at the beginning (only has an effect if \"check-format\" specified)\n * \\`\"", "\"\\` allows underscores at the end. (only has an effect if \"check-format\" specified)\n * \\`\"", "\"\\` allows PascalCase in addition to lowerCamelCase.\n * \\`\"", "\"\\` allows snake_case in addition to lowerCamelCase.\n * \\`\"", "\"\\`: disallows the use of certain TypeScript keywords as variable or parameter names.\n * These are: ", ""])), OPTION_CHECK_FORMAT, OPTION_LEADING_UNDERSCORE, OPTION_TRAILING_UNDERSCORE, OPTION_ALLOW_PASCAL_CASE, OPTION_ALLOW_SNAKE_CASE, OPTION_BAN_KEYWORDS, bannedKeywordsStr), - options: { - type: "array", - items: { - type: "string", - enum: [ - OPTION_CHECK_FORMAT, - OPTION_LEADING_UNDERSCORE, - OPTION_TRAILING_UNDERSCORE, - OPTION_ALLOW_PASCAL_CASE, - OPTION_ALLOW_SNAKE_CASE, - OPTION_BAN_KEYWORDS, - ], - }, - minLength: 0, - maxLength: 5, - }, - optionExamples: [[true, "ban-keywords", "check-format", "allow-leading-underscore"]], - type: "style", - typescriptOnly: false, - }; - Rule.KEYWORD_FAILURE = "variable name clashes with keyword/type"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(ruleArguments) { - var banKeywords = hasOption(OPTION_BAN_KEYWORDS); - return { - banKeywords: banKeywords, - // check variable name formatting by default if no options are specified - checkFormat: !banKeywords || hasOption(OPTION_CHECK_FORMAT), - leadingUnderscore: hasOption(OPTION_LEADING_UNDERSCORE), - trailingUnderscore: hasOption(OPTION_TRAILING_UNDERSCORE), - allowPascalCase: hasOption(OPTION_ALLOW_PASCAL_CASE), - allowSnakeCase: hasOption(OPTION_ALLOW_SNAKE_CASE), - }; - function hasOption(name) { - return ruleArguments.indexOf(name) !== -1; - } -} -function walk(ctx) { - var options = ctx.options, sourceFile = ctx.sourceFile; - return ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.BindingElement: { - var _a = node, initializer = _a.initializer, name = _a.name, propertyName = _a.propertyName; - if (name.kind === ts.SyntaxKind.Identifier) { - handleVariableNameKeyword(name); - // A destructuring pattern that does not rebind an expression is always an alias, e.g. `var {Foo} = ...;`. - // Only check if the name is rebound (`var {Foo: bar} = ...;`). - if (node.parent.kind !== ts.SyntaxKind.ObjectBindingPattern || propertyName !== undefined) { - handleVariableNameFormat(name, initializer); - } - } - break; - } - case ts.SyntaxKind.VariableStatement: - // skip 'declare' keywords - if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) { - return; - } - break; - case ts.SyntaxKind.Parameter: - case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.VariableDeclaration: { - var _b = node, name = _b.name, initializer = _b.initializer; - if (name.kind === ts.SyntaxKind.Identifier) { - handleVariableNameFormat(name, initializer); - // do not check property declarations for keywords, they are allowed to be keywords - if (node.kind !== ts.SyntaxKind.PropertyDeclaration) { - handleVariableNameKeyword(name); - } - } - } - } - return ts.forEachChild(node, cb); - }); - function handleVariableNameFormat(name, initializer) { - if (!options.checkFormat) { - return; - } - var text = name.text; - if (initializer !== undefined && isAlias(text, initializer)) { - return; - } - if (text.length !== 0 && !isCamelCase(text, options) && !utils_1.isUpperCase(text)) { - ctx.addFailureAtNode(name, formatFailure()); - } - } - function handleVariableNameKeyword(name) { - if (options.banKeywords && bannedKeywordsSet.has(name.text)) { - ctx.addFailureAtNode(name, Rule.KEYWORD_FAILURE); - } - } - function formatFailure() { - var failureMessage = "variable name must be in lowerCamelCase"; - if (options.allowPascalCase) { - failureMessage += ", PascalCase"; - } - if (options.allowSnakeCase) { - failureMessage += ", snake_case"; - } - return failureMessage + " or UPPER_CASE"; - } -} -function isAlias(name, initializer) { - switch (initializer.kind) { - case ts.SyntaxKind.PropertyAccessExpression: - return initializer.name.text === name; - case ts.SyntaxKind.Identifier: - return initializer.text === name; - default: - return false; - } -} -function isCamelCase(name, options) { - var firstCharacter = name[0]; - var lastCharacter = name[name.length - 1]; - var middle = name.slice(1, -1); - if (!options.leadingUnderscore && firstCharacter === "_") { - return false; - } - if (!options.trailingUnderscore && lastCharacter === "_") { - return false; - } - if (!options.allowPascalCase && !utils_1.isLowerCase(firstCharacter)) { - return false; - } - if (!options.allowSnakeCase && middle.indexOf("_") !== -1) { - return false; - } - return true; -} -var templateObject_1; diff --git a/node_modules/tslint/lib/rules/whitespaceRule.d.ts b/node_modules/tslint/lib/rules/whitespaceRule.d.ts deleted file mode 100644 index 6a6280637..000000000 --- a/node_modules/tslint/lib/rules/whitespaceRule.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import * as ts from "typescript"; -import * as Lint from "../index"; -export declare class Rule extends Lint.Rules.AbstractRule { - static metadata: Lint.IRuleMetadata; - static FAILURE_STRING_MISSING: string; - static FAILURE_STRING_INVALID: string; - apply(sourceFile: ts.SourceFile): Lint.RuleFailure[]; -} diff --git a/node_modules/tslint/lib/rules/whitespaceRule.js b/node_modules/tslint/lib/rules/whitespaceRule.js deleted file mode 100644 index b39159eb3..000000000 --- a/node_modules/tslint/lib/rules/whitespaceRule.js +++ /dev/null @@ -1,312 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -// tslint:disable object-literal-sort-keys -var utils = require("tsutils"); -var ts = require("typescript"); -var Lint = require("../index"); -var OPTION_BRANCH = "check-branch"; -var OPTION_DECL = "check-decl"; -var OPTION_OPERATOR = "check-operator"; -var OPTION_MODULE = "check-module"; -var OPTION_SEPARATOR = "check-separator"; -var OPTION_REST_SPREAD = "check-rest-spread"; -var OPTION_TYPE = "check-type"; -var OPTION_TYPECAST = "check-typecast"; -var OPTION_TYPE_OPERATOR = "check-type-operator"; -var OPTION_PREBLOCK = "check-preblock"; -var Rule = /** @class */ (function (_super) { - tslib_1.__extends(Rule, _super); - function Rule() { - return _super !== null && _super.apply(this, arguments) || this; - } - Rule.prototype.apply = function (sourceFile) { - return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments)); - }; - Rule.metadata = { - ruleName: "whitespace", - description: "Enforces whitespace style conventions.", - rationale: "Helps maintain a readable, consistent style in your codebase.", - optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Ten arguments may be optionally provided:\n\n * `\"check-branch\"` checks branching statements (`if`/`else`/`for`/`while`) are followed by whitespace.\n * `\"check-decl\"`checks that variable declarations have whitespace around the equals token.\n * `\"check-operator\"` checks for whitespace around operator tokens.\n * `\"check-module\"` checks for whitespace in import & export statements.\n * `\"check-separator\"` checks for whitespace after separator tokens (`,`/`;`).\n * `\"check-rest-spread\"` checks that there is no whitespace after rest/spread operator (`...`).\n * `\"check-type\"` checks for whitespace before a variable type specification.\n * `\"check-typecast\"` checks for whitespace between a typecast and its target.\n * `\"check-type-operator\"` checks for whitespace between type operators `|` and `&`.\n * `\"check-preblock\"` checks for whitespace before the opening brace of a block"], ["\n Ten arguments may be optionally provided:\n\n * \\`\"check-branch\"\\` checks branching statements (\\`if\\`/\\`else\\`/\\`for\\`/\\`while\\`) are followed by whitespace.\n * \\`\"check-decl\"\\`checks that variable declarations have whitespace around the equals token.\n * \\`\"check-operator\"\\` checks for whitespace around operator tokens.\n * \\`\"check-module\"\\` checks for whitespace in import & export statements.\n * \\`\"check-separator\"\\` checks for whitespace after separator tokens (\\`,\\`/\\`;\\`).\n * \\`\"check-rest-spread\"\\` checks that there is no whitespace after rest/spread operator (\\`...\\`).\n * \\`\"check-type\"\\` checks for whitespace before a variable type specification.\n * \\`\"check-typecast\"\\` checks for whitespace between a typecast and its target.\n * \\`\"check-type-operator\"\\` checks for whitespace between type operators \\`|\\` and \\`&\\`.\n * \\`\"check-preblock\"\\` checks for whitespace before the opening brace of a block"]))), - options: { - type: "array", - items: { - type: "string", - enum: [ - "check-branch", "check-decl", "check-operator", "check-module", "check-separator", - "check-rest-spread", "check-type", "check-typecast", "check-type-operator", "check-preblock", - ], - }, - minLength: 0, - maxLength: 10, - }, - optionExamples: [[true, "check-branch", "check-operator", "check-typecast"]], - type: "style", - typescriptOnly: false, - hasFix: true, - }; - Rule.FAILURE_STRING_MISSING = "missing whitespace"; - Rule.FAILURE_STRING_INVALID = "invalid whitespace"; - return Rule; -}(Lint.Rules.AbstractRule)); -exports.Rule = Rule; -function parseOptions(ruleArguments) { - return { - branch: has(OPTION_BRANCH), - decl: has(OPTION_DECL), - operator: has(OPTION_OPERATOR), - module: has(OPTION_MODULE), - separator: has(OPTION_SEPARATOR), - restSpread: has(OPTION_REST_SPREAD), - type: has(OPTION_TYPE), - typecast: has(OPTION_TYPECAST), - typeOperator: has(OPTION_TYPE_OPERATOR), - preblock: has(OPTION_PREBLOCK), - }; - function has(option) { - return ruleArguments.indexOf(option) !== -1; - } -} -function walk(ctx) { - var sourceFile = ctx.sourceFile, options = ctx.options; - ts.forEachChild(sourceFile, function cb(node) { - switch (node.kind) { - case ts.SyntaxKind.ArrowFunction: - checkEqualsGreaterThanTokenInNode(node); - break; - // check for spaces between the operator symbol (except in the case of comma statements) - case ts.SyntaxKind.BinaryExpression: { - var _a = node, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; - if (options.operator && operatorToken.kind !== ts.SyntaxKind.CommaToken) { - checkForTrailingWhitespace(left.getEnd()); - checkForTrailingWhitespace(right.getFullStart()); - } - break; - } - case ts.SyntaxKind.Block: - if (options.preblock) { - checkForTrailingWhitespace(node.getFullStart()); - } - break; - // check for spaces between ternary operator symbols - case ts.SyntaxKind.ConditionalExpression: - if (options.operator) { - var _b = node, condition = _b.condition, whenTrue = _b.whenTrue; - checkForTrailingWhitespace(condition.getEnd()); - checkForTrailingWhitespace(whenTrue.getFullStart()); - checkForTrailingWhitespace(whenTrue.getEnd()); - } - break; - case ts.SyntaxKind.ConstructorType: - checkEqualsGreaterThanTokenInNode(node); - break; - case ts.SyntaxKind.ExportAssignment: - if (options.module) { - var exportKeyword = node.getChildAt(0); - var position = exportKeyword.getEnd(); - checkForTrailingWhitespace(position); - } - break; - case ts.SyntaxKind.FunctionType: - checkEqualsGreaterThanTokenInNode(node); - break; - case ts.SyntaxKind.ImportDeclaration: { - var importClause = node.importClause; - if (options.module && importClause !== undefined) { - // an import clause can have _both_ named bindings and a name (the latter for the default import) - // but the named bindings always come last, so we only need to check that for whitespace - var position = void 0; - var namedBindings_1 = importClause.namedBindings; - if (namedBindings_1 !== undefined) { - if (namedBindings_1.kind !== ts.SyntaxKind.NamespaceImport) { - namedBindings_1.elements.forEach(function (element, idx, arr) { - var internalName = element.name; - if (internalName !== undefined) { - if (idx === arr.length - 1) { - var token = namedBindings_1.getLastToken(); - checkForTrailingWhitespace(token.getFullStart()); - } - if (idx === 0) { - var startPos = internalName.getStart() - 1; - checkForTrailingWhitespace(startPos, startPos + 1); - } - } - }); - } - position = namedBindings_1.getEnd(); - } - else if (importClause.name !== undefined) { - position = importClause.name.getEnd(); - } - if (position !== undefined) { - checkForTrailingWhitespace(position); - } - } - break; - } - case ts.SyntaxKind.ImportEqualsDeclaration: - if (options.module) { - var position = node.name.getEnd(); - checkForTrailingWhitespace(position); - } - break; - case ts.SyntaxKind.TypeAssertionExpression: - if (options.typecast) { - var position = node.expression.getFullStart(); - checkForTrailingWhitespace(position); - } - break; - case ts.SyntaxKind.VariableDeclaration: - case ts.SyntaxKind.PropertyDeclaration: - var _c = node, name = _c.name, type = _c.type, initializer = _c.initializer; - if (options.decl && initializer !== undefined) { - checkForTrailingWhitespace((type !== undefined ? type : name).getEnd()); - } - break; - case ts.SyntaxKind.BindingElement: - case ts.SyntaxKind.Parameter: - var dotDotDotToken = node.dotDotDotToken; - if (options.restSpread && dotDotDotToken !== undefined) { - checkForExcessiveWhitespace(dotDotDotToken.end); - } - break; - case ts.SyntaxKind.SpreadAssignment: - case ts.SyntaxKind.SpreadElement: - if (options.restSpread) { - var position = node.expression.getFullStart(); - checkForExcessiveWhitespace(position); - } - break; - case ts.SyntaxKind.UnionType: - case ts.SyntaxKind.IntersectionType: - if (options.typeOperator) { - var types_1 = node.types; - types_1.forEach(function (typeNode, index) { - if (index > 0) { - checkForTrailingWhitespace(typeNode.getFullStart()); - } - if (index < types_1.length - 1) { - checkForTrailingWhitespace(typeNode.getEnd()); - } - }); - } - } - ts.forEachChild(node, cb); - }); - var prevTokenShouldBeFollowedByWhitespace = false; - utils.forEachTokenWithTrivia(sourceFile, function (_text, tokenKind, range, parent) { - if (tokenKind === ts.SyntaxKind.WhitespaceTrivia || - tokenKind === ts.SyntaxKind.NewLineTrivia || - tokenKind === ts.SyntaxKind.EndOfFileToken) { - prevTokenShouldBeFollowedByWhitespace = false; - return; - } - else if (prevTokenShouldBeFollowedByWhitespace) { - addMissingWhitespaceErrorAt(range.pos); - prevTokenShouldBeFollowedByWhitespace = false; - } - // check for trailing space after the given tokens - switch (tokenKind) { - case ts.SyntaxKind.CatchKeyword: - case ts.SyntaxKind.ForKeyword: - case ts.SyntaxKind.IfKeyword: - case ts.SyntaxKind.SwitchKeyword: - case ts.SyntaxKind.WhileKeyword: - case ts.SyntaxKind.WithKeyword: - if (options.branch) { - prevTokenShouldBeFollowedByWhitespace = true; - } - break; - case ts.SyntaxKind.CommaToken: - if (options.separator) { - prevTokenShouldBeFollowedByWhitespace = true; - } - break; - case ts.SyntaxKind.SemicolonToken: - if (!options.separator) { - break; - } - var nextPosition = range.pos + 1; - var semicolonInTrivialFor = parent.kind === ts.SyntaxKind.ForStatement && - nextPosition !== sourceFile.end && - (sourceFile.text[nextPosition] === ";" || sourceFile.text[nextPosition] === ")"); - if (!semicolonInTrivialFor) { - prevTokenShouldBeFollowedByWhitespace = true; - } - break; - case ts.SyntaxKind.EqualsToken: - if (options.decl && parent.kind !== ts.SyntaxKind.JsxAttribute) { - prevTokenShouldBeFollowedByWhitespace = true; - } - break; - case ts.SyntaxKind.ColonToken: - if (options.type) { - prevTokenShouldBeFollowedByWhitespace = true; - } - break; - case ts.SyntaxKind.ImportKeyword: - if (parent.kind === ts.SyntaxKind.CallExpression && - parent.expression.kind === ts.SyntaxKind.ImportKeyword) { - return; // Don't check ImportCall - } - // falls through - case ts.SyntaxKind.ExportKeyword: - case ts.SyntaxKind.FromKeyword: - if (options.typecast) { - prevTokenShouldBeFollowedByWhitespace = true; - } - } - }); - function checkEqualsGreaterThanTokenInNode(node) { - if (!options.operator) { - return; - } - var equalsGreaterThanToken = utils.getChildOfKind(node, ts.SyntaxKind.EqualsGreaterThanToken, sourceFile); - // condition so we don't crash if the arrow is somehow missing - if (equalsGreaterThanToken === undefined) { - return; - } - checkForTrailingWhitespace(equalsGreaterThanToken.getFullStart()); - checkForTrailingWhitespace(equalsGreaterThanToken.getEnd()); - } - function checkForTrailingWhitespace(position, whiteSpacePos) { - if (whiteSpacePos === void 0) { whiteSpacePos = position; } - if (position !== sourceFile.end && !Lint.isWhiteSpace(sourceFile.text.charCodeAt(position))) { - addMissingWhitespaceErrorAt(whiteSpacePos); - } - } - function addMissingWhitespaceErrorAt(position) { - // TODO: this rule occasionally adds duplicate failures. - if (ctx.failures.some(function (f) { return f.getStartPosition().getPosition() === position; })) { - return; - } - var fix = Lint.Replacement.appendText(position, " "); - ctx.addFailureAt(position, 1, Rule.FAILURE_STRING_MISSING, fix); - } - function checkForExcessiveWhitespace(position) { - if (position !== sourceFile.end && Lint.isWhiteSpace(sourceFile.text.charCodeAt(position))) { - addInvalidWhitespaceErrorAt(position); - } - } - function addInvalidWhitespaceErrorAt(position) { - var fix = Lint.Replacement.deleteText(position, 1); - ctx.addFailureAt(position, 1, Rule.FAILURE_STRING_INVALID, fix); - } -} -var templateObject_1; diff --git a/node_modules/tslint/lib/runner.d.ts b/node_modules/tslint/lib/runner.d.ts deleted file mode 100644 index 0d19ecd75..000000000 --- a/node_modules/tslint/lib/runner.d.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export interface Options { - /** - * Path to a configuration file. - */ - config?: string; - /** - * Exclude globs from path expansion. - */ - exclude: string[]; - /** - * File paths to lint. - */ - files: string[]; - /** - * Whether to return status code 0 even if there are lint errors. - */ - force?: boolean; - /** - * Whether to fixes linting errors for select rules. This may overwrite linted files. - */ - fix?: boolean; - /** - * Output format. - */ - format?: string; - /** - * Formatters directory path. - */ - formattersDirectory?: string; - /** - * Whether to generate a tslint.json config file in the current working directory. - */ - init?: boolean; - /** - * Output file path. - */ - out?: string; - /** - * Whether to output absolute paths - */ - outputAbsolutePaths?: boolean; - /** - * tsconfig.json file. - */ - project?: string; - /** - * Rules directory paths. - */ - rulesDirectory?: string | string[]; - /** - * Run the tests in the given directories to ensure a (custom) TSLint rule's output matches the expected output. - * When this property is `true` the `files` property is used to specify the directories from which the tests should be executed. - */ - test?: boolean; - /** - * Whether to enable type checking when linting a project. - */ - typeCheck?: boolean; -} -export declare const enum Status { - Ok = 0, - FatalError = 1, - LintError = 2 -} -export interface Logger { - log(message: string): void; - error(message: string): void; -} -export declare function run(options: Options, logger: Logger): Promise<Status>; diff --git a/node_modules/tslint/lib/runner.js b/node_modules/tslint/lib/runner.js deleted file mode 100644 index 3ce085cb8..000000000 --- a/node_modules/tslint/lib/runner.js +++ /dev/null @@ -1,276 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -// tslint:disable strict-boolean-expressions (TODO: Fix up options) -var fs = require("fs"); -var glob = require("glob"); -var minimatch_1 = require("minimatch"); -var path = require("path"); -var ts = require("typescript"); -var configuration_1 = require("./configuration"); -var error_1 = require("./error"); -var linter_1 = require("./linter"); -var utils_1 = require("./utils"); -function run(options, logger) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var error_2; - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - return [4 /*yield*/, runWorker(options, logger)]; - case 1: return [2 /*return*/, _a.sent()]; - case 2: - error_2 = _a.sent(); - if (error_2 instanceof error_1.FatalError) { - logger.error(error_2.message + "\n"); - return [2 /*return*/, 1 /* FatalError */]; - } - throw error_2; - case 3: return [2 /*return*/]; - } - }); - }); -} -exports.run = run; -function runWorker(options, logger) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var test_1, results, _a, output, errorCount; - return tslib_1.__generator(this, function (_b) { - switch (_b.label) { - case 0: - if (options.init) { - if (fs.existsSync(configuration_1.JSON_CONFIG_FILENAME)) { - throw new error_1.FatalError("Cannot generate " + configuration_1.JSON_CONFIG_FILENAME + ": file already exists"); - } - fs.writeFileSync(configuration_1.JSON_CONFIG_FILENAME, JSON.stringify(configuration_1.DEFAULT_CONFIG, undefined, " ")); - return [2 /*return*/, 0 /* Ok */]; - } - if (!options.test) return [3 /*break*/, 2]; - return [4 /*yield*/, Promise.resolve().then(function () { return require("./test"); })]; - case 1: - test_1 = _b.sent(); - results = test_1.runTests((options.files || []).map(trimSingleQuotes), options.rulesDirectory); - return [2 /*return*/, test_1.consoleTestResultsHandler(results, logger) ? 0 /* Ok */ : 1 /* FatalError */]; - case 2: - if (options.config && !fs.existsSync(options.config)) { - throw new error_1.FatalError("Invalid option for configuration: " + options.config); - } - return [4 /*yield*/, runLinter(options, logger)]; - case 3: - _a = _b.sent(), output = _a.output, errorCount = _a.errorCount; - if (output && output.trim()) { - logger.log(output + "\n"); - } - return [2 /*return*/, options.force || errorCount === 0 ? 0 /* Ok */ : 2 /* LintError */]; - } - }); - }); -} -function runLinter(options, logger) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var _a, files, program, diagnostics, message; - return tslib_1.__generator(this, function (_b) { - _a = resolveFilesAndProgram(options, logger), files = _a.files, program = _a.program; - // if type checking, run the type checker - if (program && options.typeCheck) { - diagnostics = ts.getPreEmitDiagnostics(program); - if (diagnostics.length !== 0) { - message = diagnostics.map(function (d) { return showDiagnostic(d, program, options.outputAbsolutePaths); }).join("\n"); - if (options.force) { - logger.error(message + "\n"); - } - else { - throw new error_1.FatalError(message); - } - } - } - return [2 /*return*/, doLinting(options, files, program, logger)]; - }); - }); -} -function resolveFilesAndProgram(_a, logger) { - var files = _a.files, project = _a.project, exclude = _a.exclude, outputAbsolutePaths = _a.outputAbsolutePaths; - // remove single quotes which break matching on Windows when glob is passed in single quotes - exclude = exclude.map(trimSingleQuotes); - if (project === undefined) { - return { files: resolveGlobs(files, exclude, outputAbsolutePaths, logger) }; - } - var projectPath = findTsconfig(project); - if (projectPath === undefined) { - throw new error_1.FatalError("Invalid option for project: " + project); - } - exclude = exclude.map(function (pattern) { return path.resolve(pattern); }); - var program = linter_1.Linter.createProgram(projectPath); - var filesFound; - if (files.length === 0) { - filesFound = filterFiles(linter_1.Linter.getFileNames(program), exclude, false); - } - else { - files = files.map(function (f) { return path.resolve(f); }); - filesFound = filterFiles(program.getSourceFiles().map(function (f) { return f.fileName; }), files, true); - filesFound = filterFiles(filesFound, exclude, false); - // find non-glob files that have no matching file in the project and are not excluded by any exclude pattern - for (var _i = 0, _b = filterFiles(files, exclude, false); _i < _b.length; _i++) { - var file = _b[_i]; - if (!glob.hasMagic(file) && !filesFound.some(minimatch_1.filter(file))) { - if (fs.existsSync(file)) { - throw new error_1.FatalError("'" + file + "' is not included in project."); - } - logger.error("'" + file + "' does not exist. This will be an error in TSLint 6.\n"); // TODO make this an error in v6.0.0 - } - } - } - return { files: filesFound, program: program }; -} -function filterFiles(files, patterns, include) { - if (patterns.length === 0) { - return include ? [] : files; - } - var matcher = patterns.map(function (pattern) { return new minimatch_1.Minimatch(pattern, { dot: !include }); }); // `glob` always enables `dot` for ignore patterns - return files.filter(function (file) { return include === matcher.some(function (pattern) { return pattern.match(file); }); }); -} -function resolveGlobs(files, ignore, outputAbsolutePaths, logger) { - var results = utils_1.flatMap(files, function (file) { return glob.sync(trimSingleQuotes(file), { ignore: ignore, nodir: true }); }); - // warn if `files` contains non-existent files, that are not patters and not excluded by any of the exclude patterns - for (var _i = 0, _a = filterFiles(files, ignore, false); _i < _a.length; _i++) { - var file = _a[_i]; - if (!glob.hasMagic(file) && !results.some(minimatch_1.filter(file))) { - logger.error("'" + file + "' does not exist. This will be an error in TSLint 6.\n"); // TODO make this an error in v6.0.0 - } - } - var cwd = process.cwd(); - return results.map(function (file) { return outputAbsolutePaths ? path.resolve(cwd, file) : path.relative(cwd, file); }); -} -function doLinting(options, files, program, logger) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - function isFileExcluded(filepath) { - if (configFile === undefined || configFile.linterOptions == undefined || configFile.linterOptions.exclude == undefined) { - return false; - } - var fullPath = path.resolve(filepath); - return configFile.linterOptions.exclude.some(function (pattern) { return new minimatch_1.Minimatch(pattern).match(fullPath); }); - } - var linter, lastFolder, configFile, _i, files_1, file, folder, contents, sourceFile; - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: - linter = new linter_1.Linter({ - fix: !!options.fix, - formatter: options.format, - formattersDirectory: options.formattersDirectory, - rulesDirectory: options.rulesDirectory, - }, program); - configFile = options.config !== undefined ? configuration_1.findConfiguration(options.config).results : undefined; - _i = 0, files_1 = files; - _a.label = 1; - case 1: - if (!(_i < files_1.length)) return [3 /*break*/, 6]; - file = files_1[_i]; - if (options.config === undefined) { - folder = path.dirname(file); - if (lastFolder !== folder) { - configFile = configuration_1.findConfiguration(null, folder).results; - lastFolder = folder; - } - } - if (isFileExcluded(file)) { - return [3 /*break*/, 5]; - } - contents = void 0; - if (!(program !== undefined)) return [3 /*break*/, 2]; - sourceFile = program.getSourceFile(file); - if (sourceFile !== undefined) { - contents = sourceFile.text; - } - return [3 /*break*/, 4]; - case 2: return [4 /*yield*/, tryReadFile(file, logger)]; - case 3: - contents = _a.sent(); - _a.label = 4; - case 4: - if (contents !== undefined) { - linter.lint(file, contents, configFile); - } - _a.label = 5; - case 5: - _i++; - return [3 /*break*/, 1]; - case 6: return [2 /*return*/, linter.getResult()]; - } - }); - }); -} -/** Read a file, but return undefined if it is an MPEG '.ts' file. */ -function tryReadFile(filename, logger) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var buffer, fd; - return tslib_1.__generator(this, function (_a) { - if (!fs.existsSync(filename)) { - throw new error_1.FatalError("Unable to open file: " + filename); - } - buffer = Buffer.allocUnsafe(256); - fd = fs.openSync(filename, "r"); - try { - fs.readSync(fd, buffer, 0, 256, 0); - if (buffer.readInt8(0) === 0x47 && buffer.readInt8(188) === 0x47) { - // MPEG transport streams use the '.ts' file extension. They use 0x47 as the frame - // separator, repeating every 188 bytes. It is unlikely to find that pattern in - // TypeScript source, so tslint ignores files with the specific pattern. - logger.error(filename + ": ignoring MPEG transport stream\n"); - return [2 /*return*/, undefined]; - } - } - finally { - fs.closeSync(fd); - } - return [2 /*return*/, fs.readFileSync(filename, "utf8")]; - }); - }); -} -function showDiagnostic(_a, program, outputAbsolutePaths) { - var file = _a.file, start = _a.start, category = _a.category, messageText = _a.messageText; - var message = ts.DiagnosticCategory[category]; - if (file !== undefined && start !== undefined) { - var _b = file.getLineAndCharacterOfPosition(start), line = _b.line, character = _b.character; - var currentDirectory = program.getCurrentDirectory(); - var filePath = outputAbsolutePaths - ? path.resolve(currentDirectory, file.fileName) - : path.relative(currentDirectory, file.fileName); - message += " at " + filePath + ":" + (line + 1) + ":" + (character + 1) + ":"; - } - return message + " " + ts.flattenDiagnosticMessageText(messageText, "\n"); -} -function trimSingleQuotes(str) { - return str.replace(/^'|'$/g, ""); -} -function findTsconfig(project) { - try { - var stats = fs.statSync(project); // throws if file does not exist - if (!stats.isDirectory()) { - return project; - } - var projectFile = path.join(project, "tsconfig.json"); - fs.accessSync(projectFile); // throws if file does not exist - return projectFile; - } - catch (e) { - return undefined; - } -} diff --git a/node_modules/tslint/lib/test.d.ts b/node_modules/tslint/lib/test.d.ts deleted file mode 100644 index 6230670ec..000000000 --- a/node_modules/tslint/lib/test.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { Logger } from "./runner"; -import { LintError } from "./verify/lintError"; -export interface TestOutput { - skipped: false; - errorsFromLinter: LintError[]; - errorsFromMarkup: LintError[]; - fixesFromLinter: string; - fixesFromMarkup: string; - markupFromLinter: string; - markupFromMarkup: string; -} -export interface SkippedTest { - skipped: true; - requirement: string; -} -export interface TestResult { - directory: string; - results: { - [fileName: string]: TestOutput | SkippedTest; - }; -} -export declare function runTests(patterns: string[], rulesDirectory?: string | string[]): TestResult[]; -export declare function runTest(testDirectory: string, rulesDirectory?: string | string[]): TestResult; -export declare function consoleTestResultsHandler(testResults: TestResult[], logger: Logger): boolean; -export declare function consoleTestResultHandler(testResult: TestResult, logger: Logger): boolean; diff --git a/node_modules/tslint/lib/test.js b/node_modules/tslint/lib/test.js deleted file mode 100644 index dfb828e55..000000000 --- a/node_modules/tslint/lib/test.js +++ /dev/null @@ -1,237 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var chalk_1 = require("chalk"); -var diff = require("diff"); -var fs = require("fs"); -var glob = require("glob"); -var path = require("path"); -var semver = require("semver"); -var ts = require("typescript"); -var rule_1 = require("./language/rule/rule"); -var linter_1 = require("./linter"); -var utils_1 = require("./utils"); -var parse = require("./verify/parse"); -var MARKUP_FILE_EXTENSION = ".lint"; -var FIXES_FILE_EXTENSION = ".fix"; -function runTests(patterns, rulesDirectory) { - var files = []; - for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) { - var pattern = patterns_1[_i]; - if (path.basename(pattern) !== "tslint.json") { - pattern = path.join(pattern, "tslint.json"); - } - files.push.apply(files, glob.sync(pattern)); - } - return files.map(function (directory) { return runTest(path.dirname(directory), rulesDirectory); }); -} -exports.runTests = runTests; -function runTest(testDirectory, rulesDirectory) { - var filesToLint = glob.sync(path.join(testDirectory, "**/*" + MARKUP_FILE_EXTENSION)); - var tslintConfig = linter_1.Linter.findConfiguration(path.join(testDirectory, "tslint.json"), "").results; - var tsConfig = path.join(testDirectory, "tsconfig.json"); - var compilerOptions = { allowJs: true }; - var hasConfig = fs.existsSync(tsConfig); - if (hasConfig) { - var _a = ts.readConfigFile(tsConfig, ts.sys.readFile), config = _a.config, error = _a.error; - if (error !== undefined) { - throw new Error(ts.formatDiagnostics([error], ts.createCompilerHost({}))); - } - var parseConfigHost = { - fileExists: fs.existsSync, - readDirectory: ts.sys.readDirectory, - readFile: function (file) { return fs.readFileSync(file, "utf8"); }, - useCaseSensitiveFileNames: true, - }; - compilerOptions = ts.parseJsonConfigFileContent(config, parseConfigHost, testDirectory).options; - } - var results = { directory: testDirectory, results: {} }; - var _loop_1 = function (fileToLint) { - var isEncodingRule = path.basename(testDirectory) === "encoding"; - var fileCompileName = utils_1.denormalizeWinPath(path.resolve(fileToLint.replace(/\.lint$/, ""))); - var fileText = isEncodingRule ? utils_1.readBufferWithDetectedEncoding(fs.readFileSync(fileToLint)) : fs.readFileSync(fileToLint, "utf-8"); - var tsVersionRequirement = parse.getTypescriptVersionRequirement(fileText); - if (tsVersionRequirement !== undefined) { - // remove prerelease suffix when matching to allow testing with nightly builds - if (!semver.satisfies(parse.getNormalizedTypescriptVersion(), tsVersionRequirement)) { - results.results[fileToLint] = { - requirement: tsVersionRequirement, - skipped: true, - }; - return "continue"; - } - // remove the first line from the file before continuing - var lineBreak = fileText.search(/\n/); - fileText = lineBreak === -1 ? "" : fileText.substr(lineBreak + 1); - } - fileText = parse.preprocessDirectives(fileText); - var fileTextWithoutMarkup = parse.removeErrorMarkup(fileText); - var errorsFromMarkup = parse.parseErrorsFromMarkup(fileText); - var program = void 0; - if (hasConfig) { - var compilerHost = { - fileExists: function (file) { return file === fileCompileName || fs.existsSync(file); }, - getCanonicalFileName: function (filename) { return filename; }, - getCurrentDirectory: function () { return process.cwd(); }, - getDefaultLibFileName: function () { return ts.getDefaultLibFileName(compilerOptions); }, - getDirectories: function (dir) { return fs.readdirSync(dir); }, - getNewLine: function () { return "\n"; }, - getSourceFile: function (filenameToGet, target) { - if (utils_1.denormalizeWinPath(filenameToGet) === fileCompileName) { - return ts.createSourceFile(filenameToGet, fileTextWithoutMarkup, target, true); - } - if (path.basename(filenameToGet) === filenameToGet) { - // resolve path of lib.xxx.d.ts - filenameToGet = path.join(path.dirname(ts.getDefaultLibFilePath(compilerOptions)), filenameToGet); - } - var text = fs.readFileSync(filenameToGet, "utf8"); - return ts.createSourceFile(filenameToGet, text, target, true); - }, - readFile: function (x) { return x; }, - useCaseSensitiveFileNames: function () { return true; }, - writeFile: function () { return null; }, - }; - program = ts.createProgram([fileCompileName], compilerOptions, compilerHost); - } - var lintOptions = { - fix: false, - formatter: "prose", - formattersDirectory: "", - rulesDirectory: rulesDirectory, - }; - var linter = new linter_1.Linter(lintOptions, program); - // Need to use the true path (ending in '.lint') for "encoding" rule so that it can read the file. - linter.lint(isEncodingRule ? fileToLint : fileCompileName, fileTextWithoutMarkup, tslintConfig); - var failures = linter.getResult().failures; - var errorsFromLinter = failures.map(function (failure) { - var startLineAndCharacter = failure.getStartPosition().getLineAndCharacter(); - var endLineAndCharacter = failure.getEndPosition().getLineAndCharacter(); - return { - endPos: { - col: endLineAndCharacter.character, - line: endLineAndCharacter.line, - }, - message: failure.getFailure(), - startPos: { - col: startLineAndCharacter.character, - line: startLineAndCharacter.line, - }, - }; - }); - // test against fixed files - var fixedFileText = ""; - var newFileText = ""; - try { - var fixedFile = fileToLint.replace(/\.lint$/, FIXES_FILE_EXTENSION); - var stat = fs.statSync(fixedFile); - if (stat.isFile()) { - fixedFileText = fs.readFileSync(fixedFile, "utf8"); - var fixes = utils_1.mapDefined(failures, function (f) { return f.getFix(); }); - newFileText = rule_1.Replacement.applyFixes(fileTextWithoutMarkup, fixes); - } - } - catch (e) { - fixedFileText = ""; - newFileText = ""; - } - results.results[fileToLint] = { - errorsFromLinter: errorsFromLinter, - errorsFromMarkup: errorsFromMarkup, - fixesFromLinter: newFileText, - fixesFromMarkup: fixedFileText, - markupFromLinter: parse.createMarkupFromErrors(fileTextWithoutMarkup, errorsFromMarkup), - markupFromMarkup: parse.createMarkupFromErrors(fileTextWithoutMarkup, errorsFromLinter), - skipped: false, - }; - }; - for (var _i = 0, filesToLint_1 = filesToLint; _i < filesToLint_1.length; _i++) { - var fileToLint = filesToLint_1[_i]; - _loop_1(fileToLint); - } - return results; -} -exports.runTest = runTest; -function consoleTestResultsHandler(testResults, logger) { - var didAllTestsPass = true; - for (var _i = 0, testResults_1 = testResults; _i < testResults_1.length; _i++) { - var testResult = testResults_1[_i]; - if (!consoleTestResultHandler(testResult, logger)) { - didAllTestsPass = false; - } - } - return didAllTestsPass; -} -exports.consoleTestResultsHandler = consoleTestResultsHandler; -function consoleTestResultHandler(testResult, logger) { - // needed to get colors to show up when passing through Grunt - chalk_1.default.enabled = true; - var didAllTestsPass = true; - for (var _i = 0, _a = Object.keys(testResult.results); _i < _a.length; _i++) { - var fileName = _a[_i]; - var results = testResult.results[fileName]; - logger.log(fileName + ":"); - if (results.skipped) { - logger.log(chalk_1.default.yellow(" Skipped, requires typescript " + results.requirement + "\n")); - } - else { - var markupDiffResults = diff.diffLines(results.markupFromMarkup, results.markupFromLinter); - var fixesDiffResults = diff.diffLines(results.fixesFromLinter, results.fixesFromMarkup); - var didMarkupTestPass = !markupDiffResults.some(function (hunk) { return hunk.added === true || hunk.removed === true; }); - var didFixesTestPass = !fixesDiffResults.some(function (hunk) { return hunk.added === true || hunk.removed === true; }); - if (didMarkupTestPass && didFixesTestPass) { - logger.log(chalk_1.default.green(" Passed\n")); - } - else { - logger.log(chalk_1.default.red(" Failed!\n")); - didAllTestsPass = false; - if (!didMarkupTestPass) { - displayDiffResults(markupDiffResults, MARKUP_FILE_EXTENSION, logger); - } - if (!didFixesTestPass) { - displayDiffResults(fixesDiffResults, FIXES_FILE_EXTENSION, logger); - } - } - } - } - return didAllTestsPass; -} -exports.consoleTestResultHandler = consoleTestResultHandler; -function displayDiffResults(diffResults, extension, logger) { - logger.log(chalk_1.default.green("Expected (from " + extension + " file)\n")); - logger.log(chalk_1.default.red("Actual (from TSLint)\n")); - var _loop_2 = function (diffResult) { - var color = chalk_1.default.grey; - var prefix = " "; - if (diffResult.added) { - color = chalk_1.default.green.underline; - prefix = "+ "; - } - else if (diffResult.removed) { - color = chalk_1.default.red.underline; - prefix = "- "; - } - logger.log(color(diffResult.value.split(/\r\n|\r|\n/) - // strings end on a newline which we do not want to include the prefix. - // tslint:disable-next-line:prefer-template - .map(function (line, index, array) { return index === array.length - 1 ? line : prefix + line + "\n"; }).join(""))); - }; - for (var _i = 0, diffResults_1 = diffResults; _i < diffResults_1.length; _i++) { - var diffResult = diffResults_1[_i]; - _loop_2(diffResult); - } -} diff --git a/node_modules/tslint/lib/utils.d.ts b/node_modules/tslint/lib/utils.d.ts deleted file mode 100644 index 9d7aa545e..000000000 --- a/node_modules/tslint/lib/utils.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/// <reference types="node" /> -/** - * Enforces the invariant that the input is an array. - */ -export declare function arrayify<T>(arg?: T | T[]): T[]; -/** - * @deprecated (no longer used) - * Enforces the invariant that the input is an object. - */ -export declare function objectify(arg: any): any; -export declare function hasOwnProperty(arg: {}, key: string): boolean; -/** - * Replace hyphens in a rule name by upper-casing the letter after them. - * E.g. "foo-bar" -> "fooBar" - */ -export declare function camelize(stringWithHyphens: string): string; -export declare function isUpperCase(str: string): boolean; -export declare function isLowerCase(str: string): boolean; -/** - * Removes leading indents from a template string without removing all leading whitespace - */ -export declare function dedent(strings: TemplateStringsArray, ...values: any[]): string; -/** - * Strip comments from file content. - */ -export declare function stripComments(content: string): string; -/** - * Escapes all special characters in RegExp pattern to avoid broken regular expressions and ensure proper matches - */ -export declare function escapeRegExp(re: string): string; -/** Return true if both parameters are equal. */ -export declare type Equal<T> = (a: T, b: T) => boolean; -export declare function arraysAreEqual<T>(a: ReadonlyArray<T> | undefined, b: ReadonlyArray<T> | undefined, eq: Equal<T>): boolean; -/** Returns the first non-`undefined` result. */ -export declare function find<T, U>(inputs: T[], getResult: (t: T) => U | undefined): U | undefined; -/** Returns an array that is the concatenation of all output arrays. */ -export declare function flatMap<T, U>(inputs: ReadonlyArray<T>, getOutputs: (input: T, index: number) => ReadonlyArray<U>): U[]; -/** Returns an array of all outputs that are not `undefined`. */ -export declare function mapDefined<T, U>(inputs: ReadonlyArray<T>, getOutput: (input: T) => U | undefined): U[]; -export declare function readBufferWithDetectedEncoding(buffer: Buffer): string; -export declare type Encoding = "utf8" | "utf8-bom" | "utf16le" | "utf16be"; -export declare function detectBufferEncoding(buffer: Buffer, length?: number): Encoding; -export declare function denormalizeWinPath(path: string): string; -export declare function isPascalCased(name: string): boolean; -export declare function isCamelCased(name: string): boolean; -export declare function isKebabCased(name: string): boolean; diff --git a/node_modules/tslint/lib/utils.js b/node_modules/tslint/lib/utils.js deleted file mode 100644 index 26889aa0b..000000000 --- a/node_modules/tslint/lib/utils.js +++ /dev/null @@ -1,236 +0,0 @@ -"use strict"; -/** - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Enforces the invariant that the input is an array. - */ -function arrayify(arg) { - if (Array.isArray(arg)) { - return arg; - } - else if (arg != undefined) { - return [arg]; - } - else { - return []; - } -} -exports.arrayify = arrayify; -/** - * @deprecated (no longer used) - * Enforces the invariant that the input is an object. - */ -function objectify(arg) { - if (typeof arg === "object" && arg != undefined) { - return arg; - } - else { - return {}; - } -} -exports.objectify = objectify; -function hasOwnProperty(arg, key) { - return Object.prototype.hasOwnProperty.call(arg, key); -} -exports.hasOwnProperty = hasOwnProperty; -/** - * Replace hyphens in a rule name by upper-casing the letter after them. - * E.g. "foo-bar" -> "fooBar" - */ -function camelize(stringWithHyphens) { - return stringWithHyphens.replace(/-(.)/g, function (_, nextLetter) { return nextLetter.toUpperCase(); }); -} -exports.camelize = camelize; -function isUpperCase(str) { - return str === str.toUpperCase(); -} -exports.isUpperCase = isUpperCase; -function isLowerCase(str) { - return str === str.toLowerCase(); -} -exports.isLowerCase = isLowerCase; -/** - * Removes leading indents from a template string without removing all leading whitespace - */ -function dedent(strings) { - var values = []; - for (var _i = 1; _i < arguments.length; _i++) { - values[_i - 1] = arguments[_i]; - } - var fullString = strings.reduce(function (accumulator, str, i) { return "" + accumulator + values[i - 1] + str; }); - // match all leading spaces/tabs at the start of each line - var match = fullString.match(/^[ \t]*(?=\S)/gm); - if (match === null) { - // e.g. if the string is empty or all whitespace. - return fullString; - } - // find the smallest indent, we don't want to remove all leading whitespace - var indent = Math.min.apply(Math, match.map(function (el) { return el.length; })); - var regexp = new RegExp("^[ \\t]{" + indent + "}", "gm"); - fullString = indent > 0 ? fullString.replace(regexp, "") : fullString; - return fullString; -} -exports.dedent = dedent; -/** - * Strip comments from file content. - */ -function stripComments(content) { - /** - * First capturing group matches double quoted string - * Second matches single quotes string - * Third matches block comments - * Fourth matches line comments - */ - var regexp = /("(?:[^\\\"]*(?:\\.)?)*")|('(?:[^\\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g; - var result = content.replace(regexp, function (match, _m1, _m2, m3, m4) { - // Only one of m1, m2, m3, m4 matches - if (m3 !== undefined) { - // A block comment. Replace with nothing - return ""; - } - else if (m4 !== undefined) { - // A line comment. If it ends in \r?\n then keep it. - var length = m4.length; - if (length > 2 && m4[length - 1] === "\n") { - return m4[length - 2] === "\r" ? "\r\n" : "\n"; - } - else { - return ""; - } - } - else { - // We match a string - return match; - } - }); - return result; -} -exports.stripComments = stripComments; -/** - * Escapes all special characters in RegExp pattern to avoid broken regular expressions and ensure proper matches - */ -function escapeRegExp(re) { - return re.replace(/[.+*?|^$[\]{}()\\]/g, "\\$&"); -} -exports.escapeRegExp = escapeRegExp; -function arraysAreEqual(a, b, eq) { - return a === b || a !== undefined && b !== undefined && a.length === b.length && a.every(function (x, idx) { return eq(x, b[idx]); }); -} -exports.arraysAreEqual = arraysAreEqual; -/** Returns the first non-`undefined` result. */ -function find(inputs, getResult) { - for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) { - var element = inputs_1[_i]; - var result = getResult(element); - if (result !== undefined) { - return result; - } - } - return undefined; -} -exports.find = find; -/** Returns an array that is the concatenation of all output arrays. */ -function flatMap(inputs, getOutputs) { - var out = []; - for (var i = 0; i < inputs.length; i++) { - out.push.apply(out, getOutputs(inputs[i], i)); - } - return out; -} -exports.flatMap = flatMap; -/** Returns an array of all outputs that are not `undefined`. */ -function mapDefined(inputs, getOutput) { - var out = []; - for (var _i = 0, inputs_2 = inputs; _i < inputs_2.length; _i++) { - var input = inputs_2[_i]; - var output = getOutput(input); - if (output !== undefined) { - out.push(output); - } - } - return out; -} -exports.mapDefined = mapDefined; -function readBufferWithDetectedEncoding(buffer) { - switch (detectBufferEncoding(buffer)) { - case "utf8": - return buffer.toString(); - case "utf8-bom": - return buffer.toString("utf-8", 2); - case "utf16le": - return buffer.toString("utf16le", 2); - case "utf16be": - // Round down to nearest multiple of 2. - var len = buffer.length & ~1; // tslint:disable-line no-bitwise - // Flip all byte pairs, then read as little-endian. - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } -} -exports.readBufferWithDetectedEncoding = readBufferWithDetectedEncoding; -function detectBufferEncoding(buffer, length) { - if (length === void 0) { length = buffer.length; } - if (length < 2) { - return "utf8"; - } - switch (buffer[0]) { - case 0xEF: - if (buffer[1] === 0xBB && length >= 3 && buffer[2] === 0xBF) { - return "utf8-bom"; - } - break; - case 0xFE: - if (buffer[1] === 0xFF) { - return "utf16be"; - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return "utf16le"; - } - } - return "utf8"; -} -exports.detectBufferEncoding = detectBufferEncoding; -// converts Windows normalized paths (with backwards slash `\`) to paths used by TypeScript (with forward slash `/`) -function denormalizeWinPath(path) { - return path.replace(/\\/g, "/"); -} -exports.denormalizeWinPath = denormalizeWinPath; -function isPascalCased(name) { - return isUpperCase(name[0]) && !name.includes("_") && !name.includes("-"); -} -exports.isPascalCased = isPascalCased; -function isCamelCased(name) { - return isLowerCase(name[0]) && !name.includes("_") && !name.includes("-"); -} -exports.isCamelCased = isCamelCased; -function isKebabCased(name) { - for (var i = 0; i < name.length; i++) { - var c = name.charAt(i); - if (c === "_" || !isLowerCase(c)) { - return false; - } - } - return true; -} -exports.isKebabCased = isKebabCased; diff --git a/node_modules/tslint/lib/verify/lines.d.ts b/node_modules/tslint/lib/verify/lines.d.ts deleted file mode 100644 index 8d8820db7..000000000 --- a/node_modules/tslint/lib/verify/lines.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -export declare class Line { -} -export declare class CodeLine extends Line { - contents: string; - constructor(contents: string); -} -export declare class MessageSubstitutionLine extends Line { - key: string; - message: string; - constructor(key: string, message: string); -} -export declare class ErrorLine extends Line { - startCol: number; - constructor(startCol: number); -} -export declare class MultilineErrorLine extends ErrorLine { - constructor(startCol: number); -} -export declare class EndErrorLine extends ErrorLine { - endCol: number; - message: string; - constructor(startCol: number, endCol: number, message: string); -} -export declare const ZERO_LENGTH_ERROR = "~nil"; -/** - * Maps a line of text from a .lint file to an appropriate Line object - */ -export declare function parseLine(text: string): Line; -/** - * Maps a Line object to a matching line of text that could be in a .lint file. - * This is almost the inverse of parseLine. - * If you ran `printLine(parseLine(someText), code)`, the whitespace in the result may be different than in someText - * @param line - A Line object to convert to text - * @param code - If line represents error markup, this is the line of code preceding the markup. - * Otherwise, this parameter is not required. - */ -export declare function printLine(line: Line, code?: string): string | undefined; diff --git a/node_modules/tslint/lib/verify/lines.js b/node_modules/tslint/lib/verify/lines.js deleted file mode 100644 index 80c80ba57..000000000 --- a/node_modules/tslint/lib/verify/lines.js +++ /dev/null @@ -1,158 +0,0 @@ -"use strict"; -/* - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -// Use classes here instead of interfaces because we want runtime type data -var Line = /** @class */ (function () { - function Line() { - } - return Line; -}()); -exports.Line = Line; -var CodeLine = /** @class */ (function (_super) { - tslib_1.__extends(CodeLine, _super); - function CodeLine(contents) { - var _this = _super.call(this) || this; - _this.contents = contents; - return _this; - } - return CodeLine; -}(Line)); -exports.CodeLine = CodeLine; -var MessageSubstitutionLine = /** @class */ (function (_super) { - tslib_1.__extends(MessageSubstitutionLine, _super); - function MessageSubstitutionLine(key, message) { - var _this = _super.call(this) || this; - _this.key = key; - _this.message = message; - return _this; - } - return MessageSubstitutionLine; -}(Line)); -exports.MessageSubstitutionLine = MessageSubstitutionLine; -var ErrorLine = /** @class */ (function (_super) { - tslib_1.__extends(ErrorLine, _super); - function ErrorLine(startCol) { - var _this = _super.call(this) || this; - _this.startCol = startCol; - return _this; - } - return ErrorLine; -}(Line)); -exports.ErrorLine = ErrorLine; -var MultilineErrorLine = /** @class */ (function (_super) { - tslib_1.__extends(MultilineErrorLine, _super); - function MultilineErrorLine(startCol) { - return _super.call(this, startCol) || this; - } - return MultilineErrorLine; -}(ErrorLine)); -exports.MultilineErrorLine = MultilineErrorLine; -var EndErrorLine = /** @class */ (function (_super) { - tslib_1.__extends(EndErrorLine, _super); - function EndErrorLine(startCol, endCol, message) { - var _this = _super.call(this, startCol) || this; - _this.endCol = endCol; - _this.message = message; - return _this; - } - return EndErrorLine; -}(ErrorLine)); -exports.EndErrorLine = EndErrorLine; -// example matches (between the quotes): -// " ~~~~~~~~" -var multilineErrorRegex = /^\s*(~+|~nil)$/; -// " ~~~~~~~~~ [some error message]" -var endErrorRegex = /^\s*(~+|~nil)\s*\[(.+)\]\s*$/; -// "[shortcut]: full messages goes here!! " -var messageSubstitutionRegex = /^\[([-\w]+?)]: \s*(.+?)\s*$/; -exports.ZERO_LENGTH_ERROR = "~nil"; -/** - * Maps a line of text from a .lint file to an appropriate Line object - */ -function parseLine(text) { - var multilineErrorMatch = text.match(multilineErrorRegex); - if (multilineErrorMatch !== null) { - var startErrorCol = text.indexOf("~"); - return new MultilineErrorLine(startErrorCol); - } - var endErrorMatch = text.match(endErrorRegex); - if (endErrorMatch !== null) { - var squiggles = endErrorMatch[1], message = endErrorMatch[2]; - var startErrorCol = text.indexOf("~"); - var zeroLengthError = (squiggles === exports.ZERO_LENGTH_ERROR); - var endErrorCol = zeroLengthError ? startErrorCol : text.lastIndexOf("~") + 1; - return new EndErrorLine(startErrorCol, endErrorCol, message); - } - var messageSubstitutionMatch = text.match(messageSubstitutionRegex); - if (messageSubstitutionMatch !== null) { - var key = messageSubstitutionMatch[1], message = messageSubstitutionMatch[2]; - return new MessageSubstitutionLine(key, message); - } - // line doesn't match any syntax for error markup, so it's a line of code to be linted - return new CodeLine(text); -} -exports.parseLine = parseLine; -/** - * Maps a Line object to a matching line of text that could be in a .lint file. - * This is almost the inverse of parseLine. - * If you ran `printLine(parseLine(someText), code)`, the whitespace in the result may be different than in someText - * @param line - A Line object to convert to text - * @param code - If line represents error markup, this is the line of code preceding the markup. - * Otherwise, this parameter is not required. - */ -function printLine(line, code) { - if (line instanceof ErrorLine) { - if (code === undefined) { - throw new Error("Must supply argument for code parameter when line is an ErrorLine"); - } - var leadingSpaces = " ".repeat(line.startCol); - if (line instanceof MultilineErrorLine) { - // special case for when the line of code is simply a newline. - // use "~nil" to indicate the error continues on that line - if (code.length === 0 && line.startCol === 0) { - return exports.ZERO_LENGTH_ERROR; - } - var tildes = "~".repeat(code.length - leadingSpaces.length); - return "" + leadingSpaces + tildes; - } - else if (line instanceof EndErrorLine) { - var tildes = "~".repeat(line.endCol - line.startCol); - if (code.length < line.endCol) { - // Better than crashing in String.repeat - throw new Error("Bad error marker at " + JSON.stringify(line)); - } - var endSpaces = " ".repeat(code.length - line.endCol); - if (tildes.length === 0) { - tildes = exports.ZERO_LENGTH_ERROR; - // because we add "~nil" we need four less spaces than normal at the end - // always make sure we have at least one space though - endSpaces = endSpaces.substring(0, Math.max(endSpaces.length - 4, 1)); - } - return "" + leadingSpaces + tildes + endSpaces + " [" + line.message + "]"; - } - } - else if (line instanceof MessageSubstitutionLine) { - return "[" + line.key + "]: " + line.message; - } - else if (line instanceof CodeLine) { - return line.contents; - } - return undefined; -} -exports.printLine = printLine; diff --git a/node_modules/tslint/lib/verify/lintError.d.ts b/node_modules/tslint/lib/verify/lintError.d.ts deleted file mode 100644 index a1b9f821a..000000000 --- a/node_modules/tslint/lib/verify/lintError.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface PositionInFile { - line: number; - col: number; -} -export interface LintError { - startPos: PositionInFile; - endPos: PositionInFile; - message: string; -} -export declare function errorComparator(err1: LintError, err2: LintError): number; -export declare function lintSyntaxError(message: string): Error; diff --git a/node_modules/tslint/lib/verify/lintError.js b/node_modules/tslint/lib/verify/lintError.js deleted file mode 100644 index 58082053a..000000000 --- a/node_modules/tslint/lib/verify/lintError.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -/* - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -function errorComparator(err1, err2) { - if (err1.startPos.line !== err2.startPos.line) { - return err1.startPos.line - err2.startPos.line; - } - else if (err1.startPos.col !== err2.startPos.col) { - return err1.startPos.col - err2.startPos.col; - } - else if (err1.endPos.line !== err2.endPos.line) { - return err1.endPos.line - err2.endPos.line; - } - else if (err1.endPos.col !== err2.endPos.col) { - return err1.endPos.col - err2.endPos.col; - } - else { - return err1.message.localeCompare(err2.message); - } -} -exports.errorComparator = errorComparator; -function lintSyntaxError(message) { - return new Error("Lint File Syntax Error: " + message); -} -exports.lintSyntaxError = lintSyntaxError; diff --git a/node_modules/tslint/lib/verify/parse.d.ts b/node_modules/tslint/lib/verify/parse.d.ts deleted file mode 100644 index 12e9535e8..000000000 --- a/node_modules/tslint/lib/verify/parse.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { LintError } from "./lintError"; -export declare function getTypescriptVersionRequirement(text: string): string | undefined; -export declare function getNormalizedTypescriptVersion(): string; -export declare function preprocessDirectives(text: string): string; -/** - * Takes the full text of a .lint file and returns the contents of the file - * with all error markup removed - */ -export declare function removeErrorMarkup(text: string): string; -/** - * Takes the full text of a .lint file and returns an array of LintErrors - * corresponding to the error markup in the file. - */ -export declare function parseErrorsFromMarkup(text: string): LintError[]; -export declare function createMarkupFromErrors(code: string, lintErrors: LintError[]): string; diff --git a/node_modules/tslint/lib/verify/parse.js b/node_modules/tslint/lib/verify/parse.js deleted file mode 100644 index 32743a5c9..000000000 --- a/node_modules/tslint/lib/verify/parse.js +++ /dev/null @@ -1,261 +0,0 @@ -"use strict"; -/* - * @license - * Copyright 2016 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var semver = require("semver"); -var ts = require("typescript"); -var util_1 = require("util"); -var utils_1 = require("../utils"); -var lines_1 = require("./lines"); -var lintError_1 = require("./lintError"); -var scanner; -function getTypescriptVersionRequirement(text) { - var lines = text.split(/\r?\n/); - var firstLine = lines_1.parseLine(lines[0]); - if (firstLine instanceof lines_1.MessageSubstitutionLine && firstLine.key === "typescript") { - return firstLine.message; - } - return undefined; -} -exports.getTypescriptVersionRequirement = getTypescriptVersionRequirement; -function getNormalizedTypescriptVersion() { - var tsVersion = new semver.SemVer(ts.version); - // remove prerelease suffix when matching to allow testing with nightly builds - return tsVersion.major + "." + tsVersion.minor + "." + tsVersion.patch; -} -exports.getNormalizedTypescriptVersion = getNormalizedTypescriptVersion; -function preprocessDirectives(text) { - if (!/^#(?:if|else|endif)\b/m.test(text)) { - return text; // If there are no directives, just return the input unchanged - } - var tsVersion = getNormalizedTypescriptVersion(); - var lines = text.split(/\n/); - var result = []; - var collecting = true; - var state = 0 /* Initial */; - for (var _i = 0, lines_2 = lines; _i < lines_2.length; _i++) { - var line = lines_2[_i]; - if (line.startsWith("#if typescript")) { - if (state !== 0 /* Initial */) { - throw lintError_1.lintSyntaxError("#if directives cannot be nested"); - } - state = 1 /* If */; - collecting = semver.satisfies(tsVersion, line.slice("#if typescript".length).trim()); - } - else if (/^#else\s*$/.test(line)) { - if (state !== 1 /* If */) { - throw lintError_1.lintSyntaxError("unexpected #else"); - } - state = 2 /* Else */; - collecting = !collecting; - } - else if (/^#endif\s*$/.test(line)) { - if (state === 0 /* Initial */) { - throw lintError_1.lintSyntaxError("unexpected #endif"); - } - state = 0 /* Initial */; - collecting = true; - } - else if (collecting) { - result.push(line); - } - } - if (state !== 0 /* Initial */) { - throw lintError_1.lintSyntaxError("expected #endif"); - } - return result.join("\n"); -} -exports.preprocessDirectives = preprocessDirectives; -/** - * Takes the full text of a .lint file and returns the contents of the file - * with all error markup removed - */ -function removeErrorMarkup(text) { - var textWithMarkup = text.split("\n"); - var lines = textWithMarkup.map(lines_1.parseLine); - var codeText = lines.filter(function (line) { return (line instanceof lines_1.CodeLine); }).map(function (line) { return line.contents; }); - return codeText.join("\n"); -} -exports.removeErrorMarkup = removeErrorMarkup; -/* tslint:disable:object-literal-sort-keys */ -/** - * Takes the full text of a .lint file and returns an array of LintErrors - * corresponding to the error markup in the file. - */ -function parseErrorsFromMarkup(text) { - var textWithMarkup = text.split("\n"); - var lines = textWithMarkup.map(lines_1.parseLine); - if (lines.length > 0 && !(lines[0] instanceof lines_1.CodeLine)) { - throw lintError_1.lintSyntaxError("text cannot start with an error mark line."); - } - var messageSubstitutionLines = lines.filter(function (l) { return l instanceof lines_1.MessageSubstitutionLine; }); - var messageSubstitutions = new Map(); - for (var _i = 0, messageSubstitutionLines_1 = messageSubstitutionLines; _i < messageSubstitutionLines_1.length; _i++) { - var _a = messageSubstitutionLines_1[_i], key = _a.key, message = _a.message; - messageSubstitutions.set(key, formatMessage(messageSubstitutions, message)); - } - // errorLineForCodeLine[5] contains all the ErrorLine objects associated with the 5th line of code, for example - var errorLinesForCodeLines = createCodeLineNoToErrorsMap(lines); - var lintErrors = []; - function addError(errorLine, errorStartPos, lineNo) { - lintErrors.push({ - startPos: errorStartPos, - endPos: { line: lineNo, col: errorLine.endCol }, - message: substituteMessage(messageSubstitutions, errorLine.message), - }); - } - // for each line of code... - errorLinesForCodeLines.forEach(function (errorLinesForLineOfCode, lineNo) { - // for each error marking on that line... - while (errorLinesForLineOfCode.length > 0) { - var errorLine = errorLinesForLineOfCode.shift(); - var errorStartPos = { line: lineNo, col: errorLine.startCol }; - // if the error starts and ends on this line, add it now to list of errors - if (errorLine instanceof lines_1.EndErrorLine) { - addError(errorLine, errorStartPos, lineNo); - // if the error is the start of a multiline error - } - else if (errorLine instanceof lines_1.MultilineErrorLine) { - // iterate through the MultilineErrorLines until we get to an EndErrorLine - for (var nextLineNo = lineNo + 1;; ++nextLineNo) { - if (!isValidErrorMarkupContinuation(errorLinesForCodeLines, nextLineNo)) { - throw lintError_1.lintSyntaxError("Error mark starting at " + errorStartPos.line + ":" + errorStartPos.col + " does not end correctly."); - } - else { - var nextErrorLine = errorLinesForCodeLines[nextLineNo].shift(); - // if end of multiline error, add it it list of errors - if (nextErrorLine instanceof lines_1.EndErrorLine) { - addError(nextErrorLine, errorStartPos, nextLineNo); - break; - } - } - } - } - } - }); - lintErrors.sort(lintError_1.errorComparator); - return lintErrors; -} -exports.parseErrorsFromMarkup = parseErrorsFromMarkup; -/** - * Process `message` as follows: - * - search `substitutions` for an exact match and return the substitution - * - try to format the message when it looks like: name % ('substitution1' [, "substitution2" [, ...]]) - * - or return it unchanged - */ -function substituteMessage(templates, message) { - var substitution = templates.get(message); - if (substitution !== undefined) { - return substitution; - } - return formatMessage(templates, message); -} -/** - * Tries to format the message when it has the correct format or returns it unchanged: name % ('substitution1' [, "substitution2" [, ...]]) - * Where `name` is the name of a message substitution that is used as template. - * If `name` is not found in `templates`, `message` is returned unchanged. - */ -function formatMessage(templates, message) { - var formatMatch = /^([-\w]+) % \((.+)\)$/.exec(message); - if (formatMatch !== null) { - var template = templates.get(formatMatch[1]); - if (template !== undefined) { - var formatArgs = parseFormatArguments(formatMatch[2]); - if (formatArgs !== undefined) { - message = util_1.format.apply(void 0, [template].concat(formatArgs)); - } - } - } - return message; -} -/** - * Parse a list of comma separated string literals. - * This function bails out if it sees something unexpected. - * Whitespace between tokens is ignored. - * Trailing comma is allowed. - */ -function parseFormatArguments(text) { - if (scanner === undefined) { - // once the scanner is created, it is cached for subsequent calls - scanner = ts.createScanner(ts.ScriptTarget.Latest, false); - } - scanner.setText(text); - var result = []; - var expectValue = true; - for (var token = scanner.scan(); token !== ts.SyntaxKind.EndOfFileToken; token = scanner.scan()) { - if (token === ts.SyntaxKind.StringLiteral) { - if (!expectValue) { - return undefined; - } - result.push(scanner.getTokenValue()); - expectValue = false; - } - else if (token === ts.SyntaxKind.CommaToken) { - if (expectValue) { - return undefined; - } - expectValue = true; - } - else if (token !== ts.SyntaxKind.WhitespaceTrivia) { - // only ignore whitespace, other trivia like comments makes this function bail out - return undefined; - } - } - return result.length === 0 ? undefined : result; -} -function createMarkupFromErrors(code, lintErrors) { - lintErrors.sort(lintError_1.errorComparator); - var codeText = code.split("\n"); - var errorLinesForCodeText = codeText.map(function () { return []; }); - for (var _i = 0, lintErrors_1 = lintErrors; _i < lintErrors_1.length; _i++) { - var error = lintErrors_1[_i]; - var startPos = error.startPos, endPos = error.endPos, message = error.message; - if (startPos.line === endPos.line) { - // single line error - errorLinesForCodeText[startPos.line].push(new lines_1.EndErrorLine(startPos.col, endPos.col, message)); - } - else { - // multiline error - errorLinesForCodeText[startPos.line].push(new lines_1.MultilineErrorLine(startPos.col)); - for (var lineNo = startPos.line + 1; lineNo < endPos.line; ++lineNo) { - errorLinesForCodeText[lineNo].push(new lines_1.MultilineErrorLine(0)); - } - errorLinesForCodeText[endPos.line].push(new lines_1.EndErrorLine(0, endPos.col, message)); - } - } - return utils_1.flatMap(codeText, function (line, i) { return [line].concat(utils_1.mapDefined(errorLinesForCodeText[i], function (err) { return lines_1.printLine(err, line); })); }).join("\n"); -} -exports.createMarkupFromErrors = createMarkupFromErrors; -/* tslint:enable:object-literal-sort-keys */ -function createCodeLineNoToErrorsMap(lines) { - var errorLinesForCodeLine = []; - for (var _i = 0, lines_3 = lines; _i < lines_3.length; _i++) { - var line = lines_3[_i]; - if (line instanceof lines_1.CodeLine) { - errorLinesForCodeLine.push([]); - } - else if (line instanceof lines_1.ErrorLine) { - errorLinesForCodeLine[errorLinesForCodeLine.length - 1].push(line); - } - } - return errorLinesForCodeLine; -} -function isValidErrorMarkupContinuation(errorLinesForCodeLines, lineNo) { - return lineNo < errorLinesForCodeLines.length - && errorLinesForCodeLines[lineNo].length !== 0 - && errorLinesForCodeLines[lineNo][0].startCol === 0; -} |