From d702d4810fec3e7c3ebe8abeb080f81a50aac4f8 Mon Sep 17 00:00:00 2001 From: Jay Bhagat Date: Tue, 19 Nov 2019 09:41:48 -0500 Subject: [PATCH 1/7] creating rule --- test/rules/completed-docs/defaults/edge-case/test.ts.lint | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/rules/completed-docs/defaults/edge-case/test.ts.lint diff --git a/test/rules/completed-docs/defaults/edge-case/test.ts.lint b/test/rules/completed-docs/defaults/edge-case/test.ts.lint new file mode 100644 index 00000000000..e69de29bb2d From f03e33b03025eb6e12c295acb97fcd82396486b8 Mon Sep 17 00:00:00 2001 From: Jay Bhagat Date: Tue, 19 Nov 2019 09:43:33 -0500 Subject: [PATCH 2/7] rule written --- .../completed-docs/defaults/edge-case/tslint.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/rules/completed-docs/defaults/edge-case/tslint.json diff --git a/test/rules/completed-docs/defaults/edge-case/tslint.json b/test/rules/completed-docs/defaults/edge-case/tslint.json new file mode 100644 index 00000000000..ca96ba6b633 --- /dev/null +++ b/test/rules/completed-docs/defaults/edge-case/tslint.json @@ -0,0 +1,13 @@ +{ + "rules": { + "completed-docs": [ + true, + { + "variables": { + "visibilities": ["exported"], + "tags": { "existence": [""] } + } + } + ] + } + } \ No newline at end of file From 95525bcf5fa9b89d5e6cf91360af08c2278b8481 Mon Sep 17 00:00:00 2001 From: Jay Bhagat Date: Tue, 19 Nov 2019 09:45:38 -0500 Subject: [PATCH 3/7] rule replicated --- .../defaults/edge-case/test.ts.lint | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/rules/completed-docs/defaults/edge-case/test.ts.lint b/test/rules/completed-docs/defaults/edge-case/test.ts.lint index e69de29bb2d..011989a4537 100644 --- a/test/rules/completed-docs/defaults/edge-case/test.ts.lint +++ b/test/rules/completed-docs/defaults/edge-case/test.ts.lint @@ -0,0 +1,30 @@ +export class Aaa { +~~~~~~~~~~~~~~~~~~ [Documentation must exist for exported classes.] + public bbb; + ~~~~~~~~~~~ [Documentation must exist for public properties.] + + public ccc() { } + ~~~~~~~~~~~~~~~~ [Documentation must exist for public methods.] + + public get prop() { return this.bbb; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for public properties.] + + public set prop(value) { this.bbb = value; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for public properties.] + + [Symbol.iterator]() {} + ~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.] +} + +export enum Ddd { } + +export function Eee() { } +~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for exported functions.] + +export interface Fff { } + +export namespace Ggg { } + +export type Hhh = any; + +export const i = true; From d01ff7f0a91dc02188aad6f55d097feef802db4e Mon Sep 17 00:00:00 2001 From: Jay Bhagat Date: Tue, 19 Nov 2019 10:59:25 -0500 Subject: [PATCH 4/7] isolated rule --- .../_integration/enable-disable/test.ts.lint | 146 --- .../_integration/enable-disable/test.tsx.lint | 69 -- .../_integration/enable-disable/tslint.json | 11 - .../_integration/error-format/test.ts.lint | 37 - .../_integration/error-format/tslint.json | 5 - .../rules/_integration/react/invalid.tsx.lint | 6 - test/rules/_integration/react/test.tsx.lint | 58 -- test/rules/_integration/react/tslint.json | 21 - .../typescript-version/correct.js.lint | 3 - .../typescript-version/correct.ts.fix | 1 - .../typescript-version/correct.ts.lint | 3 - .../typescript-version/if-else.ts.lint | 21 - .../typescript-version/skip.js.lint | 2 - .../typescript-version/skip.ts.lint | 2 - .../typescript-version/substitution.ts.lint | 4 - .../typescript-version/tslint.json | 8 - .../default/test.ts.lint | 166 ---- .../default/tslint.json | 5 - .../ignore-accessors/test.ts.lint | 11 - .../ignore-accessors/tslint.json | 5 - test/rules/align/arguments/test.ts.fix | 149 --- test/rules/align/arguments/test.ts.lint | 152 --- test/rules/align/arguments/tslint.json | 5 - test/rules/align/elements/test.ts.fix | 47 - test/rules/align/elements/test.ts.lint | 53 - test/rules/align/elements/tslint.json | 5 - test/rules/align/members/test.ts.fix | 40 - test/rules/align/members/test.ts.lint | 53 - test/rules/align/members/tslint.json | 5 - test/rules/align/parameters/test.ts.fix | 32 - test/rules/align/parameters/test.ts.lint | 39 - test/rules/align/parameters/tslint.json | 5 - test/rules/align/statements/bom.ts.fix | 3 - test/rules/align/statements/bom.ts.lint | 4 - test/rules/align/statements/test.ts.fix | 157 --- test/rules/align/statements/test.ts.lint | 159 --- test/rules/align/statements/tslint.json | 5 - .../rules/array-type/array-simple/test.ts.fix | 65 -- .../array-type/array-simple/test.ts.lint | 86 -- .../rules/array-type/array-simple/tslint.json | 5 - test/rules/array-type/array/test.ts.fix | 50 - test/rules/array-type/array/test.ts.lint | 65 -- test/rules/array-type/array/tslint.json | 5 - test/rules/array-type/generic/test.ts.fix | 50 - test/rules/array-type/generic/test.ts.lint | 65 -- test/rules/array-type/generic/tslint.json | 5 - .../ban-single-arg-parens/test.ts.fix | 51 - .../ban-single-arg-parens/test.ts.lint | 70 -- .../ban-single-arg-parens/tslint.json | 8 - test/rules/arrow-parens/default/test.ts.fix | 27 - test/rules/arrow-parens/default/test.ts.lint | 29 - test/rules/arrow-parens/default/tslint.json | 5 - .../default/test.ts.fix | 21 - .../default/test.ts.lint | 31 - .../default/tslint.json | 5 - .../multiline/test.ts.fix | 20 - .../multiline/test.ts.lint | 34 - .../multiline/tslint.json | 5 - .../await-promise/custom-promise/test.ts.lint | 78 -- .../custom-promise/tsconfig.json | 5 - .../await-promise/custom-promise/tslint.json | 8 - .../await-promise/es6-promise/test.ts.lint | 58 -- .../await-promise/es6-promise/tsconfig.json | 5 - .../await-promise/es6-promise/tslint.json | 5 - .../await-promise/for-await-of/test.ts.lint | 51 - .../await-promise/for-await-of/tsconfig.json | 5 - .../await-promise/for-await-of/tslint.json | 5 - test/rules/ban-comma-operator/test.ts.lint | 23 - test/rules/ban-comma-operator/tslint.json | 5 - test/rules/ban-ts-ignore/test.ts.lint | 33 - test/rules/ban-ts-ignore/tslint.json | 6 - test/rules/ban-types/test.ts.lint | 20 - test/rules/ban-types/tslint.json | 10 - test/rules/ban/test.ts.lint | 41 - test/rules/ban/tslint.json | 17 - .../test.ts.lint | 45 - .../tslint.json | 5 - test/rules/callable-types/test.ts.fix | 34 - test/rules/callable-types/test.ts.lint | 74 -- test/rules/callable-types/tslint.json | 5 - test/rules/class-name/test.ts.lint | 26 - test/rules/class-name/tslint.json | 5 - .../allow-trailing-lowercase/test.ts.fix | 15 - .../allow-trailing-lowercase/test.ts.lint | 20 - .../allow-trailing-lowercase/tslint.json | 5 - .../exceptions-pattern/test.ts.fix | 30 - .../exceptions-pattern/test.ts.lint | 39 - .../exceptions-pattern/tslint.json | 5 - .../exceptions-words/test.ts.fix | 29 - .../exceptions-words/test.ts.lint | 39 - .../exceptions-words/tslint.json | 5 - test/rules/comment-format/lower/test.ts.fix | 20 - test/rules/comment-format/lower/test.ts.lint | 27 - test/rules/comment-format/lower/test.tsx.fix | 9 - test/rules/comment-format/lower/test.tsx.lint | 12 - test/rules/comment-format/lower/tslint.json | 5 - test/rules/comment-format/upper/test.ts.fix | 27 - test/rules/comment-format/upper/test.ts.lint | 37 - test/rules/comment-format/upper/tslint.json | 5 - test/rules/comment-type/combo/test.ts.lint | 25 - test/rules/comment-type/combo/tslint.json | 5 - .../comment-type/directive/test.ts.tslint | 29 - test/rules/comment-type/directive/tslint.json | 5 - test/rules/comment-type/doc/test.ts.lint | 27 - test/rules/comment-type/doc/tslint.json | 5 - .../rules/comment-type/multiline/test.ts.lint | 25 - test/rules/comment-type/multiline/tslint.json | 5 - .../comment-type/single-line/test.ts.lint | 29 - .../comment-type/single-line/tslint.json | 5 - .../defaults/edge-case/test.ts.lint | 35 +- test/rules/curly/as-needed/test.ts.lint | 53 - test/rules/curly/as-needed/tslint.json | 5 - test/rules/curly/defaults/test.ts.fix | 103 -- test/rules/curly/defaults/test.ts.lint | 123 --- test/rules/curly/defaults/tslint.json | 5 - test/rules/curly/ignore-same-line/test.ts.fix | 93 -- .../rules/curly/ignore-same-line/test.ts.lint | 101 -- test/rules/curly/ignore-same-line/tslint.json | 5 - .../defaultThreshold/test.ts.lint | 68 -- .../defaultThreshold/tslint.json | 5 - .../invalidThreshold/test.ts.lint | 25 - .../invalidThreshold/tslint.json | 5 - .../specifiedThreshold/test.ts.lint | 383 -------- .../specifiedThreshold/tslint.json | 5 - test/rules/deprecation/other.test.ts | 34 - test/rules/deprecation/other2.test.ts | 3 - test/rules/deprecation/test.ts.lint | 174 ---- test/rules/deprecation/tsconfig.json | 5 - test/rules/deprecation/tslint.json | 5 - test/rules/encoding/tslint.json | 5 - test/rules/encoding/utf16be.ts.lint | Bin 138 -> 0 bytes test/rules/encoding/utf16le.ts.lint | Bin 144 -> 0 bytes test/rules/encoding/utf8-bom.ts.lint | 2 - test/rules/encoding/utf8.ts.lint | 0 test/rules/eofline/comment.ts.lint | 3 - test/rules/eofline/disabled.ts.lint | 2 - test/rules/eofline/empty.ts.lint | 0 test/rules/eofline/invalid.ts.fix | 1 - test/rules/eofline/invalid.ts.lint | 2 - test/rules/eofline/only-whitespace.ts.fix | 2 - test/rules/eofline/only-whitespace.ts.lint | 3 - test/rules/eofline/tslint.json | 5 - test/rules/eofline/valid.ts.lint | 1 - test/rules/eofline/whitespace.ts.lint | 2 - .../rules/file-header/bad-newline/test.ts.fix | 11 - .../file-header/bad-newline/test.ts.lint | 11 - .../rules/file-header/bad-newline/tslint.json | 5 - .../rules/file-header/bad-shebang/test.ts.fix | 21 - .../file-header/bad-shebang/test.ts.lint | 18 - .../rules/file-header/bad-shebang/tslint.json | 5 - .../file-header/bad-single-line/test.ts.fix | 17 - .../file-header/bad-single-line/test.ts.lint | 14 - .../file-header/bad-single-line/tslint.json | 5 - .../bad-single-newline/test.ts.fix | 12 - .../bad-single-newline/test.ts.lint | 9 - .../bad-single-newline/tslint.json | 5 - .../file-header/bad-use-strict/test.ts.fix | 21 - .../file-header/bad-use-strict/test.ts.lint | 18 - .../file-header/bad-use-strict/tslint.json | 5 - test/rules/file-header/bad/test.ts.fix | 19 - test/rules/file-header/bad/test.ts.lint | 16 - test/rules/file-header/bad/test2.ts.fix | 7 - test/rules/file-header/bad/test2.ts.lint | 4 - test/rules/file-header/bad/tslint.json | 5 - .../rules/file-header/empty-file/test.ts.lint | 2 - test/rules/file-header/empty-file/tslint.json | 5 - .../test.ts.lint | 4 - .../tslint.json | 8 - .../file-header/good-newline/test.ts.lint | 3 - .../file-header/good-newline/tslint.json | 10 - .../file-header/good-shebang/test.ts.lint | 14 - .../file-header/good-shebang/tslint.json | 5 - .../file-header/good-single-line/test.ts.lint | 9 - .../file-header/good-single-line/tslint.json | 5 - .../file-header/good-use-strict/test.ts.lint | 13 - .../file-header/good-use-strict/tslint.json | 5 - test/rules/file-header/good/test.ts.fix | 12 - test/rules/file-header/good/test.ts.lint | 12 - test/rules/file-header/good/tslint.json | 5 - .../camel-case/camelCase.ts.lint | 0 .../camel-case/no-camel-case.ts.lint | 2 - .../file-name-casing/camel-case/tslint.json | 5 - .../complex/ComponentName.tsx.lint | 0 .../complex/InvalidNonComponentName.ts.lint | 2 - .../complex/invalid-component-name.tsx.lint | 2 - .../complex/my-button.component.ts.lint | 2 - .../complex/nonComponentName.ts.lint | 0 .../file-name-casing/complex/tslint.json | 9 - .../file-matcher/PascalCase.ts.lint | 0 .../file-matcher/camelCase.ts.lint | 0 .../file-matcher/notPascalCase.ts.lint | 2 - .../file-matcher/not_camel_case.ts.lint | 2 - .../file-matcher/not_kebab_case.tsx.lint | 2 - .../file-name-casing/file-matcher/tslint.json | 13 - .../ignore/complaint.tsx.lint | 2 - .../file-name-casing/ignore/file.ts.lint | 0 .../rules/file-name-casing/ignore/tslint.json | 8 - .../invalid-option/snake_case.ts.lint | 0 .../invalid-option/tslint.json | 5 - .../kebab-case/kebab-case.ts.lint | 0 .../kebab-case/noKebabCase.ts.lint | 2 - .../file-name-casing/kebab-case/tslint.json | 5 - .../pascal-case/PascalCase.ts.lint | 0 .../pascal-case/no-pascal-case.ts.lint | 2 - .../file-name-casing/pascal-case/tslint.json | 5 - .../snake-case/no-snake-case.ts.lint | 2 - .../snake-case/snake_case.ts.lint | 0 .../file-name-casing/snake-case/tslint.json | 5 - test/rules/forin/test.ts.lint | 41 - test/rules/forin/tslint.json | 5 - test/rules/function-constructor/test.ts.lint | 19 - test/rules/function-constructor/tslint.json | 5 - test/rules/import-blacklist/test.ts.lint | 55 -- test/rules/import-blacklist/tslint.json | 5 - test/rules/import-spacing/test.ts.lint | 157 --- test/rules/import-spacing/tslint.json | 5 - .../allow-post/test.ts.fix | 20 - .../allow-post/test.ts.lint | 26 - .../allow-post/tslint.json | 5 - .../increment-decrement/default/test.ts.fix | 29 - .../increment-decrement/default/test.ts.lint | 45 - .../increment-decrement/default/tslint.json | 5 - test/rules/indent/spaces-2/test.ts.fix | 139 --- test/rules/indent/spaces-2/test.ts.lint | 162 ---- test/rules/indent/spaces-2/test.tsx.lint | 17 - test/rules/indent/spaces-2/tslint.json | 5 - test/rules/indent/spaces-4/test.ts.fix | 139 --- test/rules/indent/spaces-4/test.ts.lint | 162 ---- test/rules/indent/spaces-4/tslint.json | 5 - test/rules/indent/tabs-2/test.ts.fix | 141 --- test/rules/indent/tabs-2/test.ts.lint | 164 ---- test/rules/indent/tabs-2/tslint.json | 5 - test/rules/indent/tabs-4/test.ts.fix | 141 --- test/rules/indent/tabs-4/test.ts.lint | 164 ---- test/rules/indent/tabs-4/tslint.json | 5 - .../interface-name/always-prefix/test.ts.lint | 34 - .../interface-name/always-prefix/tslint.json | 5 - .../rules/interface-name/default/test.ts.lint | 7 - test/rules/interface-name/default/tslint.json | 5 - .../interface-name/never-prefix/test.ts.lint | 35 - .../interface-name/never-prefix/tslint.json | 5 - .../interface-over-type-literal/test.ts.fix | 10 - .../interface-over-type-literal/test.ts.lint | 14 - .../interface-over-type-literal/tslint.json | 5 - .../allow-generics/false/test.ts.lint | 16 - .../allow-generics/false/tslint.json | 7 - .../allow-generics/true/test.ts.lint | 11 - .../allow-generics/true/tslint.json | 7 - .../allow-generics/whitelist/test.ts.lint | 12 - .../allow-generics/whitelist/tslint.json | 7 - test/rules/invalid-void/default/test.ts.lint | 127 --- test/rules/invalid-void/default/tslint.json | 5 - .../check-multiline-start/test.ts.lint | 10 - .../check-multiline-start/tslint.json | 5 - .../jsdoc-format/default/jsdoc-bom.ts.lint | 3 - .../default/jsdoc-windows.ts.lint | 24 - test/rules/jsdoc-format/default/jsdoc.ts.lint | 88 -- test/rules/jsdoc-format/default/tslint.json | 5 - test/rules/label-position/test.ts.lint | 38 - test/rules/label-position/tslint.json | 5 - .../linebreak-style/emptyFile/test.ts.lint | 0 .../linebreak-style/emptyFile/tslint.json | 5 - .../linebreak-style/failure/CRLF/test.ts.fix | 4 - .../linebreak-style/failure/CRLF/test.ts.lint | 8 - .../linebreak-style/failure/CRLF/tslint.json | 5 - .../linebreak-style/failure/LF/test.ts.fix | 4 - .../linebreak-style/failure/LF/test.ts.lint | 8 - .../linebreak-style/failure/LF/tslint.json | 5 - .../linebreak-style/success/CRLF/test.ts.lint | 4 - .../linebreak-style/success/CRLF/tslint.json | 5 - .../linebreak-style/success/LF/test.ts.lint | 4 - .../linebreak-style/success/LF/tslint.json | 5 - .../anonymous.test.ts | 1 - .../match-default-export-name/named.test.ts | 1 - .../match-default-export-name/test.ts.lint | 3 - .../match-default-export-name/tsconfig.json | 5 - .../match-default-export-name/tslint.json | 5 - .../max-classes-per-file/one/test.ts.lint | 35 - .../max-classes-per-file/one/tslint.json | 5 - .../max-classes-per-file/two/test.ts.lint | 23 - .../max-classes-per-file/two/tslint.json | 5 - .../max-file-line-count/default/test.ts.lint | 23 - .../max-file-line-count/default/tslint.json | 5 - .../max-file-line-count/disabled/test.ts.lint | 24 - .../max-file-line-count/disabled/tslint.json | 5 - .../check-strings-and-regex/test.ts.lint | 33 - .../check-strings-and-regex/tslint.json | 10 - .../max-line-length/default/test.ts.lint | 25 - .../rules/max-line-length/default/tslint.json | 7 - test/rules/member-access/accessor/test.ts.fix | 17 - .../rules/member-access/accessor/test.ts.lint | 19 - test/rules/member-access/accessor/tslint.json | 5 - .../member-access/constructor/test.ts.fix | 10 - .../member-access/constructor/test.ts.lint | 13 - .../member-access/constructor/tslint.json | 5 - test/rules/member-access/default/test.ts.fix | 54 -- test/rules/member-access/default/test.ts.lint | 67 -- test/rules/member-access/default/tslint.json | 5 - .../rules/member-access/no-public/test.ts.fix | 12 - .../member-access/no-public/test.ts.lint | 19 - .../rules/member-access/no-public/tslint.json | 5 - .../parameter-property/test.ts.fix | 17 - .../parameter-property/test.ts.lint | 20 - .../parameter-property/tslint.json | 5 - .../alphabetize-nested/test.ts.fix | 14 - .../alphabetize-nested/test.ts.lint | 17 - .../alphabetize-nested/tslint.json | 8 - .../member-ordering/alphabetize/test.ts.fix | 32 - .../member-ordering/alphabetize/test.ts.lint | 38 - .../member-ordering/alphabetize/tslint.json | 8 - .../custom-categories/test.ts.fix | 9 - .../custom-categories/test.ts.lint | 10 - .../custom-categories/tslint.json | 18 - test/rules/member-ordering/custom/test.ts.fix | 35 - .../rules/member-ordering/custom/test.ts.lint | 36 - test/rules/member-ordering/custom/tslint.json | 8 - .../member-ordering/fields-first/test.ts.fix | 37 - .../member-ordering/fields-first/test.ts.lint | 39 - .../member-ordering/fields-first/tslint.json | 5 - .../member-ordering/fix-trivia/test.ts.fix | 23 - .../member-ordering/fix-trivia/test.ts.lint | 26 - .../member-ordering/fix-trivia/tslint.json | 8 - .../instance-sandwich/test.ts.fix | 37 - .../instance-sandwich/test.ts.lint | 40 - .../instance-sandwich/tslint.json | 5 - .../mix-old-options/test.ts.fix | 15 - .../mix-old-options/test.ts.lint | 16 - .../mix-old-options/tslint.json | 9 - .../omit-access-modifier/test.ts.fix | 11 - .../omit-access-modifier/test.ts.lint | 12 - .../omit-access-modifier/tslint.json | 9 - .../public-before-private/test.ts.fix | 8 - .../public-before-private/test.ts.lint | 10 - .../public-before-private/tslint.json | 5 - .../static-before-instance/test.ts.fix | 8 - .../static-before-instance/test.ts.lint | 10 - .../static-before-instance/tslint.json | 5 - .../member-ordering/statics-first/test.ts.fix | 37 - .../statics-first/test.ts.lint | 41 - .../member-ordering/statics-first/tslint.json | 5 - .../variables-before-functions/test.ts.fix | 63 -- .../variables-before-functions/test.ts.lint | 71 -- .../variables-before-functions/tslint.json | 5 - test/rules/new-parens/test.ts.lint | 14 - test/rules/new-parens/tslint.json | 5 - .../newline-before-return/default/test.ts.fix | 126 --- .../default/test.ts.lint | 124 --- .../default/test.tsx.fix | 17 - .../default/test.tsx.lint | 18 - .../newline-before-return/default/tslint.json | 5 - .../default/test.ts.lint | 120 --- .../default/tslint.json | 5 - .../test.ts.fix | 52 - .../test.ts.lint | 73 -- .../tslint.json | 5 - test/rules/no-any/default/test.ts.lint | 34 - test/rules/no-any/default/tslint.json | 5 - .../no-any/ignore-rest-args/test.ts.lint | 38 - .../rules/no-any/ignore-rest-args/tslint.json | 5 - test/rules/no-arg/test.ts.lint | 12 - test/rules/no-arg/tslint.json | 5 - .../rules/no-async-without-await/test.ts.lint | 165 ---- test/rules/no-async-without-await/tslint.json | 5 - test/rules/no-bitwise/test.ts.lint | 6 - test/rules/no-bitwise/tslint.json | 5 - .../no-boolean-literal-compare/test.ts.fix | 30 - .../no-boolean-literal-compare/test.ts.lint | 45 - .../no-boolean-literal-compare/tsconfig.json | 5 - .../no-boolean-literal-compare/tslint.json | 5 - .../no-conditional-assignment/test.ts.lint | 79 -- .../no-conditional-assignment/tslint.json | 5 - .../default/test.ts.fix | 27 - .../default/test.ts.lint | 42 - .../default/tslint.json | 5 - .../invalid-option/test.ts.lint | 30 - .../invalid-option/tslint.json | 5 - .../multiple/test.ts.fix | 28 - .../multiple/test.ts.lint | 40 - .../multiple/tslint.json | 5 - test/rules/no-console/all/test.ts.lint | 22 - test/rules/no-console/all/tslint.json | 5 - test/rules/no-console/list/test.ts.lint | 13 - test/rules/no-console/list/tslint.json | 5 - test/rules/no-construct/test.ts.lint | 13 - test/rules/no-construct/tslint.json | 5 - test/rules/no-debugger/test.ts.lint | 8 - test/rules/no-debugger/tslint.json | 5 - test/rules/no-default-export/test.ts.lint | 46 - test/rules/no-default-export/tslint.json | 5 - .../no-default-import/default/test.ts.lint | 36 - .../no-default-import/default/tslint.json | 5 - .../fromModules/test.ts.lint | 24 - .../no-default-import/fromModules/tslint.json | 10 - .../allow-namespace-imports/test.d.ts.lint | 6 - .../allow-namespace-imports/test.ts.lint | 14 - .../allow-namespace-imports/tslint.json | 10 - .../default/test.d.ts.lint | 7 - .../no-duplicate-imports/default/test.ts.lint | 20 - .../default/test2.d.ts.lint | 8 - .../default/test3.d.ts.lint | 11 - .../no-duplicate-imports/default/tslint.json | 5 - test/rules/no-duplicate-super/test.ts.lint | 280 ------ test/rules/no-duplicate-super/tslint.json | 5 - .../no-duplicate-switch-case/test.ts.lint | 82 -- .../no-duplicate-switch-case/tslint.json | 5 - .../check-parameters/test.ts.lint | 180 ---- .../check-parameters/tslint.json | 5 - .../default/test.ts.lint | 177 ---- .../no-duplicate-variable/default/tslint.json | 5 - test/rules/no-dynamic-delete/test.ts.fix | 19 - test/rules/no-dynamic-delete/test.ts.lint | 29 - test/rules/no-dynamic-delete/tslint.json | 5 - test/rules/no-empty-interface/test.ts.lint | 14 - test/rules/no-empty-interface/tslint.json | 5 - .../no-empty/allow-empty-catch/test.ts.lint | 86 -- .../no-empty/allow-empty-catch/tslint.json | 5 - .../allow-empty-functions/test.ts.lint | 81 -- .../allow-empty-functions/tslint.json | 5 - test/rules/no-empty/default/test.ts.lint | 87 -- test/rules/no-empty/default/tslint.json | 5 - test/rules/no-eval/test.ts.lint | 10 - test/rules/no-eval/tslint.json | 5 - .../jquerypromise/test.ts.lint | 17 - .../jquerypromise/tsconfig.json | 5 - .../jquerypromise/tslint.json | 5 - .../promises/test.ts.lint | 161 --- .../promises/tsconfig.json | 5 - .../no-floating-promises/promises/tslint.json | 5 - test/rules/no-for-in-array/test.ts.lint | 45 - test/rules/no-for-in-array/tsconfig.json | 5 - test/rules/no-for-in-array/tslint.json | 5 - test/rules/no-for-in/test.ts.lint | 20 - test/rules/no-for-in/tslint.json | 5 - .../default/bom/package.json | 5 - .../default/bom/test.ts.lint | 2 - .../default/builtin-only.ts.lint | 4 - .../default/malformed/package.json | 3 - .../default/malformed/tets.ts.lint | 2 - .../default/nested-package/package.json | 7 - .../default/nested-package/test.ts.lint | 24 - .../default/subdir/test.ts.lint | 26 - .../default/test.js.lint | 10 - .../default/test.ts.lint | 24 - .../default/tslint.json | 8 - .../no-implicit-dependencies/dev/test.ts.lint | 14 - .../no-implicit-dependencies/dev/tslint.json | 5 - .../optional/test.ts.lint | 13 - .../optional/tslint.json | 5 - .../no-implicit-dependencies/package.json | 19 - .../whitelist-with-dev/test.ts.lint | 10 - .../whitelist-with-dev/tslint.json | 5 - .../whitelist/test.ts.lint | 20 - .../whitelist/tslint.json | 5 - .../default/test.ts.lint | 22 - .../no-import-side-effect/default/tslint.json | 5 - .../ignore-module/test.ts.lint | 18 - .../ignore-module/tslint.json | 10 - .../no-inferrable-types/default/test.ts.fix | 35 - .../no-inferrable-types/default/test.ts.lint | 51 - .../no-inferrable-types/default/tslint.json | 5 - .../ignore-params/test.ts.fix | 34 - .../ignore-params/test.ts.lint | 43 - .../ignore-params/tslint.json | 8 - .../ignore-properties/test.ts.fix | 33 - .../ignore-properties/test.ts.lint | 42 - .../ignore-properties/tslint.json | 5 - .../test.ts.lint | 92 -- .../tsconfig.json | 5 - .../no-inferred-empty-object-type/tslint.json | 5 - test/rules/no-internal-module/test.ts.fix | 62 -- test/rules/no-internal-module/test.ts.lint | 76 -- test/rules/no-internal-module/tslint.json | 5 - .../no-invalid-template-strings/test.ts.lint | 41 - .../no-invalid-template-strings/tslint.json | 5 - .../no-invalid-this/enabled/test.ts.lint | 118 --- .../rules/no-invalid-this/enabled/tslint.json | 8 - .../no-irregular-whitespace/test.builder.ts | 41 - .../rules/no-irregular-whitespace/test.ts.fix | 22 - .../no-irregular-whitespace/test.ts.lint | 44 - .../rules/no-irregular-whitespace/tslint.json | 5 - .../allowed-numbers/test.ts.lint | 23 - .../allowed-numbers/tslint.json | 7 - .../no-magic-numbers/custom/test.ts.lint | 23 - .../rules/no-magic-numbers/custom/tslint.json | 5 - .../default-jsx/test.tsx.lint | 8 - .../no-magic-numbers/default-jsx/tslint.json | 5 - .../no-magic-numbers/default/test.ts.lint | 48 - .../no-magic-numbers/default/tslint.json | 5 - .../no-magic-numbers/ignore-jsx/test.tsx.lint | 10 - .../no-magic-numbers/ignore-jsx/tslint.json | 7 - .../rules/no-mergeable-namespace/test.ts.lint | 41 - test/rules/no-mergeable-namespace/tslint.json | 5 - test/rules/no-misused-new/test.ts.lint | 32 - test/rules/no-misused-new/tslint.json | 5 - .../allow-declarations/test.d.ts.lint | 1 - .../allow-declarations/test.ts.lint | 8 - .../allow-declarations/tslint.json | 5 - .../rules/no-namespace/default/test.d.ts.lint | 2 - test/rules/no-namespace/default/test.ts.lint | 25 - test/rules/no-namespace/default/tslint.json | 5 - test/rules/no-non-null-assertion/test.ts.lint | 4 - test/rules/no-non-null-assertion/tslint.json | 5 - test/rules/no-null-keyword/test.ts.fix | 12 - test/rules/no-null-keyword/test.ts.lint | 18 - test/rules/no-null-keyword/tslint.json | 5 - .../no-null-undefined-union/test.ts.lint | 85 -- .../no-null-undefined-union/ts350.ts.lint | 12 - .../no-null-undefined-union/tsconfig.json | 19 - .../rules/no-null-undefined-union/tslint.json | 5 - .../allow-arguments/test.ts.lint | 23 - .../allow-arguments/tslint.json | 5 - .../default/test.ts.lint | 31 - .../default/tslint.json | 5 - .../no-parameter-properties/test.ts.lint | 24 - .../rules/no-parameter-properties/tslint.json | 5 - .../no-parameter-reassignment/test.ts.lint | 34 - .../no-parameter-reassignment/tslint.json | 5 - .../custom-promise/test.ts.lint | 37 - .../custom-promise/tsconfig.json | 6 - .../custom-promise/tslint.json | 5 - .../es6-promise/test.ts.lint | 66 -- .../es6-promise/tsconfig.json | 6 - .../es6-promise/tslint.json | 5 - test/rules/no-redundant-jsdoc/test.ts.lint | 59 -- test/rules/no-redundant-jsdoc/tslint.json | 5 - test/rules/no-reference-import/test.d.ts.lint | 12 - .../rules/no-reference-import/ts240.d.ts.lint | 12 - test/rules/no-reference-import/tslint.json | 5 - test/rules/no-reference/test.ts.lint | 3 - test/rules/no-reference/ts240.ts.lint | 3 - test/rules/no-reference/tslint.json | 5 - test/rules/no-require-imports/test.ts.lint | 24 - test/rules/no-require-imports/tslint.json | 5 - .../no-restricted-globals/custom-global.d.ts | 2 - test/rules/no-restricted-globals/foo.d.ts | 1 - .../no-restricted-globals/namespace.ts.lint | 10 - test/rules/no-restricted-globals/test.ts.lint | 75 -- .../rules/no-restricted-globals/tsconfig.json | 8 - test/rules/no-restricted-globals/tslint.json | 11 - test/rules/no-return-await/test.ts.fix | 80 -- test/rules/no-return-await/test.ts.lint | 94 -- test/rules/no-return-await/tslint.json | 5 - .../default/ambient.d.ts.lint | 7 - .../no-shadowed-variable/default/test.ts.lint | 384 -------- .../no-shadowed-variable/default/tslint.json | 5 - .../ignore-class/test.ts.lint | 16 - .../ignore-class/tslint.json | 5 - .../ignore-import/test.ts.lint | 13 - .../ignore-import/tslint.json | 5 - .../ignore-underscore/test.ts.lint | 10 - .../ignore-underscore/tslint.json | 5 - .../temporal-dead-zone/test.ts.lint | 89 -- .../temporal-dead-zone/tslint.json | 10 - test/rules/no-sparse-arrays/test.ts.lint | 24 - test/rules/no-sparse-arrays/tslint.json | 5 - test/rules/no-string-literal/test.ts.fix | 29 - test/rules/no-string-literal/test.ts.lint | 36 - test/rules/no-string-literal/tslint.json | 5 - test/rules/no-string-throw/test.ts.fix | 30 - test/rules/no-string-throw/test.ts.lint | 42 - test/rules/no-string-throw/tslint.json | 5 - .../dynamic-imports/test.ts.lint | 28 - .../dynamic-imports/tslint.json | 5 - .../static-imports/test.ts.lint | 73 -- .../static-imports/tslint.json | 5 - .../no-switch-case-fall-through/test.ts.lint | 144 --- .../no-switch-case-fall-through/tslint.json | 5 - .../no-tautology-expression/test.ts.lint | 159 --- .../rules/no-tautology-expression/tslint.json | 5 - .../allow-destructuring/test.ts.lint | 13 - .../allow-destructuring/tslint.json | 7 - .../allowed-names/test.ts.lint | 8 - .../allowed-names/tslint.json | 7 - .../no-this-assignment/default/test.ts.lint | 46 - .../no-this-assignment/default/tslint.json | 5 - .../default/test.ts.fix | 33 - .../default/test.ts.lint | 49 - .../default/tslint.json | 5 - .../ignore-comments/test.ts.fix | 30 - .../ignore-comments/test.ts.lint | 38 - .../ignore-comments/tslint.json | 5 - .../ignore-jsdoc/test.ts.fix | 30 - .../ignore-jsdoc/test.ts.lint | 42 - .../ignore-jsdoc/tslint.json | 5 - .../ignore-template-strings/test.ts.fix | 33 - .../ignore-template-strings/test.ts.lint | 47 - .../ignore-template-strings/tslint.json | 8 - .../skip-blank-lines/test.ts.fix | 34 - .../skip-blank-lines/test.ts.lint | 46 - .../skip-blank-lines/tslint.json | 5 - .../zero-width-no-break-space/test.ts.lint | 4 - .../zero-width-no-break-space/test2.ts.lint | 5 - .../zero-width-no-break-space/tslint.json | 5 - .../no-unbound-method/default/test.ts.lint | 14 - .../no-unbound-method/default/test.tsx.lint | 68 -- .../no-unbound-method/default/tsconfig.json | 5 - .../no-unbound-method/default/tslint.json | 5 - .../ignore-static/test.tsx.lint | 46 - .../ignore-static/tsconfig.json | 5 - .../ignore-static/tslint.json | 8 - .../no-unbound-method/whitelist/test.tsx.lint | 80 -- .../no-unbound-method/whitelist/tsconfig.json | 5 - .../no-unbound-method/whitelist/tslint.json | 8 - .../test.ts.fix | 27 - .../test.ts.lint | 32 - .../tslint.json | 5 - .../allow-constructor-only/test.ts.lint | 156 --- .../allow-constructor-only/tslint.json | 5 - .../allow-empty/test.ts.lint | 151 --- .../allow-empty/tslint.json | 5 - .../allow-static-only/test.ts.lint | 136 --- .../allow-static-only/tslint.json | 5 - .../no-unnecessary-class/default/test.ts.lint | 146 --- .../no-unnecessary-class/default/tslint.json | 5 - .../no-unnecessary-initializer/test.ts.fix | 18 - .../no-unnecessary-initializer/test.ts.lint | 28 - .../no-unnecessary-initializer/tslint.json | 5 - .../arguments.ts.lint | 12 - test/rules/no-unnecessary-qualifier/b.test.ts | 1 - .../test-global-2.ts.lint | 4 - .../test-global.ts.fix | 5 - .../test-global.ts.lint | 6 - .../no-unnecessary-qualifier/test.ts.fix | 41 - .../no-unnecessary-qualifier/test.ts.lint | 54 -- .../no-unnecessary-qualifier/tsconfig.json | 5 - .../no-unnecessary-qualifier/tslint.json | 5 - .../noStrictNullChecks/test.ts.lint | 6 - .../noStrictNullChecks/tsconfig.json | 1 - .../noStrictNullChecks/tslint.json | 5 - .../strict/test.ts.fix | 104 -- .../strict/test.ts.lint | 125 --- .../strict/tsconfig.json | 6 - .../strict/tslint.json | 5 - .../strictNullChecks/test.ts.fix | 104 -- .../strictNullChecks/test.ts.lint | 124 --- .../strictNullChecks/tsconfig.json | 6 - .../strictNullChecks/tslint.json | 5 - .../no-unsafe-any/default/commonjsModule.ts | 3 - test/rules/no-unsafe-any/default/es6Module.ts | 8 - test/rules/no-unsafe-any/default/test.ts.lint | 348 ------- .../rules/no-unsafe-any/default/tsconfig.json | 7 - test/rules/no-unsafe-any/default/tslint.json | 5 - test/rules/no-unsafe-any/jsx/test.tsx.lint | 15 - test/rules/no-unsafe-any/jsx/tsconfig.json | 8 - test/rules/no-unsafe-any/jsx/tslint.json | 5 - test/rules/no-unsafe-any/unknown/test.ts.lint | 83 -- .../rules/no-unsafe-any/unknown/tsconfig.json | 7 - test/rules/no-unsafe-any/unknown/tslint.json | 5 - test/rules/no-unsafe-finally/test.ts.lint | 376 -------- test/rules/no-unsafe-finally/tslint.json | 5 - .../allow-fast-null-checks/test.ts.lint | 143 --- .../allow-fast-null-checks/tslint.json | 5 - .../allow-new/test.ts.lint | 145 --- .../allow-new/tslint.json | 9 - .../allow-tagged-template/test.ts.lint | 194 ---- .../allow-tagged-template/tslint.json | 8 - .../no-unused-expression/default/test.ts.lint | 226 ----- .../no-unused-expression/default/tslint.json | 5 - .../check-parameters/test.ts.lint | 88 -- .../check-parameters/tsconfig.json | 5 - .../check-parameters/tslint.json | 5 - .../no-unused-variable/default/class.ts.lint | 31 - .../default/false-positives.ts.lint | 69 -- .../default/function.ts.lint | 39 - .../no-unused-variable/default/import.ts.fix | 53 - .../no-unused-variable/default/import.ts.lint | 91 -- .../default/node_modules/a.ts | 2 - .../default/node_modules/react.ts | 1 - .../default/node_modules/react/addons.ts | 1 - .../default/react-addons1.tsx.lint | 5 - .../default/react-addons2.tsx.lint | 4 - .../default/react-addons3.tsx.lint | 7 - .../default/react1.tsx.lint | 5 - .../default/react2.tsx.lint | 4 - .../default/react3.tsx.lint | 7 - .../default/react4.tsx.lint | 7 - .../no-unused-variable/default/tsconfig.json | 5 - .../no-unused-variable/default/tslint.json | 5 - .../no-unused-variable/default/var.ts.lint | 92 -- .../ignore-pattern/a.test.ts | 1 - .../ignore-pattern/tsconfig.json | 5 - .../ignore-pattern/tslint.json | 5 - .../ignore-pattern/var.ts.lint | 107 -- .../no-unused-variable/type-checked/a.test.ts | 2 - .../type-checked/destructuring.ts.lint | 15 - .../type-checked/some.test.ts | 3 - .../type-checked/test.ts.lint | 6 - .../type-checked/tsconfig.json | 5 - .../type-checked/tslint.json | 5 - test/rules/no-use-before-declare/$.ts | 0 .../ImportAliasSecond.ts | 0 .../ImportAliasWithComment.ts | 0 .../ImportRegularAlias.ts | 0 .../ImportWithLineBreaks.ts | 0 .../no-use-before-declare/InterfaceFile.ts | 0 test/rules/no-use-before-declare/lib.ts | 0 test/rules/no-use-before-declare/test.ts.lint | 105 -- .../rules/no-use-before-declare/tsconfig.json | 5 - test/rules/no-use-before-declare/tslint.json | 5 - .../rules/no-use-before-declare/underscore.ts | 0 test/rules/no-var-keyword/global.d.ts.lint | 8 - test/rules/no-var-keyword/module.d.ts.lint | 17 - test/rules/no-var-keyword/test.ts.fix | 44 - test/rules/no-var-keyword/test.ts.lint | 56 -- test/rules/no-var-keyword/tslint.json | 5 - test/rules/no-var-requires/test.ts.lint | 3 - test/rules/no-var-requires/tslint.json | 5 - .../no-void-expression/default/test.ts.lint | 29 - .../no-void-expression/default/tsconfig.json | 6 - .../no-void-expression/default/tslint.json | 5 - .../test.ts.lint | 10 - .../tsconfig.json | 5 - .../tslint.json | 5 - test/rules/number-literal-format/test.ts.fix | 47 - test/rules/number-literal-format/test.ts.lint | 77 -- test/rules/number-literal-format/tslint.json | 5 - .../always/test.ts.fix | 20 - .../always/test.ts.lint | 26 - .../always/tslint.json | 5 - .../as-needed/test.ts.fix | 23 - .../as-needed/test.ts.lint | 27 - .../as-needed/tslint.json | 5 - .../consistent-as-needed/test.ts.fix | 43 - .../consistent-as-needed/test.ts.lint | 52 - .../consistent-as-needed/tslint.json | 5 - .../consistent/test.ts.lint | 43 - .../consistent/tslint.json | 5 - .../always/test.ts.fix | 43 - .../always/test.ts.lint | 55 -- .../always/tslint.json | 5 - .../never/test.ts.fix | 59 -- .../never/test.ts.lint | 72 -- .../never/tslint.json | 6 - .../onlyMethods/test.ts.fix | 45 - .../onlyMethods/test.ts.lint | 58 -- .../onlyMethods/tslint.json | 11 - .../default/crlf.ts.lint | 6 - .../default/test.ts.lint | 319 ------ .../default/tslint.json | 5 - .../ignore-blank-lines/test.ts.lint | 26 - .../ignore-blank-lines/tslint.json | 5 - .../ignore-case/test.ts.lint | 12 - .../ignore-case/tslint.json | 5 - .../locale-compare/test.ts.lint | 12 - .../locale-compare/tslint.json | 5 - .../match-declaration-order-only/test.ts.lint | 71 -- .../tsconfig.json | 1 - .../match-declaration-order-only/tslint.json | 5 - .../match-declaration-order/test.ts.lint | 72 -- .../match-declaration-order/tsconfig.json | 1 - .../match-declaration-order/tslint.json | 5 - .../shorthand-first/test.ts.lint | 79 -- .../shorthand-first/tslint.json | 5 - test/rules/one-line/all/test.ts.fix | 152 --- test/rules/one-line/all/test.ts.lint | 197 ---- test/rules/one-line/all/tslint.json | 5 - test/rules/one-line/no-whitespace/test.ts.fix | 132 --- .../rules/one-line/no-whitespace/test.ts.lint | 170 ---- test/rules/one-line/no-whitespace/tslint.json | 5 - test/rules/one-line/none/test.ts.lint | 130 --- test/rules/one-line/none/tslint.json | 5 - .../default/test.ts.lint | 45 - .../default/tslint.json | 5 - .../ignore-for-loop/test.ts.lint | 30 - .../ignore-for-loop/tslint.json | 7 - .../allow-declarations/test.ts.lint | 26 - .../allow-declarations/tslint.json | 5 - .../allow-named-functions/test.ts.lint | 7 - .../allow-named-functions/tslint.json | 5 - .../only-arrow-functions/default/test.ts.lint | 47 - .../only-arrow-functions/default/tslint.json | 5 - .../case-insensitive-legacy/test.ts.fix | 48 - .../case-insensitive-legacy/test.ts.lint | 61 -- .../case-insensitive-legacy/tslint.json | 11 - .../case-insensitive/test.ts.fix | 48 - .../case-insensitive/test.ts.lint | 61 -- .../case-insensitive/tslint.json | 5 - .../grouped-imports/test.ts.fix | 13 - .../grouped-imports/test.ts.lint | 18 - .../grouped-imports/tslint.json | 10 - .../groups-complex/test.ts.fix | 24 - .../groups-complex/test.ts.lint | 30 - .../groups-complex/tslint.json | 19 - .../groups-shared-order/test.ts.fix | 13 - .../groups-shared-order/test.ts.lint | 18 - .../groups-shared-order/tslint.json | 17 - .../groups-string-list/test.ts.fix | 18 - .../groups-string-list/test.ts.lint | 20 - .../groups-string-list/tslint.json | 13 - .../groups-unmatched/test.ts.fix | 14 - .../groups-unmatched/test.ts.lint | 18 - .../groups-unmatched/tslint.json | 13 - .../import-sources-any/default/test.ts.fix | 31 - .../import-sources-any/default/test.ts.lint | 35 - .../import-sources-any/default/tslint.json | 5 - .../grouped-imports/test.ts.fix | 4 - .../grouped-imports/test.ts.lint | 5 - .../grouped-imports/tslint.json | 5 - .../inside-module-declaration/test.ts.lint | 7 - .../inside-module-declaration/tslint.json | 5 - .../lowercase-first/test.ts.fix | 31 - .../lowercase-first/test.ts.lint | 40 - .../lowercase-first/tslint.json | 5 - .../module-source-path/test.ts.fix | 19 - .../module-source-path/test.ts.lint | 23 - .../module-source-path/tslint.json | 5 - .../named-imports-any/test.ts.fix | 42 - .../named-imports-any/test.ts.lint | 52 - .../named-imports-any/tslint.json | 5 - .../standalone-grouped-import/test.ts.fix | 10 - .../standalone-grouped-import/test.ts.lint | 13 - .../standalone-grouped-import/tslint.json | 10 - .../check-else-if/test.ts.lint | 106 -- .../check-else-if/tslint.json | 5 - .../default/test.ts.lint | 95 -- .../default/tslint.json | 5 - .../prefer-const/default/ambient.d.ts.lint | 5 - .../rules/prefer-const/default/global.ts.lint | 17 - .../rules/prefer-const/default/spread.ts.lint | 24 - test/rules/prefer-const/default/test.ts.fix | 228 ----- test/rules/prefer-const/default/test.ts.lint | 270 ------ test/rules/prefer-const/default/tslint.json | 5 - .../destructuring-all/test.ts.fix | 28 - .../destructuring-all/test.ts.lint | 34 - .../destructuring-all/tslint.json | 8 - test/rules/prefer-for-of/test.ts.lint | 197 ---- test/rules/prefer-for-of/tslint.json | 5 - .../allow-protected/test.ts.lint | 9 - .../allow-protected/tslint.json | 5 - .../allow-public-and-protected/test.ts.lint | 8 - .../allow-public-and-protected/tslint.json | 5 - .../allow-public/test.ts.lint | 9 - .../allow-public/tslint.json | 5 - .../default/test.ts.lint | 66 -- .../default/tslint.json | 5 - .../rules/prefer-method-signature/test.ts.fix | 18 - .../prefer-method-signature/test.ts.lint | 25 - .../rules/prefer-method-signature/tslint.json | 5 - test/rules/prefer-object-spread/test.ts.fix | 30 - test/rules/prefer-object-spread/test.ts.lint | 46 - test/rules/prefer-object-spread/tslint.json | 5 - .../rules/prefer-readonly/default/test.ts.fix | 155 --- .../prefer-readonly/default/test.ts.lint | 169 ---- .../prefer-readonly/default/tsconfig.json | 5 - .../rules/prefer-readonly/default/tslint.json | 5 - .../only-inline-lambdas/test.ts.fix | 28 - .../only-inline-lambdas/test.ts.lint | 29 - .../only-inline-lambdas/tsconfig.json | 5 - .../only-inline-lambdas/tslint.json | 5 - test/rules/prefer-switch/default/test.ts.lint | 79 -- test/rules/prefer-switch/default/tslint.json | 5 - .../prefer-switch/min-cases-2/test.ts.lint | 52 - .../prefer-switch/min-cases-2/tslint.json | 7 - .../allow-single-concat/test.ts.lint | 37 - .../allow-single-concat/tslint.json | 5 - .../prefer-template/default/test.ts.lint | 39 - .../rules/prefer-template/default/tslint.json | 5 - test/rules/prefer-while/test.ts.fix | 24 - test/rules/prefer-while/test.ts.lint | 26 - test/rules/prefer-while/tslint.json | 5 - .../rules/promise-function-async/test.ts.lint | 74 -- .../promise-function-async/tsconfig.json | 5 - test/rules/promise-function-async/tslint.json | 5 - .../backtick/test-post-2.7.1-syntax.ts.fix | 13 - .../backtick/test-post-2.7.1-syntax.ts.lint | 21 - .../backtick/test-pre-2.7.1-syntax.ts.fix | 11 - .../backtick/test-pre-2.7.1-syntax.ts.lint | 15 - test/rules/quotemark/backtick/test.ts.fix | 80 -- test/rules/quotemark/backtick/test.ts.lint | 99 -- test/rules/quotemark/backtick/tslint.json | 5 - .../quotemark/double-avoid-escape/test.ts.fix | 5 - .../double-avoid-escape/test.ts.lint | 7 - .../quotemark/double-avoid-escape/tslint.json | 5 - .../double-avoid-template/test.ts.fix | 20 - .../double-avoid-template/test.ts.lint | 26 - .../double-avoid-template/tslint.json | 5 - test/rules/quotemark/double/test.ts.fix | 9 - test/rules/quotemark/double/test.ts.lint | 13 - test/rules/quotemark/double/tslint.json | 5 - .../quotemark/invalid-double/test.ts.fix | 2 - .../quotemark/invalid-double/test.ts.lint | 3 - .../quotemark/invalid-double/tslint.json | 5 - .../quotemark/invalid-single/test.ts.fix | 2 - .../quotemark/invalid-single/test.ts.lint | 3 - .../quotemark/invalid-single/tslint.json | 5 - test/rules/quotemark/jsx-double/test.tsx.fix | 4 - test/rules/quotemark/jsx-double/test.tsx.lint | 8 - test/rules/quotemark/jsx-double/tslint.json | 5 - test/rules/quotemark/jsx-single/test.tsx.fix | 4 - test/rules/quotemark/jsx-single/test.tsx.lint | 7 - test/rules/quotemark/jsx-single/tslint.json | 5 - .../quotemark/single-avoid-escape/test.ts.fix | 5 - .../single-avoid-escape/test.ts.lint | 7 - .../quotemark/single-avoid-escape/tslint.json | 5 - .../single-avoid-template/test.ts.fix | 20 - .../single-avoid-template/test.ts.lint | 26 - .../single-avoid-template/tslint.json | 5 - test/rules/quotemark/single/test.ts.fix | 6 - test/rules/quotemark/single/test.ts.lint | 10 - test/rules/quotemark/single/test.tsx.lint | 2 - test/rules/quotemark/single/tslint.json | 5 - test/rules/radix/test.ts.lint | 28 - test/rules/radix/tslint.json | 5 - .../default/test.ts.lint | 68 -- .../default/tsconfig.json | 5 - .../default/tslint.json | 5 - .../esnext-bigint/test.ts.lint | 42 - .../esnext-bigint/tsconfig.json | 5 - .../esnext-bigint/tslint.json | 5 - .../return-undefined/default/test.ts.lint | 92 -- .../return-undefined/default/tsconfig.json | 5 - .../return-undefined/default/tslint.json | 5 - .../return-undefined/pre-ts-3.6/test.ts.lint | 9 - .../return-undefined/pre-ts-3.6/tsconfig.json | 5 - .../return-undefined/pre-ts-3.6/tslint.json | 5 - test/rules/semicolon/always/test.ts.fix | 96 -- test/rules/semicolon/always/test.ts.lint | 131 --- test/rules/semicolon/always/tslint.json | 5 - test/rules/semicolon/enabled/test.ts.fix | 87 -- test/rules/semicolon/enabled/test.ts.lint | 116 --- test/rules/semicolon/enabled/tslint.json | 5 - .../ignore-bound-class-methods/test.ts.fix | 83 -- .../ignore-bound-class-methods/test.ts.lint | 111 --- .../ignore-bound-class-methods/tslint.json | 5 - .../semicolon/ignore-interfaces/test.ts.fix | 83 -- .../semicolon/ignore-interfaces/test.ts.lint | 109 --- .../semicolon/ignore-interfaces/tslint.json | 5 - test/rules/semicolon/never/eof1.ts.lint | 2 - test/rules/semicolon/never/eof2.ts.lint | 2 - test/rules/semicolon/never/test.ts.fix | 227 ----- test/rules/semicolon/never/test.ts.lint | 281 ------ test/rules/semicolon/never/tslint.json | 5 - .../strict-bound-class-methods/test.ts.fix | 22 - .../strict-bound-class-methods/test.ts.lint | 27 - .../strict-bound-class-methods/tslint.json | 5 - .../always/test.ts.fix | 75 -- .../always/test.ts.lint | 104 -- .../always/tslint.json | 5 - .../mixed/test.ts.fix | 65 -- .../mixed/test.ts.lint | 89 -- .../mixed/tslint.json | 14 - .../never/test.ts.fix | 76 -- .../never/test.ts.lint | 107 -- .../never/tslint.json | 5 - .../force-one-space/test.ts.fix | 11 - .../force-one-space/test.ts.lint | 21 - .../force-one-space/tslint.json | 5 - .../force-two-spaces/test.ts.fix | 28 - .../force-two-spaces/test.ts.lint | 42 - .../force-two-spaces/tslint.json | 5 - .../space-within-parens/no-space/test.ts.fix | 37 - .../space-within-parens/no-space/test.ts.lint | 50 - .../space-within-parens/no-space/tslint.json | 5 - test/rules/static-this/test.ts.fix | 77 -- test/rules/static-this/test.ts.lint | 87 -- test/rules/static-this/tslint.json | 5 - .../test.ts.lint | 36 - .../tsconfig.json | 5 - .../allow-boolean-undefined-union/tslint.json | 5 - .../allow-enum/test.ts.lint | 6 - .../allow-enum/tsconfig.json | 5 - .../allow-enum/tslint.json | 5 - .../allow-mix/test.ts.lint | 20 - .../allow-mix/tsconfig.json | 5 - .../allow-mix/tslint.json | 5 - .../allow-null-union/test.ts.lint | 12 - .../allow-null-union/tsconfig.json | 5 - .../allow-null-union/tslint.json | 5 - .../allow-number/test.ts.lint | 19 - .../allow-number/tsconfig.json | 5 - .../allow-number/tslint.json | 5 - .../allow-string/test.ts.lint | 14 - .../allow-string/tsconfig.json | 5 - .../allow-string/tslint.json | 5 - .../allow-undefined-union/test.ts.lint | 28 - .../allow-undefined-union/tsconfig.json | 5 - .../allow-undefined-union/tslint.json | 5 - .../default/test.ts.lint | 235 ----- .../default/tsconfig.json | 5 - .../default/tslint.json | 5 - .../ignore-rhs/test.ts.lint | 78 -- .../ignore-rhs/tsconfig.json | 5 - .../ignore-rhs/tslint.json | 5 - .../no-allow-mix/test.ts.lint | 28 - .../no-allow-mix/tsconfig.json | 5 - .../no-allow-mix/tslint.json | 5 - .../test.ts.lint | 17 - .../tsconfig.json | 6 - .../tslint.json | 5 - .../test.ts.lint | 9 - .../tsconfig.json | 5 - .../tslint.json | 5 - .../no-null-checks/test.ts.lint | 17 - .../no-null-checks/tsconfig.json | 5 - .../no-null-checks/tslint.json | 5 - .../test.ts.lint | 182 ---- .../tsconfig.json | 5 - .../allow-object-equal-comparison/tslint.json | 10 - .../test.ts.lint | 178 ---- .../tsconfig.json | 5 - .../allow-string-order-comparison/tslint.json | 10 - .../strict-comparisons/default/test.ts.lint | 190 ---- .../strict-comparisons/default/tsconfig.json | 5 - .../strict-comparisons/default/tslint.json | 5 - .../allow-empty-types/test.ts.fix | 133 --- .../allow-empty-types/test.ts.lint | 145 --- .../allow-empty-types/tsconfig.json | 4 - .../allow-empty-types/tslint.json | 10 - .../disallow-empty-types/test.ts.fix | 133 --- .../disallow-empty-types/test.ts.lint | 151 --- .../disallow-empty-types/tsconfig.json | 5 - .../disallow-empty-types/tslint.json | 10 - .../no-strict-null-checks/test.ts.lint | 156 --- .../no-strict-null-checks/tsconfig.json | 5 - .../no-strict-null-checks/tslint.json | 5 - .../strict-null-checks/test.ts.lint | 215 ----- .../strict-null-checks/tsconfig.json | 5 - .../strict-null-checks/tslint.json | 5 - .../unknown/test.ts.lint | 42 - .../unknown/tsconfig.json | 5 - .../unknown/tslint.json | 5 - test/rules/switch-default/test.ts.lint | 74 -- test/rules/switch-default/tslint.json | 5 - .../switch-final-break/always/test.ts.fix | 49 - .../switch-final-break/always/test.ts.lint | 51 - .../switch-final-break/always/tslint.json | 5 - .../switch-final-break/default/test.ts.fix | 61 -- .../switch-final-break/default/test.ts.lint | 70 -- .../switch-final-break/default/tslint.json | 5 - .../multiline-always/test.ts.fix | 602 ------------ .../multiline-always/test.ts.lint | 636 ------------ .../multiline-always/tslint.json | 5 - .../multiline-custom/always/test.ts.lint | 578 ----------- .../multiline-custom/always/tslint.json | 17 - .../multiline-custom/ignore/test.ts.lint | 549 ----------- .../multiline-custom/ignore/tslint.json | 17 - .../multiline-custom/mixed/test.ts.lint | 78 -- .../multiline-custom/mixed/tslint.json | 17 - .../multiline-custom/never/test.ts.fix | 498 ---------- .../multiline-custom/never/test.ts.lint | 527 ---------- .../multiline-custom/never/tslint.json | 17 - .../multiline-never/test.ts.fix | 545 ----------- .../multiline-never/test.ts.lint | 579 ----------- .../multiline-never/tslint.json | 5 - .../singleline-always/test.ts.fix | 597 ------------ .../singleline-always/test.ts.lint | 629 ------------ .../singleline-always/tslint.json | 5 - .../singleline-custom/always/test.ts.fix | 540 ----------- .../singleline-custom/always/test.ts.lint | 565 ----------- .../singleline-custom/always/tslint.json | 17 - .../singleline-custom/ignore/test.ts.lint | 540 ----------- .../singleline-custom/ignore/tslint.json | 17 - .../singleline-custom/mixed/test.ts.lint | 28 - .../singleline-custom/mixed/tslint.json | 17 - .../singleline-custom/never/test.ts.fix | 500 ---------- .../singleline-custom/never/test.ts.lint | 523 ---------- .../singleline-custom/never/tslint.json | 17 - .../singleline-never/test.ts.fix | 550 ----------- .../singleline-never/test.ts.lint | 578 ----------- .../singleline-never/tslint.json | 5 - .../trailing-comma/spec-compliant/test.ts.fix | 66 -- .../spec-compliant/test.ts.lint | 83 -- .../trailing-comma/spec-compliant/tslint.json | 12 - .../allow-null-check/test.ts.lint | 19 - .../allow-null-check/tslint.json | 5 - .../allow-undefined-check/test.ts.lint | 19 - .../allow-undefined-check/tslint.json | 5 - .../one-liners-with-no-trailings/test.ts.fix | 21 - .../one-liners-with-no-trailings/test.ts.lint | 30 - .../one-liners-with-no-trailings/tslint.json | 5 - .../one-liners-with-trailings/test.ts.fix | 21 - .../one-liners-with-trailings/test.ts.lint | 31 - .../one-liners-with-trailings/tslint.json | 10 - .../both/nospace/test.ts.lint | 905 ----------------- .../both/nospace/tslint.json | 18 - .../both/onespace/test.ts.lint | 913 ------------------ .../both/onespace/tslint.json | 18 - .../both/space/test.ts.lint | 767 --------------- .../typedef-whitespace/both/space/tslint.json | 18 - .../left/nospace/test.ts.lint | 745 -------------- .../left/nospace/tslint.json | 11 - .../left/onespace/test.ts.lint | 762 --------------- .../left/onespace/tslint.json | 11 - .../left/space/test.ts.lint | 689 ------------- .../typedef-whitespace/left/space/tslint.json | 11 - .../typedef-whitespace/none/test.ts.lint | 527 ---------- .../rules/typedef-whitespace/none/tslint.json | 5 - .../right/nospace/test.ts.lint | 745 -------------- .../right/nospace/tslint.json | 12 - .../right/onespace/test.ts.lint | 745 -------------- .../right/onespace/tslint.json | 12 - .../right/space/test.ts.lint | 672 ------------- .../right/space/tslint.json | 12 - test/rules/typedef/all/test.ts.lint | 107 -- test/rules/typedef/all/tslint.json | 15 - .../typedef/array-destructuring/test.ts.lint | 4 - .../typedef/array-destructuring/tslint.json | 7 - .../test.ts.lint | 12 - .../tslint.json | 8 - .../typedef/arrow-call-signature/test.ts.lint | 30 - .../typedef/arrow-call-signature/tslint.json | 7 - .../typedef/arrow-parameter/test.ts.lint | 13 - .../rules/typedef/arrow-parameter/tslint.json | 7 - .../rules/typedef/call-signature/test.ts.lint | 39 - test/rules/typedef/call-signature/tslint.json | 7 - .../member-variable-declaration/test.ts.lint | 16 - .../member-variable-declaration/tslint.json | 7 - test/rules/typedef/none/test.ts.lint | 87 -- test/rules/typedef/none/tslint.json | 5 - .../typedef/object-destructuring/test.ts.lint | 4 - .../typedef/object-destructuring/tslint.json | 7 - test/rules/typedef/parameter/test.ts.lint | 19 - test/rules/typedef/parameter/tslint.json | 7 - .../test.ts.lint | 23 - .../tslint.json | 10 - .../typedef/variable-declaration/test.ts.lint | 5 - .../typedef/variable-declaration/tslint.json | 7 - test/rules/typeof-compare/test.ts.lint | 109 --- test/rules/typeof-compare/tslint.json | 5 - test/rules/unified-signatures/test.d.ts.lint | 99 -- test/rules/unified-signatures/test.ts.lint | 31 - test/rules/unified-signatures/tslint.json | 5 - .../rules/unnecessary-bind/typed/test.ts.lint | 73 -- .../unnecessary-bind/typed/tsconfig.json | 5 - test/rules/unnecessary-bind/typed/tslint.json | 5 - .../unnecessary-bind/untyped/test.ts.lint | 62 -- .../unnecessary-bind/untyped/tslint.json | 5 - .../check-super-calls/test.ts.fix | 147 --- .../check-super-calls/test.ts.lint | 188 ---- .../check-super-calls/tslint.json | 8 - .../default/test.ts.fix | 159 --- .../default/test.ts.lint | 176 ---- .../default/tslint.json | 5 - .../allow-else-if/test.ts.lint | 255 ----- .../allow-else-if/tslint.json | 5 - .../unnecessary-else/default/test.ts.lint | 337 ------- .../unnecessary-else/default/tslint.json | 5 - .../use-default-type-parameter/test.ts.fix | 18 - .../use-default-type-parameter/test.ts.lint | 26 - .../use-default-type-parameter/tsconfig.json | 1 - .../use-default-type-parameter/tslint.json | 5 - test/rules/use-isnan/test.ts.lint | 64 -- test/rules/use-isnan/tslint.json | 5 - .../test.ts.lint | 47 - .../tslint.json | 5 - .../allow-leading-underscore/test.ts.lint | 49 - .../allow-leading-underscore/tslint.json | 5 - .../allow-pascal-case/test.ts.lint | 50 - .../allow-pascal-case/tslint.json | 5 - .../allow-snake-case/test.ts.lint | 64 -- .../allow-snake-case/tslint.json | 5 - .../allow-trailing-underscore/test.ts.lint | 49 - .../allow-trailing-underscore/tslint.json | 5 - .../variable-name/ban-keywords/test.ts.lint | 21 - .../variable-name/ban-keywords/tslint.json | 5 - .../const-only-for-caps/test.ts.lint | 38 - .../const-only-for-caps/tslint.json | 5 - test/rules/variable-name/default/test.ts.lint | 65 -- test/rules/variable-name/default/tslint.json | 5 - test/rules/whitespace/all/bom.ts.lint | 1 - test/rules/whitespace/all/import-type.lint | 32 - test/rules/whitespace/all/import.ts.lint | 3 - test/rules/whitespace/all/test.ts.fix | 135 --- test/rules/whitespace/all/test.ts.lint | 220 ----- test/rules/whitespace/all/tslint.json | 16 - .../whitespace/check-postbrace/test.ts.fix | 5 - .../whitespace/check-postbrace/test.ts.lint | 6 - .../whitespace/check-postbrace/tslint.json | 5 - .../whitespace/check-separator/test.ts.lint | 1 - .../whitespace/check-separator/tslint.json | 5 - test/rules/whitespace/none/test.ts.lint | 102 -- test/rules/whitespace/none/tslint.json | 5 - 1172 files changed, 5 insertions(+), 51152 deletions(-) delete mode 100644 test/rules/_integration/enable-disable/test.ts.lint delete mode 100644 test/rules/_integration/enable-disable/test.tsx.lint delete mode 100644 test/rules/_integration/enable-disable/tslint.json delete mode 100644 test/rules/_integration/error-format/test.ts.lint delete mode 100644 test/rules/_integration/error-format/tslint.json delete mode 100644 test/rules/_integration/react/invalid.tsx.lint delete mode 100644 test/rules/_integration/react/test.tsx.lint delete mode 100644 test/rules/_integration/react/tslint.json delete mode 100644 test/rules/_integration/typescript-version/correct.js.lint delete mode 100644 test/rules/_integration/typescript-version/correct.ts.fix delete mode 100644 test/rules/_integration/typescript-version/correct.ts.lint delete mode 100644 test/rules/_integration/typescript-version/if-else.ts.lint delete mode 100644 test/rules/_integration/typescript-version/skip.js.lint delete mode 100644 test/rules/_integration/typescript-version/skip.ts.lint delete mode 100644 test/rules/_integration/typescript-version/substitution.ts.lint delete mode 100644 test/rules/_integration/typescript-version/tslint.json delete mode 100644 test/rules/adjacent-overload-signatures/default/test.ts.lint delete mode 100644 test/rules/adjacent-overload-signatures/default/tslint.json delete mode 100644 test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint delete mode 100644 test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json delete mode 100644 test/rules/align/arguments/test.ts.fix delete mode 100644 test/rules/align/arguments/test.ts.lint delete mode 100644 test/rules/align/arguments/tslint.json delete mode 100644 test/rules/align/elements/test.ts.fix delete mode 100644 test/rules/align/elements/test.ts.lint delete mode 100644 test/rules/align/elements/tslint.json delete mode 100644 test/rules/align/members/test.ts.fix delete mode 100644 test/rules/align/members/test.ts.lint delete mode 100644 test/rules/align/members/tslint.json delete mode 100644 test/rules/align/parameters/test.ts.fix delete mode 100644 test/rules/align/parameters/test.ts.lint delete mode 100644 test/rules/align/parameters/tslint.json delete mode 100644 test/rules/align/statements/bom.ts.fix delete mode 100644 test/rules/align/statements/bom.ts.lint delete mode 100644 test/rules/align/statements/test.ts.fix delete mode 100644 test/rules/align/statements/test.ts.lint delete mode 100644 test/rules/align/statements/tslint.json delete mode 100644 test/rules/array-type/array-simple/test.ts.fix delete mode 100644 test/rules/array-type/array-simple/test.ts.lint delete mode 100644 test/rules/array-type/array-simple/tslint.json delete mode 100644 test/rules/array-type/array/test.ts.fix delete mode 100644 test/rules/array-type/array/test.ts.lint delete mode 100644 test/rules/array-type/array/tslint.json delete mode 100644 test/rules/array-type/generic/test.ts.fix delete mode 100644 test/rules/array-type/generic/test.ts.lint delete mode 100644 test/rules/array-type/generic/tslint.json delete mode 100644 test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix delete mode 100644 test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint delete mode 100644 test/rules/arrow-parens/ban-single-arg-parens/tslint.json delete mode 100644 test/rules/arrow-parens/default/test.ts.fix delete mode 100644 test/rules/arrow-parens/default/test.ts.lint delete mode 100644 test/rules/arrow-parens/default/tslint.json delete mode 100644 test/rules/arrow-return-shorthand/default/test.ts.fix delete mode 100644 test/rules/arrow-return-shorthand/default/test.ts.lint delete mode 100644 test/rules/arrow-return-shorthand/default/tslint.json delete mode 100644 test/rules/arrow-return-shorthand/multiline/test.ts.fix delete mode 100644 test/rules/arrow-return-shorthand/multiline/test.ts.lint delete mode 100644 test/rules/arrow-return-shorthand/multiline/tslint.json delete mode 100644 test/rules/await-promise/custom-promise/test.ts.lint delete mode 100644 test/rules/await-promise/custom-promise/tsconfig.json delete mode 100644 test/rules/await-promise/custom-promise/tslint.json delete mode 100644 test/rules/await-promise/es6-promise/test.ts.lint delete mode 100644 test/rules/await-promise/es6-promise/tsconfig.json delete mode 100644 test/rules/await-promise/es6-promise/tslint.json delete mode 100644 test/rules/await-promise/for-await-of/test.ts.lint delete mode 100644 test/rules/await-promise/for-await-of/tsconfig.json delete mode 100644 test/rules/await-promise/for-await-of/tslint.json delete mode 100644 test/rules/ban-comma-operator/test.ts.lint delete mode 100644 test/rules/ban-comma-operator/tslint.json delete mode 100644 test/rules/ban-ts-ignore/test.ts.lint delete mode 100644 test/rules/ban-ts-ignore/tslint.json delete mode 100644 test/rules/ban-types/test.ts.lint delete mode 100644 test/rules/ban-types/tslint.json delete mode 100644 test/rules/ban/test.ts.lint delete mode 100644 test/rules/ban/tslint.json delete mode 100644 test/rules/binary-expression-operand-order/test.ts.lint delete mode 100644 test/rules/binary-expression-operand-order/tslint.json delete mode 100644 test/rules/callable-types/test.ts.fix delete mode 100644 test/rules/callable-types/test.ts.lint delete mode 100644 test/rules/callable-types/tslint.json delete mode 100644 test/rules/class-name/test.ts.lint delete mode 100644 test/rules/class-name/tslint.json delete mode 100644 test/rules/comment-format/allow-trailing-lowercase/test.ts.fix delete mode 100644 test/rules/comment-format/allow-trailing-lowercase/test.ts.lint delete mode 100644 test/rules/comment-format/allow-trailing-lowercase/tslint.json delete mode 100644 test/rules/comment-format/exceptions-pattern/test.ts.fix delete mode 100644 test/rules/comment-format/exceptions-pattern/test.ts.lint delete mode 100644 test/rules/comment-format/exceptions-pattern/tslint.json delete mode 100644 test/rules/comment-format/exceptions-words/test.ts.fix delete mode 100644 test/rules/comment-format/exceptions-words/test.ts.lint delete mode 100644 test/rules/comment-format/exceptions-words/tslint.json delete mode 100644 test/rules/comment-format/lower/test.ts.fix delete mode 100644 test/rules/comment-format/lower/test.ts.lint delete mode 100644 test/rules/comment-format/lower/test.tsx.fix delete mode 100644 test/rules/comment-format/lower/test.tsx.lint delete mode 100644 test/rules/comment-format/lower/tslint.json delete mode 100644 test/rules/comment-format/upper/test.ts.fix delete mode 100644 test/rules/comment-format/upper/test.ts.lint delete mode 100644 test/rules/comment-format/upper/tslint.json delete mode 100644 test/rules/comment-type/combo/test.ts.lint delete mode 100644 test/rules/comment-type/combo/tslint.json delete mode 100644 test/rules/comment-type/directive/test.ts.tslint delete mode 100644 test/rules/comment-type/directive/tslint.json delete mode 100644 test/rules/comment-type/doc/test.ts.lint delete mode 100644 test/rules/comment-type/doc/tslint.json delete mode 100644 test/rules/comment-type/multiline/test.ts.lint delete mode 100644 test/rules/comment-type/multiline/tslint.json delete mode 100644 test/rules/comment-type/single-line/test.ts.lint delete mode 100644 test/rules/comment-type/single-line/tslint.json delete mode 100644 test/rules/curly/as-needed/test.ts.lint delete mode 100644 test/rules/curly/as-needed/tslint.json delete mode 100644 test/rules/curly/defaults/test.ts.fix delete mode 100644 test/rules/curly/defaults/test.ts.lint delete mode 100644 test/rules/curly/defaults/tslint.json delete mode 100644 test/rules/curly/ignore-same-line/test.ts.fix delete mode 100644 test/rules/curly/ignore-same-line/test.ts.lint delete mode 100644 test/rules/curly/ignore-same-line/tslint.json delete mode 100644 test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint delete mode 100644 test/rules/cyclomatic-complexity/defaultThreshold/tslint.json delete mode 100644 test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint delete mode 100644 test/rules/cyclomatic-complexity/invalidThreshold/tslint.json delete mode 100644 test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint delete mode 100644 test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json delete mode 100644 test/rules/deprecation/other.test.ts delete mode 100644 test/rules/deprecation/other2.test.ts delete mode 100644 test/rules/deprecation/test.ts.lint delete mode 100644 test/rules/deprecation/tsconfig.json delete mode 100644 test/rules/deprecation/tslint.json delete mode 100644 test/rules/encoding/tslint.json delete mode 100644 test/rules/encoding/utf16be.ts.lint delete mode 100644 test/rules/encoding/utf16le.ts.lint delete mode 100644 test/rules/encoding/utf8-bom.ts.lint delete mode 100644 test/rules/encoding/utf8.ts.lint delete mode 100644 test/rules/eofline/comment.ts.lint delete mode 100644 test/rules/eofline/disabled.ts.lint delete mode 100644 test/rules/eofline/empty.ts.lint delete mode 100644 test/rules/eofline/invalid.ts.fix delete mode 100644 test/rules/eofline/invalid.ts.lint delete mode 100644 test/rules/eofline/only-whitespace.ts.fix delete mode 100644 test/rules/eofline/only-whitespace.ts.lint delete mode 100644 test/rules/eofline/tslint.json delete mode 100644 test/rules/eofline/valid.ts.lint delete mode 100644 test/rules/eofline/whitespace.ts.lint delete mode 100644 test/rules/file-header/bad-newline/test.ts.fix delete mode 100644 test/rules/file-header/bad-newline/test.ts.lint delete mode 100644 test/rules/file-header/bad-newline/tslint.json delete mode 100644 test/rules/file-header/bad-shebang/test.ts.fix delete mode 100644 test/rules/file-header/bad-shebang/test.ts.lint delete mode 100644 test/rules/file-header/bad-shebang/tslint.json delete mode 100644 test/rules/file-header/bad-single-line/test.ts.fix delete mode 100644 test/rules/file-header/bad-single-line/test.ts.lint delete mode 100644 test/rules/file-header/bad-single-line/tslint.json delete mode 100644 test/rules/file-header/bad-single-newline/test.ts.fix delete mode 100644 test/rules/file-header/bad-single-newline/test.ts.lint delete mode 100644 test/rules/file-header/bad-single-newline/tslint.json delete mode 100644 test/rules/file-header/bad-use-strict/test.ts.fix delete mode 100644 test/rules/file-header/bad-use-strict/test.ts.lint delete mode 100644 test/rules/file-header/bad-use-strict/tslint.json delete mode 100644 test/rules/file-header/bad/test.ts.fix delete mode 100644 test/rules/file-header/bad/test.ts.lint delete mode 100644 test/rules/file-header/bad/test2.ts.fix delete mode 100644 test/rules/file-header/bad/test2.ts.lint delete mode 100644 test/rules/file-header/bad/tslint.json delete mode 100644 test/rules/file-header/empty-file/test.ts.lint delete mode 100644 test/rules/file-header/empty-file/tslint.json delete mode 100644 test/rules/file-header/good-allow-single-line-comments/test.ts.lint delete mode 100644 test/rules/file-header/good-allow-single-line-comments/tslint.json delete mode 100644 test/rules/file-header/good-newline/test.ts.lint delete mode 100644 test/rules/file-header/good-newline/tslint.json delete mode 100644 test/rules/file-header/good-shebang/test.ts.lint delete mode 100644 test/rules/file-header/good-shebang/tslint.json delete mode 100644 test/rules/file-header/good-single-line/test.ts.lint delete mode 100644 test/rules/file-header/good-single-line/tslint.json delete mode 100644 test/rules/file-header/good-use-strict/test.ts.lint delete mode 100644 test/rules/file-header/good-use-strict/tslint.json delete mode 100644 test/rules/file-header/good/test.ts.fix delete mode 100644 test/rules/file-header/good/test.ts.lint delete mode 100644 test/rules/file-header/good/tslint.json delete mode 100644 test/rules/file-name-casing/camel-case/camelCase.ts.lint delete mode 100644 test/rules/file-name-casing/camel-case/no-camel-case.ts.lint delete mode 100644 test/rules/file-name-casing/camel-case/tslint.json delete mode 100644 test/rules/file-name-casing/complex/ComponentName.tsx.lint delete mode 100644 test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint delete mode 100644 test/rules/file-name-casing/complex/invalid-component-name.tsx.lint delete mode 100644 test/rules/file-name-casing/complex/my-button.component.ts.lint delete mode 100644 test/rules/file-name-casing/complex/nonComponentName.ts.lint delete mode 100644 test/rules/file-name-casing/complex/tslint.json delete mode 100644 test/rules/file-name-casing/file-matcher/PascalCase.ts.lint delete mode 100644 test/rules/file-name-casing/file-matcher/camelCase.ts.lint delete mode 100644 test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint delete mode 100644 test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint delete mode 100644 test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint delete mode 100644 test/rules/file-name-casing/file-matcher/tslint.json delete mode 100644 test/rules/file-name-casing/ignore/complaint.tsx.lint delete mode 100644 test/rules/file-name-casing/ignore/file.ts.lint delete mode 100644 test/rules/file-name-casing/ignore/tslint.json delete mode 100644 test/rules/file-name-casing/invalid-option/snake_case.ts.lint delete mode 100644 test/rules/file-name-casing/invalid-option/tslint.json delete mode 100644 test/rules/file-name-casing/kebab-case/kebab-case.ts.lint delete mode 100644 test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint delete mode 100644 test/rules/file-name-casing/kebab-case/tslint.json delete mode 100644 test/rules/file-name-casing/pascal-case/PascalCase.ts.lint delete mode 100644 test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint delete mode 100644 test/rules/file-name-casing/pascal-case/tslint.json delete mode 100644 test/rules/file-name-casing/snake-case/no-snake-case.ts.lint delete mode 100644 test/rules/file-name-casing/snake-case/snake_case.ts.lint delete mode 100644 test/rules/file-name-casing/snake-case/tslint.json delete mode 100644 test/rules/forin/test.ts.lint delete mode 100644 test/rules/forin/tslint.json delete mode 100644 test/rules/function-constructor/test.ts.lint delete mode 100644 test/rules/function-constructor/tslint.json delete mode 100644 test/rules/import-blacklist/test.ts.lint delete mode 100644 test/rules/import-blacklist/tslint.json delete mode 100644 test/rules/import-spacing/test.ts.lint delete mode 100644 test/rules/import-spacing/tslint.json delete mode 100644 test/rules/increment-decrement/allow-post/test.ts.fix delete mode 100644 test/rules/increment-decrement/allow-post/test.ts.lint delete mode 100644 test/rules/increment-decrement/allow-post/tslint.json delete mode 100644 test/rules/increment-decrement/default/test.ts.fix delete mode 100644 test/rules/increment-decrement/default/test.ts.lint delete mode 100644 test/rules/increment-decrement/default/tslint.json delete mode 100644 test/rules/indent/spaces-2/test.ts.fix delete mode 100644 test/rules/indent/spaces-2/test.ts.lint delete mode 100644 test/rules/indent/spaces-2/test.tsx.lint delete mode 100644 test/rules/indent/spaces-2/tslint.json delete mode 100644 test/rules/indent/spaces-4/test.ts.fix delete mode 100644 test/rules/indent/spaces-4/test.ts.lint delete mode 100644 test/rules/indent/spaces-4/tslint.json delete mode 100644 test/rules/indent/tabs-2/test.ts.fix delete mode 100644 test/rules/indent/tabs-2/test.ts.lint delete mode 100644 test/rules/indent/tabs-2/tslint.json delete mode 100644 test/rules/indent/tabs-4/test.ts.fix delete mode 100644 test/rules/indent/tabs-4/test.ts.lint delete mode 100644 test/rules/indent/tabs-4/tslint.json delete mode 100644 test/rules/interface-name/always-prefix/test.ts.lint delete mode 100644 test/rules/interface-name/always-prefix/tslint.json delete mode 100644 test/rules/interface-name/default/test.ts.lint delete mode 100644 test/rules/interface-name/default/tslint.json delete mode 100644 test/rules/interface-name/never-prefix/test.ts.lint delete mode 100644 test/rules/interface-name/never-prefix/tslint.json delete mode 100644 test/rules/interface-over-type-literal/test.ts.fix delete mode 100644 test/rules/interface-over-type-literal/test.ts.lint delete mode 100644 test/rules/interface-over-type-literal/tslint.json delete mode 100644 test/rules/invalid-void/allow-generics/false/test.ts.lint delete mode 100644 test/rules/invalid-void/allow-generics/false/tslint.json delete mode 100644 test/rules/invalid-void/allow-generics/true/test.ts.lint delete mode 100644 test/rules/invalid-void/allow-generics/true/tslint.json delete mode 100644 test/rules/invalid-void/allow-generics/whitelist/test.ts.lint delete mode 100644 test/rules/invalid-void/allow-generics/whitelist/tslint.json delete mode 100644 test/rules/invalid-void/default/test.ts.lint delete mode 100644 test/rules/invalid-void/default/tslint.json delete mode 100644 test/rules/jsdoc-format/check-multiline-start/test.ts.lint delete mode 100644 test/rules/jsdoc-format/check-multiline-start/tslint.json delete mode 100644 test/rules/jsdoc-format/default/jsdoc-bom.ts.lint delete mode 100644 test/rules/jsdoc-format/default/jsdoc-windows.ts.lint delete mode 100644 test/rules/jsdoc-format/default/jsdoc.ts.lint delete mode 100644 test/rules/jsdoc-format/default/tslint.json delete mode 100644 test/rules/label-position/test.ts.lint delete mode 100644 test/rules/label-position/tslint.json delete mode 100644 test/rules/linebreak-style/emptyFile/test.ts.lint delete mode 100644 test/rules/linebreak-style/emptyFile/tslint.json delete mode 100644 test/rules/linebreak-style/failure/CRLF/test.ts.fix delete mode 100644 test/rules/linebreak-style/failure/CRLF/test.ts.lint delete mode 100644 test/rules/linebreak-style/failure/CRLF/tslint.json delete mode 100644 test/rules/linebreak-style/failure/LF/test.ts.fix delete mode 100644 test/rules/linebreak-style/failure/LF/test.ts.lint delete mode 100644 test/rules/linebreak-style/failure/LF/tslint.json delete mode 100644 test/rules/linebreak-style/success/CRLF/test.ts.lint delete mode 100644 test/rules/linebreak-style/success/CRLF/tslint.json delete mode 100644 test/rules/linebreak-style/success/LF/test.ts.lint delete mode 100644 test/rules/linebreak-style/success/LF/tslint.json delete mode 100644 test/rules/match-default-export-name/anonymous.test.ts delete mode 100644 test/rules/match-default-export-name/named.test.ts delete mode 100644 test/rules/match-default-export-name/test.ts.lint delete mode 100644 test/rules/match-default-export-name/tsconfig.json delete mode 100644 test/rules/match-default-export-name/tslint.json delete mode 100644 test/rules/max-classes-per-file/one/test.ts.lint delete mode 100644 test/rules/max-classes-per-file/one/tslint.json delete mode 100644 test/rules/max-classes-per-file/two/test.ts.lint delete mode 100644 test/rules/max-classes-per-file/two/tslint.json delete mode 100644 test/rules/max-file-line-count/default/test.ts.lint delete mode 100644 test/rules/max-file-line-count/default/tslint.json delete mode 100644 test/rules/max-file-line-count/disabled/test.ts.lint delete mode 100644 test/rules/max-file-line-count/disabled/tslint.json delete mode 100644 test/rules/max-line-length/check-strings-and-regex/test.ts.lint delete mode 100644 test/rules/max-line-length/check-strings-and-regex/tslint.json delete mode 100644 test/rules/max-line-length/default/test.ts.lint delete mode 100644 test/rules/max-line-length/default/tslint.json delete mode 100644 test/rules/member-access/accessor/test.ts.fix delete mode 100644 test/rules/member-access/accessor/test.ts.lint delete mode 100644 test/rules/member-access/accessor/tslint.json delete mode 100644 test/rules/member-access/constructor/test.ts.fix delete mode 100644 test/rules/member-access/constructor/test.ts.lint delete mode 100644 test/rules/member-access/constructor/tslint.json delete mode 100644 test/rules/member-access/default/test.ts.fix delete mode 100644 test/rules/member-access/default/test.ts.lint delete mode 100644 test/rules/member-access/default/tslint.json delete mode 100644 test/rules/member-access/no-public/test.ts.fix delete mode 100644 test/rules/member-access/no-public/test.ts.lint delete mode 100644 test/rules/member-access/no-public/tslint.json delete mode 100644 test/rules/member-access/parameter-property/test.ts.fix delete mode 100644 test/rules/member-access/parameter-property/test.ts.lint delete mode 100644 test/rules/member-access/parameter-property/tslint.json delete mode 100644 test/rules/member-ordering/alphabetize-nested/test.ts.fix delete mode 100644 test/rules/member-ordering/alphabetize-nested/test.ts.lint delete mode 100644 test/rules/member-ordering/alphabetize-nested/tslint.json delete mode 100644 test/rules/member-ordering/alphabetize/test.ts.fix delete mode 100644 test/rules/member-ordering/alphabetize/test.ts.lint delete mode 100644 test/rules/member-ordering/alphabetize/tslint.json delete mode 100644 test/rules/member-ordering/custom-categories/test.ts.fix delete mode 100644 test/rules/member-ordering/custom-categories/test.ts.lint delete mode 100644 test/rules/member-ordering/custom-categories/tslint.json delete mode 100644 test/rules/member-ordering/custom/test.ts.fix delete mode 100644 test/rules/member-ordering/custom/test.ts.lint delete mode 100644 test/rules/member-ordering/custom/tslint.json delete mode 100644 test/rules/member-ordering/fields-first/test.ts.fix delete mode 100644 test/rules/member-ordering/fields-first/test.ts.lint delete mode 100644 test/rules/member-ordering/fields-first/tslint.json delete mode 100644 test/rules/member-ordering/fix-trivia/test.ts.fix delete mode 100644 test/rules/member-ordering/fix-trivia/test.ts.lint delete mode 100644 test/rules/member-ordering/fix-trivia/tslint.json delete mode 100644 test/rules/member-ordering/instance-sandwich/test.ts.fix delete mode 100644 test/rules/member-ordering/instance-sandwich/test.ts.lint delete mode 100644 test/rules/member-ordering/instance-sandwich/tslint.json delete mode 100644 test/rules/member-ordering/mix-old-options/test.ts.fix delete mode 100644 test/rules/member-ordering/mix-old-options/test.ts.lint delete mode 100644 test/rules/member-ordering/mix-old-options/tslint.json delete mode 100644 test/rules/member-ordering/omit-access-modifier/test.ts.fix delete mode 100644 test/rules/member-ordering/omit-access-modifier/test.ts.lint delete mode 100644 test/rules/member-ordering/omit-access-modifier/tslint.json delete mode 100644 test/rules/member-ordering/public-before-private/test.ts.fix delete mode 100644 test/rules/member-ordering/public-before-private/test.ts.lint delete mode 100644 test/rules/member-ordering/public-before-private/tslint.json delete mode 100644 test/rules/member-ordering/static-before-instance/test.ts.fix delete mode 100644 test/rules/member-ordering/static-before-instance/test.ts.lint delete mode 100644 test/rules/member-ordering/static-before-instance/tslint.json delete mode 100644 test/rules/member-ordering/statics-first/test.ts.fix delete mode 100644 test/rules/member-ordering/statics-first/test.ts.lint delete mode 100644 test/rules/member-ordering/statics-first/tslint.json delete mode 100644 test/rules/member-ordering/variables-before-functions/test.ts.fix delete mode 100644 test/rules/member-ordering/variables-before-functions/test.ts.lint delete mode 100644 test/rules/member-ordering/variables-before-functions/tslint.json delete mode 100644 test/rules/new-parens/test.ts.lint delete mode 100644 test/rules/new-parens/tslint.json delete mode 100644 test/rules/newline-before-return/default/test.ts.fix delete mode 100644 test/rules/newline-before-return/default/test.ts.lint delete mode 100644 test/rules/newline-before-return/default/test.tsx.fix delete mode 100644 test/rules/newline-before-return/default/test.tsx.lint delete mode 100644 test/rules/newline-before-return/default/tslint.json delete mode 100644 test/rules/newline-per-chained-call/default/test.ts.lint delete mode 100644 test/rules/newline-per-chained-call/default/tslint.json delete mode 100644 test/rules/no-angle-bracket-type-assertion/test.ts.fix delete mode 100644 test/rules/no-angle-bracket-type-assertion/test.ts.lint delete mode 100644 test/rules/no-angle-bracket-type-assertion/tslint.json delete mode 100644 test/rules/no-any/default/test.ts.lint delete mode 100644 test/rules/no-any/default/tslint.json delete mode 100644 test/rules/no-any/ignore-rest-args/test.ts.lint delete mode 100644 test/rules/no-any/ignore-rest-args/tslint.json delete mode 100644 test/rules/no-arg/test.ts.lint delete mode 100644 test/rules/no-arg/tslint.json delete mode 100644 test/rules/no-async-without-await/test.ts.lint delete mode 100644 test/rules/no-async-without-await/tslint.json delete mode 100644 test/rules/no-bitwise/test.ts.lint delete mode 100644 test/rules/no-bitwise/tslint.json delete mode 100644 test/rules/no-boolean-literal-compare/test.ts.fix delete mode 100644 test/rules/no-boolean-literal-compare/test.ts.lint delete mode 100644 test/rules/no-boolean-literal-compare/tsconfig.json delete mode 100644 test/rules/no-boolean-literal-compare/tslint.json delete mode 100644 test/rules/no-conditional-assignment/test.ts.lint delete mode 100644 test/rules/no-conditional-assignment/tslint.json delete mode 100644 test/rules/no-consecutive-blank-lines/default/test.ts.fix delete mode 100644 test/rules/no-consecutive-blank-lines/default/test.ts.lint delete mode 100644 test/rules/no-consecutive-blank-lines/default/tslint.json delete mode 100644 test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint delete mode 100644 test/rules/no-consecutive-blank-lines/invalid-option/tslint.json delete mode 100644 test/rules/no-consecutive-blank-lines/multiple/test.ts.fix delete mode 100644 test/rules/no-consecutive-blank-lines/multiple/test.ts.lint delete mode 100644 test/rules/no-consecutive-blank-lines/multiple/tslint.json delete mode 100644 test/rules/no-console/all/test.ts.lint delete mode 100644 test/rules/no-console/all/tslint.json delete mode 100644 test/rules/no-console/list/test.ts.lint delete mode 100644 test/rules/no-console/list/tslint.json delete mode 100644 test/rules/no-construct/test.ts.lint delete mode 100644 test/rules/no-construct/tslint.json delete mode 100644 test/rules/no-debugger/test.ts.lint delete mode 100644 test/rules/no-debugger/tslint.json delete mode 100644 test/rules/no-default-export/test.ts.lint delete mode 100644 test/rules/no-default-export/tslint.json delete mode 100644 test/rules/no-default-import/default/test.ts.lint delete mode 100644 test/rules/no-default-import/default/tslint.json delete mode 100644 test/rules/no-default-import/fromModules/test.ts.lint delete mode 100644 test/rules/no-default-import/fromModules/tslint.json delete mode 100644 test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint delete mode 100644 test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint delete mode 100644 test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json delete mode 100644 test/rules/no-duplicate-imports/default/test.d.ts.lint delete mode 100644 test/rules/no-duplicate-imports/default/test.ts.lint delete mode 100644 test/rules/no-duplicate-imports/default/test2.d.ts.lint delete mode 100644 test/rules/no-duplicate-imports/default/test3.d.ts.lint delete mode 100644 test/rules/no-duplicate-imports/default/tslint.json delete mode 100644 test/rules/no-duplicate-super/test.ts.lint delete mode 100644 test/rules/no-duplicate-super/tslint.json delete mode 100644 test/rules/no-duplicate-switch-case/test.ts.lint delete mode 100644 test/rules/no-duplicate-switch-case/tslint.json delete mode 100644 test/rules/no-duplicate-variable/check-parameters/test.ts.lint delete mode 100644 test/rules/no-duplicate-variable/check-parameters/tslint.json delete mode 100644 test/rules/no-duplicate-variable/default/test.ts.lint delete mode 100644 test/rules/no-duplicate-variable/default/tslint.json delete mode 100644 test/rules/no-dynamic-delete/test.ts.fix delete mode 100644 test/rules/no-dynamic-delete/test.ts.lint delete mode 100644 test/rules/no-dynamic-delete/tslint.json delete mode 100644 test/rules/no-empty-interface/test.ts.lint delete mode 100644 test/rules/no-empty-interface/tslint.json delete mode 100644 test/rules/no-empty/allow-empty-catch/test.ts.lint delete mode 100644 test/rules/no-empty/allow-empty-catch/tslint.json delete mode 100644 test/rules/no-empty/allow-empty-functions/test.ts.lint delete mode 100644 test/rules/no-empty/allow-empty-functions/tslint.json delete mode 100644 test/rules/no-empty/default/test.ts.lint delete mode 100644 test/rules/no-empty/default/tslint.json delete mode 100644 test/rules/no-eval/test.ts.lint delete mode 100644 test/rules/no-eval/tslint.json delete mode 100644 test/rules/no-floating-promises/jquerypromise/test.ts.lint delete mode 100644 test/rules/no-floating-promises/jquerypromise/tsconfig.json delete mode 100644 test/rules/no-floating-promises/jquerypromise/tslint.json delete mode 100644 test/rules/no-floating-promises/promises/test.ts.lint delete mode 100644 test/rules/no-floating-promises/promises/tsconfig.json delete mode 100644 test/rules/no-floating-promises/promises/tslint.json delete mode 100644 test/rules/no-for-in-array/test.ts.lint delete mode 100644 test/rules/no-for-in-array/tsconfig.json delete mode 100644 test/rules/no-for-in-array/tslint.json delete mode 100644 test/rules/no-for-in/test.ts.lint delete mode 100644 test/rules/no-for-in/tslint.json delete mode 100644 test/rules/no-implicit-dependencies/default/bom/package.json delete mode 100644 test/rules/no-implicit-dependencies/default/bom/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/default/builtin-only.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/default/malformed/package.json delete mode 100644 test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/default/nested-package/package.json delete mode 100644 test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/default/subdir/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/default/test.js.lint delete mode 100644 test/rules/no-implicit-dependencies/default/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/default/tslint.json delete mode 100644 test/rules/no-implicit-dependencies/dev/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/dev/tslint.json delete mode 100644 test/rules/no-implicit-dependencies/optional/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/optional/tslint.json delete mode 100644 test/rules/no-implicit-dependencies/package.json delete mode 100644 test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json delete mode 100644 test/rules/no-implicit-dependencies/whitelist/test.ts.lint delete mode 100644 test/rules/no-implicit-dependencies/whitelist/tslint.json delete mode 100644 test/rules/no-import-side-effect/default/test.ts.lint delete mode 100644 test/rules/no-import-side-effect/default/tslint.json delete mode 100644 test/rules/no-import-side-effect/ignore-module/test.ts.lint delete mode 100644 test/rules/no-import-side-effect/ignore-module/tslint.json delete mode 100644 test/rules/no-inferrable-types/default/test.ts.fix delete mode 100644 test/rules/no-inferrable-types/default/test.ts.lint delete mode 100644 test/rules/no-inferrable-types/default/tslint.json delete mode 100644 test/rules/no-inferrable-types/ignore-params/test.ts.fix delete mode 100644 test/rules/no-inferrable-types/ignore-params/test.ts.lint delete mode 100644 test/rules/no-inferrable-types/ignore-params/tslint.json delete mode 100644 test/rules/no-inferrable-types/ignore-properties/test.ts.fix delete mode 100644 test/rules/no-inferrable-types/ignore-properties/test.ts.lint delete mode 100644 test/rules/no-inferrable-types/ignore-properties/tslint.json delete mode 100644 test/rules/no-inferred-empty-object-type/test.ts.lint delete mode 100644 test/rules/no-inferred-empty-object-type/tsconfig.json delete mode 100644 test/rules/no-inferred-empty-object-type/tslint.json delete mode 100644 test/rules/no-internal-module/test.ts.fix delete mode 100644 test/rules/no-internal-module/test.ts.lint delete mode 100644 test/rules/no-internal-module/tslint.json delete mode 100644 test/rules/no-invalid-template-strings/test.ts.lint delete mode 100644 test/rules/no-invalid-template-strings/tslint.json delete mode 100644 test/rules/no-invalid-this/enabled/test.ts.lint delete mode 100644 test/rules/no-invalid-this/enabled/tslint.json delete mode 100644 test/rules/no-irregular-whitespace/test.builder.ts delete mode 100644 test/rules/no-irregular-whitespace/test.ts.fix delete mode 100644 test/rules/no-irregular-whitespace/test.ts.lint delete mode 100644 test/rules/no-irregular-whitespace/tslint.json delete mode 100644 test/rules/no-magic-numbers/allowed-numbers/test.ts.lint delete mode 100644 test/rules/no-magic-numbers/allowed-numbers/tslint.json delete mode 100644 test/rules/no-magic-numbers/custom/test.ts.lint delete mode 100644 test/rules/no-magic-numbers/custom/tslint.json delete mode 100644 test/rules/no-magic-numbers/default-jsx/test.tsx.lint delete mode 100644 test/rules/no-magic-numbers/default-jsx/tslint.json delete mode 100644 test/rules/no-magic-numbers/default/test.ts.lint delete mode 100644 test/rules/no-magic-numbers/default/tslint.json delete mode 100644 test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint delete mode 100644 test/rules/no-magic-numbers/ignore-jsx/tslint.json delete mode 100644 test/rules/no-mergeable-namespace/test.ts.lint delete mode 100644 test/rules/no-mergeable-namespace/tslint.json delete mode 100644 test/rules/no-misused-new/test.ts.lint delete mode 100644 test/rules/no-misused-new/tslint.json delete mode 100644 test/rules/no-namespace/allow-declarations/test.d.ts.lint delete mode 100644 test/rules/no-namespace/allow-declarations/test.ts.lint delete mode 100644 test/rules/no-namespace/allow-declarations/tslint.json delete mode 100644 test/rules/no-namespace/default/test.d.ts.lint delete mode 100644 test/rules/no-namespace/default/test.ts.lint delete mode 100644 test/rules/no-namespace/default/tslint.json delete mode 100644 test/rules/no-non-null-assertion/test.ts.lint delete mode 100644 test/rules/no-non-null-assertion/tslint.json delete mode 100644 test/rules/no-null-keyword/test.ts.fix delete mode 100644 test/rules/no-null-keyword/test.ts.lint delete mode 100644 test/rules/no-null-keyword/tslint.json delete mode 100644 test/rules/no-null-undefined-union/test.ts.lint delete mode 100644 test/rules/no-null-undefined-union/ts350.ts.lint delete mode 100644 test/rules/no-null-undefined-union/tsconfig.json delete mode 100644 test/rules/no-null-undefined-union/tslint.json delete mode 100644 test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint delete mode 100644 test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json delete mode 100644 test/rules/no-object-literal-type-assertion/default/test.ts.lint delete mode 100644 test/rules/no-object-literal-type-assertion/default/tslint.json delete mode 100644 test/rules/no-parameter-properties/test.ts.lint delete mode 100644 test/rules/no-parameter-properties/tslint.json delete mode 100644 test/rules/no-parameter-reassignment/test.ts.lint delete mode 100644 test/rules/no-parameter-reassignment/tslint.json delete mode 100644 test/rules/no-promise-as-boolean/custom-promise/test.ts.lint delete mode 100644 test/rules/no-promise-as-boolean/custom-promise/tsconfig.json delete mode 100644 test/rules/no-promise-as-boolean/custom-promise/tslint.json delete mode 100644 test/rules/no-promise-as-boolean/es6-promise/test.ts.lint delete mode 100644 test/rules/no-promise-as-boolean/es6-promise/tsconfig.json delete mode 100644 test/rules/no-promise-as-boolean/es6-promise/tslint.json delete mode 100644 test/rules/no-redundant-jsdoc/test.ts.lint delete mode 100644 test/rules/no-redundant-jsdoc/tslint.json delete mode 100644 test/rules/no-reference-import/test.d.ts.lint delete mode 100644 test/rules/no-reference-import/ts240.d.ts.lint delete mode 100644 test/rules/no-reference-import/tslint.json delete mode 100644 test/rules/no-reference/test.ts.lint delete mode 100644 test/rules/no-reference/ts240.ts.lint delete mode 100644 test/rules/no-reference/tslint.json delete mode 100644 test/rules/no-require-imports/test.ts.lint delete mode 100644 test/rules/no-require-imports/tslint.json delete mode 100644 test/rules/no-restricted-globals/custom-global.d.ts delete mode 100644 test/rules/no-restricted-globals/foo.d.ts delete mode 100644 test/rules/no-restricted-globals/namespace.ts.lint delete mode 100644 test/rules/no-restricted-globals/test.ts.lint delete mode 100644 test/rules/no-restricted-globals/tsconfig.json delete mode 100644 test/rules/no-restricted-globals/tslint.json delete mode 100644 test/rules/no-return-await/test.ts.fix delete mode 100644 test/rules/no-return-await/test.ts.lint delete mode 100644 test/rules/no-return-await/tslint.json delete mode 100644 test/rules/no-shadowed-variable/default/ambient.d.ts.lint delete mode 100644 test/rules/no-shadowed-variable/default/test.ts.lint delete mode 100644 test/rules/no-shadowed-variable/default/tslint.json delete mode 100644 test/rules/no-shadowed-variable/ignore-class/test.ts.lint delete mode 100644 test/rules/no-shadowed-variable/ignore-class/tslint.json delete mode 100644 test/rules/no-shadowed-variable/ignore-import/test.ts.lint delete mode 100644 test/rules/no-shadowed-variable/ignore-import/tslint.json delete mode 100644 test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint delete mode 100644 test/rules/no-shadowed-variable/ignore-underscore/tslint.json delete mode 100644 test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint delete mode 100644 test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json delete mode 100644 test/rules/no-sparse-arrays/test.ts.lint delete mode 100644 test/rules/no-sparse-arrays/tslint.json delete mode 100644 test/rules/no-string-literal/test.ts.fix delete mode 100644 test/rules/no-string-literal/test.ts.lint delete mode 100644 test/rules/no-string-literal/tslint.json delete mode 100644 test/rules/no-string-throw/test.ts.fix delete mode 100644 test/rules/no-string-throw/test.ts.lint delete mode 100644 test/rules/no-string-throw/tslint.json delete mode 100644 test/rules/no-submodule-imports/dynamic-imports/test.ts.lint delete mode 100644 test/rules/no-submodule-imports/dynamic-imports/tslint.json delete mode 100644 test/rules/no-submodule-imports/static-imports/test.ts.lint delete mode 100644 test/rules/no-submodule-imports/static-imports/tslint.json delete mode 100644 test/rules/no-switch-case-fall-through/test.ts.lint delete mode 100644 test/rules/no-switch-case-fall-through/tslint.json delete mode 100644 test/rules/no-tautology-expression/test.ts.lint delete mode 100644 test/rules/no-tautology-expression/tslint.json delete mode 100644 test/rules/no-this-assignment/allow-destructuring/test.ts.lint delete mode 100644 test/rules/no-this-assignment/allow-destructuring/tslint.json delete mode 100644 test/rules/no-this-assignment/allowed-names/test.ts.lint delete mode 100644 test/rules/no-this-assignment/allowed-names/tslint.json delete mode 100644 test/rules/no-this-assignment/default/test.ts.lint delete mode 100644 test/rules/no-this-assignment/default/tslint.json delete mode 100644 test/rules/no-trailing-whitespace/default/test.ts.fix delete mode 100644 test/rules/no-trailing-whitespace/default/test.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/default/tslint.json delete mode 100644 test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix delete mode 100644 test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/ignore-comments/tslint.json delete mode 100644 test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix delete mode 100644 test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json delete mode 100644 test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix delete mode 100644 test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json delete mode 100644 test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix delete mode 100644 test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json delete mode 100644 test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint delete mode 100644 test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json delete mode 100644 test/rules/no-unbound-method/default/test.ts.lint delete mode 100644 test/rules/no-unbound-method/default/test.tsx.lint delete mode 100644 test/rules/no-unbound-method/default/tsconfig.json delete mode 100644 test/rules/no-unbound-method/default/tslint.json delete mode 100644 test/rules/no-unbound-method/ignore-static/test.tsx.lint delete mode 100644 test/rules/no-unbound-method/ignore-static/tsconfig.json delete mode 100644 test/rules/no-unbound-method/ignore-static/tslint.json delete mode 100644 test/rules/no-unbound-method/whitelist/test.tsx.lint delete mode 100644 test/rules/no-unbound-method/whitelist/tsconfig.json delete mode 100644 test/rules/no-unbound-method/whitelist/tslint.json delete mode 100644 test/rules/no-unnecessary-callback-wrapper/test.ts.fix delete mode 100644 test/rules/no-unnecessary-callback-wrapper/test.ts.lint delete mode 100644 test/rules/no-unnecessary-callback-wrapper/tslint.json delete mode 100644 test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint delete mode 100644 test/rules/no-unnecessary-class/allow-constructor-only/tslint.json delete mode 100644 test/rules/no-unnecessary-class/allow-empty/test.ts.lint delete mode 100644 test/rules/no-unnecessary-class/allow-empty/tslint.json delete mode 100644 test/rules/no-unnecessary-class/allow-static-only/test.ts.lint delete mode 100644 test/rules/no-unnecessary-class/allow-static-only/tslint.json delete mode 100644 test/rules/no-unnecessary-class/default/test.ts.lint delete mode 100644 test/rules/no-unnecessary-class/default/tslint.json delete mode 100644 test/rules/no-unnecessary-initializer/test.ts.fix delete mode 100644 test/rules/no-unnecessary-initializer/test.ts.lint delete mode 100644 test/rules/no-unnecessary-initializer/tslint.json delete mode 100644 test/rules/no-unnecessary-qualifier/arguments.ts.lint delete mode 100644 test/rules/no-unnecessary-qualifier/b.test.ts delete mode 100644 test/rules/no-unnecessary-qualifier/test-global-2.ts.lint delete mode 100644 test/rules/no-unnecessary-qualifier/test-global.ts.fix delete mode 100644 test/rules/no-unnecessary-qualifier/test-global.ts.lint delete mode 100644 test/rules/no-unnecessary-qualifier/test.ts.fix delete mode 100644 test/rules/no-unnecessary-qualifier/test.ts.lint delete mode 100644 test/rules/no-unnecessary-qualifier/tsconfig.json delete mode 100644 test/rules/no-unnecessary-qualifier/tslint.json delete mode 100644 test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint delete mode 100644 test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json delete mode 100644 test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json delete mode 100644 test/rules/no-unnecessary-type-assertion/strict/test.ts.fix delete mode 100644 test/rules/no-unnecessary-type-assertion/strict/test.ts.lint delete mode 100644 test/rules/no-unnecessary-type-assertion/strict/tsconfig.json delete mode 100644 test/rules/no-unnecessary-type-assertion/strict/tslint.json delete mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix delete mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint delete mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json delete mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json delete mode 100644 test/rules/no-unsafe-any/default/commonjsModule.ts delete mode 100644 test/rules/no-unsafe-any/default/es6Module.ts delete mode 100644 test/rules/no-unsafe-any/default/test.ts.lint delete mode 100644 test/rules/no-unsafe-any/default/tsconfig.json delete mode 100644 test/rules/no-unsafe-any/default/tslint.json delete mode 100644 test/rules/no-unsafe-any/jsx/test.tsx.lint delete mode 100644 test/rules/no-unsafe-any/jsx/tsconfig.json delete mode 100644 test/rules/no-unsafe-any/jsx/tslint.json delete mode 100644 test/rules/no-unsafe-any/unknown/test.ts.lint delete mode 100644 test/rules/no-unsafe-any/unknown/tsconfig.json delete mode 100644 test/rules/no-unsafe-any/unknown/tslint.json delete mode 100644 test/rules/no-unsafe-finally/test.ts.lint delete mode 100644 test/rules/no-unsafe-finally/tslint.json delete mode 100644 test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint delete mode 100644 test/rules/no-unused-expression/allow-fast-null-checks/tslint.json delete mode 100644 test/rules/no-unused-expression/allow-new/test.ts.lint delete mode 100644 test/rules/no-unused-expression/allow-new/tslint.json delete mode 100644 test/rules/no-unused-expression/allow-tagged-template/test.ts.lint delete mode 100644 test/rules/no-unused-expression/allow-tagged-template/tslint.json delete mode 100644 test/rules/no-unused-expression/default/test.ts.lint delete mode 100644 test/rules/no-unused-expression/default/tslint.json delete mode 100644 test/rules/no-unused-variable/check-parameters/test.ts.lint delete mode 100644 test/rules/no-unused-variable/check-parameters/tsconfig.json delete mode 100644 test/rules/no-unused-variable/check-parameters/tslint.json delete mode 100644 test/rules/no-unused-variable/default/class.ts.lint delete mode 100644 test/rules/no-unused-variable/default/false-positives.ts.lint delete mode 100644 test/rules/no-unused-variable/default/function.ts.lint delete mode 100644 test/rules/no-unused-variable/default/import.ts.fix delete mode 100644 test/rules/no-unused-variable/default/import.ts.lint delete mode 100644 test/rules/no-unused-variable/default/node_modules/a.ts delete mode 100644 test/rules/no-unused-variable/default/node_modules/react.ts delete mode 100644 test/rules/no-unused-variable/default/node_modules/react/addons.ts delete mode 100644 test/rules/no-unused-variable/default/react-addons1.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/react-addons2.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/react-addons3.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/react1.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/react2.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/react3.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/react4.tsx.lint delete mode 100644 test/rules/no-unused-variable/default/tsconfig.json delete mode 100644 test/rules/no-unused-variable/default/tslint.json delete mode 100644 test/rules/no-unused-variable/default/var.ts.lint delete mode 100644 test/rules/no-unused-variable/ignore-pattern/a.test.ts delete mode 100644 test/rules/no-unused-variable/ignore-pattern/tsconfig.json delete mode 100644 test/rules/no-unused-variable/ignore-pattern/tslint.json delete mode 100644 test/rules/no-unused-variable/ignore-pattern/var.ts.lint delete mode 100644 test/rules/no-unused-variable/type-checked/a.test.ts delete mode 100644 test/rules/no-unused-variable/type-checked/destructuring.ts.lint delete mode 100644 test/rules/no-unused-variable/type-checked/some.test.ts delete mode 100644 test/rules/no-unused-variable/type-checked/test.ts.lint delete mode 100644 test/rules/no-unused-variable/type-checked/tsconfig.json delete mode 100644 test/rules/no-unused-variable/type-checked/tslint.json delete mode 100644 test/rules/no-use-before-declare/$.ts delete mode 100644 test/rules/no-use-before-declare/ImportAliasSecond.ts delete mode 100644 test/rules/no-use-before-declare/ImportAliasWithComment.ts delete mode 100644 test/rules/no-use-before-declare/ImportRegularAlias.ts delete mode 100644 test/rules/no-use-before-declare/ImportWithLineBreaks.ts delete mode 100644 test/rules/no-use-before-declare/InterfaceFile.ts delete mode 100644 test/rules/no-use-before-declare/lib.ts delete mode 100644 test/rules/no-use-before-declare/test.ts.lint delete mode 100644 test/rules/no-use-before-declare/tsconfig.json delete mode 100644 test/rules/no-use-before-declare/tslint.json delete mode 100644 test/rules/no-use-before-declare/underscore.ts delete mode 100644 test/rules/no-var-keyword/global.d.ts.lint delete mode 100644 test/rules/no-var-keyword/module.d.ts.lint delete mode 100644 test/rules/no-var-keyword/test.ts.fix delete mode 100644 test/rules/no-var-keyword/test.ts.lint delete mode 100644 test/rules/no-var-keyword/tslint.json delete mode 100644 test/rules/no-var-requires/test.ts.lint delete mode 100644 test/rules/no-var-requires/tslint.json delete mode 100644 test/rules/no-void-expression/default/test.ts.lint delete mode 100644 test/rules/no-void-expression/default/tsconfig.json delete mode 100644 test/rules/no-void-expression/default/tslint.json delete mode 100644 test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint delete mode 100644 test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json delete mode 100644 test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json delete mode 100644 test/rules/number-literal-format/test.ts.fix delete mode 100644 test/rules/number-literal-format/test.ts.lint delete mode 100644 test/rules/number-literal-format/tslint.json delete mode 100644 test/rules/object-literal-key-quotes/always/test.ts.fix delete mode 100644 test/rules/object-literal-key-quotes/always/test.ts.lint delete mode 100644 test/rules/object-literal-key-quotes/always/tslint.json delete mode 100644 test/rules/object-literal-key-quotes/as-needed/test.ts.fix delete mode 100644 test/rules/object-literal-key-quotes/as-needed/test.ts.lint delete mode 100644 test/rules/object-literal-key-quotes/as-needed/tslint.json delete mode 100644 test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix delete mode 100644 test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint delete mode 100644 test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json delete mode 100644 test/rules/object-literal-key-quotes/consistent/test.ts.lint delete mode 100644 test/rules/object-literal-key-quotes/consistent/tslint.json delete mode 100644 test/rules/object-literal-shorthand/always/test.ts.fix delete mode 100644 test/rules/object-literal-shorthand/always/test.ts.lint delete mode 100644 test/rules/object-literal-shorthand/always/tslint.json delete mode 100644 test/rules/object-literal-shorthand/never/test.ts.fix delete mode 100644 test/rules/object-literal-shorthand/never/test.ts.lint delete mode 100644 test/rules/object-literal-shorthand/never/tslint.json delete mode 100644 test/rules/object-literal-shorthand/onlyMethods/test.ts.fix delete mode 100644 test/rules/object-literal-shorthand/onlyMethods/test.ts.lint delete mode 100644 test/rules/object-literal-shorthand/onlyMethods/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/default/crlf.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/default/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/default/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/ignore-case/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/ignore-case/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/locale-compare/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/locale-compare/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json delete mode 100644 test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json delete mode 100644 test/rules/object-literal-sort-keys/match-declaration-order/tslint.json delete mode 100644 test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint delete mode 100644 test/rules/object-literal-sort-keys/shorthand-first/tslint.json delete mode 100644 test/rules/one-line/all/test.ts.fix delete mode 100644 test/rules/one-line/all/test.ts.lint delete mode 100644 test/rules/one-line/all/tslint.json delete mode 100644 test/rules/one-line/no-whitespace/test.ts.fix delete mode 100644 test/rules/one-line/no-whitespace/test.ts.lint delete mode 100644 test/rules/one-line/no-whitespace/tslint.json delete mode 100644 test/rules/one-line/none/test.ts.lint delete mode 100644 test/rules/one-line/none/tslint.json delete mode 100644 test/rules/one-variable-per-declaration/default/test.ts.lint delete mode 100644 test/rules/one-variable-per-declaration/default/tslint.json delete mode 100644 test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint delete mode 100644 test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json delete mode 100644 test/rules/only-arrow-functions/allow-declarations/test.ts.lint delete mode 100644 test/rules/only-arrow-functions/allow-declarations/tslint.json delete mode 100644 test/rules/only-arrow-functions/allow-named-functions/test.ts.lint delete mode 100644 test/rules/only-arrow-functions/allow-named-functions/tslint.json delete mode 100644 test/rules/only-arrow-functions/default/test.ts.lint delete mode 100644 test/rules/only-arrow-functions/default/tslint.json delete mode 100644 test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix delete mode 100644 test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint delete mode 100644 test/rules/ordered-imports/case-insensitive-legacy/tslint.json delete mode 100644 test/rules/ordered-imports/case-insensitive/test.ts.fix delete mode 100644 test/rules/ordered-imports/case-insensitive/test.ts.lint delete mode 100644 test/rules/ordered-imports/case-insensitive/tslint.json delete mode 100644 test/rules/ordered-imports/grouped-imports/test.ts.fix delete mode 100644 test/rules/ordered-imports/grouped-imports/test.ts.lint delete mode 100644 test/rules/ordered-imports/grouped-imports/tslint.json delete mode 100644 test/rules/ordered-imports/groups-complex/test.ts.fix delete mode 100644 test/rules/ordered-imports/groups-complex/test.ts.lint delete mode 100644 test/rules/ordered-imports/groups-complex/tslint.json delete mode 100644 test/rules/ordered-imports/groups-shared-order/test.ts.fix delete mode 100644 test/rules/ordered-imports/groups-shared-order/test.ts.lint delete mode 100644 test/rules/ordered-imports/groups-shared-order/tslint.json delete mode 100644 test/rules/ordered-imports/groups-string-list/test.ts.fix delete mode 100644 test/rules/ordered-imports/groups-string-list/test.ts.lint delete mode 100644 test/rules/ordered-imports/groups-string-list/tslint.json delete mode 100644 test/rules/ordered-imports/groups-unmatched/test.ts.fix delete mode 100644 test/rules/ordered-imports/groups-unmatched/test.ts.lint delete mode 100644 test/rules/ordered-imports/groups-unmatched/tslint.json delete mode 100644 test/rules/ordered-imports/import-sources-any/default/test.ts.fix delete mode 100644 test/rules/ordered-imports/import-sources-any/default/test.ts.lint delete mode 100644 test/rules/ordered-imports/import-sources-any/default/tslint.json delete mode 100644 test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix delete mode 100644 test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint delete mode 100644 test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json delete mode 100644 test/rules/ordered-imports/inside-module-declaration/test.ts.lint delete mode 100644 test/rules/ordered-imports/inside-module-declaration/tslint.json delete mode 100644 test/rules/ordered-imports/lowercase-first/test.ts.fix delete mode 100644 test/rules/ordered-imports/lowercase-first/test.ts.lint delete mode 100644 test/rules/ordered-imports/lowercase-first/tslint.json delete mode 100644 test/rules/ordered-imports/module-source-path/test.ts.fix delete mode 100644 test/rules/ordered-imports/module-source-path/test.ts.lint delete mode 100644 test/rules/ordered-imports/module-source-path/tslint.json delete mode 100644 test/rules/ordered-imports/named-imports-any/test.ts.fix delete mode 100644 test/rules/ordered-imports/named-imports-any/test.ts.lint delete mode 100644 test/rules/ordered-imports/named-imports-any/tslint.json delete mode 100644 test/rules/ordered-imports/standalone-grouped-import/test.ts.fix delete mode 100644 test/rules/ordered-imports/standalone-grouped-import/test.ts.lint delete mode 100644 test/rules/ordered-imports/standalone-grouped-import/tslint.json delete mode 100644 test/rules/prefer-conditional-expression/check-else-if/test.ts.lint delete mode 100644 test/rules/prefer-conditional-expression/check-else-if/tslint.json delete mode 100644 test/rules/prefer-conditional-expression/default/test.ts.lint delete mode 100644 test/rules/prefer-conditional-expression/default/tslint.json delete mode 100644 test/rules/prefer-const/default/ambient.d.ts.lint delete mode 100644 test/rules/prefer-const/default/global.ts.lint delete mode 100644 test/rules/prefer-const/default/spread.ts.lint delete mode 100644 test/rules/prefer-const/default/test.ts.fix delete mode 100644 test/rules/prefer-const/default/test.ts.lint delete mode 100644 test/rules/prefer-const/default/tslint.json delete mode 100644 test/rules/prefer-const/destructuring-all/test.ts.fix delete mode 100644 test/rules/prefer-const/destructuring-all/test.ts.lint delete mode 100644 test/rules/prefer-const/destructuring-all/tslint.json delete mode 100644 test/rules/prefer-for-of/test.ts.lint delete mode 100644 test/rules/prefer-for-of/tslint.json delete mode 100644 test/rules/prefer-function-over-method/allow-protected/test.ts.lint delete mode 100644 test/rules/prefer-function-over-method/allow-protected/tslint.json delete mode 100644 test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint delete mode 100644 test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json delete mode 100644 test/rules/prefer-function-over-method/allow-public/test.ts.lint delete mode 100644 test/rules/prefer-function-over-method/allow-public/tslint.json delete mode 100644 test/rules/prefer-function-over-method/default/test.ts.lint delete mode 100644 test/rules/prefer-function-over-method/default/tslint.json delete mode 100644 test/rules/prefer-method-signature/test.ts.fix delete mode 100644 test/rules/prefer-method-signature/test.ts.lint delete mode 100644 test/rules/prefer-method-signature/tslint.json delete mode 100644 test/rules/prefer-object-spread/test.ts.fix delete mode 100644 test/rules/prefer-object-spread/test.ts.lint delete mode 100644 test/rules/prefer-object-spread/tslint.json delete mode 100644 test/rules/prefer-readonly/default/test.ts.fix delete mode 100644 test/rules/prefer-readonly/default/test.ts.lint delete mode 100644 test/rules/prefer-readonly/default/tsconfig.json delete mode 100644 test/rules/prefer-readonly/default/tslint.json delete mode 100644 test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix delete mode 100644 test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint delete mode 100644 test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json delete mode 100644 test/rules/prefer-readonly/only-inline-lambdas/tslint.json delete mode 100644 test/rules/prefer-switch/default/test.ts.lint delete mode 100644 test/rules/prefer-switch/default/tslint.json delete mode 100644 test/rules/prefer-switch/min-cases-2/test.ts.lint delete mode 100644 test/rules/prefer-switch/min-cases-2/tslint.json delete mode 100644 test/rules/prefer-template/allow-single-concat/test.ts.lint delete mode 100644 test/rules/prefer-template/allow-single-concat/tslint.json delete mode 100644 test/rules/prefer-template/default/test.ts.lint delete mode 100644 test/rules/prefer-template/default/tslint.json delete mode 100644 test/rules/prefer-while/test.ts.fix delete mode 100644 test/rules/prefer-while/test.ts.lint delete mode 100644 test/rules/prefer-while/tslint.json delete mode 100644 test/rules/promise-function-async/test.ts.lint delete mode 100644 test/rules/promise-function-async/tsconfig.json delete mode 100644 test/rules/promise-function-async/tslint.json delete mode 100644 test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix delete mode 100644 test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint delete mode 100644 test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix delete mode 100644 test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint delete mode 100644 test/rules/quotemark/backtick/test.ts.fix delete mode 100644 test/rules/quotemark/backtick/test.ts.lint delete mode 100644 test/rules/quotemark/backtick/tslint.json delete mode 100644 test/rules/quotemark/double-avoid-escape/test.ts.fix delete mode 100644 test/rules/quotemark/double-avoid-escape/test.ts.lint delete mode 100644 test/rules/quotemark/double-avoid-escape/tslint.json delete mode 100644 test/rules/quotemark/double-avoid-template/test.ts.fix delete mode 100644 test/rules/quotemark/double-avoid-template/test.ts.lint delete mode 100644 test/rules/quotemark/double-avoid-template/tslint.json delete mode 100644 test/rules/quotemark/double/test.ts.fix delete mode 100644 test/rules/quotemark/double/test.ts.lint delete mode 100644 test/rules/quotemark/double/tslint.json delete mode 100644 test/rules/quotemark/invalid-double/test.ts.fix delete mode 100644 test/rules/quotemark/invalid-double/test.ts.lint delete mode 100644 test/rules/quotemark/invalid-double/tslint.json delete mode 100644 test/rules/quotemark/invalid-single/test.ts.fix delete mode 100644 test/rules/quotemark/invalid-single/test.ts.lint delete mode 100644 test/rules/quotemark/invalid-single/tslint.json delete mode 100644 test/rules/quotemark/jsx-double/test.tsx.fix delete mode 100644 test/rules/quotemark/jsx-double/test.tsx.lint delete mode 100644 test/rules/quotemark/jsx-double/tslint.json delete mode 100644 test/rules/quotemark/jsx-single/test.tsx.fix delete mode 100644 test/rules/quotemark/jsx-single/test.tsx.lint delete mode 100644 test/rules/quotemark/jsx-single/tslint.json delete mode 100644 test/rules/quotemark/single-avoid-escape/test.ts.fix delete mode 100644 test/rules/quotemark/single-avoid-escape/test.ts.lint delete mode 100644 test/rules/quotemark/single-avoid-escape/tslint.json delete mode 100644 test/rules/quotemark/single-avoid-template/test.ts.fix delete mode 100644 test/rules/quotemark/single-avoid-template/test.ts.lint delete mode 100644 test/rules/quotemark/single-avoid-template/tslint.json delete mode 100644 test/rules/quotemark/single/test.ts.fix delete mode 100644 test/rules/quotemark/single/test.ts.lint delete mode 100644 test/rules/quotemark/single/test.tsx.lint delete mode 100644 test/rules/quotemark/single/tslint.json delete mode 100644 test/rules/radix/test.ts.lint delete mode 100644 test/rules/radix/tslint.json delete mode 100644 test/rules/restrict-plus-operands/default/test.ts.lint delete mode 100644 test/rules/restrict-plus-operands/default/tsconfig.json delete mode 100644 test/rules/restrict-plus-operands/default/tslint.json delete mode 100644 test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint delete mode 100644 test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json delete mode 100644 test/rules/restrict-plus-operands/esnext-bigint/tslint.json delete mode 100644 test/rules/return-undefined/default/test.ts.lint delete mode 100644 test/rules/return-undefined/default/tsconfig.json delete mode 100644 test/rules/return-undefined/default/tslint.json delete mode 100644 test/rules/return-undefined/pre-ts-3.6/test.ts.lint delete mode 100644 test/rules/return-undefined/pre-ts-3.6/tsconfig.json delete mode 100644 test/rules/return-undefined/pre-ts-3.6/tslint.json delete mode 100644 test/rules/semicolon/always/test.ts.fix delete mode 100644 test/rules/semicolon/always/test.ts.lint delete mode 100644 test/rules/semicolon/always/tslint.json delete mode 100644 test/rules/semicolon/enabled/test.ts.fix delete mode 100644 test/rules/semicolon/enabled/test.ts.lint delete mode 100644 test/rules/semicolon/enabled/tslint.json delete mode 100644 test/rules/semicolon/ignore-bound-class-methods/test.ts.fix delete mode 100644 test/rules/semicolon/ignore-bound-class-methods/test.ts.lint delete mode 100644 test/rules/semicolon/ignore-bound-class-methods/tslint.json delete mode 100644 test/rules/semicolon/ignore-interfaces/test.ts.fix delete mode 100644 test/rules/semicolon/ignore-interfaces/test.ts.lint delete mode 100644 test/rules/semicolon/ignore-interfaces/tslint.json delete mode 100644 test/rules/semicolon/never/eof1.ts.lint delete mode 100644 test/rules/semicolon/never/eof2.ts.lint delete mode 100644 test/rules/semicolon/never/test.ts.fix delete mode 100644 test/rules/semicolon/never/test.ts.lint delete mode 100644 test/rules/semicolon/never/tslint.json delete mode 100644 test/rules/semicolon/strict-bound-class-methods/test.ts.fix delete mode 100644 test/rules/semicolon/strict-bound-class-methods/test.ts.lint delete mode 100644 test/rules/semicolon/strict-bound-class-methods/tslint.json delete mode 100644 test/rules/space-before-function-paren/always/test.ts.fix delete mode 100644 test/rules/space-before-function-paren/always/test.ts.lint delete mode 100644 test/rules/space-before-function-paren/always/tslint.json delete mode 100644 test/rules/space-before-function-paren/mixed/test.ts.fix delete mode 100644 test/rules/space-before-function-paren/mixed/test.ts.lint delete mode 100644 test/rules/space-before-function-paren/mixed/tslint.json delete mode 100644 test/rules/space-before-function-paren/never/test.ts.fix delete mode 100644 test/rules/space-before-function-paren/never/test.ts.lint delete mode 100644 test/rules/space-before-function-paren/never/tslint.json delete mode 100644 test/rules/space-within-parens/force-one-space/test.ts.fix delete mode 100644 test/rules/space-within-parens/force-one-space/test.ts.lint delete mode 100644 test/rules/space-within-parens/force-one-space/tslint.json delete mode 100644 test/rules/space-within-parens/force-two-spaces/test.ts.fix delete mode 100644 test/rules/space-within-parens/force-two-spaces/test.ts.lint delete mode 100644 test/rules/space-within-parens/force-two-spaces/tslint.json delete mode 100644 test/rules/space-within-parens/no-space/test.ts.fix delete mode 100644 test/rules/space-within-parens/no-space/test.ts.lint delete mode 100644 test/rules/space-within-parens/no-space/tslint.json delete mode 100644 test/rules/static-this/test.ts.fix delete mode 100644 test/rules/static-this/test.ts.lint delete mode 100644 test/rules/static-this/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-enum/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-enum/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-enum/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-mix/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-mix/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-mix/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-null-union/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-number/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-number/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-number/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-string/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-string/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-string/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/default/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/default/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/default/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/ignore-rhs/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/no-allow-mix/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json delete mode 100644 test/rules/strict-boolean-expressions/no-null-checks/tslint.json delete mode 100644 test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint delete mode 100644 test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json delete mode 100644 test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json delete mode 100644 test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint delete mode 100644 test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json delete mode 100644 test/rules/strict-comparisons/allow-string-order-comparison/tslint.json delete mode 100644 test/rules/strict-comparisons/default/test.ts.lint delete mode 100644 test/rules/strict-comparisons/default/tsconfig.json delete mode 100644 test/rules/strict-comparisons/default/tslint.json delete mode 100644 test/rules/strict-string-expressions/allow-empty-types/test.ts.fix delete mode 100644 test/rules/strict-string-expressions/allow-empty-types/test.ts.lint delete mode 100644 test/rules/strict-string-expressions/allow-empty-types/tsconfig.json delete mode 100644 test/rules/strict-string-expressions/allow-empty-types/tslint.json delete mode 100644 test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix delete mode 100644 test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint delete mode 100644 test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json delete mode 100644 test/rules/strict-string-expressions/disallow-empty-types/tslint.json delete mode 100644 test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint delete mode 100644 test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json delete mode 100644 test/rules/strict-type-predicates/no-strict-null-checks/tslint.json delete mode 100644 test/rules/strict-type-predicates/strict-null-checks/test.ts.lint delete mode 100644 test/rules/strict-type-predicates/strict-null-checks/tsconfig.json delete mode 100644 test/rules/strict-type-predicates/strict-null-checks/tslint.json delete mode 100644 test/rules/strict-type-predicates/unknown/test.ts.lint delete mode 100644 test/rules/strict-type-predicates/unknown/tsconfig.json delete mode 100644 test/rules/strict-type-predicates/unknown/tslint.json delete mode 100644 test/rules/switch-default/test.ts.lint delete mode 100644 test/rules/switch-default/tslint.json delete mode 100644 test/rules/switch-final-break/always/test.ts.fix delete mode 100644 test/rules/switch-final-break/always/test.ts.lint delete mode 100644 test/rules/switch-final-break/always/tslint.json delete mode 100644 test/rules/switch-final-break/default/test.ts.fix delete mode 100644 test/rules/switch-final-break/default/test.ts.lint delete mode 100644 test/rules/switch-final-break/default/tslint.json delete mode 100644 test/rules/trailing-comma/multiline-always/test.ts.fix delete mode 100644 test/rules/trailing-comma/multiline-always/test.ts.lint delete mode 100644 test/rules/trailing-comma/multiline-always/tslint.json delete mode 100644 test/rules/trailing-comma/multiline-custom/always/test.ts.lint delete mode 100644 test/rules/trailing-comma/multiline-custom/always/tslint.json delete mode 100644 test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint delete mode 100644 test/rules/trailing-comma/multiline-custom/ignore/tslint.json delete mode 100644 test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint delete mode 100644 test/rules/trailing-comma/multiline-custom/mixed/tslint.json delete mode 100644 test/rules/trailing-comma/multiline-custom/never/test.ts.fix delete mode 100644 test/rules/trailing-comma/multiline-custom/never/test.ts.lint delete mode 100644 test/rules/trailing-comma/multiline-custom/never/tslint.json delete mode 100644 test/rules/trailing-comma/multiline-never/test.ts.fix delete mode 100644 test/rules/trailing-comma/multiline-never/test.ts.lint delete mode 100644 test/rules/trailing-comma/multiline-never/tslint.json delete mode 100644 test/rules/trailing-comma/singleline-always/test.ts.fix delete mode 100644 test/rules/trailing-comma/singleline-always/test.ts.lint delete mode 100644 test/rules/trailing-comma/singleline-always/tslint.json delete mode 100644 test/rules/trailing-comma/singleline-custom/always/test.ts.fix delete mode 100644 test/rules/trailing-comma/singleline-custom/always/test.ts.lint delete mode 100644 test/rules/trailing-comma/singleline-custom/always/tslint.json delete mode 100644 test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint delete mode 100644 test/rules/trailing-comma/singleline-custom/ignore/tslint.json delete mode 100644 test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint delete mode 100644 test/rules/trailing-comma/singleline-custom/mixed/tslint.json delete mode 100644 test/rules/trailing-comma/singleline-custom/never/test.ts.fix delete mode 100644 test/rules/trailing-comma/singleline-custom/never/test.ts.lint delete mode 100644 test/rules/trailing-comma/singleline-custom/never/tslint.json delete mode 100644 test/rules/trailing-comma/singleline-never/test.ts.fix delete mode 100644 test/rules/trailing-comma/singleline-never/test.ts.lint delete mode 100644 test/rules/trailing-comma/singleline-never/tslint.json delete mode 100644 test/rules/trailing-comma/spec-compliant/test.ts.fix delete mode 100644 test/rules/trailing-comma/spec-compliant/test.ts.lint delete mode 100644 test/rules/trailing-comma/spec-compliant/tslint.json delete mode 100644 test/rules/triple-equals/allow-null-check/test.ts.lint delete mode 100644 test/rules/triple-equals/allow-null-check/tslint.json delete mode 100644 test/rules/triple-equals/allow-undefined-check/test.ts.lint delete mode 100644 test/rules/triple-equals/allow-undefined-check/tslint.json delete mode 100644 test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix delete mode 100644 test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint delete mode 100644 test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json delete mode 100644 test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix delete mode 100644 test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint delete mode 100644 test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json delete mode 100644 test/rules/typedef-whitespace/both/nospace/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/both/nospace/tslint.json delete mode 100644 test/rules/typedef-whitespace/both/onespace/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/both/onespace/tslint.json delete mode 100644 test/rules/typedef-whitespace/both/space/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/both/space/tslint.json delete mode 100644 test/rules/typedef-whitespace/left/nospace/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/left/nospace/tslint.json delete mode 100644 test/rules/typedef-whitespace/left/onespace/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/left/onespace/tslint.json delete mode 100644 test/rules/typedef-whitespace/left/space/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/left/space/tslint.json delete mode 100644 test/rules/typedef-whitespace/none/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/none/tslint.json delete mode 100644 test/rules/typedef-whitespace/right/nospace/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/right/nospace/tslint.json delete mode 100644 test/rules/typedef-whitespace/right/onespace/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/right/onespace/tslint.json delete mode 100644 test/rules/typedef-whitespace/right/space/test.ts.lint delete mode 100644 test/rules/typedef-whitespace/right/space/tslint.json delete mode 100644 test/rules/typedef/all/test.ts.lint delete mode 100644 test/rules/typedef/all/tslint.json delete mode 100644 test/rules/typedef/array-destructuring/test.ts.lint delete mode 100644 test/rules/typedef/array-destructuring/tslint.json delete mode 100644 test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint delete mode 100644 test/rules/typedef/arrow-call-signature-and-parameter/tslint.json delete mode 100644 test/rules/typedef/arrow-call-signature/test.ts.lint delete mode 100644 test/rules/typedef/arrow-call-signature/tslint.json delete mode 100644 test/rules/typedef/arrow-parameter/test.ts.lint delete mode 100644 test/rules/typedef/arrow-parameter/tslint.json delete mode 100644 test/rules/typedef/call-signature/test.ts.lint delete mode 100644 test/rules/typedef/call-signature/tslint.json delete mode 100644 test/rules/typedef/member-variable-declaration/test.ts.lint delete mode 100644 test/rules/typedef/member-variable-declaration/tslint.json delete mode 100644 test/rules/typedef/none/test.ts.lint delete mode 100644 test/rules/typedef/none/tslint.json delete mode 100644 test/rules/typedef/object-destructuring/test.ts.lint delete mode 100644 test/rules/typedef/object-destructuring/tslint.json delete mode 100644 test/rules/typedef/parameter/test.ts.lint delete mode 100644 test/rules/typedef/parameter/tslint.json delete mode 100644 test/rules/typedef/variable-declaration-ignore-function/test.ts.lint delete mode 100644 test/rules/typedef/variable-declaration-ignore-function/tslint.json delete mode 100644 test/rules/typedef/variable-declaration/test.ts.lint delete mode 100644 test/rules/typedef/variable-declaration/tslint.json delete mode 100644 test/rules/typeof-compare/test.ts.lint delete mode 100644 test/rules/typeof-compare/tslint.json delete mode 100644 test/rules/unified-signatures/test.d.ts.lint delete mode 100644 test/rules/unified-signatures/test.ts.lint delete mode 100644 test/rules/unified-signatures/tslint.json delete mode 100644 test/rules/unnecessary-bind/typed/test.ts.lint delete mode 100644 test/rules/unnecessary-bind/typed/tsconfig.json delete mode 100644 test/rules/unnecessary-bind/typed/tslint.json delete mode 100644 test/rules/unnecessary-bind/untyped/test.ts.lint delete mode 100644 test/rules/unnecessary-bind/untyped/tslint.json delete mode 100644 test/rules/unnecessary-constructor/check-super-calls/test.ts.fix delete mode 100644 test/rules/unnecessary-constructor/check-super-calls/test.ts.lint delete mode 100644 test/rules/unnecessary-constructor/check-super-calls/tslint.json delete mode 100644 test/rules/unnecessary-constructor/default/test.ts.fix delete mode 100644 test/rules/unnecessary-constructor/default/test.ts.lint delete mode 100644 test/rules/unnecessary-constructor/default/tslint.json delete mode 100644 test/rules/unnecessary-else/allow-else-if/test.ts.lint delete mode 100644 test/rules/unnecessary-else/allow-else-if/tslint.json delete mode 100644 test/rules/unnecessary-else/default/test.ts.lint delete mode 100644 test/rules/unnecessary-else/default/tslint.json delete mode 100644 test/rules/use-default-type-parameter/test.ts.fix delete mode 100644 test/rules/use-default-type-parameter/test.ts.lint delete mode 100644 test/rules/use-default-type-parameter/tsconfig.json delete mode 100644 test/rules/use-default-type-parameter/tslint.json delete mode 100644 test/rules/use-isnan/test.ts.lint delete mode 100644 test/rules/use-isnan/tslint.json delete mode 100644 test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint delete mode 100644 test/rules/variable-name/allow-leading-trailing-underscore/tslint.json delete mode 100644 test/rules/variable-name/allow-leading-underscore/test.ts.lint delete mode 100644 test/rules/variable-name/allow-leading-underscore/tslint.json delete mode 100644 test/rules/variable-name/allow-pascal-case/test.ts.lint delete mode 100644 test/rules/variable-name/allow-pascal-case/tslint.json delete mode 100644 test/rules/variable-name/allow-snake-case/test.ts.lint delete mode 100644 test/rules/variable-name/allow-snake-case/tslint.json delete mode 100644 test/rules/variable-name/allow-trailing-underscore/test.ts.lint delete mode 100644 test/rules/variable-name/allow-trailing-underscore/tslint.json delete mode 100644 test/rules/variable-name/ban-keywords/test.ts.lint delete mode 100644 test/rules/variable-name/ban-keywords/tslint.json delete mode 100644 test/rules/variable-name/const-only-for-caps/test.ts.lint delete mode 100644 test/rules/variable-name/const-only-for-caps/tslint.json delete mode 100644 test/rules/variable-name/default/test.ts.lint delete mode 100644 test/rules/variable-name/default/tslint.json delete mode 100644 test/rules/whitespace/all/bom.ts.lint delete mode 100644 test/rules/whitespace/all/import-type.lint delete mode 100644 test/rules/whitespace/all/import.ts.lint delete mode 100644 test/rules/whitespace/all/test.ts.fix delete mode 100644 test/rules/whitespace/all/test.ts.lint delete mode 100644 test/rules/whitespace/all/tslint.json delete mode 100644 test/rules/whitespace/check-postbrace/test.ts.fix delete mode 100644 test/rules/whitespace/check-postbrace/test.ts.lint delete mode 100644 test/rules/whitespace/check-postbrace/tslint.json delete mode 100644 test/rules/whitespace/check-separator/test.ts.lint delete mode 100644 test/rules/whitespace/check-separator/tslint.json delete mode 100644 test/rules/whitespace/none/test.ts.lint delete mode 100644 test/rules/whitespace/none/tslint.json diff --git a/test/rules/_integration/enable-disable/test.ts.lint b/test/rules/_integration/enable-disable/test.ts.lint deleted file mode 100644 index 3aae677ef36..00000000000 --- a/test/rules/_integration/enable-disable/test.ts.lint +++ /dev/null @@ -1,146 +0,0 @@ -/* tslint:enable */ -var AAAaA = 'test' - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] -/* tslint:disable */ -var AAAaA = 'test' -/* tslint:disable */ -var AAAaA = 'test' -/* tslint:enable:quotemark */ -var AAAaA = 'test' - ~~~~~~ [' should be "] -/* tslint:enable */ -var AAAaA = 'test' - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] -/* tslint:disable:quotemark variable-name */ -var AAAaA = 'test' -/* tslint:disable:quotemark */ -var AAAaA = 'test' -/* tslint:enable:quotemark */ -var AAAaA = 'test' - ~~~~~~ [' should be "] -/* tslint:disable */ -var AAAaA = 'test' -/* tslint:enable:zasdadsa */ -var AAAaA = 'test' - -/* tslint:enable quotemark */ -var AAAaA = 'test' - ~~~~~~ [' should be "] -/* tslint:disable */ -var AAAaA = 'test' -/* tslint:enable quotemark variable-name */ -var AAAaA = 'test' - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] -/* tslint:disable quotemark */ -var AAAaA = 'test' - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -/* tslint:enable */ -var re; -re = /`/; - -// tslint:disable -var AAAaA = 'test' -// tslint:enable - -var AAAaA = 'test' // tslint:disable-line -var AAAaA = 'test' /* tslint:disable-line */ - -// tslint:disable-next-line:quotemark variable-name -var AAAaA = 'test' -/* tslint:disable-next-line:quotemark variable-name */ -var AAAaA = 'test' - -// tslint:disable -var AAAaA = 'test' // tslint:enable-line:quotemark - ~~~~~~ [' should be "] -// tslint:enable-next-line:variable-name -var AAAaA = 'test' - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -// tslint:enable - -/* tslint:disable:quotemark */ -var s = 'xxx'; - -// Test case for issue #1624 -// tslint:disable:quotemark variable-name -var AAAaA = 'test' // tslint:disable-line:quotemark -// tslint:disable-next-line:variable-name -var AAAaA = 'test' // previously `quotemark` rule was enabled after previous line - -var AAAaA = 'test' // previously both `quotemark` and `variable-name` rules were enabled after previous lines - -// tslint:enable:quotemark -// tslint:disable -var AAAaA = 'test' // tslint:disable-line:quotemark -var AAAaA = 'test' // ensure that disable-line rule correctly handles previous `enable rule - disable all` switches - -// tslint:enable:no-var-keyword -var AAAaA = 'test' // ensure that disabled in config rule isn't enabled - -/* tslint:enable-next-line: */ -var AAAaA = 'test' // ensure that nothing is enabled with explicit separator and empty list of rules - -/* tslint:enable-next-line quotemark*/ -var AAAaA = 'test' // ensure that comment end is handled correctly with implicit separator - ~~~~~~ [' should be "] - -/* tslint:enable-next-line:quotemark*/ -var AAAaA = 'test' // ensure that comment end is handled correctly with explicit separator - ~~~~~~ [' should be "] - -// ensure that line switches switch the whole line -var AAAaA = 'test'; /* tslint:enable-line quotemark */ var AAAaA = 'test' - ~~~~~~ [' should be "] - ~~~~~~ [' should be "] -var AAAaA = 'test' // line should not be affected - -// ensure that next-line switch only switches next line -var AAAaA = 'test'; /*tslint:enable-next-line*/ var AAAaA = 'test' -var AAAaA = 'test' - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] -var AAAaA = 'test' -var AAAaA = 'test'; //tslint:enable-next-line - - -// ensure that enable/disable switch switches at start of comment -var AAAaA = 'test'; //tslint:enable - ~~~~~~~~~~~~~ [comment must start with a space] -var AAAaA = 'test'; //tslint:disable - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] -var AAAaA = 'test' - -// ensure that "all" switches all rules -var AAAaA = 'test'; //tslint:enable-line all - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] - ~~~~~~~~~~~~~~~~~~~~~~ [comment must start with a space] - -// ensure that "all" switches all rules even if others are in the list -var AAAaA = 'test'; //tslint:enable-line quotemark all - ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~ [' should be "] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [comment must start with a space] - -// ensure line switches only switch the next line -//tslint:enable-next-line:quotemark -'foo'; -~~~~~ [' should be "] -'bar'; -'baz'; // tslint:enable-line:quotemark -~~~~~ [' should be "] -'bas'; - -//tslint:enable:quotemark -//tslint:disable-next-line:quotemark -'foo'; -'bar'; -~~~~~ [' should be "] -'baz'; // tslint:disable-line:quotemark -'bas'; -~~~~~ [' should be "] diff --git a/test/rules/_integration/enable-disable/test.tsx.lint b/test/rules/_integration/enable-disable/test.tsx.lint deleted file mode 100644 index e6bab97957b..00000000000 --- a/test/rules/_integration/enable-disable/test.tsx.lint +++ /dev/null @@ -1,69 +0,0 @@ -const span = ( - - /* tslint:disable */ - { - x + 'test' - ~~~~~~ [' should be "] - } - text - -); - -const span = ( - - // tslint:disable-next-line - {x + 'test'} - ~~~~~~ [' should be "] - text - -); - -const span = ( - - {x + 'comment is ignored with text'} // tslint:disable-line - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] - works with text - -); - -const span = ( - - {x + 'comment is ignored without text'} // tslint:disable-line - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] - -); - -const span = ( - - /* tslint:disable */ {x + 'ignores comments before element if not root'} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] - -); - -const span = ( - - {x + 'ignores comments after element if not root'} /* tslint:disable-line */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] - -); - -const span = ( - /* tslint:disable-next-line */ - {x + 'ignores trailing comments of root element'} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] - -); - -const span = ( - - {{x + 'works for comments inside JsxExpression'} /* tslint:disable-line */} - -); - -const span = ( - - {/* tslint:disable-next-line */} - {x + 'works for comment-only expressions'} - text - -); diff --git a/test/rules/_integration/enable-disable/tslint.json b/test/rules/_integration/enable-disable/tslint.json deleted file mode 100644 index 7038f339ba2..00000000000 --- a/test/rules/_integration/enable-disable/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double"], - "variable-name": true, - "no-var-keyword": false, - "comment-format": [ - true, - "check-space" - ] - } -} diff --git a/test/rules/_integration/error-format/test.ts.lint b/test/rules/_integration/error-format/test.ts.lint deleted file mode 100644 index bb67e417440..00000000000 --- a/test/rules/_integration/error-format/test.ts.lint +++ /dev/null @@ -1,37 +0,0 @@ -import {} from 'foo'; - -let noSubstitution; - ~~~~~~~~~~~~~~ [Identifier 'noSubstitution' is never reassigned; use 'const' instead of 'let'.] -let noFormat; - ~~~~~~~~ [no_format] -let format; - ~~~~~~ [let_base % ('format')] -let formatMultiArgs; - ~~~~~~~~~~~~~~~ [base % ('formatMultiArgs', 'let')] -var formatMultiArgsTrailingComma; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [base % ('formatMultiArgsTrailingComma', 'var', )] -let indirection; - ~~~~~~~~~~~ [let % ('indirection')] -var indirection2; - ~~~~~~~~~~~~ [var % ('indirection2')] -let indirection3; - ~~~~~~~~~~~~ [partial_format % ('let')] -var formatInSubstitution; - ~~~~~~~~~~~~~~~~~~~~ [preformatted] -let worksWithEscape; - ~~~~~~~~~~~~~~~ [full-substitution % ('Identifier \'worksWithEscape\' is never reassigned; use \'const\' instead of \'let\'.')] -var worksWithDoubleQuotes; - ~~~~~~~~~~~~~~~~~~~~~ [full-substitution % ("Identifier 'worksWithDoubleQuotes' is never reassigned; use 'const' instead of 'var'.")] -let doesntTrimSpaces; - ~~~~~~~~~~~~~~~~ [base3 % ("Identifier 'doesntTrimSpaces' is never reassigned; ", " 'let'")] - -[no_format]: Identifier 'noFormat' is never reassigned; use 'const' instead of 'let'. -[base]: Identifier '%s' is never reassigned; use 'const' instead of '%s'. -[let_base]: Identifier '%s' is never reassigned; use 'const' instead of 'let'. -[base2]: Identifier '%%s' is never reassigned; use 'const' instead of '%s'. -[let]: base2 % ('let') -[var]: base2 % ('var') -[partial_format]: base % ('indirection3') -[preformatted]: base % ('formatInSubstitution', 'var') -[full-substitution]: %s -[base3]: %suse 'const' instead of%s. \ No newline at end of file diff --git a/test/rules/_integration/error-format/tslint.json b/test/rules/_integration/error-format/tslint.json deleted file mode 100644 index 369865b3ae9..00000000000 --- a/test/rules/_integration/error-format/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-const": true - } -} diff --git a/test/rules/_integration/react/invalid.tsx.lint b/test/rules/_integration/react/invalid.tsx.lint deleted file mode 100644 index de36dea81c9..00000000000 --- a/test/rules/_integration/react/invalid.tsx.lint +++ /dev/null @@ -1,6 +0,0 @@ -// don't crash on invalid jsx -// tslint:disable -const a = - - diff --git a/test/rules/_integration/react/test.tsx.lint b/test/rules/_integration/react/test.tsx.lint deleted file mode 100644 index cd7b705f2b2..00000000000 --- a/test/rules/_integration/react/test.tsx.lint +++ /dev/null @@ -1,58 +0,0 @@ -import * as React from 'react'; // quotemark failure - ~~~~~~~ [' should be "] - -class BazComponent extends React.Component, {}> { - public render() { - return ( -
- ); - } -} - -interface IFooProps extends React.Props { - fooProp: string; -} - -interface IFooState { - bar:string[]; // whitespace failure - ~ [missing whitespace] -} - -export class FooComponent extends React.Component { - public state = { - bar: [] as string[] - }; - - public render() { - return ( -
this.onClick()} class={true===false?"foo":"bar"}> - ~ [missing whitespace] - ~ [missing whitespace] - ~ [missing whitespace] - ~ [missing whitespace] - ~ [missing whitespace] - ~ [missing whitespace] - {this.state.bar.map((s) => {s})} - -
- ); - } // indent failure -~ [space indentation expected] - - private onClick() { - console.info("foo component clicked"); - } -} - -export function buildFooComponent(): JSX.Element { - let x: string = "test"; - return ; -} - -// test false positive for JSX spread (https://github.com/palantir/tslint/issues/658) -class MyComponent extends React.Component<{}, {}> { - public render() { - let props = { foo: "bar" }; - return
; - } -} diff --git a/test/rules/_integration/react/tslint.json b/test/rules/_integration/react/tslint.json deleted file mode 100644 index bf90872d231..00000000000 --- a/test/rules/_integration/react/tslint.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "rules": { - "curly": true, - "eofline": true, - "indent": [true, "spaces"], - "max-line-length": [true, 120], - "no-bitwise": true, - "no-unused-expression": true, - "quotemark": [true, "double"], - "semicolon": [true, "always"], - "whitespace": [true, - "check-branch", - "check-decl", - "check-operator", - "check-module", - "check-separator", - "check-type", - "check-typecast" - ] - } -} diff --git a/test/rules/_integration/typescript-version/correct.js.lint b/test/rules/_integration/typescript-version/correct.js.lint deleted file mode 100644 index c73eab3c737..00000000000 --- a/test/rules/_integration/typescript-version/correct.js.lint +++ /dev/null @@ -1,3 +0,0 @@ -[typescript]: >= 2.0.0 -'foo'; -~~~~~ [' should be "] \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/correct.ts.fix b/test/rules/_integration/typescript-version/correct.ts.fix deleted file mode 100644 index 00d7c9624e9..00000000000 --- a/test/rules/_integration/typescript-version/correct.ts.fix +++ /dev/null @@ -1 +0,0 @@ -"foo"; \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/correct.ts.lint b/test/rules/_integration/typescript-version/correct.ts.lint deleted file mode 100644 index c73eab3c737..00000000000 --- a/test/rules/_integration/typescript-version/correct.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -[typescript]: >= 2.0.0 -'foo'; -~~~~~ [' should be "] \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/if-else.ts.lint b/test/rules/_integration/typescript-version/if-else.ts.lint deleted file mode 100644 index a30dcdf1ce6..00000000000 --- a/test/rules/_integration/typescript-version/if-else.ts.lint +++ /dev/null @@ -1,21 +0,0 @@ -'foo'; -~~~~~ [' should be "] -#if typescript 0.0.0 -'bar' -#else -"bar" -#endif - -#if typescript >= 2.0.0 -'baz' -#else -"baz" -#endif -~~~~~ [err] - -'bas' -~~~~~ [err] - -#if typescript >= 2.0.0 -[err]: ' should be " -#endif diff --git a/test/rules/_integration/typescript-version/skip.js.lint b/test/rules/_integration/typescript-version/skip.js.lint deleted file mode 100644 index 75aca5a3539..00000000000 --- a/test/rules/_integration/typescript-version/skip.js.lint +++ /dev/null @@ -1,2 +0,0 @@ -[typescript]: < 2.0.0 -'foo'; \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/skip.ts.lint b/test/rules/_integration/typescript-version/skip.ts.lint deleted file mode 100644 index 0cb99adb064..00000000000 --- a/test/rules/_integration/typescript-version/skip.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -[typescript]: 0.0.0 -'foo'; \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/substitution.ts.lint b/test/rules/_integration/typescript-version/substitution.ts.lint deleted file mode 100644 index d0b23d919e3..00000000000 --- a/test/rules/_integration/typescript-version/substitution.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -[typescript]: >= 2.0.0 -'foo'; // substition has the same key as the version requirement, but still works -~~~~~ [typescript] -[typescript]: ' should be " \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/tslint.json b/test/rules/_integration/typescript-version/tslint.json deleted file mode 100644 index 4e380ea41bb..00000000000 --- a/test/rules/_integration/typescript-version/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double"] - }, - "jsRules": { - "quotemark": [true, "double"] - } -} diff --git a/test/rules/adjacent-overload-signatures/default/test.ts.lint b/test/rules/adjacent-overload-signatures/default/test.ts.lint deleted file mode 100644 index 13bb2c09867..00000000000 --- a/test/rules/adjacent-overload-signatures/default/test.ts.lint +++ /dev/null @@ -1,166 +0,0 @@ -// good - -interface i1 { - a(); - a(x: number); - b(); - b(x: string); -} - -interface i2 { - a(); - a(x: number); - a(): void; - b(); - b(x: string); -} - -interface i3 { - a(); - "a"(); -} - -interface i4 { - a(); - ["a"](); -} - -interface i5 { - a(): string; - bar: { - a(): number; - } -} - -interface i6 { - // ensure no false positives for properties/methods available from prototype chain - toString(): string; -} - -interface i7 { - // Computed properties with different source code text OK - [Symbol.iterator](): void; - [Symbol.toStringTag](): void; -} - -interface i8 { - // Computed property with same source code text as regular property OK - [Symbol.iterator](): void; - x: number; - "Symbol.iterator"(): void; -} - - -// bad - -interface b1 { - a(); - a(x: number); - b(); - b(x: string); - a(x: string); - ~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] -} - -interface b2 { - a(); - a(x: number); - b(); - b(x: string); - a(): void; - ~~~~~~~~~~ [All 'a' signatures should be adjacent] -} - -interface b3 { - a(); - 12(); - "a"(); - ~~~~~~ [All 'a' signatures should be adjacent] - 12(); - ~~~~~ [All '12' signatures should be adjacent] -} - -interface b4 { - a(); - b(): void; - ["a"](v: number): void; - ~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] -} - -interface b5 { - a(): string; - bar: { - a(): number; - b(); - a(b: number): void; - ~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] - } -} - -interface b6 { - (): void; - x: number; - (x: number): number; - ~~~~~~~~~~~~~~~~~~~~ [All '()' signatures should be adjacent] -} - -// Also works in classes, source files, modules, namespaces - -class C { - a(): void; - b(): void; - a(x: number): void; - ~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] -} - -declare function a(): void; -declare function b(): void; -declare function a(x: number): void; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] - -declare module "m" { - export function a(): void; - export function b(): void; - export function a(x: number): void; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] -} - -declare namespace N { - export function a(): void; - export function b(): void; - export function a(x: number): void; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] -} - -class Foo { - public static bar() {} - private constructor() {} - public bar() {} - public constructor(foo: any) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'constructor' signatures should be adjacent] -} - -// A semicolon on its own is a SemicolonClassElement, but still consider them adjacent. -class Bar { - get test() { return 0; }; - set test(v: number) {}; -} - -interface I { - // Catches computed properties with same source code text - [Symbol.iterator](): void; - x: number; - [Symbol.iterator](): void; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'Symbol.iterator' signatures should be adjacent] -} - -class Accessors { - private x: number; - private y: number; - get x() {return this.x;} - get y() {return this.y;} - set x(newX: number) {this.x = newX;} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'x' signatures should be adjacent] - set y(newY: number) {this.y = newY;} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'y' signatures should be adjacent] -} diff --git a/test/rules/adjacent-overload-signatures/default/tslint.json b/test/rules/adjacent-overload-signatures/default/tslint.json deleted file mode 100644 index 69957950dd9..00000000000 --- a/test/rules/adjacent-overload-signatures/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "adjacent-overload-signatures": true - } -} diff --git a/test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint b/test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint deleted file mode 100644 index 536581f2871..00000000000 --- a/test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint +++ /dev/null @@ -1,11 +0,0 @@ -// good - -class Accessors { - private x: number; - private y: number; - get x() {return this.x;} - get y() {return this.y;} - // setter is not considered as an overload of getter - set x(newX: number) {this.x = newX;} - set y(newY: number) {this.y = newY;} -} diff --git a/test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json b/test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json deleted file mode 100644 index 76ecf8ce198..00000000000 --- a/test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "adjacent-overload-signatures": [true, { "ignore-accessors": true }] - } -} diff --git a/test/rules/align/arguments/test.ts.fix b/test/rules/align/arguments/test.ts.fix deleted file mode 100644 index 7f30959b034..00000000000 --- a/test/rules/align/arguments/test.ts.fix +++ /dev/null @@ -1,149 +0,0 @@ -function invalidParametersAlignment1(a: number, -b: number) { - var i = 0; -} - -function invalidParametersAlignment2(a: number, b: number, -c: number) { - var i = 0; -} - -function invalidParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -class C1 { - invalidParametersAlignment(a: number, - b: number) - { - } -} - -class InvalidAlignmentInConstructor { - constructor(a: number, - str: string) - { - } -} - -var invalidParametersAlignment4 = function(xxx: foo, - yyy: bar) { return true; } - -function validParametersAlignment1(a: number, b: number) { - var i = 0; -} - -function validParametersAlignment2(a: number, b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment4( - a: number, - b: number, - c: number) { - var i = 0; -} - -var validParametersAlignment6 = function(xxx: foo, - yyy: bar) { return true; } - -/////// - -function invalidArgumentsAlignment1() -{ - f(10, - 'abcd', 0); -} - -function invalidArgumentsAlignment2() -{ - f(10, - 'abcd', - 0); - -} - -class Foo { - constructor(a: number, - str: string) - { - } -} - -var invalidConstructorArgsAlignment = new foo(10, - "abcd"); - -function validArgumentsAlignment1() -{ - f(101, 'xyz', 'abc'); -} - -function validArgumentsAlignment2() -{ - f(1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f( - 1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f(1, 2, - 3, 4); -} - -//////// - -function invalidStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function invalidStatementsAlignment1() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function validStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function validStatementsAlignment2() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function shouldntCrash() { - let f = new Foo; -} diff --git a/test/rules/align/arguments/test.ts.lint b/test/rules/align/arguments/test.ts.lint deleted file mode 100644 index 0202a35c2fd..00000000000 --- a/test/rules/align/arguments/test.ts.lint +++ /dev/null @@ -1,152 +0,0 @@ -function invalidParametersAlignment1(a: number, -b: number) { - var i = 0; -} - -function invalidParametersAlignment2(a: number, b: number, -c: number) { - var i = 0; -} - -function invalidParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -class C1 { - invalidParametersAlignment(a: number, - b: number) - { - } -} - -class InvalidAlignmentInConstructor { - constructor(a: number, - str: string) - { - } -} - -var invalidParametersAlignment4 = function(xxx: foo, - yyy: bar) { return true; } - -function validParametersAlignment1(a: number, b: number) { - var i = 0; -} - -function validParametersAlignment2(a: number, b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment4( - a: number, - b: number, - c: number) { - var i = 0; -} - -var validParametersAlignment6 = function(xxx: foo, - yyy: bar) { return true; } - -/////// - -function invalidArgumentsAlignment1() -{ - f(10, - 'abcd', 0); - ~~~~~~ [arguments are not aligned] -} - -function invalidArgumentsAlignment2() -{ - f(10, - 'abcd', - 0); - ~ [arguments are not aligned] - -} - -class Foo { - constructor(a: number, - str: string) - { - } -} - -var invalidConstructorArgsAlignment = new foo(10, - "abcd"); - ~~~~~~ [arguments are not aligned] - -function validArgumentsAlignment1() -{ - f(101, 'xyz', 'abc'); -} - -function validArgumentsAlignment2() -{ - f(1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f( - 1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f(1, 2, - 3, 4); -} - -//////// - -function invalidStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function invalidStatementsAlignment1() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function validStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function validStatementsAlignment2() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function shouldntCrash() { - let f = new Foo; -} diff --git a/test/rules/align/arguments/tslint.json b/test/rules/align/arguments/tslint.json deleted file mode 100644 index 642cc953dcf..00000000000 --- a/test/rules/align/arguments/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "align": [true, "arguments"] - } -} diff --git a/test/rules/align/elements/test.ts.fix b/test/rules/align/elements/test.ts.fix deleted file mode 100644 index 9c67ce0083a..00000000000 --- a/test/rules/align/elements/test.ts.fix +++ /dev/null @@ -1,47 +0,0 @@ -let foo = []; -let foo = [1, 2]; -let foo = [ - 1, 2 -]; -let foo = [ - 1, - 2 -]; -let foo = [ - 1, - 2 -]; -let foo = [ - ...foo, - 1 -]; -let foo = [ - , - 1, - , - , -]; -let foo = [ - , - 1, - , - , -] - -let [foo, bar] = foo; -let [ - foo, bar -] = foo; -let [foo, - bar -] = foo; -let [ - , - ...foo -] = foo; - -let foo: [number, number]; -let foo = [ - number - , number -] \ No newline at end of file diff --git a/test/rules/align/elements/test.ts.lint b/test/rules/align/elements/test.ts.lint deleted file mode 100644 index bcada281103..00000000000 --- a/test/rules/align/elements/test.ts.lint +++ /dev/null @@ -1,53 +0,0 @@ -let foo = []; -let foo = [1, 2]; -let foo = [ - 1, 2 -]; -let foo = [ - 1, - 2 -]; -let foo = [ - 1, - 2 - ~ [elements are not aligned] -]; -let foo = [ - ...foo, - 1 - ~ [elements are not aligned] -]; -let foo = [ - , - 1, - , - , -]; -let foo = [ - , - 1, - ~ [elements are not aligned] - , - ~nil [elements are not aligned] - , -] - -let [foo, bar] = foo; -let [ - foo, bar -] = foo; -let [foo, - bar - ~~~ [elements are not aligned] -] = foo; -let [ - , - ...foo -] = foo; - -let foo: [number, number]; -let foo = [ - number - , number - ~~~~~~ [elements are not aligned] -] \ No newline at end of file diff --git a/test/rules/align/elements/tslint.json b/test/rules/align/elements/tslint.json deleted file mode 100644 index ce5e6722b9d..00000000000 --- a/test/rules/align/elements/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "align": [true, "elements"] - } -} diff --git a/test/rules/align/members/test.ts.fix b/test/rules/align/members/test.ts.fix deleted file mode 100644 index 8b59a0a624e..00000000000 --- a/test/rules/align/members/test.ts.fix +++ /dev/null @@ -1,40 +0,0 @@ -interface Foo { - bar, - baz - bas - foo; -} - -class Foo { - bar, - baz() { - - }; - get bas() {} - foo; -} - -let Bar = class { - bar, - foo -} - -let foo = { - foo, - moep, - baz, - baz: foo, -} - -let { - foo, - boo, - baz, - baz, -} = foo; - -let foo: { - foo - bar - baz -} diff --git a/test/rules/align/members/test.ts.lint b/test/rules/align/members/test.ts.lint deleted file mode 100644 index 51a20b69be1..00000000000 --- a/test/rules/align/members/test.ts.lint +++ /dev/null @@ -1,53 +0,0 @@ -interface Foo { - bar, - baz - bas - ~~~ [0] - foo; - ~~~~ [0] -} - -class Foo { - bar, - baz() { - - }; - get bas() {} - ~~~~~~~~~~~~ [0] - foo; - ~~~~ [0] -} - -let Bar = class { - bar, - foo - ~~~ [0] -} - -let foo = { - foo, - moep, - baz, - ~~~ [0] - baz: foo, - ~~~~~~~~ [0] -} - -let { - foo, - boo, - baz, - ~~~ [0] - baz, - ~~~ [0] -} = foo; - -let foo: { - foo - bar - ~~~ [0] - baz - ~~~ [0] -} - -[0]: members are not aligned \ No newline at end of file diff --git a/test/rules/align/members/tslint.json b/test/rules/align/members/tslint.json deleted file mode 100644 index ee50416d766..00000000000 --- a/test/rules/align/members/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "align": [true, "members"] - } -} diff --git a/test/rules/align/parameters/test.ts.fix b/test/rules/align/parameters/test.ts.fix deleted file mode 100644 index 476991849a0..00000000000 --- a/test/rules/align/parameters/test.ts.fix +++ /dev/null @@ -1,32 +0,0 @@ -function invalidParametersAlignment1(a: number, - b: number) { - var i = 0; -} - -function invalidParametersAlignment2(a: number, b: number, - c: number) { - var i = 0; -} - -function invalidParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -class C1 { - invalidParametersAlignment(a: number, - b: number) - { - } -} - -class InvalidAlignmentInConstructor { - constructor(a: number, - str: string) - { - } -} - -var invalidParametersAlignment4 = function(xxx: foo, - yyy: bar) { return true; } diff --git a/test/rules/align/parameters/test.ts.lint b/test/rules/align/parameters/test.ts.lint deleted file mode 100644 index a38a5152672..00000000000 --- a/test/rules/align/parameters/test.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -function invalidParametersAlignment1(a: number, -b: number) { -~~~~~~~~~ [parameters are not aligned] - var i = 0; -} - -function invalidParametersAlignment2(a: number, b: number, -c: number) { -~~~~~~~~~ [parameters are not aligned] - var i = 0; -} - -function invalidParametersAlignment3(a: number, - b: number, - ~~~~~~~~~ [parameters are not aligned] - c: number) { - ~~~~~~~~~ [parameters are not aligned] - var i = 0; -} - -class C1 { - invalidParametersAlignment(a: number, - b: number) - ~~~~~~~~~ [parameters are not aligned] - { - } -} - -class InvalidAlignmentInConstructor { - constructor(a: number, - str: string) - ~~~~~~~~~~~ [parameters are not aligned] - { - } -} - -var invalidParametersAlignment4 = function(xxx: foo, - yyy: bar) { return true; } - ~~~~~~~~ [parameters are not aligned] diff --git a/test/rules/align/parameters/tslint.json b/test/rules/align/parameters/tslint.json deleted file mode 100644 index b9360403062..00000000000 --- a/test/rules/align/parameters/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "align": [true, "parameters"] - } -} diff --git a/test/rules/align/statements/bom.ts.fix b/test/rules/align/statements/bom.ts.fix deleted file mode 100644 index 1168a0b3915..00000000000 --- a/test/rules/align/statements/bom.ts.fix +++ /dev/null @@ -1,3 +0,0 @@ -var foo = 1; -var bar = 2; -var baz = 3; diff --git a/test/rules/align/statements/bom.ts.lint b/test/rules/align/statements/bom.ts.lint deleted file mode 100644 index 9defdf3f4f5..00000000000 --- a/test/rules/align/statements/bom.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -var foo = 1; -var bar = 2; - var baz = 3; - ~~~~~~~~~~~~ [statements are not aligned] diff --git a/test/rules/align/statements/test.ts.fix b/test/rules/align/statements/test.ts.fix deleted file mode 100644 index ab62ae38cc1..00000000000 --- a/test/rules/align/statements/test.ts.fix +++ /dev/null @@ -1,157 +0,0 @@ -function invalidParametersAlignment1(a: number, -b: number) { - var i = 0; -} - -function invalidParametersAlignment2(a: number, b: number, -c: number) { - var i = 0; -} - -function invalidParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -class C1 { - invalidParametersAlignment(a: number, - b: number) - { - } -} - -class InvalidAlignmentInConstructor { - constructor(a: number, - str: string) - { - } -} - -var invalidParametersAlignment4 = function(xxx: foo, - yyy: bar) { return true; } - -function validParametersAlignment1(a: number, b: number) { - var i = 0; -} - -function validParametersAlignment2(a: number, b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment4( - a: number, - b: number, - c: number) { - var i = 0; -} - -var validParametersAlignment6 = function(xxx: foo, - yyy: bar) { return true; } - - -/////// - -function invalidArgumentsAlignment1() -{ - f(10, - 'abcd', 0); -} - -function invalidArgumentsAlignment2() -{ - f(10, - 'abcd', - 0); -} - -class Foo { - constructor(a: number, - str: string) - { - } -} - -var invalidConstructorArgsAlignment = new foo(10, - "abcd"); - -function validArgumentsAlignment1() -{ - f(101, 'xyz', 'abc'); -} - -function validArgumentsAlignment2() -{ - f(1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f( - 1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f(1, 2, - 3, 4); -} - -//////// - -function invalidStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function invalidStatementsAlignment1() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function validStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function validStatementsAlignment2() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function shouldntCrash() { - let f = new Foo; -} - -if (foo) { - bar; -}; - -if (foo) { - bar; -} /* should not be removed */; diff --git a/test/rules/align/statements/test.ts.lint b/test/rules/align/statements/test.ts.lint deleted file mode 100644 index 412c6dfdd81..00000000000 --- a/test/rules/align/statements/test.ts.lint +++ /dev/null @@ -1,159 +0,0 @@ -function invalidParametersAlignment1(a: number, -b: number) { - var i = 0; -} - -function invalidParametersAlignment2(a: number, b: number, -c: number) { - var i = 0; -} - -function invalidParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -class C1 { - invalidParametersAlignment(a: number, - b: number) - { - } -} - -class InvalidAlignmentInConstructor { - constructor(a: number, - str: string) - { - } -} - -var invalidParametersAlignment4 = function(xxx: foo, - yyy: bar) { return true; } - -function validParametersAlignment1(a: number, b: number) { - var i = 0; -} - -function validParametersAlignment2(a: number, b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment3(a: number, - b: number, - c: number) { - var i = 0; -} - -function validParametersAlignment4( - a: number, - b: number, - c: number) { - var i = 0; -} - -var validParametersAlignment6 = function(xxx: foo, - yyy: bar) { return true; } - - -/////// - -function invalidArgumentsAlignment1() -{ - f(10, - 'abcd', 0); -} - -function invalidArgumentsAlignment2() -{ - f(10, - 'abcd', - 0); -} - -class Foo { - constructor(a: number, - str: string) - { - } -} - -var invalidConstructorArgsAlignment = new foo(10, - "abcd"); - -function validArgumentsAlignment1() -{ - f(101, 'xyz', 'abc'); -} - -function validArgumentsAlignment2() -{ - f(1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f( - 1, - 2, - 3, - 4); -} - -function validArgumentsAlignment3() -{ - f(1, 2, - 3, 4); -} - -//////// - -function invalidStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; - ~~~~~~~~~~ [statements are not aligned] -} - -function invalidStatementsAlignment1() -{ - var i = 0; - { - var j = 0; - var k = 1; - ~~~~~~~~~~ [statements are not aligned] - } -} - -function validStatementsAlignment1() -{ - var i = 0; - var j = 0; - var k = 1; -} - -function validStatementsAlignment2() -{ - var i = 0; - { - var j = 0; - var k = 1; - } -} - -function shouldntCrash() { - let f = new Foo; -} - -if (foo) { - bar; -}; - -if (foo) { - bar; -} /* should not be removed */; diff --git a/test/rules/align/statements/tslint.json b/test/rules/align/statements/tslint.json deleted file mode 100644 index 3bd25ec81d8..00000000000 --- a/test/rules/align/statements/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "align": [true, "statements"] - } -} diff --git a/test/rules/array-type/array-simple/test.ts.fix b/test/rules/array-type/array-simple/test.ts.fix deleted file mode 100644 index 9fe94f1a5af..00000000000 --- a/test/rules/array-type/array-simple/test.ts.fix +++ /dev/null @@ -1,65 +0,0 @@ -let x: undefined[] = [undefined] as undefined[]; -let xx: object[] = []; -let y: string[] = ["2"]; -let z: any[] = [3, "4"]; -let u: unknown[] = []; - -let xx: number[][] = [[1, 2], [3]]; -let yy: number[][] = [[4, 5], [6]]; - -let ya = [[1, "2"]] as Array<[number, string]>; - -type Arr = T[]; -type ParenthesisArr = (T)[]; -type DoubleParenthesisArr = ((T))[]; - -// Ignore user defined aliases -let yyyy: Arr>>> = [[[["2"]]]]; - -interface ArrayClass { - foo: T[]; - bar: T[]; - baz: Arr; - xyz: this[]; -} - -function fooFunction(foo: Array>) { - return foo.map(e => e.foo); -} - -function barFunction(bar: Array>) { - return bar.map(e => e.bar); -} - -function bazFunction(baz: Arr>) { - return baz.map(e => e.baz); -} - -let fooVar: Array<(c: number) => number>; -let barVar: Array<(c: number) => number>; - -type fooUnion = Array; -type barUnion = Array; -type bazUnion = Array<(string|number|boolean)>; - -type fooIntersection = Array; -type barIntersection = Array; -type bazIntersection = Array<(string & number)>; - -namespace fooName { - type BarType = { bar: string }; - type BazType = Arr; -} - -let v: fooName.BarType[] = [{ bar: "bar" }]; - -let w: Array> = [["baz"]]; - -interface FooInterface { - '.bar': {baz: string[];}; -} - -// Test an unknown Array -let t: unknown[] = []; -let u: unknown[] = []; - diff --git a/test/rules/array-type/array-simple/test.ts.lint b/test/rules/array-type/array-simple/test.ts.lint deleted file mode 100644 index 18605baac0f..00000000000 --- a/test/rules/array-type/array-simple/test.ts.lint +++ /dev/null @@ -1,86 +0,0 @@ -let x: Array = [undefined] as undefined[]; - ~~~~~~~~~~~~~~~~ [0] -let xx: Array = []; - ~~~~~~~~~~~~~ [0] -let y: string[] = >["2"]; - ~~~~~~~~~~~~~ [0] -let z: Array = [3, "4"]; - ~~~~~ [0] -let u: Array = []; - ~~~~~~~~~~~~~~ [0] - -let xx: Array> = [[1, 2], [3]]; - ~~~~~~~~~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~~ [0] -let yy: number[][] = [[4, 5], [6]]; - -let ya = [[1, "2"]] as[number, string][]; - ~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - -type Arr = Array; - ~~~~~~~~ [0] -type ParenthesisArr = (T)[]; -type DoubleParenthesisArr = ((T))[]; - -// Ignore user defined aliases -let yyyy: Arr>[]> = [[[["2"]]]]; - ~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - -interface ArrayClass { - foo: Array; - ~~~~~~~~ [0] - bar: T[]; - baz: Arr; - xyz: this[]; -} - -function fooFunction(foo: Array>) { - return foo.map(e => e.foo); -} - -function barFunction(bar: ArrayClass[]) { - ~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - return bar.map(e => e.bar); -} - -function bazFunction(baz: Arr>) { - return baz.map(e => e.baz); -} - -let fooVar: Array<(c: number) => number>; -let barVar: ((c: number) => number)[]; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - -type fooUnion = Array; -type barUnion = (string|number|boolean)[]; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] -type bazUnion = ((string|number|boolean))[]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - -type fooIntersection = Array; -type barIntersection = (string & number)[]; - ~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] -type bazIntersection = ((string & number))[]; - ~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - -namespace fooName { - type BarType = { bar: string }; - type BazType = Arr; -} - -let v: Array = [{ bar: "bar" }]; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -let w: fooName.BazType[] = [["baz"]]; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] - -interface FooInterface { - '.bar': {baz: string[];}; -} - -// Test an unknown Array -let t: unknown[] = []; -let u: Array = []; - ~~~~~~~~~~~~~~ [0] - -[0]: Array type using 'Array' is forbidden for simple types. Use 'T[]' instead. diff --git a/test/rules/array-type/array-simple/tslint.json b/test/rules/array-type/array-simple/tslint.json deleted file mode 100644 index a483323c7cb..00000000000 --- a/test/rules/array-type/array-simple/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "array-type": [true, "array-simple"] - } -} diff --git a/test/rules/array-type/array/test.ts.fix b/test/rules/array-type/array/test.ts.fix deleted file mode 100644 index 99dd1bef794..00000000000 --- a/test/rules/array-type/array/test.ts.fix +++ /dev/null @@ -1,50 +0,0 @@ -let x: undefined[] = [undefined] as undefined[]; -let y: string[] = ["2"]; -let z: any[] = [3, "4"]; -let u: unknown[] = []; - -let xx: number[][] = [[1, 2], [3]]; -let yy: number[][] = [[4, 5], [6]]; - -let ya = [[1, "2"]] as[number, string][]; - -type Arr = T[]; - -// Ignore user defined aliases -let yyyy: Arr[][]> = [[[["2"]]]]; - -interface ArrayClass { - foo: T[]; - bar: T[]; - baz: Arr; -} - -function fooFunction(foo: ArrayClass[]) { - return foo.map(e => e.foo); -} - -function barFunction(bar: ArrayClass[]) { - return bar.map(e => e.bar); -} - -function bazFunction(baz: Arr>) { - return baz.map(e => e.baz); -} - -let fooVar: ((c: number) => number)[]; -let barVar: ((c: number) => number)[]; - -type fooUnion = (string|number|boolean)[]; -type barUnion = (string|number|boolean)[]; - -type fooIntersection = (string & number)[]; -type barIntersection = (string & number)[]; - -interface FooInterface { - '.bar': {baz: string[];}; -} - -// Test an unknown Array -let t: unknown[] = []; -let u: unknown[] = []; - diff --git a/test/rules/array-type/array/test.ts.lint b/test/rules/array-type/array/test.ts.lint deleted file mode 100644 index d7b4efe095f..00000000000 --- a/test/rules/array-type/array/test.ts.lint +++ /dev/null @@ -1,65 +0,0 @@ -let x: Array = [undefined] as undefined[]; - ~~~~~~~~~~~~~~~~ [0] -let y: string[] = >["2"]; - ~~~~~~~~~~~~~ [0] -let z: Array = [3, "4"]; - ~~~~~ [0] -let u: Array = []; - ~~~~~~~~~~~~~~ [0] - -let xx: Array> = [[1, 2], [3]]; - ~~~~~~~~~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~~ [0] -let yy: number[][] = [[4, 5], [6]]; - -let ya = [[1, "2"]] as[number, string][]; - -type Arr = Array; - ~~~~~~~~ [0] - -// Ignore user defined aliases -let yyyy: Arr>[]> = [[[["2"]]]]; - ~~~~~~~~~~~~~~~~~~ [0] - -interface ArrayClass { - foo: Array; - ~~~~~~~~ [0] - bar: T[]; - baz: Arr; -} - -function fooFunction(foo: Array>) { - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - return foo.map(e => e.foo); -} - -function barFunction(bar: ArrayClass[]) { - return bar.map(e => e.bar); -} - -function bazFunction(baz: Arr>) { - return baz.map(e => e.baz); -} - -let fooVar: Array<(c: number) => number>; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let barVar: ((c: number) => number)[]; - -type fooUnion = Array; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -type barUnion = (string|number|boolean)[]; - -type fooIntersection = Array; - ~~~~~~~~~~~~~~~~~~~~~~ [0] -type barIntersection = (string & number)[]; - -interface FooInterface { - '.bar': {baz: string[];}; -} - -// Test an unknown Array -let t: unknown[] = []; -let u: Array = []; - ~~~~~~~~~~~~~~ [0] - -[0]: Array type using 'Array' is forbidden. Use 'T[]' instead. diff --git a/test/rules/array-type/array/tslint.json b/test/rules/array-type/array/tslint.json deleted file mode 100644 index 184d4606431..00000000000 --- a/test/rules/array-type/array/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "array-type": [true, "array"] - } -} diff --git a/test/rules/array-type/generic/test.ts.fix b/test/rules/array-type/generic/test.ts.fix deleted file mode 100644 index f67b3148f24..00000000000 --- a/test/rules/array-type/generic/test.ts.fix +++ /dev/null @@ -1,50 +0,0 @@ -let x: Array = [1] as Array; -let y: Array = >["2"]; -let z: Array = [3, "4"]; -let u: Array = []; - -let xx: Array> = [[1, 2], [3]]; -let yy: Array> = [[4, 5], [6]]; - -let ya = [[1, "2"]] as Array<[number, string]>; - -type Arr = Array; - -// Ignore user defined aliases -let yyyy: Arr>>> = [[[["2"]]]]; - -interface ArrayClass { - foo: Array; - bar: Array; - baz: Arr; -} - -function fooFunction(foo: Array>) { - return foo.map(e => e.foo); -} - -function barFunction(bar: Array>) { - return bar.map(e => e.bar); -} - -function bazFunction(baz: Arr>) { - return baz.map(e => e.baz); -} - -let fooVar: Array<(c: number) => number>; -let barVar: Array<(c: number) => number>; - -type fooUnion = Array; -type barUnion = Array; - -type fooIntersection = Array; -type barIntersection = Array; - -interface FooInterface { - '.bar': {baz: Array;}; -} - -// Test an unknown Array -let t: Array = []; -let u: Array = []; - diff --git a/test/rules/array-type/generic/test.ts.lint b/test/rules/array-type/generic/test.ts.lint deleted file mode 100644 index c3f4496c5e7..00000000000 --- a/test/rules/array-type/generic/test.ts.lint +++ /dev/null @@ -1,65 +0,0 @@ -let x: Array = [1] as number[]; - ~~~~~~~~ [0] -let y: string[] = >["2"]; - ~~~~~~~~ [0] -let z: Array = [3, "4"]; -let u: unknown[] = []; - ~~~~~~~~~ [0] - -let xx: Array> = [[1, 2], [3]]; -let yy: number[][] = [[4, 5], [6]]; - ~~~~~~~~~~ [0] - ~~~~~~~~ [0] - -let ya = [[1, "2"]] as[number, string][]; - ~~~~~~~~~~~~~~~~~~ [0] - -type Arr = Array; - -// Ignore user defined aliases -let yyyy: Arr>[]> = [[[["2"]]]]; - ~~~~~~~~~~~~~~~~~~~~ [0] - -interface ArrayClass { - foo: Array; - bar: T[]; - ~~~ [0] - baz: Arr; -} - -function fooFunction(foo: Array>) { - return foo.map(e => e.foo); -} - -function barFunction(bar: ArrayClass[]) { - ~~~~~~~~~~~~~~~~~~~~ [0] - return bar.map(e => e.bar); -} - -function bazFunction(baz: Arr>) { - return baz.map(e => e.baz); -} - -let fooVar: Array<(c: number) => number>; -let barVar: ((c: number) => number)[]; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -type fooUnion = Array; -type barUnion = (string|number|boolean)[]; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -type fooIntersection = Array; -type barIntersection = (string & number)[]; - ~~~~~~~~~~~~~~~~~~~ [0] - -interface FooInterface { - '.bar': {baz: string[];}; - ~~~~~~~~ [0] -} - -// Test an unknown Array -let t: unknown[] = []; - ~~~~~~~~~ [0] -let u: Array = []; - -[0]: Array type using 'T[]' is forbidden. Use 'Array' instead. diff --git a/test/rules/array-type/generic/tslint.json b/test/rules/array-type/generic/tslint.json deleted file mode 100644 index 610c20100a8..00000000000 --- a/test/rules/array-type/generic/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "array-type": [true, "generic"] - } -} diff --git a/test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix b/test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix deleted file mode 100644 index 5e19f335993..00000000000 --- a/test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix +++ /dev/null @@ -1,51 +0,0 @@ -// valid case -var a = ([x, y]) => {}; -var aa = ({x, y}) => {}; -var b = (a: number) => {}; -var c = (a, b) => {}; -var f = (...rest) => {}; -var f = a: number => {}; // TSLint don't warn. But syntax is wrong. -var bar = (method: () => T) => { - method(); -}; -var barbar = (method: (a: any) => T) => { - method(""); -}; -var barbarbar = (method: (a) => T) => { - method(""); -}; -var piyo = (method: () => T) => { - method(); -}; -const validAsync = async (param: any) => {}; - -var e = (a => {})(1); -var f = ab => {}; - -arr.map(a => b); - -// invalid case -var a =a => {}; -const invalidAsync = async param => {}; -const invalidAsync = async param => {}; - -// parens required when return type annotation is present -const fn = (param): void => {}; - -let foo =bar => bar; - -let foo =bar => bar; - -let foo =bar => bar; - -let foo = async bar => bar; - -arr.map(a => b); - -foo(async a => b); - -function *gen() { yield a => b; } - -export default a => b; - -throw a => b; diff --git a/test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint b/test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint deleted file mode 100644 index 6e59800db6a..00000000000 --- a/test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint +++ /dev/null @@ -1,70 +0,0 @@ -// valid case -var a = ([x, y]) => {}; -var aa = ({x, y}) => {}; -var b = (a: number) => {}; -var c = (a, b) => {}; -var f = (...rest) => {}; -var f = a: number => {}; // TSLint don't warn. But syntax is wrong. -var bar = (method: () => T) => { - method(); -}; -var barbar = (method: (a: any) => T) => { - method(""); -}; -var barbarbar = (method: (a) => T) => { - method(""); -}; -var piyo = (method: () => T) => { - method(); -}; -const validAsync = async (param: any) => {}; - -var e = (a => {})(1); -var f = ab => {}; - -arr.map(a => b); - -// invalid case -var a = (a) => {}; - ~ [0] -const invalidAsync = async (param) => {}; - ~~~~~ [0] -const invalidAsync = async(param) => {}; - ~~~~~ [0] - -// parens required when return type annotation is present -const fn = (param): void => {}; - -let foo = (bar,) => bar; - ~~~ [0] - -let foo = ( - bar - ~~~ [0] -) => bar; - -let foo = ( - bar, - ~~~ [0] -) => bar; - -let foo = async ( - bar, - ~~~ [0] -) => bar; - -arr.map((a) => b); - ~ [0] - -foo(async (a) => b); - ~ [0] - -function *gen() { yield (a) => b; } - ~ [0] - -export default (a) => b; - ~ [0] - -throw (a) => b; - ~ [0] -[0]: Parentheses are prohibited around the parameter in this single parameter arrow function diff --git a/test/rules/arrow-parens/ban-single-arg-parens/tslint.json b/test/rules/arrow-parens/ban-single-arg-parens/tslint.json deleted file mode 100644 index 972351cafb9..00000000000 --- a/test/rules/arrow-parens/ban-single-arg-parens/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "arrow-parens": [ - true, - "ban-single-arg-parens" - ] - } -} diff --git a/test/rules/arrow-parens/default/test.ts.fix b/test/rules/arrow-parens/default/test.ts.fix deleted file mode 100644 index 780c4f61339..00000000000 --- a/test/rules/arrow-parens/default/test.ts.fix +++ /dev/null @@ -1,27 +0,0 @@ -// valid case -var a = (a) => {}; -var b = (a: number) => {}; -var c = (a, b) => {}; -var f = (...rest) => {}; -var f = a: number => {}; // TSLint don't warn. But syntax is wrong. -class Foo { - a: (a) =>{} -} -var bar = (method: () => T) => { - method(); -}; -var barbar = (method: (a: any) => T) => { - method(""); -}; -var barbarbar = (method: (a) => T) => { - method(""); -}; -var piyo = (method: () => T) => { - method(); -}; -const validAsync = async (param: any) => {}; -const validAsync = async (param) => {}; - -// invalid case -var e = ((a) => {})(1); -var f = (ab) => {}; diff --git a/test/rules/arrow-parens/default/test.ts.lint b/test/rules/arrow-parens/default/test.ts.lint deleted file mode 100644 index 463decd2270..00000000000 --- a/test/rules/arrow-parens/default/test.ts.lint +++ /dev/null @@ -1,29 +0,0 @@ -// valid case -var a = (a) => {}; -var b = (a: number) => {}; -var c = (a, b) => {}; -var f = (...rest) => {}; -var f = a: number => {}; // TSLint don't warn. But syntax is wrong. -class Foo { - a: (a) =>{} -} -var bar = (method: () => T) => { - method(); -}; -var barbar = (method: (a: any) => T) => { - method(""); -}; -var barbarbar = (method: (a) => T) => { - method(""); -}; -var piyo = (method: () => T) => { - method(); -}; -const validAsync = async (param: any) => {}; -const validAsync = async (param) => {}; - -// invalid case -var e = (a => {})(1); - ~ [Parentheses are required around the parameters of an arrow function definition] -var f = ab => {}; - ~~ [Parentheses are required around the parameters of an arrow function definition] diff --git a/test/rules/arrow-parens/default/tslint.json b/test/rules/arrow-parens/default/tslint.json deleted file mode 100644 index f2bb606a314..00000000000 --- a/test/rules/arrow-parens/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "arrow-parens": true - } -} diff --git a/test/rules/arrow-return-shorthand/default/test.ts.fix b/test/rules/arrow-return-shorthand/default/test.ts.fix deleted file mode 100644 index 2c485de7c8f..00000000000 --- a/test/rules/arrow-return-shorthand/default/test.ts.fix +++ /dev/null @@ -1,21 +0,0 @@ -// Invalid: -(() => 0); -(() => ({ x: 1 })); -(() => { - return 0; -}); - -// Valid: -(() => 0); -(() => {}); -(() => { throw 0; }) -(() => { const x = 0; return x; }); - -// No fix if there's a comment. -(() => /**/ { return 0; }); -(() => { /**/ return 0; }); -(() => { return /**/ 0; }); -(() => { return 0 /**/ }); -(() => { return 0 /**/; }); -(() => { return 0; /**/ }); - diff --git a/test/rules/arrow-return-shorthand/default/test.ts.lint b/test/rules/arrow-return-shorthand/default/test.ts.lint deleted file mode 100644 index b922ef93192..00000000000 --- a/test/rules/arrow-return-shorthand/default/test.ts.lint +++ /dev/null @@ -1,31 +0,0 @@ -// Invalid: -(() => { return 0; }); - ~~~~~~~~~~~~~ [0] -(() => { return { x: 1 } }); - ~~~~~~~~~~~~~~~~~~~ [1] -(() => { - return 0; -}); - -// Valid: -(() => 0); -(() => {}); -(() => { throw 0; }) -(() => { const x = 0; return x; }); - -// No fix if there's a comment. -(() => /**/ { return 0; }); - ~~~~~~~~~~~~~ [0] -(() => { /**/ return 0; }); - ~~~~~~~~~~~~~~~~~~ [0] -(() => { return /**/ 0; }); - ~~~~~~~~~~~~~~~~~~ [0] -(() => { return 0 /**/ }); - ~~~~~~~~~~~~~~~~~ [0] -(() => { return 0 /**/; }); - ~~~~~~~~~~~~~~~~~~ [0] -(() => { return 0; /**/ }); - ~~~~~~~~~~~~~~~~~~ [0] - -[0]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return'. -[1]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return', and wrapping the object literal in parentheses. diff --git a/test/rules/arrow-return-shorthand/default/tslint.json b/test/rules/arrow-return-shorthand/default/tslint.json deleted file mode 100644 index 880c0cf113e..00000000000 --- a/test/rules/arrow-return-shorthand/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "arrow-return-shorthand": true - } -} diff --git a/test/rules/arrow-return-shorthand/multiline/test.ts.fix b/test/rules/arrow-return-shorthand/multiline/test.ts.fix deleted file mode 100644 index f80bb6ed8f4..00000000000 --- a/test/rules/arrow-return-shorthand/multiline/test.ts.fix +++ /dev/null @@ -1,20 +0,0 @@ -// Invalid: -(() => 0); -(() => ({ x: 1 })); -(() => - 0); - -// Valid: -(() => 0); -(() => {}); -(() => { throw 0; }) -(() => { const x = 0; return x; }); - -// No fix if there's a comment. -(() => /**/ { return 0; }); -(() => { /**/ return 0; }); -(() => { return /**/ 0; }); -(() => { return 0 /**/ }); -(() => { return 0 /**/; }); -(() => { return 0; /**/ }); - diff --git a/test/rules/arrow-return-shorthand/multiline/test.ts.lint b/test/rules/arrow-return-shorthand/multiline/test.ts.lint deleted file mode 100644 index 98d54b9d245..00000000000 --- a/test/rules/arrow-return-shorthand/multiline/test.ts.lint +++ /dev/null @@ -1,34 +0,0 @@ -// Invalid: -(() => { return 0; }); - ~~~~~~~~~~~~~ [0] -(() => { return { x: 1 } }); - ~~~~~~~~~~~~~~~~~~~ [1] -(() => { - ~ - return 0; -~~~~~~~~~~~~~ -}); -~ [0] - -// Valid: -(() => 0); -(() => {}); -(() => { throw 0; }) -(() => { const x = 0; return x; }); - -// No fix if there's a comment. -(() => /**/ { return 0; }); - ~~~~~~~~~~~~~ [0] -(() => { /**/ return 0; }); - ~~~~~~~~~~~~~~~~~~ [0] -(() => { return /**/ 0; }); - ~~~~~~~~~~~~~~~~~~ [0] -(() => { return 0 /**/ }); - ~~~~~~~~~~~~~~~~~ [0] -(() => { return 0 /**/; }); - ~~~~~~~~~~~~~~~~~~ [0] -(() => { return 0; /**/ }); - ~~~~~~~~~~~~~~~~~~ [0] - -[0]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return'. -[1]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return', and wrapping the object literal in parentheses. diff --git a/test/rules/arrow-return-shorthand/multiline/tslint.json b/test/rules/arrow-return-shorthand/multiline/tslint.json deleted file mode 100644 index 429bf4cc655..00000000000 --- a/test/rules/arrow-return-shorthand/multiline/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "arrow-return-shorthand": [true, "multiline"] - } -} diff --git a/test/rules/await-promise/custom-promise/test.ts.lint b/test/rules/await-promise/custom-promise/test.ts.lint deleted file mode 100644 index 24b3614ded9..00000000000 --- a/test/rules/await-promise/custom-promise/test.ts.lint +++ /dev/null @@ -1,78 +0,0 @@ -class CustomPromise {} - -async function fAny() { - const isAny: any = 1; - - // any type - await isAny; - - // union type with any type - await (Math.random() > 0.5 ? isAny : 0); -} - -async function fNonPromise() { - // number type - await 0; - ~~~~~~~ [0] - - // union type without Promise - await (Math.random() > 0.5 ? "" : 0); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - // non Promise type - class NonPromise extends Array {} - await new NonPromise(); - ~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -async function fStandardPromise() { - // direct type - const numberPromise: Promise; - await numberPromise; - - // 1st level base type - class Foo extends Promise {} - const foo: Foo = Foo.resolve(2); - await foo; - - // 2nd level base type - class Bar extends Foo {} - const bar: Bar = Bar.resolve(2); - await bar; - - // union type - await (Math.random() > 0.5 ? numberPromise : 0); - await (Math.random() > 0.5 ? foo : 0); - await (Math.random() > 0.5 ? bar : 0); - - // intersection type - const intersectionPromise: Promise & number; - await intersectionPromise; -} - -async function fCustomPromise() { - // direct type - const numberPromise: CustomPromise; - await numberPromise; - - // 1st level base type - class Foo extends CustomPromise {} - const foo: Foo = Foo.resolve(2); - await foo; - - // 2nd level base type - class Bar extends Foo {} - const bar: Bar = Bar.resolve(2); - await bar; - - // union type - await (Math.random() > 0.5 ? numberPromise : 0); - await (Math.random() > 0.5 ? foo : 0); - await (Math.random() > 0.5 ? bar : 0); - - // intersection type - const intersectionPromise: CustomPromise & number; - await intersectionPromise; -} - -[0]: Invalid 'await' of a non-Promise value. diff --git a/test/rules/await-promise/custom-promise/tsconfig.json b/test/rules/await-promise/custom-promise/tsconfig.json deleted file mode 100644 index ea71f9415cf..00000000000 --- a/test/rules/await-promise/custom-promise/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "target": "es6" - } -} \ No newline at end of file diff --git a/test/rules/await-promise/custom-promise/tslint.json b/test/rules/await-promise/custom-promise/tslint.json deleted file mode 100644 index 9c27c722ced..00000000000 --- a/test/rules/await-promise/custom-promise/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "linterOptions": { - "typeCheck": true - }, - "rules": { - "await-promise": [true, "CustomPromise"] - } -} diff --git a/test/rules/await-promise/es6-promise/test.ts.lint b/test/rules/await-promise/es6-promise/test.ts.lint deleted file mode 100644 index 6544b984781..00000000000 --- a/test/rules/await-promise/es6-promise/test.ts.lint +++ /dev/null @@ -1,58 +0,0 @@ -async function fAny() { - const isAny: any = 1; - - // any type - await isAny; - - // union type with any type - await (Math.random() > 0.5 ? isAny : 0); -} - -async function fNonPromise() { - // number type - await 0; - ~~~~~~~ [0] - - // union type without Promise - await (Math.random() > 0.5 ? "" : 0); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - // non Promise type - class NonPromise extends Array {} - await new NonPromise(); - ~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -async function fPromise() { - // direct type - const numberPromise: Promise; - await numberPromise; - - // 1st level base type - class Foo extends Promise {} - const foo: Foo = Foo.resolve(2); - await foo; - - // 2nd level base type - class Bar extends Foo {} - const bar: Bar = Bar.resolve(2); - await bar; - - // union type - await (Math.random() > 0.5 ? numberPromise : 0); - await (Math.random() > 0.5 ? foo : 0); - await (Math.random() > 0.5 ? bar : 0); - - // intersection type - const intersectionPromise: Promise & number; - await intersectionPromise; -} - -type AxiosResponse = T; -interface AxiosPromise extends Promise> {} - -async function extendsPromise(v: AxiosPromise) { - await v; -} - -[0]: Invalid 'await' of a non-Promise value. diff --git a/test/rules/await-promise/es6-promise/tsconfig.json b/test/rules/await-promise/es6-promise/tsconfig.json deleted file mode 100644 index ea71f9415cf..00000000000 --- a/test/rules/await-promise/es6-promise/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "target": "es6" - } -} \ No newline at end of file diff --git a/test/rules/await-promise/es6-promise/tslint.json b/test/rules/await-promise/es6-promise/tslint.json deleted file mode 100644 index 8f307816f9b..00000000000 --- a/test/rules/await-promise/es6-promise/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "await-promise": true - } -} diff --git a/test/rules/await-promise/for-await-of/test.ts.lint b/test/rules/await-promise/for-await-of/test.ts.lint deleted file mode 100644 index cc753ea5de0..00000000000 --- a/test/rules/await-promise/for-await-of/test.ts.lint +++ /dev/null @@ -1,51 +0,0 @@ -[typescript]: >= 2.3.0 -async function correct(foo: AsyncIterableIterator) { - for await (const element of foo) {} -} - -async function correct2() { - for await (const element of asyncGenerator()) {} -} - -async function correct(foo: AsyncIterable) { - for await (const element of foo) {} -} - -async function correct3(foo: AsyncIterableIterator | AsyncIterableIterator) { - for await (const element of foo) {} -} - -async function incorrect(foo: Array) { - for await (const element of foo) {} - ~~~ [0] -} - -async function incorrect2(foo: IterableIterator>) { - for await (const element of foo) {} - ~~~ [0] -} - -async function incorrect3() { - for await (const element of asyncGenerator) {} - ~~~~~~~~~~~~~~ [0] -} - -async function incorrect4() { - for await (const element of generator()) {} - ~~~~~~~~~~~ [0] -} - -async function incorrect5(foo: Iterable) { - for await (const element of foo) {} - ~~~ [0] -} - -async function* asyncGenerator() { - yield 1; -} - -function* generator() { - yield 1; -} - -[0]: Invalid 'for-await-of' of a non-AsyncIterable value. diff --git a/test/rules/await-promise/for-await-of/tsconfig.json b/test/rules/await-promise/for-await-of/tsconfig.json deleted file mode 100644 index 0d58d115f70..00000000000 --- a/test/rules/await-promise/for-await-of/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext" - } -} diff --git a/test/rules/await-promise/for-await-of/tslint.json b/test/rules/await-promise/for-await-of/tslint.json deleted file mode 100644 index 8f307816f9b..00000000000 --- a/test/rules/await-promise/for-await-of/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "await-promise": true - } -} diff --git a/test/rules/ban-comma-operator/test.ts.lint b/test/rules/ban-comma-operator/test.ts.lint deleted file mode 100644 index 5e65d1e787e..00000000000 --- a/test/rules/ban-comma-operator/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -let x = (y = 1, z = 2); - ~~~~~~~~~~~~ [0] - -// Error prone: forgot to add parens around arguments. -(x, y => x + y)(a, b); - ~~~~~~~~~~~~~ [0] - -foo((bar, baz)); - ~~~~~~~~ [0] - -switch (blah) { - case 1, 2: // equals `case 2` - probably intended `case 1: case2:` - ~~~~ [0] - return true; - case 3: - return false; -} - -for(let i = 0, j = 0; i < 10, j < 10; i++, j++) { - ~~~~~~~~~~~~~~ [0] -} - -[0]: Do not use comma operator here because it can be easily misunderstood or lead to unintended bugs. diff --git a/test/rules/ban-comma-operator/tslint.json b/test/rules/ban-comma-operator/tslint.json deleted file mode 100644 index 4f4d95561fa..00000000000 --- a/test/rules/ban-comma-operator/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ban-comma-operator": true - } -} diff --git a/test/rules/ban-ts-ignore/test.ts.lint b/test/rules/ban-ts-ignore/test.ts.lint deleted file mode 100644 index b093491e3b0..00000000000 --- a/test/rules/ban-ts-ignore/test.ts.lint +++ /dev/null @@ -1,33 +0,0 @@ -if (false) { - // @ts-ignore: Unreachable code error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] - console.log("hello"); // Random comments. -} - -var x = 0; - -/// @ts-ignore Triple-slash -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] -x(); - -/// @ts-ignore -~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] -x( - 2, - 3); - -// come comment - -// @ts-ignore Multiple comments -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] - -// some other comment - -// @anohter - -x(); - -x( // @ts-ignore inline - ~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] - 2, - 3); diff --git a/test/rules/ban-ts-ignore/tslint.json b/test/rules/ban-ts-ignore/tslint.json deleted file mode 100644 index 103785c3dda..00000000000 --- a/test/rules/ban-ts-ignore/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "rules": { - "ban-ts-ignore": true - } - } - \ No newline at end of file diff --git a/test/rules/ban-types/test.ts.lint b/test/rules/ban-types/test.ts.lint deleted file mode 100644 index 4e813ab2ccd..00000000000 --- a/test/rules/ban-types/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -let a: Object; - ~~~~~~ [Don't use 'Object' as a type.] -let b: {c: String}; - ~~~~~~ [Don't use 'String' as a type. Use 'string' instead.] -function foo(a: String) {} - ~~~~~~ [Don't use 'String' as a type. Use 'string' instead.] -'a' as String; - ~~~~~~ [Don't use 'String' as a type. Use 'string' instead.] -let c: F; - ~ [Don't use 'F' as a type.] -let d: Foooooo; - ~~~~~~~ [Don't use 'Foooooo' as a type.] - -// no warning for separately scoped types -let e: foo.String; - -// no warning for actual uses. -let f = Object(); -let g = Object.create(null); -let h = String(false); \ No newline at end of file diff --git a/test/rules/ban-types/tslint.json b/test/rules/ban-types/tslint.json deleted file mode 100644 index 738570950f6..00000000000 --- a/test/rules/ban-types/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "ban-types": [ - true, - ["String", "Use 'string' instead."], - ["Object"], - ["Fo*"] - ] - } -} diff --git a/test/rules/ban/test.ts.lint b/test/rules/ban/test.ts.lint deleted file mode 100644 index bc487516a86..00000000000 --- a/test/rules/ban/test.ts.lint +++ /dev/null @@ -1,41 +0,0 @@ -console.time(); -window.toString(); -~~~~~~~~~~~~~~~ [err % ('window.toString')] -console.log(); -document.window.toString(); -reference.randomContainer.window.toString(); -globals.getDocument().window.toString(); -_.keys(obj).forEach(fun); -~~~~~~~~~~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] -_.map(fun, (x) => x); -~~~~~ [err % ('_.map')] -_.filter(array); -~~~~~~~~ [err % ('_.filter', "Use the native JavaScript 'myArray.filter' instead.")] -describe("some text", () => {}); -xdescribe("some text", () => {}); -~~~~~~~~~ [err % ('xdescribe')] -fdescribe("some text", () => {}); -~~~~~~~~~ [err % ('fdescribe')] -it("some text", () => {}); -xit("some text", () => {}); -~~~ [err % ('xit')] -fit("some text", () => {}); -~~~ [err % ('fit')] -someObject.fit() -chai.assert.equal(1, "1"); -~~~~~~~~~~~~~~~~~ [err % ('chai.assert.equal', "Use 'strictEqual' instead.")] -chai.equal(1, "1"); -assert.equal(1, "1"); -foo.assert.equal(1, "1"); -someObject.chai.assert.equal(1, "1"); -[].forEach(() => {}); -~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] -arr.forEach(() => {}); -~~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] -someObject.someProperty.forEach(() => {}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] -someObject._id.toString(); -~~~~~~~~~~~~~~~~~~~~~~~ [err % ('*._id.toString', "Use 'toHexString' instead.")] -someObject.toString(); - -[err]: Calls to '%s' are not allowed. \ No newline at end of file diff --git a/test/rules/ban/tslint.json b/test/rules/ban/tslint.json deleted file mode 100644 index 739ed951c37..00000000000 --- a/test/rules/ban/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "ban": [ - true, - "xit", - {"name": "fit"}, - {"name": ["xdescribe"]}, - ["fdescribe"], - ["window", "toString"], - {"name": ["_", "map"]}, - ["_", "filter", "Use the native JavaScript 'myArray.filter' instead."], - {"name": ["*", "forEach"], "message": "Use a regular for loop instead."}, - {"name": ["chai", "assert", "equal"], "message": "Use 'strictEqual' instead."}, - {"name": ["*", "_id", "toString"], "message": "Use 'toHexString' instead."} - ] - } -} diff --git a/test/rules/binary-expression-operand-order/test.ts.lint b/test/rules/binary-expression-operand-order/test.ts.lint deleted file mode 100644 index e551edd1458..00000000000 --- a/test/rules/binary-expression-operand-order/test.ts.lint +++ /dev/null @@ -1,45 +0,0 @@ -"red" !== x; -~~~~~~~~~~~ [0] - -true === x; -~~~~~~~~~~ [0] - -false === x; -~~~~~~~~~~~ [0] - -null == x; -~~~~~~~~~ [0] - -undefined != x; -~~~~~~~~~~~~~~ [0] - -5 < x; -~~~~~ [0] - --1 + x; -~~~~~~ [0] - -(-1) + x; -~~~~~~~~ [0] - -// Allows string literal left hand side. -"foo" + x; - -// Allows certain ordered operators. -1 - x; -1 / x; -1 % x; -1 << x; -1 >> x; -1 >>> x; -2 ** x; -"key" in x; -"foo", x; - -// Allows literals on both sides. -1 + 1; -1 + 1 + 1; -1 + x + 1; -~~~~~ [0] - -[0]: Literal expression should be on the right-hand side of a binary expression. diff --git a/test/rules/binary-expression-operand-order/tslint.json b/test/rules/binary-expression-operand-order/tslint.json deleted file mode 100644 index 346b91833a5..00000000000 --- a/test/rules/binary-expression-operand-order/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "binary-expression-operand-order": true - } -} diff --git a/test/rules/callable-types/test.ts.fix b/test/rules/callable-types/test.ts.fix deleted file mode 100644 index 350ce4ca699..00000000000 --- a/test/rules/callable-types/test.ts.fix +++ /dev/null @@ -1,34 +0,0 @@ -type I = () => void; - -type J = () => void; - -type K = (param1: U, param2: T) => U; - -type L = () => T - -type T = () => void; - -type U = (t: T) => T - -var fn: () => void; -function f(x: () => void): void; -function f(x: string | (() => void)): void; -function f(x: string | (() => void)): void; -function f(x: (() => string) | (() => number)): void; -function f(x: string & (() => void)): void; -function f(x: (() => string) & (() => number)): void; -function f(x: (() => string)[]): void; - -// Overloads OK -interface K { - (x: number): number; - (x: string): string; -} - -// handle modifiers -export type I0 = () => void; - -export type I1 = new () => void; - -export type T = () => void - diff --git a/test/rules/callable-types/test.ts.lint b/test/rules/callable-types/test.ts.lint deleted file mode 100644 index fc36bcb058f..00000000000 --- a/test/rules/callable-types/test.ts.lint +++ /dev/null @@ -1,74 +0,0 @@ -interface I { - (): void; - ~~~~~~~~~ [interface % ('type I = () => void;')] -} - -interface J extends Function { - (): void; - ~~~~~~~~~ [interface % ('type J = () => void;')] -} - -interface K { - (param1: U, param2: T): U; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [interface % ('type K = (param1: U, param2: T) => U;')] -} - -interface L { - (): T - ~~~~~ [interface % ('type L = () => T')] -} - -type T = { - (): void; - ~~~~~~~~~ [type % ('() => void')] -}; - -type U = { - (t: T): T; - ~~~~~~~~~~~~~ [type % ('(t: T) => T')] -} - -var fn: {(): void;}; - ~~~~~~~~~ [type % ('() => void')] -function f(x: { (): void }): void; - ~~~~~~~~ [type % ('() => void')] -function f(x: string | { (): void }): void; - ~~~~~~~~ [type % ('(() => void)')] -function f(x: string | ({ (): void })): void; - ~~~~~~~~ [type % ('() => void')] -function f(x: { (): string } | { (): number }): void; - ~~~~~~~~~~ [type % ('(() => string)')] - ~~~~~~~~~~ [type % ('(() => number)')] -function f(x: string & { (): void }): void; - ~~~~~~~~ [type % ('(() => void)')] -function f(x: { (): string } & { (): number }): void; - ~~~~~~~~~~ [type % ('(() => string)')] - ~~~~~~~~~~ [type % ('(() => number)')] -function f(x: { (): string }[]): void; - ~~~~~~~~~~ [type % ('(() => string)')] - -// Overloads OK -interface K { - (x: number): number; - (x: string): string; -} - -// handle modifiers -export interface I0 { - (): void; - ~~~~~~~~~ [interface % ('type I0 = () => void;')] -} - -export interface I1 { - new (): void; - ~~~~~~~~~~~~~ [interface % ('type I1 = new () => void;')] -} - -export type T = { - (): void; - ~~~~~~~~~ [type % ('() => void')] -} - -[_base]: %s has only a call signature — use `%s` instead. -[interface]: _base % ('Interface') -[type]: _base % ('Type literal') diff --git a/test/rules/callable-types/tslint.json b/test/rules/callable-types/tslint.json deleted file mode 100644 index d24a06daec4..00000000000 --- a/test/rules/callable-types/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "callable-types": true - } -} diff --git a/test/rules/class-name/test.ts.lint b/test/rules/class-name/test.ts.lint deleted file mode 100644 index 62436a26f20..00000000000 --- a/test/rules/class-name/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -class ValidClassName { - -} - -class invalidClassName { - ~~~~~~~~~~~~~~~~ [0] -} - -class Another_Invalid_Class_Name { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -export default class { - // should not fail -} - -// anonymous class expression -var foo = class {}; -var bar = class invalidName {} - ~~~~~~~~~~~ [0] - -interface someInterface {} - ~~~~~~~~~~~~~ [0] -interface SomeInterface {} - -[0]: Class name must be in pascal case diff --git a/test/rules/class-name/tslint.json b/test/rules/class-name/tslint.json deleted file mode 100644 index fcaed86a61e..00000000000 --- a/test/rules/class-name/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "class-name": true - } -} diff --git a/test/rules/comment-format/allow-trailing-lowercase/test.ts.fix b/test/rules/comment-format/allow-trailing-lowercase/test.ts.fix deleted file mode 100644 index 29c8535bbd0..00000000000 --- a/test/rules/comment-format/allow-trailing-lowercase/test.ts.fix +++ /dev/null @@ -1,15 +0,0 @@ -// This is a valid -// multiline comment - -// This is an invalid -// multiline - -let a = 1; // Some description -let b = "foo"; // Another description - -// Another multiline -// comment .. -// -// With multiple -// paragraphs - diff --git a/test/rules/comment-format/allow-trailing-lowercase/test.ts.lint b/test/rules/comment-format/allow-trailing-lowercase/test.ts.lint deleted file mode 100644 index f53db41854f..00000000000 --- a/test/rules/comment-format/allow-trailing-lowercase/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -// This is a valid -// multiline comment - -// This is an invalid -//multiline - ~~~~~~~~~[space] - -let a = 1; // Some description -let b = "foo"; // another description - ~~~~~~~~~~~~~~~~~~~~[upper] - -// Another multiline -// comment .. -// -// with multiple - ~~~~~~~~~~~~~~[upper] -// paragraphs - -[upper]: comment must start with uppercase letter -[space]: comment must start with a space diff --git a/test/rules/comment-format/allow-trailing-lowercase/tslint.json b/test/rules/comment-format/allow-trailing-lowercase/tslint.json deleted file mode 100644 index 705d0c25fc8..00000000000 --- a/test/rules/comment-format/allow-trailing-lowercase/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-format": [true, "check-space", "check-uppercase", "allow-trailing-lowercase"] - } -} diff --git a/test/rules/comment-format/exceptions-pattern/test.ts.fix b/test/rules/comment-format/exceptions-pattern/test.ts.fix deleted file mode 100644 index c142d9cb849..00000000000 --- a/test/rules/comment-format/exceptions-pattern/test.ts.fix +++ /dev/null @@ -1,30 +0,0 @@ -/// -class Clazz { // this comment is correct - /* block comment - * adada - */ - public funcxion() { // this comment has a capital letter starting it - // this comment is on its own line, and starts with a capital _and_ no space - console.log("test"); // this comment has no space - } - /// - //// foo -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -//noinspection JSUnusedGlobalSymbols -const unusedVar = 'unneeded value'; - -// tODO: Write more tests -// hACKING is not an exception - -// STDIN for input -// STDOUT for output -// stderr for errors - - - diff --git a/test/rules/comment-format/exceptions-pattern/test.ts.lint b/test/rules/comment-format/exceptions-pattern/test.ts.lint deleted file mode 100644 index 58cb88eeabd..00000000000 --- a/test/rules/comment-format/exceptions-pattern/test.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -/// -class Clazz { // this comment is correct - /* block comment - * adada - */ - public funcxion() { // This comment has a capital letter starting it - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] - //This comment is on its own line, and starts with a capital _and_ no space - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_lower] - console.log("test"); //this comment has no space - ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] - } - /// - ////foo - ~~~ [space] -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -//noinspection JSUnusedGlobalSymbols -const unusedVar = 'unneeded value'; - -// TODO: Write more tests - ~~~~~~~~~~~~~~~~~~~~~~~ [lower] -// HACKING is not an exception - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] - -// STDIN for input -// STDOUT for output -// stderr for errors - - - -[lower]: comment must start with lowercase letter or its start must match the regex pattern "STD\w{2,3}" -[space]: comment must start with a space -[space_lower]: comment must start with a space and lowercase letter or its start must match the regex pattern "STD\w{2,3}" diff --git a/test/rules/comment-format/exceptions-pattern/tslint.json b/test/rules/comment-format/exceptions-pattern/tslint.json deleted file mode 100644 index 095aa7b0de4..00000000000 --- a/test/rules/comment-format/exceptions-pattern/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-format": [true, "check-space", "check-lowercase", {"ignore-pattern": "STD\\w{2,3}"}] - } -} diff --git a/test/rules/comment-format/exceptions-words/test.ts.fix b/test/rules/comment-format/exceptions-words/test.ts.fix deleted file mode 100644 index ff593a9c2fe..00000000000 --- a/test/rules/comment-format/exceptions-words/test.ts.fix +++ /dev/null @@ -1,29 +0,0 @@ -class Clazz { // this comment is correct - /* block comment - * adada - */ - public funcxion() { // this comment has a capital letter starting it - // this comment is on its own line, and starts with a capital _and_ no space - console.log("test"); // this comment has no space - } - /// - //// foo -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -//noinspection JSUnusedGlobalSymbols -const unusedVar = 'unneeded value'; - -// TODO: Write more tests - -// hACKING is not an exception - -// sTDIN for input -// sTDOUT for output -// stderr for errors - - diff --git a/test/rules/comment-format/exceptions-words/test.ts.lint b/test/rules/comment-format/exceptions-words/test.ts.lint deleted file mode 100644 index 4a19e036682..00000000000 --- a/test/rules/comment-format/exceptions-words/test.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -class Clazz { // this comment is correct - /* block comment - * adada - */ - public funcxion() { // This comment has a capital letter starting it - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] - //This comment is on its own line, and starts with a capital _and_ no space - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_lower] - console.log("test"); //this comment has no space - ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] - } - /// - ////foo - ~~~ [space] -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -//noinspection JSUnusedGlobalSymbols -const unusedVar = 'unneeded value'; - -// TODO: Write more tests - -// HACKING is not an exception - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] - -// STDIN for input - ~~~~~~~~~~~~~~~~ [lower] -// STDOUT for output - ~~~~~~~~~~~~~~~~~~ [lower] -// stderr for errors - - -[lower]: comment must start with lowercase letter or the word(s): TODO, HACK -[space]: comment must start with a space -[space_lower]: comment must start with a space and lowercase letter or the word(s): TODO, HACK diff --git a/test/rules/comment-format/exceptions-words/tslint.json b/test/rules/comment-format/exceptions-words/tslint.json deleted file mode 100644 index 812c9d96fe1..00000000000 --- a/test/rules/comment-format/exceptions-words/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-format": [true, "check-space", "check-lowercase", {"ignore-words": ["TODO", "HACK"]}] - } -} diff --git a/test/rules/comment-format/lower/test.ts.fix b/test/rules/comment-format/lower/test.ts.fix deleted file mode 100644 index d71c05768db..00000000000 --- a/test/rules/comment-format/lower/test.ts.fix +++ /dev/null @@ -1,20 +0,0 @@ -class Clazz { // this comment is correct - /* block comment - * adada - */ - public funcxion() { // this comment has a capital letter starting it - // this comment is on its own line, and starts with a capital _and_ no space - console.log("test"); // this comment has no space - } - /// - //// foo -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -//noinspection JSUnusedGlobalSymbols -const unusedVar = 'unneeded value'; - diff --git a/test/rules/comment-format/lower/test.ts.lint b/test/rules/comment-format/lower/test.ts.lint deleted file mode 100644 index 07c3390abf6..00000000000 --- a/test/rules/comment-format/lower/test.ts.lint +++ /dev/null @@ -1,27 +0,0 @@ -class Clazz { // this comment is correct - /* block comment - * adada - */ - public funcxion() { // This comment has a capital letter starting it - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] - //This comment is on its own line, and starts with a capital _and_ no space - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_lower] - console.log("test"); //this comment has no space - ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] - } - /// - ////foo - ~~~ [space] -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -//noinspection JSUnusedGlobalSymbols -const unusedVar = 'unneeded value'; - -[lower]: comment must start with lowercase letter -[space]: comment must start with a space -[space_lower]: comment must start with a space and lowercase letter diff --git a/test/rules/comment-format/lower/test.tsx.fix b/test/rules/comment-format/lower/test.tsx.fix deleted file mode 100644 index 7c09e671f03..00000000000 --- a/test/rules/comment-format/lower/test.tsx.fix +++ /dev/null @@ -1,9 +0,0 @@ -const a = ( - - https://github.com/ { - // invalid comment - content - }, text - -); - diff --git a/test/rules/comment-format/lower/test.tsx.lint b/test/rules/comment-format/lower/test.tsx.lint deleted file mode 100644 index 7a7e5388409..00000000000 --- a/test/rules/comment-format/lower/test.tsx.lint +++ /dev/null @@ -1,12 +0,0 @@ -const a = ( - - https://github.com/ { - //invalid comment - ~~~~~~~~~~~~~~~ [space] - content - }, text - -); - - -[space]: comment must start with a space \ No newline at end of file diff --git a/test/rules/comment-format/lower/tslint.json b/test/rules/comment-format/lower/tslint.json deleted file mode 100644 index b5c3658ef21..00000000000 --- a/test/rules/comment-format/lower/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-format": [true, "check-space", "check-lowercase"] - } -} diff --git a/test/rules/comment-format/upper/test.ts.fix b/test/rules/comment-format/upper/test.ts.fix deleted file mode 100644 index 562af0396fa..00000000000 --- a/test/rules/comment-format/upper/test.ts.fix +++ /dev/null @@ -1,27 +0,0 @@ -class Clazz { // This comment is correct - /* block comment - * adada - */ - public funcxion() { // This comment has a lowercase letter starting it - // This comment is on its own line, and starts with a lowercase _and_ no space - console.log("test"); // This comment has no space - } - /// - //// Foo -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -// Tslint should show error here - -// Tslint: not a rule flag - -// tslint:disable-next-line:no-unused-expression -class Invalid {} - -// tslint:disable-next-line:no-unused-expression -class Valid {} - diff --git a/test/rules/comment-format/upper/test.ts.lint b/test/rules/comment-format/upper/test.ts.lint deleted file mode 100644 index d9d21816446..00000000000 --- a/test/rules/comment-format/upper/test.ts.lint +++ /dev/null @@ -1,37 +0,0 @@ -class Clazz { // This comment is correct - /* block comment - * adada - */ - public funcxion() { // this comment has a lowercase letter starting it - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [upper] - //this comment is on its own line, and starts with a lowercase _and_ no space - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_upper] - console.log("test"); //This comment has no space - ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] - } - /// - ////foo - ~~~ [space_upper] -} - -//#region test -//#endregion - -`${location.protocol}//${location.hostname}` - -// tslint should show error here - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [upper] - -// tslint: not a rule flag - ~~~~~~~~~~~~~~~~~~~~~~~~ [upper] - -//tslint:disable-next-line:no-unused-expression - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space] -class Invalid {} - -// tslint:disable-next-line:no-unused-expression -class Valid {} - -[upper]: comment must start with uppercase letter -[space]: comment must start with a space -[space_upper]: comment must start with a space and uppercase letter diff --git a/test/rules/comment-format/upper/tslint.json b/test/rules/comment-format/upper/tslint.json deleted file mode 100644 index acb87406447..00000000000 --- a/test/rules/comment-format/upper/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-format": [true, "check-space", "check-uppercase"] - } -} diff --git a/test/rules/comment-type/combo/test.ts.lint b/test/rules/comment-type/combo/test.ts.lint deleted file mode 100644 index 965f3029509..00000000000 --- a/test/rules/comment-type/combo/test.ts.lint +++ /dev/null @@ -1,25 +0,0 @@ -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] - -// single comment - -/* multiline comment */ -~~~~~~~~~~~~~~~~~~~~~~~ [multiline] - -/** doc comment */ - - /** indented doc comment */ - -const x = /** inline doc comment */ 3; - -/* -~~ -actually -~~~~~~~~ -multiline -~~~~~~~~~ -*/ -~~ [multiline] - -[multiline]: multiline comments are not allowed -[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/combo/tslint.json b/test/rules/comment-type/combo/tslint.json deleted file mode 100644 index f15923071bb..00000000000 --- a/test/rules/comment-type/combo/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-type": [true, "singleline", "doc"] - } -} diff --git a/test/rules/comment-type/directive/test.ts.tslint b/test/rules/comment-type/directive/test.ts.tslint deleted file mode 100644 index 26aa7ce4056..00000000000 --- a/test/rules/comment-type/directive/test.ts.tslint +++ /dev/null @@ -1,29 +0,0 @@ -/// - -// single comment -~~~~~~~~~~~~~~~~~ [singleline] - -/* multiline comment */ -~~~~~~~~~~~~~~~~~~~~~~~ [multiline] - -/** doc comment */ -~~~~~~~~~~~~~~~~~~ [doc] - - /** indented doc comment */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] - -const x = /** inline doc comment */ 3; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] - -/* -~~ -actually -~~~~~~~~ -multiline -~~~~~~~~~ -*/ -~~ [multiline] - -[singleline]: singleline comments are not allowed -[multiline]: multiline comments are not allowed -[doc]: doc comments are not allowed diff --git a/test/rules/comment-type/directive/tslint.json b/test/rules/comment-type/directive/tslint.json deleted file mode 100644 index 80a14818b2e..00000000000 --- a/test/rules/comment-type/directive/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-type": [true, "directive"] - } -} diff --git a/test/rules/comment-type/doc/test.ts.lint b/test/rules/comment-type/doc/test.ts.lint deleted file mode 100644 index d065facdec9..00000000000 --- a/test/rules/comment-type/doc/test.ts.lint +++ /dev/null @@ -1,27 +0,0 @@ -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] - -// single comment -~~~~~~~~~~~~~~~~~ [singleline] - -/* multiline comment */ -~~~~~~~~~~~~~~~~~~~~~~~ [multiline] - -/** doc comment */ - - /** indented doc comment */ - -const x = /** inline doc comment */ 3; - -/* -~~ -actually -~~~~~~~~ -multiline -~~~~~~~~~ -*/ -~~ [multiline] - -[singleline]: singleline comments are not allowed -[multiline]: multiline comments are not allowed -[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/doc/tslint.json b/test/rules/comment-type/doc/tslint.json deleted file mode 100644 index 8cdb60d9bcd..00000000000 --- a/test/rules/comment-type/doc/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-type": [true, "doc"] - } -} diff --git a/test/rules/comment-type/multiline/test.ts.lint b/test/rules/comment-type/multiline/test.ts.lint deleted file mode 100644 index b2318fdd373..00000000000 --- a/test/rules/comment-type/multiline/test.ts.lint +++ /dev/null @@ -1,25 +0,0 @@ -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] - -// single comment -~~~~~~~~~~~~~~~~~ [singleline] - -/* multiline comment */ - -/** doc comment */ -~~~~~~~~~~~~~~~~~~ [doc] - - /** indented doc comment */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] - -const x = /** inline doc comment */ 3; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] - -/* -actually -multiline -*/ - -[singleline]: singleline comments are not allowed -[doc]: doc comments are not allowed -[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/multiline/tslint.json b/test/rules/comment-type/multiline/tslint.json deleted file mode 100644 index 82a09889d0a..00000000000 --- a/test/rules/comment-type/multiline/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-type": [true, "multiline"] - } -} diff --git a/test/rules/comment-type/single-line/test.ts.lint b/test/rules/comment-type/single-line/test.ts.lint deleted file mode 100644 index 7386ef8760e..00000000000 --- a/test/rules/comment-type/single-line/test.ts.lint +++ /dev/null @@ -1,29 +0,0 @@ -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] - -// single comment - -/* multiline comment */ -~~~~~~~~~~~~~~~~~~~~~~~ [multiline] - -/** doc comment */ -~~~~~~~~~~~~~~~~~~ [doc] - - /** indented doc comment */ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] - -const x = /** inline doc comment */ 3; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] - -/* -~~ -actually -~~~~~~~~ -multiline -~~~~~~~~~ -*/ -~~ [multiline] - -[multiline]: multiline comments are not allowed -[doc]: doc comments are not allowed -[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/single-line/tslint.json b/test/rules/comment-type/single-line/tslint.json deleted file mode 100644 index 3814eeb0381..00000000000 --- a/test/rules/comment-type/single-line/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "comment-type": [true, "singleline"] - } -} diff --git a/test/rules/completed-docs/defaults/edge-case/test.ts.lint b/test/rules/completed-docs/defaults/edge-case/test.ts.lint index 011989a4537..eeae338c31d 100644 --- a/test/rules/completed-docs/defaults/edge-case/test.ts.lint +++ b/test/rules/completed-docs/defaults/edge-case/test.ts.lint @@ -1,30 +1,5 @@ -export class Aaa { -~~~~~~~~~~~~~~~~~~ [Documentation must exist for exported classes.] - public bbb; - ~~~~~~~~~~~ [Documentation must exist for public properties.] - - public ccc() { } - ~~~~~~~~~~~~~~~~ [Documentation must exist for public methods.] - - public get prop() { return this.bbb; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for public properties.] - - public set prop(value) { this.bbb = value; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for public properties.] - - [Symbol.iterator]() {} - ~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for methods.] -} - -export enum Ddd { } - -export function Eee() { } -~~~~~~~~~~~~~~~~~~~~~~~~~ [Documentation must exist for exported functions.] - -export interface Fff { } - -export namespace Ggg { } - -export type Hhh = any; - -export const i = true; +/** + * + * @returns {Promise} + */ +export const handler = async () => { ... } diff --git a/test/rules/curly/as-needed/test.ts.lint b/test/rules/curly/as-needed/test.ts.lint deleted file mode 100644 index 448d9151fa8..00000000000 --- a/test/rules/curly/as-needed/test.ts.lint +++ /dev/null @@ -1,53 +0,0 @@ -if (so) { - ~ [0] - foo(); -} else { - ~ [0] - foo(); -} - -while (true) { - ~ [0] - foo(); -} - -if (so) { - ~ [0] - if (also) - foo(); -} - -if (so) { - ~ [0] - if (also) - foo(); - else - foo(); -} else - foo(); - -if (so) - bar(); -else { - ~ [0] - if (also) - foo(); -} - -// Some blocks are necessary. - -if (so) { - if (also) - foo(); -} else - bar(); - -function f() { - foo(); -} - -() => { foo(); }; - -try { foo(); } catch (e) { foo(); } finally { foo(); } - -[0]: Block contains only one statement; remove the curly braces. diff --git a/test/rules/curly/as-needed/tslint.json b/test/rules/curly/as-needed/tslint.json deleted file mode 100644 index 81fdd50f632..00000000000 --- a/test/rules/curly/as-needed/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "curly": [true, "as-needed"] - } -} diff --git a/test/rules/curly/defaults/test.ts.fix b/test/rules/curly/defaults/test.ts.fix deleted file mode 100644 index 93047211552..00000000000 --- a/test/rules/curly/defaults/test.ts.fix +++ /dev/null @@ -1,103 +0,0 @@ - if (a == 1) { console.log("a"); } - -if (x == 3) { - console.log("x"); -} - -if (y == 4) -{ - console.log("y"); -} - - if (z == 5) { // failure - console.log("z"); - } - - for (h = 0; h < 1; ++h) { console.log("h"); } - -for (i = 0; i < 1; ++i) { - console.log("i"); -} - -for (j = 0; j < 1; ++j) -{ - console.log("j"); -} - - for (k = 0; k < 1; ++k) { // failure - console.log("k"); - } - - for (k1 in l1) { console.log("l1"); } // failure - -for (k in l) { // failure - console.log("l"); -} - - for (k3 of l3) { console.log("l3"); } // failure - -for (k4 of l4) { // failure - console.log("l4"); -} - - while (m < 0) { console.log("q"); } // Failure - -while (m < 0) { - console.log("q"); -} - -while (n < 0) -{ - console.log("r"); -} - -while (n < 0) { // failure - console.log("s"); -} - - do { console.log("m1"); } // failure - while (i == 1); - -do { console.log("m2"); } -while (i == 1); - -do { - console.log("m3"); -} while (i == 1); - -do -{ - console.log("n"); -} -while (j == 1); - -do { // failure - console.log("o"); -} -while (k == 1); - -if (true) { - console.log("x"); -} else { console.log("y"); } // failure - -if (true) { - console.log("x"); -} else if (true) {console.log("y")}; - -for (let x of [1, 2, 3]) { - console.log(x); -} - -for (let y of [1, 2, 3]) { // failure - console.log(y); -} - -if (true) { /* some - comment */ - console.log(z); -} - -if (foo === "bar") { throw new Error( - "baz" -) -} diff --git a/test/rules/curly/defaults/test.ts.lint b/test/rules/curly/defaults/test.ts.lint deleted file mode 100644 index 21b07949aa3..00000000000 --- a/test/rules/curly/defaults/test.ts.lint +++ /dev/null @@ -1,123 +0,0 @@ - if (a == 1) console.log("a"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [if statements must be braced] - -if (x == 3) { - console.log("x"); -} - -if (y == 4) -{ - console.log("y"); -} - - if (z == 5) // failure - ~~~~~~~~~~~~~~~~~~~~~~ - console.log("z"); -~~~~~~~~~~~~~~~~~~~~~~~~~ [if statements must be braced] - - for (h = 0; h < 1; ++h) console.log("h"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -for (i = 0; i < 1; ++i) { - console.log("i"); -} - -for (j = 0; j < 1; ++j) -{ - console.log("j"); -} - - for (k = 0; k < 1; ++k) // failure - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - console.log("k"); -~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - - for (k1 in l1) console.log("l1"); // failure - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -for (k in l) // failure -~~~~~~~~~~~~~~~~~~~~~~~ - console.log("l"); -~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - - for (k3 of l3) console.log("l3"); // failure - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -for (k4 of l4) // failure -~~~~~~~~~~~~~~~~~~~~~~~~~ - console.log("l4"); -~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - - while (m < 0) console.log("q"); // Failure - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [while statements must be braced] - -while (m < 0) { - console.log("q"); -} - -while (n < 0) -{ - console.log("r"); -} - -while (n < 0) // failure -~~~~~~~~~~~~~~~~~~~~~~~~ - console.log("s"); -~~~~~~~~~~~~~~~~~~~~~ [while statements must be braced] - - do console.log("m1"); // failure - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - while (i == 1); -~~~~~~~~~~~~~~~~~~~ [do statements must be braced] - -do { console.log("m2"); } -while (i == 1); - -do { - console.log("m3"); -} while (i == 1); - -do -{ - console.log("n"); -} -while (j == 1); - -do // failure -~~~~~~~~~~~~~ - console.log("o"); -~~~~~~~~~~~~~~~~~~~~~ -while (k == 1); -~~~~~~~~~~~~~~~ [do statements must be braced] - -if (true) { - console.log("x"); -} else console.log("y"); // failure - ~~~~~~~~~~~~~~~~~~~~~~ [else statements must be braced] - -if (true) { - console.log("x"); -} else if (true) {console.log("y")}; - -for (let x of [1, 2, 3]) { - console.log(x); -} - -for (let y of [1, 2, 3]) // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - console.log(y); -~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -if (true) /* some -~~~~~~~~~~~~~~~~~ - comment */ -~~~~~~~~~~~~~~~~~~~~~~~ - console.log(z); -~~~~~~~~~~~~~~~~~~~ [if statements must be braced] - -if (foo === "bar") throw new Error( -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - "baz" -~~~~~~~ -) -~ [if statements must be braced] diff --git a/test/rules/curly/defaults/tslint.json b/test/rules/curly/defaults/tslint.json deleted file mode 100644 index c0855ef9fd0..00000000000 --- a/test/rules/curly/defaults/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "curly": true - } -} diff --git a/test/rules/curly/ignore-same-line/test.ts.fix b/test/rules/curly/ignore-same-line/test.ts.fix deleted file mode 100644 index 8363ab364bf..00000000000 --- a/test/rules/curly/ignore-same-line/test.ts.fix +++ /dev/null @@ -1,93 +0,0 @@ -if (a == 1) console.log("a"); - -if (x == 3) { - console.log("x"); -} - -if (y == 4) -{ - console.log("y"); -} - - if (z == 5) { // failure - console.log("z"); - } - -for (h = 0; h < 1; ++h) console.log("h"); - -for (i = 0; i < 1; ++i) { - console.log("i"); -} - -for (j = 0; j < 1; ++j) -{ - console.log("j"); -} - - for (k = 0; k < 1; ++k) { // failure - console.log("k"); - } - -for (k1 in l1) console.log("l1"); - -for (k in l) { // failure - console.log("l"); -} - -for (k3 of l3) console.log("l3"); - -for (k4 of l4) { // failure - console.log("l4"); -} - -while (m < 0) console.log("q"); - -while (m < 0) { - console.log("q"); -} - -while (n < 0) -{ - console.log("r"); -} - -while (n < 0) { // failure - console.log("s"); -} - -do console.log("m1"); -while (i == 1); - -do { console.log("m2"); } -while (i == 1); - -do { - console.log("m3"); -} while (i == 1); - -do -{ - console.log("n"); -} -while (j == 1); - -do { // failure - console.log("o"); -} -while (k == 1); - -if (true) { - console.log("x"); -} else console.log("y"); - -if (true) { - console.log("x"); -} else if (true) {console.log("y")}; - -for (let x of [1, 2, 3]) { - console.log(x); -} - -for (let y of [1, 2, 3]) { // failure - console.log(y); -} diff --git a/test/rules/curly/ignore-same-line/test.ts.lint b/test/rules/curly/ignore-same-line/test.ts.lint deleted file mode 100644 index 2d51287c5f7..00000000000 --- a/test/rules/curly/ignore-same-line/test.ts.lint +++ /dev/null @@ -1,101 +0,0 @@ -if (a == 1) console.log("a"); - -if (x == 3) { - console.log("x"); -} - -if (y == 4) -{ - console.log("y"); -} - - if (z == 5) // failure - ~~~~~~~~~~~~~~~~~~~~~~ - console.log("z"); -~~~~~~~~~~~~~~~~~~~~~~~~~ [if statements must be braced] - -for (h = 0; h < 1; ++h) console.log("h"); - -for (i = 0; i < 1; ++i) { - console.log("i"); -} - -for (j = 0; j < 1; ++j) -{ - console.log("j"); -} - - for (k = 0; k < 1; ++k) // failure - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - console.log("k"); -~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -for (k1 in l1) console.log("l1"); - -for (k in l) // failure -~~~~~~~~~~~~~~~~~~~~~~~ - console.log("l"); -~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -for (k3 of l3) console.log("l3"); - -for (k4 of l4) // failure -~~~~~~~~~~~~~~~~~~~~~~~~~ - console.log("l4"); -~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] - -while (m < 0) console.log("q"); - -while (m < 0) { - console.log("q"); -} - -while (n < 0) -{ - console.log("r"); -} - -while (n < 0) // failure -~~~~~~~~~~~~~~~~~~~~~~~~ - console.log("s"); -~~~~~~~~~~~~~~~~~~~~~ [while statements must be braced] - -do console.log("m1"); -while (i == 1); - -do { console.log("m2"); } -while (i == 1); - -do { - console.log("m3"); -} while (i == 1); - -do -{ - console.log("n"); -} -while (j == 1); - -do // failure -~~~~~~~~~~~~~ - console.log("o"); -~~~~~~~~~~~~~~~~~~~~~ -while (k == 1); -~~~~~~~~~~~~~~~ [do statements must be braced] - -if (true) { - console.log("x"); -} else console.log("y"); - -if (true) { - console.log("x"); -} else if (true) {console.log("y")}; - -for (let x of [1, 2, 3]) { - console.log(x); -} - -for (let y of [1, 2, 3]) // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - console.log(y); -~~~~~~~~~~~~~~~~~~~ [for statements must be braced] diff --git a/test/rules/curly/ignore-same-line/tslint.json b/test/rules/curly/ignore-same-line/tslint.json deleted file mode 100644 index 9788efabf64..00000000000 --- a/test/rules/curly/ignore-same-line/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "curly": [true, "ignore-same-line"] - } -} diff --git a/test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint b/test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint deleted file mode 100644 index a55df367b3b..00000000000 --- a/test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint +++ /dev/null @@ -1,68 +0,0 @@ -// Check that a default threshold is used if none is specified. - -function validThresholdPass() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - const condition3 = true ? "true" : "false"; - const condition4 = true ? "true" : "false"; - const condition5 = true ? "true" : "false"; - const condition6 = true ? "true" : "false"; - const condition7 = true ? "true" : "false"; - const condition8 = true ? "true" : "false"; - const condition9 = true ? "true" : "false"; - const condition10 = true ? "true" : "false"; - const condition11 = true ? "true" : "false"; - const condition12 = true ? "true" : "false"; - const condition13 = true ? "true" : "false"; - const condition14 = true ? "true" : "false"; - const condition15 = true ? "true" : "false"; - const condition16 = true ? "true" : "false"; - const condition17 = true ? "true" : "false"; - const condition18 = true ? "true" : "false"; - const condition19 = true ? "true" : "false"; -} - -function validThresholdFail() { -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition4 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition5 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition6 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition7 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition8 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition9 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition10 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition11 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition12 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition13 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition14 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition15 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition16 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition17 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition18 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition19 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition20 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function validThresholdFail has a cyclomatic complexity of 21 which is higher than the threshold of 20] diff --git a/test/rules/cyclomatic-complexity/defaultThreshold/tslint.json b/test/rules/cyclomatic-complexity/defaultThreshold/tslint.json deleted file mode 100644 index aee113f4f0b..00000000000 --- a/test/rules/cyclomatic-complexity/defaultThreshold/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "cyclomatic-complexity": [true] - } -} diff --git a/test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint b/test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint deleted file mode 100644 index aa6f059cad0..00000000000 --- a/test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint +++ /dev/null @@ -1,25 +0,0 @@ -// Check that rule is not applied for invalid config values by checking a -// function with complexity higher than the dafault threshold. - -function invalidThreshold() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - const condition3 = true ? "true" : "false"; - const condition4 = true ? "true" : "false"; - const condition5 = true ? "true" : "false"; - const condition6 = true ? "true" : "false"; - const condition7 = true ? "true" : "false"; - const condition8 = true ? "true" : "false"; - const condition9 = true ? "true" : "false"; - const condition10 = true ? "true" : "false"; - const condition11 = true ? "true" : "false"; - const condition12 = true ? "true" : "false"; - const condition13 = true ? "true" : "false"; - const condition14 = true ? "true" : "false"; - const condition15 = true ? "true" : "false"; - const condition16 = true ? "true" : "false"; - const condition17 = true ? "true" : "false"; - const condition18 = true ? "true" : "false"; - const condition19 = true ? "true" : "false"; - const condition20 = true ? "true" : "false"; -} diff --git a/test/rules/cyclomatic-complexity/invalidThreshold/tslint.json b/test/rules/cyclomatic-complexity/invalidThreshold/tslint.json deleted file mode 100644 index d8c5fbdd4c0..00000000000 --- a/test/rules/cyclomatic-complexity/invalidThreshold/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "cyclomatic-complexity": [true, -5] - } -} diff --git a/test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint b/test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint deleted file mode 100644 index cbf59112825..00000000000 --- a/test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint +++ /dev/null @@ -1,383 +0,0 @@ -// Test each function type. -const validFunctionExpression = function() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; -} - -const invalidFunctionExpression = function() { - ~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function has a cyclomatic complexity of 4 which is higher than the threshold of 3] - - -function validFunctionDeclaration() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; -} - -function invalidFunctionDeclaration() { -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function invalidFunctionDeclaration has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -const validArrowFunction = () => { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; -} - -const invalidArrowFunction = () => { - ~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -class MyClass { - get validGet(): string { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - return "test"; - } - - get invalidGet(): string { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - return "test"; -~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [The function invalidGet has a cyclomatic complexity of 4 which is higher than the threshold of 3] - - set validSet(newValue: string) { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - } - - set invalidSet(newValue: string) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [The function invalidSet has a cyclomatic complexity of 4 which is higher than the threshold of 3] - - validMethod() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - } - - invalidMethod() { - ~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [The function invalidMethod has a cyclomatic complexity of 4 which is higher than the threshold of 3] -} - -class validConstructor { - constructor() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - } -} - -class invalidConstructor { - constructor() { - ~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [The function has a cyclomatic complexity of 4 which is higher than the threshold of 3] -} - -// Test each remaining expression type. -function validBinaryExpression() { - return first || second && third -} - -function invalidBinaryExpression() { -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - return first || second && third || fourth; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function invalidBinaryExpression has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validSwitch() { - switch(5) { - case 0: - case 2: - return "even"; - case 1: - case 3: - return "odd"; - default: - return -1; - } -} - -function invalidSwitch() { -~~~~~~~~~~~~~~~~~~~~~~~~~~ - switch(5) { -~~~~~~~~~~~~~~~ - case 0: -~~~~~~~~~~~~~~~ - return 0; -~~~~~~~~~~~~~~~~~~~~~ - case 1: -~~~~~~~~~~~~~~~ - return 1; -~~~~~~~~~~~~~~~~~~~~~ - case 2: -~~~~~~~~~~~~~~~ - return 2; -~~~~~~~~~~~~~~~~~~~~~ - default: -~~~~~~~~~~~~~~~~ - return -1; -~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ -} -~ [The function invalidSwitch has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validCatch() { - try { } - catch(error) { } - try { } - catch(error) { } - try { } - finally { } -} - -function invalidCatch() { -~~~~~~~~~~~~~~~~~~~~~~~~~ - try { } -~~~~~~~~~~~ - catch(error) { } -~~~~~~~~~~~~~~~~~~~~ - try { } -~~~~~~~~~~~ - catch(error) { } -~~~~~~~~~~~~~~~~~~~~ - try { } -~~~~~~~~~~~ - catch(error) { } -~~~~~~~~~~~~~~~~~~~~ - try { } -~~~~~~~~~~~ - finally { } -~~~~~~~~~~~~~~~ -} -~ [The function invalidCatch has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validDo() { - do { } - while (false) - do { } - while (false) -} - -function invalidDo() { -~~~~~~~~~~~~~~~~~~~~~~ - do { } -~~~~~~~~~~ - while (false) -~~~~~~~~~~~~~~~~~ - do { } -~~~~~~~~~~ - while (false) -~~~~~~~~~~~~~~~~~ - do { } -~~~~~~~~~~ - while (false) -~~~~~~~~~~~~~~~~~ -} -~ [The function invalidDo has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validFor() { - for(;;) { } - for(;;) { } -} - -function invalidFor() { -~~~~~~~~~~~~~~~~~~~~~~~ - for(;;) { } -~~~~~~~~~~~~~~~ - for(;;) { } -~~~~~~~~~~~~~~~ - for(;;) { } -~~~~~~~~~~~~~~~ -} -~ [The function invalidFor has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validForIn() { - for(let i in [0,1,2]) { } - for(let i in [0,1,2]) { } -} - -function invalidForIn() { -~~~~~~~~~~~~~~~~~~~~~~~~~ - for(let i in [0,1,2]) { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - for(let i in [0,1,2]) { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - for(let i in [0,1,2]) { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function invalidForIn has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validForOf() { - for(let i of [0,1,2]) { } - for(let i of [0,1,2]) { } -} - -function invalidForOf() { -~~~~~~~~~~~~~~~~~~~~~~~~~ - for(let i of [0,1,2]) { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - for(let i of [0,1,2]) { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - for(let i of [0,1,2]) { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [The function invalidForOf has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -let variable = 1; - -function validIf() { - if(variable) { } - if(variable) { } else { } -} - -function invalidIf() { -~~~~~~~~~~~~~~~~~~~~~~ - if(variable) { } -~~~~~~~~~~~~~~~~~~~~ - if(variable) { } else { } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if(variable) { } -~~~~~~~~~~~~~~~~~~~~ -} -~ [The function invalidIf has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -function validWhile() { - while(false) { } - while(false) { } -} - -function invalidWhile() { -~~~~~~~~~~~~~~~~~~~~~~~~~ - while(false) { } -~~~~~~~~~~~~~~~~~~~~ - while(false) { } -~~~~~~~~~~~~~~~~~~~~ - while(false) { } -~~~~~~~~~~~~~~~~~~~~ -} -~ [The function invalidWhile has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -// Test that the rule behaves correctly for nested functions. - -// Valid outer function, invalid inner function. -function outer1() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - function inner1() { - ~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition4 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition5 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [The function inner1 has a cyclomatic complexity of 4 which is higher than the threshold of 3] -} - -// Invalid outer function, valid inner function. -function outer2() { -~~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - function inner2() { -~~~~~~~~~~~~~~~~~~~~~~~ - const condition4 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition5 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ -} -~ [The function outer2 has a cyclomatic complexity of 4 which is higher than the threshold of 3] - -// Both valid. -function outer3() { - const condition1 = true ? "true" : "false"; - const condition2 = true ? "true" : "false"; - function inner3() { - const condition3 = true ? "true" : "false"; - const condition4 = true ? "true" : "false"; - } -} - -// Both invalid. -function outer4() { -~~~~~~~~~~~~~~~~~~~ - const condition1 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition2 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition3 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - function inner4() { -~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~~~~ - const condition4 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition5 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const condition6 = true ? "true" : "false"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ -~~~~~ [The function inner4 has a cyclomatic complexity of 4 which is higher than the threshold of 3] -} -~ [The function outer4 has a cyclomatic complexity of 4 which is higher than the threshold of 3] diff --git a/test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json b/test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json deleted file mode 100644 index b16ec05ded6..00000000000 --- a/test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "cyclomatic-complexity": [true, 3] - } -} diff --git a/test/rules/deprecation/other.test.ts b/test/rules/deprecation/other.test.ts deleted file mode 100644 index 780c95c9c38..00000000000 --- a/test/rules/deprecation/other.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** @deprecated reason */ -export function other(): void; -/** not deprecated */ -export function other(num: number); -export function other(_num?: number) {} - -/** @deprecated */ -export let other2: Function; - -/** This one has @deprecated somewhere in it's jsdoc */ -export let notDeprecated: any; -/* @deprecated but it's no JsDoc */ -export let notDeprecated2: any; - -/** @deprecated deprecated default export */ -let def = ""; -export default def; - -/** @deprecated */ -export class DeprecatedClass { - constructor() {} -} - -export class DeprecatedConstructorClass { - /** @deprecated */ - constructor() {} -} - -export class PartiallyDeprecatedClass { - constructor(); - /** @deprecated */ - constructor(foo: number); - constructor(_foo?: number) {} -} diff --git a/test/rules/deprecation/other2.test.ts b/test/rules/deprecation/other2.test.ts deleted file mode 100644 index 77d6d94afda..00000000000 --- a/test/rules/deprecation/other2.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -/** @deprecated */ -let x = ""; -export = x; \ No newline at end of file diff --git a/test/rules/deprecation/test.ts.lint b/test/rules/deprecation/test.ts.lint deleted file mode 100644 index a2131666f4c..00000000000 --- a/test/rules/deprecation/test.ts.lint +++ /dev/null @@ -1,174 +0,0 @@ -// don't show an error on imports, because they don't do any harm if not used -import def, {other, other2 as foobar, notDeprecated, notDeprecated2} from './other.test'; -import * as namespaceImport from './other.test'; -import * as other2 from './other2.test'; - -other(); -~~~~~ [errmsg % ('other', 'reason')] -other(1); -foobar(); -~~~~~~ [err % ('foobar')] -other2; -~~~~~~ [err % ('other2')] - -import tmp = namespaceImport.other; - -tmp; -~~~ [errmsg % ('tmp', 'reason')] - -declare interface D { - /** @deprecated */ m: () => void; -} - - -declare let d: D; -d.m(); - ~ [err % ('m')] - -/** - * Some text - * @one-tag - * @deprecated reason is this - * @two-tag - */ -export class P { - /** @deprecated */ f: string; - g, - /** @deprecated Use g instead.*/ h: number; -} - -let p = new P(); - ~ [errmsg % ('P', 'reason is this')] -let pf = p.f; - ~ [err % ('f')] -pf; // that indirection is allowed -p.g; -p.h; - ~ [errmsg % ('h', 'Use g instead.')] - -interface I extends P {} - ~ [errmsg % ('P', 'reason is this')] -declare var i: I; -i.f; - ~ [err % ('f')] -i.g; - -/** @deprecated */ -const A = 1, B = 2; - -A + B; -~ [err % ('A')] -#if typescript < 2.6.1 - ~ [err % ('B')] -#endif - -export default A; - -declarationIsMissing(); - -function fn(): T; -/** @deprecated */ -function fn(bar: any): any; -function fn() { } - -fn(); -fn(1); -~~ [err % ('fn')] -fn; -~~ [err % ('fn')] - -class TestClass { - /** @deprecated */ - static method(): void; - static method(param): void; - static method(param?): void {} -} - -TestClass.method(); - ~~~~~~ [err % ('method')] -TestClass.method(1); - -interface TestInterface { - /** @deprecated */ - method(): void; - method(param): void; -} -declare let interfaceTest: TestInterface; -interfaceTest.method(); - ~~~~~~ [err % ('method')] -interfaceTest.method(1); - -declare let callSignatureTest: { - /** @deprecated */ - (): void; - (param): void; -} -callSignatureTest(); -~~~~~~~~~~~~~~~~~ [err % ('callSignatureTest')] -callSignatureTest(1); - -/** @deprecated */ -declare let variableWithCallSignature: { - (): void; -} -variableWithCallSignature(); -~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('variableWithCallSignature')] - -/** @deprecated */ -declare let variableWithCallSignature2: () => void; -variableWithCallSignature2(); -~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('variableWithCallSignature2')] - -function dedent(strings: TemplateStringsArray, ...values: string[]): string; -function dedent(strings: TemplateStringsArray, ...values: number[]): string; -/** @deprecated */ -function dedent(strings: TemplateStringsArray, ...values: any[]): string; -function dedent(strings: TemplateStringsArray, ...values: any[]): string { - return "foo"; -} - -dedent``; -dedent`${"foo"}`; -dedent`${1}`; -dedent`${[]}`; -~~~~~~ [err % ('dedent')] - -import {DeprecatedClass, DeprecatedConstructorClass, PartiallyDeprecatedClass} from "./other.test" -{ - const a: DeprecatedClass = new DeprecatedClass(); - ~~~~~~~~~~~~~~~ [err % ('DeprecatedClass')] - ~~~~~~~~~~~~~~~ [err % ('DeprecatedClass')] - const b: DeprecatedConstructorClass = new DeprecatedConstructorClass(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('DeprecatedConstructorClass')] - const c: PartiallyDeprecatedClass = new PartiallyDeprecatedClass(); - const d: PartiallyDeprecatedClass = new PartiallyDeprecatedClass(1); - ~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('PartiallyDeprecatedClass')] -} - -let {f, g, h} = p; - ~ [err % ('f')] - ~ [errmsg % ('h', 'Use g instead.')] -({f, g, h} = p); - ~ [err % ('f')] - ~ [errmsg % ('h', 'Use g instead.')] - -({f: g, g: h, h: f} = p); - ~ [err % ('f')] - ~ [errmsg % ('h', 'Use g instead.')] - -{ - /** @deprecated Just don't use. */ - let tmp; - ({f: tmp} = p); - ~ [err % ('f')] - ~~~ [errmsg % ('tmp', "Just don't use.")] -} - -(function ({f, g, h: tmp}: I) {}) - ~ [err % ('f')] - ~ [errmsg % ('h', 'Use g instead.')] -(function ({foo: {f, g}}: {foo: I}) {}) - ~ [err % ('f')] - -[err]: %s is deprecated. -[errmsg]: %s is deprecated: %s diff --git a/test/rules/deprecation/tsconfig.json b/test/rules/deprecation/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/deprecation/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/deprecation/tslint.json b/test/rules/deprecation/tslint.json deleted file mode 100644 index db90a0266cd..00000000000 --- a/test/rules/deprecation/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "deprecation": true - } -} diff --git a/test/rules/encoding/tslint.json b/test/rules/encoding/tslint.json deleted file mode 100644 index cfaabc04423..00000000000 --- a/test/rules/encoding/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "encoding": true - } -} \ No newline at end of file diff --git a/test/rules/encoding/utf16be.ts.lint b/test/rules/encoding/utf16be.ts.lint deleted file mode 100644 index 9e23e87aa89dcf5ac20167b9b0fc6d67b69f9617..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 138 zcmXwxyAD8507K90D~t>z7O`4<0h1Um*DDbQW}l9_VrqNR_PWXOIPs||nV8w-2kAmD w_vN0IjtwhjMU87!S`?Ax{p=;L)^IarhlJ*oe|UEJ>oGJWB>pF diff --git a/test/rules/encoding/utf16le.ts.lint b/test/rules/encoding/utf16le.ts.lint deleted file mode 100644 index cca0c813eb3f5bce94bd91658b40c8ed36a8a4c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmXwzu?|2$5JX??E0h!`(TG;#3#ddPoVY|zLG9BqPGqy$*~!f8-d9D$NlZt>f@2q+ zHCL?Aw_7|T8=0C~95sfVLR=z;<50a$qxRA|X+3F3@^T&Ghmf)9O3a^8lF{pv E2cd5mzyJUM diff --git a/test/rules/encoding/utf8-bom.ts.lint b/test/rules/encoding/utf8-bom.ts.lint deleted file mode 100644 index e4366f08bd3..00000000000 --- a/test/rules/encoding/utf8-bom.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -A -~ [This file is encoded as UTF-8 with byte-order marker (BOM) instead of UTF-8.] diff --git a/test/rules/encoding/utf8.ts.lint b/test/rules/encoding/utf8.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/eofline/comment.ts.lint b/test/rules/eofline/comment.ts.lint deleted file mode 100644 index ca08d31db5c..00000000000 --- a/test/rules/eofline/comment.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -let foo = bar; -// some comment in last line - ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/eofline/disabled.ts.lint b/test/rules/eofline/disabled.ts.lint deleted file mode 100644 index 573e1afe932..00000000000 --- a/test/rules/eofline/disabled.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -let bar = baz; -let foo = bar; // tslint:disable-line: eofline \ No newline at end of file diff --git a/test/rules/eofline/empty.ts.lint b/test/rules/eofline/empty.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/eofline/invalid.ts.fix b/test/rules/eofline/invalid.ts.fix deleted file mode 100644 index e5f25d98abb..00000000000 --- a/test/rules/eofline/invalid.ts.fix +++ /dev/null @@ -1 +0,0 @@ -let foo = bar; \ No newline at end of file diff --git a/test/rules/eofline/invalid.ts.lint b/test/rules/eofline/invalid.ts.lint deleted file mode 100644 index 6ab3f3de0be..00000000000 --- a/test/rules/eofline/invalid.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -let foo = bar; - ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/eofline/only-whitespace.ts.fix b/test/rules/eofline/only-whitespace.ts.fix deleted file mode 100644 index 5237d534ed2..00000000000 --- a/test/rules/eofline/only-whitespace.ts.fix +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/test/rules/eofline/only-whitespace.ts.lint b/test/rules/eofline/only-whitespace.ts.lint deleted file mode 100644 index e23b1c7dfef..00000000000 --- a/test/rules/eofline/only-whitespace.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ - - - ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/eofline/tslint.json b/test/rules/eofline/tslint.json deleted file mode 100644 index 030ddb8c92b..00000000000 --- a/test/rules/eofline/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "eofline": true - } -} diff --git a/test/rules/eofline/valid.ts.lint b/test/rules/eofline/valid.ts.lint deleted file mode 100644 index c85081ab6c4..00000000000 --- a/test/rules/eofline/valid.ts.lint +++ /dev/null @@ -1 +0,0 @@ -let foo = bar; diff --git a/test/rules/eofline/whitespace.ts.lint b/test/rules/eofline/whitespace.ts.lint deleted file mode 100644 index ce57bec9c84..00000000000 --- a/test/rules/eofline/whitespace.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -let foo = bar; - ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/file-header/bad-newline/test.ts.fix b/test/rules/file-header/bad-newline/test.ts.fix deleted file mode 100644 index c5133e19990..00000000000 --- a/test/rules/file-header/bad-newline/test.ts.fix +++ /dev/null @@ -1,11 +0,0 @@ -/*! - * Good header 2 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/bad-newline/test.ts.lint b/test/rules/file-header/bad-newline/test.ts.lint deleted file mode 100644 index eb415cdf751..00000000000 --- a/test/rules/file-header/bad-newline/test.ts.lint +++ /dev/null @@ -1,11 +0,0 @@ -/*! -~nil [missing new line following the file header] - * Good header 2 - */ -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/bad-newline/tslint.json b/test/rules/file-header/bad-newline/tslint.json deleted file mode 100644 index 888444210f1..00000000000 --- a/test/rules/file-header/bad-newline/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d", "Good header 2", "enforce-trailing-newline"] - } -} diff --git a/test/rules/file-header/bad-shebang/test.ts.fix b/test/rules/file-header/bad-shebang/test.ts.fix deleted file mode 100644 index b0ad7bf0496..00000000000 --- a/test/rules/file-header/bad-shebang/test.ts.fix +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node - -/*! - * Good header 2 - */ - -/* - * Bad header 3 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 4 - */ diff --git a/test/rules/file-header/bad-shebang/test.ts.lint b/test/rules/file-header/bad-shebang/test.ts.lint deleted file mode 100644 index 9032f789dfe..00000000000 --- a/test/rules/file-header/bad-shebang/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node - -~nil [missing file header] -/* - * Bad header 3 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 4 - */ diff --git a/test/rules/file-header/bad-shebang/tslint.json b/test/rules/file-header/bad-shebang/tslint.json deleted file mode 100644 index 9203b6ffb9a..00000000000 --- a/test/rules/file-header/bad-shebang/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d", "Good header 2"] - } -} diff --git a/test/rules/file-header/bad-single-line/test.ts.fix b/test/rules/file-header/bad-single-line/test.ts.fix deleted file mode 100644 index 47cd4177286..00000000000 --- a/test/rules/file-header/bad-single-line/test.ts.fix +++ /dev/null @@ -1,17 +0,0 @@ -/*! - * Good header 2 - */ - -// Bad header 1 - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 2 - */ diff --git a/test/rules/file-header/bad-single-line/test.ts.lint b/test/rules/file-header/bad-single-line/test.ts.lint deleted file mode 100644 index 9c69e523faf..00000000000 --- a/test/rules/file-header/bad-single-line/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -// Bad header 1 -~nil [missing file header] - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 2 - */ diff --git a/test/rules/file-header/bad-single-line/tslint.json b/test/rules/file-header/bad-single-line/tslint.json deleted file mode 100644 index 9203b6ffb9a..00000000000 --- a/test/rules/file-header/bad-single-line/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d", "Good header 2"] - } -} diff --git a/test/rules/file-header/bad-single-newline/test.ts.fix b/test/rules/file-header/bad-single-newline/test.ts.fix deleted file mode 100644 index ae4d4867777..00000000000 --- a/test/rules/file-header/bad-single-newline/test.ts.fix +++ /dev/null @@ -1,12 +0,0 @@ -/*! - * Good header 2 - */ - -// Bad header -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/bad-single-newline/test.ts.lint b/test/rules/file-header/bad-single-newline/test.ts.lint deleted file mode 100644 index 1ededeaf0ba..00000000000 --- a/test/rules/file-header/bad-single-newline/test.ts.lint +++ /dev/null @@ -1,9 +0,0 @@ -// Bad header -~nil [missing file header] -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/bad-single-newline/tslint.json b/test/rules/file-header/bad-single-newline/tslint.json deleted file mode 100644 index 888444210f1..00000000000 --- a/test/rules/file-header/bad-single-newline/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d", "Good header 2", "enforce-trailing-newline"] - } -} diff --git a/test/rules/file-header/bad-use-strict/test.ts.fix b/test/rules/file-header/bad-use-strict/test.ts.fix deleted file mode 100644 index 9ccabfa32f4..00000000000 --- a/test/rules/file-header/bad-use-strict/test.ts.fix +++ /dev/null @@ -1,21 +0,0 @@ -/*! - * Good header 2 - */ - -"use strict"; - -/* - * Bad header 5 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 6 - */ diff --git a/test/rules/file-header/bad-use-strict/test.ts.lint b/test/rules/file-header/bad-use-strict/test.ts.lint deleted file mode 100644 index 910a579d7a2..00000000000 --- a/test/rules/file-header/bad-use-strict/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -~nil [missing file header] - -/* - * Bad header 5 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 6 - */ diff --git a/test/rules/file-header/bad-use-strict/tslint.json b/test/rules/file-header/bad-use-strict/tslint.json deleted file mode 100644 index 9203b6ffb9a..00000000000 --- a/test/rules/file-header/bad-use-strict/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d", "Good header 2"] - } -} diff --git a/test/rules/file-header/bad/test.ts.fix b/test/rules/file-header/bad/test.ts.fix deleted file mode 100644 index c280ae62d78..00000000000 --- a/test/rules/file-header/bad/test.ts.fix +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Good header 2 - */ - -/* - * Bad header 1 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 2 - */ diff --git a/test/rules/file-header/bad/test.ts.lint b/test/rules/file-header/bad/test.ts.lint deleted file mode 100644 index f26963fcabf..00000000000 --- a/test/rules/file-header/bad/test.ts.lint +++ /dev/null @@ -1,16 +0,0 @@ -/* -~nil [missing file header] - * Bad header 1 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} - -/* - * Good header 2 - */ diff --git a/test/rules/file-header/bad/test2.ts.fix b/test/rules/file-header/bad/test2.ts.fix deleted file mode 100644 index 29f5b546f57..00000000000 --- a/test/rules/file-header/bad/test2.ts.fix +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * Good header 2 - */ - -// ********************************** -// Bad header -// ********************************** diff --git a/test/rules/file-header/bad/test2.ts.lint b/test/rules/file-header/bad/test2.ts.lint deleted file mode 100644 index ef259de4caf..00000000000 --- a/test/rules/file-header/bad/test2.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -// ********************************** -~nil [missing file header] -// Bad header -// ********************************** diff --git a/test/rules/file-header/bad/tslint.json b/test/rules/file-header/bad/tslint.json deleted file mode 100644 index 9203b6ffb9a..00000000000 --- a/test/rules/file-header/bad/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d", "Good header 2"] - } -} diff --git a/test/rules/file-header/empty-file/test.ts.lint b/test/rules/file-header/empty-file/test.ts.lint deleted file mode 100644 index 40e2acd429d..00000000000 --- a/test/rules/file-header/empty-file/test.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [missing file header] diff --git a/test/rules/file-header/empty-file/tslint.json b/test/rules/file-header/empty-file/tslint.json deleted file mode 100644 index 79f26da8b41..00000000000 --- a/test/rules/file-header/empty-file/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d"] - } -} diff --git a/test/rules/file-header/good-allow-single-line-comments/test.ts.lint b/test/rules/file-header/good-allow-single-line-comments/test.ts.lint deleted file mode 100644 index 8aa13d57e2e..00000000000 --- a/test/rules/file-header/good-allow-single-line-comments/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -// ********************************** -// Good header -// ********************************** - diff --git a/test/rules/file-header/good-allow-single-line-comments/tslint.json b/test/rules/file-header/good-allow-single-line-comments/tslint.json deleted file mode 100644 index 5f1256bb402..00000000000 --- a/test/rules/file-header/good-allow-single-line-comments/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "file-header": [true, { - "match": "Good header", - "allow-single-line-comments": true - }] - } - } diff --git a/test/rules/file-header/good-newline/test.ts.lint b/test/rules/file-header/good-newline/test.ts.lint deleted file mode 100644 index f724f642455..00000000000 --- a/test/rules/file-header/good-newline/test.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -/* Copyright 2019 */ - -class Foo {} diff --git a/test/rules/file-header/good-newline/tslint.json b/test/rules/file-header/good-newline/tslint.json deleted file mode 100644 index 858210b6a93..00000000000 --- a/test/rules/file-header/good-newline/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "file-header": [ - true, - "Copyright \\d{4}", - "Copyright 2019", - "enforce-trailing-newline" - ] - } -} diff --git a/test/rules/file-header/good-shebang/test.ts.lint b/test/rules/file-header/good-shebang/test.ts.lint deleted file mode 100644 index 0c58de97be7..00000000000 --- a/test/rules/file-header/good-shebang/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env node - - -/* - * Good header 2 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/good-shebang/tslint.json b/test/rules/file-header/good-shebang/tslint.json deleted file mode 100644 index 79f26da8b41..00000000000 --- a/test/rules/file-header/good-shebang/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d"] - } -} diff --git a/test/rules/file-header/good-single-line/test.ts.lint b/test/rules/file-header/good-single-line/test.ts.lint deleted file mode 100644 index 7c9cd1e230b..00000000000 --- a/test/rules/file-header/good-single-line/test.ts.lint +++ /dev/null @@ -1,9 +0,0 @@ -// Good header 4 - -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/good-single-line/tslint.json b/test/rules/file-header/good-single-line/tslint.json deleted file mode 100644 index 79f26da8b41..00000000000 --- a/test/rules/file-header/good-single-line/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d"] - } -} diff --git a/test/rules/file-header/good-use-strict/test.ts.lint b/test/rules/file-header/good-use-strict/test.ts.lint deleted file mode 100644 index e76f84c6bd4..00000000000 --- a/test/rules/file-header/good-use-strict/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Good header 3 - */ - -"use strict"; - -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/good-use-strict/tslint.json b/test/rules/file-header/good-use-strict/tslint.json deleted file mode 100644 index 79f26da8b41..00000000000 --- a/test/rules/file-header/good-use-strict/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d"] - } -} diff --git a/test/rules/file-header/good/test.ts.fix b/test/rules/file-header/good/test.ts.fix deleted file mode 100644 index df6b2bb9a56..00000000000 --- a/test/rules/file-header/good/test.ts.fix +++ /dev/null @@ -1,12 +0,0 @@ - -/* - * Good header 1 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/good/test.ts.lint b/test/rules/file-header/good/test.ts.lint deleted file mode 100644 index df6b2bb9a56..00000000000 --- a/test/rules/file-header/good/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ - -/* - * Good header 1 - */ - -export class A { - public x = 1; - - public B() { - return 2; - } -} diff --git a/test/rules/file-header/good/tslint.json b/test/rules/file-header/good/tslint.json deleted file mode 100644 index 79f26da8b41..00000000000 --- a/test/rules/file-header/good/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-header": [true, "Good header \\d"] - } -} diff --git a/test/rules/file-name-casing/camel-case/camelCase.ts.lint b/test/rules/file-name-casing/camel-case/camelCase.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/camel-case/no-camel-case.ts.lint b/test/rules/file-name-casing/camel-case/no-camel-case.ts.lint deleted file mode 100644 index c6a2024811e..00000000000 --- a/test/rules/file-name-casing/camel-case/no-camel-case.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be camelCase] diff --git a/test/rules/file-name-casing/camel-case/tslint.json b/test/rules/file-name-casing/camel-case/tslint.json deleted file mode 100644 index 883029f5a95..00000000000 --- a/test/rules/file-name-casing/camel-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, "camel-case"] - } -} diff --git a/test/rules/file-name-casing/complex/ComponentName.tsx.lint b/test/rules/file-name-casing/complex/ComponentName.tsx.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint b/test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint deleted file mode 100644 index c6a2024811e..00000000000 --- a/test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be camelCase] diff --git a/test/rules/file-name-casing/complex/invalid-component-name.tsx.lint b/test/rules/file-name-casing/complex/invalid-component-name.tsx.lint deleted file mode 100644 index 947411ef4df..00000000000 --- a/test/rules/file-name-casing/complex/invalid-component-name.tsx.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/complex/my-button.component.ts.lint b/test/rules/file-name-casing/complex/my-button.component.ts.lint deleted file mode 100644 index 947411ef4df..00000000000 --- a/test/rules/file-name-casing/complex/my-button.component.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/complex/nonComponentName.ts.lint b/test/rules/file-name-casing/complex/nonComponentName.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/complex/tslint.json b/test/rules/file-name-casing/complex/tslint.json deleted file mode 100644 index be350316521..00000000000 --- a/test/rules/file-name-casing/complex/tslint.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, { - ".component.ts$": "pascal-case", - ".tsx$": "pascal-case", - ".ts$": "camel-case" - }] - } -} diff --git a/test/rules/file-name-casing/file-matcher/PascalCase.ts.lint b/test/rules/file-name-casing/file-matcher/PascalCase.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/file-matcher/camelCase.ts.lint b/test/rules/file-name-casing/file-matcher/camelCase.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint b/test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint deleted file mode 100644 index 947411ef4df..00000000000 --- a/test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint b/test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint deleted file mode 100644 index c6a2024811e..00000000000 --- a/test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be camelCase] diff --git a/test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint b/test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint deleted file mode 100644 index 75f1057bba6..00000000000 --- a/test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be kebab-case] diff --git a/test/rules/file-name-casing/file-matcher/tslint.json b/test/rules/file-name-casing/file-matcher/tslint.json deleted file mode 100644 index bc03c3b8579..00000000000 --- a/test/rules/file-name-casing/file-matcher/tslint.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "rules": { - "file-name-casing": [ - true, - { - ".*)": "snake-case", // making sure invalid RegExp will be ignored - "pascal.?case": "pascal-case", - "tsx$": "kebab-case", - ".*": "camel-case" - } - ] - } -} diff --git a/test/rules/file-name-casing/ignore/complaint.tsx.lint b/test/rules/file-name-casing/ignore/complaint.tsx.lint deleted file mode 100644 index 947411ef4df..00000000000 --- a/test/rules/file-name-casing/ignore/complaint.tsx.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/ignore/file.ts.lint b/test/rules/file-name-casing/ignore/file.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/ignore/tslint.json b/test/rules/file-name-casing/ignore/tslint.json deleted file mode 100644 index dab56203717..00000000000 --- a/test/rules/file-name-casing/ignore/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, { - ".ts$": "ignore", - ".tsx$": "pascal-case" - }] - } -} diff --git a/test/rules/file-name-casing/invalid-option/snake_case.ts.lint b/test/rules/file-name-casing/invalid-option/snake_case.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/invalid-option/tslint.json b/test/rules/file-name-casing/invalid-option/tslint.json deleted file mode 100644 index 357701e90f4..00000000000 --- a/test/rules/file-name-casing/invalid-option/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, "invalid-option"] - } -} diff --git a/test/rules/file-name-casing/kebab-case/kebab-case.ts.lint b/test/rules/file-name-casing/kebab-case/kebab-case.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint b/test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint deleted file mode 100644 index 75f1057bba6..00000000000 --- a/test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be kebab-case] diff --git a/test/rules/file-name-casing/kebab-case/tslint.json b/test/rules/file-name-casing/kebab-case/tslint.json deleted file mode 100644 index b600a590662..00000000000 --- a/test/rules/file-name-casing/kebab-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, "kebab-case"] - } -} diff --git a/test/rules/file-name-casing/pascal-case/PascalCase.ts.lint b/test/rules/file-name-casing/pascal-case/PascalCase.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint b/test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint deleted file mode 100644 index 947411ef4df..00000000000 --- a/test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/pascal-case/tslint.json b/test/rules/file-name-casing/pascal-case/tslint.json deleted file mode 100644 index 1036cc4572a..00000000000 --- a/test/rules/file-name-casing/pascal-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, "pascal-case"] - } -} diff --git a/test/rules/file-name-casing/snake-case/no-snake-case.ts.lint b/test/rules/file-name-casing/snake-case/no-snake-case.ts.lint deleted file mode 100644 index d37aa03d910..00000000000 --- a/test/rules/file-name-casing/snake-case/no-snake-case.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ - -~nil [File name must be snake_case] diff --git a/test/rules/file-name-casing/snake-case/snake_case.ts.lint b/test/rules/file-name-casing/snake-case/snake_case.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/file-name-casing/snake-case/tslint.json b/test/rules/file-name-casing/snake-case/tslint.json deleted file mode 100644 index a08000df93c..00000000000 --- a/test/rules/file-name-casing/snake-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "file-name-casing": [true, "snake-case"] - } -} diff --git a/test/rules/forin/test.ts.lint b/test/rules/forin/test.ts.lint deleted file mode 100644 index a621922b16b..00000000000 --- a/test/rules/forin/test.ts.lint +++ /dev/null @@ -1,41 +0,0 @@ -function a() { - for (var i in obj) { - ~~~~~~~~~~~~~~~~~~~~ - console.log("i"); -~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [0] - - for (var j in obj) { - ~~~~~~~~~~~~~~~~~~~~ - if (j === 3) { -~~~~~~~~~~~~~~~~~~~~~~ - console.log("j"); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~~~~~ - console.log("j"); -~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [0] - - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - console.log("k"); - } - } - - for (var m in obj) { - if (!obj.hasOwnProperty(m)) { - continue; - } - console.log("m"); - } - - for (var n in obj) { - if (!obj.hasOwnProperty(n)) continue; - console.log("m"); - } -} - -[0]: for (... in ...) statements must be filtered with an if statement diff --git a/test/rules/forin/tslint.json b/test/rules/forin/tslint.json deleted file mode 100644 index c7c10b4b899..00000000000 --- a/test/rules/forin/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "forin": true - } -} diff --git a/test/rules/function-constructor/test.ts.lint b/test/rules/function-constructor/test.ts.lint deleted file mode 100644 index cc2f3829427..00000000000 --- a/test/rules/function-constructor/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -function one() { } -const two = function () { }; -const three = () => {}; - -const noParametersNew = Function(); - ~~~~~~~~~~ [0] -const oneParameterNew = Function("a"); - ~~~~~~~~~~~~~ [0] -const twoParametersNew = Function("a", "b"); - ~~~~~~~~~~~~~~~~~~ [0] - -const noParametersNew = new Function(); - ~~~~~~~~~~~~~~ [0] -const oneParameterNew = new Function("a"); - ~~~~~~~~~~~~~~~~~ [0] -const twoParametersNew = new Function("a", "b"); - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: Do not use the Function constructor to create functions. diff --git a/test/rules/function-constructor/tslint.json b/test/rules/function-constructor/tslint.json deleted file mode 100644 index 9f48491ff28..00000000000 --- a/test/rules/function-constructor/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "function-constructor": true - } -} diff --git a/test/rules/import-blacklist/test.ts.lint b/test/rules/import-blacklist/test.ts.lint deleted file mode 100644 index 0c499ed2f39..00000000000 --- a/test/rules/import-blacklist/test.ts.lint +++ /dev/null @@ -1,55 +0,0 @@ -import { Observable } from 'rxjs'; - ~~~~ [0] -import { Observable } from 'rxjs/Observable'; - -import rxjs = require('rxjs'); - ~~~~ [0] -import Observable = require('rxjs/Observable'); - -import * as rxjs from "rxjs"; - ~~~~ [0] - -// non-static imports cannot be checked -import {Observable} from rxjs; -import forOwn = require(lodash); - -import * as notBlacklisted from "not-blacklisted"; - -export * from 'rxjs'; - ~~~~ [0] - -export { default } from "dummy"; - ~~~~~~~~~~~ [3] - -export * from "lodash"; - ~~~~~~ [1] - -import * as lodash from "lodash"; - ~~~~~~ [1] -import { difference } from "lodash"; - -import { pull, difference } from "lodash"; - ~~~~~~~~~~~~~~~~~~~~ [2] - -import lodash, { pull } from "lodash"; - ~~~~~~~~~~~~~~~~ [2] - -import { pull as notPull } from "lodash"; - ~~~~~~~~~~~~~~~~~~~ [2] - -import test from "dummy"; - ~~~~ [3] - -import {myFunc} from './my.temp'; - ~~~~~~~~~ [4] - -import {myFunc} from './my.tmp'; - ~~~~~~~~ [5] - - -[0]: Importing this module is blacklisted. Try importing a submodule instead. -[1]: Some named exports from this module are blacklisted for importing (or re-exporting). Import/re-export only the specific values you want, instead of the whole module. -[2]: The export "pull" is blacklisted. -[3]: Importing (or re-exporting) the default export is blacklisted. -[4]: This import is blacklisted by /.*\.temp$/ -[5]: This import is blacklisted by /.*\.tmp$/ diff --git a/test/rules/import-blacklist/tslint.json b/test/rules/import-blacklist/tslint.json deleted file mode 100644 index 5ac04a3762d..00000000000 --- a/test/rules/import-blacklist/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "import-blacklist": [true, "rxjs", { "lodash": ["pullAll", "pull"] }, { "dummy": ["default"] }, [".*\\.temp$", ".*\\.tmp$"]] - } -} diff --git a/test/rules/import-spacing/test.ts.lint b/test/rules/import-spacing/test.ts.lint deleted file mode 100644 index daa11455ba4..00000000000 --- a/test/rules/import-spacing/test.ts.lint +++ /dev/null @@ -1,157 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------- -// Module with side effect import -// --------------------------------------------------------------------------------------------------------------------- -// good -import "styles.css"; - -// bad -import"styles.css"; -~~~~~~ [Add space after 'import'] -import "styles.css"; -~~~~~~~~ [Too many spaces after 'import'] -import "styles.css"; -~~~~~~~~~ [Too many spaces after 'import'] - -import -~~~~~~ -"styles.css"; -~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] -// --------------------------------------------------------------------------------------------------------------------- -// Namespace import -// --------------------------------------------------------------------------------------------------------------------- -// good -import * as ts from "typescript"; - -// bad -import*as ts from "typescript"; -~~~~~~ [Add space after 'import'] - ~~~~~~ [Add space after '*'] -import *as ts from "typescript"; - ~~~~~~ [Add space after '*'] -import * as ts from "typescript"; - ~~~~~~~~ [Too many spaces after '*'] -import * as ts from "typescript"; - ~~~~~~~~~ [Too many spaces after '*'] -import* as ts from "typescript"; -~~~~~~ [Add space after 'import'] -import * as ts from"typescript"; - ~~~~~ [Add space after 'from'] -import * as ts from "typescript"; -~~~~~~~~ [Too many spaces after 'import'] -import * as ts from "typescript"; -~~~~~~~~~~ [Too many spaces after 'import'] -import * as ts from "typescript"; - ~~~~~~~ [Too many spaces after 'from'] -import -~~~~~~ [Line breaks are not allowed in import declaration] -* as ts from "typescript"; - -import * - ~ -as ts from "typescript"; -~~~~~ [Line breaks are not allowed in import declaration] - -import * as - ~~~~ -ts from "typescript"; -~~ [Line breaks are not allowed in import declaration] - -import * as ts - ~nil -from "typescript"; -~~~~~~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] - - -// --------------------------------------------------------------------------------------------------------------------- -// Single-line import -// --------------------------------------------------------------------------------------------------------------------- -// good -import {Expression} from "typescript"; - -// bad -import{Expression}from"typescript"; -~~~~~~ [Add space after 'import'] - ~~~~ [Add space after 'from'] - ~~~~ [Add space before 'from'] -import {Expression}from"typescript"; - ~~~~ [Add space after 'from'] - ~~~~ [Add space before 'from'] -import {Expression} from"typescript"; - ~~~~~ [Add space after 'from'] -import {Expression} from "typescript"; -~~~~~~~~ [Too many spaces after 'import'] -import {Expression} from "typescript"; - ~~~~~~~ [Too many spaces before 'from'] -import {Expression} from "typescript"; - ~~~~~~~ [Too many spaces after 'from'] -import {Expression} from "typescript"; -~~~~~~~~ [Too many spaces after 'import'] -import {Expression} from "typescript"; -~~~~~~~~~ [Too many spaces after 'import'] - -import -~~~~~~ [Line breaks are not allowed in import declaration] -{Expression} from "typescript"; - -import {Expression} - ~nil -from "typescript"; -~~~~~~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] - -import {Expression} from - ~~~~~ -"typescript"; -~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] - -// --------------------------------------------------------------------------------------------------------------------- -// Multi-line import -// --------------------------------------------------------------------------------------------------------------------- -// good -import { - Expression -} from "typescript"; - -// bad -import{ -~~~~~~ [Add space after 'import'] - Expression -} from "typescript"; - -import {Expression -}from "typescript"; - ~~~~~ [Add space before 'from'] - -import { - Expression -} from"typescript"; - ~~~~~ [Add space after 'from'] - -import { -~~~~~~~~ [Too many spaces after 'import'] - Expression -} from "typescript"; - -import { -~~~~~~~~ [Too many spaces after 'import'] - Expression -} from "typescript"; - -import { - Expression -} - ~nil -from "typescript"; -~~~~~~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] - -import { - Expression -} from - ~~~~~ -"typescript"; -~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] - -import -~~~~~~ [Line breaks are not allowed in import declaration] -{ - Expression -} from "typescript" diff --git a/test/rules/import-spacing/tslint.json b/test/rules/import-spacing/tslint.json deleted file mode 100644 index acb0f7dc507..00000000000 --- a/test/rules/import-spacing/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "import-spacing": true - } -} diff --git a/test/rules/increment-decrement/allow-post/test.ts.fix b/test/rules/increment-decrement/allow-post/test.ts.fix deleted file mode 100644 index ebac59985d4..00000000000 --- a/test/rules/increment-decrement/allow-post/test.ts.fix +++ /dev/null @@ -1,20 +0,0 @@ -let x = 7; - -x += 1; -x++; - -x -= 1; -x--; - -+x; --x; -x + 1; -x - 1; -1 + x; -1 - x; - -x + (x += 1); -x + x++; - -x - (x -= 1); -x - x--; diff --git a/test/rules/increment-decrement/allow-post/test.ts.lint b/test/rules/increment-decrement/allow-post/test.ts.lint deleted file mode 100644 index c27629a2cdb..00000000000 --- a/test/rules/increment-decrement/allow-post/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -let x = 7; - -++x; -~~~ [plus] -x++; - ---x; -~~~ [minus] -x--; - -+x; --x; -x + 1; -x - 1; -1 + x; -1 - x; - -x + ++x; - ~~~ [plus] -x + x++; - -x - --x; - ~~~ [minus] -x - x--; -[plus]: Use an explicit += 1 operator. -[minus]: Use an explicit -= 1 operator. diff --git a/test/rules/increment-decrement/allow-post/tslint.json b/test/rules/increment-decrement/allow-post/tslint.json deleted file mode 100644 index b0964670126..00000000000 --- a/test/rules/increment-decrement/allow-post/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "increment-decrement": [true, "allow-post"] - } -} diff --git a/test/rules/increment-decrement/default/test.ts.fix b/test/rules/increment-decrement/default/test.ts.fix deleted file mode 100644 index 245a116d30f..00000000000 --- a/test/rules/increment-decrement/default/test.ts.fix +++ /dev/null @@ -1,29 +0,0 @@ -let x = 7; - -x += 1; -x += 1; - -x -= 1; -x -= 1; - -+x; --x; -x + 1; -x - 1; -1 + x; -1 - x; - -x + (x += 1); -x + x++; - -x - (x -= 1); -x - x--; - -(x += 1) + x; -x++ + x; - -(x -= 1) - x; -x-- - x; - -expect(x++) -expect(x += 1) diff --git a/test/rules/increment-decrement/default/test.ts.lint b/test/rules/increment-decrement/default/test.ts.lint deleted file mode 100644 index 19f39bb99b0..00000000000 --- a/test/rules/increment-decrement/default/test.ts.lint +++ /dev/null @@ -1,45 +0,0 @@ -let x = 7; - -++x; -~~~ [plus] -x++; -~~~ [plus] - ---x; -~~~ [minus] -x--; -~~~ [minus] - -+x; --x; -x + 1; -x - 1; -1 + x; -1 - x; - -x + ++x; - ~~~ [plus] -x + x++; - ~~~ [plus] - -x - --x; - ~~~ [minus] -x - x--; - ~~~ [minus] - -++x + x; -~~~ [plus] -x++ + x; -~~~ [plus] - ---x - x; -~~~ [minus] -x-- - x; -~~~ [minus] -[plus]: Use an explicit += 1 operator. -[minus]: Use an explicit -= 1 operator. - -expect(x++) - ~~~ [plus] -expect(++x) - ~~~ [plus] diff --git a/test/rules/increment-decrement/default/tslint.json b/test/rules/increment-decrement/default/tslint.json deleted file mode 100644 index 42c70f0b7ab..00000000000 --- a/test/rules/increment-decrement/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "increment-decrement": true - } -} diff --git a/test/rules/indent/spaces-2/test.ts.fix b/test/rules/indent/spaces-2/test.ts.fix deleted file mode 100644 index 02ee82b0503..00000000000 --- a/test/rules/indent/spaces-2/test.ts.fix +++ /dev/null @@ -1,139 +0,0 @@ -// valid code -module TestModule { - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading tabs inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -// we get a weird scenario here where our ~~ underlines don't quite line up with the line above -// this is because tabs are only one character and thus only one ~ goes beneath them. -module TestModule { - var testVariable = 123; -} - -function() { - var test = 123; -} - -class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } -} - -var obj = { - a: 1, - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, - VALUE2 -} - -switch (integerValue) { - case 0: - console.warn("1"); - break; - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -} - -while (i < 1) { - console.warn("123"); -} - -do { - console.warn("123"); -} while (i < 1); - -if (i < 1) { - console.warn("123"); -} - -var arr = [ - 1, - 2 -]; - -var arr2 = [ - { - a: 1, - b: 2 - }, - { - a: 3, - b: 4 - } -]; - diff --git a/test/rules/indent/spaces-2/test.ts.lint b/test/rules/indent/spaces-2/test.ts.lint deleted file mode 100644 index fabe1580c83..00000000000 --- a/test/rules/indent/spaces-2/test.ts.lint +++ /dev/null @@ -1,162 +0,0 @@ -// valid code -module TestModule { - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading tabs inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } -~~ [0] - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -// we get a weird scenario here where our ~~ underlines don't quite line up with the line above -// this is because tabs are only one character and thus only one ~ goes beneath them. -module TestModule { - var testVariable = 123; -~ [0] -} - -function() { - var test = 123; -~~ [0] -} - -class TestClass { - private variable; -~ [0] - - testFunction() { -~ [0] - this.variable = 3; -~~ [0] - } -~ [0] -} - -var obj = { - a: 1, -~ [0] - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, -~ [0] - VALUE2 -} - -switch (integerValue) { - case 0: -~ [0] - console.warn("1"); -~~ [0] - break; -~~ [0] - case 1: - console.warn("1"); - break; - default: -~ [0] - console.warn("default"); -~~ [0] - break; -~~ [0] -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -~ [0] -} - -while (i < 1) { - console.warn("123"); -~ [0] -} - -do { - console.warn("123"); -~ [0] -} while (i < 1); - -if (i < 1) { - console.warn("123"); -~ [0] -} - -var arr = [ - 1, -~ [0] - 2 -]; - -var arr2 = [ - { - a: 1, -~~ [0] - b: 2 - }, -~ [0] - { - a: 3, - b: 4 - } -]; - -[0]: 2 space indentation expected diff --git a/test/rules/indent/spaces-2/test.tsx.lint b/test/rules/indent/spaces-2/test.tsx.lint deleted file mode 100644 index 07f54d1fc56..00000000000 --- a/test/rules/indent/spaces-2/test.tsx.lint +++ /dev/null @@ -1,17 +0,0 @@ - - -~ [0] - baz -~~ [0] - -~ [0] - - { -~ [0] - -~~ [0] - } -~ [0] - - -[0]: 2 space indentation expected \ No newline at end of file diff --git a/test/rules/indent/spaces-2/tslint.json b/test/rules/indent/spaces-2/tslint.json deleted file mode 100644 index 1845d7c8884..00000000000 --- a/test/rules/indent/spaces-2/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "indent": [true, "spaces", 2] - } -} diff --git a/test/rules/indent/spaces-4/test.ts.fix b/test/rules/indent/spaces-4/test.ts.fix deleted file mode 100644 index bc01c41e902..00000000000 --- a/test/rules/indent/spaces-4/test.ts.fix +++ /dev/null @@ -1,139 +0,0 @@ -// valid code -module TestModule { - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading tabs inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -// we get a weird scenario here where our ~~ underlines don't quite line up with the line above -// this is because tabs are only one character and thus only one ~ goes beneath them. -module TestModule { - var testVariable = 123; -} - -function() { - var test = 123; -} - -class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } -} - -var obj = { - a: 1, - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, - VALUE2 -} - -switch (integerValue) { - case 0: - console.warn("1"); - break; - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -} - -while (i < 1) { - console.warn("123"); -} - -do { - console.warn("123"); -} while (i < 1); - -if (i < 1) { - console.warn("123"); -} - -var arr = [ - 1, - 2 -]; - -var arr2 = [ - { - a: 1, - b: 2 - }, - { - a: 3, - b: 4 - } -]; - diff --git a/test/rules/indent/spaces-4/test.ts.lint b/test/rules/indent/spaces-4/test.ts.lint deleted file mode 100644 index 0c173f913a5..00000000000 --- a/test/rules/indent/spaces-4/test.ts.lint +++ /dev/null @@ -1,162 +0,0 @@ -// valid code -module TestModule { - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading tabs inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } -~~ [0] - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -// we get a weird scenario here where our ~~ underlines don't quite line up with the line above -// this is because tabs are only one character and thus only one ~ goes beneath them. -module TestModule { - var testVariable = 123; -~ [0] -} - -function() { - var test = 123; -~~ [0] -} - -class TestClass { - private variable; -~ [0] - - testFunction() { -~ [0] - this.variable = 3; -~~ [0] - } -~ [0] -} - -var obj = { - a: 1, -~ [0] - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, -~ [0] - VALUE2 -} - -switch (integerValue) { - case 0: -~ [0] - console.warn("1"); -~~ [0] - break; -~~ [0] - case 1: - console.warn("1"); - break; - default: -~ [0] - console.warn("default"); -~~ [0] - break; -~~ [0] -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -~ [0] -} - -while (i < 1) { - console.warn("123"); -~ [0] -} - -do { - console.warn("123"); -~ [0] -} while (i < 1); - -if (i < 1) { - console.warn("123"); -~ [0] -} - -var arr = [ - 1, -~ [0] - 2 -]; - -var arr2 = [ - { - a: 1, -~~ [0] - b: 2 - }, -~ [0] - { - a: 3, - b: 4 - } -]; - -[0]: 4 space indentation expected diff --git a/test/rules/indent/spaces-4/tslint.json b/test/rules/indent/spaces-4/tslint.json deleted file mode 100644 index 9a84296b21d..00000000000 --- a/test/rules/indent/spaces-4/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "indent": [true, "spaces", 4] - } -} diff --git a/test/rules/indent/tabs-2/test.ts.fix b/test/rules/indent/tabs-2/test.ts.fix deleted file mode 100644 index 709a381974e..00000000000 --- a/test/rules/indent/tabs-2/test.ts.fix +++ /dev/null @@ -1,141 +0,0 @@ -// valid code -module TestModule { - /** - * Some documentation - */ - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 1; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading spaces inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -module TestModule { - var testVariable = 123; -} - -function() { - var test = 123; -} - -class TestClass { - private variable; - - testFunction() { - // fix incomplete space groups - this.variable = 1; - } -} - -var obj = { - a: 1, - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, - VALUE2 -} - -switch (integerValue) { - case 0: - console.warn("1"); - break; - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -} - -while (i < 1) { - console.warn("123"); -} - -do { - console.warn("123"); -} while (i < 1); - -if (i < 1) { - console.warn("123"); -} - -var arr = [ - 1, - 2 -]; - -var arr2 = [ - { - a: 1, - b: 2 - }, - { - a: 3, - b: 4 - } -]; - diff --git a/test/rules/indent/tabs-2/test.ts.lint b/test/rules/indent/tabs-2/test.ts.lint deleted file mode 100644 index fcc0344f5c8..00000000000 --- a/test/rules/indent/tabs-2/test.ts.lint +++ /dev/null @@ -1,164 +0,0 @@ -// valid code -module TestModule { - /** - * Some documentation - */ - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 1; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading spaces inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } -~~~~~ [0] - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -module TestModule { - var testVariable = 123; -~~ [0] -} - -function() { - var test = 123; -~~~~ [0] -} - -class TestClass { - private variable; -~~ [0] - - testFunction() { -~~ [0] - // fix incomplete space groups - this.variable = 1; -~~~ [0] - } -~~ [0] -} - -var obj = { - a: 1, -~~ [0] - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, -~~ [0] - VALUE2 -} - -switch (integerValue) { - case 0: - console.warn("1"); - break; - case 1: -~~ [0] - console.warn("1"); -~~~~ [0] - break; -~~~~ [0] - default: -~~ [0] - console.warn("default"); -~~~~ [0] - break; -~~~~ [0] -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -~~ [0] -} - -while (i < 1) { - console.warn("123"); -~~ [0] -} - -do { - console.warn("123"); -~~ [0] -} while (i < 1); - -if (i < 1) { - console.warn("123"); -~~ [0] -} - -var arr = [ - 1, -~~ [0] - 2 -]; - -var arr2 = [ - { - a: 1, -~~~~ [0] - b: 2 - }, -~~ [0] - { - a: 3, - b: 4 - } -]; - -[0]: tab indentation expected diff --git a/test/rules/indent/tabs-2/tslint.json b/test/rules/indent/tabs-2/tslint.json deleted file mode 100644 index 4d52a9464e0..00000000000 --- a/test/rules/indent/tabs-2/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "indent": [true, "tabs", 2] - } -} diff --git a/test/rules/indent/tabs-4/test.ts.fix b/test/rules/indent/tabs-4/test.ts.fix deleted file mode 100644 index a41a63e5d3c..00000000000 --- a/test/rules/indent/tabs-4/test.ts.fix +++ /dev/null @@ -1,141 +0,0 @@ -// valid code -module TestModule { - /** - * Some documentation - */ - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading spaces inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -module TestModule { - var testVariable = 123; -} - -function() { - var test = 123; -} - -class TestClass { - private variable; - - testFunction() { - // fix incomplete space groups - this.variable = 3; - } -} - -var obj = { - a: 1, - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, - VALUE2 -} - -switch (integerValue) { - case 0: - console.warn("1"); - break; - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -} - -while (i < 1) { - console.warn("123"); -} - -do { - console.warn("123"); -} while (i < 1); - -if (i < 1) { - console.warn("123"); -} - -var arr = [ - 1, - 2 -]; - -var arr2 = [ - { - a: 1, - b: 2 - }, - { - a: 3, - b: 4 - } -]; - diff --git a/test/rules/indent/tabs-4/test.ts.lint b/test/rules/indent/tabs-4/test.ts.lint deleted file mode 100644 index c867527b411..00000000000 --- a/test/rules/indent/tabs-4/test.ts.lint +++ /dev/null @@ -1,164 +0,0 @@ -// valid code -module TestModule { - /** - * Some documentation - */ - var func = () => { - console.warn("hi"); - }; - - class TestClass { - private variable; - - testFunction() { - this.variable = 3; - } - } - - var obj = { - a: 1, - b: 2, - c: 3 - }; - - // ignore leading spaces inside template strings - var s1 = ` - multiline` + ` template - string`; - var s2 = ` - multiline ${ "A" } - template ${ "B" - + "C" } -~~~~~ [0] - string`; - - export enum TestEnum { - VALUE1, - VALUE2 - } - - switch (integerValue) { - case 1: - console.warn("1"); - break; - default: - console.warn("default"); - break; - } - - function loops() { - for (var i = 0; i < 1; ++i) { - console.warn(i); - } - - while (i < 1) { - console.warn(i); - } - - do { - console.warn(i); - } while (i < 1); - - if (i < 1) { - console.warn(i); - } else { - console.warn(i + 1); - } - } -} - -// invalid code -module TestModule { - var testVariable = 123; -~~~~ [0] -} - -function() { - var test = 123; -~~~~~~~~ [0] -} - -class TestClass { - private variable; -~~~~ [0] - - testFunction() { -~~~~ [0] - // fix incomplete space groups - this.variable = 3; -~~~~~~~ [0] - } -~~~~ [0] -} - -var obj = { - a: 1, -~~~~ [0] - b: 2, - c: 3 -}; - -enum TestEnum { - VALUE1, -~~~~ [0] - VALUE2 -} - -switch (integerValue) { - case 0: - console.warn("1"); - break; - case 1: -~~~~ [0] - console.warn("1"); -~~~~~~~~ [0] - break; -~~~~~~~~ [0] - default: -~~~~ [0] - console.warn("default"); -~~~~~~~~ [0] - break; -~~~~~~~~ [0] -} - -for (var i = 0; i < 1; ++i) { - console.warn("123"); -~~~~ [0] -} - -while (i < 1) { - console.warn("123"); -~~~~ [0] -} - -do { - console.warn("123"); -~~~~ [0] -} while (i < 1); - -if (i < 1) { - console.warn("123"); -~~~~ [0] -} - -var arr = [ - 1, -~~~~ [0] - 2 -]; - -var arr2 = [ - { - a: 1, -~~~~~~~~ [0] - b: 2 - }, -~~~~ [0] - { - a: 3, - b: 4 - } -]; - -[0]: tab indentation expected diff --git a/test/rules/indent/tabs-4/tslint.json b/test/rules/indent/tabs-4/tslint.json deleted file mode 100644 index a2677945fc2..00000000000 --- a/test/rules/indent/tabs-4/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "indent": [true, "tabs", 4] - } -} diff --git a/test/rules/interface-name/always-prefix/test.ts.lint b/test/rules/interface-name/always-prefix/test.ts.lint deleted file mode 100644 index a196ab0fb7e..00000000000 --- a/test/rules/interface-name/always-prefix/test.ts.lint +++ /dev/null @@ -1,34 +0,0 @@ -// valid code -interface IOptions { -} - -interface ID { -} - -interface IABC { -} - -interface IDBFactory { -} - -interface II18nService { -} - -interface IIS3Foobar { -} - -interface IS3Foobar { -} - -// invalid code -interface Options { - ~~~~~~~ [interface name must start with a capitalized I] -} - -interface Incomplete { - ~~~~~~~~~~ [interface name must start with a capitalized I] -} - -interface I18nService { - ~~~~~~~~~~~ [interface name must start with a capitalized I] -} diff --git a/test/rules/interface-name/always-prefix/tslint.json b/test/rules/interface-name/always-prefix/tslint.json deleted file mode 100644 index be1e1405023..00000000000 --- a/test/rules/interface-name/always-prefix/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "interface-name": [true, "always-prefix"] - } -} diff --git a/test/rules/interface-name/default/test.ts.lint b/test/rules/interface-name/default/test.ts.lint deleted file mode 100644 index 5904c7e823d..00000000000 --- a/test/rules/interface-name/default/test.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -interface IValidInterfaceName { - -} - -interface NotValidInterfaceName { - ~~~~~~~~~~~~~~~~~~~~~ [interface name must start with a capitalized I] -} diff --git a/test/rules/interface-name/default/tslint.json b/test/rules/interface-name/default/tslint.json deleted file mode 100644 index a474c87992a..00000000000 --- a/test/rules/interface-name/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "interface-name": true - } -} diff --git a/test/rules/interface-name/never-prefix/test.ts.lint b/test/rules/interface-name/never-prefix/test.ts.lint deleted file mode 100644 index 1dd62de83ba..00000000000 --- a/test/rules/interface-name/never-prefix/test.ts.lint +++ /dev/null @@ -1,35 +0,0 @@ -// valid code -interface Index { -} - -interface I { -} - -interface ID { -} - -interface IABC { -} - -interface IDBFactory { -} - -interface I18nFactory { -} - -interface II18nFactory { -} - -interface IS3Foobar { -} - -interface IIS3Foobar { -} - -interface ABC { -} - -// invalid code -interface IOptions { - ~~~~~~~~ [interface name must not have an "I" prefix] -} diff --git a/test/rules/interface-name/never-prefix/tslint.json b/test/rules/interface-name/never-prefix/tslint.json deleted file mode 100644 index bd0d2d24374..00000000000 --- a/test/rules/interface-name/never-prefix/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "interface-name": [true, "never-prefix"] - } -} diff --git a/test/rules/interface-over-type-literal/test.ts.fix b/test/rules/interface-over-type-literal/test.ts.fix deleted file mode 100644 index 69ff2367698..00000000000 --- a/test/rules/interface-over-type-literal/test.ts.fix +++ /dev/null @@ -1,10 +0,0 @@ -interface T { x: number; } - -type U = string; -type V = { x: number; } | { y: string; }; -export interface W { - x: T, -} -type Record = { - [K in T]: U; -} diff --git a/test/rules/interface-over-type-literal/test.ts.lint b/test/rules/interface-over-type-literal/test.ts.lint deleted file mode 100644 index de37151b029..00000000000 --- a/test/rules/interface-over-type-literal/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -type T = { x: number; } - ~ [0] - -type U = string; -type V = { x: number; } | { y: string; }; -export type W = { - ~ [0] - x: T, -}; -type Record = { - [K in T]: U; -} - -[0]: Use an interface instead of a type literal. \ No newline at end of file diff --git a/test/rules/interface-over-type-literal/tslint.json b/test/rules/interface-over-type-literal/tslint.json deleted file mode 100644 index dfcff017ebf..00000000000 --- a/test/rules/interface-over-type-literal/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "interface-over-type-literal": true - } -} \ No newline at end of file diff --git a/test/rules/invalid-void/allow-generics/false/test.ts.lint b/test/rules/invalid-void/allow-generics/false/test.ts.lint deleted file mode 100644 index 2ad5f1ef10f..00000000000 --- a/test/rules/invalid-void/allow-generics/false/test.ts.lint +++ /dev/null @@ -1,16 +0,0 @@ -type Generic = [T]; -type GenericVoid = Generic; - ~~~~ [0] - -function takeVoid(thing: void) { } - ~~~~ [0] - -let voidPromise: Promise = new Promise(() => {}); - ~~~~ [0] - ~~~~ [0] - -let voidMap: Map = new Map(); - ~~~~ [0] - ~~~~ [0] - -[0]: void is only valid as a return type diff --git a/test/rules/invalid-void/allow-generics/false/tslint.json b/test/rules/invalid-void/allow-generics/false/tslint.json deleted file mode 100644 index baddd96c2b4..00000000000 --- a/test/rules/invalid-void/allow-generics/false/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "invalid-void": [true, { - "allow-generics": false - }] - } -} diff --git a/test/rules/invalid-void/allow-generics/true/test.ts.lint b/test/rules/invalid-void/allow-generics/true/test.ts.lint deleted file mode 100644 index 900c5f54946..00000000000 --- a/test/rules/invalid-void/allow-generics/true/test.ts.lint +++ /dev/null @@ -1,11 +0,0 @@ -type Generic = [T]; -type GenericVoid = Generic; - -function takeVoid(thing: void) { } - ~~~~ [0] - -let voidPromise: Promise = new Promise(() => {}); - -let voidMap: Map = new Map(); - -[0]: void is only valid as a return type or generic type variable diff --git a/test/rules/invalid-void/allow-generics/true/tslint.json b/test/rules/invalid-void/allow-generics/true/tslint.json deleted file mode 100644 index d7dec9afca2..00000000000 --- a/test/rules/invalid-void/allow-generics/true/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "invalid-void": [true, { - "allow-generics": true - }] - } -} diff --git a/test/rules/invalid-void/allow-generics/whitelist/test.ts.lint b/test/rules/invalid-void/allow-generics/whitelist/test.ts.lint deleted file mode 100644 index 3734b406e2b..00000000000 --- a/test/rules/invalid-void/allow-generics/whitelist/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -type Allowed = [T]; -type AllowedVoid = Allowed; - -type Banned = [T]; -type BannedVoid = Banned; - ~~~~ [Generic % ('Banned')] - -function takeVoid(thing: void) { } - ~~~~ [0] - -[0]: void is only valid as a return type or generic type variable -[Generic]: %s may not have void as a type variable diff --git a/test/rules/invalid-void/allow-generics/whitelist/tslint.json b/test/rules/invalid-void/allow-generics/whitelist/tslint.json deleted file mode 100644 index 44c4d38f9ef..00000000000 --- a/test/rules/invalid-void/allow-generics/whitelist/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "invalid-void": [true, { - "allow-generics": ["Allowed"] - }] - } -} diff --git a/test/rules/invalid-void/default/test.ts.lint b/test/rules/invalid-void/default/test.ts.lint deleted file mode 100644 index 1f1fef5fc85..00000000000 --- a/test/rules/invalid-void/default/test.ts.lint +++ /dev/null @@ -1,127 +0,0 @@ -function func(): void {} - -type NormalType = () => void; - -let normalArrow = (): void => { } - -let ughThisThing = void 0; - -function takeThing(thing: undefined) { } -takeThing(void 0); - -function takeVoid(thing: void) { } - ~~~~ [0] - - -const arrowGeneric = (arg: T) => { } - ~~~~ [0] -#if typescript >= 2.3.0 -const arrowGeneric1 = (arg: T) => { } - ~~~~ [0] -const arrowGeneric2 = (arg: T) => { } - ~~~~ [0] - ~~~~ [0] -#endif - -#if typescript >= 2.3.0 -function functionGeneric(arg: T) {} - ~~~~ [0] - -function functionGeneric1(arg: T) {} - ~~~~ [0] -function functionGeneric2(arg: T) {} - ~~~~ [0] - ~~~~ [0] -#endif - -declare function functionDeclaration(arg: T): void; - ~~~~ [0] -#if typescript >= 2.3.0 -declare function functionDeclaration1(arg: T): void; - ~~~~ [0] -declare function functionDeclaration2(arg: T): void; - ~~~~ [0] - ~~~~ [0] -#endif - - -functionGeneric(undefined); - ~~~~ [0] - -declare function voidArray(args: void[]): void[]; - ~~~~ [0] - ~~~~ [0] - -let value = undefined as void; - ~~~~ [0] - -let value = undefined; - ~~~~ [0] - -function takesThings(...things: void[]): void { } - ~~~~ [0] - -type KeyofVoid = keyof void; - ~~~~[0] - -interface Interface { - lambda: () => void; - voidProp: void; - ~~~~ [0] -} - -class ClassName { - private readonly propName: void; - ~~~~ [0] -} - -let voidPromise: Promise = new Promise(() => {}); - -let voidMap: Map = new Map(); - -let letVoid: void; - ~~~~ [0] - -type VoidType = void; - ~~~~ [0] - -class OtherClassName { - private propName: VoidType; -} - -type UnionType = string | number; -type UnionType2 = string | number | void; - ~~~~ [0] - -type UnionType3 = string | (number & any | (string | void)); - ~~~~ [0] - -type IntersectionType = string & number & void; - ~~~~ [0] - -function returnsVoidPromiseDirectly(): Promise { - return Promise.resolve(); -} - -async function returnsVoidPromiseAsync(): Promise {} - -#if typescript >= 2.8.0 -type MappedType = { - [K in keyof T]: void; - ~~~~ [0] -} -type ConditionalType = { - [K in keyof T]: T[K] extends string ? void : string; - ~~~~ [0] -} -#endif - -#if typescript >= 3.4.0 -type ManyVoid = readonly void[]; - ~~~~ [0] - -function foo(arr: readonly void[]) { } - ~~~~ [0] -#endif - -[0]: void is only valid as a return type or generic type variable diff --git a/test/rules/invalid-void/default/tslint.json b/test/rules/invalid-void/default/tslint.json deleted file mode 100644 index 79da7276673..00000000000 --- a/test/rules/invalid-void/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "invalid-void": true - } -} diff --git a/test/rules/jsdoc-format/check-multiline-start/test.ts.lint b/test/rules/jsdoc-format/check-multiline-start/test.ts.lint deleted file mode 100644 index 1e78b77b079..00000000000 --- a/test/rules/jsdoc-format/check-multiline-start/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ - /** First line of multiline jsdoc - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [jsdoc is not formatted correctly on this line] - * should be empty. - */ - - /** - * Good multiline. - */ - - /** Good singleline */ diff --git a/test/rules/jsdoc-format/check-multiline-start/tslint.json b/test/rules/jsdoc-format/check-multiline-start/tslint.json deleted file mode 100644 index 40faa974a27..00000000000 --- a/test/rules/jsdoc-format/check-multiline-start/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "jsdoc-format": [true, "check-multiline-start"] - } -} diff --git a/test/rules/jsdoc-format/default/jsdoc-bom.ts.lint b/test/rules/jsdoc-format/default/jsdoc-bom.ts.lint deleted file mode 100644 index 7cbf9e07419..00000000000 --- a/test/rules/jsdoc-format/default/jsdoc-bom.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -/** - * This is a valid jsdoc comment and should show no warning even though there is a BOM in the first line - */ diff --git a/test/rules/jsdoc-format/default/jsdoc-windows.ts.lint b/test/rules/jsdoc-format/default/jsdoc-windows.ts.lint deleted file mode 100644 index 5d6090b9b0a..00000000000 --- a/test/rules/jsdoc-format/default/jsdoc-windows.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -/** - * MyClass - * - * Does classy things and impresses everyone. Quite a debonair class indeed. - * - * This file has all windows line endings "\r\n" and valid jsdoc. - */ -class MyClass { - -} - -/** - *here comes some invalid jsdoc -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] - to ensure that the error is shown in the right place -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [asterisks] - * -*/ -~~ [asterisks] -function foo() {} - -[format]: jsdoc is not formatted correctly on this line -[asterisks]: asterisks in jsdoc must be aligned \ No newline at end of file diff --git a/test/rules/jsdoc-format/default/jsdoc.ts.lint b/test/rules/jsdoc-format/default/jsdoc.ts.lint deleted file mode 100644 index 8a66c75a6be..00000000000 --- a/test/rules/jsdoc-format/default/jsdoc.ts.lint +++ /dev/null @@ -1,88 +0,0 @@ -function makeHeader(pkg: Package) { - return [ - `\t/**`, - `\t * ${pkg.name} v${pkg.version}`, - `\t */` - ].join("\r\n"); -} - -class Clazz { //this is not a block comment - /* block comment - *Not a jsdoc and not subject to the rules lalala - * oh look I'm over here and you can't do anything about me - *and now I'm here, wheeee -I've even got characters where I shouldn't. How fun! * - You can't stop me! */ - public funcxion() { - /** - * This is jsdoc - * and it is correct - * so should be no errors here - * - * not on the above line either - */ - } - - /**********************************************************/ - /* this is just an arbitrary separator, not a jsdoc block */ - /**********************************************************/ - - /** - * this is also jsdoc - *and it has a problem on this line -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] - */ - - /** - * this jsoc is fine - * up until the last line when it isn't - */ -~~~~~ [asterisks] - - /** - * this jsdoc has characters where it really should -not */ -~~~~~~~ [format] - - /** - * same thing with this -one * -~~~~~~ [format] - */ - - /** - * what else can go wrong? - * oh right this -~~~~~~~~~~~~~~~~~~ [asterisks] - */ - - /**a bad one liner */ - ~~~~~~~~~~~~~~~~~~~~~ [format] - - /** another bad one liner*/ - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] - - /** */ - - /** */ - - /** a good one */ - - /**/ // no jsdoc - - /** First line of multiline jsdoc - * should be empty. - */ -} - -// Regression test: jsdoc rule shouldn't look inside template strings (https://github.com/palantir/tslint/issues/332) -function makeHeader(pkg: Package) { - return [ - `\t/**`, - `\t * ${pkg.name} v${pkg.version}`, - `\t */` - ].join("\r\n"); -} - -[format]: jsdoc is not formatted correctly on this line -[asterisks]: asterisks in jsdoc must be aligned diff --git a/test/rules/jsdoc-format/default/tslint.json b/test/rules/jsdoc-format/default/tslint.json deleted file mode 100644 index 02b95774ec7..00000000000 --- a/test/rules/jsdoc-format/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "jsdoc-format": true - } -} diff --git a/test/rules/label-position/test.ts.lint b/test/rules/label-position/test.ts.lint deleted file mode 100644 index cd7c95afd2d..00000000000 --- a/test/rules/label-position/test.ts.lint +++ /dev/null @@ -1,38 +0,0 @@ -var t = function() { - lab1: - ~~~~ [unexpected label on statement] - var x = 123; - - lab2: - ~~~~ [unexpected label on statement] - console.log("123"); - - lab3: - for (var i = 0; i < 5; ++i) { - break lab3; - } - - lab4: - do { - break lab4; - } while (i < 10); - - lab5: - while (i < 10) { - lab6: - while (j < 20) { - break lab5; - } - } - - lab7: - switch (i) { - case 0: - break lab7; - } - - lab8: - for (let value of [1]) { - break lab8; - } -}; diff --git a/test/rules/label-position/tslint.json b/test/rules/label-position/tslint.json deleted file mode 100644 index 82a6a0582e6..00000000000 --- a/test/rules/label-position/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "label-position": true - } -} diff --git a/test/rules/linebreak-style/emptyFile/test.ts.lint b/test/rules/linebreak-style/emptyFile/test.ts.lint deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/linebreak-style/emptyFile/tslint.json b/test/rules/linebreak-style/emptyFile/tslint.json deleted file mode 100644 index f82a6f4d1df..00000000000 --- a/test/rules/linebreak-style/emptyFile/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "linebreak-style": [true, "LF"] - } -} diff --git a/test/rules/linebreak-style/failure/CRLF/test.ts.fix b/test/rules/linebreak-style/failure/CRLF/test.ts.fix deleted file mode 100644 index 4a60171c332..00000000000 --- a/test/rules/linebreak-style/failure/CRLF/test.ts.fix +++ /dev/null @@ -1,4 +0,0 @@ -// this line uses CRLF -// this line uses CRLF -// this line uses CRLF -// this line uses CRLF diff --git a/test/rules/linebreak-style/failure/CRLF/test.ts.lint b/test/rules/linebreak-style/failure/CRLF/test.ts.lint deleted file mode 100644 index 7d55d0fe1f9..00000000000 --- a/test/rules/linebreak-style/failure/CRLF/test.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -// this line uses CRLF -~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] -// this line uses CRLF -~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] -// this line uses CRLF -~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] -// this line uses CRLF -~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] diff --git a/test/rules/linebreak-style/failure/CRLF/tslint.json b/test/rules/linebreak-style/failure/CRLF/tslint.json deleted file mode 100644 index f82a6f4d1df..00000000000 --- a/test/rules/linebreak-style/failure/CRLF/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "linebreak-style": [true, "LF"] - } -} diff --git a/test/rules/linebreak-style/failure/LF/test.ts.fix b/test/rules/linebreak-style/failure/LF/test.ts.fix deleted file mode 100644 index 1f88a5a75a2..00000000000 --- a/test/rules/linebreak-style/failure/LF/test.ts.fix +++ /dev/null @@ -1,4 +0,0 @@ -// this line uses LF -// this line uses LF -// this line uses LF -// this line uses LF diff --git a/test/rules/linebreak-style/failure/LF/test.ts.lint b/test/rules/linebreak-style/failure/LF/test.ts.lint deleted file mode 100644 index fa51e943c77..00000000000 --- a/test/rules/linebreak-style/failure/LF/test.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -// this line uses LF -~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] -// this line uses LF -~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] -// this line uses LF -~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] -// this line uses LF -~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] diff --git a/test/rules/linebreak-style/failure/LF/tslint.json b/test/rules/linebreak-style/failure/LF/tslint.json deleted file mode 100644 index d959e7a49e4..00000000000 --- a/test/rules/linebreak-style/failure/LF/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "linebreak-style": [true, "CRLF"] - } -} diff --git a/test/rules/linebreak-style/success/CRLF/test.ts.lint b/test/rules/linebreak-style/success/CRLF/test.ts.lint deleted file mode 100644 index 4a60171c332..00000000000 --- a/test/rules/linebreak-style/success/CRLF/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -// this line uses CRLF -// this line uses CRLF -// this line uses CRLF -// this line uses CRLF diff --git a/test/rules/linebreak-style/success/CRLF/tslint.json b/test/rules/linebreak-style/success/CRLF/tslint.json deleted file mode 100644 index d959e7a49e4..00000000000 --- a/test/rules/linebreak-style/success/CRLF/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "linebreak-style": [true, "CRLF"] - } -} diff --git a/test/rules/linebreak-style/success/LF/test.ts.lint b/test/rules/linebreak-style/success/LF/test.ts.lint deleted file mode 100644 index 1f88a5a75a2..00000000000 --- a/test/rules/linebreak-style/success/LF/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -// this line uses LF -// this line uses LF -// this line uses LF -// this line uses LF diff --git a/test/rules/linebreak-style/success/LF/tslint.json b/test/rules/linebreak-style/success/LF/tslint.json deleted file mode 100644 index f82a6f4d1df..00000000000 --- a/test/rules/linebreak-style/success/LF/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "linebreak-style": [true, "LF"] - } -} diff --git a/test/rules/match-default-export-name/anonymous.test.ts b/test/rules/match-default-export-name/anonymous.test.ts deleted file mode 100644 index 7f810d3f328..00000000000 --- a/test/rules/match-default-export-name/anonymous.test.ts +++ /dev/null @@ -1 +0,0 @@ -export default 0; diff --git a/test/rules/match-default-export-name/named.test.ts b/test/rules/match-default-export-name/named.test.ts deleted file mode 100644 index c33f5633d79..00000000000 --- a/test/rules/match-default-export-name/named.test.ts +++ /dev/null @@ -1 +0,0 @@ -export default function a() {} diff --git a/test/rules/match-default-export-name/test.ts.lint b/test/rules/match-default-export-name/test.ts.lint deleted file mode 100644 index 5fdb33083bd..00000000000 --- a/test/rules/match-default-export-name/test.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -import b from "./named.test"; - ~ [Expected import 'b' to match the default export 'a'.] -import anyName from "./anonymous.test"; diff --git a/test/rules/match-default-export-name/tsconfig.json b/test/rules/match-default-export-name/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/match-default-export-name/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/match-default-export-name/tslint.json b/test/rules/match-default-export-name/tslint.json deleted file mode 100644 index be090e5892d..00000000000 --- a/test/rules/match-default-export-name/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "match-default-export-name": true - } -} diff --git a/test/rules/max-classes-per-file/one/test.ts.lint b/test/rules/max-classes-per-file/one/test.ts.lint deleted file mode 100644 index a2910cb15f6..00000000000 --- a/test/rules/max-classes-per-file/one/test.ts.lint +++ /dev/null @@ -1,35 +0,0 @@ -export abstract class UnsupportedVisitor extends NodeVisitor { - public static withDescriptor(descriptor: string): typeof UnsupportedVisitor { - return class extends UnsupportedVisitor { - protected descriptor = descriptor; - }; - } - - protected abstract descriptor: string; - - public visit(node: Node): undefined { - return `${this.descriptor} is not supported.`; - } -} - -class one { -~~~~~~~~~~~ - public foo = "bar"; -~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [0] - -class two { -~~~~~~~~~~~ - public banana = "apple"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - public theAbovePropertyMakesSense = false; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [0] - -let three = class { - public foo = "bar"; -} - -[0]: A maximum of 1 class per file is allowed. diff --git a/test/rules/max-classes-per-file/one/tslint.json b/test/rules/max-classes-per-file/one/tslint.json deleted file mode 100644 index 62170ab7c05..00000000000 --- a/test/rules/max-classes-per-file/one/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "max-classes-per-file": [true, 1, "exclude-class-expressions"] - } -} diff --git a/test/rules/max-classes-per-file/two/test.ts.lint b/test/rules/max-classes-per-file/two/test.ts.lint deleted file mode 100644 index 38e499b87e5..00000000000 --- a/test/rules/max-classes-per-file/two/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -class one { - public foo = "bar"; -} - -class two { - public foo = "bar"; -} - -let three = class { - ~~~~~~~ - public foo = "bar"; -~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [0] - -class four { -~~~~~~~~~~~~ - public foo = "bar"; -~~~~~~~~~~~~~~~~~~~~~~~ -} -~ [0] - -[0]: A maximum of 2 classes per file are allowed. diff --git a/test/rules/max-classes-per-file/two/tslint.json b/test/rules/max-classes-per-file/two/tslint.json deleted file mode 100644 index 2064f81ad82..00000000000 --- a/test/rules/max-classes-per-file/two/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "max-classes-per-file": [true, 2] - } -} diff --git a/test/rules/max-file-line-count/default/test.ts.lint b/test/rules/max-file-line-count/default/test.ts.lint deleted file mode 100644 index d6425abcfce..00000000000 --- a/test/rules/max-file-line-count/default/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -namespace App { - class GiveMeANumber { - - /* tslint:disable:no-any */ - private num:any = 10; - /* tslint:enable:no-any */ - - //This is some kind of comment - constructor(){ - this.giveNumber(); - } - - /* - Here is another comment - It's very helpful. - */ - - public giveNumber = () =>{ - alert(this.num); - }; - } -} -~ [This file has 22 lines, which exceeds the maximum of 10 lines allowed. Consider breaking this file up into smaller parts] \ No newline at end of file diff --git a/test/rules/max-file-line-count/default/tslint.json b/test/rules/max-file-line-count/default/tslint.json deleted file mode 100644 index 0a612cdcda6..00000000000 --- a/test/rules/max-file-line-count/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "max-file-line-count": [true, 10] - } -} diff --git a/test/rules/max-file-line-count/disabled/test.ts.lint b/test/rules/max-file-line-count/disabled/test.ts.lint deleted file mode 100644 index b648ec13e27..00000000000 --- a/test/rules/max-file-line-count/disabled/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -//This file NEEDS to be very long, so we've disabled this rule here - -/* tslint:disable:max-file-line-count */ - -namespace App { - class GiveMeANumber { - - //THis is a comment about something - private num = 10; - - constructor(){ - this.giveNumber(); - } - - /* - Here is another comment - It's very helpful. - */ - - public giveNumber = () =>{ - alert(this.num); - }; - } -} diff --git a/test/rules/max-file-line-count/disabled/tslint.json b/test/rules/max-file-line-count/disabled/tslint.json deleted file mode 100644 index 0a612cdcda6..00000000000 --- a/test/rules/max-file-line-count/disabled/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "max-file-line-count": [true, 10] - } -} diff --git a/test/rules/max-line-length/check-strings-and-regex/test.ts.lint b/test/rules/max-line-length/check-strings-and-regex/test.ts.lint deleted file mode 100644 index 438b13a6f8e..00000000000 --- a/test/rules/max-line-length/check-strings-and-regex/test.ts.lint +++ /dev/null @@ -1,33 +0,0 @@ -import { KindOfOneVerySpecificComponentOrSomethingLikeThis } from '../../../../very/very/very/very/very/long/and/complicated/and/nested/directory/structure/target'; - -var simpleName = 1; -var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedName; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicat; - -const extremelyLongSingleQuoteString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const extremelyLongDoubleQuoteString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const extremelyLongTemplateString = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu`; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const extremelyLongTemplateStringWithVariableAtLimit = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod ${simpleName} ut labore et dolore magna aliquyam `; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const multiLineTemplateString = ` -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -`; - -const veryLongRegularExpression = /\s*********************************************************************************************************************/; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: Exceeds maximum line length of 140 \ No newline at end of file diff --git a/test/rules/max-line-length/check-strings-and-regex/tslint.json b/test/rules/max-line-length/check-strings-and-regex/tslint.json deleted file mode 100644 index fd6631ccaae..00000000000 --- a/test/rules/max-line-length/check-strings-and-regex/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "max-line-length": [true, { - "limit": "140", - "ignore-pattern": "^import ", - "check-strings": true, - "check-regex": true - }] - } -} diff --git a/test/rules/max-line-length/default/test.ts.lint b/test/rules/max-line-length/default/test.ts.lint deleted file mode 100644 index eb9b6dc1172..00000000000 --- a/test/rules/max-line-length/default/test.ts.lint +++ /dev/null @@ -1,25 +0,0 @@ -import { KindOfOneVerySpecificComponentOrSomethingLikeThis } from '../../../../very/very/very/very/very/long/and/complicated/and/nested/directory/structure/target'; - -var simpleName = 1; -var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedName; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicat; - -const extremelyLongSingleQuoteString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu'; - -const extremelyLongDoubleQuoteString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu"; - -const extremelyLongTemplateString = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu`; - -const extremelyLongTemplateStringWithVariableAtLimit = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod ${someVariable} ut labore et dolore magna aliquyam `; - -const multiLineTemplateString = ` -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu -`; - -const veryLongRegularExpression = /\s*********************************************************************************************************************/; - -[0]: Exceeds maximum line length of 140 \ No newline at end of file diff --git a/test/rules/max-line-length/default/tslint.json b/test/rules/max-line-length/default/tslint.json deleted file mode 100644 index 5937f62d6a7..00000000000 --- a/test/rules/max-line-length/default/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "max-line-length": [true, { - "limit": 140 - }] - } -} diff --git a/test/rules/member-access/accessor/test.ts.fix b/test/rules/member-access/accessor/test.ts.fix deleted file mode 100644 index 5a91a06fc98..00000000000 --- a/test/rules/member-access/accessor/test.ts.fix +++ /dev/null @@ -1,17 +0,0 @@ -class Members { - public get g() { - return 1; - } - public set s(o: any) {} - - public get publicG() { - return 1; - } - public set publicS(o: any) {} -} - -const obj = { - get g() { - return 1; - } -}; diff --git a/test/rules/member-access/accessor/test.ts.lint b/test/rules/member-access/accessor/test.ts.lint deleted file mode 100644 index 4541a8fbb78..00000000000 --- a/test/rules/member-access/accessor/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -class Members { - get g() { - ~ [The get property accessor 'g' must be marked either 'private', 'public', or 'protected'] - return 1; - } - set s(o: any) {} - ~ [The set property accessor 's' must be marked either 'private', 'public', or 'protected'] - - public get publicG() { - return 1; - } - public set publicS(o: any) {} -} - -const obj = { - get g() { - return 1; - } -}; diff --git a/test/rules/member-access/accessor/tslint.json b/test/rules/member-access/accessor/tslint.json deleted file mode 100644 index 165c6526ab4..00000000000 --- a/test/rules/member-access/accessor/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-access": [true, "check-accessor"] - } -} diff --git a/test/rules/member-access/constructor/test.ts.fix b/test/rules/member-access/constructor/test.ts.fix deleted file mode 100644 index d4b9899da44..00000000000 --- a/test/rules/member-access/constructor/test.ts.fix +++ /dev/null @@ -1,10 +0,0 @@ -class ContructorsNoAccess { - public constructor(i: number); - public constructor(o: any) {} -} - -class ContructorsAccess { - public constructor(i: number); - public constructor(o: any) {} -} - diff --git a/test/rules/member-access/constructor/test.ts.lint b/test/rules/member-access/constructor/test.ts.lint deleted file mode 100644 index 7c140b2da27..00000000000 --- a/test/rules/member-access/constructor/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -class ContructorsNoAccess { - constructor(i: number); - ~~~~~~~~~~~ [0] - constructor(o: any) {} - ~~~~~~~~~~~ [0] -} - -class ContructorsAccess { - public constructor(i: number); - public constructor(o: any) {} -} - -[0]: The class constructor must be marked either 'private', 'public', or 'protected' diff --git a/test/rules/member-access/constructor/tslint.json b/test/rules/member-access/constructor/tslint.json deleted file mode 100644 index 2166eb52f4f..00000000000 --- a/test/rules/member-access/constructor/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-access": [true, "check-constructor"] - } -} diff --git a/test/rules/member-access/default/test.ts.fix b/test/rules/member-access/default/test.ts.fix deleted file mode 100644 index 640a45fc5e9..00000000000 --- a/test/rules/member-access/default/test.ts.fix +++ /dev/null @@ -1,54 +0,0 @@ -declare class AmbientNoAccess { - public a(): number; - - public static b(): number; -} - -declare class AmbientAccess { - public a(): number; - public static b(): number; -} - -class Members { - [x: string]: number; - public i: number; - public static j: number; - - public nPublic: number; - protected nProtected: number; - private nPrivate: number; - - public static nsPublic: number; - protected static nsProtected: number; - private static nsPrivate: number; - - public noAccess(x: number): number; - public noAccess(o: any): any {} - - public static noAccess(x: number): number; - public static noAccess(o: any): any {} - - public access(x: number): number; - public access(o: any): any {} - - public static access(x: number): number; - public static access(o: any): any {} -} - -const obj = { - func() {} -}; - -function main() { - class A { - public i: number; - public static j: number; - public n: number; - } -} - -abstract class Decorated { - @decorator public prop; - @decorator public abstract method() {} - @decorator @moreDecorator({}) public readonly static PROP = 'FOO'; -} diff --git a/test/rules/member-access/default/test.ts.lint b/test/rules/member-access/default/test.ts.lint deleted file mode 100644 index 3f67fc4fa21..00000000000 --- a/test/rules/member-access/default/test.ts.lint +++ /dev/null @@ -1,67 +0,0 @@ -declare class AmbientNoAccess { - a(): number; - ~ [The class method 'a' must be marked either 'private', 'public', or 'protected'] - - static b(): number; - ~ [The class method 'b' must be marked either 'private', 'public', or 'protected'] -} - -declare class AmbientAccess { - public a(): number; - public static b(): number; -} - -class Members { - [x: string]: number; - i: number; - ~ [The class property 'i' must be marked either 'private', 'public', or 'protected'] - static j: number; - ~ [The class property 'j' must be marked either 'private', 'public', or 'protected'] - - public nPublic: number; - protected nProtected: number; - private nPrivate: number; - - public static nsPublic: number; - protected static nsProtected: number; - private static nsPrivate: number; - - noAccess(x: number): number; - ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] - noAccess(o: any): any {} - ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] - - static noAccess(x: number): number; - ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] - static noAccess(o: any): any {} - ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] - - public access(x: number): number; - public access(o: any): any {} - - public static access(x: number): number; - public static access(o: any): any {} -} - -const obj = { - func() {} -}; - -function main() { - class A { - i: number; - ~ [The class property 'i' must be marked either 'private', 'public', or 'protected'] - static j: number; - ~ [The class property 'j' must be marked either 'private', 'public', or 'protected'] - public n: number; - } -} - -abstract class Decorated { - @decorator prop; - ~~~~ [The class property 'prop' must be marked either 'private', 'public', or 'protected'] - @decorator abstract method() {} - ~~~~~~ [The class method 'method' must be marked either 'private', 'public', or 'protected'] - @decorator @moreDecorator({}) readonly static PROP = 'FOO'; - ~~~~ [The class property 'PROP' must be marked either 'private', 'public', or 'protected'] -} diff --git a/test/rules/member-access/default/tslint.json b/test/rules/member-access/default/tslint.json deleted file mode 100644 index f9c417e0902..00000000000 --- a/test/rules/member-access/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-access": true - } -} diff --git a/test/rules/member-access/no-public/test.ts.fix b/test/rules/member-access/no-public/test.ts.fix deleted file mode 100644 index 25f61ce9e3a..00000000000 --- a/test/rules/member-access/no-public/test.ts.fix +++ /dev/null @@ -1,12 +0,0 @@ -class { - x() {} - constructor() {} - get y() {} - public() {} - constructor(readonly param : number) {} - constructor(readonly param : number) {} - constructor(private readonly paramPrivate : number, protected readonly paramProtected : number, readonly paramReadonly : number) {} - - constructor(public necessaryPublic : number) {} -} - diff --git a/test/rules/member-access/no-public/test.ts.lint b/test/rules/member-access/no-public/test.ts.lint deleted file mode 100644 index 138f6d73841..00000000000 --- a/test/rules/member-access/no-public/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -class { - public x() {} - ~~~~~~ [0] - public constructor() {} - ~~~~~~ [0] - public/*some comment*/ get y() {} - ~~~~~~ [0] - public() {} - constructor(public readonly param : number) {} - ~~~~~~ [0] - public constructor(public readonly param : number) {} - ~~~~~~ [0] - ~~~~~~ [0] - constructor(private readonly paramPrivate : number, protected readonly paramProtected : number, readonly paramReadonly : number) {} - - constructor(public necessaryPublic : number) {} -} - -[0]: 'public' is implicit. diff --git a/test/rules/member-access/no-public/tslint.json b/test/rules/member-access/no-public/tslint.json deleted file mode 100644 index bb4607c80fd..00000000000 --- a/test/rules/member-access/no-public/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-access": [true, "no-public"] - } -} diff --git a/test/rules/member-access/parameter-property/test.ts.fix b/test/rules/member-access/parameter-property/test.ts.fix deleted file mode 100644 index 889981a518c..00000000000 --- a/test/rules/member-access/parameter-property/test.ts.fix +++ /dev/null @@ -1,17 +0,0 @@ -class Members { - constructor( - public readonly paramReadonly : number, - public paramPublic : number, - protected paramProtected : number, - private paramPrivate : number, - public readonly paramPublicReadonly : number, - protected readonly paramProtectedReadonly : number, - private readonly paramPrivateReadonly : number - ){ - - } - - constructor(public readonly a : number, @decorated public readonly b : number) { - - } -} diff --git a/test/rules/member-access/parameter-property/test.ts.lint b/test/rules/member-access/parameter-property/test.ts.lint deleted file mode 100644 index 2c110ca7a31..00000000000 --- a/test/rules/member-access/parameter-property/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -class Members { - constructor( - readonly paramReadonly : number, - ~~~~~~~~~~~~~ [The parameter property 'paramReadonly' must be marked either 'private', 'public', or 'protected'] - public paramPublic : number, - protected paramProtected : number, - private paramPrivate : number, - public readonly paramPublicReadonly : number, - protected readonly paramProtectedReadonly : number, - private readonly paramPrivateReadonly : number - ){ - - } - - constructor(readonly a : number, @decorated readonly b : number) { - ~ [The parameter property 'a' must be marked either 'private', 'public', or 'protected'] - ~ [The parameter property 'b' must be marked either 'private', 'public', or 'protected'] - - } -} diff --git a/test/rules/member-access/parameter-property/tslint.json b/test/rules/member-access/parameter-property/tslint.json deleted file mode 100644 index d4c6243e573..00000000000 --- a/test/rules/member-access/parameter-property/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-access": [true, "check-parameter-property"] - } -} diff --git a/test/rules/member-ordering/alphabetize-nested/test.ts.fix b/test/rules/member-ordering/alphabetize-nested/test.ts.fix deleted file mode 100644 index 7463bdea548..00000000000 --- a/test/rules/member-ordering/alphabetize-nested/test.ts.fix +++ /dev/null @@ -1,14 +0,0 @@ -class X { - a() { - class A { - e() {} - f() {} - } - } - b() { - class B { - c() {} - d() {} - } - } -} diff --git a/test/rules/member-ordering/alphabetize-nested/test.ts.lint b/test/rules/member-ordering/alphabetize-nested/test.ts.lint deleted file mode 100644 index 59d0e971cb9..00000000000 --- a/test/rules/member-ordering/alphabetize-nested/test.ts.lint +++ /dev/null @@ -1,17 +0,0 @@ -class X { - b() { - class B { - d() {} - c() {} - ~ ['c' should come alphabetically before 'd'] - } - } - a() { - ~ ['a' should come alphabetically before 'b'] - class A { - f() {} - e() {} - ~ ['e' should come alphabetically before 'f'] - } - } -} diff --git a/test/rules/member-ordering/alphabetize-nested/tslint.json b/test/rules/member-ordering/alphabetize-nested/tslint.json deleted file mode 100644 index d63ae1f4057..00000000000 --- a/test/rules/member-ordering/alphabetize-nested/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { - "order": "fields-first", - "alphabetize": true - }] - } -} diff --git a/test/rules/member-ordering/alphabetize/test.ts.fix b/test/rules/member-ordering/alphabetize/test.ts.fix deleted file mode 100644 index bc854ab87a3..00000000000 --- a/test/rules/member-ordering/alphabetize/test.ts.fix +++ /dev/null @@ -1,32 +0,0 @@ -class X { - // Different categories have alphabetization together. - bar: number; - foo: string; - - get y() { - return 0; - } - set y(x: number) {} - get z() { - return 0; - } - - set z(x: number) {} - - [Symbol.iterator]() {} - // No ordering among computed properties - [Symbol.alpherator]() {} - - // Computed properties must go at the beginning. - [Symbol.zeterator]() {} - - 0() {} - 1() {} - 2() {} - bar() {} - - foo() {} - "goo"() {} - Hoo() {} - ioo() {} -} diff --git a/test/rules/member-ordering/alphabetize/test.ts.lint b/test/rules/member-ordering/alphabetize/test.ts.lint deleted file mode 100644 index 6ae168f0267..00000000000 --- a/test/rules/member-ordering/alphabetize/test.ts.lint +++ /dev/null @@ -1,38 +0,0 @@ -class X { - // Different categories have alphabetization together. - bar: number; - foo: string; - - set z(x: number) {} - get z() { - ~ [Getter for 'z' should appear before setter.] - return 0; - } - - get y() { - ~ ['y' should come alphabetically before 'z'] - return 0; - } - set y(x: number) {} - ~ ['y' should come alphabetically before 'z'] - - [Symbol.iterator]() {} - // No ordering among computed properties - [Symbol.alpherator]() {} - - 0() {} - 2() {} - 1() {} - ~ ['1' should come alphabetically before '2'] - - foo() {} - "goo"() {} - Hoo() {} - ioo() {} - bar() {} - ~~~ ['bar' should come alphabetically before 'foo'] - - // Computed properties must go at the beginning. - [Symbol.zeterator]() {} - ~~~~~~~~~~~~~~~~~~ [Computed property should come alphabetically before '0'] -} diff --git a/test/rules/member-ordering/alphabetize/tslint.json b/test/rules/member-ordering/alphabetize/tslint.json deleted file mode 100644 index d63ae1f4057..00000000000 --- a/test/rules/member-ordering/alphabetize/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { - "order": "fields-first", - "alphabetize": true - }] - } -} diff --git a/test/rules/member-ordering/custom-categories/test.ts.fix b/test/rules/member-ordering/custom-categories/test.ts.fix deleted file mode 100644 index ad7d44f2f54..00000000000 --- a/test/rules/member-ordering/custom-categories/test.ts.fix +++ /dev/null @@ -1,9 +0,0 @@ -class C { - static foo() {} - protected static bar = 0; - static baz(); - - static bang(); - - constructor(); -} diff --git a/test/rules/member-ordering/custom-categories/test.ts.lint b/test/rules/member-ordering/custom-categories/test.ts.lint deleted file mode 100644 index 6df80c3273e..00000000000 --- a/test/rules/member-ordering/custom-categories/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -class C { - static foo() {} - protected static bar = 0; - static baz(); - - constructor(); - - static bang(); - ~~~~~~~~~~~~~~ [Declaration of static non-private not allowed after declaration of constructor. Instead, this should come at the beginning of the class/interface.] -} diff --git a/test/rules/member-ordering/custom-categories/tslint.json b/test/rules/member-ordering/custom-categories/tslint.json deleted file mode 100644 index ddacc962238..00000000000 --- a/test/rules/member-ordering/custom-categories/tslint.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { - "order": [ - { - "name": "static non-private", - "kinds": [ - "public-static-field", - "protected-static-field", - "public-static-method", - "protected-static-method" - ] - }, - "constructor" - ] - }] - } -} diff --git a/test/rules/member-ordering/custom/test.ts.fix b/test/rules/member-ordering/custom/test.ts.fix deleted file mode 100644 index 51d32ec08dd..00000000000 --- a/test/rules/member-ordering/custom/test.ts.fix +++ /dev/null @@ -1,35 +0,0 @@ -class Good { - constructor() {} - bar = 5; - static foo() {} - private z = 12; - private static zz = 10; -} - -class Bad { - constructor() {} - private static a() {} - static b() {} - private c = 2; -} - -class AlsoOkay { - constructor() { - const bar = { - someMethod() {} - }; - } - - private z = 10; -} - -const foo = { - // TS treats this as a method, but we should be careful not to - someMethod() {} -}; - -function makeAClass() { - const myClass = class { - method(){} - }; -} diff --git a/test/rules/member-ordering/custom/test.ts.lint b/test/rules/member-ordering/custom/test.ts.lint deleted file mode 100644 index 6a4f8d749e2..00000000000 --- a/test/rules/member-ordering/custom/test.ts.lint +++ /dev/null @@ -1,36 +0,0 @@ -class Good { - constructor() {} - bar = 5; - static foo() {} - private z = 12; - private static zz = 10; -} - -class Bad { - constructor() {} - private static a() {} - private c = 2; - static b() {} - ~~~~~~~~~~~~~ [Declaration of public static method not allowed after declaration of private instance field. Instead, this should come at the beginning of the class/interface.] -} - -class AlsoOkay { - constructor() { - const bar = { - someMethod() {} - }; - } - - private z = 10; -} - -const foo = { - // TS treats this as a method, but we should be careful not to - someMethod() {} -}; - -function makeAClass() { - const myClass = class { - method(){} - }; -} diff --git a/test/rules/member-ordering/custom/tslint.json b/test/rules/member-ordering/custom/tslint.json deleted file mode 100644 index 5b8c7471e59..00000000000 --- a/test/rules/member-ordering/custom/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { "order": [ - "public-static-method", - "private-instance-field" - ]}] - } -} diff --git a/test/rules/member-ordering/fields-first/test.ts.fix b/test/rules/member-ordering/fields-first/test.ts.fix deleted file mode 100644 index 7c3057e9753..00000000000 --- a/test/rules/member-ordering/fields-first/test.ts.fix +++ /dev/null @@ -1,37 +0,0 @@ -class Good { - public static a = 1; - protected static b = 2; - private static c = 3; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - public static g() {} - protected static h() {} - private static i = () => {}; - j = () => {}; - protected k() {}; - private l = () => {}; -} - -interface IGood { - foo: number; - arrowsAreFields: () => void; - nonArrowsAreMethods(): void; -} - -class Bad { - public static a = 1; - protected static b = 2; - private static c = 3; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - public static g() {} - protected static h() {} - private static i = () => {}; - j = () => {}; - protected k() {} - private l = () => {}; -} diff --git a/test/rules/member-ordering/fields-first/test.ts.lint b/test/rules/member-ordering/fields-first/test.ts.lint deleted file mode 100644 index 4769de116d0..00000000000 --- a/test/rules/member-ordering/fields-first/test.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -class Good { - public static a = 1; - protected static b = 2; - private static c = 3; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - public static g() {} - protected static h() {} - private static i = () => {}; - j = () => {}; - protected k() {}; - private l = () => {}; -} - -interface IGood { - foo: number; - arrowsAreFields: () => void; - nonArrowsAreMethods(): void; -} - -class Bad { - public static a = 1; - protected static b = 2; - public d = 4; - protected e: number = 5; - private static c = 3; - ~~~~~~~~~~~~~~~~~~~~~ [Declaration of private static field not allowed after declaration of protected instance field. Instead, this should come after protected static fields.] - private f = foo(); - public static g() {} - protected static h() {} - private static i = () => {}; - j = () => {}; - protected k() {} - constructor() {} - ~~~~~~~~~~~~~~~~ [Declaration of constructor not allowed after declaration of protected instance method. Instead, this should come after private instance fields.] - private l = () => {}; -} diff --git a/test/rules/member-ordering/fields-first/tslint.json b/test/rules/member-ordering/fields-first/tslint.json deleted file mode 100644 index 5c797489522..00000000000 --- a/test/rules/member-ordering/fields-first/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { "order": "fields-first" }] - } -} diff --git a/test/rules/member-ordering/fix-trivia/test.ts.fix b/test/rules/member-ordering/fix-trivia/test.ts.fix deleted file mode 100644 index e76c436a61e..00000000000 --- a/test/rules/member-ordering/fix-trivia/test.ts.fix +++ /dev/null @@ -1,23 +0,0 @@ -class A { - - /** - * bar() JSDoc. - */ - bar() { - return 2; - } // bar trailing comment - - /** - * foo() JSDoc. - */ - foo(x: string): number - // an overload taking a string - foo(x: number): number // comment after foo(x: number) - foo(x: string | number): number { - return 1; - } // foo trailing comment -} - -class B { -declaration() {} // 4 -line() {} /* 3 */ /* 1 */ single() {} /* 2 */ } diff --git a/test/rules/member-ordering/fix-trivia/test.ts.lint b/test/rules/member-ordering/fix-trivia/test.ts.lint deleted file mode 100644 index 2f6e456bbdb..00000000000 --- a/test/rules/member-ordering/fix-trivia/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -class A { - - /** - * foo() JSDoc. - */ - foo(x: string): number - // an overload taking a string - foo(x: number): number // comment after foo(x: number) - foo(x: string | number): number { - return 1; - } // foo trailing comment - - /** - * bar() JSDoc. - */ - bar() { - ~~~ ['bar' should come alphabetically before 'foo'] - return 2; - } // bar trailing comment -} - -class B { - /* 1 */ single() {} /* 2 */ line() {} /* 3 */ declaration() {} // 4 - ~~~~ ['line' should come alphabetically before 'single'] - ~~~~~~~~~~~ ['declaration' should come alphabetically before 'single'] -} diff --git a/test/rules/member-ordering/fix-trivia/tslint.json b/test/rules/member-ordering/fix-trivia/tslint.json deleted file mode 100644 index d63ae1f4057..00000000000 --- a/test/rules/member-ordering/fix-trivia/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { - "order": "fields-first", - "alphabetize": true - }] - } -} diff --git a/test/rules/member-ordering/instance-sandwich/test.ts.fix b/test/rules/member-ordering/instance-sandwich/test.ts.fix deleted file mode 100644 index 5043f06924e..00000000000 --- a/test/rules/member-ordering/instance-sandwich/test.ts.fix +++ /dev/null @@ -1,37 +0,0 @@ -class Good { - public static a = 1; - protected static b = 2; - private static c = 3; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - j = () => {}; - protected k() {} - private l = () => {}; - public static g() {} - protected static h() {} - private static i = () => {}; -} - -interface IGood { - foo: number; - arrowsAreFields: () => void; - nonArrowsAreMethods(): void; -} - -class Bad { - public static a = 1; - protected static b = 2; - private static c = 3; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - j = () => {}; - protected k() {} - private l = () => {}; - public static g() {} - protected static h() {} - private static i = () => {}; -} diff --git a/test/rules/member-ordering/instance-sandwich/test.ts.lint b/test/rules/member-ordering/instance-sandwich/test.ts.lint deleted file mode 100644 index 537ce64d9af..00000000000 --- a/test/rules/member-ordering/instance-sandwich/test.ts.lint +++ /dev/null @@ -1,40 +0,0 @@ -class Good { - public static a = 1; - protected static b = 2; - private static c = 3; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - j = () => {}; - protected k() {} - private l = () => {}; - public static g() {} - protected static h() {} - private static i = () => {}; -} - -interface IGood { - foo: number; - arrowsAreFields: () => void; - nonArrowsAreMethods(): void; -} - -class Bad { - public static a = 1; - public d = 4; - protected static b = 2; - ~~~~~~~~~~~~~~~~~~~~~~~ [Declaration of protected static field not allowed after declaration of public instance field. Instead, this should come after public static fields.] - private static c = 3; - ~~~~~~~~~~~~~~~~~~~~~ [Declaration of private static field not allowed after declaration of public instance field. Instead, this should come after protected static fields.] - protected e: number = 5; - private f = foo(); - j = () => {}; - protected k() {} - private l = () => {}; - public static g() {} - protected static h() {} - private static i = () => {}; - constructor() {} - ~~~~~~~~~~~~~~~~ [Declaration of constructor not allowed after declaration of private static method. Instead, this should come after private instance fields.] -} diff --git a/test/rules/member-ordering/instance-sandwich/tslint.json b/test/rules/member-ordering/instance-sandwich/tslint.json deleted file mode 100644 index db381ec0429..00000000000 --- a/test/rules/member-ordering/instance-sandwich/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { "order": "instance-sandwich" }] - } -} diff --git a/test/rules/member-ordering/mix-old-options/test.ts.fix b/test/rules/member-ordering/mix-old-options/test.ts.fix deleted file mode 100644 index 677ce8b2228..00000000000 --- a/test/rules/member-ordering/mix-old-options/test.ts.fix +++ /dev/null @@ -1,15 +0,0 @@ -class Foo { - public static x: number; - private static y: number; - public x: number; - - z: number; - private y: number; - - public static m() {} - private static n() {} - - constructor() {} - public m() {} - private n() {} -} diff --git a/test/rules/member-ordering/mix-old-options/test.ts.lint b/test/rules/member-ordering/mix-old-options/test.ts.lint deleted file mode 100644 index 109ef9699e3..00000000000 --- a/test/rules/member-ordering/mix-old-options/test.ts.lint +++ /dev/null @@ -1,16 +0,0 @@ -class Foo { - public static x: number; - private static y: number; - public x: number; - private y: number; - - public static m() {} - private static n() {} - - constructor() {} - public m() {} - private n() {} - - z: number; - ~~~~~~~~~~ [Declaration of public instance field not allowed after declaration of private instance method. Instead, this should come after private static fields.] -} diff --git a/test/rules/member-ordering/mix-old-options/tslint.json b/test/rules/member-ordering/mix-old-options/tslint.json deleted file mode 100644 index 659333c1fbe..00000000000 --- a/test/rules/member-ordering/mix-old-options/tslint.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "rules": { - "member-ordering": [true, - "public-before-private", - "static-before-instance", - "variables-before-functions" - ] - } -} diff --git a/test/rules/member-ordering/omit-access-modifier/test.ts.fix b/test/rules/member-ordering/omit-access-modifier/test.ts.fix deleted file mode 100644 index adc639d8934..00000000000 --- a/test/rules/member-ordering/omit-access-modifier/test.ts.fix +++ /dev/null @@ -1,11 +0,0 @@ -class C { - private static x = 0; - static y = 1; - - static z = 2; - - x = 0; - private y = 1; - - constructor() {} -} diff --git a/test/rules/member-ordering/omit-access-modifier/test.ts.lint b/test/rules/member-ordering/omit-access-modifier/test.ts.lint deleted file mode 100644 index fdfbf683047..00000000000 --- a/test/rules/member-ordering/omit-access-modifier/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -class C { - private static x = 0; - static y = 1; - - x = 0; - private y = 1; - - constructor() {} - - static z = 2; - ~~~~~~~~~~~~~ [Declaration of static field not allowed after declaration of constructor. Instead, this should come at the beginning of the class/interface.] -} diff --git a/test/rules/member-ordering/omit-access-modifier/tslint.json b/test/rules/member-ordering/omit-access-modifier/tslint.json deleted file mode 100644 index c88314eb612..00000000000 --- a/test/rules/member-ordering/omit-access-modifier/tslint.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { "order": [ - "static-field", - "instance-field", - "constructor" - ]}] - } -} diff --git a/test/rules/member-ordering/public-before-private/test.ts.fix b/test/rules/member-ordering/public-before-private/test.ts.fix deleted file mode 100644 index f714c2a6e33..00000000000 --- a/test/rules/member-ordering/public-before-private/test.ts.fix +++ /dev/null @@ -1,8 +0,0 @@ -class Foo { - y: number; - private x: number; - private bar(): any { - var bla: { a: string } = {a: '1'}; - } -} - diff --git a/test/rules/member-ordering/public-before-private/test.ts.lint b/test/rules/member-ordering/public-before-private/test.ts.lint deleted file mode 100644 index c26be55d8ac..00000000000 --- a/test/rules/member-ordering/public-before-private/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -class Foo { - private x: number; - private bar(): any { - var bla: { a: string } = {a: '1'}; - } - y: number; - ~~~~~~~~~~ [0] -} - -[0]: Declaration of public member not allowed after declaration of private member. Instead, this should come at the beginning of the class/interface. diff --git a/test/rules/member-ordering/public-before-private/tslint.json b/test/rules/member-ordering/public-before-private/tslint.json deleted file mode 100644 index 9b2be79af85..00000000000 --- a/test/rules/member-ordering/public-before-private/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-ordering": [true, "public-before-private"] - } -} diff --git a/test/rules/member-ordering/static-before-instance/test.ts.fix b/test/rules/member-ordering/static-before-instance/test.ts.fix deleted file mode 100644 index 05a93c60f2a..00000000000 --- a/test/rules/member-ordering/static-before-instance/test.ts.fix +++ /dev/null @@ -1,8 +0,0 @@ -class Foo { - static y: number; - x: number; - constructor() { - // nothing to do - } -} - diff --git a/test/rules/member-ordering/static-before-instance/test.ts.lint b/test/rules/member-ordering/static-before-instance/test.ts.lint deleted file mode 100644 index 532440d9837..00000000000 --- a/test/rules/member-ordering/static-before-instance/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -class Foo { - x: number; - static y: number; - ~~~~~~~~~~~~~~~~~ [0] - constructor() { - // nothing to do - } -} - -[0]: Declaration of static member not allowed after declaration of instance member. Instead, this should come at the beginning of the class/interface. diff --git a/test/rules/member-ordering/static-before-instance/tslint.json b/test/rules/member-ordering/static-before-instance/tslint.json deleted file mode 100644 index 01c8d924d1e..00000000000 --- a/test/rules/member-ordering/static-before-instance/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-ordering": [true, "static-before-instance"] - } -} diff --git a/test/rules/member-ordering/statics-first/test.ts.fix b/test/rules/member-ordering/statics-first/test.ts.fix deleted file mode 100644 index 36999db9354..00000000000 --- a/test/rules/member-ordering/statics-first/test.ts.fix +++ /dev/null @@ -1,37 +0,0 @@ -class Good { - public static a = 1; - public static g() {} - protected static b = 2; - protected static h() {} - private static c = 3; - private static i = () => {}; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - j = () => {}; - protected k() {} - private l = () => {}; -} - -interface IGood { - foo: number; - arrowsAreFields: () => void; - nonArrowsAreMethods(): void; -} - -class Bad { - public static a = 1; - public static g() {} - protected static b = 2; - protected static h() {} - private static c = 3; - private static i = () => {}; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - j = () => {}; - protected k() {} - private l = () => {}; -} diff --git a/test/rules/member-ordering/statics-first/test.ts.lint b/test/rules/member-ordering/statics-first/test.ts.lint deleted file mode 100644 index a4d4ed2e1f5..00000000000 --- a/test/rules/member-ordering/statics-first/test.ts.lint +++ /dev/null @@ -1,41 +0,0 @@ -class Good { - public static a = 1; - public static g() {} - protected static b = 2; - protected static h() {} - private static c = 3; - private static i = () => {}; - public d = 4; - protected e: number = 5; - private f = foo(); - constructor() {} - j = () => {}; - protected k() {} - private l = () => {}; -} - -interface IGood { - foo: number; - arrowsAreFields: () => void; - nonArrowsAreMethods(): void; -} - -class Bad { - public static a = 1; - private static c = 3; - public static g() {} - ~~~~~~~~~~~~~~~~~~~~ [Declaration of public static method not allowed after declaration of private static field. Instead, this should come after public static fields.] - protected static h() {} - ~~~~~~~~~~~~~~~~~~~~~~~ [Declaration of protected static method not allowed after declaration of private static field. Instead, this should come after protected static fields.] - private static i = () => {}; - public d = 4; - protected static b = 2; - ~~~~~~~~~~~~~~~~~~~~~~~ [Declaration of protected static field not allowed after declaration of public instance field. Instead, this should come after public static methods.] - protected e: number = 5; - constructor() {} - j = () => {}; - protected k() {} - private f = foo(); - ~~~~~~~~~~~~~~~~~~ [Declaration of private instance field not allowed after declaration of protected instance method. Instead, this should come after protected instance fields.] - private l = () => {}; -} diff --git a/test/rules/member-ordering/statics-first/tslint.json b/test/rules/member-ordering/statics-first/tslint.json deleted file mode 100644 index bf764615abc..00000000000 --- a/test/rules/member-ordering/statics-first/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-ordering": [true, { "order": "statics-first" }] - } -} diff --git a/test/rules/member-ordering/variables-before-functions/test.ts.fix b/test/rules/member-ordering/variables-before-functions/test.ts.fix deleted file mode 100644 index b1d89382406..00000000000 --- a/test/rules/member-ordering/variables-before-functions/test.ts.fix +++ /dev/null @@ -1,63 +0,0 @@ -// ensure that Bar and Baz do not get conflated -interface Bar { - x(): void; -} - -interface Baz { - y: number; -} - -interface BarBaz { - y: number; - x(): void; -} - -class Foo { - y: number; - x(): void {} -} - -interface IArrowMethods { - a: number; - d: () => void; - b(): void; -} - -class ArrowMethods { - public a = 5; - private callback: () => void - public b = "foo"; - public c() {} - public d = () => {}; - public e = function() {}; -} - -class OutOfOrder { - b = 5; - a = () => {}; -} - -class Constructor1 { - blah: number = 0; - constructor() {} -} - -class Constructor2 { - blah: number = 0; - constructor() {} -} - -// Works for type literal, just like interface -type T = { - y: number; - x(): void; -} - -// Works for class inside object literal -const o = { - foo: class C { - y: number; - x(): void; - } -} - diff --git a/test/rules/member-ordering/variables-before-functions/test.ts.lint b/test/rules/member-ordering/variables-before-functions/test.ts.lint deleted file mode 100644 index e657b567d72..00000000000 --- a/test/rules/member-ordering/variables-before-functions/test.ts.lint +++ /dev/null @@ -1,71 +0,0 @@ -// ensure that Bar and Baz do not get conflated -interface Bar { - x(): void; -} - -interface Baz { - y: number; -} - -interface BarBaz { - x(): void; - y: number; - ~~~~~~~~~~ [0] -} - -class Foo { - x(): void {} - y: number; - ~~~~~~~~~~ [0] -} - -interface IArrowMethods { - a: number; - b(): void; - d: () => void; - ~~~~~~~~~~~~~~ [0] -} - -class ArrowMethods { - public a = 5; - private callback: () => void - public b = "foo"; - public c() {} - public d = () => {}; - public e = function() {}; -} - -class OutOfOrder { - a = () => {}; - b = 5; - ~~~~~~ [0] -} - -class Constructor1 { - blah: number = 0; - constructor() {} -} - -class Constructor2 { - constructor() {} - blah: number = 0; - ~~~~~~~~~~~~~~~~~ [0] -} - -// Works for type literal, just like interface -type T = { - x(): void; - y: number; - ~~~~~~~~~~ [0] -} - -// Works for class inside object literal -const o = { - foo: class C { - x(): void; - y: number; - ~~~~~~~~~~ [0] - } -} - -[0]: Declaration of field not allowed after declaration of method. Instead, this should come at the beginning of the class/interface. diff --git a/test/rules/member-ordering/variables-before-functions/tslint.json b/test/rules/member-ordering/variables-before-functions/tslint.json deleted file mode 100644 index 9be59dcd531..00000000000 --- a/test/rules/member-ordering/variables-before-functions/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "member-ordering": [true, "variables-before-functions"] - } -} diff --git a/test/rules/new-parens/test.ts.lint b/test/rules/new-parens/test.ts.lint deleted file mode 100644 index 733f48ed974..00000000000 --- a/test/rules/new-parens/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -// correct case -var foo = new Date(); - -// incorrect case -var foge = new Date; - ~~~~~~~~ [0] -class Bar {} -var bar = new Bar; - ~~~~~~~ [0] -var fogefoge = new Bar(new Foo); - ~~~~~~~ [0] - -[0]: Parentheses are required when invoking a constructor - diff --git a/test/rules/new-parens/tslint.json b/test/rules/new-parens/tslint.json deleted file mode 100644 index 7cd049d2253..00000000000 --- a/test/rules/new-parens/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "new-parens": true - } -} diff --git a/test/rules/newline-before-return/default/test.ts.fix b/test/rules/newline-before-return/default/test.ts.fix deleted file mode 100644 index bfde13a5783..00000000000 --- a/test/rules/newline-before-return/default/test.ts.fix +++ /dev/null @@ -1,126 +0,0 @@ -function foo(bar) { - if (!bar) { - return; - } - - return bar; -} - -function foo(bar) { - if (!bar) { - var statement = ''; - - return statement; - } - - return bar; -} - -function foo(bar) { - if (!bar) { - return; - } - - /* multi-line - comment */ - return bar; -} - -var fn = () => null; -function foo() { - fn(); - - return; -} - -function foo(fn) { - fn(); - - return; -} - -function foo(fn) { - fn(); - - return; -} - -function foo(fn) { - fn(); - - return; -} - -function foo() { - return; -} - -function foo() { - - return; -} - -function foo(bar) { - if (!bar) return; -} - -function foo(bar) { - let someCall; - if (!bar) return; -} - -function foo(bar) { - if (!bar) { return }; -} - -function foo(bar) { - if (!bar) { - return; - } -} - -function foo(bar) { - if (!bar) { - return; - } - - return bar; -} - -function foo(bar) { - if (!bar) { - - return; - } -} - -function foo() { - - // comment - return; -} - -function test() { - console.log("Any statement"); - // Any comment - - return; -} - -function foo() { - fn(); - // comment - - // comment - return; -} - -function bar() { - "some statement"; - - //comment - //comment - //comment - return; -} - diff --git a/test/rules/newline-before-return/default/test.ts.lint b/test/rules/newline-before-return/default/test.ts.lint deleted file mode 100644 index 1ed6848f696..00000000000 --- a/test/rules/newline-before-return/default/test.ts.lint +++ /dev/null @@ -1,124 +0,0 @@ -function foo(bar) { - if (!bar) { - return; - } - return bar; - ~nil [0] -} - -function foo(bar) { - if (!bar) { - var statement = ''; - return statement; - ~nil [0] - } - - return bar; -} - -function foo(bar) { - if (!bar) { - return; - } - /* multi-line - ~nil [0] - comment */ - return bar; -} - -var fn = () => null; -function foo() { - fn(); - return; - ~nil [0] -} - -function foo(fn) { - fn(); return; - ~nil [0] -} - -function foo(fn) { - fn(); return; - ~nil [0] -} - -function foo(fn) { - fn(); return; - ~nil [0] -} - -function foo() { - return; -} - -function foo() { - - return; -} - -function foo(bar) { - if (!bar) return; -} - -function foo(bar) { - let someCall; - if (!bar) return; -} - -function foo(bar) { - if (!bar) { return }; -} - -function foo(bar) { - if (!bar) { - return; - } -} - -function foo(bar) { - if (!bar) { - return; - } - - return bar; -} - -function foo(bar) { - if (!bar) { - - return; - } -} - -function foo() { - - // comment - return; -} - -function test() { - console.log("Any statement"); - // Any comment - - return; -} - -function foo() { - fn(); - // comment - - // comment - return; -} - -function bar() { - "some statement"; - //comment - ~nil [0] - //comment - //comment - return; -} - -[0]: Missing blank line before return diff --git a/test/rules/newline-before-return/default/test.tsx.fix b/test/rules/newline-before-return/default/test.tsx.fix deleted file mode 100644 index e6b34d9b171..00000000000 --- a/test/rules/newline-before-return/default/test.tsx.fix +++ /dev/null @@ -1,17 +0,0 @@ -import * as React from 'react'; - -
{ [].map((child: any) => { - let i = 0; - - return ; -}) }
- -
{ [].map((child: any) => { - return ; -}) }
- -
{ [].map((child: any) => - ; -) }
- - diff --git a/test/rules/newline-before-return/default/test.tsx.lint b/test/rules/newline-before-return/default/test.tsx.lint deleted file mode 100644 index ae18dcfb7d0..00000000000 --- a/test/rules/newline-before-return/default/test.tsx.lint +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; - -
{ [].map((child: any) => { - let i = 0; - return ; - ~nil [0] -}) }
- -
{ [].map((child: any) => { - return ; -}) }
- -
{ [].map((child: any) => - ; -) }
- - -[0]: Missing blank line before return diff --git a/test/rules/newline-before-return/default/tslint.json b/test/rules/newline-before-return/default/tslint.json deleted file mode 100644 index fdefd1ad13b..00000000000 --- a/test/rules/newline-before-return/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "newline-before-return": true - } -} diff --git a/test/rules/newline-per-chained-call/default/test.ts.lint b/test/rules/newline-per-chained-call/default/test.ts.lint deleted file mode 100644 index a00c7e99ea7..00000000000 --- a/test/rules/newline-per-chained-call/default/test.ts.lint +++ /dev/null @@ -1,120 +0,0 @@ -this.getFoo()[0].toString(); - ~~~~~~~~~ [ERROR] - -this.foo()["bar"]().buzz(); - ~~~~~ [ERROR] - -this.foo()["bar"](); - -foo().bar(); - ~~~~ [ERROR] - -const y: string[] = _observable - .map(function(item) { return item.helloYay().another() } - ~~~~~~~~ [ERROR] - .operator() - .another(function(result) { return result.hello.Yay! }).wrong(); - ~~~~~~ [ERROR] - -SomeClass.propA.helloYay((a: number) => { - return a + 1; -}); - -this.some.nested(); - -const y: string[] = _observable - .map(function(item) { return item.helloYay! }) - .operator() - .another(function(result) { return result.hello.Yay! }); - - -const y: string[] = _observable.map(item => item.helloYay).operator().another(function(result) { return result.helloYay! }); - ~~~~~~~~ [ERROR] - ~~~~~~~~~ [ERROR] - -const x: string[] = _observable.map(item => item.helloYay); - -SomeClass.propA.propB.helloYay(); - -SomeClass - .propA - .propB - .helloYay(); - -SomeClass - .propA - .propB.helloYay(); - -SomeClass - .propA - .propB - .helloYay(function() { - return 1; - }).test(); - ~~~~~ [ERROR] - -SomeClass - .propA - .propB - .helloYay(function() { - return 1; - }). test(); - ~~~~~~~ [ERROR] - -SomeClass - .propA - .propB - .helloYay(function() { - return 1; - }). - ~ - test(); -~~~~~~~~ [ERROR] - -SomeClass.propA.propB.methodB(() => { - return "hello Yay!"; -}).helloYay((a: number) => { - ~~~~~~~~~ [ERROR] - return a + 1; -}); - -SomeClass.propA.propB.methodB(() => { - return "hello Yay!"; -}) -.helloYay((a: number) => { - return a + 1; -}); - -SomeClass.propA.propB.methodB(() => { - return "hello Yay!"; -}) -.helloYay((a: number) => { - return obj.method() - .chainedButOkay( - objB.nested().superNestedCall() - ~~~~~~~~~~~~~~~~ [ERROR] - ) -}); - -SomeClass.propA.propB.methodB(() => { - return "hello Yay!"; -}) -.helloYay((a: number) => { - return obj.method() - .chainedButOkay( - objB.nested() - .superNestedCall() - ) -}); - -SomeClass - .propA - .propB - .methodC(() => { - return "hello Yay!"; - }) - .helloYay(() => { - return 1; - }); - -[ERROR]: When chaining calls, put method calls on new lines. \ No newline at end of file diff --git a/test/rules/newline-per-chained-call/default/tslint.json b/test/rules/newline-per-chained-call/default/tslint.json deleted file mode 100644 index 5501b8f65cf..00000000000 --- a/test/rules/newline-per-chained-call/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "newline-per-chained-call": true - } -} diff --git a/test/rules/no-angle-bracket-type-assertion/test.ts.fix b/test/rules/no-angle-bracket-type-assertion/test.ts.fix deleted file mode 100644 index 292b90da4fa..00000000000 --- a/test/rules/no-angle-bracket-type-assertion/test.ts.fix +++ /dev/null @@ -1,52 +0,0 @@ -var a = 5 as any; - -var b = 5 as any as number; - -var c = (5 as any) as number; - -var d = 5 as any as number; - -var e = 5 as any as number; - -let f = (flag as any as number) & value; -f = (flag as any as number) | value; - -let g = a as any as A; - -let h = a as any as AsyncIterableIterator; - -interface Action { - payload: number | false; -} - -const action: Action = { - payload: 5, -} - -const booleanAction: Action = { - payload: false, -} - -const a = 5 + (action.payload as number); - -const a = 5 - (action.payload as number); - -const a = 5 * (action.payload as number); - -const a = 5 / (action.payload as number); - -const a = 5 % (action.payload as number); - -const a = 5 && (action.payload as number); - -const a = 5 || (action.payload as number); - -const a = 5 % (action.payload as any as number); - -const a = 5 && (action.payload as any as number); - -const a = 5 || (action.payload as any as number); - -const a = true || (booleanAction.payload as boolean); - -const a = false && (booleanAction.payload as boolean); diff --git a/test/rules/no-angle-bracket-type-assertion/test.ts.lint b/test/rules/no-angle-bracket-type-assertion/test.ts.lint deleted file mode 100644 index b45672e67e5..00000000000 --- a/test/rules/no-angle-bracket-type-assertion/test.ts.lint +++ /dev/null @@ -1,73 +0,0 @@ -var a = 5; - ~~~~~~ [0] - -var b = 5; - ~~~~~~~~~~~~~~ [0] - -var c = (5 as any); - ~~~~~~~~~~~~~~~~~~ [0] - -var d = 5 as number; - ~~~~~~~ [0] - -var e = 5 as any as number; - -let f = flag & value; - ~~~~~~~~~~~~~~~~~ [0] -f = flag | value; - ~~~~~~~~~~~~~~~~~ [0] - -let g = a; - ~~~~~~~~~ [0] - -let h = a; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -interface Action { - payload: number | false; -} - -const action: Action = { - payload: 5, -} - -const booleanAction: Action = { - payload: false, -} - -const a = 5 + action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 - action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 * action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 / action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 % action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 && action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 || action.payload; - ~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 % action.payload; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 && action.payload; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = 5 || action.payload; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = true || booleanAction.payload; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const a = false && booleanAction.payload; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -[0]: Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead. diff --git a/test/rules/no-angle-bracket-type-assertion/tslint.json b/test/rules/no-angle-bracket-type-assertion/tslint.json deleted file mode 100644 index a067500fe8b..00000000000 --- a/test/rules/no-angle-bracket-type-assertion/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-angle-bracket-type-assertion": true - } -} diff --git a/test/rules/no-any/default/test.ts.lint b/test/rules/no-any/default/test.ts.lint deleted file mode 100644 index 66200e514a1..00000000000 --- a/test/rules/no-any/default/test.ts.lint +++ /dev/null @@ -1,34 +0,0 @@ -var x: any; // error - ~~~ [0] - -function foo(a: any) : any { // 2 errors - ~~~ [0] - ~~~ [0] - return; -} - -const fooArrow(a: any[]) => { - ~~~ [0] - return; -} - -function bar(...a: any[]) { - ~~~ [0] - return; -} - -const barArrow = (...a: any[]): any => { - ~~~ [0] - ~~~ [0] - return; -} - -let a: any = 2, // error - ~~~ [0] - b: any[] = 4; // error - ~~~ [0] - -let {a: c, b: d}: {c: any, d: number} = {c: 99, d: 100}; // error - ~~~ [0] - -[0]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type. diff --git a/test/rules/no-any/default/tslint.json b/test/rules/no-any/default/tslint.json deleted file mode 100644 index 2876d288c08..00000000000 --- a/test/rules/no-any/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-any": true - } -} diff --git a/test/rules/no-any/ignore-rest-args/test.ts.lint b/test/rules/no-any/ignore-rest-args/test.ts.lint deleted file mode 100644 index 9cf2ae897f1..00000000000 --- a/test/rules/no-any/ignore-rest-args/test.ts.lint +++ /dev/null @@ -1,38 +0,0 @@ -var x: any; // error - ~~~ [0] - -function foo(a: any) : any { // 2 errors - ~~~ [0] - ~~~ [0] - return; -} - -const fooArrow(a: any[]) => { - ~~~ [0] - return; -} - -function bar(...a: any[]) { - return; -} - -const barArrow = (...a: any[]): any => { - ~~~ [0] - return; -} - -const function(...a: { [key: any]: any }[]) { - ~~~ [0] - ~~~ [0] - return; -} - -let a: any = 2, // error - ~~~ [0] - b: any[] = 4; // error - ~~~ [0] - -let {a: c, b: d}: {c: any, d: number} = {c: 99, d: 100}; // error - ~~~ [0] - -[0]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type. diff --git a/test/rules/no-any/ignore-rest-args/tslint.json b/test/rules/no-any/ignore-rest-args/tslint.json deleted file mode 100644 index 8ec5fb037c2..00000000000 --- a/test/rules/no-any/ignore-rest-args/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-any": [true, { "ignore-rest-args": true }] - } -} diff --git a/test/rules/no-arg/test.ts.lint b/test/rules/no-arg/test.ts.lint deleted file mode 100644 index d8e2193dcde..00000000000 --- a/test/rules/no-arg/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -var testVariable = 123; - -function testFunction(): number { - if(arguments.callee.caller === testFunction) { - ~~~~~~~~~~~~~~~~ [Access to arguments.callee is forbidden] - console.log("called"); - } - - argument.callee = testFunction; - - return testVariable; -} diff --git a/test/rules/no-arg/tslint.json b/test/rules/no-arg/tslint.json deleted file mode 100644 index 139d0955e11..00000000000 --- a/test/rules/no-arg/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-arg": true - } -} diff --git a/test/rules/no-async-without-await/test.ts.lint b/test/rules/no-async-without-await/test.ts.lint deleted file mode 100644 index cda2178d5f5..00000000000 --- a/test/rules/no-async-without-await/test.ts.lint +++ /dev/null @@ -1,165 +0,0 @@ -async function a(){ -~~~~~ [FAILURE_STRING] - let b = 1; - console.log(b); -} - -async function a(){ - let b = 1; - await console.log(b); -} - -async function a(){ - let b = 1; - console.log(await b()); -} - -async function a(){ -~~~~~ [FAILURE_STRING] - let b = 1; - let c = async () => { - await fetch(); - }; -} - -async function a(){ -~~~~~ [FAILURE_STRING] - let b = 1; - async function f() { - await fetch(); - }; -} - -function a(){ - let b = 1; - async function f() { - ~~~~~ [FAILURE_STRING] - fetch(); - }; -} - -const a = async () => { - ~~~~~ [FAILURE_STRING] - let b = 1; - console.log(b); -} - -class A { - async b() { - ~~~~~ [FAILURE_STRING] - console.log(1); - } -} - -class A { - async b() { - await b(); - } -} - -class A { - public a = async function b() { - await b(); - } - } - -class A { - public a = async function b() { - ~~~~~ [FAILURE_STRING] - b(); - } - } - -class A { - public a = async () => { - await b(); - } - } - -class A { - public a = async () => { - ~~~~~ [FAILURE_STRING] - b(); - } - } - -class A { - public a = async () => 1; - } - -async () => { - await a(); - class A { - async b() { - ~~~~~ [FAILURE_STRING] - console.log(1); - } - } -}; - -async function a() { - let b = 1; - return b; -} - -let a = async () => 1; - -async function a() { -~~~~~ [FAILURE_STRING] - let b = 1; - let a = () => { - return 1; - } -} - -async function foo; -~~~~~ [FAILURE_STRING] - -function * foo() { - return 1; -} - -abstract class A { - public async func() { - ~~~~~ [FAILURE_STRING] - b(); - } -} - -abstract class A { - public abstract func(): void; -} - -abstract class A { - public async func() { /* */ } - ~~~~~ [FAILURE_STRING] -} - -abstract class A { - public async func(): Promise { /* */ } - ~~~~~ [FAILURE_STRING] -} - -abstract class A { - public const test: Promise -} - -abstract class A { - public abstract async func(param: T): Promise; -} - -export async function f(i: number): Promise; -export async function f(s1: string, s2: string): Promise; -export async function f(...args: unknown[]): Promise { - return Promise.resolve(); -} - -export class A { - public async f(i: number): Promise; - public async f(s1: string, s2: string): Promise; - public async f(..._args: unknown[]): Promise { - return Promise.resolve(); - } -} - -[FAILURE_STRING]: Functions marked async must contain an await or return statement. diff --git a/test/rules/no-async-without-await/tslint.json b/test/rules/no-async-without-await/tslint.json deleted file mode 100644 index 140ce628454..00000000000 --- a/test/rules/no-async-without-await/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-async-without-await": true - } -} diff --git a/test/rules/no-bitwise/test.ts.lint b/test/rules/no-bitwise/test.ts.lint deleted file mode 100644 index f16f3bcc8b2..00000000000 --- a/test/rules/no-bitwise/test.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -var z = (x || 3) && (y || 4); -var yy = x | 3; - ~~~~~ [Forbidden bitwise operation] -var zz = (z || y) & (x | y); - ~~~~~~~~~~~~~~~~~~ [Forbidden bitwise operation] - ~~~~~ [Forbidden bitwise operation] diff --git a/test/rules/no-bitwise/tslint.json b/test/rules/no-bitwise/tslint.json deleted file mode 100644 index 9dfce74f345..00000000000 --- a/test/rules/no-bitwise/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-bitwise": true - } -} diff --git a/test/rules/no-boolean-literal-compare/test.ts.fix b/test/rules/no-boolean-literal-compare/test.ts.fix deleted file mode 100644 index 30bb48dc97e..00000000000 --- a/test/rules/no-boolean-literal-compare/test.ts.fix +++ /dev/null @@ -1,30 +0,0 @@ -declare const x: boolean; - -x; -x; - -!x; -!x; - -!x; -!x; - -x; -x; - -x; - -declare const y: boolean | undefined; -y === true; - -declare function f(): boolean; -!f(); - -declare const a: number, b: number; - -!(a as any as boolean); - -!(a < b); - -!!x; - diff --git a/test/rules/no-boolean-literal-compare/test.ts.lint b/test/rules/no-boolean-literal-compare/test.ts.lint deleted file mode 100644 index 9e54c2c6e92..00000000000 --- a/test/rules/no-boolean-literal-compare/test.ts.lint +++ /dev/null @@ -1,45 +0,0 @@ -declare const x: boolean; - -x === true; -~ [T] -true === x; - ~ [T] - -x === false; -~ [F] -false === x; - ~ [F] - -x !== true; -~ [F] -true !== x; - ~ [F] - -x !== false; -~ [T] -false !== x; - ~ [T] - -x == true; -~ [T] - -declare const y: boolean | undefined; -y === true; - -declare function f(): boolean; -f() === false; -~~~ [F] - -declare const a: number, b: number; - -a as any as boolean === false; -~~~~~~~~~~~~~~~~~~~ [F] - -a < b === false; -~~~~~ [F] - -!x === false; -~~ [F] - -[T]: This expression is unnecessarily compared to a boolean. Just use it directly. -[F]: This expression is unnecessarily compared to a boolean. Just negate it. diff --git a/test/rules/no-boolean-literal-compare/tsconfig.json b/test/rules/no-boolean-literal-compare/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/no-boolean-literal-compare/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/no-boolean-literal-compare/tslint.json b/test/rules/no-boolean-literal-compare/tslint.json deleted file mode 100644 index ad257794e15..00000000000 --- a/test/rules/no-boolean-literal-compare/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-boolean-literal-compare": true - } -} \ No newline at end of file diff --git a/test/rules/no-conditional-assignment/test.ts.lint b/test/rules/no-conditional-assignment/test.ts.lint deleted file mode 100644 index e43cb87702e..00000000000 --- a/test/rules/no-conditional-assignment/test.ts.lint +++ /dev/null @@ -1,79 +0,0 @@ -// valid cases -if (x == 5) { } -if (x === 5) { } -else if (y <= 23) { } -else if ((z && a) == 7) { } -else { } - -do { } while (x == 2); -do { } while (x !== 2); - -while (x == 2) { } -while (x !== 2) { } - -for (var x = 8; x == 8; ++x) { } -for (var x = 8; x == 8; x = 12) { } -for (;;) { } - -while (a ? b : c) {} -while (--i) {} -while ((a = b)++) {} // don't bother, it's a compile error anyway - -while ((a || (a = b)).foo) {} -while (a[b = c]) {} -while ((() => a = b)()) {} -while (fn(a = b)) {} -a ? b = a : a = b; - -// invalid cases -if (x = 5) { } - ~~~~~ [0] -if (a && (b = 5)) { } - ~~~~~ [0] -else if (x = 2) { } - ~~~~~ [0] - -do { } while (x = 4); - ~~~~~ [0] - -while (x = 4); - ~~~~~ [0] -while ((x = y - 12)); - ~~~~~~~~~~ [0] - -for (var x = 4; x = 8; x++) { } - ~~~~~ [0] -for (; (y == 2) && (x = 3); ) { } - ~~~~~ [0] - -if (x += 2) { } - ~~~~~~ [0] -else if (h || (x <<= 4)) { } - ~~~~~~~ [0] - -do { } while (x ^= 4) { } - ~~~~~~ [0] -while ((a = 5) && ((b == 4) || (c = 3))) {} - ~~~~~ [0] - ~~~~~ [0] -while (+(a = b) || -(b = c)) {} - ~~~~~ [0] - ~~~~~ [0] -while (foo() || (a = (b = c)!)) {} - ~~~~~~~~~~~~ [0] - ~~~~~ [0] -while (a == (b = fn()) as any) {} - ~~~~~~~~ [0] -while (a ? b = a : a = b) {} - ~~~~~ [0] - ~~~~~ [0] -while (!((a = b) ? c : d) || (x = y)) {} - ~~~~~ [0] - ~~~~~ [0] -(a = b) ? c : d; - ~~~~~ [0] -(foo ? a = b : b = a) ? c : d; - ~~~~~ [0] - ~~~~~ [0] - -[0]: Assignments in conditional expressions are forbidden diff --git a/test/rules/no-conditional-assignment/tslint.json b/test/rules/no-conditional-assignment/tslint.json deleted file mode 100644 index 014f7127c44..00000000000 --- a/test/rules/no-conditional-assignment/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-conditional-assignment": true - } -} diff --git a/test/rules/no-consecutive-blank-lines/default/test.ts.fix b/test/rules/no-consecutive-blank-lines/default/test.ts.fix deleted file mode 100644 index 119e8e98967..00000000000 --- a/test/rules/no-consecutive-blank-lines/default/test.ts.fix +++ /dev/null @@ -1,27 +0,0 @@ -// the markup for this test is a little bit weird -// tslint, for the first error below, says it goes from -// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) - -class Clazz { // comment - - public funcxion() { - - // also comment - - console.log("test"); - - } - -} - -//Begin whitespace -// The next two lines of "code" contain only tabs or spaces, they are also considered "blank" lines - -let foo = ` - - -`; - -let bar = `${bar - -}`; diff --git a/test/rules/no-consecutive-blank-lines/default/test.ts.lint b/test/rules/no-consecutive-blank-lines/default/test.ts.lint deleted file mode 100644 index 9577de1bef6..00000000000 --- a/test/rules/no-consecutive-blank-lines/default/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -// the markup for this test is a little bit weird -// tslint, for the first error below, says it goes from -// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) - - -~nil -class Clazz { // comment -~nil [Consecutive blank lines are forbidden] - - public funcxion() { - - // also comment - - -~nil - console.log("test"); -~nil [Consecutive blank lines are forbidden] - - } - - -~nil -} -~nil [Consecutive blank lines are forbidden] - -//Begin whitespace -// The next two lines of "code" contain only tabs or spaces, they are also considered "blank" lines - - -~ [Consecutive blank lines are forbidden] - - -let foo = ` - - -`; - -let bar = `${bar - - -~ [Consecutive blank lines are forbidden] -}`; diff --git a/test/rules/no-consecutive-blank-lines/default/tslint.json b/test/rules/no-consecutive-blank-lines/default/tslint.json deleted file mode 100644 index 3aa56ee6643..00000000000 --- a/test/rules/no-consecutive-blank-lines/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-consecutive-blank-lines": true - } -} diff --git a/test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint b/test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint deleted file mode 100644 index 6bc6eb7fc90..00000000000 --- a/test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint +++ /dev/null @@ -1,30 +0,0 @@ -// This rule will always pass since the arguments value in tslint.json is a string, -// while it should be a valid integer and > 1. -// In such a case, the rule is not enabled. - -class Clazz { // comment - - public funcxion() { - - - // also comment - - - - // still allowed since 2 lines only - - - - - - // this one won't be allowed anymore - - console.log("test"); - - } - - -} - - - diff --git a/test/rules/no-consecutive-blank-lines/invalid-option/tslint.json b/test/rules/no-consecutive-blank-lines/invalid-option/tslint.json deleted file mode 100644 index 11f06b692b3..00000000000 --- a/test/rules/no-consecutive-blank-lines/invalid-option/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-consecutive-blank-lines": [true, "three"] - } -} diff --git a/test/rules/no-consecutive-blank-lines/multiple/test.ts.fix b/test/rules/no-consecutive-blank-lines/multiple/test.ts.fix deleted file mode 100644 index c1ba96dee2e..00000000000 --- a/test/rules/no-consecutive-blank-lines/multiple/test.ts.fix +++ /dev/null @@ -1,28 +0,0 @@ -// the markup for this test is a little bit weird -// tslint, for the first error below, says it goes from -// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) - -class Clazz { // comment - - - public funcxion() { - - // also comment - - - // still allowed since 2 lines only - - - // this one won't be allowed anymore - - console.log("test"); - - } - - -} - -//Begin whitespace -// The next lines contain only tabs or spaces, they are also considered "blank" lines - - \ No newline at end of file diff --git a/test/rules/no-consecutive-blank-lines/multiple/test.ts.lint b/test/rules/no-consecutive-blank-lines/multiple/test.ts.lint deleted file mode 100644 index 5f05126c895..00000000000 --- a/test/rules/no-consecutive-blank-lines/multiple/test.ts.lint +++ /dev/null @@ -1,40 +0,0 @@ -// the markup for this test is a little bit weird -// tslint, for the first error below, says it goes from -// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) - -class Clazz { // comment - - - -~nil - -~nil [Exceeds the 2 allowed consecutive blank lines] - public funcxion() { - - // also comment - - - // still allowed since 2 lines only - - - -~nil - -~nil [Exceeds the 2 allowed consecutive blank lines] - - // this one won't be allowed anymore - - console.log("test"); - - } - - -} - -//Begin whitespace -// The next lines contain only tabs or spaces, they are also considered "blank" lines - - - -~ [Exceeds the 2 allowed consecutive blank lines] - diff --git a/test/rules/no-consecutive-blank-lines/multiple/tslint.json b/test/rules/no-consecutive-blank-lines/multiple/tslint.json deleted file mode 100644 index b9a168a7960..00000000000 --- a/test/rules/no-consecutive-blank-lines/multiple/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-consecutive-blank-lines": [true, 2] - } -} diff --git a/test/rules/no-console/all/test.ts.lint b/test/rules/no-console/all/test.ts.lint deleted file mode 100644 index 45cd25785a6..00000000000 --- a/test/rules/no-console/all/test.ts.lint +++ /dev/null @@ -1,22 +0,0 @@ -console.time(); -~~~~~~~~~~~~ [err % ('time')] -console.log("log"); -~~~~~~~~~~~ [err % ('log')] -console.dir(object); -~~~~~~~~~~~ [err % ('dir')] -console.info("info"); -~~~~~~~~~~~~ [err % ('info')] -console.trace("trace"); -~~~~~~~~~~~~~ [err % ('trace')] -console.warn("warn"); -~~~~~~~~~~~~ [err % ('warn')] -console.error("error"); -~~~~~~~~~~~~~ [err % ('error')] -console.something(); -~~~~~~~~~~~~~~~~~ [err % ('something')] -console.timeEnd(); -~~~~~~~~~~~~~~~ [err % ('timeEnd')] -[].forEach(console.log); - ~~~~~~~~~~~ [err % ('log')] - -[err]: Calls to 'console.%s' are not allowed. diff --git a/test/rules/no-console/all/tslint.json b/test/rules/no-console/all/tslint.json deleted file mode 100644 index a4bede1138e..00000000000 --- a/test/rules/no-console/all/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-console": true - } -} diff --git a/test/rules/no-console/list/test.ts.lint b/test/rules/no-console/list/test.ts.lint deleted file mode 100644 index 2ee294b7d6b..00000000000 --- a/test/rules/no-console/list/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -console.time(); -console.log("log"); -~~~~~~~~~~~ [Calls to 'console.log' are not allowed.] -console.dir(object); -~~~~~~~~~~~ [Calls to 'console.dir' are not allowed.] -console.info("info"); -console.trace("trace"); -console.warn("warn"); -~~~~~~~~~~~~ [Calls to 'console.warn' are not allowed.] -console.error("error"); -~~~~~~~~~~~~~ [Calls to 'console.error' are not allowed.] -console.something(); -console.timeEnd(); diff --git a/test/rules/no-console/list/tslint.json b/test/rules/no-console/list/tslint.json deleted file mode 100644 index 08a0d1815f8..00000000000 --- a/test/rules/no-console/list/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-console": [true, "dir", "error", "log", "warn"] - } -} diff --git a/test/rules/no-construct/test.ts.lint b/test/rules/no-construct/test.ts.lint deleted file mode 100644 index b11a12570b8..00000000000 --- a/test/rules/no-construct/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -var s1 = "s"; -var s2 = new String("s"); - ~~~~~~~~~~ [0] - -var n1 = 1; -var n2 = new Number(1); - ~~~~~~~~~~~~~ [0] - -var b1 = true; -var b2 = new Boolean (true); - ~~~~~~~~~~~ [0] - -[0]: Forbidden constructor, use a literal or simple function call instead diff --git a/test/rules/no-construct/tslint.json b/test/rules/no-construct/tslint.json deleted file mode 100644 index 9d1db2e04c1..00000000000 --- a/test/rules/no-construct/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-construct": true - } -} diff --git a/test/rules/no-debugger/test.ts.lint b/test/rules/no-debugger/test.ts.lint deleted file mode 100644 index de25e88e833..00000000000 --- a/test/rules/no-debugger/test.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -var testVariable = "debugger"; - -function testFunction(): number { - if (testVariable === "debugger") { - debugger; - ~~~~~~~~~ [Use of debugger statements is forbidden] - } -} diff --git a/test/rules/no-debugger/tslint.json b/test/rules/no-debugger/tslint.json deleted file mode 100644 index 53e3193c563..00000000000 --- a/test/rules/no-debugger/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-debugger": true - } -} diff --git a/test/rules/no-default-export/test.ts.lint b/test/rules/no-default-export/test.ts.lint deleted file mode 100644 index e50cfe2816d..00000000000 --- a/test/rules/no-default-export/test.ts.lint +++ /dev/null @@ -1,46 +0,0 @@ -switch (value) { - case 1: break; - default: break; -} - -export { SingleItem }; - -export { FirstItem, SecondItem }; - -export { Item as aliasForItem }; - -export { ItemFromImport } from 'module'; - -export * from './relativeModule'; - -export namespace SomeNamespace { } - -export import ItemAlias = someNamespace.Item; - -export const default = 'VALID'; - -export = 'VALID'; - -export default 'INVALID'; - ~~~~~~~ [0] - -export default { } - ~~~~~~~ [0] - -export default class { } - ~~~~~~~ [0] - -export default class Test { } - ~~~~~~~ [0] - -export default abstract class { } - ~~~~~~~ [0] - -export default function() { } - ~~~~~~~ [0] - -export default function Test() { } - ~~~~~~~ [0] - -[0]: Use of default exports is forbidden - diff --git a/test/rules/no-default-export/tslint.json b/test/rules/no-default-export/tslint.json deleted file mode 100644 index ebed5e9e331..00000000000 --- a/test/rules/no-default-export/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-default-export": true - } -} diff --git a/test/rules/no-default-import/default/test.ts.lint b/test/rules/no-default-import/default/test.ts.lint deleted file mode 100644 index 399593ed9f6..00000000000 --- a/test/rules/no-default-import/default/test.ts.lint +++ /dev/null @@ -1,36 +0,0 @@ -import * as Utils from "tslint-utils" - -import TslintUtils from "tslint-utils" - -import Bar, { Foo } from "tslint-misc" - -import Bar, * as Foo from "tslint-misc" - -import { default as Foo } from "tslint-misc" - -import { default as foo, bar } from "tslint-misc" - -import { bar, default as foo } from "tslint-misc" - -import TslintUtils from "../tslint-utils" - ~~~~~~~~~~~ [0] - -import TslintUtils from "./tslint-utils" - ~~~~~~~~~~~ [0] - -import Bar, { Foo } from "../tslint-misc" - ~~~ [0] - -import Bar, * as Foo from "./tslint-misc" - ~~~ [0] - -import { default as Foo } from "../tslint-misc" - ~~~~~~~ [0] - -import { default as foo, bar } from "./tslint-misc" - ~~~~~~~ [0] - -import { bar, default as foo } from "../tslint-misc" - ~~~~~~~ [0] - -[0]: Import of default members from this module is forbidden. Import named member instead diff --git a/test/rules/no-default-import/default/tslint.json b/test/rules/no-default-import/default/tslint.json deleted file mode 100644 index 63855417715..00000000000 --- a/test/rules/no-default-import/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-default-import": true - } -} diff --git a/test/rules/no-default-import/fromModules/test.ts.lint b/test/rules/no-default-import/fromModules/test.ts.lint deleted file mode 100644 index 2b789830c6e..00000000000 --- a/test/rules/no-default-import/fromModules/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -import * as Utils from "tslint-utils" - -import TslintUtils from "../tslint-utils" - ~~~~~~~~~~~ [0] - -import TslintUtils from "tslint-utils" - ~~~~~~~~~~~ [0] - -import Bar, { Foo } from "tslint-misc" - ~~~ [0] - -import Bar, * as Foo from "tslint-misc" - ~~~ [0] - -import { default as Foo } from "tslint-misc" - ~~~~~~~ [0] - -import { default as foo, bar } from "tslint-misc" - ~~~~~~~ [0] - -import { bar, default as foo } from "tslint-misc" - ~~~~~~~ [0] - -[0]: Import of default members from this module is forbidden. Import named member instead diff --git a/test/rules/no-default-import/fromModules/tslint.json b/test/rules/no-default-import/fromModules/tslint.json deleted file mode 100644 index 1d9bf38d79d..00000000000 --- a/test/rules/no-default-import/fromModules/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "no-default-import": [ - true, - { - "fromModules": "^tslint-|^\\./|^\\.\\./" - } - ] - } -} diff --git a/test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint b/test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint deleted file mode 100644 index 89d54bb9eb8..00000000000 --- a/test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -import * as fs from 'fs'; -declare module "foo" { - import {readFile} from 'fs'; -} - -declare module "*"; diff --git a/test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint b/test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint deleted file mode 100644 index 7bf56979661..00000000000 --- a/test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -import * as fs from 'fs'; -import {readFile} from 'fs'; -import {readFileSync} from 'fs'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'fs' can be combined into one.] - -import * as fs from 'fs'; -~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple wildcard imports from the same module, 'fs', are prohibited.] - -import * as path from 'path'; -import {resolve} from 'path'; - -import {Socket} from 'net' -import {Server} from 'net'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'net' can be combined into one.] diff --git a/test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json b/test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json deleted file mode 100644 index ca35db49814..00000000000 --- a/test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "no-duplicate-imports": { - "severity": "error", - "options": { - "allow-namespace-imports": true - } - } - } -} diff --git a/test/rules/no-duplicate-imports/default/test.d.ts.lint b/test/rules/no-duplicate-imports/default/test.d.ts.lint deleted file mode 100644 index 5c5b614baa9..00000000000 --- a/test/rules/no-duplicate-imports/default/test.d.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -import * as fs from 'fs'; -declare module "foo" { - import {readFile} from 'fs'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'fs' can be combined into one.] -} - -declare module "*"; diff --git a/test/rules/no-duplicate-imports/default/test.ts.lint b/test/rules/no-duplicate-imports/default/test.ts.lint deleted file mode 100644 index 7a5c5def8de..00000000000 --- a/test/rules/no-duplicate-imports/default/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -import * as fs from 'fs'; -import {readFile} from 'fs'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('fs')] - -import * as path from 'path'; - -import {writeFileSync as wfs} from 'fs'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('fs')] - -import {parse} from 'url'; -import {format} from 'url'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('url')] - -import foo from './foo'; -import {bar} from './foo'; -~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('./foo')] - -import {writeFile} from './fs'; - -[err]: Multiple imports from '%s' can be combined into one. diff --git a/test/rules/no-duplicate-imports/default/test2.d.ts.lint b/test/rules/no-duplicate-imports/default/test2.d.ts.lint deleted file mode 100644 index 00ce946e7d1..00000000000 --- a/test/rules/no-duplicate-imports/default/test2.d.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -declare module 'a' { - import foo from 'foo'; -} - -declare module 'b' { - // No error -- this is a separate ambient module declaration. - import foo from 'foo'; -} diff --git a/test/rules/no-duplicate-imports/default/test3.d.ts.lint b/test/rules/no-duplicate-imports/default/test3.d.ts.lint deleted file mode 100644 index bd64667a22f..00000000000 --- a/test/rules/no-duplicate-imports/default/test3.d.ts.lint +++ /dev/null @@ -1,11 +0,0 @@ -export {}; - -declare module 'a' { - import foo from 'foo'; -} - -declare module 'b' { - // Error because these imports could be combined in an outer scope. - import foo from 'foo'; - ~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'foo' can be combined into one.] -} diff --git a/test/rules/no-duplicate-imports/default/tslint.json b/test/rules/no-duplicate-imports/default/tslint.json deleted file mode 100644 index 27886316114..00000000000 --- a/test/rules/no-duplicate-imports/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-duplicate-imports": true - } -} diff --git a/test/rules/no-duplicate-super/test.ts.lint b/test/rules/no-duplicate-super/test.ts.lint deleted file mode 100644 index 052d90c45eb..00000000000 --- a/test/rules/no-duplicate-super/test.ts.lint +++ /dev/null @@ -1,280 +0,0 @@ -declare const b: boolean; -declare const b2: boolean; -declare const n: number; - -// Simple -{ - class A { - constructor() { - super(); - ~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~ [0] - } - } - - class B { - constructor() { - super(); - super.foo(); - } - } - - class C1 { - constructor() { - super(); - - class C2 { - constructor() { - super(); - } - } - } - } - - class D { - constructor() { - super(super()); - ~~~~~~~~~~~~~ [0] - } - } -} - -// If/else -{ - class A { - constructor() { - if (b) { - super(); - return; - } - super(); - } - } - - class B { - constructor() { - if (b) { - super(); - } else { - super(); - } - } - } - - class C { - constructor() { - if (b) { - super(); - return; - } else if (b2) { - super(); - ~~~~~~~~ - } -~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~ [0] - } - } - - class D { - constructor() { - if (b) { - super(); - return; - } else if (b) { - super(); - return; - } - super(); - } - } -} - -// Loop -{ - class A { - constructor() { - while (b) { - if (b) { - super(); - break; - } - } - } - } - - class B { - constructor() { - while (b) { - if (b) { - super(); - break; - } - if (b2) { - super(); - break; - } - super(); - break; - } - } - } - - class C { - constructor() { - while (b) { - if (b) { - super(); - return; - } else { - super(); - return; - } - } - super(); - } - } - - class D { - constructor() { - while (b) { - if (b) { - super(); - return; - } else { - super(); - ~~~~~~~ - break; -~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~~~~~~~~~~~~~ - } -~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~ [0] - } - } - - class E { - constructor() { - while (b) { - if (b) { - super(); - ~~~~~~~ - break; -~~~~~~~~~~~~~~~~~~~~~~~~~~ - } else { -~~~~~~~~~~~~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - return; -~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~~~~~~~~~~~~~ - } -~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~ [0] - } - } -} - -// Switch -{ - class A { - constructor() { - switch (n) { - case 0: - super(); - ~~~~~~~~ - case 1: -~~~~~~~~~~~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - } - } - } - - class B { - constructor() { - switch (n) { - case 0: - super(); - break; - case 1: - super(); - break; - } - } - } - - class C { - constructor() { - switch (n) { - case 0: - super(); - break; - case 1: - super(); - ~~~~~~~~ - break; -~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~~~~ [0] - } - } -} - -// Wierd -{ - class A { - constructor() { - if (b) { - super(); - { - return; - } - } - super(); - } - } - - class B { - constructor() { - switch (n) { - case 0: - if (b) { - super(); - return; - } else { - super(); - if (b2) return; else return; - } - } - super(); - } - } -} - -// With ternary operator -{ - class A { - constructor(props?: any) { - props ? super(props) : super(); - } - } - - class B { - constructor(props?: any) { - props ? super(props) : super() ? super() : super(); - ~~~~~~~~~~~~~~~~~ [0] - } - } -} - - -[0]: Multiple calls to 'super()' found. It must be called only once. -[1]: 'super()' called in a loop. It must be called only once. diff --git a/test/rules/no-duplicate-super/tslint.json b/test/rules/no-duplicate-super/tslint.json deleted file mode 100644 index 715471b08e5..00000000000 --- a/test/rules/no-duplicate-super/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-duplicate-super": true - } -} diff --git a/test/rules/no-duplicate-switch-case/test.ts.lint b/test/rules/no-duplicate-switch-case/test.ts.lint deleted file mode 100644 index ecfd4a1914d..00000000000 --- a/test/rules/no-duplicate-switch-case/test.ts.lint +++ /dev/null @@ -1,82 +0,0 @@ -const withNumber = (value: number) => { - switch (value): - case 0: - break; - - case 1: - break; - - case 0: - ~ [error % ("0")] - case 1: { - ~ [error % ("1")] - break; - } -}; - -class WithString { - constructor(param: string) { - switch (param) { - case "aaa": - break; - - case "bbb": - case "ccc": - break; - - case "bbb": - ~~~~~ [error % ('"bbb"')] - case "ddd": - switch (param.length) { - case 0: - break; - - case 0: - ~ [error % ("0")] - case 1: - break; - - default: - break; - } - - case "eee": - case "eee": - ~~~~~ [error % ('"eee"')] - break; - - case "default": - break; - - case 0: - break; - - case "1": - break; - - default: - break; - } - } - - test(obj: object) { - switch (obj) { - case undefined: - break; - - case null: - case Infinity: - break; - - case this: - case null: - ~~~~ [error % ("null")] - break; - - default: - break; - } - } -} - -[error]: Duplicate switch case: '%s'. diff --git a/test/rules/no-duplicate-switch-case/tslint.json b/test/rules/no-duplicate-switch-case/tslint.json deleted file mode 100644 index 27ad3e6211d..00000000000 --- a/test/rules/no-duplicate-switch-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-duplicate-switch-case": [true] - } -} diff --git a/test/rules/no-duplicate-variable/check-parameters/test.ts.lint b/test/rules/no-duplicate-variable/check-parameters/test.ts.lint deleted file mode 100644 index 76fe1d878a0..00000000000 --- a/test/rules/no-duplicate-variable/check-parameters/test.ts.lint +++ /dev/null @@ -1,180 +0,0 @@ -var duplicated = 1; - -function f(x) { - var x; - ~ [err % ('x')] -} - -class Test { - private myFunc() { - var notDuplicated = 123, - duplicated = 234, - someFunc = () => { - var notDuplicated = 345; - }; - - var duplicated = null; - ~~~~~~~~~~ [err % ('duplicated')] - } -} - -function test() { - var notDuplicated = 123, - duplicated = 234, - someFunc = () => { - var notDuplicated = 345; - }; - - var duplicated = null; - ~~~~~~~~~~ [err % ('duplicated')] -} - -duplicated = 2; -var duplicated = 3; - ~~~~~~~~~~ [err % ('duplicated')] - -// valid code -module tmp { - var path = require("path"); - export class MyType { - path: string; - } -} - -module MyModule { - export class ClassA { - id: string; - } - - export class ClassB { - id: string; - } -} - -var a = { - foo(): void { - var bar = 1; - }, - baz(): void { - var bar = 1; - } -}; - -class AccessorTest { - get accesor1(): number { - var x = 0; - return x; - } - - get accesor2(): number { - var x = 0; - return x; - } - -} - -class NoDupConstructor { - private test: string; - constructor() { - var test = "test"; - this.test = test; - } -} - -// valid/invalid code -function letTesting() { - var a = 1; - let b = 1; - let d = 1; - if (true) { - let a = 2; - let b = 2; - let c = 2; - var d = 2; - var e = 2; - } - else { - let b = 3; - let c = 3; - let e = 3; - let f = 3; - } - var f = 4; -} - -// failure: two arguments have the same name. -function testArguments1(arg: number, arg: number): void { -} - -// failure: local var/let declarations shadow arguments. -function testArguments2(x: number, y: number): void { - var x = 1; - ~ [err % ('x')] - let y = 2; -} - -var references: {[vertex: string]: any}; -var dependents: {[vertex: string]: any}; - -function blah(arg1: {[key: string]: any}, arg2: {[key:string]: any}) { -} - -interface IClipboard { - copy(key: string, state: any): void; - paste(key: string): any; - findMaxOrMin(values: any[], defaultValue: number, operation: (...values: any[]) => number); - functionA: (value: string) => void; - functionB: (value: string) => void; -} - -try { - // -} catch (e) { - e.blah(); - // -} - -try { - // -} catch (e) { - e.blah(); - // -} - -function testDestructuring() { - function myFunc() { - return [1, 2]; - } - - var [x, y] = myFunc(); - var [z, z] = myFunc(); // failure - ~ [err % ('z')] - - let [x1, y1] = myFunc(); - let [z1, z1] = myFunc(); // tsc error - - const [x2, y2] = myFunc(); - const [z2, z2] = myFunc(); // tsc error - - let [a1, [b1, c1]] = [1, [2, 3]]; - let [{a1, d1}] = [{a1: 1, d1: 4}]; // tsc error - - var [a2, [b2, c2]] = [1, [2, 3]]; - var [{a2, d2}] = [{a2: 1, d2: 4}]; // failure - ~~ [err % ('a2')] - - function myFunc2([a, b]) { - var a; - ~ [err % ('a')] - return b; - } - - var [x, y3] = myFunc(); // failure - ~ [err % ('x')] - var [x3, ...y] = [1, 2, 3, 4]; // failure - ~ [err % ('y')] -} - -function compileErrors(foo, {bar}, bar, foo, {baz}, [baz]) {} - -[err]: Duplicate variable: '%s' \ No newline at end of file diff --git a/test/rules/no-duplicate-variable/check-parameters/tslint.json b/test/rules/no-duplicate-variable/check-parameters/tslint.json deleted file mode 100644 index 3c4e30e3d0b..00000000000 --- a/test/rules/no-duplicate-variable/check-parameters/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-duplicate-variable": [true, "check-parameters"] - } -} diff --git a/test/rules/no-duplicate-variable/default/test.ts.lint b/test/rules/no-duplicate-variable/default/test.ts.lint deleted file mode 100644 index 9676f576c3d..00000000000 --- a/test/rules/no-duplicate-variable/default/test.ts.lint +++ /dev/null @@ -1,177 +0,0 @@ -var duplicated = 1; - -function f(x) { - var x; -} - -class Test { - private myFunc() { - var notDuplicated = 123, - duplicated = 234, - someFunc = () => { - var notDuplicated = 345; - }; - - var duplicated = null; - ~~~~~~~~~~ [err % ('duplicated')] - } -} - -function test() { - var notDuplicated = 123, - duplicated = 234, - someFunc = () => { - var notDuplicated = 345; - }; - - var duplicated = null; - ~~~~~~~~~~ [err % ('duplicated')] -} - -duplicated = 2; -var duplicated = 3; - ~~~~~~~~~~ [err % ('duplicated')] - -// valid code -module tmp { - var path = require("path"); - export class MyType { - path: string; - } -} - -module MyModule { - export class ClassA { - id: string; - } - - export class ClassB { - id: string; - } -} - -var a = { - foo(): void { - var bar = 1; - }, - baz(): void { - var bar = 1; - } -}; - -class AccessorTest { - get accesor1(): number { - var x = 0; - return x; - } - - get accesor2(): number { - var x = 0; - return x; - } - -} - -class NoDupConstructor { - private test: string; - constructor() { - var test = "test"; - this.test = test; - } -} - -// valid/invalid code -function letTesting() { - var a = 1; - let b = 1; - let d = 1; - if (true) { - let a = 2; - let b = 2; - let c = 2; - var d = 2; - var e = 2; - } - else { - let b = 3; - let c = 3; - let e = 3; - let f = 3; - } - var f = 4; -} - -// failure: two arguments have the same name. -function testArguments1(arg: number, arg: number): void { -} - -// local var/let declarations shadow arguments. Use options "check-parameters" to catch this -function testArguments2(x: number, y: number): void { - var x = 1; - let y = 2; -} - -var references: {[vertex: string]: any}; -var dependents: {[vertex: string]: any}; - -function blah(arg1: {[key: string]: any}, arg2: {[key:string]: any}) { -} - -interface IClipboard { - copy(key: string, state: any): void; - paste(key: string): any; - findMaxOrMin(values: any[], defaultValue: number, operation: (...values: any[]) => number); - functionA: (value: string) => void; - functionB: (value: string) => void; -} - -try { - // -} catch (e) { - e.blah(); - // -} - -try { - // -} catch (e) { - e.blah(); - // -} - -function testDestructuring() { - function myFunc() { - return [1, 2]; - } - - var [x, y] = myFunc(); - var [z, z] = myFunc(); // failure - ~ [err % ('z')] - - let [x1, y1] = myFunc(); - let [z1, z1] = myFunc(); // tsc error - - const [x2, y2] = myFunc(); - const [z2, z2] = myFunc(); // tsc error - - let [a1, [b1, c1]] = [1, [2, 3]]; - let [{a1, d1}] = [{a1: 1, d1: 4}]; // tsc error - - var [a2, [b2, c2]] = [1, [2, 3]]; - var [{a2, d2}] = [{a2: 1, d2: 4}]; // failure - ~~ [err % ('a2')] - - function myFunc2([a, b]) { - var a; - return b; - } - - var [x, y3] = myFunc(); // failure - ~ [err % ('x')] - var [x3, ...y] = [1, 2, 3, 4]; // failure - ~ [err % ('y')] -} - -function compileErrors(foo, {bar}, bar, foo, {baz}, [baz]) {} - -[err]: Duplicate variable: '%s' \ No newline at end of file diff --git a/test/rules/no-duplicate-variable/default/tslint.json b/test/rules/no-duplicate-variable/default/tslint.json deleted file mode 100644 index 9d9b7a7156a..00000000000 --- a/test/rules/no-duplicate-variable/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-duplicate-variable": true - } -} diff --git a/test/rules/no-dynamic-delete/test.ts.fix b/test/rules/no-dynamic-delete/test.ts.fix deleted file mode 100644 index 0cefd09ec54..00000000000 --- a/test/rules/no-dynamic-delete/test.ts.fix +++ /dev/null @@ -1,19 +0,0 @@ -const container: { [i: string]: 0 } = {}; - -const getName = () => ""; - -delete container.aaa; -delete container["bb" + "b"]; -delete container.ccc; -delete container.delete; -delete container.delete; -delete container[7]; -delete container[-7]; -delete container[7]; -delete container[-Infinity]; -delete container["-Infinity"]; -delete container[+Infinity]; -delete container["+Infinity"]; -delete container[NaN]; -delete container.NaN; -delete container[getName()]; diff --git a/test/rules/no-dynamic-delete/test.ts.lint b/test/rules/no-dynamic-delete/test.ts.lint deleted file mode 100644 index 51dbc6295d2..00000000000 --- a/test/rules/no-dynamic-delete/test.ts.lint +++ /dev/null @@ -1,29 +0,0 @@ -const container: { [i: string]: 0 } = {}; - -const getName = () => ""; - -delete container.aaa; -delete container["bb" + "b"]; - ~~~~~~~~~~~~ [0] -delete container["ccc"]; - ~~~~~~~ [0] -delete container.delete; -delete container["delete"]; - ~~~~~~~~~~ [0] -delete container[7]; -delete container[-7]; -delete container[+7]; - ~~~~ [0] -delete container[-Infinity]; - ~~~~~~~~~~~ [0] -delete container["-Infinity"]; -delete container[+Infinity]; - ~~~~~~~~~~~ [0] -delete container["+Infinity"]; -delete container[NaN]; - ~~~~~ [0] -delete container["NaN"]; - ~~~~~~~ [0] -delete container[getName()]; - ~~~~~~~~~~~ [0] -[0]: Do not delete dynamically computed property keys. diff --git a/test/rules/no-dynamic-delete/tslint.json b/test/rules/no-dynamic-delete/tslint.json deleted file mode 100644 index f0c7404cfbf..00000000000 --- a/test/rules/no-dynamic-delete/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-dynamic-delete": true - } -} diff --git a/test/rules/no-empty-interface/test.ts.lint b/test/rules/no-empty-interface/test.ts.lint deleted file mode 100644 index b740fc1d6cd..00000000000 --- a/test/rules/no-empty-interface/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -interface I { } - ~ [An empty interface is equivalent to `{}`.] - -interface J extends I { } - ~ [An interface declaring no members is equivalent to its supertype.] - -interface K { x: number; } - -interface L extends J, K {} // extending more than one interface is ok, as it can be used instead of intersection types - -interface M extends {} // don't crash on empty extends list - ~ [An interface declaring no members is equivalent to its supertype.] - -interface N extends Promise {} diff --git a/test/rules/no-empty-interface/tslint.json b/test/rules/no-empty-interface/tslint.json deleted file mode 100644 index 366f38b35e9..00000000000 --- a/test/rules/no-empty-interface/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-empty-interface": true - } -} diff --git a/test/rules/no-empty/allow-empty-catch/test.ts.lint b/test/rules/no-empty/allow-empty-catch/test.ts.lint deleted file mode 100644 index b93d14c4cf5..00000000000 --- a/test/rules/no-empty/allow-empty-catch/test.ts.lint +++ /dev/null @@ -1,86 +0,0 @@ -if (x === 1) {} - ~~ [block is empty] -if (x === 2) { - ~ - -~nil - -~nil -} -~ [block is empty] - -function testFunction1() { - ~ - -~nil -} -~ [block is empty] - -const testFunction2 = () => { }; - ~~~ [block is empty] - -const testFunction3 = function() {} - ~~ [block is empty] - -const testFunction4 = function(): void {} - ~~ [block is empty] - -for (var x = 0; x < 1; ++x) { } - ~~~ [block is empty] - -// empty blocks with comments should be legal -for (var y = 0; y < 1; ++y) { - // empty here -} -{ // empty block allowed -} -{ - /* this block is also empty, but allowed to be */ -} - -class testClass { - constructor(private allowed: any, private alsoAllowed: any) { - } -} - -class testClass2 { - constructor(protected allowed: any) { - } -} - -class testClass3 { - constructor(notAllowed: any) { - ~ - } -~~~~~ [block is empty] -} - -class testClass4 { - constructor(readonly allowed: any) { - } -} - -class PrivateClassConstructor { - private constructor() {} -} - -class ProtectedClassConstructor { - protected constructor() {} -} - -class PublicClassConstructor { - public constructor() {} - ~~ [block is empty] -} - -class ClassMethod { - public methodWithoutResultTypehinting() {} - ~~ [block is empty] - - public methodWithResultTypehinting(): void {} - ~~ [block is empty] -} - -try { - throw new Error(); -} catch (error) {} diff --git a/test/rules/no-empty/allow-empty-catch/tslint.json b/test/rules/no-empty/allow-empty-catch/tslint.json deleted file mode 100644 index 02e43ab164d..00000000000 --- a/test/rules/no-empty/allow-empty-catch/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-empty": [true, "allow-empty-catch"] - } -} diff --git a/test/rules/no-empty/allow-empty-functions/test.ts.lint b/test/rules/no-empty/allow-empty-functions/test.ts.lint deleted file mode 100644 index daeb737873a..00000000000 --- a/test/rules/no-empty/allow-empty-functions/test.ts.lint +++ /dev/null @@ -1,81 +0,0 @@ -if (x === 1) {} - ~~ [block is empty] -if (x === 2) { - ~ - -~nil - -~nil -} -~ [block is empty] - -function testFunction1() { - - - -} - -const testFunction2 = () => { }; - -const testFunction3 = function() {} - -const testFunction4 = function(): void {} - -for (var x = 0; x < 1; ++x) { } - ~~~ [block is empty] - -// empty blocks with comments should be legal -for (var y = 0; y < 1; ++y) { - // empty here -} -{ // empty block allowed -} -{ - /* this block is also empty, but allowed to be */ -} - -class testClass { - constructor(private allowed: any, private alsoAllowed: any) { - } -} - -class testClass2 { - constructor(protected allowed: any) { - } -} - -class testClass3 { - constructor(notAllowed: any) { - ~ - } -~~~~~ [block is empty] -} - -class testClass4 { - constructor(readonly allowed: any) { - } -} - -class PrivateClassConstructor { - private constructor() {} -} - -class ProtectedClassConstructor { - protected constructor() {} -} - -class PublicClassConstructor { - public constructor() {} - ~~ [block is empty] -} - -class ClassMethod { - public methodWithoutResultTypehinting() {} - - public methodWithResultTypehinting(): void {} -} - -try { - throw new Error(); -} catch (error) {} - ~~ [block is empty] diff --git a/test/rules/no-empty/allow-empty-functions/tslint.json b/test/rules/no-empty/allow-empty-functions/tslint.json deleted file mode 100644 index 56754e50512..00000000000 --- a/test/rules/no-empty/allow-empty-functions/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-empty": [true, "allow-empty-functions"] - } -} diff --git a/test/rules/no-empty/default/test.ts.lint b/test/rules/no-empty/default/test.ts.lint deleted file mode 100644 index 111c4986bbf..00000000000 --- a/test/rules/no-empty/default/test.ts.lint +++ /dev/null @@ -1,87 +0,0 @@ -if (x === 1) {} - ~~ [block is empty] -if (x === 2) { - ~ - -~nil - -~nil -} -~ [block is empty] - -function testFunction1() { - ~ - -~nil -} -~ [block is empty] - -const testFunction2 = () => { }; - ~~~ [block is empty] - -const testFunction3 = function() {} - ~~ [block is empty] - -const testFunction4 = function(): void {} - ~~ [block is empty] - -for (var x = 0; x < 1; ++x) { } - ~~~ [block is empty] - -// empty blocks with comments should be legal -for (var y = 0; y < 1; ++y) { - // empty here -} -{ // empty block allowed -} -{ - /* this block is also empty, but allowed to be */ -} - -class testClass { - constructor(private allowed: any, private alsoAllowed: any) { - } -} - -class testClass2 { - constructor(protected allowed: any) { - } -} - -class testClass3 { - constructor(notAllowed: any) { - ~ - } -~~~~~ [block is empty] -} - -class testClass4 { - constructor(readonly allowed: any) { - } -} - -class PrivateClassConstructor { - private constructor() {} -} - -class ProtectedClassConstructor { - protected constructor() {} -} - -class PublicClassConstructor { - public constructor() {} - ~~ [block is empty] -} - -class ClassMethod { - public methodWithoutResultTypehinting() {} - ~~ [block is empty] - - public methodWithResultTypehinting(): void {} - ~~ [block is empty] -} - -try { - throw new Error(); -} catch (error) {} - ~~ [block is empty] diff --git a/test/rules/no-empty/default/tslint.json b/test/rules/no-empty/default/tslint.json deleted file mode 100644 index 282eaa1ffa3..00000000000 --- a/test/rules/no-empty/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-empty": true - } -} diff --git a/test/rules/no-eval/test.ts.lint b/test/rules/no-eval/test.ts.lint deleted file mode 100644 index d7ffe5c856c..00000000000 --- a/test/rules/no-eval/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -var testVariable = "eval"; - -function a() { - function b() { - function c() { - eval("console.log('hi');"); - ~~~~ [forbidden eval] - } - } -} diff --git a/test/rules/no-eval/tslint.json b/test/rules/no-eval/tslint.json deleted file mode 100644 index 1f0ba96f559..00000000000 --- a/test/rules/no-eval/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-eval": true - } -} diff --git a/test/rules/no-floating-promises/jquerypromise/test.ts.lint b/test/rules/no-floating-promises/jquerypromise/test.ts.lint deleted file mode 100644 index 4d6096e18c1..00000000000 --- a/test/rules/no-floating-promises/jquerypromise/test.ts.lint +++ /dev/null @@ -1,17 +0,0 @@ -class Promise { } -class JQueryPromise { } -class NotAPromise { } - -const returnsPromise = () => new Promise(); -const returnsJQueryPromise = () => new JQueryPromise(); -const returnsNotAPromise = () => new NotAPromise(); - -returnsPromise(); -~~~~~~~~~~~~~~~~ [0] - -returnsJQueryPromise(); -~~~~~~~~~~~~~~~~~~~~~~ [0] - -returnsNotAPromise(); - -[0]: Promises must be handled appropriately diff --git a/test/rules/no-floating-promises/jquerypromise/tsconfig.json b/test/rules/no-floating-promises/jquerypromise/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-floating-promises/jquerypromise/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-floating-promises/jquerypromise/tslint.json b/test/rules/no-floating-promises/jquerypromise/tslint.json deleted file mode 100644 index 1aa03fb4f2f..00000000000 --- a/test/rules/no-floating-promises/jquerypromise/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-floating-promises": [true, "JQueryPromise"] - } -} diff --git a/test/rules/no-floating-promises/promises/test.ts.lint b/test/rules/no-floating-promises/promises/test.ts.lint deleted file mode 100644 index 145062f8c24..00000000000 --- a/test/rules/no-floating-promises/promises/test.ts.lint +++ /dev/null @@ -1,161 +0,0 @@ -class Promise { - then(): Promise; -} - -function returnsPromiseFunction() { - return new Promise(); -} - -const returnsPromiseVariable = () => new Promise(); - -class ReturnsPromiseClass { - returnsPromiseMemberFunction() { - return new Promise(); - } - - returnsPromiseMemberVariable = () => new Promise(); - - static returnsPromiseStaticFunction = () => new Promise(); -} - -let a = returnsPromiseFunction(); -let b = returnsPromiseVariable(); -let c = new ReturnsPromiseClass().returnsPromiseMemberFunction(); -let d = new ReturnsPromiseClass().returnsPromiseMemberVariable(); -let e = ReturnsPromiseClass.returnsPromiseStaticFunction(); - -returnsPromiseFunction(); -~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -returnsPromiseFunction().then(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -returnsPromiseVariable(); -~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -returnsPromiseVariable().then(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -new ReturnsPromiseClass().returnsPromiseMemberFunction(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -new ReturnsPromiseClass().returnsPromiseMemberFunction().then(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -new ReturnsPromiseClass().returnsPromiseMemberVariable(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -new ReturnsPromiseClass().returnsPromiseMemberVariable().then(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -ReturnsPromiseClass.returnsPromiseStaticFunction(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -ReturnsPromiseClass.returnsPromiseStaticFunction().then(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -(function () { - let a = returnsPromiseFunction(); - - returnsPromiseFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - returnsPromiseFunction().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberFunction().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberVariable(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberVariable().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - ReturnsPromiseClass.returnsPromiseStaticFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - ReturnsPromiseClass.returnsPromiseStaticFunction().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -})(); - -(() => { - let a = returnsPromiseFunction(); - - returnsPromiseFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - returnsPromiseFunction().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberFunction().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberVariable(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - new ReturnsPromiseClass().returnsPromiseMemberVariable().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - ReturnsPromiseClass.returnsPromiseStaticFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - ReturnsPromiseClass.returnsPromiseStaticFunction().then(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -})(); - -[].push(returnsPromiseFunction()); - -[].push(returnsPromiseFunction().then()); - -[].push(ReturnsPromiseClass.returnsPromiseStaticFunction()); - -[].push(ReturnsPromiseClass.returnsPromiseStaticFunction().then()); - -while (returnsPromiseFunction()); - -while (returnsPromiseFunction().then()); - -for (let i = 0; i < returnsPromiseFunction(); i += 1); - -for (let i = 0; i < returnsPromiseFunction().then(); i += 1); - -for (let i in returnsPromiseFunction()); - -for (let i in returnsPromiseFunction().then()); - -for (const promise of returnsPromiseFunction()); - -for (const promise of returnsPromiseFunction().then()); - -let promise = Math.random() > .5 - ? returnsPromiseFunction() - : returnsPromiseFunction().then(); - -declare var foo: boolean; -if (foo) - returnsPromiseFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] -switch(foo) { - case true: - returnsPromiseFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] - break; - case false: { - returnsPromiseFunction(); - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] - break; - } -} - -returnsPromiseFunction().catch(e => { console.error(e.stack); }); - -returnsPromiseFunction().then(() => {}, e => { console.error(e.stack); }); - -[0]: Promises must be handled appropriately diff --git a/test/rules/no-floating-promises/promises/tsconfig.json b/test/rules/no-floating-promises/promises/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-floating-promises/promises/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-floating-promises/promises/tslint.json b/test/rules/no-floating-promises/promises/tslint.json deleted file mode 100644 index 9ed3c104284..00000000000 --- a/test/rules/no-floating-promises/promises/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-floating-promises": true - } -} \ No newline at end of file diff --git a/test/rules/no-for-in-array/test.ts.lint b/test/rules/no-for-in-array/test.ts.lint deleted file mode 100644 index 4024527653e..00000000000 --- a/test/rules/no-for-in-array/test.ts.lint +++ /dev/null @@ -1,45 +0,0 @@ -const array = [1, 2, 3, 4]; -const strArray = ['a', 'b', 'c']; -const objArray = [{a: 1}, {a: 2, b: 10}, {a: 3}]; -const o = {}; -const numArray = { - 1: "a", - 2: "b" -}; -const d = new Date(); -const str = "abc"; -const objectMap = {} as {[key: string]: number}; -const map = new Map([['a', 1], ['b', 2]]); -const set = new Set([1, 2, 3]); - -class C { - a: number; - f() {} - g() {} -} -c = new C(); - -class A { } -let refType: A; - -// valid cases -for (var k in o); -for (var k in d); -for (var k in map); -for (var k in numArray); -for (var k in c); -for (var k in refType); - -// invalid cases -for (var k in array); -~~~~~~~~~~~~~~~~~~~~~ [0] -for (var k in str); -~~~~~~~~~~~~~~~~~~~ [0] -for (var k in objArray); -~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -// Ideally these would also be forbidden: -for (var k in map); -for (var k in set); - -[0]: for-in loops over arrays are forbidden. Use for-of or array.forEach instead. diff --git a/test/rules/no-for-in-array/tsconfig.json b/test/rules/no-for-in-array/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-for-in-array/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-for-in-array/tslint.json b/test/rules/no-for-in-array/tslint.json deleted file mode 100644 index 57f80691b45..00000000000 --- a/test/rules/no-for-in-array/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-for-in-array": true - } -} diff --git a/test/rules/no-for-in/test.ts.lint b/test/rules/no-for-in/test.ts.lint deleted file mode 100644 index a3dd806a466..00000000000 --- a/test/rules/no-for-in/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -const columns = [{ data: [1] }]; -for (let i = 0; i < columns[0].data.length; i++) { - columns.map((x) => x.data[i]); -} - -const object = { test: 1, test2: 1, test3: 1 }; -for (const key in object) { -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if (object.hasOwnProperty(key)) { -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const element = object[key]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~ -} -~ [Use a for...of statement instead of for...in. If iterating over an object, use Object.keys() to access its enumerable keys.] - -for (const key of Object.keys(object)) { - const value = object[key]; -} diff --git a/test/rules/no-for-in/tslint.json b/test/rules/no-for-in/tslint.json deleted file mode 100644 index 2a62503d3e3..00000000000 --- a/test/rules/no-for-in/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-for-in": true - } -} diff --git a/test/rules/no-implicit-dependencies/default/bom/package.json b/test/rules/no-implicit-dependencies/default/bom/package.json deleted file mode 100644 index 9c78824fcec..00000000000 --- a/test/rules/no-implicit-dependencies/default/bom/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "bom", - "version": "1.0.0", - "dependencies": {} -} diff --git a/test/rules/no-implicit-dependencies/default/bom/test.ts.lint b/test/rules/no-implicit-dependencies/default/bom/test.ts.lint deleted file mode 100644 index 3531bc9edbc..00000000000 --- a/test/rules/no-implicit-dependencies/default/bom/test.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -import * as ts from "typescript"; - ~~~~~~~~~~~~ [Module 'typescript' is not listed as dependency in package.json] diff --git a/test/rules/no-implicit-dependencies/default/builtin-only.ts.lint b/test/rules/no-implicit-dependencies/default/builtin-only.ts.lint deleted file mode 100644 index 1223a2e0983..00000000000 --- a/test/rules/no-implicit-dependencies/default/builtin-only.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -import * as fs from 'fs'; -import path = require('path'); -import('child_process').then(cp => cp.exec('foo')); -const http = require('http'); diff --git a/test/rules/no-implicit-dependencies/default/malformed/package.json b/test/rules/no-implicit-dependencies/default/malformed/package.json deleted file mode 100644 index 8c94190c464..00000000000 --- a/test/rules/no-implicit-dependencies/default/malformed/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - , -} diff --git a/test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint b/test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint deleted file mode 100644 index 217310ee713..00000000000 --- a/test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -import foo from 'foo'; - ~~~~~ [Module 'foo' is not listed as dependency in package.json] diff --git a/test/rules/no-implicit-dependencies/default/nested-package/package.json b/test/rules/no-implicit-dependencies/default/nested-package/package.json deleted file mode 100644 index 0b574aa2cf6..00000000000 --- a/test/rules/no-implicit-dependencies/default/nested-package/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "nested", - "version": "0.0.1", - "dependencies": { - "baz": "next" - } -} diff --git a/test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint b/test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint deleted file mode 100644 index 02f84aefcd8..00000000000 --- a/test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -import {assert} from 'chai'; - ~~~~~~ [err % ('chai')] -import foo from 'foo'; - ~~~~~ [err % ('foo')] - -if (foo) { - const common = require('common'); - ~~~~~~~~ [err % ('common')] -} - -export * from "@angular/core"; - ~~~~~~~~~~~~~~~ [err % ('@angular/core')] - -export * from "@angular/common/http"; - ~~~~~~~~~~~~~~~~~~~~~~ [err % ('@angular/common')] - -import * as ts from "typescript"; - ~~~~~~~~~~~~ [err % ('typescript')] - -import "baz"; - -const http = require('http'); - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/subdir/test.ts.lint b/test/rules/no-implicit-dependencies/default/subdir/test.ts.lint deleted file mode 100644 index 927a875463c..00000000000 --- a/test/rules/no-implicit-dependencies/default/subdir/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -import {assert} from 'chai'; - ~~~~~~ [err % ('chai')] -import foo from 'foo'; - -import Foo from 'Foo'; - ~~~~~ [err % ('Foo')] - -if (foo) { - const common = require('common'); - ~~~~~~~~ [err % ('common')] -} - -export * from "@angular/core"; - -export * from "@angular/common/http"; - -import * as ts from "typescript"; - -import "baz/foo"; - ~~~~~~~~~ [err % ('baz')] - -const http = require('http'); - -import test from '../test.ts'; - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/test.js.lint b/test/rules/no-implicit-dependencies/default/test.js.lint deleted file mode 100644 index ba3366f2051..00000000000 --- a/test/rules/no-implicit-dependencies/default/test.js.lint +++ /dev/null @@ -1,10 +0,0 @@ -const foo = require('foo'); -const bar = require('bar'); -const baz = require('baz'); - ~~~~~ [err % ('baz')] - -import storageHelper from 'storage-helper'; - ~~~~~~~~~~~~~~~~ [err % ('storage-helper')] -const myModule = require('./myModule'); - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/test.ts.lint b/test/rules/no-implicit-dependencies/default/test.ts.lint deleted file mode 100644 index 3ad34b19414..00000000000 --- a/test/rules/no-implicit-dependencies/default/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -import {assert} from 'chai'; - ~~~~~~ [err % ('chai')] -import foo from 'foo'; - -if (foo) { - const common = require('common'); - ~~~~~~~~ [err % ('common')] -} - -export * from "@angular/core"; - -export * from "@angular/common/http"; - -import * as ts from "typescript"; - -import "baz"; - ~~~~~ [err % ('baz')] - -const http = require('http'); - -import * as fsevents from "fsevents"; - ~~~~~~~~~~ [err % ('fsevents')] - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/tslint.json b/test/rules/no-implicit-dependencies/default/tslint.json deleted file mode 100644 index 9ad9a030528..00000000000 --- a/test/rules/no-implicit-dependencies/default/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "no-implicit-dependencies": true - }, - "jsRules": { - "no-implicit-dependencies": true - } -} diff --git a/test/rules/no-implicit-dependencies/dev/test.ts.lint b/test/rules/no-implicit-dependencies/dev/test.ts.lint deleted file mode 100644 index 9d4bbf3f269..00000000000 --- a/test/rules/no-implicit-dependencies/dev/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -import * as ts from 'typescript'; - -import {assert} from 'chai'; - -import foo from 'foo'; - -import {baz} from 'baz'; - ~~~~~ [err % ('baz')] - - -import * as fsevents from "fsevents"; - ~~~~~~~~~~ [err % ('fsevents')] - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/dev/tslint.json b/test/rules/no-implicit-dependencies/dev/tslint.json deleted file mode 100644 index 63472f0676a..00000000000 --- a/test/rules/no-implicit-dependencies/dev/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-implicit-dependencies": [true, "dev"] - } -} diff --git a/test/rules/no-implicit-dependencies/optional/test.ts.lint b/test/rules/no-implicit-dependencies/optional/test.ts.lint deleted file mode 100644 index 6c361996c20..00000000000 --- a/test/rules/no-implicit-dependencies/optional/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -import * as ts from 'typescript'; - -import {assert} from 'chai'; - ~~~~~~ [err % ('chai')] - -import foo from 'foo'; - -import {baz} from 'baz'; - ~~~~~ [err % ('baz')] - -import * as fsevents from "fsevents"; - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/optional/tslint.json b/test/rules/no-implicit-dependencies/optional/tslint.json deleted file mode 100644 index 451b4ce11e2..00000000000 --- a/test/rules/no-implicit-dependencies/optional/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-implicit-dependencies": [true, "optional"] - } -} diff --git a/test/rules/no-implicit-dependencies/package.json b/test/rules/no-implicit-dependencies/package.json deleted file mode 100644 index 9ff1fed0ee3..00000000000 --- a/test/rules/no-implicit-dependencies/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "test", - "version": "1.0.0", - "dependencies": { - "foo": "latest", - "bar": "latest", - "@angular/core": "4.4.5", - "@angular/common": "4.4.4" - }, - "devDependencies": { - "chai": "latest" - }, - "peerDependencies": { - "typescript": "2.5.3" - }, - "optionalDependencies": { - "fsevents": "latest" - } -} diff --git a/test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint b/test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint deleted file mode 100644 index 64c8000afb0..00000000000 --- a/test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -import * as ts from 'typescript'; - -import * from 'src/a'; - -import * from 'app/b'; - -import * from 'notapp/c'; - ~~~~~~~~~~ [err % ('notapp')] - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json b/test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json deleted file mode 100644 index 4e1437158ad..00000000000 --- a/test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-implicit-dependencies": [true, "dev", ["src", "app"]] - } -} diff --git a/test/rules/no-implicit-dependencies/whitelist/test.ts.lint b/test/rules/no-implicit-dependencies/whitelist/test.ts.lint deleted file mode 100644 index efc3c279f19..00000000000 --- a/test/rules/no-implicit-dependencies/whitelist/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -import * as ts from 'typescript'; - -import * from 'src/a'; - -import * from '@components/a'; - -import * from '@com/fixer'; - -import * from 'app/b'; - -import * from 'notapp/c'; - ~~~~~~~~~~ [err % ('notapp')] - -import * from '@notapp/c'; - ~~~~~~~~~~~ [err % ('@notapp/c')] - -import * from '@com/c'; - ~~~~~~~~ [err % ('@com/c')] - -[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/whitelist/tslint.json b/test/rules/no-implicit-dependencies/whitelist/tslint.json deleted file mode 100644 index 98121cf053c..00000000000 --- a/test/rules/no-implicit-dependencies/whitelist/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-implicit-dependencies": [true, ["src", "app", "@components", "@com/fixer"]] - } -} diff --git a/test/rules/no-import-side-effect/default/test.ts.lint b/test/rules/no-import-side-effect/default/test.ts.lint deleted file mode 100644 index 0f5151a0b4e..00000000000 --- a/test/rules/no-import-side-effect/default/test.ts.lint +++ /dev/null @@ -1,22 +0,0 @@ - -// valid cases -import {Injectable, Component, Directive} from '@angular/core'; -import {Inject} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; -import {Observable as Obs} from 'rxjs/Observable'; -import * as _ from 'underscore'; -import DefaultExport from 'module-with-default'; - -// invalid cases -import './allow-side-effect'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -import './styles.css'; -~~~~~~~~~~~~~~~~~~~~~~ [0] -import 'rxjs/add/observable/of'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -import 'rxjs/add/operator/mapTo'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -import 'random-side-effect'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: import with explicit side-effect diff --git a/test/rules/no-import-side-effect/default/tslint.json b/test/rules/no-import-side-effect/default/tslint.json deleted file mode 100644 index 220182feece..00000000000 --- a/test/rules/no-import-side-effect/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-import-side-effect": [true] - } -} diff --git a/test/rules/no-import-side-effect/ignore-module/test.ts.lint b/test/rules/no-import-side-effect/ignore-module/test.ts.lint deleted file mode 100644 index 971b14817a2..00000000000 --- a/test/rules/no-import-side-effect/ignore-module/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -// valid cases -import {Injectable, Component, Directive} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; -import {Observable as Obs} from 'rxjs/Observable'; -import * as _ from 'underscore'; -import DefaultExport from 'module-with-default'; -import './allow-side-effect'; -import './styles.css'; - -// invalid cases -import 'rxjs/add/observable/of'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -import 'rxjs/add/operator/mapTo'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -import 'random-side-effect'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: import with explicit side-effect diff --git a/test/rules/no-import-side-effect/ignore-module/tslint.json b/test/rules/no-import-side-effect/ignore-module/tslint.json deleted file mode 100644 index 72647987f09..00000000000 --- a/test/rules/no-import-side-effect/ignore-module/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "no-import-side-effect": [ - true, - { - "ignore-module": "(allow-side-effect|\\.css)$" - } - ] - } -} diff --git a/test/rules/no-inferrable-types/default/test.ts.fix b/test/rules/no-inferrable-types/default/test.ts.fix deleted file mode 100644 index 51255e20557..00000000000 --- a/test/rules/no-inferrable-types/default/test.ts.fix +++ /dev/null @@ -1,35 +0,0 @@ -// errors, inferrable type is declared -let a = 7; -let b = false; -let c = "foo"; -let d = Infinity; -let e = -Infinity; -class C { - x = 1; -} - -// errors, types are inferrable -function foo (a = 5, b = true, c = "bah") { } - -class Foo { - bar = 0; - baz = true, - bas = "moar"; - readonly foo: boolean = false; - constructor(readonly foobar: string = "test", public barfoo = 1) {} -} - -// not errors, inferrable type is not declared -let _x = 7; -let _y = false; -let _z = "foo"; - -// not error, type is not inferrable -let weird: any = 123; - -// not errors, inferrable type is not declared -function bar(a = 5, b = true, c = "bah") { } - -// not errors, types are not inferrable -function baz(a: any = 5, b: any = true, c: any = "bah") { } - diff --git a/test/rules/no-inferrable-types/default/test.ts.lint b/test/rules/no-inferrable-types/default/test.ts.lint deleted file mode 100644 index 02282636387..00000000000 --- a/test/rules/no-inferrable-types/default/test.ts.lint +++ /dev/null @@ -1,51 +0,0 @@ -// errors, inferrable type is declared -let a: number = 7; - ~~~~~~ [number] -let b: boolean = false; - ~~~~~~~ [boolean] -let c: string = "foo"; - ~~~~~~ [string] -let d: number = Infinity; - ~~~~~~ [number] -let e: number = -Infinity; - ~~~~~~ [number] -class C { - x: number = 1; - ~~~~~~ [number] -} - -// errors, types are inferrable -function foo (a: number = 5, b: boolean = true, c: string = "bah") { } - ~~~~~~ [number] - ~~~~~~~ [boolean] - ~~~~~~ [string] - -class Foo { - bar: number = 0; - ~~~~~~ [number] - baz: boolean = true, - ~~~~~~~ [boolean] - bas: string = "moar"; - ~~~~~~ [string] - readonly foo: boolean = false; - constructor(readonly foobar: string = "test", public barfoo: number = 1) {} - ~~~~~~ [number] -} - -// not errors, inferrable type is not declared -let _x = 7; -let _y = false; -let _z = "foo"; - -// not error, type is not inferrable -let weird: any = 123; - -// not errors, inferrable type is not declared -function bar(a = 5, b = true, c = "bah") { } - -// not errors, types are not inferrable -function baz(a: any = 5, b: any = true, c: any = "bah") { } - -[number]: Type number trivially inferred from a number literal, remove type annotation -[boolean]: Type boolean trivially inferred from a boolean literal, remove type annotation -[string]: Type string trivially inferred from a string literal, remove type annotation diff --git a/test/rules/no-inferrable-types/default/tslint.json b/test/rules/no-inferrable-types/default/tslint.json deleted file mode 100644 index e753f48f599..00000000000 --- a/test/rules/no-inferrable-types/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-inferrable-types": true - } -} diff --git a/test/rules/no-inferrable-types/ignore-params/test.ts.fix b/test/rules/no-inferrable-types/ignore-params/test.ts.fix deleted file mode 100644 index 2adaaff65c3..00000000000 --- a/test/rules/no-inferrable-types/ignore-params/test.ts.fix +++ /dev/null @@ -1,34 +0,0 @@ -// errors, inferrable type is declared -let x = 7; -let y = false; -let z = "foo"; - -// not errors, we are skipping params -function foo (a: number = 5, b: boolean = true, c: string = "bah") { } - -class TestClass { - doSomething(a: number = 5, b: boolean = true, c: string = "bah") {} -} - -class Foo { - bar = 0; - baz = true, - bas = "moar"; - readonly foo: boolean = false; - constructor(readonly foobar: string = "test", public barfoo: number = 1) {} -} - -// not errors, inferrable type is not declared -let _x = 7; -let _y = false; -let _z = "foo"; - -// not error, type is not inferrable -let weird: any = 123; - -// not errors, inferrable type is not declared -function bar(a = 5, b = true, c = "bah") { } - -// not errors, types are not inferrable -function baz(a: any = 5, b: any = true, c: any = "bah") { } - diff --git a/test/rules/no-inferrable-types/ignore-params/test.ts.lint b/test/rules/no-inferrable-types/ignore-params/test.ts.lint deleted file mode 100644 index f5fbee1fc09..00000000000 --- a/test/rules/no-inferrable-types/ignore-params/test.ts.lint +++ /dev/null @@ -1,43 +0,0 @@ -// errors, inferrable type is declared -let x: number = 7; - ~~~~~~ [number] -let y: boolean = false; - ~~~~~~~ [boolean] -let z: string = "foo"; - ~~~~~~ [string] - -// not errors, we are skipping params -function foo (a: number = 5, b: boolean = true, c: string = "bah") { } - -class TestClass { - doSomething(a: number = 5, b: boolean = true, c: string = "bah") {} -} - -class Foo { - bar: number = 0; - ~~~~~~ [number] - baz: boolean = true, - ~~~~~~~ [boolean] - bas: string = "moar"; - ~~~~~~ [string] - readonly foo: boolean = false; - constructor(readonly foobar: string = "test", public barfoo: number = 1) {} -} - -// not errors, inferrable type is not declared -let _x = 7; -let _y = false; -let _z = "foo"; - -// not error, type is not inferrable -let weird: any = 123; - -// not errors, inferrable type is not declared -function bar(a = 5, b = true, c = "bah") { } - -// not errors, types are not inferrable -function baz(a: any = 5, b: any = true, c: any = "bah") { } - -[number]: Type number trivially inferred from a number literal, remove type annotation -[boolean]: Type boolean trivially inferred from a boolean literal, remove type annotation -[string]: Type string trivially inferred from a string literal, remove type annotation diff --git a/test/rules/no-inferrable-types/ignore-params/tslint.json b/test/rules/no-inferrable-types/ignore-params/tslint.json deleted file mode 100644 index bad8056f990..00000000000 --- a/test/rules/no-inferrable-types/ignore-params/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "no-inferrable-types": [ - true, - "ignore-params" - ] - } -} diff --git a/test/rules/no-inferrable-types/ignore-properties/test.ts.fix b/test/rules/no-inferrable-types/ignore-properties/test.ts.fix deleted file mode 100644 index 5f9c54304c6..00000000000 --- a/test/rules/no-inferrable-types/ignore-properties/test.ts.fix +++ /dev/null @@ -1,33 +0,0 @@ -// errors, inferrable type is declared -let x = 7; -let y = false; -let z = "foo"; -class C { - x: number = 1; -} - -// errors, types are inferrable -function foo (a = 5, b = true, c = "bah") { } - -class Foo { - bar: number = 0; - baz: boolean = true, - bas: string = "moar"; - readonly foo: boolean = false; - constructor(readonly foobar: string = "test", public barfoo: number = 1) {} -} - -// not errors, inferrable type is not declared -let _x = 7; -let _y = false; -let _z = "foo"; - -// not error, type is not inferrable -let weird: any = 123; - -// not errors, inferrable type is not declared -function bar(a = 5, b = true, c = "bah") { } - -// not errors, types are not inferrable -function baz(a: any = 5, b: any = true, c: any = "bah") { } - diff --git a/test/rules/no-inferrable-types/ignore-properties/test.ts.lint b/test/rules/no-inferrable-types/ignore-properties/test.ts.lint deleted file mode 100644 index b9147ddd705..00000000000 --- a/test/rules/no-inferrable-types/ignore-properties/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -// errors, inferrable type is declared -let x: number = 7; - ~~~~~~ [number] -let y: boolean = false; - ~~~~~~~ [boolean] -let z: string = "foo"; - ~~~~~~ [string] -class C { - x: number = 1; -} - -// errors, types are inferrable -function foo (a: number = 5, b: boolean = true, c: string = "bah") { } - ~~~~~~ [number] - ~~~~~~~ [boolean] - ~~~~~~ [string] - -class Foo { - bar: number = 0; - baz: boolean = true, - bas: string = "moar"; - readonly foo: boolean = false; - constructor(readonly foobar: string = "test", public barfoo: number = 1) {} -} - -// not errors, inferrable type is not declared -let _x = 7; -let _y = false; -let _z = "foo"; - -// not error, type is not inferrable -let weird: any = 123; - -// not errors, inferrable type is not declared -function bar(a = 5, b = true, c = "bah") { } - -// not errors, types are not inferrable -function baz(a: any = 5, b: any = true, c: any = "bah") { } - -[number]: Type number trivially inferred from a number literal, remove type annotation -[boolean]: Type boolean trivially inferred from a boolean literal, remove type annotation -[string]: Type string trivially inferred from a string literal, remove type annotation diff --git a/test/rules/no-inferrable-types/ignore-properties/tslint.json b/test/rules/no-inferrable-types/ignore-properties/tslint.json deleted file mode 100644 index 2d9fd532f2c..00000000000 --- a/test/rules/no-inferrable-types/ignore-properties/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-inferrable-types": [true, "ignore-properties"] - } -} diff --git a/test/rules/no-inferred-empty-object-type/test.ts.lint b/test/rules/no-inferred-empty-object-type/test.ts.lint deleted file mode 100644 index 9026cc355d4..00000000000 --- a/test/rules/no-inferred-empty-object-type/test.ts.lint +++ /dev/null @@ -1,92 +0,0 @@ -[typescript]: <=3.4.5 - -let s: string; -let n: number; -let o: Object; -let l: { a: number, b: string }; -let t: [number, string]; -let p: Wrapper; -let f: () => void; -type EmptyFunc = () => void; -let voidFunc: () => void; -let stringFunc: () => string; -function WrapperFunc(x?: T): T { - return x; -} -function CurriedFunc(h?: () => T): () => T { - return h; -} -function MultiParamFunction(x?: T, y?: U): T { - return x; -} -class Wrapper { - val: T; -} -class MultiParamsClass { - val1: T; - val2: U; -} - -/* Bad */ -WrapperFunc(); -~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the function call] -CurriedFunc(); -~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the function call] -MultiParamFunction(); -~~~~~~~~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the function call] -new Wrapper(); -~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the constructor] -new MultiParamsClass(); -~~~~~~~~~~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the constructor] - -/* Good */ -WrapperFunc(); -WrapperFunc(); -WrapperFunc(); -WrapperFunc(s); -WrapperFunc(n); -WrapperFunc(o); -WrapperFunc(l); -WrapperFunc(t); -WrapperFunc(p); -WrapperFunc(f); -WrapperFunc<() => {}>(); - -WrapperFunc<() => void>(); -WrapperFunc<{ a: number }>(); -WrapperFunc<{ [x: number]: string }>(); -WrapperFunc<{ [x: string]: string }>(); - -CurriedFunc(voidFunc); -CurriedFunc(stringFunc); - -MultiParamFunction(); -MultiParamFunction<{}, number>(); -MultiParamFunction(); -MultiParamFunction<{ a: number }, string>(); -MultiParamFunction<() => {}, () => void>(); -MultiParamFunction<() => void, () => {}>(); -MultiParamFunction<() => void, () => void>(); -MultiParamFunction<{ [x: number]: string }, () => void>(); -MultiParamFunction<{ [x: string]: string }, number>(); - -new Wrapper(); -new Wrapper<() => void>(); -new Wrapper<() => {}>(); -new Wrapper<{ a: number }>(); -new Wrapper<{ [x: number]: string }>(); -new Wrapper<{ [x: string]: string }>(); - -new MultiParamsClass(); -new MultiParamsClass<{}, number>(); -new MultiParamsClass(); -new MultiParamsClass<{ a: number }, string>(); -new MultiParamsClass<() => {}, () => void>(); -new MultiParamsClass<() => void, () => {}>(); -new MultiParamsClass<() => void, () => void>(); -new MultiParamsClass<{ [x: number]: string }, () => void>(); -new MultiParamsClass<{ [x: string]: string }, number>(); - -// don't crash with stack overflow -import {expect} from "chai"; -expect(1).to.eq(1); diff --git a/test/rules/no-inferred-empty-object-type/tsconfig.json b/test/rules/no-inferred-empty-object-type/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-inferred-empty-object-type/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-inferred-empty-object-type/tslint.json b/test/rules/no-inferred-empty-object-type/tslint.json deleted file mode 100644 index 81b900beb64..00000000000 --- a/test/rules/no-inferred-empty-object-type/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-inferred-empty-object-type": true - } -} diff --git a/test/rules/no-internal-module/test.ts.fix b/test/rules/no-internal-module/test.ts.fix deleted file mode 100644 index 89359233193..00000000000 --- a/test/rules/no-internal-module/test.ts.fix +++ /dev/null @@ -1,62 +0,0 @@ -namespace foo { -} - -// valid, special syntax for augmenting global -declare global { } - -namespace bar { -} - -declare namespace buzz { -} - -declare module "hoge" { -} -declare module 'fuga' { -} - -namespace foo.bar { -} -namespace foo.bar.baz { -} -namespace foo { - namespace bar.baz { - } -} - -namespace foo.bar { - namespace baz { - namespace buzz { - } - } -} - -namespace foo.bar { - namespace baz { - namespace buzz { - } - } -} - -namespace name.namespace { -} -namespace namespace.name { -} - -// intentionally malformed for test cases, do not format -declare namespace declare -.dec{} -declare namespace dec . declare { -} - -namespace mod.module{} -namespace module.mod -{ -} - -namespace global {} -namespace foo.global {} -namespace foo { - export namespace global {} -} - diff --git a/test/rules/no-internal-module/test.ts.lint b/test/rules/no-internal-module/test.ts.lint deleted file mode 100644 index 64cf478d2db..00000000000 --- a/test/rules/no-internal-module/test.ts.lint +++ /dev/null @@ -1,76 +0,0 @@ -namespace foo { -} - -// valid, special syntax for augmenting global -declare global { } - -module bar { -~~~~~~ [0] -} - -declare module buzz { - ~~~~~~ [0] -} - -declare module "hoge" { -} -declare module 'fuga' { -} - -namespace foo.bar { -} -namespace foo.bar.baz { -} -namespace foo { - namespace bar.baz { - } -} - -namespace foo.bar { - module baz { - ~~~~~~ [0] - namespace buzz { - } - } -} - -module foo.bar { -~~~~~~ [0] - namespace baz { - module buzz { - ~~~~~~ [0] - } - } -} - -namespace name.namespace { -} -namespace namespace.name { -} - -// intentionally malformed for test cases, do not format -declare module declare - ~~~~~~ [0] -.dec{} -declare module dec . declare { - ~~~~~~ [0] -} - -module mod.module{} -~~~~~~ [0] -module module.mod -~~~~~~ [0] -{ -} - -module global {} -~~~~~~ [0] -module foo.global {} -~~~~~~ [0] -module foo { -~~~~~~ [0] - export module global {} - ~~~~~~ [0] -} - -[0]: The internal 'module' syntax is deprecated, use the 'namespace' keyword instead. diff --git a/test/rules/no-internal-module/tslint.json b/test/rules/no-internal-module/tslint.json deleted file mode 100644 index ac4edc57f5f..00000000000 --- a/test/rules/no-internal-module/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-internal-module": true - } -} diff --git a/test/rules/no-invalid-template-strings/test.ts.lint b/test/rules/no-invalid-template-strings/test.ts.lint deleted file mode 100644 index ac4fd54f7d2..00000000000 --- a/test/rules/no-invalid-template-strings/test.ts.lint +++ /dev/null @@ -1,41 +0,0 @@ -new (Tab.mixins.Controlled('MemberComments',Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData()))) - -new (Tab.mixins.Controlled('MemberComments',Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('\${c}')))) - -Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('\\${d}')) - ~~~~ [0] - -Tab.mixins.Templated(`
`,Tab.mixins.AlwaysHasData('${f}')) - ~~~~ [0] - -Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('${h}'), Tab.mixin.SomeMethod('${i}')) - ~~~~ [0] - ~~~~ [0] - ~~~~ [0] - -new (Tab.mixins.Controlled('MemberComments',Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData()))) - ~~~~ [0] - -new (Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('\\\\${c}')))) - ~~~~ [0] - -"\${a} = ${a}"; - ~~~~ [0] - -"One plus one is ${1 + 1}."; - ~~~~~~~~ [0] - -'One plus one is ${1 + 1}.'; - ~~~~~~~~ [0] - -`One plus one is ${1 + 1}.`; - -"${"; - -"${" + '}'; - -"${() => {}} ${abc}" - ~~~~~~~~~~ [0] - ~~~~~~ [0] - -[0]: Interpolation will only work for template strings. diff --git a/test/rules/no-invalid-template-strings/tslint.json b/test/rules/no-invalid-template-strings/tslint.json deleted file mode 100644 index f495c57db7e..00000000000 --- a/test/rules/no-invalid-template-strings/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-invalid-template-strings": true - } -} diff --git a/test/rules/no-invalid-this/enabled/test.ts.lint b/test/rules/no-invalid-this/enabled/test.ts.lint deleted file mode 100644 index 47f50f57aa2..00000000000 --- a/test/rules/no-invalid-this/enabled/test.ts.lint +++ /dev/null @@ -1,118 +0,0 @@ -function setSomeProperty(this: { someProperty: number }) { - this.someProperty = 7; -} - -function bindProperty(this: { someProperty: number }, fn: Function) { - return fn.bind(this); -} - -const objectLiteralStyle = { - bindProperty: function(this: { someProperty: number }, fn: Function) { - return fn.bind(this); - }, -}; - -const objectMethodStyle = { - bindProperty(this: { someProperty: number }, fn: Function) { - return fn.bind(this); - }, -}; - -export function f(this: Observable): Observable { - const nestedFunction = function(this) => { - console.log(this) - } - return this.map(i=>i); -} - -class ContextualThisClass { - private someMethod(): void { - let nestedFunction: (this: number[]) => number[] = function(this) { - [3,4].forEach(function(nr){ - console.log(this); - ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] - }); - return this.map(i=>i); - }; - } -} - -function foo(x: number) { - console.log(this.x); - ~~~~ [the "this" keyword is disallowed outside of a class body] - - this.evilMethod(); - ~~~~ [the "this" keyword is disallowed outside of a class body] -} - -class AClass { - private x: number; - - constructor() { - this.x = 2; - } - - public aMethod() { - this.x = 5; - } - - public bMethod() { - [3,4].forEach(function(nr){ - console.log(this.x === nr); - ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] - }); - } - - public bMethod() { - [3,4].forEach((nr) => { - console.log(this.x === nr); - }); - } - - public cMethod = () => { - [3,4].forEach(function(nr){ - console.log(this.x === nr); - ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] - }); - } - - public dMethod() { - [3,4].forEach(badFunction); - function badFunction(nr) { - console.log(this.x === nr); - ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] - } - } - - public eMethod() { - [3,4].forEach(badFunction); - let badFunction = nr => console.log(this.x === nr); - } - - public fMethod() { - const objectLiteralStyle = { - bindProperty: function(this: { someProperty: number }, fn: Function) { - return fn.bind(this); - }, - }; - - const objectMethodStyle = { - bindProperty(this: { someProperty: number }, fn: Function) { - return fn.bind(this); - }, - }; - - return { - objectLiteralStyle, - objectMethodStyle, - }; - } -} - -const AClassExpression = class { - private x: number; - - public aMethod() { - this.x = 5; - } -} diff --git a/test/rules/no-invalid-this/enabled/tslint.json b/test/rules/no-invalid-this/enabled/tslint.json deleted file mode 100644 index 55c5eee2986..00000000000 --- a/test/rules/no-invalid-this/enabled/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "no-invalid-this": [ - true, - "check-function-in-method" - ] - } -} diff --git a/test/rules/no-irregular-whitespace/test.builder.ts b/test/rules/no-irregular-whitespace/test.builder.ts deleted file mode 100644 index 4d540345060..00000000000 --- a/test/rules/no-irregular-whitespace/test.builder.ts +++ /dev/null @@ -1,41 +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. - */ - -/** - * This script auto-generate test files for the `no-irregular-whitespace` rule - */ - -import * as fs from 'fs'; -import * as path from 'path'; - -import { IRREGULAR_WHITESPACE_REGEX } from '../../../src/rules/noIrregularWhitespaceRule'; - -const matches = IRREGULAR_WHITESPACE_REGEX.source - .substring(1, IRREGULAR_WHITESPACE_REGEX.source.length - 2) - .match(/\\\w+/g) - .filter(match => ['\\u2029', '\\u2028'].indexOf(match) === -1) // those seems to break the parser - .map(match => JSON.parse(`"${match}"`) as string); - -const lintFilePath = path.join(__dirname, "test.ts.lint"); -const lintFileContent = matches.reduce((acc: string, match) => { - return acc += `let ${match} foo;\n ~ [Irregular whitespace not allowed]\n`; -}, ''); -fs.writeFileSync(lintFilePath, lintFileContent); - -const fixFilePath = path.join(__dirname, "test.ts.fix"); -const fixFileContent = 'let foo;\n'.repeat(matches.length) -fs.writeFileSync(fixFilePath, fixFileContent); diff --git a/test/rules/no-irregular-whitespace/test.ts.fix b/test/rules/no-irregular-whitespace/test.ts.fix deleted file mode 100644 index 608ce2c0cf4..00000000000 --- a/test/rules/no-irregular-whitespace/test.ts.fix +++ /dev/null @@ -1,22 +0,0 @@ -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; -let foo; diff --git a/test/rules/no-irregular-whitespace/test.ts.lint b/test/rules/no-irregular-whitespace/test.ts.lint deleted file mode 100644 index d18c7f261e2..00000000000 --- a/test/rules/no-irregular-whitespace/test.ts.lint +++ /dev/null @@ -1,44 +0,0 @@ -let foo; - ~ [Irregular whitespace not allowed] -let foo; - ~ [Irregular whitespace not allowed] -let … foo; - ~ [Irregular whitespace not allowed] -let  foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let ᠎ foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let ​ foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] -let   foo; - ~ [Irregular whitespace not allowed] diff --git a/test/rules/no-irregular-whitespace/tslint.json b/test/rules/no-irregular-whitespace/tslint.json deleted file mode 100644 index 5d70362a4a2..00000000000 --- a/test/rules/no-irregular-whitespace/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-irregular-whitespace": true - } -} diff --git a/test/rules/no-magic-numbers/allowed-numbers/test.ts.lint b/test/rules/no-magic-numbers/allowed-numbers/test.ts.lint deleted file mode 100644 index 35a47e2bb56..00000000000 --- a/test/rules/no-magic-numbers/allowed-numbers/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -parseInt(); -parseInt('123', 2); -parseInt('123', 8); -parseInt('123', 10); -parseInt('123', 16); -console.log(-0); -console.log(1337); -console.log(-1337); -console.log(- 1337); -console.log(1337.7); -console.log(1338); - ~~~~ ['magic numbers' are not allowed: 1338] -console.log(-1338) - ~~~~~ ['magic numbers' are not allowed: -1338] -parseInt(foo === 4711 ? bar : baz, 10); - ~~~~ ['magic numbers' are not allowed: 4711] -parseInt(foo === -0 ? bar : baz, 10); -export let x = 1337; -export let x = -1337; -export let x = 1337.7; -export let x = 1338; -export let x = -1338; -export let x = -0; diff --git a/test/rules/no-magic-numbers/allowed-numbers/tslint.json b/test/rules/no-magic-numbers/allowed-numbers/tslint.json deleted file mode 100644 index 6cbe7e8b5a8..00000000000 --- a/test/rules/no-magic-numbers/allowed-numbers/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "no-magic-numbers": [true, { - "allowed-numbers": [1337, 1337.7, -1337, -0] - }] - } -} diff --git a/test/rules/no-magic-numbers/custom/test.ts.lint b/test/rules/no-magic-numbers/custom/test.ts.lint deleted file mode 100644 index 35a47e2bb56..00000000000 --- a/test/rules/no-magic-numbers/custom/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -parseInt(); -parseInt('123', 2); -parseInt('123', 8); -parseInt('123', 10); -parseInt('123', 16); -console.log(-0); -console.log(1337); -console.log(-1337); -console.log(- 1337); -console.log(1337.7); -console.log(1338); - ~~~~ ['magic numbers' are not allowed: 1338] -console.log(-1338) - ~~~~~ ['magic numbers' are not allowed: -1338] -parseInt(foo === 4711 ? bar : baz, 10); - ~~~~ ['magic numbers' are not allowed: 4711] -parseInt(foo === -0 ? bar : baz, 10); -export let x = 1337; -export let x = -1337; -export let x = 1337.7; -export let x = 1338; -export let x = -1338; -export let x = -0; diff --git a/test/rules/no-magic-numbers/custom/tslint.json b/test/rules/no-magic-numbers/custom/tslint.json deleted file mode 100644 index 7b109490b00..00000000000 --- a/test/rules/no-magic-numbers/custom/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-magic-numbers": [true, 1337, 1337.7, -1337, -0] - } -} diff --git a/test/rules/no-magic-numbers/default-jsx/test.tsx.lint b/test/rules/no-magic-numbers/default-jsx/test.tsx.lint deleted file mode 100644 index 27ae8e598f8..00000000000 --- a/test/rules/no-magic-numbers/default-jsx/test.tsx.lint +++ /dev/null @@ -1,8 +0,0 @@ -import * as React from "react"; -class App extends React.Component { - render() { - return ; - ~~~ ['magic numbers' are not allowed: 200] - ~~~ ['magic numbers' are not allowed: 200] - } -} diff --git a/test/rules/no-magic-numbers/default-jsx/tslint.json b/test/rules/no-magic-numbers/default-jsx/tslint.json deleted file mode 100644 index 13ce3e0dab0..00000000000 --- a/test/rules/no-magic-numbers/default-jsx/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-magic-numbers": true - } -} diff --git a/test/rules/no-magic-numbers/default/test.ts.lint b/test/rules/no-magic-numbers/default/test.ts.lint deleted file mode 100644 index 8cd050f2c5e..00000000000 --- a/test/rules/no-magic-numbers/default/test.ts.lint +++ /dev/null @@ -1,48 +0,0 @@ -console.log(-1, 0, 1); -console.log(42.42); - ~~~~~ ['magic numbers' are not allowed: 42.42] -console.log(-0); - ~~ ['magic numbers' are not allowed: -0] -const a = 1337; -const b = { - a: 1338, - b: 0, -} -b.b = 1339; - ~~~~ ['magic numbers' are not allowed: 1339] - -console.log(1340); - ~~~~ ['magic numbers' are not allowed: 1340] -for(let i = 0;i>1341;++i) { - ~~~~ ['magic numbers' are not allowed: 1341] -} - -throw 1342; - ~~~~ ['magic numbers' are not allowed: 1342] - -class A { - static test = 1337; - - constructor (private a = 1337) { - } -} - -enum Test { - key = 1337, -} - -const a = 0.1234567801234567890; -a.toFixed(2); -a.toFixed(5); -a.toFixed(10); - -a.toString(10); -a.toString(36); - -a.toPrecision(3) -a.toPrecision(10) -a.toPrecision(20) - -const b = 77.1234; -b.toExponential(4); -b.toExponential(2); diff --git a/test/rules/no-magic-numbers/default/tslint.json b/test/rules/no-magic-numbers/default/tslint.json deleted file mode 100644 index 13ce3e0dab0..00000000000 --- a/test/rules/no-magic-numbers/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-magic-numbers": true - } -} diff --git a/test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint b/test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint deleted file mode 100644 index 77e9a1bf651..00000000000 --- a/test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint +++ /dev/null @@ -1,10 +0,0 @@ -import * as React from "react"; -class App extends React.Component { - render() { - return ; - } -} - -function something(num) {} -something(100) - ~~~ ['magic numbers' are not allowed: 100] diff --git a/test/rules/no-magic-numbers/ignore-jsx/tslint.json b/test/rules/no-magic-numbers/ignore-jsx/tslint.json deleted file mode 100644 index d0d81589636..00000000000 --- a/test/rules/no-magic-numbers/ignore-jsx/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "no-magic-numbers": [true, { - "ignore-jsx": true - }] - } -} diff --git a/test/rules/no-mergeable-namespace/test.ts.lint b/test/rules/no-mergeable-namespace/test.ts.lint deleted file mode 100644 index 9e884966eee..00000000000 --- a/test/rules/no-mergeable-namespace/test.ts.lint +++ /dev/null @@ -1,41 +0,0 @@ -// valid case -var foo; -namespace foo{ - namespace foo {} -} -declare module buzz {} -module bar {} - -// invalid case -namespace a {} -namespace a {} - ~ [err % ('a', '10')] - -namespace b { - namespace b {} - namespace b {} - ~ [err % ('b', '14')] - namespace b {} - ~ [err % ('b', '15')] -} - -namespace x.y {} -namespace x { namespace y{} } - ~ [err % ('x', '19')] - -namespace m.n { - namespace l {} - namespace l {} - ~ [err % ('l', '23')] -} - -module "foo" { - // Different than outer 'a' - namespace a {} - - namespace q {} - namespace q {} - ~ [err % ('q', '31')] -} - -[err]: Mergeable namespace '%s' found. Merge its contents with the namespace on line %s. diff --git a/test/rules/no-mergeable-namespace/tslint.json b/test/rules/no-mergeable-namespace/tslint.json deleted file mode 100644 index 74cde33b4d0..00000000000 --- a/test/rules/no-mergeable-namespace/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-mergeable-namespace": true - } -} diff --git a/test/rules/no-misused-new/test.ts.lint b/test/rules/no-misused-new/test.ts.lint deleted file mode 100644 index f1ed5ca1120..00000000000 --- a/test/rules/no-misused-new/test.ts.lint +++ /dev/null @@ -1,32 +0,0 @@ -interface I { - new(): I; - ~~~~~~~~~ [0] - // OK if return type is not the interface. - new(): {}; - constructor(): void; - ~~~~~~~~~~~~~~~~~~~~ [0] -} - -// Works for generic type. -interface G { - new(): G; - ~~~~~~~~~~~~~~~ [0] -} - -type T = { - // `new` OK in type literal (we don't know the type name) - new(): T; - // `constructor` still flagged. - constructor(): void; - ~~~~~~~~~~~~~~~~~~~~ [0] -} - -class C { - new(): C; - ~~~~~~~~~ [1] - // OK if there's a body - new() {} -} - -[0]: Interfaces cannot be constructed, only classes. Did you mean `declare class`? -[1]: `new` in a class is a method named "new". Did you mean `constructor`? diff --git a/test/rules/no-misused-new/tslint.json b/test/rules/no-misused-new/tslint.json deleted file mode 100644 index 87f36324069..00000000000 --- a/test/rules/no-misused-new/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-misused-new": true - } -} diff --git a/test/rules/no-namespace/allow-declarations/test.d.ts.lint b/test/rules/no-namespace/allow-declarations/test.d.ts.lint deleted file mode 100644 index 28cba058e92..00000000000 --- a/test/rules/no-namespace/allow-declarations/test.d.ts.lint +++ /dev/null @@ -1 +0,0 @@ -namespace N { } diff --git a/test/rules/no-namespace/allow-declarations/test.ts.lint b/test/rules/no-namespace/allow-declarations/test.ts.lint deleted file mode 100644 index d60730eae44..00000000000 --- a/test/rules/no-namespace/allow-declarations/test.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -declare global {} - -declare namespace Foo { - // Allowed because namespaces nested in ambients are implicitly ambient. - namespace Foo { - - } -} diff --git a/test/rules/no-namespace/allow-declarations/tslint.json b/test/rules/no-namespace/allow-declarations/tslint.json deleted file mode 100644 index b90b9030e34..00000000000 --- a/test/rules/no-namespace/allow-declarations/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-namespace": [true, "allow-declarations"] - } -} diff --git a/test/rules/no-namespace/default/test.d.ts.lint b/test/rules/no-namespace/default/test.d.ts.lint deleted file mode 100644 index eb104f9c9e7..00000000000 --- a/test/rules/no-namespace/default/test.d.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -namespace N { } -~~~~~~~~~~~~~~~ ['namespace' and 'module' are disallowed] diff --git a/test/rules/no-namespace/default/test.ts.lint b/test/rules/no-namespace/default/test.ts.lint deleted file mode 100644 index 7bce2405982..00000000000 --- a/test/rules/no-namespace/default/test.ts.lint +++ /dev/null @@ -1,25 +0,0 @@ -namespace Foo { -~~~~~~~~~~~~~~~ -} -~ ['namespace' and 'module' are disallowed] -namespace Foo.Bar { -~~~~~~~~~~~~~~~~~~~ -} -~ ['namespace' and 'module' are disallowed] - -module Foo { -~~~~~~~~~~~~ -} -~ ['namespace' and 'module' are disallowed] - -declare namespace Foo { -~~~~~~~~~~~~~~~~~~~~~~~ -} -~ ['namespace' and 'module' are disallowed] - -declare module 'foo' { -} - -declare global { - interface Foo {} -} diff --git a/test/rules/no-namespace/default/tslint.json b/test/rules/no-namespace/default/tslint.json deleted file mode 100644 index 6958cd0e9b5..00000000000 --- a/test/rules/no-namespace/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-namespace": [true] - } -} diff --git a/test/rules/no-non-null-assertion/test.ts.lint b/test/rules/no-non-null-assertion/test.ts.lint deleted file mode 100644 index 12bb8af725d..00000000000 --- a/test/rules/no-non-null-assertion/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -var x = null - -x!.y = null -~~ [Forbidden non null assertion] diff --git a/test/rules/no-non-null-assertion/tslint.json b/test/rules/no-non-null-assertion/tslint.json deleted file mode 100644 index 6359b34ac55..00000000000 --- a/test/rules/no-non-null-assertion/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-non-null-assertion": true - } -} diff --git a/test/rules/no-null-keyword/test.ts.fix b/test/rules/no-null-keyword/test.ts.fix deleted file mode 100644 index 5a43ae107d8..00000000000 --- a/test/rules/no-null-keyword/test.ts.fix +++ /dev/null @@ -1,12 +0,0 @@ -var x = null; // error -console.log(null, x); // error - -let match: string | null; -interface foo { - bar: [number, null, string]; -} - -if (document.querySelector('.foo') === null) {} -if (document.querySelector('.foo') == undefined) {} -if (null !== document.querySelector('.foo')) {} -if (undefined != document.querySelector('.foo')) {} diff --git a/test/rules/no-null-keyword/test.ts.lint b/test/rules/no-null-keyword/test.ts.lint deleted file mode 100644 index 92248e37a1f..00000000000 --- a/test/rules/no-null-keyword/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -var x = null; // error - ~~~~ [0] -console.log(null, x); // error - ~~~~ [0] - -let match: string | null; -interface foo { - bar: [number, null, string]; -} - -if (document.querySelector('.foo') === null) {} -if (document.querySelector('.foo') == null) {} - ~~~~ [0] -if (null !== document.querySelector('.foo')) {} -if (null != document.querySelector('.foo')) {} - ~~~~ [0] - -[0]: Use 'undefined' instead of 'null' \ No newline at end of file diff --git a/test/rules/no-null-keyword/tslint.json b/test/rules/no-null-keyword/tslint.json deleted file mode 100644 index 1e4bf06a307..00000000000 --- a/test/rules/no-null-keyword/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-null-keyword": true - } -} diff --git a/test/rules/no-null-undefined-union/test.ts.lint b/test/rules/no-null-undefined-union/test.ts.lint deleted file mode 100644 index 5b7df70469b..00000000000 --- a/test/rules/no-null-undefined-union/test.ts.lint +++ /dev/null @@ -1,85 +0,0 @@ -[typescript]: >= 2.4.0 < 3.5.0 - -// Catches explicit union types. - -type SomeType = - - | null - ~~~~ - | undefined -~~~~~~~~~~~~~~~ - | boolean; -~~~~~~~~~~~~~ [0] - -const c: string | null | undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const someFunc = (): string | undefined | null => {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const someFunc = (foo: null | string | undefined, bar: boolean) => {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -interface SomeInterface { - foo: number | null | undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - bar: boolean; -} - -function someFunc(): Promise {} // error - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -function someFunc(bar: boolean, foo: undefined | number | null) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -// Catches implicit return types. - -function testFunc() { -~~~~~~~~~~~~~~~~~~~~~ - const somePredicate = (): boolean => true; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const someFunc = (): string | null => null; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - let foo; -~~~~~~~~~~~~ - if (somePredicate()) { -~~~~~~~~~~~~~~~~~~~~~~~~~~ - foo = someFunc(); -~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ - return foo; -~~~~~~~~~~~~~~~ -} -~ [0] - -// Does not consider ? as shorthand for undefined. - -type Text = string | null - -interface TextInterface { - foo?: Text -} - -interface SuperTextInterface { - bar?: Text | number -} - -function someFunc(foo?: Text, bar?: Text | number) {} - -// Ignores implicit union types. - -const x: SomeType; - -const someFunc = (): SomeType => {} - -function(foo: SomeInterface) {} - -const y = testFunc(); - -// Unless they are explicitly unioned. - -const z: Text | undefined; - ~~~~~~~~~~~~~~~~ [0] - -[0]: Union type cannot include both 'null' and 'undefined'. diff --git a/test/rules/no-null-undefined-union/ts350.ts.lint b/test/rules/no-null-undefined-union/ts350.ts.lint deleted file mode 100644 index a6a907edcd5..00000000000 --- a/test/rules/no-null-undefined-union/ts350.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -[typescript]: >= 3.5.0 - -type SomeType = - - | null - ~~~~~~ - | undefined -~~~~~~~~~~~~~~~ - | boolean; -~~~~~~~~~~~~~ [0] - -[0]: Union type cannot include both 'null' and 'undefined'. diff --git a/test/rules/no-null-undefined-union/tsconfig.json b/test/rules/no-null-undefined-union/tsconfig.json deleted file mode 100644 index d81c1202adb..00000000000 --- a/test/rules/no-null-undefined-union/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "downlevelIteration": true, - "experimentalDecorators": true, - "importHelpers": true, - "jsx": "react", - "lib": [ - "es5", - "es2015", - "es2016", - "es2017" - ], - "module": "commonjs", - "moduleResolution": "node", - "strict": true, - "stripInternal": true, - "target": "es5" - } -} diff --git a/test/rules/no-null-undefined-union/tslint.json b/test/rules/no-null-undefined-union/tslint.json deleted file mode 100644 index f41c08c7b72..00000000000 --- a/test/rules/no-null-undefined-union/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-null-undefined-union": true - } -} diff --git a/test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint b/test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint deleted file mode 100644 index ba5f37ee442..00000000000 --- a/test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ - ({}); -~~~~~~~~ [0] - -({}) as T; -~~~~~~~~~ [0] - - x; - -x as T; - -// Allow cast to 'any' -{} as any; - {}; - -// Allow cast to 'unknown' -{} as unknown; - {}; - -// Allow object literals to be asserted when used as arguments. -foo({} as T); -foo({}); - -[0]: Type assertion on object literals is forbidden, use a type annotation instead. diff --git a/test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json b/test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json deleted file mode 100644 index 6dad916f47d..00000000000 --- a/test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-object-literal-type-assertion": [true, { "allow-arguments": true }] - } -} diff --git a/test/rules/no-object-literal-type-assertion/default/test.ts.lint b/test/rules/no-object-literal-type-assertion/default/test.ts.lint deleted file mode 100644 index 53a555a4710..00000000000 --- a/test/rules/no-object-literal-type-assertion/default/test.ts.lint +++ /dev/null @@ -1,31 +0,0 @@ - ({}); -~~~~~~~~ [0] - -({}) as T; -~~~~~~~~~ [0] - - x; - -x as T; - -// Allow cast to 'any' -{} as any; - {}; - -// Allow cast to 'unknown' -{} as unknown; - {}; - -#if typescript >= 3.4.0 -// Allow const assertion -({}) as const; - ({}); -#endif - -foo({} as T); - ~~~~~~~ [0] - -foo({}); - ~~~~~ [0] - -[0]: Type assertion on object literals is forbidden, use a type annotation instead. diff --git a/test/rules/no-object-literal-type-assertion/default/tslint.json b/test/rules/no-object-literal-type-assertion/default/tslint.json deleted file mode 100644 index 98063421083..00000000000 --- a/test/rules/no-object-literal-type-assertion/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-object-literal-type-assertion": true - } -} diff --git a/test/rules/no-parameter-properties/test.ts.lint b/test/rules/no-parameter-properties/test.ts.lint deleted file mode 100644 index 49f957f1cad..00000000000 --- a/test/rules/no-parameter-properties/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -class Class1 { - // one error - constructor(private foo: string) { - ~~~~~~~ [err % ('foo')] - } -} - -class Class2 { - // three errors, last one is correct - // don't crash if name is not an identifier - constructor(private foo: string, public bar: string, qux: any, readonly {baz}: any) { - ~~~~~~~ [err % ('foo')] - ~~~~~~ [err % ('bar')] - ~~~~~~~~ [err % ('{baz}')] - } -} - -class Class3 { - // no errors - constructor() { - } -} - -[err]: Property '%s' cannot be declared in the constructor \ No newline at end of file diff --git a/test/rules/no-parameter-properties/tslint.json b/test/rules/no-parameter-properties/tslint.json deleted file mode 100644 index c65a294034b..00000000000 --- a/test/rules/no-parameter-properties/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-parameter-properties": true - } -} diff --git a/test/rules/no-parameter-reassignment/test.ts.lint b/test/rules/no-parameter-reassignment/test.ts.lint deleted file mode 100644 index 550ba46a186..00000000000 --- a/test/rules/no-parameter-reassignment/test.ts.lint +++ /dev/null @@ -1,34 +0,0 @@ -function f1(foo = "") {} - -function f2([foo = 0]: number[]) {} - -function f3(foo: number) { - foo; -} - -let noParam: number = 0; -noParam++; -noParam = 0; -let [alsoNoParam] = [0]; ---alsoNoParam; - -function f4(foo: number, {bar}: {bar: number}, baz: string) { - --noParam; - alsoNoParam += alsoNoParam; - foo += 1; - ~~~ [err % ('foo')] - foo++; - ~~~ [err % ('foo')] - --foo; - ~~~ [err % ('foo')] - foo += foo; - ~~~ [err % ('foo')] - ({foo} = {foo: 1}); - ~~~ [err % ('foo')] - for (bar of arr) {} - ~~~ [err % ('bar')] - for (baz in obj) {} - ~~~ [err % ('baz')] -} - -[err]: Reassigning parameter '%s' is forbidden. diff --git a/test/rules/no-parameter-reassignment/tslint.json b/test/rules/no-parameter-reassignment/tslint.json deleted file mode 100644 index f5b8846ea7d..00000000000 --- a/test/rules/no-parameter-reassignment/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-parameter-reassignment": true - } -} diff --git a/test/rules/no-promise-as-boolean/custom-promise/test.ts.lint b/test/rules/no-promise-as-boolean/custom-promise/test.ts.lint deleted file mode 100644 index 57a4b051488..00000000000 --- a/test/rules/no-promise-as-boolean/custom-promise/test.ts.lint +++ /dev/null @@ -1,37 +0,0 @@ -[typescript]: >= 2.4.0 - -async function promiseFunc() { - return false; -} - -class CustomPromise {} -const customPromise = new CustomPromise(); - -// Custom promise -if (customPromise) {} - ~~~~~~~~~~~~~ [0] - -normalExpression = customPromise; -const stringLiteral = "text" + customPromise; - -const globalUnaryExpression = !!customPromise; - ~~~~~~~~~~~~~ [0] - -const globalBinaryExpression = "text" && customPromise; - ~~~~~~~~~~~~~ [0] - -customPromise && console.log("topLevelBinaryExpression"); -~~~~~~~~~~~~~ [0] - -function union(promiseOrUndefined: CustomPromise | undefined, promiseOrFalse: CustomPromise | false, promiseOrNull: CustomPromise | null) { - if (promiseOrUndefined || promiseOrFalse || promiseOrNull) { - return; - } -} - -function normalUrCustomPromise(onlyPromise: CustomPromise | Promise, promiseOrNull: CustomPromise | Promise | null) { - if (onlyPromise && promiseOrNull) { } - ~~~~~~~~~~~ [0] -} - -[0]: Promises are not allowed as boolean. diff --git a/test/rules/no-promise-as-boolean/custom-promise/tsconfig.json b/test/rules/no-promise-as-boolean/custom-promise/tsconfig.json deleted file mode 100644 index f8f3eb52d44..00000000000 --- a/test/rules/no-promise-as-boolean/custom-promise/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "target": "es6" - } -} diff --git a/test/rules/no-promise-as-boolean/custom-promise/tslint.json b/test/rules/no-promise-as-boolean/custom-promise/tslint.json deleted file mode 100644 index 654b35ecb70..00000000000 --- a/test/rules/no-promise-as-boolean/custom-promise/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-promise-as-boolean": [true, { "promise-classes": ["CustomPromise"] }] - } -} diff --git a/test/rules/no-promise-as-boolean/es6-promise/test.ts.lint b/test/rules/no-promise-as-boolean/es6-promise/test.ts.lint deleted file mode 100644 index ba86acaed03..00000000000 --- a/test/rules/no-promise-as-boolean/es6-promise/test.ts.lint +++ /dev/null @@ -1,66 +0,0 @@ -[typescript]: >= 2.4.0 - -async function promiseFunc() { - return false; -} - -normalExpression = promiseFunc(); -const stringLiteral = "text" + promiseFunc(); - -const globalUnaryExpression = !!promiseFunc(); - ~~~~~~~~~~~~~ [0] - -const globalBinaryExpression = "text" && promiseFunc(); - ~~~~~~~~~~~~~ [0] - -promiseFunc() && console.log("topLevelBinaryExpression"); -~~~~~~~~~~~~~ [0] - -function union(promiseOrUndefined: Promise | undefined, promiseOrFalse: Promise | false, promiseOrNull: Promise | null) { - if (promiseOrUndefined || promiseOrFalse || promiseOrNull) { - return; - } -}; - -function funky(maybePromise?: Promise) { - while (promiseFunc() && maybePromise) { - ~~~~~~~~~~~~~ [0] - - const binaryExpression = (promiseFunc() && "1") || ("1" && !promiseFunc()) ? ("1" && promiseFunc() ? "1" : "1") : maybePromise; - ~~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~~ [0] - - // For-loop - for (let index = 0; promiseFunc(); index++) { - ~~~~~~~~~~~~~ [0] - - // a non-promise - if ("just some text" + promiseFunc()) { - - // Promise literal - } else if (new Promise(() => { })) { - ~~~~~~~~~~~~~~~~~~~~~~ [0] - - // Nested Promise - if (promiseFunc()) { - ~~~~~~~~~~~~~ [0] - } - - // Parenthesized Expression + Exclamation Tokens - } else if (promiseFunc() && !!promiseFunc()) { - ~~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~~ [0] - } - } - } -} - -async function waiter(custumerDecisionPromise: Promise) { - if (await custumerDecisionPromise) { - console.log("Customer ready to take an order.") - } -} - -[0]: Promises are not allowed as boolean. diff --git a/test/rules/no-promise-as-boolean/es6-promise/tsconfig.json b/test/rules/no-promise-as-boolean/es6-promise/tsconfig.json deleted file mode 100644 index f8f3eb52d44..00000000000 --- a/test/rules/no-promise-as-boolean/es6-promise/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "target": "es6" - } -} diff --git a/test/rules/no-promise-as-boolean/es6-promise/tslint.json b/test/rules/no-promise-as-boolean/es6-promise/tslint.json deleted file mode 100644 index 88591c2c285..00000000000 --- a/test/rules/no-promise-as-boolean/es6-promise/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-promise-as-boolean": true - } -} diff --git a/test/rules/no-redundant-jsdoc/test.ts.lint b/test/rules/no-redundant-jsdoc/test.ts.lint deleted file mode 100644 index 6711a859702..00000000000 --- a/test/rules/no-redundant-jsdoc/test.ts.lint +++ /dev/null @@ -1,59 +0,0 @@ -/** @typedef {number} T */ - ~~~~~~~ [tag % ('typedef')] - -/** @function - ~~~~~~~~ [tag % ('function')] - * @this - ~~~~ [tag % ('this')] - */ -function f() {} - -/** @type number */ - ~~~~ [tag % ('type')] -const x = 0; - -/** - * @class - ~~~~~ [tag % ('class')] - * @this {} - ~~~~ [tag % ('this')] - * @param {number} x Is a number - ~~~~~~~~ [type] - * @param y - ~~~~~ [param] - * @param {number} z - ~~~~~ [param] - ~~~~~~~~ [type] - * @returns {number} - ~~~~~~~ [returns] - ~~~~~~~~ [type] - */ -declare function g(x: number, y: number, z: number): number; - -/** - * @this {SomeClass} - ~~~~ [tag % ('this')] - */ -declare function h(); - -/** - * @author John Doe - * @param x Useful comment - * @returns Useful comment - */ -declare function i(x: number): number; - -/** - * @template T, U -#if typescript < 2.2.0 || >= 2.3.0 - ~~~~~~~~ [description % ('template')] -#endif - * @template V Some additional information - */ -declare function j(x: T, y: V): U; - -[tag]: JSDoc tag '@%s' is redundant in TypeScript code. -[type]: Type annotation in JSDoc is redundant in TypeScript code. -[description]: '@%s' is redundant in TypeScript code if it has no description. -[param]: description % ('param') -[returns]: description % ('returns') diff --git a/test/rules/no-redundant-jsdoc/tslint.json b/test/rules/no-redundant-jsdoc/tslint.json deleted file mode 100644 index b7cc878baac..00000000000 --- a/test/rules/no-redundant-jsdoc/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-redundant-jsdoc": true - } -} diff --git a/test/rules/no-reference-import/test.d.ts.lint b/test/rules/no-reference-import/test.d.ts.lint deleted file mode 100644 index ba9a8709347..00000000000 --- a/test/rules/no-reference-import/test.d.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -[typescript]: <2.4.0 -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [No need to reference "foo", since it is imported.] -/// -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [No need to reference "baz", since it is imported.] - -import * as foo from "foo"; - -declare module "quux" { - import * as baz from "baz"; -} diff --git a/test/rules/no-reference-import/ts240.d.ts.lint b/test/rules/no-reference-import/ts240.d.ts.lint deleted file mode 100644 index 56d2baf3e41..00000000000 --- a/test/rules/no-reference-import/ts240.d.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -[typescript]: >=2.4.0 -/// - ~~~ [No need to reference "foo", since it is imported.] -/// -/// - ~~~ [No need to reference "baz", since it is imported.] - -import * as foo from "foo"; - -declare module "quux" { - import * as baz from "baz"; -} diff --git a/test/rules/no-reference-import/tslint.json b/test/rules/no-reference-import/tslint.json deleted file mode 100644 index 4809ce73100..00000000000 --- a/test/rules/no-reference-import/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-reference-import": true - } -} diff --git a/test/rules/no-reference/test.ts.lint b/test/rules/no-reference/test.ts.lint deleted file mode 100644 index cb833f0f9be..00000000000 --- a/test/rules/no-reference/test.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -[typescript]: <2.4.0 -/// -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ is not allowed, use imports] diff --git a/test/rules/no-reference/ts240.ts.lint b/test/rules/no-reference/ts240.ts.lint deleted file mode 100644 index 4806cef6f23..00000000000 --- a/test/rules/no-reference/ts240.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -[typescript]: >=2.4.0 -/// - ~~~~~~~~~~~~ [ is not allowed, use imports] diff --git a/test/rules/no-reference/tslint.json b/test/rules/no-reference/tslint.json deleted file mode 100644 index 6a925a49578..00000000000 --- a/test/rules/no-reference/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-reference": true - } -} diff --git a/test/rules/no-require-imports/test.ts.lint b/test/rules/no-require-imports/test.ts.lint deleted file mode 100644 index b54741ed2b8..00000000000 --- a/test/rules/no-require-imports/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -var lib = require('lib'); // failure - ~~~~~~~~~~~~~~ [no-require] - -let lib2 = require('lib2'); // failure - ~~~~~~~~~~~~~~~ [no-require] - -import {l} from 'lib'; - -var lib3 = load('not_an_import'); - -var lib4 = lib2.subImport; - -var lib5 = require('lib5'), // failure - ~~~~~~~~~~~~~~~ [no-require] - lib6 = require('lib6'), // failure - ~~~~~~~~~~~~~~~ [no-require] - lib7 = 700; - -import lib8 = require('lib8'); // failure - ~~~~~~~~~~~~~~~ [no-require] - -import lib9 = lib2.anotherSubImport; - -[no-require]: require() style import is forbidden diff --git a/test/rules/no-require-imports/tslint.json b/test/rules/no-require-imports/tslint.json deleted file mode 100644 index 39bc26f8312..00000000000 --- a/test/rules/no-require-imports/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-require-imports": true - } -} diff --git a/test/rules/no-restricted-globals/custom-global.d.ts b/test/rules/no-restricted-globals/custom-global.d.ts deleted file mode 100644 index e981c8a88cf..00000000000 --- a/test/rules/no-restricted-globals/custom-global.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare var badGlobal: any; -declare var goodGlobal: any; \ No newline at end of file diff --git a/test/rules/no-restricted-globals/foo.d.ts b/test/rules/no-restricted-globals/foo.d.ts deleted file mode 100644 index 30f811d837f..00000000000 --- a/test/rules/no-restricted-globals/foo.d.ts +++ /dev/null @@ -1 +0,0 @@ -export var name: string; \ No newline at end of file diff --git a/test/rules/no-restricted-globals/namespace.ts.lint b/test/rules/no-restricted-globals/namespace.ts.lint deleted file mode 100644 index 5fe8939d5c6..00000000000 --- a/test/rules/no-restricted-globals/namespace.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -console.log(name); - ~~~~ [Unexpected global variable 'name'. Use a local parameter or variable instead.] - -namespace A { - const foo = name; -} - -namespace A { - export var name = 23; -} \ No newline at end of file diff --git a/test/rules/no-restricted-globals/test.ts.lint b/test/rules/no-restricted-globals/test.ts.lint deleted file mode 100644 index 2fb6b4c5521..00000000000 --- a/test/rules/no-restricted-globals/test.ts.lint +++ /dev/null @@ -1,75 +0,0 @@ -function foo(evt: Event) { - let length: number = 1; - console.log(length); - - Event.target; - - event.target; - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] -} - -console.log(length); - ~~~~~~ [Unexpected global variable 'length'. Use a local parameter or variable instead.] - -import { name } from "./foo"; -import "./custom-global" -console.log(name); - -console.log(badGlobal); - ~~~~~~~~~ [Unexpected global variable 'badGlobal'. Use a local parameter or variable instead.] - -console.log(goodGlobal); - -let { foo = event } = bar - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] - -let { foo = (() => event)() } = bar; - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] - -let foo: typeof event; - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] - -function rest() { - const { bar, ...event } = foo; -} - -function nested() { - const { bar, event: { x: y } } = foo; -} - -function initializer() { - const { bar, length = () => event } = foo; - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] -} - -function nestedInitializer() { - const { bar, length: { x: y = () => event } } = foo; - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] -} - -function computedProperty() { - const { [event.type]: x } = foo; - ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] -} - -function typeTest() { - type name = any; -} - -function functionTest () { - const foo = name; - - function name () { - - } -} - -function interfaceTest() { - var foo: name; - interface name {} -} - -function classTest() { - const foo = new name(); - class name {} -} \ No newline at end of file diff --git a/test/rules/no-restricted-globals/tsconfig.json b/test/rules/no-restricted-globals/tsconfig.json deleted file mode 100644 index 3039d056863..00000000000 --- a/test/rules/no-restricted-globals/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "dom" - ] - } -} diff --git a/test/rules/no-restricted-globals/tslint.json b/test/rules/no-restricted-globals/tslint.json deleted file mode 100644 index 4c2950318f4..00000000000 --- a/test/rules/no-restricted-globals/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "no-restricted-globals": [ - true, - "name", - "length", - "event", - "badGlobal" - ] - } -} diff --git a/test/rules/no-return-await/test.ts.fix b/test/rules/no-return-await/test.ts.fix deleted file mode 100644 index 23b56babfaa..00000000000 --- a/test/rules/no-return-await/test.ts.fix +++ /dev/null @@ -1,80 +0,0 @@ -async function foo() { - return x; -} -(async () => x); - -async function allowTypeAssertion() { - return (await x)!; - return (await x as number); - return await x; -} -async function allowedInsideTryCatch() { - try { - return await x; - } catch (e) { - // handle error - return x; // not allowed in catch when there is no finally - } -} -async function allowedInsideTryFinally() { - try { - return await x; - } finally { - // do cleanup, close connection for example - return x; // not allowed in finally at all - } -} -async function allowedInsideCatchFinally() { - try { - return await x; - } catch (e) { - return await x; - } finally { - return x; - } -} -async function nestedTryStatements() { - try { - try { - return await x; - } catch (e) { - return await x; - } finally { - return await foobar; - } - } catch(e) { - try { - return await x; - } catch (e) { - return await x; - } finally { - return await foobar; - } - } finally { - try { - return await x; - } catch (e) { - return await x; - } finally { - return x; - } - } -} - -async function handleParens() { - return (x); -} -async function handleBinaryExpression() { - return await foo || x; - return await foo && x; - return await foo, x; - return await foo + await bar; -} -async function handleConditionalExpression() { - return await foo ? bar : baz; -} - -throw await x; -await x; -return x; - diff --git a/test/rules/no-return-await/test.ts.lint b/test/rules/no-return-await/test.ts.lint deleted file mode 100644 index 57fac556b11..00000000000 --- a/test/rules/no-return-await/test.ts.lint +++ /dev/null @@ -1,94 +0,0 @@ -async function foo() { - return await x; - ~~~~~ [0] -} -(async () => await x); - ~~~~~ [0] - -async function allowTypeAssertion() { - return (await x)!; - return (await x as number); - return await x; -} -async function allowedInsideTryCatch() { - try { - return await x; - } catch (e) { - // handle error - return await x; // not allowed in catch when there is no finally - ~~~~~ [0] - } -} -async function allowedInsideTryFinally() { - try { - return await x; - } finally { - // do cleanup, close connection for example - return await x; // not allowed in finally at all - ~~~~~ [0] - } -} -async function allowedInsideCatchFinally() { - try { - return await x; - } catch (e) { - return await x; - } finally { - return await x; - ~~~~~ [0] - } -} -async function nestedTryStatements() { - try { - try { - return await x; - } catch (e) { - return await x; - } finally { - return await foobar; - } - } catch(e) { - try { - return await x; - } catch (e) { - return await x; - } finally { - return await foobar; - } - } finally { - try { - return await x; - } catch (e) { - return await x; - } finally { - return await x; - ~~~~~ [0] - } - } -} - -async function handleParens() { - return (await x); - ~~~~~ [0] -} -async function handleBinaryExpression() { - return await foo || await x; - ~~~~~ [0] - return await foo && await x; - ~~~~~ [0] - return await foo, await x; - ~~~~~ [0] - return await foo + await bar; -} -async function handleConditionalExpression() { - return await foo ? await bar : await baz; - ~~~~~ [0] - ~~~~~ [0] -} - -throw await x; -await x; -return await x; - ~~~~~ [0] - -[0]: Unnecessary 'await'. diff --git a/test/rules/no-return-await/tslint.json b/test/rules/no-return-await/tslint.json deleted file mode 100644 index 56764d25ff0..00000000000 --- a/test/rules/no-return-await/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-return-await": true - } -} diff --git a/test/rules/no-shadowed-variable/default/ambient.d.ts.lint b/test/rules/no-shadowed-variable/default/ambient.d.ts.lint deleted file mode 100644 index a629aba6c7e..00000000000 --- a/test/rules/no-shadowed-variable/default/ambient.d.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -// no errors in declaration files -declare type T = any; -declare class C {} -declare namespace ns { - type T = C; - class C {} -} diff --git a/test/rules/no-shadowed-variable/default/test.ts.lint b/test/rules/no-shadowed-variable/default/test.ts.lint deleted file mode 100644 index b7d372cd6d8..00000000000 --- a/test/rules/no-shadowed-variable/default/test.ts.lint +++ /dev/null @@ -1,384 +0,0 @@ -import { Foo } from './foo'; -import * as Bar from '.bar'; -import Baz from './baz'; -import Bas = require('./bas'); -import _ = require('lodash'); -{ - const Foo = 'bar'; - ~~~ [err % ('Foo')] - const Bar = Foo; - ~~~ [err % ('Bar')] - const Baz = Bar; - ~~~ [err % ('Baz')] - const Bas = Baz; - ~~~ [err % ('Bas')] - const _ = _; - ~ [err % ('_')] -} -function letTesting() { - var a = 1; - ~ [err % ('a')] - let b = 1; - - if (true) { - let a = 2; // failure - ~ [err % ('a')] - let b = 2; // failure - ~ [err % ('b')] - let c = 2; - var e = 2; - } else { - let b = 3; // failure - ~ [err % ('b')] - let c = 3; - let e = 3; // failure - ~ [err % ('e')] - let f = 3; - ~ [err % ('f')] - } - - var f = 4; - ~ [err % ('f')] -} - -let a = 1; -if (true) { - let a = 2; // failure - ~ [err % ('a')] -} - -var g = 1; -for (var index in [0, 1, 2]) { - let g = 2; // failure - ~ [err % ('g')] -} - -function constTesting() { - var h = 1; - const i = 1; - - if (true) { - const h = 2; // failure - ~ [err % ('h')] - const i = 2; // failure - ~ [err % ('i')] - } -} - -function testArguments(x: number, y: number): void { - var x = 1; // failure - let y = 2; // tsc error -} - -let j = 1; -for (var index in [0, 1, 2]) { - let j = 2; // failure - ~ [err % ('j')] -} - -function testTryStatement() { - try { - let foo = 1; - throw new Error(); - } catch (e) { - let foo = 2; - var bar = 2; - } finally { - let foo = 3; - let bar = 3; // failure - ~~~ [err % ('bar')] - } -} - -function testWhileStatement() { - let foo = 1; - - while (true) { - let foo = 2; // failure - ~~~ [err % ('foo')] - } -} - -function testDoStatement() { - let foo = 1; - - do { - let foo = 2; // failure - ~~~ [err % ('foo')] - } while (true); -} - -function testDestructuring(x: number) { - var {y, z} = {y: 2, z: 3}; - - function myFunc() { - return [1]; - } - - function innerFunc() { - var [foo] = myFunc(); - var [x] = myFunc(); // failure - ~ [err % ('x')] - let [y] = myFunc(); // failure - ~ [err % ('y')] - const [z] = myFunc(); // failure - ~ [err % ('z')] - } - - function anotherInnerFunc() { - var [{x}] = [{x: 1}]; // failure - ~ [err % ('x')] - let [[y]] = [[2]]; // failure - ~ [err % ('y')] - var [foo, ...bar] = [1, 2, 3, 4]; - var [...z] = [1, 2, 3, 4]; // failure - ~ [err % ('z')] - } -} - -function falsePositive1(bar: (okay1: any) => void) { - let okay1 = 1; -} - -function falsePositive2(okay2: any, done: (okay2: any) => void) { } - -interface FalsePositive3 { - diffuse: (pos: number) => number; - specular: (pos: number) => number; - pos: number; -} - -interface FalsePositive4 { - (parameters: T, runSynchonous: boolean): TResult; - (parameters: T, callback: (error: Error, result: TResult) => void): void; -} - -let p = 1; -function testParameterDestructuring( - { pos: p }: FalsePositive3, // failure - ~ [err % ('p')] - { pos: q, specular: r }: FalsePositive3, - { pos }: FalsePositive3 -) { - p = 2; - var q = 1; // merges with parameter, should use no-duplicate-variable to catch this - - function someInnerFunc() { - let pos = 3; // failure - ~~~ [err % ('pos')] - } -} - - -{ - const simpleBlockVar = 3 -} - -function testSimpleBlockVar() { - const simpleBlockVar = 4 -} - -interface SeparateIndexeSighatures1 { - [separate: string]: any; -} -interface SeparateIndexeSighatures2 { - [separate: number]: any; -} - -const external = 1; -interface ExternalIndexSignature1 { - [external: string]: any; -} -interface ExternalIndexSignature2 { - [external: number]: any; -} - -interface CombinedIndexeSighatures { - [i: string]: any; - [i: number]: any; -} - -function constructorsWithArgs( - derivedCtor: new (...args: any[]) => any, - baseCtors: Array any>): void { - // ... -} - -function constructorsWithArgsConst( - derivedCtor: new (...args: any[]) => any, - baseCtors: Array any>): void { - const args = []; -} - -function constructorsWithArgsParamConst( - derivedCtor: new (...args: any[]) => any, - baseCtors: Array any>, - args: any[]): void { - { - const args = []; - ~~~~ [err % ('args')] - } -} - -class MyClass { }; - -declare type MyConstructor = new (myVariable: any) => MyClass; -declare type MyFunction = (myParameter: any) => boolean; - -function creatorFunction(constructor: MyConstructor, filter: MyFunction): void { - const myVariable = 1; - const myParameter = 1; - console.log(myVariable); -} - -for (let i = 0; i < 3; i++) { - let i = 34; - ~ [err % ('i')] -} - -(function f1() { - let f1; - ~~ [err % ('f1')] -})(); -function f2() { - const f2 = 0; - ~~ [err % ('f2')] -} -(function f3() { - var f3; - ~~ [err % ('f3')] -})(); -(function f4(f4) { - ~~ [err % ('f4')] -})(); -let f5; -(function f5(){})() - ~~ [err % ('f5')] - -class C { - ~ [err % ('C')] - C(C: C): C { - ~ [err % ('C')] - ~ [err % ('C')] - type C = C; - ~ [err % ('C')] - namespace C { - ~ [err % ('C')] - interface C {} - ~ [err % ('C')] - ~ [err % ('C')] - } - } -} - -// allow nested namespaces -namespace ns.C {} -namespace ns { - export namespace C {} - ~ [err % ('C')] -} -namespace ns { - namespace C {} - ~ [err % ('C')] -} - -type Mapped = { - [K in T]: K - ~ [err % ('K')] -} - -// Allow parameters in signatures -{ - let param; - class TestClass { - myMethod(param): void; - myMethod(): void; - myMethod(param): void {} - ~~~~~ [err % ('param')] - } - interface TestInterface { - (param): void; - myMethod(param): void - myMethod(): void; - ~~~~~ [err % ('param')] - } -} - -// Handle variables in multiple child scopes -{ - { - { - let test; - ~~~~ [err % ('test')] - } - let test; - ~~~~ [err % ('test')] - { - let test; - ~~~~ [err % ('test')] - } - } - { - let test; - ~~~~ [err % ('test')] - } - let test; -} - -// Allow mergeable declarations. -interface I {} -interface I {} - -// Exempt 'this' -function f(this): void { - function inner(this): void {} -} - -@decorator((param) => param) -function funxion(param) {} - -class Clazz { - static method() {} - static prop = () => {} - method() {} - ~ [err % ('T')] - prop = () => {} - ~ [err % ('T')] - constructor() { - class Inner { - ~ [err % ('T')] - static method() {} - ~ [err % ('T')] - static prop = () => {} - ~ [err % ('T')] - } - } -} - -export default function ( - paramA = function() {let paramB}, - ~~~~~~ [err % ('paramB')] - paramB, -) {} - -// allow IndexSignature names -function baz(param: {[baz: string]: string}) {} - -// no error INSIDE ambient namespaces and module -declare global { - function baz(): void; -} -declare module "foo" { - class Clazz {} -} -declare namespace MyNamespaceName { - interface I {} -} - -{ - let MyNamespaceName; // still check names of declare namespace - ~~~~~~~~~~~~~~~ [err % ('MyNamespaceName')] - let global; // don't treat `declare global` as variable -} - -[err]: Shadowed name: '%s' diff --git a/test/rules/no-shadowed-variable/default/tslint.json b/test/rules/no-shadowed-variable/default/tslint.json deleted file mode 100644 index f9d0b34237a..00000000000 --- a/test/rules/no-shadowed-variable/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-shadowed-variable": true - } -} diff --git a/test/rules/no-shadowed-variable/ignore-class/test.ts.lint b/test/rules/no-shadowed-variable/ignore-class/test.ts.lint deleted file mode 100644 index 7fa3dadeb35..00000000000 --- a/test/rules/no-shadowed-variable/ignore-class/test.ts.lint +++ /dev/null @@ -1,16 +0,0 @@ -class C { - constructor() { - var C; - var D; - ~ [Shadowed name: 'D'] - { - class C { - constructor() { - var C; - ~ [Shadowed name: 'C'] - } - } - } - } -} -interface D {} diff --git a/test/rules/no-shadowed-variable/ignore-class/tslint.json b/test/rules/no-shadowed-variable/ignore-class/tslint.json deleted file mode 100644 index 8e16e7b3ca6..00000000000 --- a/test/rules/no-shadowed-variable/ignore-class/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-shadowed-variable": [true, {"class": false}] - } -} diff --git a/test/rules/no-shadowed-variable/ignore-import/test.ts.lint b/test/rules/no-shadowed-variable/ignore-import/test.ts.lint deleted file mode 100644 index c2f713c6fa5..00000000000 --- a/test/rules/no-shadowed-variable/ignore-import/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -import {diff} from "diff"; -import clear from "storage-helper"; - -diff(original, current).forEach((diff) => { - console.log(diff); -}); - -{ - (function clear() { - let clear = true; - ~~~~~ [Shadowed name: 'clear'] - })(); -} diff --git a/test/rules/no-shadowed-variable/ignore-import/tslint.json b/test/rules/no-shadowed-variable/ignore-import/tslint.json deleted file mode 100644 index 2fac839865b..00000000000 --- a/test/rules/no-shadowed-variable/ignore-import/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-shadowed-variable": [true, {"import": false}] - } -} diff --git a/test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint b/test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint deleted file mode 100644 index 4e1fa88763d..00000000000 --- a/test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -import _ = require('lodash'); - -function foo(_) { - console.log(_); -} - -function foo(_1, _2) { - // Allow shadowing of multiple unused parameters - [].map((_1, _2) => undefined); -} diff --git a/test/rules/no-shadowed-variable/ignore-underscore/tslint.json b/test/rules/no-shadowed-variable/ignore-underscore/tslint.json deleted file mode 100644 index ed40897ba47..00000000000 --- a/test/rules/no-shadowed-variable/ignore-underscore/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-shadowed-variable": [true, {"underscore": false}] - } - } diff --git a/test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint b/test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint deleted file mode 100644 index 06798ae55fe..00000000000 --- a/test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint +++ /dev/null @@ -1,89 +0,0 @@ -['a', 'b', 'c'].map((path) => path.resolve(path)) - ~~~~ [err % ('path')] - -import * as path from 'path' - -export function foo(wam: boolean) { - if (wam) { - const now = new Date(); // no error because it's in the temporal dead zone of the outer `now` - return now.getTime(); - } - - const now = new Date(); - return now.getTime() + 1000; -} - -function foo(v) { - if (v) { - const Foo = null; // classes are block scoped, therefore no error in the temporal dead zone - return Foo; - } - class Foo {} - return new Foo(); -} - -function foo(v) { - if (v) { - const Foo = null; // interfaces are block scoped, but hoisted -> error in temporal dead zone - ~~~ [err % ('Foo')] - return Foo; - } - interface Foo {} - class Foo {} - return new Foo(); -} - -function foo() { - { - let tmp = 1; // error because `var` is hoisted - ~~~ [err % ('tmp')] - return tmp; - } - var tmp = undefined; - return tmp; -} - -function foo(v) { - let tmp = 1; - if (v) { - const tmp = v; - ~~~ [err % ('tmp')] - return v; - } else { - const v = tmp; - ~ [err % ('v')] - return v; - } -} - -// parameters also have a temporal dead zone -function foo( - a = function() {let b}, - b, -) {} - -{ - { - class Foo {} // tdz - } - enum Foo {} // tdz - { - class Foo {} // shadowing enum Foo - ~~~ [err % ('Foo')] - } -} -class Foo {} -{ - { - class Foo {} - ~~~ [err % ('Foo')] - } - enum Foo {} - ~~~ [err % ('Foo')] - { - class Foo {} - ~~~ [err % ('Foo')] - } -} - -[err]: Shadowed name: '%s' diff --git a/test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json b/test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json deleted file mode 100644 index a5685425fc5..00000000000 --- a/test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "no-shadowed-variable": [ - true, - { - "temporalDeadZone": false - } - ] - } -} diff --git a/test/rules/no-sparse-arrays/test.ts.lint b/test/rules/no-sparse-arrays/test.ts.lint deleted file mode 100644 index 3a777dbd0a6..00000000000 --- a/test/rules/no-sparse-arrays/test.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -[1, , 3]; - ~ [0] - -// Destructuring allowed. -const [foo, , bar] = []; -const [{foo: [, bar]}] = []; -const [foo = [, 1]] = []; - ~ [0] - -[foo, , (bar)] = []; -[{foo: [, bar]}] = []; -[foo = [, 1]] = []; - ~ [0] -[foo = bar([,])] = []; - ~ [0] - -[1,,]; - ~ [0] - -[1,,,]; - ~ [0] - ~ [0] - -[0]: Array has a missing element. diff --git a/test/rules/no-sparse-arrays/tslint.json b/test/rules/no-sparse-arrays/tslint.json deleted file mode 100644 index e3be109d241..00000000000 --- a/test/rules/no-sparse-arrays/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-sparse-arrays": true - } -} diff --git a/test/rules/no-string-literal/test.ts.fix b/test/rules/no-string-literal/test.ts.fix deleted file mode 100644 index ad0703fba31..00000000000 --- a/test/rules/no-string-literal/test.ts.fix +++ /dev/null @@ -1,29 +0,0 @@ -var obj = { - a: 1, - b: 2, - c: 3, - d: 4 -}; - -function test() { - var a = obj.a; - var b = obj.bcd; - var c = obj.c; - var d = obj[b]; -} - -obj.invalid_accessor; -obj._AnotherInvalidAccessor; -obj.a; // unicode value "a" - -// valid accessors -obj["a-2"]; -obj["2a"]; -obj["?a#$!$^&%&"]; - -// invalid accessor - no crash -obj[] - -// that underscrore escaping thing typescript does -obj.__foo__; - diff --git a/test/rules/no-string-literal/test.ts.lint b/test/rules/no-string-literal/test.ts.lint deleted file mode 100644 index 00c61285f4c..00000000000 --- a/test/rules/no-string-literal/test.ts.lint +++ /dev/null @@ -1,36 +0,0 @@ -var obj = { - a: 1, - b: 2, - c: 3, - d: 4 -}; - -function test() { - var a = obj.a; - var b = obj[ 'bcd' ]; - ~~~~~ [0] - var c = obj["c"]; - ~~~ [0] - var d = obj[b]; -} - -obj["invalid_accessor"]; - ~~~~~~~~~~~~~~~~~~ [0] -obj["_AnotherInvalidAccessor"]; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -obj["\u0061"]; // unicode value "a" - ~~~~~~~~ [0] - -// valid accessors -obj["a-2"]; -obj["2a"]; -obj["?a#$!$^&%&"]; - -// invalid accessor - no crash -obj[] - -// that underscrore escaping thing typescript does -obj['__foo__']; - ~~~~~~~~~ [0] - -[0]: object access via string literals is disallowed diff --git a/test/rules/no-string-literal/tslint.json b/test/rules/no-string-literal/tslint.json deleted file mode 100644 index ade4197c3d3..00000000000 --- a/test/rules/no-string-literal/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-string-literal": true - } -} diff --git a/test/rules/no-string-throw/test.ts.fix b/test/rules/no-string-throw/test.ts.fix deleted file mode 100644 index 92fc925fa7b..00000000000 --- a/test/rules/no-string-throw/test.ts.fix +++ /dev/null @@ -1,30 +0,0 @@ -let a: never = () => throw new Error('bla'); - -let b: never = () => throw new Error('bla'); - -let c: never = () => throw new Error('string1' + 'string2' + 'string3'); - -let d: never = () => throw new Error('string' + 1); - -let e: never = () => throw new Error('string1' + 1 + {}); - -let f: never = () => throw new Error(('string')); - -let g: never = () => throw new Error(1 + 2 + ('string')); - -// no warning because rule does not check for toString() -const one = 1; -let h: never = () => throw one.toString(); - -let i: never = () => throw new Error(`some template string`); - -const someVariable = 123; -let j: never = () => throw new Error(`template with ${someVariable} string`); - -throw new Error(('component requires CSS height property')); - -throw new Error('component...') - -throw new Error((('component...'))) - -throw/**/new Error('component') diff --git a/test/rules/no-string-throw/test.ts.lint b/test/rules/no-string-throw/test.ts.lint deleted file mode 100644 index 788fb9af842..00000000000 --- a/test/rules/no-string-throw/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -let a: never = () => throw 'bla'; - ~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -let b: never = () => throw new Error('bla'); - -let c: never = () => throw 'string1' + 'string2' + 'string3'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -let d: never = () => throw 'string' + 1; - ~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -let e: never = () => throw 'string1' + 1 + {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -let f: never = () => throw ('string'); - ~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -let g: never = () => throw 1 + 2 + ('string'); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -// no warning because rule does not check for toString() -const one = 1; -let h: never = () => throw one.toString(); - -let i: never = () => throw `some template string`; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -const someVariable = 123; -let j: never = () => throw `template with ${someVariable} string`; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -throw('component requires CSS height property'); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -throw'component...' -~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -throw(('component...')) -~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] - -throw/**/'component' -~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] diff --git a/test/rules/no-string-throw/tslint.json b/test/rules/no-string-throw/tslint.json deleted file mode 100644 index dc5dabddab0..00000000000 --- a/test/rules/no-string-throw/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-string-throw": true - } -} \ No newline at end of file diff --git a/test/rules/no-submodule-imports/dynamic-imports/test.ts.lint b/test/rules/no-submodule-imports/dynamic-imports/test.ts.lint deleted file mode 100644 index 46a66fd6e5a..00000000000 --- a/test/rules/no-submodule-imports/dynamic-imports/test.ts.lint +++ /dev/null @@ -1,28 +0,0 @@ -[typescript]: >=2.4.0 - -const dynamicImport = import("lodash"); - -const dynamicImport = import("lodash/sub-module"); - ~~~~~~~~~~~~~~~~~~~ [0] - -const dynamicImport = import("lodash/a/b/c/sub-module"); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - -const dynamicImport = import("@blueprintjs/core"); - -const dynamicImport = import("@blueprintjs/core/sub-module"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const dynamicImport = import("@blueprintjs/core/a/b/c/sub-module"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const dynamicImport = import("rxjs"); -const dynamicImport = import("rxjs/sub-module"); -const dynamicImport = import("@angular/core"); -const dynamicImport = import("@angular/core/forms/directives"); - -const dynamicImport = import("./myModule"); -const dynamicImport = import("./myModule/a/b/c/sub-module"); - -[0]: Submodule import paths from this package are disallowed; import from the root instead \ No newline at end of file diff --git a/test/rules/no-submodule-imports/dynamic-imports/tslint.json b/test/rules/no-submodule-imports/dynamic-imports/tslint.json deleted file mode 100644 index 61983d2a471..00000000000 --- a/test/rules/no-submodule-imports/dynamic-imports/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-submodule-imports": [true, "@angular/core", "rxjs"] - } -} \ No newline at end of file diff --git a/test/rules/no-submodule-imports/static-imports/test.ts.lint b/test/rules/no-submodule-imports/static-imports/test.ts.lint deleted file mode 100644 index 75ddc078a89..00000000000 --- a/test/rules/no-submodule-imports/static-imports/test.ts.lint +++ /dev/null @@ -1,73 +0,0 @@ -import { submodule } from "@blueprintjs/core"; - -import { submodule } from "@blueprintjs/core/sub-module"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import submodule = require("@blueprintjs/core"); - -import submodule = require("@blueprintjs/core/sub-module"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import { submodule } from "@blueprintjs/core"; - -import { submodule } from "@blueprintjs/core/a/b/c/sub-module"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import submodule = require("@blueprintjs/core"); - -import submodule = require("@blueprintjs/core/a/b/c/sub-module"); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import { submodule } from "@angular/core"; -import { submodule } from "@angular/core/sub-module"; -import submodule = require("@angular/core"); -import submodule = require("@angular/core/sub-module"); -import { submodule } from "@angular/core"; -import { submodule } from "@angular/core/a/b/c/sub-module"; -import submodule = require("@angular/core"); -import submodule = require("@angular/core/a/b/c/sub-module"); - -import { submodule } from "@angular/platform-browser"; -import { submodule } from "@angular/platform-browser/animations"; -import { submodule } from "@angular/platform-browser/animations/foo"; -import { submodule } from "@angular/platform-browser/bar"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import { submodule } from "lodash"; - -import { submodule } from "lodash/sub-module"; - ~~~~~~~~~~~~~~~~~~~ [0] - -import submodule = require("lodash"); - -import submodule = require("lodash/sub-module"); - ~~~~~~~~~~~~~~~~~~~ [0] - -import { submodule } from "lodash"; - -import { submodule } from "lodash/a/b/c/sub-module"; - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import submodule = require("lodash"); - -import submodule = require("lodash/a/b/c/sub-module"); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -import { submodule } from "rxjs"; -import { submodule } from "rxjs/sub-module"; -import submodule = require("rxjs"); -import submodule = require("rxjs/sub-module"); -import { submodule } from "rxjs"; -import { submodule } from "rxjs/a/b/c/sub-module"; -import submodule = require("rxjs"); -import submodule = require("rxjs/a/b/c/sub-module"); - -import { submodule } from "./../node_modules/package"; -import { submodule } from "../myModule/a/package"; -import submodule = require("./../node_modules/package"); -import submodule = require("../myModule/a/package"); - -export * from "@angular/http/testing"; - ~~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: Submodule import paths from this package are disallowed; import from the root instead diff --git a/test/rules/no-submodule-imports/static-imports/tslint.json b/test/rules/no-submodule-imports/static-imports/tslint.json deleted file mode 100644 index 5a36dc800f1..00000000000 --- a/test/rules/no-submodule-imports/static-imports/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-submodule-imports": [true, "@angular/core", "rxjs", "@angular/platform-browser/animations"] - } -} diff --git a/test/rules/no-switch-case-fall-through/test.ts.lint b/test/rules/no-switch-case-fall-through/test.ts.lint deleted file mode 100644 index 1b0a1511e2a..00000000000 --- a/test/rules/no-switch-case-fall-through/test.ts.lint +++ /dev/null @@ -1,144 +0,0 @@ -switch (foo) { - case 1: - bar(); - case 2: - ~~~~ [expected a 'break' before 'case'] - bar(); - bar(); - case 3: - ~~~~ [expected a 'break' before 'case'] - case 4: - default: - break; -} - - -switch (foo) { - case 1: - bar(); - case 2: - ~~~~ [expected a 'break' before 'case'] - bar(); -} - - -switch (foo) { - case 1: - case 2: - default: - bar(); -} - -switch (foo) { - case 1: - switch (bar) { - case "": - default: - break; - } - case 2: - ~~~~ [expected a 'break' before 'case'] -} - -switch (foo) { - case 1: - case 2: - - case 3: - - case 4: - break; - default: - bar(); -} - - -switch (foo) { - case 1: - return; // handle return the same as break - case 2: - case 3: - throw "error"; -} - -switch (foo) { - case 1: - bar(); - /* falls through */ - case 2: - bar(); - /* Testing */ - /* falls through */ - default: - bar(); - // falls through - case 3: - break; -} - -// valid -switch (foo) { - case 1: - break; - case 2: - case 3: - break; - default: -} - -// recognise blocks -switch (foo) { - case 1: { - break; - } - case 2: -} - -// recognise if-else -switch (foo) { - case 1: - if (bar) { - break; - } else { - return; - } - case 2: - if (bar) { - break; - } - case 3: - ~~~~ [expected a 'break' before 'case'] -} - -// allow throw -switch (foo) { - case 1: - throw bar; - case 2: -} - -// handle nested switch statements -switch (foo) { - case 1: - switch (bar) { - case 1: - foobar(); // this case clause falls through and returns in the default clause - default: - ~~~~~~~ [expected a 'break' before 'default'] - return; - } - case 2: -} - -switch (foo) { - case 1: - foo; - // Falls through - case 2: - foo; - // Falls through. - case 3: - foo; - // Falls through -- for reasons - default: -} diff --git a/test/rules/no-switch-case-fall-through/tslint.json b/test/rules/no-switch-case-fall-through/tslint.json deleted file mode 100644 index 31c7fba4e6e..00000000000 --- a/test/rules/no-switch-case-fall-through/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-switch-case-fall-through": true - } -} diff --git a/test/rules/no-tautology-expression/test.ts.lint b/test/rules/no-tautology-expression/test.ts.lint deleted file mode 100644 index 09a5057a7cf..00000000000 --- a/test/rules/no-tautology-expression/test.ts.lint +++ /dev/null @@ -1,159 +0,0 @@ - -const expr = "someStr" === "someStr"; - ~~~~~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] -const expr = 123 === 123; - ~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] -const someVar = 100; -const expr = someVar === someVar; - ~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - -const someFunc = () => { - if ("SomeStr" === "SomeStr") { - ~~~~~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (100 === 100) { - ~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - let someVar = 100; - if (someVar === someVar) { - ~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (1 !== 1) { - ~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (1 > 1) { - ~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - const someVar = 123; - if (someVar < someVar) { - ~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if ("str" == "str") { - ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (123 != 123) { - ~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if ("str" <= "str") { - ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if ("str" >= "str") { - ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - const someVar = true; - if (someVar || someVar) { - ~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - const someVar = true; - if (someVar && someVar) { - ~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - const someObj = { "name" : "moses the great" }; - if (someObj.name === someObj.name) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - const someObj = { "name" : "moses the great", "address" : "king's road 10" }; - if (someObj.name === someObj.address) { - return true; - } -} - -const someFunc = () => { - const objOne = { "name" : "moses the great" }; - const objTwo = { "name" : "moses the great" }; - if (objOne.name === objTwo.name) { - return true; - } -} - -const someFunc = () => { - if (true === true) { - ~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (false === false) { - ~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (true === false) { - ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (null === null) { - ~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] - return true; - } -} - -const someFunc = () => { - if (null === false) { - return true; - } -} - -const someVar1 = 3 + 3; -const someVar2 = 3 - 3; -const someVar3 = 3 * 3; -const someVar4 = 3 % 3; -const someVar5 = 3 / 3; diff --git a/test/rules/no-tautology-expression/tslint.json b/test/rules/no-tautology-expression/tslint.json deleted file mode 100644 index 82111395df2..00000000000 --- a/test/rules/no-tautology-expression/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-tautology-expression": true - } -} diff --git a/test/rules/no-this-assignment/allow-destructuring/test.ts.lint b/test/rules/no-this-assignment/allow-destructuring/test.ts.lint deleted file mode 100644 index 3be40991478..00000000000 --- a/test/rules/no-this-assignment/allow-destructuring/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -const { length } = this; - -const { length, toString } = this; - -const [foo] = this; - -const [foo, bar] = this; - -const self = this; - ~~~~~~~~~~~ [name % ('self')] - -[name]: Assigning `this` reference to local variable not allowed: %s. - diff --git a/test/rules/no-this-assignment/allow-destructuring/tslint.json b/test/rules/no-this-assignment/allow-destructuring/tslint.json deleted file mode 100644 index ba6ce5a4fd2..00000000000 --- a/test/rules/no-this-assignment/allow-destructuring/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "no-this-assignment": [true, { - "allow-destructuring": true - }] - } -} diff --git a/test/rules/no-this-assignment/allowed-names/test.ts.lint b/test/rules/no-this-assignment/allowed-names/test.ts.lint deleted file mode 100644 index 7411f550af8..00000000000 --- a/test/rules/no-this-assignment/allowed-names/test.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -const start = this; - -const startEnd = this; - -const endStart = this; - ~~~~~~~~~~~~~~~ [name % ('endStart')] - -[name]: Assigning `this` reference to local variable not allowed: %s. diff --git a/test/rules/no-this-assignment/allowed-names/tslint.json b/test/rules/no-this-assignment/allowed-names/tslint.json deleted file mode 100644 index 8435d774dc5..00000000000 --- a/test/rules/no-this-assignment/allowed-names/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "no-this-assignment": [true, { - "allowed-names": ["^start"] - }] - } -} diff --git a/test/rules/no-this-assignment/default/test.ts.lint b/test/rules/no-this-assignment/default/test.ts.lint deleted file mode 100644 index 94a9141c709..00000000000 --- a/test/rules/no-this-assignment/default/test.ts.lint +++ /dev/null @@ -1,46 +0,0 @@ -var unscoped = this; - ~~~~~~~~~~~~~~~ [identifier % ('unscoped')] - -function testFunction() { - let inFunction = this; - ~~~~~~~~~~~~~~~~~ [identifier % ('inFunction')] -} - -const testLambda = () => { - const inLambda = this; - ~~~~~~~~~~~~~~~ [identifier % ('inLambda')] -}; - -class TestClass { - constructor() { - const inConstructor = this; - ~~~~~~~~~~~~~~~~~~~~ [identifier % ('inConstructor')] - - const asThis: this = this; - ~~~~~~~~~~~~~~~~~~~ [identifier % ('asThis')] - - const asString = "this"; - const asArray = [this]; - const asArrayString = ["this"]; - } - - public act(scope: this = this) { - const inMemberFunction = this; - ~~~~~~~~~~~~~~~~~~~~~~~ [identifier % ('inMemberFunction')] - - const { act } = this; - ~~~~~~~~~~~~~~ [binding] - - const { act, constructor } = this; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [binding] - - const [foo] = this; - ~~~~~~~~~~~~ [binding] - - const [foo, bar] = this; - ~~~~~~~~~~~~~~~~~ [binding] - } -} - -[binding]: Don't assign members of `this` to local variables. -[identifier]: Assigning `this` reference to local variable not allowed: %s. diff --git a/test/rules/no-this-assignment/default/tslint.json b/test/rules/no-this-assignment/default/tslint.json deleted file mode 100644 index 3fb515282cd..00000000000 --- a/test/rules/no-this-assignment/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-this-assignment": true - } -} diff --git a/test/rules/no-trailing-whitespace/default/test.ts.fix b/test/rules/no-trailing-whitespace/default/test.ts.fix deleted file mode 100644 index 4383de12e33..00000000000 --- a/test/rules/no-trailing-whitespace/default/test.ts.fix +++ /dev/null @@ -1,33 +0,0 @@ -class Clazz { - public funcxion() { - console.log("test") ; - } - - - private foobar() { - } -} -const template = ` -I have trailing whitespace -`; -// single line comment without trailing whitespace -// single line comment with trailing whitespace - /* single line multiline comment */ -/* whitespace after comment */ -/* first line has trailing whitespace - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - * - */ - -// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/default/test.ts.lint b/test/rules/no-trailing-whitespace/default/test.ts.lint deleted file mode 100644 index a6a9bca652e..00000000000 --- a/test/rules/no-trailing-whitespace/default/test.ts.lint +++ /dev/null @@ -1,49 +0,0 @@ -class Clazz { - public funcxion() { - ~~~~ [trailing whitespace] - console.log("test") ; - ~~~~ [trailing whitespace] - } - -~~~~ [trailing whitespace] - -~~~~ [trailing whitespace] - private foobar() { - } -} - ~~~~ [trailing whitespace] -const template = ` - ~ [trailing whitespace] -I have trailing whitespace - ~~ [trailing whitespace] -`; -// single line comment without trailing whitespace -// single line comment with trailing whitespace - ~~~ [trailing whitespace] - /* single line multiline comment */ -/* whitespace after comment */ - ~ [trailing whitespace] -/* first line has trailing whitespace - ~~ [trailing whitespace] - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -/*** - * not a JSDoc comment - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -// following line checks for trailing whitespace before EOF - -~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/default/tslint.json b/test/rules/no-trailing-whitespace/default/tslint.json deleted file mode 100644 index f81bfe73957..00000000000 --- a/test/rules/no-trailing-whitespace/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true - } -} diff --git a/test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix b/test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix deleted file mode 100644 index 18bfde2eeb4..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix +++ /dev/null @@ -1,30 +0,0 @@ -class Clazz { - public funcxion() { - console.log("test") ; - } - - - private foobar() { - } -} -// single line comment without trailing whitespace -// single line comment with trailing whitespace - /* single line multiline comment */ -/* whitespace after comment */ -/* first line has trailing whitespace - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - * - */ - -// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint b/test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint deleted file mode 100644 index db700e685d1..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint +++ /dev/null @@ -1,38 +0,0 @@ -class Clazz { - public funcxion() { - ~~~~ [trailing whitespace] - console.log("test") ; - ~~~~ [trailing whitespace] - } - -~~~~ [trailing whitespace] - -~~~~ [trailing whitespace] - private foobar() { - } -} - ~~~~ [trailing whitespace] -// single line comment without trailing whitespace -// single line comment with trailing whitespace - /* single line multiline comment */ -/* whitespace after comment */ - ~ [trailing whitespace] -/* first line has trailing whitespace - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - * - */ - -// following line checks for trailing whitespace before EOF - -~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/ignore-comments/tslint.json b/test/rules/no-trailing-whitespace/ignore-comments/tslint.json deleted file mode 100644 index 862e2496a87..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-comments/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": [true, "ignore-comments"] - } -} diff --git a/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix b/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix deleted file mode 100644 index dfd0fadad70..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix +++ /dev/null @@ -1,30 +0,0 @@ -class Clazz { - public funcxion() { - console.log("test") ; - } - - - private foobar() { - } -} -// single line comment without trailing whitespace -// single line comment with trailing whitespace - /* single line multiline comment */ -/* whitespace after comment */ -/* first line has trailing whitespace - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - * - */ - -// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint b/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint deleted file mode 100644 index 0bf15bf9b69..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -class Clazz { - public funcxion() { - ~~~~ [trailing whitespace] - console.log("test") ; - ~~~~ [trailing whitespace] - } - -~~~~ [trailing whitespace] - -~~~~ [trailing whitespace] - private foobar() { - } -} - ~~~~ [trailing whitespace] -// single line comment without trailing whitespace -// single line comment with trailing whitespace - ~~~ [trailing whitespace] - /* single line multiline comment */ -/* whitespace after comment */ - ~ [trailing whitespace] -/* first line has trailing whitespace - ~~ [trailing whitespace] - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -// following line checks for trailing whitespace before EOF - -~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json b/test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json deleted file mode 100644 index fc15bef2af0..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": [true, "ignore-jsdoc"] - } -} diff --git a/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix b/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix deleted file mode 100644 index 201e1a6ef36..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix +++ /dev/null @@ -1,33 +0,0 @@ -class Clazz { - public funcxion() { - console.log("test") ; - } - - - private foobar() { - } -} -const template = ` -I have trailing whitespace -`; -// single line comment without trailing whitespace -// single line comment with trailing whitespace - /* single line multiline comment */ -/* whitespace after comment */ -/* first line has trailing whitespace - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - * - */ - -// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint b/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint deleted file mode 100644 index b0de5d3f721..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint +++ /dev/null @@ -1,47 +0,0 @@ -class Clazz { - public funcxion() { - ~~~~ [trailing whitespace] - console.log("test") ; - ~~~~ [trailing whitespace] - } - -~~~~ [trailing whitespace] - -~~~~ [trailing whitespace] - private foobar() { - } -} - ~~~~ [trailing whitespace] -const template = ` -I have trailing whitespace -`; -// single line comment without trailing whitespace -// single line comment with trailing whitespace - ~~~ [trailing whitespace] - /* single line multiline comment */ -/* whitespace after comment */ - ~ [trailing whitespace] -/* first line has trailing whitespace - ~~ [trailing whitespace] - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -/*** - * not a JSDoc comment - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -// following line checks for trailing whitespace before EOF - -~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json b/test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json deleted file mode 100644 index 0cffd8366f0..00000000000 --- a/test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": [ - true, - "ignore-template-strings" - ] - } -} diff --git a/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix b/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix deleted file mode 100644 index e5d0cb0d678..00000000000 --- a/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix +++ /dev/null @@ -1,34 +0,0 @@ -class Clazz { - public funcxion() { - console.log("test") ; - } - - - private foobar() { - } -} -const template = ` -I have trailing whitespace -`; -// single line comment without trailing whitespace -// single line comment with trailing whitespace - /* single line multiline comment */ -/* whitespace after comment */ -/* first line has trailing whitespace - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - * - */ - -/*** - * not a JSDoc comment - * - */ - -// following line checks for trailing whitespace before EOF - \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint b/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint deleted file mode 100644 index bd036eba86f..00000000000 --- a/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint +++ /dev/null @@ -1,46 +0,0 @@ -class Clazz { - public funcxion() { - ~~~~ [trailing whitespace] - console.log("test") ; - ~~~~ [trailing whitespace] - } - - - private foobar() { - } -} - ~~~~ [trailing whitespace] -const template = ` - ~ [trailing whitespace] -I have trailing whitespace - ~~ [trailing whitespace] -`; -// single line comment without trailing whitespace -// single line comment with trailing whitespace - ~~~ [trailing whitespace] - /* single line multiline comment */ -/* whitespace after comment */ - ~ [trailing whitespace] -/* first line has trailing whitespace - ~~ [trailing whitespace] - second line is ok - last line is not checked */ -/* - */ - -/** - * JSDoc comment with trailing whitespace - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -/*** - * not a JSDoc comment - ~ [trailing whitespace] - * - ~ [trailing whitespace] - */ - -// following line checks for trailing whitespace before EOF - \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json b/test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json deleted file mode 100644 index 8c800146f7d..00000000000 --- a/test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": [true, "ignore-blank-lines"] - } -} diff --git a/test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint b/test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint deleted file mode 100644 index c873c6af5a2..00000000000 --- a/test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ - -// This file starts with a zero width no-break-space. -// See http://www.fileformat.info/info/unicode/char/feff/index.htm -const a = 3; diff --git a/test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint b/test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint deleted file mode 100644 index 96c770979e8..00000000000 --- a/test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint +++ /dev/null @@ -1,5 +0,0 @@ - -~~ [trailing whitespace] -// This file starts with a zero width no-break-space followed by a trailing space. -// See http://www.fileformat.info/info/unicode/char/feff/index.htm -const a = 3; diff --git a/test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json b/test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json deleted file mode 100644 index f81bfe73957..00000000000 --- a/test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true - } -} diff --git a/test/rules/no-unbound-method/default/test.ts.lint b/test/rules/no-unbound-method/default/test.ts.lint deleted file mode 100644 index 53d3ba61f8f..00000000000 --- a/test/rules/no-unbound-method/default/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -interface I { m?(): void; } -function f(i: I) { - i.m!(); - (i.m as any)(1); - ( i.m)(1); - i.m ? 1 : 2; - if (i.m) {} - !i.m; - i.m["length"]; - return i.m!; - ~~~ [0] -} - -[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/default/test.tsx.lint b/test/rules/no-unbound-method/default/test.tsx.lint deleted file mode 100644 index b6e86b3405d..00000000000 --- a/test/rules/no-unbound-method/default/test.tsx.lint +++ /dev/null @@ -1,68 +0,0 @@ -class C { - method(x: number) {} - property: () => void; - template(strs: TemplateStringsArray, x: any) {} -} - -const c = new C(); -[0].forEach(c.method); - ~~~~~~~~ [0] -[0].forEach(x => c.method(x)); -[0].forEach(c.property); - -c.template; -~~~~~~~~~~ [0] -c.template`foo${0}`; -String.raw`${c.template}`; - ~~~~~~~~~~ [0] - -interface I { - foo(): void; - bar: () => void; -} -declare var i: I; -i.foo; -~~~~~ [0] -i.bar; - -c.method === i.foo; - -// OK in condition -c.method ? 1 : 2; -1 ? c.method : c.method; - ~~~~~~~~ [0] - ~~~~~~~~ [0] -if (c.method) {} -while (c.method) {} -do {} while (c.method); -for (c.method; c.method; c.method) {} - - -[0].forEach(c.method || i.foo); - ~~~~~~~~ [0] - ~~~~~ [0] -[0].forEach(c.method.bind(c)); - -; - ~~~~~~~~ [0] - -class Validators { - static required() { - return null; - } - static compose(...args: Function[]) {} -} - -Validators.compose(Validators.required); - ~~~~~~~~~~~~~~~~~~~ [0] - -const a = { - getText() { - return 'text'; - } -}; - -delete a.getText; - ~~~~~~~~~ [0] - -[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/default/tsconfig.json b/test/rules/no-unbound-method/default/tsconfig.json deleted file mode 100644 index f7855d670cb..00000000000 --- a/test/rules/no-unbound-method/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} \ No newline at end of file diff --git a/test/rules/no-unbound-method/default/tslint.json b/test/rules/no-unbound-method/default/tslint.json deleted file mode 100644 index 908c6e2ad9e..00000000000 --- a/test/rules/no-unbound-method/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unbound-method": true - } -} diff --git a/test/rules/no-unbound-method/ignore-static/test.tsx.lint b/test/rules/no-unbound-method/ignore-static/test.tsx.lint deleted file mode 100644 index e1775b891dc..00000000000 --- a/test/rules/no-unbound-method/ignore-static/test.tsx.lint +++ /dev/null @@ -1,46 +0,0 @@ -class C { - method(x: number) {} - property: () => void; - template(strs: TemplateStringsArray, x: any) {} -} - -const c = new C(); -[0].forEach(c.method); - ~~~~~~~~ [0] -[0].forEach(x => c.method(x)); -[0].forEach(c.property); - -c.template; -~~~~~~~~~~ [0] -c.template`foo${0}`; -String.raw`${c.template}`; - ~~~~~~~~~~ [0] - -interface I { - foo(): void; - bar: () => void; -} -declare var i: I; -i.foo; -~~~~~ [0] -i.bar; - -c.method === i.foo; -[0].forEach(c.method || i.foo); - ~~~~~~~~ [0] - ~~~~~ [0] -[0].forEach(c.method.bind(c)); - -; - ~~~~~~~~ [0] - -class Validators { - static required() { - return null; - } - static compose(...args: Function[]) {} -} - -Validators.compose(Validators.required); - -[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/ignore-static/tsconfig.json b/test/rules/no-unbound-method/ignore-static/tsconfig.json deleted file mode 100644 index f7855d670cb..00000000000 --- a/test/rules/no-unbound-method/ignore-static/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} \ No newline at end of file diff --git a/test/rules/no-unbound-method/ignore-static/tslint.json b/test/rules/no-unbound-method/ignore-static/tslint.json deleted file mode 100644 index d0674c20abf..00000000000 --- a/test/rules/no-unbound-method/ignore-static/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "linterOptions": { - "typeCheck": true - }, - "rules": { - "no-unbound-method": [true, "ignore-static"] - } -} diff --git a/test/rules/no-unbound-method/whitelist/test.tsx.lint b/test/rules/no-unbound-method/whitelist/test.tsx.lint deleted file mode 100644 index fbb98f7d95c..00000000000 --- a/test/rules/no-unbound-method/whitelist/test.tsx.lint +++ /dev/null @@ -1,80 +0,0 @@ -class C { - method(x: number) {} - property: () => void; - template(strs: TemplateStringsArray, x: any) {} -} - -const c = new C(); -[0].forEach(c.method); - ~~~~~~~~ [0] -[0].forEach(x => c.method(x)); -[0].forEach(c.property); - -c.template; -~~~~~~~~~~ [0] -c.template`foo${0}`; -String.raw`${c.template}`; - ~~~~~~~~~~ [0] - -expect(c.method).toHaveBeenCalled(); -typeof c.method; - -test(c.method); - ~~~~~~~~ [0] - -interface I { - foo(): void; - bar: () => void; -} -declare var i: I; -i.foo; -~~~~~ [0] -i.bar; - -c.method === i.foo; - -// OK in condition -c.method ? 1 : 2; -1 ? c.method : c.method; - ~~~~~~~~ [0] - ~~~~~~~~ [0] -if (c.method) {} -while (c.method) {} -do {} while (c.method); -for (c.method; c.method; c.method) {} - - -[0].forEach(c.method || i.foo); - ~~~~~~~~ [0] - ~~~~~ [0] -[0].forEach(c.method.bind(c)); - -; - ~~~~~~~~ [0] - -class Validators { - static required() { - return null; - } - static compose(...args: Function[]) {} -} - -Validators.compose(Validators.required); - ~~~~~~~~~~~~~~~~~~~ [0] - -(condition ? expectA : expectB)(c.method); - ~~~~~~~~ [0] -(await someObject)(c.method); - ~~~~~~~~ [0] -(await someMethod())(c.method); - ~~~~~~~~ [0] - -const a = { - getText() { - return 'text'; - } -}; - -delete a.getText; - -[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/whitelist/tsconfig.json b/test/rules/no-unbound-method/whitelist/tsconfig.json deleted file mode 100644 index f7855d670cb..00000000000 --- a/test/rules/no-unbound-method/whitelist/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} \ No newline at end of file diff --git a/test/rules/no-unbound-method/whitelist/tslint.json b/test/rules/no-unbound-method/whitelist/tslint.json deleted file mode 100644 index 96ff8334aa8..00000000000 --- a/test/rules/no-unbound-method/whitelist/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "linterOptions": { - "typeCheck": true - }, - "rules": { - "no-unbound-method": [true, { "whitelist": ["expect"], "allow-typeof": true, "allow-delete": true }] - } -} diff --git a/test/rules/no-unnecessary-callback-wrapper/test.ts.fix b/test/rules/no-unnecessary-callback-wrapper/test.ts.fix deleted file mode 100644 index 6a81f365c99..00000000000 --- a/test/rules/no-unnecessary-callback-wrapper/test.ts.fix +++ /dev/null @@ -1,27 +0,0 @@ -f; - -f; - -(x, y) => f(x, y, 0); -(x, y) => f(y, x); - -f; - -(x, ...y) => f(x, y); - -f; - -// Ignore if function is not an identifier -(x) => obj.f(x); -(x) => obj["f"](x); -x => foo()(x); -// x is not only used as argument -(x) => obj[x](x); -x => x(x); - -// allow async arrows -async (x) => f(x); - -// Not bothering to catch this case. -({ x, y }) => f({ x, y }); - diff --git a/test/rules/no-unnecessary-callback-wrapper/test.ts.lint b/test/rules/no-unnecessary-callback-wrapper/test.ts.lint deleted file mode 100644 index c51c4067a7a..00000000000 --- a/test/rules/no-unnecessary-callback-wrapper/test.ts.lint +++ /dev/null @@ -1,32 +0,0 @@ -x => f(x); -~~~~~~~~~ [0] - -(x, y) => f(x, y); -~~~~~~~~~~~~~~~~~ [0] - -(x, y) => f(x, y, 0); -(x, y) => f(y, x); - -(x, y) => f(x, y); -~~~~~~~~~~~~~~~~~~~~ [0] - -(x, ...y) => f(x, y); - -(...args) => f(...args); -~~~~~~~~~~~~~~~~~~~~~~~ [0] - -// Ignore if function is not an identifier -(x) => obj.f(x); -(x) => obj["f"](x); -x => foo()(x); -// x is not only used as argument -(x) => obj[x](x); -x => x(x); - -// allow async arrows -async (x) => f(x); - -// Not bothering to catch this case. -({ x, y }) => f({ x, y }); - -[0]: No need to wrap 'f' in another function. Just use it directly. diff --git a/test/rules/no-unnecessary-callback-wrapper/tslint.json b/test/rules/no-unnecessary-callback-wrapper/tslint.json deleted file mode 100644 index 44e0d7a2d07..00000000000 --- a/test/rules/no-unnecessary-callback-wrapper/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-callback-wrapper": true - } -} diff --git a/test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint b/test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint deleted file mode 100644 index ca5c10c9c05..00000000000 --- a/test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint +++ /dev/null @@ -1,156 +0,0 @@ -class Foo { - public prop = 1; - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { - constructor() { - class Bar { - constructor() { - class FizzBuzz { - ~~~~~ [STATIC_ONLY] - public static a = 'hello mom!'; - } - } - } - } -} - -class Foo { - constructor() { - class Bar { - public static helper(): void {} - private Helper(): boolean { - return true; - } - constructor() {} - } - } -} - -class Foo { - constructor() { - class Bar { - constructor() { - class FizzBuzz { - public static helper(): void {} - private privateHelper(): boolean { - return true; - } - constructor() {} - } - } - } - } -} - -class Foo { - constructor() { - class Bar { - private a: SomeType; - static PROP = 2; - } - } -} - -class Foo { - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class EmptyClassA {} -~~~~~ [EMPTY_CLASS] - -class EmptyClassB { constructor() {} } - -export class AClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class BClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - - constructor() { - class nestedClass {} - ~~~~~ [EMPTY_CLASS] - } -} - -export class DoubleClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - - constructor() { - class NestedClass {} - ~~~~~ [EMPTY_CLASS] - - class SecondNestedClass { - ~~~~~ [STATIC_ONLY] - static myNum: number = 0; - } - } -} - -export class CClass extends BaseClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class ShorthandPropsClass { - public static helper(): void {} - constructor(private a: string) {} -} - -export class DClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - public index = 0; - constructor() {} -} - -export class EClass { - public static helper(): void {} - private Helper(): boolean { - return true; - } - constructor() {} -} - -[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. -[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. -[EMPTY_CLASS]: This class has no members. diff --git a/test/rules/no-unnecessary-class/allow-constructor-only/tslint.json b/test/rules/no-unnecessary-class/allow-constructor-only/tslint.json deleted file mode 100644 index f3f43df47fd..00000000000 --- a/test/rules/no-unnecessary-class/allow-constructor-only/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-class": [true, "allow-constructor-only"] - } -} diff --git a/test/rules/no-unnecessary-class/allow-empty/test.ts.lint b/test/rules/no-unnecessary-class/allow-empty/test.ts.lint deleted file mode 100644 index a26534a409c..00000000000 --- a/test/rules/no-unnecessary-class/allow-empty/test.ts.lint +++ /dev/null @@ -1,151 +0,0 @@ -class Foo { - public prop = 1; - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { - private number hello = 0; - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class FizzBuzz { - ~~~~~ [STATIC_ONLY] - public static a = 'hello mom!'; - } - } - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - public static helper(): void {} - private private Helper(): boolean { - return true; - } - constructor() {} - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class FizzBuzz { - public static helper(): void {} - private privateHelper(): boolean { - return true; - } - constructor() {} - } - } - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - private a: SomeType; - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class EmptyClassA {} - -class EmptyClassB { constructor() {} } -~~~~~ [CONSTRUCTOR_ONLY] - -export class AClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class BClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } -} - -export class CClass extends BaseClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class ShorthandPropsClass { - public static helper(): void {} - constructor(private a: string) {} -} - -export class DClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - public index = 0; - constructor() {} -} - -export class EClass { - public static helper(): void {} - private Helper(): boolean { - return true; - } - constructor() {} -} - -[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. -[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. -[EMPTY_CLASS]: This class has no members. \ No newline at end of file diff --git a/test/rules/no-unnecessary-class/allow-empty/tslint.json b/test/rules/no-unnecessary-class/allow-empty/tslint.json deleted file mode 100644 index 02f4ec676fa..00000000000 --- a/test/rules/no-unnecessary-class/allow-empty/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-class": [true, "allow-empty-class"] - } -} diff --git a/test/rules/no-unnecessary-class/allow-static-only/test.ts.lint b/test/rules/no-unnecessary-class/allow-static-only/test.ts.lint deleted file mode 100644 index 7813da0f876..00000000000 --- a/test/rules/no-unnecessary-class/allow-static-only/test.ts.lint +++ /dev/null @@ -1,136 +0,0 @@ -class Foo { - public prop = 1; - constructor() { - class Bar { - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class FizzBuzz { - public static a = 'hello mom!'; - } - } - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - public static helper(): void {} - private private Helper(): boolean { - return true; - } - constructor() {} - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class FizzBuzz { - public static helper(): void {} - private privateHelper(): boolean { - return true; - } - constructor() {} - } - } - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - private a: SomeType; - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - static PROP = 2; - } - } -} - -class EmptyClassA {} -~~~~~ [EMPTY_CLASS] - -class EmptyClassB { constructor() {} } -~~~~~ [CONSTRUCTOR_ONLY] - -export class AClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class BClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } -} - -export class CClass extends BaseClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class ShorthandPropsClass { - public static helper(): void {} - constructor(private a: string) {} -} - -export class DClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - public index = 0; - constructor() {} -} - -export class EClass { - public static helper(): void {} - private Helper(): boolean { - return true; - } - constructor() {} -} - -[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. -[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. -[EMPTY_CLASS]: This class has no members. \ No newline at end of file diff --git a/test/rules/no-unnecessary-class/allow-static-only/tslint.json b/test/rules/no-unnecessary-class/allow-static-only/tslint.json deleted file mode 100644 index 37ecb72cc17..00000000000 --- a/test/rules/no-unnecessary-class/allow-static-only/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-class": [true, "allow-static-only"] - } -} diff --git a/test/rules/no-unnecessary-class/default/test.ts.lint b/test/rules/no-unnecessary-class/default/test.ts.lint deleted file mode 100644 index eeda30340f3..00000000000 --- a/test/rules/no-unnecessary-class/default/test.ts.lint +++ /dev/null @@ -1,146 +0,0 @@ -class Foo { - public prop = 1; - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class FizzBuzz { - ~~~~~ [STATIC_ONLY] - public static a = 'hello mom!'; - } - } - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - public static helper(): void {} - private private Helper(): boolean { - return true; - } - constructor() {} - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class FizzBuzz { - public static helper(): void {} - private privateHelper(): boolean { - return true; - } - constructor() {} - } - } - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - private a: SomeType; - static PROP = 2; - } - } -} - -class Foo { -~~~~~ [CONSTRUCTOR_ONLY] - constructor() { - class Bar { - ~~~~~ [STATIC_ONLY] - static PROP = 2; - } - } -} - -class EmptyClassA {} -~~~~~ [EMPTY_CLASS] - -class EmptyClassB { constructor() {} } -~~~~~ [CONSTRUCTOR_ONLY] - -export class AClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() { - class nestedClass { - ~~~~~ [EMPTY_CLASS] - } - } -} - -export class BClass { - ~~~~~ [STATIC_ONLY] - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } -} - -export class CClass extends BaseClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - constructor() {} -} - -export class ShorthandPropsClass { - public static helper(): void {} - constructor(private a: string) {} -} - -export class DClass { - public static helper(): void {} - private static privateHelper(): boolean { - return true; - } - public index = 0; - constructor() {} -} - -export class EClass { - public static helper(): void {} - private Helper(): boolean { - return true; - } - constructor() {} -} - -[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. -[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. -[EMPTY_CLASS]: This class has no members. \ No newline at end of file diff --git a/test/rules/no-unnecessary-class/default/tslint.json b/test/rules/no-unnecessary-class/default/tslint.json deleted file mode 100644 index 58f7ae0f0ba..00000000000 --- a/test/rules/no-unnecessary-class/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-class": [true] - } -} diff --git a/test/rules/no-unnecessary-initializer/test.ts.fix b/test/rules/no-unnecessary-initializer/test.ts.fix deleted file mode 100644 index 0d832bda1cf..00000000000 --- a/test/rules/no-unnecessary-initializer/test.ts.fix +++ /dev/null @@ -1,18 +0,0 @@ -let a: string | undefined; -var b: string | undefined; - -for (let c: number | undefined; c < 2; c++) {} - -let d; - -const e = undefined; - -function f(x: string | undefined, bar: number) {} -function f2(x: string | undefined = undefined, bar: number = 1) {} - -declare function get(): T -const { g } = get<{ g?: number }>(); -const [h] = get(); - -function f({ x }: { x?: number }) {} - diff --git a/test/rules/no-unnecessary-initializer/test.ts.lint b/test/rules/no-unnecessary-initializer/test.ts.lint deleted file mode 100644 index 1de4897d422..00000000000 --- a/test/rules/no-unnecessary-initializer/test.ts.lint +++ /dev/null @@ -1,28 +0,0 @@ -let a: string | undefined = undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -var b: string | undefined = undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -for (let c: number | undefined = undefined; c < 2; c++) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -let d; - -const e = undefined; - -function f(x: string | undefined = undefined, bar: number) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -function f2(x: string | undefined = undefined, bar: number = 1) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] - -declare function get(): T -const { g = undefined } = get<{ g?: number }>(); - ~~~~~~~~~~~~~ [0] -const [h = undefined] = get(); - ~~~~~~~~~~~~~ [0] - -function f({ x = undefined }: { x?: number }) {} - ~~~~~~~~~~~~~ [0] - -[0]: Unnecessary initialization to 'undefined'. -[1]: Use an optional parameter instead of initializing to 'undefined'. Also, the type declaration does not need to include '| undefined'. diff --git a/test/rules/no-unnecessary-initializer/tslint.json b/test/rules/no-unnecessary-initializer/tslint.json deleted file mode 100644 index 2fbb39a5e80..00000000000 --- a/test/rules/no-unnecessary-initializer/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-initializer": [true] - } -} diff --git a/test/rules/no-unnecessary-qualifier/arguments.ts.lint b/test/rules/no-unnecessary-qualifier/arguments.ts.lint deleted file mode 100644 index 04dd3ffb80d..00000000000 --- a/test/rules/no-unnecessary-qualifier/arguments.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -namespace N { - export type T = number; - export const x: N.T = 0; - ~ [N] - export function f() { - if (arguments.length > 0) { - console.log('arguments should not break this rule'); - } - } -} - -[N]: Qualifier is unnecessary since 'N' is in scope. diff --git a/test/rules/no-unnecessary-qualifier/b.test.ts b/test/rules/no-unnecessary-qualifier/b.test.ts deleted file mode 100644 index a87fbc00e59..00000000000 --- a/test/rules/no-unnecessary-qualifier/b.test.ts +++ /dev/null @@ -1 +0,0 @@ -export type T = number; \ No newline at end of file diff --git a/test/rules/no-unnecessary-qualifier/test-global-2.ts.lint b/test/rules/no-unnecessary-qualifier/test-global-2.ts.lint deleted file mode 100644 index 2365cfd2eb0..00000000000 --- a/test/rules/no-unnecessary-qualifier/test-global-2.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -namespace M { - // Used in test-global.ts - export type T = number; -} diff --git a/test/rules/no-unnecessary-qualifier/test-global.ts.fix b/test/rules/no-unnecessary-qualifier/test-global.ts.fix deleted file mode 100644 index b82929776f6..00000000000 --- a/test/rules/no-unnecessary-qualifier/test-global.ts.fix +++ /dev/null @@ -1,5 +0,0 @@ -namespace N { - export type T = number; - export const x: T = 0; - export const x: M.T = 0; -} diff --git a/test/rules/no-unnecessary-qualifier/test-global.ts.lint b/test/rules/no-unnecessary-qualifier/test-global.ts.lint deleted file mode 100644 index 67436ffccfe..00000000000 --- a/test/rules/no-unnecessary-qualifier/test-global.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -namespace N { - export type T = number; - export const x: N.T = 0; - ~ [Qualifier is unnecessary since 'N' is in scope.] - export const x: M.T = 0; -} diff --git a/test/rules/no-unnecessary-qualifier/test.ts.fix b/test/rules/no-unnecessary-qualifier/test.ts.fix deleted file mode 100644 index 0775562d407..00000000000 --- a/test/rules/no-unnecessary-qualifier/test.ts.fix +++ /dev/null @@ -1,41 +0,0 @@ -namespace N { - export type T = number; - export const x: T = 0; - - export namespace M { - export type U = T; - export const y: U = 0; - export const z: U = 0; - export const a = x; - export const b = y; - export const c = z; - } -} - -namespace A.B.C1 { - export const D = 7; -} - -namespace A.B.C2 { - const copy = C1.D; -} - -import * as B from "./b.test"; -declare module "./b.test" { - const x: T; -} - -namespace X { - export type T = number; - namespace Y { - type T = string; - // This qualifier *is* necessary since 'X.T' is shadowed. - const x: X.T = 0; - } -} - -enum E { - A, - B = A -} - diff --git a/test/rules/no-unnecessary-qualifier/test.ts.lint b/test/rules/no-unnecessary-qualifier/test.ts.lint deleted file mode 100644 index ee09132ffd4..00000000000 --- a/test/rules/no-unnecessary-qualifier/test.ts.lint +++ /dev/null @@ -1,54 +0,0 @@ -namespace N { - export type T = number; - export const x: N.T = 0; - ~ [N] - - export namespace M { - export type U = N.T; - ~ [N] - export const y: M.U = 0; - ~ [M] - export const z: N.M.U = 0; - ~~~ [NM] - export const a = N.x; - ~ [N] - export const b = M.y; - ~ [M] - export const c = N.M.z; - ~~~ [NM] - } -} - -namespace A.B.C1 { - export const D = 7; -} - -namespace A.B.C2 { - const copy = A.B.C1.D; - ~~~ [Qualifier is unnecessary since 'A.B' is in scope.] -} - -import * as B from "./b.test"; -declare module "./b.test" { - const x: B.T; - ~ [Qualifier is unnecessary since 'B' is in scope.] -} - -namespace X { - export type T = number; - namespace Y { - type T = string; - // This qualifier *is* necessary since 'X.T' is shadowed. - const x: X.T = 0; - } -} - -enum E { - A, - B = E.A - ~ [Qualifier is unnecessary since 'E' is in scope.] -} - -[N]: Qualifier is unnecessary since 'N' is in scope. -[M]: Qualifier is unnecessary since 'M' is in scope. -[NM]: Qualifier is unnecessary since 'N.M' is in scope. diff --git a/test/rules/no-unnecessary-qualifier/tsconfig.json b/test/rules/no-unnecessary-qualifier/tsconfig.json deleted file mode 100644 index db953a729b9..00000000000 --- a/test/rules/no-unnecessary-qualifier/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "declaration": true - } -} \ No newline at end of file diff --git a/test/rules/no-unnecessary-qualifier/tslint.json b/test/rules/no-unnecessary-qualifier/tslint.json deleted file mode 100644 index 53feac1c8ab..00000000000 --- a/test/rules/no-unnecessary-qualifier/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-qualifier": true - } -} \ No newline at end of file diff --git a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint deleted file mode 100644 index baa6c0a6dfd..00000000000 --- a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -declare const x: string | undefined; -x!; - -declare const y: string; -y as string; -~~~~~~~~~~~ [This assertion is unnecessary since it does not change the type of the expression.] diff --git a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json deleted file mode 100644 index 0967ef424bc..00000000000 --- a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json deleted file mode 100644 index 2acf91b7b08..00000000000 --- a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-type-assertion": true - } -} diff --git a/test/rules/no-unnecessary-type-assertion/strict/test.ts.fix b/test/rules/no-unnecessary-type-assertion/strict/test.ts.fix deleted file mode 100644 index 17726c9bc0c..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strict/test.ts.fix +++ /dev/null @@ -1,104 +0,0 @@ -const nonNullStringLiteral: 'test'; -const nonNullString: string; -const nullableString: string|undefined; -let anyType: any; -type AnyDuringMigration = any; -let tuple: [number, number] = [1, 2]; - -// non-null -let a = nonNullStringLiteral; -let b = nonNullString; -let c = nullableString!; -tuple; - -// as -let d = nonNullStringLiteral as string; -let e = nonNullString; -let f = nullableString as string; - -// type assertion -let g = nonNullStringLiteral; -let h = nonNullString; -let i = nullableString; - -// complex inner expression -let j = (nonNullString + nonNullStringLiteral); -let k = (nonNullString + nonNullStringLiteral); -let l = (nonNullString + nonNullStringLiteral); -let m = nonNullString.trim(); -let n = nonNullString.trim(); -let o = nonNullString.trim(); -let p = nonNullString.trim(); - -// custom types -interface Iface1 { - prop: string; -} -interface Iface2 { - prop: string; -} - -const value1: Iface1 = {prop: 'test'}; -const value2: Iface2 = {prop: 'test'}; - -let q = value1; -let r = value1; -let s = value2; -let t = value2 as Iface1; -let aa = anyType as AnyDuringMigration; - -interface TypeA { - kind: 'a'; -} -interface TypeB { - kind: 'b'; -} - -function isB(x: TypeA|TypeB): x is TypeB { - return true; -} - -function func(aOrB: TypeA|TypeB) { - let u = aOrB as TypeA; - let v = aOrB; - - if (aOrB.kind === 'a') { - let w = aOrB; - } else { - let x = aOrB; - } - - if (isB(aOrB)) { - let y = aOrB; - } else { - let z = aOrB; - } -} - -// Expecting no warning for these assertions as they are not unnecessary. - -type Bar = 'bar'; -const data = { - x: 'foo' as 'foo', - y: 'bar' as Bar, -} - -[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); -let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); - -interface NotATuple { - 0: number, - 0.5: number, - 2: number, -} - -declare const notATuple: NotATuple; -notATuple; - -function foo() { - let xx: 1 | 2 = 1; - const f = () => xx = 2; - f(); - xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error -} - diff --git a/test/rules/no-unnecessary-type-assertion/strict/test.ts.lint b/test/rules/no-unnecessary-type-assertion/strict/test.ts.lint deleted file mode 100644 index 42ae2598262..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strict/test.ts.lint +++ /dev/null @@ -1,125 +0,0 @@ -[typescript]: >= 2.4.0 -const nonNullStringLiteral: 'test'; -const nonNullString: string; -const nullableString: string|undefined; -let anyType: any; -type AnyDuringMigration = any; -let tuple: [number, number] = [1, 2]; - -// non-null -let a = nonNullStringLiteral!; - ~~~~~~~~~~~~~~~~~~~~~ [0] -let b = nonNullString!; - ~~~~~~~~~~~~~~ [0] -let c = nullableString!; -tuple!; -~~~~~~ [0] - -// as -let d = nonNullStringLiteral as string; -let e = nonNullString as string; - ~~~~~~~~~~~~~~~~~~~~~~~ [0] -let f = nullableString as string; - -// type assertion -let g = nonNullStringLiteral; -let h = nonNullString; - ~~~~~~~~~~~~~~~~~~~~~ [0] -let i = nullableString; - -// complex inner expression -let j = (nonNullString + nonNullStringLiteral)!; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let k = (nonNullString + nonNullStringLiteral) as string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let l = (nonNullString + nonNullStringLiteral); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let m = nonNullString.trim()!; - ~~~~~~~~~~~~~~~~~~~~~ [0] -let n = nonNullString.trim() as string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let o = nonNullString.trim(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let p = nonNullString!.trim(); - ~~~~~~~~~~~~~~ [0] - -// custom types -interface Iface1 { - prop: string; -} -interface Iface2 { - prop: string; -} - -const value1: Iface1 = {prop: 'test'}; -const value2: Iface2 = {prop: 'test'}; - -let q = value1; - ~~~~~~~~~~~~~~ [0] -let r = value1; -let s = value2 as Iface2; - ~~~~~~~~~~~~~~~~ [0] -let t = value2 as Iface1; -let aa = anyType as AnyDuringMigration; - -interface TypeA { - kind: 'a'; -} -interface TypeB { - kind: 'b'; -} - -function isB(x: TypeA|TypeB): x is TypeB { - return true; -} - -function func(aOrB: TypeA|TypeB) { - let u = aOrB as TypeA; - let v = aOrB; - - if (aOrB.kind === 'a') { - let w = aOrB as TypeA; - ~~~~~~~~~~~~~ [0] - } else { - let x = aOrB; - ~~~~~~~~~~~ [0] - } - - if (isB(aOrB)) { - let y = aOrB as TypeB; - ~~~~~~~~~~~~~ [0] - } else { - let z = aOrB; - ~~~~~~~~~~~ [0] - } -} - -// Expecting no warning for these assertions as they are not unnecessary. - -type Bar = 'bar'; -const data = { - x: 'foo' as 'foo', - y: 'bar' as Bar, -} - -[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); -let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); - -interface NotATuple { - 0: number, - 0.5: number, - 2: number, -} - -declare const notATuple: NotATuple; -notATuple; -~~~~~~~~~~~~~~~~~~~~ [0] - -function foo() { - let xx: 1 | 2 = 1; - const f = () => xx = 2; - f(); - xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error -} - -[0]: This assertion is unnecessary since it does not change the type of the expression. diff --git a/test/rules/no-unnecessary-type-assertion/strict/tsconfig.json b/test/rules/no-unnecessary-type-assertion/strict/tsconfig.json deleted file mode 100644 index 71e2b87a156..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strict/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "target": "es2015", - "strict": true - } -} diff --git a/test/rules/no-unnecessary-type-assertion/strict/tslint.json b/test/rules/no-unnecessary-type-assertion/strict/tslint.json deleted file mode 100644 index 6c6fdcf5f38..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strict/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-type-assertion": [true, "AnyDuringMigration"] - } -} diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix b/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix deleted file mode 100644 index 17726c9bc0c..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix +++ /dev/null @@ -1,104 +0,0 @@ -const nonNullStringLiteral: 'test'; -const nonNullString: string; -const nullableString: string|undefined; -let anyType: any; -type AnyDuringMigration = any; -let tuple: [number, number] = [1, 2]; - -// non-null -let a = nonNullStringLiteral; -let b = nonNullString; -let c = nullableString!; -tuple; - -// as -let d = nonNullStringLiteral as string; -let e = nonNullString; -let f = nullableString as string; - -// type assertion -let g = nonNullStringLiteral; -let h = nonNullString; -let i = nullableString; - -// complex inner expression -let j = (nonNullString + nonNullStringLiteral); -let k = (nonNullString + nonNullStringLiteral); -let l = (nonNullString + nonNullStringLiteral); -let m = nonNullString.trim(); -let n = nonNullString.trim(); -let o = nonNullString.trim(); -let p = nonNullString.trim(); - -// custom types -interface Iface1 { - prop: string; -} -interface Iface2 { - prop: string; -} - -const value1: Iface1 = {prop: 'test'}; -const value2: Iface2 = {prop: 'test'}; - -let q = value1; -let r = value1; -let s = value2; -let t = value2 as Iface1; -let aa = anyType as AnyDuringMigration; - -interface TypeA { - kind: 'a'; -} -interface TypeB { - kind: 'b'; -} - -function isB(x: TypeA|TypeB): x is TypeB { - return true; -} - -function func(aOrB: TypeA|TypeB) { - let u = aOrB as TypeA; - let v = aOrB; - - if (aOrB.kind === 'a') { - let w = aOrB; - } else { - let x = aOrB; - } - - if (isB(aOrB)) { - let y = aOrB; - } else { - let z = aOrB; - } -} - -// Expecting no warning for these assertions as they are not unnecessary. - -type Bar = 'bar'; -const data = { - x: 'foo' as 'foo', - y: 'bar' as Bar, -} - -[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); -let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); - -interface NotATuple { - 0: number, - 0.5: number, - 2: number, -} - -declare const notATuple: NotATuple; -notATuple; - -function foo() { - let xx: 1 | 2 = 1; - const f = () => xx = 2; - f(); - xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error -} - diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint b/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint deleted file mode 100644 index 0bac9d59232..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint +++ /dev/null @@ -1,124 +0,0 @@ -const nonNullStringLiteral: 'test'; -const nonNullString: string; -const nullableString: string|undefined; -let anyType: any; -type AnyDuringMigration = any; -let tuple: [number, number] = [1, 2]; - -// non-null -let a = nonNullStringLiteral!; - ~~~~~~~~~~~~~~~~~~~~~ [0] -let b = nonNullString!; - ~~~~~~~~~~~~~~ [0] -let c = nullableString!; -tuple!; -~~~~~~ [0] - -// as -let d = nonNullStringLiteral as string; -let e = nonNullString as string; - ~~~~~~~~~~~~~~~~~~~~~~~ [0] -let f = nullableString as string; - -// type assertion -let g = nonNullStringLiteral; -let h = nonNullString; - ~~~~~~~~~~~~~~~~~~~~~ [0] -let i = nullableString; - -// complex inner expression -let j = (nonNullString + nonNullStringLiteral)!; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let k = (nonNullString + nonNullStringLiteral) as string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let l = (nonNullString + nonNullStringLiteral); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let m = nonNullString.trim()!; - ~~~~~~~~~~~~~~~~~~~~~ [0] -let n = nonNullString.trim() as string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let o = nonNullString.trim(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let p = nonNullString!.trim(); - ~~~~~~~~~~~~~~ [0] - -// custom types -interface Iface1 { - prop: string; -} -interface Iface2 { - prop: string; -} - -const value1: Iface1 = {prop: 'test'}; -const value2: Iface2 = {prop: 'test'}; - -let q = value1; - ~~~~~~~~~~~~~~ [0] -let r = value1; -let s = value2 as Iface2; - ~~~~~~~~~~~~~~~~ [0] -let t = value2 as Iface1; -let aa = anyType as AnyDuringMigration; - -interface TypeA { - kind: 'a'; -} -interface TypeB { - kind: 'b'; -} - -function isB(x: TypeA|TypeB): x is TypeB { - return true; -} - -function func(aOrB: TypeA|TypeB) { - let u = aOrB as TypeA; - let v = aOrB; - - if (aOrB.kind === 'a') { - let w = aOrB as TypeA; - ~~~~~~~~~~~~~ [0] - } else { - let x = aOrB; - ~~~~~~~~~~~ [0] - } - - if (isB(aOrB)) { - let y = aOrB as TypeB; - ~~~~~~~~~~~~~ [0] - } else { - let z = aOrB; - ~~~~~~~~~~~ [0] - } -} - -// Expecting no warning for these assertions as they are not unnecessary. - -type Bar = 'bar'; -const data = { - x: 'foo' as 'foo', - y: 'bar' as Bar, -} - -[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); -let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); - -interface NotATuple { - 0: number, - 0.5: number, - 2: number, -} - -declare const notATuple: NotATuple; -notATuple; -~~~~~~~~~~~~~~~~~~~~ [0] - -function foo() { - let xx: 1 | 2 = 1; - const f = () => xx = 2; - f(); - xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error -} - -[0]: This assertion is unnecessary since it does not change the type of the expression. diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json b/test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json deleted file mode 100644 index 52e6c965a46..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "target": "es2015", - "strictNullChecks": true - } -} diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json b/test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json deleted file mode 100644 index 6c6fdcf5f38..00000000000 --- a/test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unnecessary-type-assertion": [true, "AnyDuringMigration"] - } -} diff --git a/test/rules/no-unsafe-any/default/commonjsModule.ts b/test/rules/no-unsafe-any/default/commonjsModule.ts deleted file mode 100644 index d38fad21b9c..00000000000 --- a/test/rules/no-unsafe-any/default/commonjsModule.ts +++ /dev/null @@ -1,3 +0,0 @@ -const x: any = 0; -namespace x {} -export = x; diff --git a/test/rules/no-unsafe-any/default/es6Module.ts b/test/rules/no-unsafe-any/default/es6Module.ts deleted file mode 100644 index 26ffb150702..00000000000 --- a/test/rules/no-unsafe-any/default/es6Module.ts +++ /dev/null @@ -1,8 +0,0 @@ -const defaultExport: any = 0; -export default defaultExport; -export const namedExport: any = 0; -export type T = number; - -export namespace NS { - export interface ITest {} -} diff --git a/test/rules/no-unsafe-any/default/test.ts.lint b/test/rules/no-unsafe-any/default/test.ts.lint deleted file mode 100644 index 3746de2495c..00000000000 --- a/test/rules/no-unsafe-any/default/test.ts.lint +++ /dev/null @@ -1,348 +0,0 @@ -import importEquals = require("./commonjsModule"); -import importAlias = importEquals; -namespace N { export const x: any = 0; } -import importQualifiedName = N.x; -import * as namespaceImport from "./es6Module"; -import defaultExport, { namedExport, NS } from "./es6Module"; -import namedExportAlias = namespaceImport.namedExport; - -const num: namespaceImport.T = 0; - -{ - const { x: { y, z } } = { x: { y: 1, z: 2 } }; - function f(a: any, b: { x: any }) { - const { g } = a; - ~~~~~ [0] - ~ [0] - const { x } = b; - } -} - -// Ignore number/string literal in type -function returnsA(): 0 | "a" | null | undefined { - return null; -} - -label: for (const x of [1]) { - continue label; -} -label: while(true) { - break label; -} - -importAlias.property; - -namespaceImport.namedExport; - -namedExport.foo; -~~~~~~~~~~~ [0] -namedExportAlias.foo; -~~~~~~~~~~~~~~~~ [0] -namedExport, namedExportAlias; - - -declare const x: any; -declare const hasProp: { x: any }; - -hasProp.x(1); -~~~~~~~~~ [0] - -declare function takesAny(a: any, ...bs: any[]): void; -declare function takesNumber(a: number, ...bs: number[]): void; - -takesAny(x, x); -takesNumber(x, x); - ~ [0] - ~ [0] - -declare function templateTakesAny(arr: TemplateStringsArray, a: any, ...bs: any[]): any; -declare function templateTakesNumber(arr: TemplateStringsArray, a: number, ...bs: number[]): any; - -templateTakesAny`${x}${x}`; -templateTakesNumber`${x}${x}`; - ~ [0] - ~ [0] -templateTakesAny`${x}`.prop; -~~~~~~~~~~~~~~~~~~~~~~ [0] - -declare function decoratorTakesAny(value: any): Function; -declare function decoratorTakesNumber(value: number): Function; -declare const decoratorIsAny: any; - -class C { - @decoratorTakesAny(x) f() {} - @decoratorTakesNumber(x) g() {} - ~ [0] - @decoratorIsAny h() {} - ~~~~~~~~~~~~~~ [0] -} - -x instanceof Date; -Date instanceof x; - ~ [0] - -const retBool: () => boolean = x; - ~ [0] - -function params(a: any = x, b: boolean = x) {} - ~ [0] - -function f(x: any, retAny: () => any): any { - x; - (x); - - x.foo; - ~ [0] - x(0); - ~ [0] - x``; - ~ [0] - x + 3; - ~ [0] - new x(); - ~ [0] - - retAny(); - retAny()[0]; - ~~~~~~~~ [0] - - // Same for constructors - new X(x); - new Y(x); - ~ [0] - - // Assignment: assign to 'any' OK, assign to other not OK. - const v0: any = x; - const v1: boolean = x; - ~ [0] - let v2: any, v3: boolean; - v2 = x; - v3 = x; - ~ [0] - - // Return OK if return type is 'any' - return x; -} - -function f2(x: any): boolean { - return x; - ~ [0] -} - -class X { - constructor(y: any) {} - - prop0: any = x; - prop1: number = x; - ~ [0] - -} -class Y { - constructor(x: number) {} -} - -function g(x: any): string { - if (x === undefined) { - return "undefined"; - } - if (typeof x === "string") { - return `string: ${x}`; - } - if (x instanceof Array) { - // Once it's been tested, OK to use it as an array. - return `Array, length ${x.length}`; - } - if (Math.random() > 0.5) { - // Allow explicit cast to 'any' - (x as any).whatchamacallit; - // Allow explicit cast - return ( x).toLowerCase() + (x as string).toUpperCase(); - } - - "" + x; - x + ""; - let s = ""; - s += x; - x += s; - ~ [0] - - return `other: ${x}`; -} - -function deleteOk(obj: { x: any }) { - delete obj.x; -} - -const obj: { x: number, y: number } = { - x: "number" as any, // Cast OK, and doesn't warn for LHS either. - [x]: 1, -}; - -switch (x) {} -switch (x.y) { - ~ [0] - case x: - x.y; - ~ [0] - break; - case x.y: - ~ [0] - break; -} - -declare global {} - -if (x) {} -if (!x) {} -if (!x || x) {} -for (;x;) {} -while (x) {} -do {} while (x); - -takesNumber(x ? x : x); - ~ [0] - ~ [0] -typeof x.prop; - ~ [0] - -function *gen1(): any { - yield x; - (yield).foo; - ~~~~~ [0] -} - -function *gen2() { - yield x; -} - -function *gen3(): IterableIterator { - yield x; - ~ [0] -} - -function *gen4(): IterableIterator { - yield x; -} - -void x; - -{ - let { a = x, b = x, c: d = x }: { a: number, b: any, c: string } = { a: 1, b: true, c: '' }; - ~ [0] - ~ [0] -} -{ - let {a, b} = x; - ~~~~~~ [0] - ~ [0] - let {c, d}: any = x; - ~~~~~~ [0] - let {x: {e, f}} = {x}; - ~~~~~~ [0] - ~ [0] - let {x: {g, h}}: {x: any} = {x}; - ~~~~~~ [0] - ({a, b} = x); - ~ [0] - ({x: {a, b}} = {x}); - ~ [0] -} -{ - let obj = {x}; - let {x: {a, b}} = obj; - ~~~~~~ [0] - ({x: {a, b}} = obj); // TODO show error on the inner destructuring -} -{ - let { a = x, b = x, c: d = x } = { a: 1, b: true, c: '' }; - ~ [0] - ~ [0] - ~ [0] -} -{ - let obj: {a: any, b: any} = null!; - let {a = x, b = x}: {a: number, b: any} = obj; - ~ [0] -} -{ - let a: number; - let b: any; - let c: string; - ({a = x, b: b = x, d: c = x} = {a: 1, b: x, d: ''}); - ~ [0] - ~ [0] -} -{ - class C { - prop: number = x; - ~ [0] - prop2 = x; - prop3: any = x; - } - class D extends C { - prop = x; - ~ [0] - prop2 = x; - prop3 = x; - } -} -{ - let obj = {x}; - let arr = [x]; -} -for (const {prop} of [x]) {} - ~~~~~~ [0] - -function predicate(x: any): x is number { - return typeof x === 'number'; -} - -function hasThisParameter(this: any) { - const v: number = this; - ~~~~ [0] -} - -(async function() { - return x; -}); -(async function(): Promise { - return x; -}); -(async function(): Promise { - return x; - ~ [0] -}) - -{ - let obj = {...x}; - ({...obj} = x); - ~~~ [0] - let arr = [...x]; - ~ [0] - predicate(...x); - ~ [0] -} - -namespace TestNS { - export interface ITest {} -} -namespace TestNS2 { - ""; - export interface ITest {} -} -{ - class Test implements TestNS.ITest {} - type T = any; - class Test2 implements T {} - ~ [0] - let C = null as any; - class Test3 extends C {} - ~ [0] - - interface I {} - class Test4 implements I {} - class Test5 implements TestNS2.ITest {} - class Test6 implements NS.ITest {} -} - -[0]: Unsafe use of expression of type 'any'. diff --git a/test/rules/no-unsafe-any/default/tsconfig.json b/test/rules/no-unsafe-any/default/tsconfig.json deleted file mode 100644 index 2ea9f28254e..00000000000 --- a/test/rules/no-unsafe-any/default/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "experimentalDecorators": true - } -} diff --git a/test/rules/no-unsafe-any/default/tslint.json b/test/rules/no-unsafe-any/default/tslint.json deleted file mode 100644 index b44ff572bc8..00000000000 --- a/test/rules/no-unsafe-any/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unsafe-any": true - } -} diff --git a/test/rules/no-unsafe-any/jsx/test.tsx.lint b/test/rules/no-unsafe-any/jsx/test.tsx.lint deleted file mode 100644 index edd49f1002c..00000000000 --- a/test/rules/no-unsafe-any/jsx/test.tsx.lint +++ /dev/null @@ -1,15 +0,0 @@ -declare const AnyComponent: any; - -const nativeJsxFull = ; -const nativeJsxShort = ; - -const nativeFragmentEmpty = <>; -const nativeFragmentFull = <>; - -const componentJsxFull = ; - ~~~~~~~~~~~~ [0] - ~~~~~~~~~~~~ [0] -const componentJsxShort = ; - ~~~~~~~~~~~~ [0] - -[0]: Unsafe use of expression of type 'any'. diff --git a/test/rules/no-unsafe-any/jsx/tsconfig.json b/test/rules/no-unsafe-any/jsx/tsconfig.json deleted file mode 100644 index 0b75885e6e8..00000000000 --- a/test/rules/no-unsafe-any/jsx/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "jsx": "react", - "module": "commonjs", - "target": "es6", - "experimentalDecorators": true - } -} diff --git a/test/rules/no-unsafe-any/jsx/tslint.json b/test/rules/no-unsafe-any/jsx/tslint.json deleted file mode 100644 index b44ff572bc8..00000000000 --- a/test/rules/no-unsafe-any/jsx/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unsafe-any": true - } -} diff --git a/test/rules/no-unsafe-any/unknown/test.ts.lint b/test/rules/no-unsafe-any/unknown/test.ts.lint deleted file mode 100644 index 1f955c599cb..00000000000 --- a/test/rules/no-unsafe-any/unknown/test.ts.lint +++ /dev/null @@ -1,83 +0,0 @@ -[typescript]: >= 3.0.0 - -/* - * It is not unsafe to pass any where unknown is allowed. This file checks - * these uses. - */ - -declare const x: any; - -declare function takesUnknown(a: unknown, ...bs: unknown[]): void; -takesUnknown(x, x); - -declare function templateTakesUnknown(arr: TemplateStringsArray, a: unknown, ...bs: unknown[]): any; -templateTakesUnknown`${x}${x}`; - -declare function decoratorTakesUnknown(value: unknown): Function; - -class C { - @decoratorTakesUnknown(x) f() {} -} - -function f(x: any, retAny: () => any): unknown { - const v2: unknown = x; - let v5: unknown; - v5 = x; - - // Return OK if return type is 'any' - return x; -} - -class X { - constructor(y: any) {} - prop: unknown = x; -} - -takesUnknown(x ? x : x); - -function *gen(): IterableIterator { - yield x; -} - -void x; - -{ - class C { - prop: unknown = x; - } - class D extends C { - prop = x; - } -} - -function hasThisParameter(this: any) { - const u: unknown = this; -} - -(async function(): Promise { - return x; -}); - -const obj = { property: "value" } as any; -const result: unknown = JSON.parse("{}"); - -const hasUnknownProp: { prop: unknown, obj: unknown } = { prop: obj, obj }; -hasUnknownProp.prop = obj; - -function acceptsUnknown(a: unknown, b: unknown = x) { } - -acceptsUnknown(obj); - -interface ContainsUnknownProperty { - e: unknown; -} - -const p: ContainsUnknownProperty = { e: (123 as any) }; - -function g() { - try { - - } catch (e) { - acceptsUnknown(e); - } -} diff --git a/test/rules/no-unsafe-any/unknown/tsconfig.json b/test/rules/no-unsafe-any/unknown/tsconfig.json deleted file mode 100644 index 2ea9f28254e..00000000000 --- a/test/rules/no-unsafe-any/unknown/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "experimentalDecorators": true - } -} diff --git a/test/rules/no-unsafe-any/unknown/tslint.json b/test/rules/no-unsafe-any/unknown/tslint.json deleted file mode 100644 index b44ff572bc8..00000000000 --- a/test/rules/no-unsafe-any/unknown/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unsafe-any": true - } -} diff --git a/test/rules/no-unsafe-finally/test.ts.lint b/test/rules/no-unsafe-finally/test.ts.lint deleted file mode 100644 index b64d8f7408c..00000000000 --- a/test/rules/no-unsafe-finally/test.ts.lint +++ /dev/null @@ -1,376 +0,0 @@ -function() { - try { - } finally { - return; - ~~~~~~~ [return] - } -} - -function() { - try { - } catch { - } finally { - return 1; - ~~~~~~~~~ [return] - } -} - -function() { - try { - } catch { - } finally { - { - return 1; - ~~~~~~~~~ [return] - } - } -} - -function() { - try { - } catch { - } finally { - for (let i = 0; i < 5; ++i) { - if (i % 2 === 0) { - return 1; - ~~~~~~~~~ [return] - } - } - } -} - -function() { - try { - } catch { - } finally { - let i = 1; - while (i < 5) { - if (i % 2 === 0) { - return i; - ~~~~~~~~~ [return] - } - - ++i; - } - } -} - -function() { - try { - } catch { - } finally { - let i = 1; - do { - if (i % 2 === 0) { - return i; - ~~~~~~~~~ [return] - } - - ++i; - } while (i < 5); - } -} - -function() { - try { - if (foo()) { - try { - bar(); - } catch { - } finally { - return 2; - ~~~~~~~~~ [return] - } - } - } catch { - } finally { - for (const i of [1, 2, 3, 4, 5]) { - if (i % 2 === 0) { - return 1; - ~~~~~~~~~ [return] - } - } - } -} - -function foo() { - try { - try { - } finally { - return 1; - ~~~~~~~~~ [return] - } - } catch { - } -} - -function foo() { - try { - } finally { - throw "error"; - ~~~~~~~~~~~~~~ [throw] - } -} - -function foo() { - for (const i of [1, 2, 3, 4, 5]) { - try { - } finally { - continue; - ~~~~~~~~~ [continue] - } - } -} - -function foo() { - for (const i of [1, 2, 3, 4, 5]) { - try { - } finally { - break; - ~~~~~~ [break] - } - } -} - -function foo() { - for (let i = 0; i < 5; ++i) { - try { - } finally { - continue; - ~~~~~~~~~ [continue] - } - } -} - -function foo() { - do { - try { - } finally { - continue; - ~~~~~~~~~ [continue] - } - } while (i > 0); -} - -function foo() { - while (i > 0) { - try { - } finally { - continue; - ~~~~~~~~~ [continue] - } - } -} - -function foo() { - do { - try { - } finally { - break; - ~~~~~~ [break] - } - } while (i > 0); -} - -function foo() { - while (i > 0) { - try { - } finally { - break; - ~~~~~~ [break] - } - } -} - -function foo() { - switch (a) { - case 1: - try { - return; - } finally { - break; - ~~~~~~ [break] - } - break; - default: - try { - } finally { - break; - ~~~~~~ [break] - } - break; - } -} - -function foo() { - label: - try { - } finally { - break label; - ~~~~~~~~~~~~ [break] - } -} - -function foo() { - label: - for (let i = 0; i < 4; ++i) { - try { - } finally { - break label; - ~~~~~~~~~~~~ [break] - } - } -} - -function foo() { - outer: - for (let i = 0; i < 4; ++i) { - try { - } finally { - inner: - for (let j = 0; j < 2; ++j) { - break outer; - ~~~~~~~~~~~~ [break] - } - } - } -} - -function foo() { - label: - for (let i = 0; i < 4; ++i) { - try { - } finally { - continue label; - ~~~~~~~~~~~~~~~ [continue] - } - } -} - -function foo() { - outer: - for (let i = 0; i < 4; ++i) { - try { - } finally { - inner: - for (let j = 0; j < 2; ++j) { - continue outer; - ~~~~~~~~~~~~~~~ [continue] - } - } - } -} - -// valid -function() { - try { - } finally { - (function() { - return 1; - })(); - } -} - -// valid -function() { - try { - foo(); - } finally { - class C { - bar() { - return 1; - } - } - } - - return 1; -} - -// valid -function() { - try { - } catch { - } finally { - for (let i = 0; i < 5; ++i) { - if (i % 2 === 0) { - continue; - } - } - } -} - -// valid -function() { - try { - } catch { - } finally { - for (let i = 0; i < 5; ++i) { - if (i % 2 === 0) { - break; - } - } - } -} - -// valid -function() { - try { - } catch { - } finally { - switch (a) { - case 1: - break; - default: - break; - } - } -} - -//valid -function() { - try { - } finally { - label: - break label; - } -} - -//valid -function() { - try { - } finally { - outer: - for (let i = 0; i < 2; ++i) { - if (i % 2 === 0) { - continue outer; - } - - inner: - for (let j = 0; j < 2; ++j) { - if (j % 2 === 0) { - continue outer; - } - } - } - } -} - -function() { - try { - } finally { - function f() { - return; - } - } -} - -try { -} finally { - break; - ~~~~~~ [break] -} - -[return]: 'return' statements in finally blocks are forbidden. -[throw]: 'throw' statements in finally blocks are forbidden. -[break]: 'break' statements in finally blocks are forbidden. -[continue]: 'continue' statements in finally blocks are forbidden. diff --git a/test/rules/no-unsafe-finally/tslint.json b/test/rules/no-unsafe-finally/tslint.json deleted file mode 100644 index 0b957d11b67..00000000000 --- a/test/rules/no-unsafe-finally/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unsafe-finally": true - } -} \ No newline at end of file diff --git a/test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint b/test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint deleted file mode 100644 index ca6bef0e813..00000000000 --- a/test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint +++ /dev/null @@ -1,143 +0,0 @@ -"use strict"; -'use asm'; -"ngInject"; -''; - -function fun1() { - "use strict"; - 'someOtherDirective'; - return 0; -} - -(function() { "directive"; -'foo' -'directive2' -console.log('foo'); -'notdirective'; -~~~~~~~~~~~~~~~ [0] -})(); - -const a = () => { -'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } - ~~~~~~~~~~~~~~~ [0] - -function fun2(a: number) { - return 0; -} - -function fun3(a: number, b: number) { - return 0; -} - -namespace Fam { 'use strict'; 'use cool'; } -module Bam { 'use strict'; 'use cool'; } -namespace Az.Bz.Cz.Dz { - 'ngInject'; -} - -class Foo { - constructor() { - "ngInject"; - var a = 1; - 'notdirective'; - ~~~~~~~~~~~~~~~ [0] - } - - bar() { - 'use strict'; - } - - get baz() { - 'use asm'; - } - - set baz(newValue) { - "use asm"; - } -} - -// valid code: - -var i: number; -var j = 3; -i = 1 + 2; -j = fun1(); -fun1(); -fun2(2); -fun3(2, fun1()); -i++; -i += 2; ---i; -i <<= 2; -i = fun1() + fun1(); -j = (j === 0 ? 5 : 6); -(j === 0 ? fun1() : fun2(j)); -(a => 5)(4); -var obj = {}; -delete obj.key; -function* g(): Iterable { - for (let i = 0; i < 100; i++) { - yield i; - } -} - -async function f(foo: Promise): Promise { - await foo; - return 0; -} - -new Foo(); -~~~~~~~~~~ [0] - -// invalid code: - -5; -~~ [0] -i; -~~ [0] -3 + 5; -~~~~~~ [0] -fun1() + fun1(); -~~~~~~~~~~~~~~~~ [0] -fun2(i) + fun3(4,7); -~~~~~~~~~~~~~~~~~~~~ [0] -fun1() + 4; -~~~~~~~~~~~ [0] -4 + fun2(j); -~~~~~~~~~~~~ [0] -(j === 0 ? fun1() : 5); - ~ [0] -(j === 0 ? i : fun2(j)); - ~ [0] -a => fun2(a); -~~~~~~~~~~~~~ [0] -() => {return fun1();}; -~~~~~~~~~~~~~~~~~~~~~~~ [0] -"use strct"; -~~~~~~~~~~~~ [0] - -afterEach((el) => { - el && el.remove(); -}); - -checkParams((a, b) => { - (a || required('a')) && (b || required('b')); -}); - -checkParams((a, b) => { - ((a && b) || required('a, b')); -}); - -function interactionHandler(e) { - // fails in all cases since logical NOT operator is redundant - e && !e.preventDefault(); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -a && b; -~~~~~~~ [0] -a() && b; -~~~~~~~~~ [0] -a() && b(); - -[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/allow-fast-null-checks/tslint.json b/test/rules/no-unused-expression/allow-fast-null-checks/tslint.json deleted file mode 100644 index a0cf399bd23..00000000000 --- a/test/rules/no-unused-expression/allow-fast-null-checks/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unused-expression": [true, "allow-fast-null-checks"] - } -} diff --git a/test/rules/no-unused-expression/allow-new/test.ts.lint b/test/rules/no-unused-expression/allow-new/test.ts.lint deleted file mode 100644 index bb5542b6642..00000000000 --- a/test/rules/no-unused-expression/allow-new/test.ts.lint +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; -'use asm'; -"ngInject"; -''; - -function fun1() { - "use strict"; - 'someOtherDirective'; - return 0; -} - -(function() { "directive"; -'foo' -'directive2' -console.log('foo'); -'notdirective'; -~~~~~~~~~~~~~~~ [0] -})(); - -const a = () => { -'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } - ~~~~~~~~~~~~~~~ [0] - -function fun2(a: number) { - return 0; -} - -function fun3(a: number, b: number) { - return 0; -} - -namespace Fam { 'use strict'; 'use cool'; } -module Bam { 'use strict'; 'use cool'; } -namespace Az.Bz.Cz.Dz { - 'ngInject'; -} - -class Foo { - constructor() { - "ngInject"; - var a = 1; - 'notdirective'; - ~~~~~~~~~~~~~~~ [0] - } - - bar() { - 'use strict'; - } - - get baz() { - 'use asm'; - } - - set baz(newValue) { - "use asm"; - } -} - -// valid code: - -var i: number; -var j = 3; -i = 1 + 2; -j = fun1(); -fun1(); -fun2(2); -fun3(2, fun1()); -i++; -i += 2; ---i; -i <<= 2; -i = fun1() + fun1(); -j = (j === 0 ? 5 : 6); -(j === 0 ? fun1() : fun2(j)); -(a => 5)(4); -var obj = {}; -delete obj.key; -function* g(): Iterable { - for (let i = 0; i < 100; i++) { - yield i; - } -} - -async function f(foo: Promise): Promise { - await foo; - return 0; -} - -new Foo(); - -bar.foo || (bar.foo = new Foo()); - -// invalid code: - -5; -~~ [0] -i; -~~ [0] -3 + 5; -~~~~~~ [0] -fun1() + fun1(); -~~~~~~~~~~~~~~~~ [0] -fun2(i) + fun3(4,7); -~~~~~~~~~~~~~~~~~~~~ [0] -fun1() + 4; -~~~~~~~~~~~ [0] -4 + fun2(j); -~~~~~~~~~~~~ [0] -(j === 0 ? fun1() : 5); - ~ [0] -(j === 0 ? i : fun2(j)); - ~ [0] -a => fun2(a); -~~~~~~~~~~~~~ [0] -() => {return fun1();}; -~~~~~~~~~~~~~~~~~~~~~~~ [0] -"use strct"; -~~~~~~~~~~~~ [0] - -afterEach((el) => { - el && el.remove(); -}); - -checkParams((a, b) => { - (a || required('a')) && (b || required('b')); -}); - -checkParams((a, b) => { - ((a && b) || required('a, b')); -}); - -function interactionHandler(e) { - // fails in all cases since logical NOT operator is redundant - e && !e.preventDefault(); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -let var1, var2; -if (foo) - var1 = 1, var2 = 1; -else - var1 = 2, var2; - ~~~~ [0] - -[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/allow-new/tslint.json b/test/rules/no-unused-expression/allow-new/tslint.json deleted file mode 100644 index f340315a6d7..00000000000 --- a/test/rules/no-unused-expression/allow-new/tslint.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "rules": { - "no-unused-expression": [ - true, - "allow-new", - "allow-fast-null-checks" - ] - } -} diff --git a/test/rules/no-unused-expression/allow-tagged-template/test.ts.lint b/test/rules/no-unused-expression/allow-tagged-template/test.ts.lint deleted file mode 100644 index 2c69f6790ae..00000000000 --- a/test/rules/no-unused-expression/allow-tagged-template/test.ts.lint +++ /dev/null @@ -1,194 +0,0 @@ -"use strict"; -'use asm'; -"ngInject"; -''; - -function fun1() { - "use strict"; - 'someOtherDirective'; - return 0; -} - -(function() { "directive"; -'foo' -'directive2' -console.log('foo'); -'notdirective'; -~~~~~~~~~~~~~~~ [0] -})(); - -const a = () => { -'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } - ~~~~~~~~~~~~~~~ [0] - -function fun2(a: number) { - return 0; -} - -function fun3(a: number, b: number) { - return 0; -} - -namespace Fam { 'use strict'; 'use cool'; } -module Bam { 'use strict'; 'use cool'; } -namespace Az.Bz.Cz.Dz { - 'ngInject'; -} - -class Foo { - constructor() { - "ngInject"; - var a = 1; - 'notdirective'; - ~~~~~~~~~~~~~~~ [0] - } - - bar() { - 'use strict'; - } - - get baz() { - 'use asm'; - } - - set baz(newValue) { - "use asm"; - } -} - -// valid code: - -var i: number; -var j = 3; -i = 1 + 2; -j = fun1(); -fun1(); -fun2(2); -fun3(2, fun1()); -i++; -i += 2; ---i; -i <<= 2; -i = fun1() + fun1(); -j = (j === 0 ? 5 : 6); -(j === 0 ? fun1() : fun2(j)); -(a => 5)(4); -var obj = {}; -delete obj.key; -function* g(): Iterable { - for (let i = 0; i < 100; i++) { - yield i; - } -} - -async function f(foo: Promise): Promise { - await foo; - return 0; -} - -new Foo(); -~~~~~~~~~~ [0] - -// invalid code: - -5; -~~ [0] -i; -~~ [0] -3 + 5; -~~~~~~ [0] -fun1() + fun1(); -~~~~~~~~~~~~~~~~ [0] -fun2(i) + fun3(4,7); -~~~~~~~~~~~~~~~~~~~~ [0] -fun1() + 4; -~~~~~~~~~~~ [0] -4 + fun2(j); -~~~~~~~~~~~~ [0] -(j === 0 ? fun1() : 5); - ~ [0] -(j === 0 ? i : fun2(j)); - ~ [0] -a => fun2(a); -~~~~~~~~~~~~~ [0] -() => {return fun1();}; -~~~~~~~~~~~~~~~~~~~~~~~ [0] -"use strct"; -~~~~~~~~~~~~ [0] - -afterEach((el) => { - el && el.remove(); - ~~~~~~~~~~~~~~~~~~ [0] -}); - -checkParams((a, b) => { - (a || required('a')) && (b || required('b')); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -}); - -checkParams((a, b) => { - ((a && b) || required('a, b')); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -}); - -function interactionHandler(e) { - // fails in all cases since logical NOT operator is redundant - e && !e.preventDefault(); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -let var1, var2; -if (foo) - var1 = 1, var2 = 1; -else - var1 = 2, var2; - ~~~~ [0] - -(0,eval)('"foobar";'); -(foo,eval)('"foobar";'); - ~~~ [0] -(foo(),eval)('"foobar";'); -(0, 1, eval)('"foobar";'); - ~~~~ [0] -(1, eval)('"foobar";'); - ~ [0] -(0, foo)('"foobar":'); - ~ [0] -var2 = (0, 1, 2); - ~~~~ [0] -(0, 1, 2); -~~~~~~~~~~ [0] - -var1 = void 0; -var1 = void 1; - ~ [0] -var1 = void foo; - ~~~ [0] -var1 = void foo === bar; - ~~~ [0] - -var1 = void (foo === bar); - ~~~~~~~~~~~~~ [0] -var1 = void (foo = bar); -var1 = void foo.bar; - ~~~~~~~ [0] -var1 = void foo(); - -switch(l) { - case 0, 1: - ~ [0] - return 'zero or one'; - default: - return 'more than one'; -} - -let x = Math.pow((3, 5)); - ~ [0] -let a = [(3 + 4), ((1 + 1, 8) * 4)]; - ~~~~~ [0] - -`foo`; -~~~~~~ [0] -foo`bar`; - -[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/allow-tagged-template/tslint.json b/test/rules/no-unused-expression/allow-tagged-template/tslint.json deleted file mode 100644 index 0c85e06a62c..00000000000 --- a/test/rules/no-unused-expression/allow-tagged-template/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "no-unused-expression": [ - true, - "allow-tagged-template" - ] - } -} diff --git a/test/rules/no-unused-expression/default/test.ts.lint b/test/rules/no-unused-expression/default/test.ts.lint deleted file mode 100644 index 88bf876a3fb..00000000000 --- a/test/rules/no-unused-expression/default/test.ts.lint +++ /dev/null @@ -1,226 +0,0 @@ -"use strict"; -'use asm'; -"ngInject"; -''; - -function fun1() { - "use strict"; - 'someOtherDirective'; - return 0; -} - -(function() { "directive"; -'foo' -'directive2' -console.log('foo'); -'notdirective'; -~~~~~~~~~~~~~~~ [0] -})(); - -const a = () => { -'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } - ~~~~~~~~~~~~~~~ [0] - -function fun2(a: number) { - return 0; -} - -function fun3(a: number, b: number) { - return 0; -} - -namespace Fam { 'use strict'; 'use cool'; } -module Bam { 'use strict'; 'use cool'; } -namespace Az.Bz.Cz.Dz { - 'ngInject'; -} - -class Foo { - constructor() { - "ngInject"; - var a = 1; - 'notdirective'; - ~~~~~~~~~~~~~~~ [0] - } - - bar() { - 'use strict'; - } - - get baz() { - 'use asm'; - } - - set baz(newValue) { - "use asm"; - } -} - -// valid code: - -var i: number; -var j = 3; -i = 1 + 2; -j = fun1(); -fun1(); -fun2(2); -fun3(2, fun1()); -i++; -i += 2; ---i; -i <<= 2; -i = fun1() + fun1(); -j = (j === 0 ? 5 : 6); -(j === 0 ? fun1() : fun2(j)); -(a => 5)(4); -var obj = {}; -delete obj.key; -function* g(): Iterable { - for (let i = 0; i < 100; i++) { - yield i; - } -} - -async function f(foo: Promise): Promise { - await foo; - return 0; -} - -new Foo(); -~~~~~~~~~~ [0] - -// invalid code: - -5; -~~ [0] -i; -~~ [0] -3 + 5; -~~~~~~ [0] -fun1() + fun1(); -~~~~~~~~~~~~~~~~ [0] -fun2(i) + fun3(4,7); -~~~~~~~~~~~~~~~~~~~~ [0] -fun1() + 4; -~~~~~~~~~~~ [0] -4 + fun2(j); -~~~~~~~~~~~~ [0] -(j === 0 ? fun1() : 5); - ~ [0] -(j === 0 ? i : fun2(j)); - ~ [0] -a => fun2(a); -~~~~~~~~~~~~~ [0] -() => {return fun1();}; -~~~~~~~~~~~~~~~~~~~~~~~ [0] -"use strct"; -~~~~~~~~~~~~ [0] - -afterEach((el) => { - el && el.remove(); - ~~~~~~~~~~~~~~~~~~ [0] -}); - -checkParams((a, b) => { - (a || required('a')) && (b || required('b')); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -}); - -checkParams((a, b) => { - ((a && b) || required('a, b')); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -}); - -function interactionHandler(e) { - // fails in all cases since logical NOT operator is redundant - e && !e.preventDefault(); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -a && b ? a : b; -~~~~~~~~~~~~~~~ [0] - -a && b; -~~~~~~~ [0] -a() && b; -~~~~~~~~~ [0] -a() && b(); -~~~~~~~~~~~ [0] - -let var1, var2; -if (foo) - var1 = 1, var2 = 1; -else - var1 = 2, var2; - ~~~~ [0] -var1, var2; -~~~~~~~~~~~ [0] - -(0,eval)('"foobar";'); -(foo,eval)('"foobar";'); - ~~~ [0] -(foo(),eval)('"foobar";'); -(foo(), 0, eval)('"foobar";'); - ~ [0] -(0, 1, eval)('"foobar";'); - ~~~~ [0] -(1, eval)('"foobar";'); - ~ [0] -(0, foo)('"foobar";'); - ~ [0] -var2 = (0, 1, 2); - ~~~~ [0] -(0, 1, 2); -~~~~~~~~~~ [0] -(0, 1, foo()); - ~~~~ [0] - -var1 = void 0; -var1 = void(0); -var1 = void 1; - ~ [0] -var1 = void(1); - ~~~ [0] -var1 = void foo; - ~~~ [0] -var1 = void foo === bar; - ~~~ [0] - -var1 = void (foo === bar); - ~~~~~~~~~~~~~ [0] -var1 = void (foo = bar); -var1 = void foo.bar; - ~~~~~~~ [0] -var1 = void foo(); - -void foo(); -void (foo && foo()); -~~~~~~~~~~~~~~~~~~~~ [0] -void 0; -~~~~~~~ [0] -void (foo = bar); -void 1; -~~~~~~~ [0] -foo ? bar = foo : void 0; - ~~~~~~ [0] -var1 = foo ? void (foo && foo()) : void 0; - -switch(l) { - case 0, 1: - ~ [0] - return 'zero or one'; - default: - return 'more than one'; -} - -let x = Math.pow((3, 5)); - ~ [0] -let a = [(3 + 4), ((1 + 1, 8) * 4)]; - ~~~~~ [0] - -`foo`; -~~~~~~ [0] -foo`bar`; -~~~~~~~~~ [0] - -[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/default/tslint.json b/test/rules/no-unused-expression/default/tslint.json deleted file mode 100644 index 042bc2f9ac4..00000000000 --- a/test/rules/no-unused-expression/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unused-expression": true - } -} diff --git a/test/rules/no-unused-variable/check-parameters/test.ts.lint b/test/rules/no-unused-variable/check-parameters/test.ts.lint deleted file mode 100644 index 95aa5f377a9..00000000000 --- a/test/rules/no-unused-variable/check-parameters/test.ts.lint +++ /dev/null @@ -1,88 +0,0 @@ -[typescript]: < 2.9.0 -export function func1(x: number, y: number, ...args: number[]) { - ~~~~ [err % ('args')] - return x + y; -} - -export function func2(x: number, y: number, ...args: number[]) { - ~ [err % ('y')] - return x + args[0]; -} - -export function func3(x?: number, y?: number) { - ~ [err % ('y')] - return x; -} - -export interface ITestInterface { - func4(x: number, y: number): number; -} - -export class ABCD { - constructor(private x: number, public y: number, private z: number) { - ~ [prop % ('x')] - } - - func5() { - return this.z; - } -} - -export interface ITestMapInterface { - [key: string]: string; -} - -export function func6(...args: number[]) { - return args; -} - -export function func7(f: (x: number) => number) { - return f; -} - -export function func8([x, y]: [number, number]) { - ~ [err % ('y')] - return x; -} - -export class DestructuringTests { - constructor(public x: number, public [y, z]) { // tsc error on binding pattern - } - - public func9({a, b}) { - ~ [err % ('b')] - return a; - } - - public func10([a, b]) { - ~ [err % ('b')] - return [a]; - } - - // destructuring with default value - public func11([x = 0]) { - ~ [err % ('x')] - return; - } -} - -abstract class AbstractTest { -#if typescript >= 2.9.0 -~~~~~~~~~~~~~~~~~~~~~~~~~~~ ['AbstractTest' is declared but never used.] -#endif -#if typescript >= 2.8.0 < 2.9.0 -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('AbstractTest')] -#endif -#if typescript < 2.8.0 - ~~~~~~~~~~~~ [err % ('AbstractTest')] -#endif - abstract foo(x); -} - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -[prop]: Property '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -[prop]: Property '%s' is declared but never used. -#endif diff --git a/test/rules/no-unused-variable/check-parameters/tsconfig.json b/test/rules/no-unused-variable/check-parameters/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-unused-variable/check-parameters/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-unused-variable/check-parameters/tslint.json b/test/rules/no-unused-variable/check-parameters/tslint.json deleted file mode 100644 index ab3b45be1f5..00000000000 --- a/test/rules/no-unused-variable/check-parameters/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unused-variable": [true, "check-parameters"] - } -} diff --git a/test/rules/no-unused-variable/default/class.ts.lint b/test/rules/no-unused-variable/default/class.ts.lint deleted file mode 100644 index 54e168a045f..00000000000 --- a/test/rules/no-unused-variable/default/class.ts.lint +++ /dev/null @@ -1,31 +0,0 @@ -[typescript]: < 2.9.0 -class ABCD { - private z2: number; - ~~ [err % ('z2')] - constructor() { - } - - mfunc1() { - // - } - - public mfunc2() { - this.mfunc3(); - } - - private mfunc3() { - // - } - - private mfunc4() { - ~~~~~~ [err % ('mfunc4')] - // - } - static stillPublic: number; -} - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -#endif diff --git a/test/rules/no-unused-variable/default/false-positives.ts.lint b/test/rules/no-unused-variable/default/false-positives.ts.lint deleted file mode 100644 index 61ed54826de..00000000000 --- a/test/rules/no-unused-variable/default/false-positives.ts.lint +++ /dev/null @@ -1,69 +0,0 @@ -[typescript]: < 2.9.0 -// case 1 -const fs = require("fs"); - -module Foo { -#if typescript >= 2.8.0 -~~~~~~~~~~ [err % ('Foo')] -#else - ~~~ [err % ('Foo')] -#endif - const path = require("path"); - - console.log(fs); - console.log(path); -} - -// case 2 -class HelloWorld { - constructor(public name: string) { } - sayHello() { - return `Hello, ${this.name}!`; - } -}; - -let hello = new HelloWorld("TSLint"); -hello.sayHello(); - -// case 3 -import Bar = whatever.that.Foo; - -module some.module.blah { -#if typescript >= 2.8.0 -~~~~~~~~~~~ [err % ('some')] -#else - ~~~~ [err % ('some')] -#endif - export class bar { - private bar: Bar; - constructor() { - console.log(this.bar); - } - } -} - -// case 4 -import DateTimeOpts = Intl.DateTimeFormatOptions; - -interface MyDateTimeOpts extends DateTimeOpts { - timezoneOffset: number; -} - -let opts: MyDateTimeOpts; -console.log(opts.timezoneOffset - 1); - -import * as myLib from 'a'; -export { myLib }; - -import foo from 'a'; -const bar = {foo}; -myFunc(bar); - -import a from "a"; -export { a }; - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -#endif diff --git a/test/rules/no-unused-variable/default/function.ts.lint b/test/rules/no-unused-variable/default/function.ts.lint deleted file mode 100644 index a844cfbcf70..00000000000 --- a/test/rules/no-unused-variable/default/function.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -[typescript]: < 2.9.0 -function func1(x: number, y: number) { - return x + y; -} - -var func2 = () => { - ~~~~~ [err % ('func2')] - // -}; - -function func3() { -#if typescript >= 2.8.0 -~~~~~~~~~~~~~~ [err % ('func3')] -#else - ~~~~~ [err % ('func3')] -#endif - return func1(1, 2); -} - -export function func4() { - return func1(2, 3); -} - -declare function func5(): any; -#if typescript >= 2.8.0 -~~~~~~~~~~~~~~~~~~~~~~ [err % ('func5')] -#else - ~~~~~ [err % ('func5')] -#endif - -export default function () { - return 0; -} - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -#endif diff --git a/test/rules/no-unused-variable/default/import.ts.fix b/test/rules/no-unused-variable/default/import.ts.fix deleted file mode 100644 index 961e3f72bad..00000000000 --- a/test/rules/no-unused-variable/default/import.ts.fix +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Some license that appears in the leading trivia of a statement that will be deleted. - * This text will not be deleted. - */ -import $ = require("a"); -import _ = require("a"); -import {a2 as aa2} from "a"; -aa2; -import {a3 as aa3} from "a"; -aa3; -// This import statement is unused and will be deleted along with this comment. -import {a8} from "a"; -a8; -import {a13} from "a"; -a13; -import {a14, a16} from "a"; -a14; -a16; - -// Leading comment will not be deleted -// Next comment will not be deleted - -export import a = require("a"); - -$(_.xyz()); - -/// - -module S { - var template = ""; -} - -import * as bar from "a"; -import baz from "a"; -import { namedExport } from "a"; -import d3 from "a"; -d3; - -d3; -d3; -d3;d3; - -bar.someFunc(); -baz(); -namedExport(); - -import "a"; - -import abc = require('a'); -import def = abc.someVar; -console.log(def); - - diff --git a/test/rules/no-unused-variable/default/import.ts.lint b/test/rules/no-unused-variable/default/import.ts.lint deleted file mode 100644 index 45fb1651d6a..00000000000 --- a/test/rules/no-unused-variable/default/import.ts.lint +++ /dev/null @@ -1,91 +0,0 @@ -[typescript]: < 2.9.0 -/** - * Some license that appears in the leading trivia of a statement that will be deleted. - * This text will not be deleted. - */ -import xyz = require("a"); - ~~~ [err % ('xyz')] -import $ = require("a"); -import _ = require("a"); -import {a1 as aa1, a2 as aa2} from "a"; - ~~~ [err % ('aa1')] -aa2; -import {a3 as aa3, a4 as aa4} from "a"; - ~~~ [err % ('aa4')] -aa3; -// This import statement is unused and will be deleted along with this comment. -import {a5, a6} from "a"; -~~~~~~~~~~~~~~~~~~~~~~~~~ [allErr] -import {a7} from "a"; -~~~~~~~~~~~~~~~~~~~~~ [allErr] -import {a8, a9, a10} from "a"; - ~~ [err % ('a9')] - ~~~ [err % ('a10')] -a8; -import {a11, a12, a13} from "a"; - ~~~ [err % ('a11')] - ~~~ [err % ('a12')] -a13; -import {a14, a15, a16} from "a"; - ~~~ [err % ('a15')] -a14; -a16; - -// Leading comment will not be deleted -import {unusedFunction} from "legacyDependency"; // Import unusedFunction because .... -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [allErr] -// Next comment will not be deleted - -export import a = require("a"); - -$(_.xyz()); - -/// - -module S { -#if typescript >= 2.8.0 -~~~~~~~~ [err % ('S')] -#else - ~ [err % ('S')] -#endif - var template = ""; - ~~~~~~~~ [err % ('template')] -} - -import * as foo from "a"; - ~~~ [err % ('foo')] -import * as bar from "a"; -import baz from "a"; -import defaultExport, { namedExport } from "a"; - ~~~~~~~~~~~~~ [err % ('defaultExport')] -import d1, { d2 } from "a"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [allErr] -import d3, { d4 } from "a"; - ~~~~~~ [All named bindings are unused.] -d3; - -d3;import d5 from "a"; - ~~~~~~~~~~~~~~~~~~~ [allErr] -import d6 from "a";d3; -~~~~~~~~~~~~~~~~~~~ [allErr] -d3;import d7 from "a";d3; - ~~~~~~~~~~~~~~~~~~~ [allErr] - -bar.someFunc(); -baz(); -namedExport(); - -import "a"; - -import abc = require('a'); -import def = abc.someVar; -console.log(def); - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -#endif - -[allErr]: All imports on this line are unused. -[allErrDecl]: All imports in import declaration are unused. diff --git a/test/rules/no-unused-variable/default/node_modules/a.ts b/test/rules/no-unused-variable/default/node_modules/a.ts deleted file mode 100644 index 85e5dcf1ed9..00000000000 --- a/test/rules/no-unused-variable/default/node_modules/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare var x: any; -export = x; diff --git a/test/rules/no-unused-variable/default/node_modules/react.ts b/test/rules/no-unused-variable/default/node_modules/react.ts deleted file mode 100644 index 6c1838c3425..00000000000 --- a/test/rules/no-unused-variable/default/node_modules/react.ts +++ /dev/null @@ -1 +0,0 @@ -export default x = 0; \ No newline at end of file diff --git a/test/rules/no-unused-variable/default/node_modules/react/addons.ts b/test/rules/no-unused-variable/default/node_modules/react/addons.ts deleted file mode 100644 index d6d31ab1196..00000000000 --- a/test/rules/no-unused-variable/default/node_modules/react/addons.ts +++ /dev/null @@ -1 +0,0 @@ -export const x = 0; \ No newline at end of file diff --git a/test/rules/no-unused-variable/default/react-addons1.tsx.lint b/test/rules/no-unused-variable/default/react-addons1.tsx.lint deleted file mode 100644 index e416a7fd69b..00000000000 --- a/test/rules/no-unused-variable/default/react-addons1.tsx.lint +++ /dev/null @@ -1,5 +0,0 @@ -[typescript]: >= 2.1.0 < 2.9.0 - -import * as React from "react/addons"; - -console.log(
); diff --git a/test/rules/no-unused-variable/default/react-addons2.tsx.lint b/test/rules/no-unused-variable/default/react-addons2.tsx.lint deleted file mode 100644 index 1fbc8455304..00000000000 --- a/test/rules/no-unused-variable/default/react-addons2.tsx.lint +++ /dev/null @@ -1,4 +0,0 @@ -[typescript]: < 2.9.0 -import * as React from "react/addons"; - -export class MyComponent extends React.Component<{}, {}> {} diff --git a/test/rules/no-unused-variable/default/react-addons3.tsx.lint b/test/rules/no-unused-variable/default/react-addons3.tsx.lint deleted file mode 100644 index 65b914d5bf3..00000000000 --- a/test/rules/no-unused-variable/default/react-addons3.tsx.lint +++ /dev/null @@ -1,7 +0,0 @@ -[typescript]: < 2.9.0 -import * as React from "react/addons"; -#if typescript >= 2.6.0 - ~~~~~ ['React' is declared but its value is never read.] -#else - ~~~~~ ['React' is declared but never used.] -#endif diff --git a/test/rules/no-unused-variable/default/react1.tsx.lint b/test/rules/no-unused-variable/default/react1.tsx.lint deleted file mode 100644 index 7ba79ea6418..00000000000 --- a/test/rules/no-unused-variable/default/react1.tsx.lint +++ /dev/null @@ -1,5 +0,0 @@ -[typescript]: >= 2.1.0 < 2.9.0 - -import * as React from "react"; - -console.log(
); diff --git a/test/rules/no-unused-variable/default/react2.tsx.lint b/test/rules/no-unused-variable/default/react2.tsx.lint deleted file mode 100644 index e3be995c34d..00000000000 --- a/test/rules/no-unused-variable/default/react2.tsx.lint +++ /dev/null @@ -1,4 +0,0 @@ -[typescript]: < 2.9.0 -import * as React from "react"; - -export class MyComponent extends React.Component<{}, {}> {} diff --git a/test/rules/no-unused-variable/default/react3.tsx.lint b/test/rules/no-unused-variable/default/react3.tsx.lint deleted file mode 100644 index c509ec72b6a..00000000000 --- a/test/rules/no-unused-variable/default/react3.tsx.lint +++ /dev/null @@ -1,7 +0,0 @@ -[typescript]: < 2.9.0 -import * as React from "react"; -#if typescript >= 2.6.0 - ~~~~~ ['React' is declared but its value is never read.] -#else - ~~~~~ ['React' is declared but never used.] -#endif diff --git a/test/rules/no-unused-variable/default/react4.tsx.lint b/test/rules/no-unused-variable/default/react4.tsx.lint deleted file mode 100644 index c509ec72b6a..00000000000 --- a/test/rules/no-unused-variable/default/react4.tsx.lint +++ /dev/null @@ -1,7 +0,0 @@ -[typescript]: < 2.9.0 -import * as React from "react"; -#if typescript >= 2.6.0 - ~~~~~ ['React' is declared but its value is never read.] -#else - ~~~~~ ['React' is declared but never used.] -#endif diff --git a/test/rules/no-unused-variable/default/tsconfig.json b/test/rules/no-unused-variable/default/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-unused-variable/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-unused-variable/default/tslint.json b/test/rules/no-unused-variable/default/tslint.json deleted file mode 100644 index b1d833a0963..00000000000 --- a/test/rules/no-unused-variable/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unused-variable": true - } -} diff --git a/test/rules/no-unused-variable/default/var.ts.lint b/test/rules/no-unused-variable/default/var.ts.lint deleted file mode 100644 index 5cff354df76..00000000000 --- a/test/rules/no-unused-variable/default/var.ts.lint +++ /dev/null @@ -1,92 +0,0 @@ -[typescript]: < 2.9.0 -var x = 3; - -var y = x; - ~ [err % ('y')] -var z; -#if typescript >= 2.6.0 - ~ [err % ('z')] -#endif - -export var abcd = 3; - -class ABCD { -#if typescript >= 2.9.0 -~~~~~~~~~~ ['ABCD' is declared but never used.] -#endif -#if typescript >= 2.8.0 < 2.9.0 -~~~~~~~~~~ [err % ('ABCD')] -#endif -#if typescript < 2.8.0 - ~~~~ [err % ('ABCD')] -#endif - constructor() { - z = 3; - } -} - -try { - // code here -} catch (e) { - // e is unused but that's still ok -} - -declare var tmp: any; - ~~~ [err % ('tmp')] - -export function testDestructuring() { - var [a, b] = [1, 2]; - ~ [err % ('a')] - ~ [err % ('b')] - var [c] = [3]; - - var {d, e} = { d: 1, e: 2 }; -#if typescript >= 2.9.0 - ~~~~~~ [All destructured elements are unused.] -#else - ~ [err % ('d')] - ~ [err % ('e')] -#endif - var {f} = { f: 3 }; - - return c * f; -} - -export var [foo, bar] = [1, 2]; - -export function testUnusedSpread() { - var a = [1, 2]; - ~ [err % ('a')] - var b = [3, 4]; - var c = [...b, 5]; // make sure we see that b is being used - - return c; - -} - -for(let e of [1,2,3]) { - ~ [err % ('e')] - -} - -export function testRenamingDestructure() { - var a = 2; - let {a: b} = {a: 4}; -#if typescript >= 2.9.0 - ~~~~~~ [err % ('b')] -#endif -#if typescript >= 2.8.0 < 2.9.0 - ~~~~ [err % ('b')] -#endif -#if typescript < 2.8.0 - ~ [err % ('b')] -#endif - let {x: y} = {x: 7}; // false positive - return a + y; -} - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -#endif diff --git a/test/rules/no-unused-variable/ignore-pattern/a.test.ts b/test/rules/no-unused-variable/ignore-pattern/a.test.ts deleted file mode 100644 index 3f0fe05dfe0..00000000000 --- a/test/rules/no-unused-variable/ignore-pattern/a.test.ts +++ /dev/null @@ -1 +0,0 @@ -export class _A {} diff --git a/test/rules/no-unused-variable/ignore-pattern/tsconfig.json b/test/rules/no-unused-variable/ignore-pattern/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-unused-variable/ignore-pattern/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-unused-variable/ignore-pattern/tslint.json b/test/rules/no-unused-variable/ignore-pattern/tslint.json deleted file mode 100644 index 6e81221de24..00000000000 --- a/test/rules/no-unused-variable/ignore-pattern/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unused-variable": [true, {"ignore-pattern": "^[_R]"}] - } -} diff --git a/test/rules/no-unused-variable/ignore-pattern/var.ts.lint b/test/rules/no-unused-variable/ignore-pattern/var.ts.lint deleted file mode 100644 index 4c067d4d355..00000000000 --- a/test/rules/no-unused-variable/ignore-pattern/var.ts.lint +++ /dev/null @@ -1,107 +0,0 @@ -[typescript]: < 2.9.0 -import { _A } from './a.test'; - -var x = 3; - -var y = x; - ~ [err % ('y')] -var _y = x; -var z; -#if typescript >= 2.6.0 - ~ [err % ('z')] -#endif - -export var abcd = 3; - -class ABCD { -#if typescript >= 2.9.0 -~~~~~~~~~~ ['ABCD' is declared but never used.] -#endif -#if typescript >= 2.8.0 < 2.9.0 -~~~~~~~~~~ [err % ('ABCD')] -#endif -#if typescript < 2.8.0 - ~~~~ [err % ('ABCD')] -#endif - constructor() { - z = 3; - } -} - -try { - // code here -} catch (e) { - // e is Unused but that's still ok -} - -declare var tmp: any; - ~~~ [err % ('tmp')] - -export function testDestructuring() { - var [a, b] = [1, 2]; - ~ [err % ('a')] - ~ [err % ('b')] - var [_a, _b] = [1, 2]; - var [c] = [3]; - - var {d, e} = { d: 1, e: 2 }; -#if typescript >= 2.9.0 - ~~~~~~ [All destructured elements are unused.] -#else - ~ [err % ('d')] - ~ [err % ('e')] -#endif - var {d: _d, e: _e} = { d: 1, e: 2 }; -#if typescript >= 2.9.0 - ~~~~~~~~~~~~~~ [All destructured elements are unused.] -#endif - // this above is incorrect, unfortunately w/ TS 2.9+, ignore pattern doesn't work for this sort of error - var {f} = { f: 3 }; - - return c * f; -} - -export var [foo, bar] = [1, 2]; - -export function testUnusedSpread() { - var a = [1, 2]; - ~ [err % ('a')] - var _a = [1, 2]; - var b = [3, 4]; - var c = [...b, 5]; // make sure we see that b is being used - - return c; - -} - -for(let e of [1,2,3]) { - ~ [err % ('e')] - -} - -for(let _e of [1,2,3]) { - -} - -export function testRenamingDestructure() { - var a = 2; - let {a: b} = {a: 4}; -#if typescript >= 2.9.0 - ~~~~~~ [err % ('b')] -#endif -#if typescript >= 2.8.0 < 2.9.0 - ~~~~ [err % ('b')] -#endif -#if typescript < 2.8.0 - ~ [err % ('b')] -#endif - let {a: _b} = {a: 4}; - let {x: y} = {x: 7}; // false positive - return a + y; -} - -#if typescript >= 2.6.0 -[err]: '%s' is declared but its value is never read. -#else -[err]: '%s' is declared but never used. -#endif diff --git a/test/rules/no-unused-variable/type-checked/a.test.ts b/test/rules/no-unused-variable/type-checked/a.test.ts deleted file mode 100644 index abfc7078006..00000000000 --- a/test/rules/no-unused-variable/type-checked/a.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -export class A {} -export var a: A; diff --git a/test/rules/no-unused-variable/type-checked/destructuring.ts.lint b/test/rules/no-unused-variable/type-checked/destructuring.ts.lint deleted file mode 100644 index b83d808dd8a..00000000000 --- a/test/rules/no-unused-variable/type-checked/destructuring.ts.lint +++ /dev/null @@ -1,15 +0,0 @@ -[typescript]: < 2.9.0 -import { SomeClass, someVar } from "./some.test"; -const person = { name: "alice" }; -const { name } = person; -#if typescript >= 2.9.0 - ~~~~~~~~ ['name' is declared but its value is never read.] -#endif -#if typescript >= 2.6.0 < 2.9.0 - ~~~~ ['name' is declared but its value is never read.] -#endif -#if typescript < 2.6.0 - ~~~~ ['name' is declared but never used.] -#endif - -export const {prop} = someVar; diff --git a/test/rules/no-unused-variable/type-checked/some.test.ts b/test/rules/no-unused-variable/type-checked/some.test.ts deleted file mode 100644 index 334bcaebd46..00000000000 --- a/test/rules/no-unused-variable/type-checked/some.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class SomeClass {} - -export const someVar = {prop: new SomeClass()}; diff --git a/test/rules/no-unused-variable/type-checked/test.ts.lint b/test/rules/no-unused-variable/type-checked/test.ts.lint deleted file mode 100644 index aa2ee88fa30..00000000000 --- a/test/rules/no-unused-variable/type-checked/test.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -[typescript]: < 2.9.0 -import {a, A} from './a.test'; - -export class B { - static thing = a; -} diff --git a/test/rules/no-unused-variable/type-checked/tsconfig.json b/test/rules/no-unused-variable/type-checked/tsconfig.json deleted file mode 100644 index db953a729b9..00000000000 --- a/test/rules/no-unused-variable/type-checked/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "declaration": true - } -} \ No newline at end of file diff --git a/test/rules/no-unused-variable/type-checked/tslint.json b/test/rules/no-unused-variable/type-checked/tslint.json deleted file mode 100644 index b1d833a0963..00000000000 --- a/test/rules/no-unused-variable/type-checked/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-unused-variable": true - } -} diff --git a/test/rules/no-use-before-declare/$.ts b/test/rules/no-use-before-declare/$.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/ImportAliasSecond.ts b/test/rules/no-use-before-declare/ImportAliasSecond.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/ImportAliasWithComment.ts b/test/rules/no-use-before-declare/ImportAliasWithComment.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/ImportRegularAlias.ts b/test/rules/no-use-before-declare/ImportRegularAlias.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/ImportWithLineBreaks.ts b/test/rules/no-use-before-declare/ImportWithLineBreaks.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/InterfaceFile.ts b/test/rules/no-use-before-declare/InterfaceFile.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/lib.ts b/test/rules/no-use-before-declare/lib.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-use-before-declare/test.ts.lint b/test/rules/no-use-before-declare/test.ts.lint deleted file mode 100644 index d8cf57c1805..00000000000 --- a/test/rules/no-use-before-declare/test.ts.lint +++ /dev/null @@ -1,105 +0,0 @@ -subscribe(({ meta: newMeta }: {meta: SessionMeta}) => { - this.setCount(newMeta.match_count); -}); - -subscribe(({ meta: newMeta }) => this.setCount(meta.match_count)); - -$.x = 3; -~ [variable '$' used before declaration] -import $ = require("./$"); -var vara = varb, varb; - ~~~~ [variable 'varb' used before declaration] - -class Test { - constructor() { - this.a = 3; - } - - private a: number; -} - -var i = j; - ~ [variable 'j' used before declaration] - -class ClassA { - prop: number; - constructor(object: ClassB) { - this.prop = object.prop; - } -} - -class ClassB { - prop: number; -} - -var j: number; - -if (something) { - var defined = 1; -} else { - var defined; -} - -testUndeclaredImports(); // Function early reference OK - -function testUndeclaredImports() { - console.log(foo1); - ~~~~ [variable 'foo1' used before declaration] - console.log(foo2); - ~~~~ [variable 'foo2' used before declaration] - console.log(foo3); - ~~~~ [variable 'foo3' used before declaration] - map([], (x) => x); - ~~~ [variable 'map' used before declaration] -} - -import { default as foo1 } from "./lib"; -import foo2 from "./lib"; -import _, { map, foldl } from "./underscore"; -import * as foo3 from "./lib"; -import "./lib"; - -export default function () { - // -}; - -export { - undeclaredA, - ~~~~~~~~~~~ [variable 'undeclaredA' used before declaration] - undeclaredB, - ~~~~~~~~~~~ [variable 'undeclaredB' used before declaration] - undeclaredC, - ~~~~~~~~~~~ [variable 'undeclaredC' used before declaration] - testUndeclaredImports -}; - -var undeclaredA = 42; -var { undeclaredB } = { undeclaredB: 43 }; -var { undeclaredB: undeclaredA } = { undeclaredB: 43 }; -var { undeclaredB: undeclaredA, undeclaredC } = { undeclaredB: 43, undeclaredC: 'hello' }; -var { undeclaredB: undeclaredA, undeclaredC: undeclaredD } = { undeclaredB: 43, undeclaredC: 'hello' }; -const [ undeclaredC, [undeclaredD] ] = [ 1, [2] ]; - -// shouldn't crash tslint -function a() { - var b = ({c: dog}) => { dog++; }; - b({ c: 5 }); -} - -import { ITest as ITest0 } from './ImportRegularAlias'; -import {/*ensure comments works*/ ITest as ITest1 } from './ImportAliasWithComment'; -import { - ITest as ITest2 -} from './ImportWithLineBreaks'; -import {First, ITest as ITest3 } from './ImportAliasSecond'; - -import ITest from './InterfaceFile'; - -class Greeter { - greet(options: { str: string }) { - var {str} = options; - return str; - } -} - -undefined; diff --git a/test/rules/no-use-before-declare/tsconfig.json b/test/rules/no-use-before-declare/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-use-before-declare/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-use-before-declare/tslint.json b/test/rules/no-use-before-declare/tslint.json deleted file mode 100644 index 744ae40f6ff..00000000000 --- a/test/rules/no-use-before-declare/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-use-before-declare": true - } -} diff --git a/test/rules/no-use-before-declare/underscore.ts b/test/rules/no-use-before-declare/underscore.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/rules/no-var-keyword/global.d.ts.lint b/test/rules/no-var-keyword/global.d.ts.lint deleted file mode 100644 index 76f30701892..00000000000 --- a/test/rules/no-var-keyword/global.d.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -declare var x: number; - -declare namespace N { - var y: number; - ~~~ [0] -} - -[0]: Forbidden 'var' keyword, use 'let' or 'const' instead diff --git a/test/rules/no-var-keyword/module.d.ts.lint b/test/rules/no-var-keyword/module.d.ts.lint deleted file mode 100644 index 50210412d76..00000000000 --- a/test/rules/no-var-keyword/module.d.ts.lint +++ /dev/null @@ -1,17 +0,0 @@ -export var x: number; - ~~~ [0] - -declare global { - var x: number; -} - -declare namespace foo.global { - var x: number; - ~~~ [0] - export namespace global { - var x: number; - ~~~ [0] - } -} - -[0]: Forbidden 'var' keyword, use 'let' or 'const' instead diff --git a/test/rules/no-var-keyword/test.ts.fix b/test/rules/no-var-keyword/test.ts.fix deleted file mode 100644 index a01748fb9da..00000000000 --- a/test/rules/no-var-keyword/test.ts.fix +++ /dev/null @@ -1,44 +0,0 @@ -let foo; - -function tmp(t: any) { - let x = 3; -} - -let i, - j; - -let [a, b] = [1, 2]; - -for (let n; false;); -for (let n1 in foo); -for (let n2 of foo); - -export let exportVar0 = 0; -export let exportVar1 = 1; -export let exportVar2 = 2, - exportVar21 = 21; -export /* var tst */ let exportVar3 = 3; - -module quz { - export let i; -} - -declare var tmp2: any; - -let bar; -const qux; - -let k, - l; - -let [x, y] = [1, 2]; - -for (n; false;); -for (let n; false;); -for (let name in foo); -for (let name of foo); -for (const name in foo); -for (const name of foo); - -export let exportLet = 1; -export const exportConst = 1; diff --git a/test/rules/no-var-keyword/test.ts.lint b/test/rules/no-var-keyword/test.ts.lint deleted file mode 100644 index 0579e31d389..00000000000 --- a/test/rules/no-var-keyword/test.ts.lint +++ /dev/null @@ -1,56 +0,0 @@ -var foo; -~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] - -function tmp(t: any) { - var x = 3; - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] -} - -var i, -~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] - j; - -var [a, b] = [1, 2]; -~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] - -for (var n; false;); - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] -for (var n1 in foo); - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] -for (var n2 of foo); - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] - -export var exportVar0 = 0; - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] -export var exportVar1 = 1; - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] -export var exportVar2 = 2, - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] - exportVar21 = 21; -export /* var tst */ var exportVar3 = 3; - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] - -module quz { - export var i; - ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] -} - -declare var tmp2: any; - -let bar; -const qux; - -let k, - l; - -let [x, y] = [1, 2]; - -for (n; false;); -for (let n; false;); -for (let name in foo); -for (let name of foo); -for (const name in foo); -for (const name of foo); - -export let exportLet = 1; -export const exportConst = 1; diff --git a/test/rules/no-var-keyword/tslint.json b/test/rules/no-var-keyword/tslint.json deleted file mode 100644 index 1de4119c014..00000000000 --- a/test/rules/no-var-keyword/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-var-keyword": true - } -} diff --git a/test/rules/no-var-requires/test.ts.lint b/test/rules/no-var-requires/test.ts.lint deleted file mode 100644 index de02a16a8ad..00000000000 --- a/test/rules/no-var-requires/test.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -import a = require("a"); -var b = require("b"); - ~~~~~~~~~~~~ [require statement not part of an import statement] diff --git a/test/rules/no-var-requires/tslint.json b/test/rules/no-var-requires/tslint.json deleted file mode 100644 index 665051136ed..00000000000 --- a/test/rules/no-var-requires/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-var-requires": true - } -} diff --git a/test/rules/no-void-expression/default/test.ts.lint b/test/rules/no-void-expression/default/test.ts.lint deleted file mode 100644 index 1322aff7aee..00000000000 --- a/test/rules/no-void-expression/default/test.ts.lint +++ /dev/null @@ -1,29 +0,0 @@ -function doIt() {} -async function doAsync() {} -function print(strs) {} - -[].forEach(x => console.log(x)); - ~~~~~~~~~~~~~~ [0] - -[].forEach(x => x && console.log(x)); - ~~~~~~~~~~~~~~ [0] - -async function f(): Promise { - const x = doIt(); - ~~~~~~ [0] - console.log(await doAsync()); - ~~~~~~~~~~~~~~~ [0] - return print``; - ~~~~~~~ [0] -} - -true && console.log(0); -false || console.log(0); - -declare function doIt(): void; -declare function doAsync(): Promise; -declare function print(strs: TemplateStringsArray): void; - -!!data ? console.info(message, data) : console.info(message); - -[0]: Expression has type `void`. Put it on its own line as a statement. diff --git a/test/rules/no-void-expression/default/tsconfig.json b/test/rules/no-void-expression/default/tsconfig.json deleted file mode 100644 index 981cde20346..00000000000 --- a/test/rules/no-void-expression/default/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "allowJs": true - } -} \ No newline at end of file diff --git a/test/rules/no-void-expression/default/tslint.json b/test/rules/no-void-expression/default/tslint.json deleted file mode 100644 index d8073cc8eda..00000000000 --- a/test/rules/no-void-expression/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-void-expression": true - } -} diff --git a/test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint b/test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint deleted file mode 100644 index 023f1861947..00000000000 --- a/test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -[].forEach(x => console.log(x)); -[].forEach(x => x && console.log(x)); -[].forEach(x => !x || console.log(x)); - -[].forEach(x => { - return console.log(x); - ~~~~~~~~~~~~~~ [0] -}); - -[0]: Expression has type `void`. Put it on its own line as a statement. diff --git a/test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json b/test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json b/test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json deleted file mode 100644 index edb823990d3..00000000000 --- a/test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "no-void-expression": [true, "ignore-arrow-function-shorthand"] - } -} diff --git a/test/rules/number-literal-format/test.ts.fix b/test/rules/number-literal-format/test.ts.fix deleted file mode 100644 index 8e9e5fcd6eb..00000000000 --- a/test/rules/number-literal-format/test.ts.fix +++ /dev/null @@ -1,47 +0,0 @@ -0; -0.5; -10; -1.1e10; - --6000; - --777; - --0; - --0.9; - --0.2; - --0.5; - --123e3; - --145E4; - --1467e-8; - --189e10; - --0xDEADBEEF; - -1; - -1 - -0; -0.5; - -0.5; - -0.5; - -1e1; -1E1; -1e-1; -1e10; - -0xDEADBEEF; - -0.0102; - diff --git a/test/rules/number-literal-format/test.ts.lint b/test/rules/number-literal-format/test.ts.lint deleted file mode 100644 index e9c9d9d0d00..00000000000 --- a/test/rules/number-literal-format/test.ts.lint +++ /dev/null @@ -1,77 +0,0 @@ -0; -0.5; -10; -1.1e10; - --0000006000; - ~~~~~~~~~~ [leading-0] - --777.; - ~~~~ [trailing-decimal] - --0.000; - ~~~~~ [trailing-0] - --0.90000; - ~~~~~~~ [trailing-0] - --.2; - ~~ [leading-decimal] - --.50000; - ~~~~~~ [trailing-0] - ~~~~~~ [leading-decimal] - --123e0003; - ~~~~ [leading-0] - --145E0004; - ~~~~ [leading-0] - --1467e-0008; - ~~~~~ [leading-0] - --189.000e10; - ~~~~~~~ [trailing-0] - --0xDEAdBEEF; - ~~~~~~~~~~ [uppercase] - -01; -~~ [leading-0] - -1. -~~ [trailing-decimal] - -0.0; -~~~ [trailing-0] -0.50; -~~~~ [trailing-0] - -.5; -~~ [leading-decimal] - -.50; -~~~ [trailing-0] -~~~ [leading-decimal] - -1e01; - ~~ [leading-0] -1E01; - ~~ [leading-0] -1e-01; - ~~~ [leading-0] -1.0e10; -~~~ [trailing-0] - -0xDEAdBEEF; -~~~~~~~~~~ [uppercase] - -0.010200; -~~~~~~~~ [trailing-0] - -[leading-0]: Number literal should not have a leading '0'. -[trailing-0]: Number literal should not have a trailing '0'. -[trailing-decimal]: Number literal should not end in '.'. -[leading-decimal]: Number literal should begin with '0.' and not just '.'. -[uppercase]: Hexadecimal number literal should be uppercase. diff --git a/test/rules/number-literal-format/tslint.json b/test/rules/number-literal-format/tslint.json deleted file mode 100644 index ec0d152e9f2..00000000000 --- a/test/rules/number-literal-format/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "number-literal-format": true - } -} diff --git a/test/rules/object-literal-key-quotes/always/test.ts.fix b/test/rules/object-literal-key-quotes/always/test.ts.fix deleted file mode 100644 index b5d13dd2b1f..00000000000 --- a/test/rules/object-literal-key-quotes/always/test.ts.fix +++ /dev/null @@ -1,20 +0,0 @@ -const o = { - 'hello': 123, - "goodbye": 234, // failure - "quote": 345, - "needs quote": 789, - "hyphens-need-quotes": null, - [computed]: 456, - "123": "hello", // failure - "10000": "something", // failure - "0.123": "float", // failure - '123': 'numbers do not need quotes', - '010': 'but this one does.', - '.123': 'as does this one', - "fn"() { return }, - "true": 0, // failure - "0x0": 0, - "true": 0, - x, - ...y, -}; diff --git a/test/rules/object-literal-key-quotes/always/test.ts.lint b/test/rules/object-literal-key-quotes/always/test.ts.lint deleted file mode 100644 index 9ccb80df382..00000000000 --- a/test/rules/object-literal-key-quotes/always/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -const o = { - 'hello': 123, - goodbye: 234, // failure - ~~~~~~~ [Unquoted property 'goodbye' found.] - "quote": 345, - "needs quote": 789, - "hyphens-need-quotes": null, - [computed]: 456, - 123: "hello", // failure - ~~~ [Unquoted property '123' found.] - 1e4: "something", // failure - ~~~ [Unquoted property '10000' found.] - .123: "float", // failure - ~~~~ [Unquoted property '0.123' found.] - '123': 'numbers do not need quotes', - '010': 'but this one does.', - '.123': 'as does this one', - fn() { return }, - ~~ [Unquoted property 'fn' found.] - true: 0, // failure - ~~~~ [Unquoted property 'true' found.] - "0x0": 0, - "true": 0, - x, - ...y, -}; diff --git a/test/rules/object-literal-key-quotes/always/tslint.json b/test/rules/object-literal-key-quotes/always/tslint.json deleted file mode 100644 index a7927997726..00000000000 --- a/test/rules/object-literal-key-quotes/always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-key-quotes": [true, "always"] - } -} diff --git a/test/rules/object-literal-key-quotes/as-needed/test.ts.fix b/test/rules/object-literal-key-quotes/as-needed/test.ts.fix deleted file mode 100644 index d4e6146b179..00000000000 --- a/test/rules/object-literal-key-quotes/as-needed/test.ts.fix +++ /dev/null @@ -1,23 +0,0 @@ -const o = { - hello: 123, // failure - goodbye: 234, - quote: 345, // failure - "needs quote": 789, - "hyphens-need-quotes": null, - [computed]: 456, - 123: "hello", - 1e4: "something", - .123: "float", - 123: 'numbers do not need quotes', // failure - 1.23: null, - '010': 'but this one does.', - '.123': 'as does this one', - '-1': 'and this one', - fn() { return }, - true: 0, - "0x0": 0, - true: 0, // failure - '': 'always quote the empty string', - x, - ...y, -}; diff --git a/test/rules/object-literal-key-quotes/as-needed/test.ts.lint b/test/rules/object-literal-key-quotes/as-needed/test.ts.lint deleted file mode 100644 index 3e4e2cefd43..00000000000 --- a/test/rules/object-literal-key-quotes/as-needed/test.ts.lint +++ /dev/null @@ -1,27 +0,0 @@ -const o = { - 'hello': 123, // failure - ~~~~~~~ [Unnecessarily quoted property 'hello' found.] - goodbye: 234, - "quote": 345, // failure - ~~~~~~~ [Unnecessarily quoted property 'quote' found.] - "needs quote": 789, - "hyphens-need-quotes": null, - [computed]: 456, - 123: "hello", - 1e4: "something", - .123: "float", - '123': 'numbers do not need quotes', // failure - ~~~~~ [Unnecessarily quoted property '123' found.] - 1.23: null, - '010': 'but this one does.', - '.123': 'as does this one', - '-1': 'and this one', - fn() { return }, - true: 0, - "0x0": 0, - "true": 0, // failure - ~~~~~~ [Unnecessarily quoted property 'true' found.] - '': 'always quote the empty string', - x, - ...y, -}; diff --git a/test/rules/object-literal-key-quotes/as-needed/tslint.json b/test/rules/object-literal-key-quotes/as-needed/tslint.json deleted file mode 100644 index a366a23efb2..00000000000 --- a/test/rules/object-literal-key-quotes/as-needed/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-key-quotes": [true, "as-needed"] - } -} diff --git a/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix b/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix deleted file mode 100644 index b15e40fea09..00000000000 --- a/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix +++ /dev/null @@ -1,43 +0,0 @@ - -const o = { - hello: 123, - bye: 45, -}; -const v = { - hello: 123, - bye: 45, -}; -const s = { - hello: 123, - bye: 45, -}; -const r = { - "hello": 123, - "bye-bye": 45, -}; -const p = { - hello: 123, - bye: 45, -}; -const q = { - "hello": 123, - "bye-bye": 45, -}; -const t = { - hello: 123, - nested: { - bird: 2, - egg: 3, - } -}; -const u = { - hello: 123, - bye: 45, - nested: { - bird: 1, - egg: 2, - } -}; -const v = { - ...o, -}; diff --git a/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint b/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint deleted file mode 100644 index f05f6777157..00000000000 --- a/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint +++ /dev/null @@ -1,52 +0,0 @@ - -const o = { - 'hello': 123, - ~~~~~~~ [Unnecessarily quoted property 'hello' found.] - "bye": 45, - ~~~~~ [Unnecessarily quoted property 'bye' found.] -}; -const v = { - "hello": 123, - ~~~~~~~ [Unnecessarily quoted property 'hello' found.] - "bye": 45, - ~~~~~ [Unnecessarily quoted property 'bye' found.] -}; -const s = { - hello: 123, - bye: 45, -}; -const r = { - "hello": 123, - "bye-bye": 45, -}; -const p = { - hello: 123, - "bye": 45, - ~~~~~ [Unnecessarily quoted property 'bye' found.] -}; -const q = { - hello: 123, - ~~~~~ [Unquoted property 'hello' found.] - "bye-bye": 45, -}; -const t = { - hello: 123, - nested: { - "bird": 2, - ~~~~~~ [Unnecessarily quoted property 'bird' found.] - egg: 3, - } -}; -const u = { - hello: 123, - bye: 45, - nested: { - "bird": 1, - ~~~~~~ [Unnecessarily quoted property 'bird' found.] - "egg": 2, - ~~~~~ [Unnecessarily quoted property 'egg' found.] - } -}; -const v = { - ...o, -}; diff --git a/test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json b/test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json deleted file mode 100644 index f125186828a..00000000000 --- a/test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-key-quotes": [true, "consistent-as-needed"] - } -} diff --git a/test/rules/object-literal-key-quotes/consistent/test.ts.lint b/test/rules/object-literal-key-quotes/consistent/test.ts.lint deleted file mode 100644 index d6404cc432e..00000000000 --- a/test/rules/object-literal-key-quotes/consistent/test.ts.lint +++ /dev/null @@ -1,43 +0,0 @@ - -const o = { - 'hello': 123, - "bye": 45, -}; -const v = { - "hello": 123, - "bye": 45, -}; -const s = { - hello: 123, - bye: 45, -}; -const r = { - "hello": 123, - "bye-bye": 45, -}; -const p = { - ~ [All property names in this object literal must be consistently quoted or unquoted.] - hello: 123, - "bye": 45, -}; -const q = { - ~ [All property names in this object literal must be consistently quoted or unquoted.] - hello: 123, - "bye-bye": 45, -}; -const t = { - hello: 123, - nested: { - ~ [All property names in this object literal must be consistently quoted or unquoted.] - "bird": 2, - egg: 3, - } -}; -const u = { - hello: 123, - bye: 45, - nested: { - "bird": 1, - "egg": 2, - } -}; \ No newline at end of file diff --git a/test/rules/object-literal-key-quotes/consistent/tslint.json b/test/rules/object-literal-key-quotes/consistent/tslint.json deleted file mode 100644 index e8d308b9b78..00000000000 --- a/test/rules/object-literal-key-quotes/consistent/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-key-quotes": [true, "consistent"] - } -} diff --git a/test/rules/object-literal-shorthand/always/test.ts.fix b/test/rules/object-literal-shorthand/always/test.ts.fix deleted file mode 100644 index edf1133d480..00000000000 --- a/test/rules/object-literal-shorthand/always/test.ts.fix +++ /dev/null @@ -1,43 +0,0 @@ -const bad = { - w() {}, - *x() {}, - [y]() {}, - z -}; - -const good = { - w() {}, - *x() {}, - [y]() {}, - z -}; - -const arrows = { - x: (y) => y // this is OK. -}; - -const namedFunctions = { - x: function y() {} // named function expressions are also OK. -}; - -const quotes = { - "foo-bar"() {}, - "foo-bar"() {} -}; - -const extraCases = { - x, - a: 123, - b: "hello", - c: 'c', - ["a" + "nested"]: { - x - } -}; - -const asyncFn = { - async foo() {}, - async *bar() {} -} - -({foo} = {foo}); diff --git a/test/rules/object-literal-shorthand/always/test.ts.lint b/test/rules/object-literal-shorthand/always/test.ts.lint deleted file mode 100644 index 8e887237eca..00000000000 --- a/test/rules/object-literal-shorthand/always/test.ts.lint +++ /dev/null @@ -1,55 +0,0 @@ -const bad = { - w: function() {}, - ~~~~~~~~~~~ [LONGHAND_METHOD % ("('{w() {...}}')")] - x: function *() {}, - ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{*x() {...}}')")] - [y]: function() {}, - ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{[y]() {...}}')")] - z: z - ~~~~ [Expected property shorthand in object literal ('{z}').] -}; - -const good = { - w() {}, - *x() {}, - [y]() {}, - z -}; - -const arrows = { - x: (y) => y // this is OK. -}; - -const namedFunctions = { - x: function y() {} // named function expressions are also OK. -}; - -const quotes = { - "foo-bar": function() {}, - ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{\"foo-bar\"() {...}}')")] - "foo-bar"() {} -}; - -const extraCases = { - x, - a: 123, - b: "hello", - c: 'c', - ["a" + "nested"]: { - x: x - ~~~~ [Expected property shorthand in object literal ('{x}').] - } -}; - -const asyncFn = { - foo: async function() {}, - ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async foo() {...}}')")] - bar: async function*() {} - ~~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async *bar() {...}}')")] -} - -({foo: foo} = {foo: foo}); - ~~~~~~~~ [LONGHAND_PROPERTY % ("('{foo}')")] - ~~~~~~~~ [LONGHAND_PROPERTY % ("('{foo}')")] -[LONGHAND_METHOD]: Expected method shorthand in object literal %s. -[LONGHAND_PROPERTY]: Expected property shorthand in object literal %s. diff --git a/test/rules/object-literal-shorthand/always/tslint.json b/test/rules/object-literal-shorthand/always/tslint.json deleted file mode 100644 index 3979c6d1466..00000000000 --- a/test/rules/object-literal-shorthand/always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-shorthand": [true, "always"] - } -} diff --git a/test/rules/object-literal-shorthand/never/test.ts.fix b/test/rules/object-literal-shorthand/never/test.ts.fix deleted file mode 100644 index 25576bcb9b1..00000000000 --- a/test/rules/object-literal-shorthand/never/test.ts.fix +++ /dev/null @@ -1,59 +0,0 @@ -const asyncFn = { - f: async function() { - await some_promise; - }, - fa: async function*() { - await some_promise; - } -}; - -const bad = { - w: function() { - const alsoBad = { - bad: bad, - }; - }, - x: function*() {}, - [y]: function() {}, - z: z, - nest: { - nestBad: function() {}, - nextGood: function(prop: string): void {} - } -}; - -const good = { - w: function() {}, - x: function *() {}, - [y]: function() {} -}; - -const arrows = { - x: (y) => y // this is OK. -}; - -const namedFunctions = { - x: function y() {} // named function expressions are also OK. -}; - -const quotes = { - "foo-bar": function() {}, - "foo-bar": function() {} -}; - -const extraCases = { - x: x, - a: 123, - b: "hello", - c: 'c', - ["a" + "nested"]: { - x: x - } -}; - -export class ClassA extends ClassZ { - testMethod() {} -} - -({foo: foo} = {foo: foo}); - diff --git a/test/rules/object-literal-shorthand/never/test.ts.lint b/test/rules/object-literal-shorthand/never/test.ts.lint deleted file mode 100644 index b6ea615c327..00000000000 --- a/test/rules/object-literal-shorthand/never/test.ts.lint +++ /dev/null @@ -1,72 +0,0 @@ -const asyncFn = { - async f() { - ~ [SHORTHAND_ASSIGNMENT] - await some_promise; - }, - async* fa() { - ~~ [SHORTHAND_ASSIGNMENT] - await some_promise; - } -}; - -const bad = { - w() { - ~ [SHORTHAND_ASSIGNMENT] - const alsoBad = { - bad, - ~~~ [SHORTHAND_ASSIGNMENT] - }; - }, - *x() {}, - ~ [SHORTHAND_ASSIGNMENT] - [y]() {}, - ~~~ [SHORTHAND_ASSIGNMENT] - z, - ~ [SHORTHAND_ASSIGNMENT] - nest: { - nestBad() {}, - ~~~~~~~ [SHORTHAND_ASSIGNMENT] - nextGood: function(prop: string): void {} - } -}; - -const good = { - w: function() {}, - x: function *() {}, - [y]: function() {} -}; - -const arrows = { - x: (y) => y // this is OK. -}; - -const namedFunctions = { - x: function y() {} // named function expressions are also OK. -}; - -const quotes = { - "foo-bar": function() {}, - "foo-bar"() {} - ~~~~~~~~~ [SHORTHAND_ASSIGNMENT] -}; - -const extraCases = { - x, - ~ [SHORTHAND_ASSIGNMENT] - a: 123, - b: "hello", - c: 'c', - ["a" + "nested"]: { - x: x - } -}; - -export class ClassA extends ClassZ { - testMethod() {} -} - -({foo} = {foo}); - ~~~ [SHORTHAND_ASSIGNMENT] - ~~~ [SHORTHAND_ASSIGNMENT] - -[SHORTHAND_ASSIGNMENT]: Shorthand property and method assignments have been disallowed. diff --git a/test/rules/object-literal-shorthand/never/tslint.json b/test/rules/object-literal-shorthand/never/tslint.json deleted file mode 100644 index 407e9d245b9..00000000000 --- a/test/rules/object-literal-shorthand/never/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "rules": { - "object-literal-shorthand": [true, "never"] - } - } - \ No newline at end of file diff --git a/test/rules/object-literal-shorthand/onlyMethods/test.ts.fix b/test/rules/object-literal-shorthand/onlyMethods/test.ts.fix deleted file mode 100644 index 47e0f714cf4..00000000000 --- a/test/rules/object-literal-shorthand/onlyMethods/test.ts.fix +++ /dev/null @@ -1,45 +0,0 @@ -const badMethodsGoodProps = { - w() {}, - *x() {}, - [y]() {}, - z: z -}; - -const goodMethodsBadProps = { - w() {}, - *x() {}, - [y]() {}, - z: z -}; - -const arrows = { - x: (y) => y // this is OK. -}; - -const namedFunctions = { - x: function y() {} // named function expressions are also OK. -}; - -const quotes = { - "foo-bar"() {}, - "foo-bar"() {} -}; - -const extraCases = { - x: x, - a: 123, - b: "hello", - c: 'c', - ["a" + "nested"]: { - x: x - } -}; - -const asyncFn = { - async foo() {}, - async *bar() {} -} - -({foo: foo} = {foo: foo}); -({foo: foo} = {foo: foo}); - diff --git a/test/rules/object-literal-shorthand/onlyMethods/test.ts.lint b/test/rules/object-literal-shorthand/onlyMethods/test.ts.lint deleted file mode 100644 index ffc9981c5d1..00000000000 --- a/test/rules/object-literal-shorthand/onlyMethods/test.ts.lint +++ /dev/null @@ -1,58 +0,0 @@ -const badMethodsGoodProps = { - w: function() {}, - ~~~~~~~~~~~ [LONGHAND_METHOD % ("('{w() {...}}')")] - x: function *() {}, - ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{*x() {...}}')")] - [y]: function() {}, - ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{[y]() {...}}')")] - z: z -}; - -const goodMethodsBadProps = { - w() {}, - *x() {}, - [y]() {}, - z - ~ [OBJECT_LITERAL_DISALLOWED] -}; - -const arrows = { - x: (y) => y // this is OK. -}; - -const namedFunctions = { - x: function y() {} // named function expressions are also OK. -}; - -const quotes = { - "foo-bar": function() {}, - ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{\"foo-bar\"() {...}}')")] - "foo-bar"() {} -}; - -const extraCases = { - x, - ~ [OBJECT_LITERAL_DISALLOWED] - a: 123, - b: "hello", - c: 'c', - ["a" + "nested"]: { - x: x - } -}; - -const asyncFn = { - foo: async function() {}, - ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async foo() {...}}')")] - bar: async function*() {} - ~~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async *bar() {...}}')")] -} - -({foo: foo} = {foo: foo}); -({foo} = {foo}); - ~~~ [OBJECT_LITERAL_DISALLOWED] - ~~~ [OBJECT_LITERAL_DISALLOWED] - -[OBJECT_LITERAL_DISALLOWED]: Shorthand property assignments have been disallowed. -[LONGHAND_METHOD]: Expected method shorthand in object literal %s. -[LONGHAND_PROPERTY]: Expected property shorthand in object literal %s. diff --git a/test/rules/object-literal-shorthand/onlyMethods/tslint.json b/test/rules/object-literal-shorthand/onlyMethods/tslint.json deleted file mode 100644 index fc32bc1d466..00000000000 --- a/test/rules/object-literal-shorthand/onlyMethods/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "object-literal-shorthand": [ - true, - { - "property": "never", - "method": "always" - } - ] - } -} diff --git a/test/rules/object-literal-sort-keys/default/crlf.ts.lint b/test/rules/object-literal-sort-keys/default/crlf.ts.lint deleted file mode 100644 index 1aea24abe6f..00000000000 --- a/test/rules/object-literal-sort-keys/default/crlf.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -// ensure that we don't treat \r\n as two line breaks -let obj = { - foo: 1, - bar: 2, - ~~~ [The key 'bar' is not sorted alphabetically] -} diff --git a/test/rules/object-literal-sort-keys/default/test.ts.lint b/test/rules/object-literal-sort-keys/default/test.ts.lint deleted file mode 100644 index 491a05b083b..00000000000 --- a/test/rules/object-literal-sort-keys/default/test.ts.lint +++ /dev/null @@ -1,319 +0,0 @@ -var passA = { - a: 1, - b: 2 -}; - -var failA = { - b: 1, - a: 2 - ~ [err % ('a')] -}; - -var passB = { - a: 1, - b: 2, - c: 3, - d: 4 -}; - -var failB = { - c: 3, - a: 1, - ~ [err % ('a')] - b: 2, - d: 4 -}; - -var passC = { - a: 1, - b: { - aa: 1, - bb: 2 - } -}; - -var failC = { - a: 1, - b: { - bb: 2, - aa: 1 - ~~ [err % ('aa')] - } -}; - -var passD = { - a: 1, - b: { - aa: 1, - bb: 2 - }, - c: 3 -}; - -var failD = { - a: 1, - c: { - aa: 1, - bb: 2 - }, - b: 3 - ~ [err % ('b')] -}; - -var passE = {}; - -var passF = { - asdf: [1, 2, 3], - sdfa: {} -}; - -var failF = { - sdfa: {}, - asdf: [1, 2, 3] - ~~~~ [err % ('asdf')] -}; - -var passG = { - asdfn: function () {}, - sdafn: function () {} -}; - -var failG = { - sdafn: function () {}, - asdfn: function () {} - ~~~~~ [err % ('asdfn')] -}; - -var passH = { - a: 1, - 'b': 2, - c: 3 -} - -var failH = { - 'b': 2, - a: 1, - ~ [err % ('a')] - c: 3 -} - -var passI = { - 'Z': 1, - À: 2, - è: 3 -} - -var failI = { - À: 2, - 'Z': 1, - ~~~ [err % ('Z')] - è: 3, -} - -var passJ = { - 1: 1, - '11': 2 - 2: 4, - A: 3, -} - -var failJ = { - 1: 1, - 2: 4, - A: 3, - '11': 2 - ~~~~ [err % ('11')] -} - -var passK = { - a: 1, - 'b': { - 'd': 4, - e: 5 - }, - c: 3 -} - -var failK = { - 'b': { - e: 5, - 'd': 4 - ~~~ [err % ('d')] - }, - a: 1, - ~ [err % ('a')] - c: 3 -} - -var passL = {z: 1, y: '1', x: [1, 2]}; - -var failL = {x: 1, y: { - b: 1, - a: 2 - ~ [err % ('a')] -}, z: [1, 2]}; - -var passM = { - x: 1, - y: { - a: 1, - b: 2 - }, - z: {z: 1, y: '1', x: [1, 2]} -}; - -const spread = { - c, - ...x, - b: b, - a, - ~ [err % ('a')] -}; - -const numbers = { - 1: true, - 2: true, - 100: true, - 1e4: true, - 2e-1: true, -} - -const a = { - array: [], - objList: [{}, {}], - object: {}, -} - -const b = { - array: [], - object: {}, - objList: [{}, {}], - ~~~~~~~ [err % ('objList')] -} - -var blankLineGroupingPassA = { - a: 1, - b: 2, - d: 4, - - c: 3, - e: 5, -}; - -var blankLineGroupingFailA = { - a: 1, - b: 2, - d: 4, - // non-empty line not counted as a new line - c: 3, - ~ [err % ('c')] - e: 5, -}; - -var blankLineGroupingPassB = { - a: 1, - b: 2, - d: 4, - // a comment - - c: 3, - e: 5, -}; - -var blankLineGroupingFailB = { - a: 1, - b: 2, - c: 3, - - f: 6, - e: 5, - ~ [err % ('e')] - d: 4 -}; - -var blankLineGroupingPassC = { - b: 1, - - // a single line comment before the group - a: 2, - c: 3, -}; - -var blankLineGroupingFailC = { - b: 1, - /* a multiline comment with - - an extra new line in the middle */ - a: 2, - ~ [err % ('a')] - c: 3, -}; - -var blankLineGroupingPassD = { - b: 1, - - /* a multiline comment with a new line before and - - an extra new line in the middle, before a group */ - a: 2, - c: 3, -}; - -var blankLineGroupingFailD = { - b: 1, - // a single-line comments - /* a multiline comment with - - an extra new line in the middle */ - a: 2, - ~ [err % ('a')] - c: 3, -}; - -var blankLineGroupingPassE = { - b: 1, - /* a multiline comment with a new line after and - - an extra new line in the middle */ - - a: 2, - c: 3, -}; - -var blankLineGroupingFailE = { - a: 1, - c: `3 is a - - multiline string`, - b: 2, - ~ [err % ('b')] - d: 4 -} - -var blankLineGroupingPassF = { - b: 1, - /* double multiline comments - - and a space between */ - - /* more talking - - here */ - a: 2, - c: 3, -}; - -var blankLineGroupingFailF = { - b: 1, - /* double multiline comments - - with no space between */ - /* more talking - - here */ - a: 2, - ~ [err % ('a')] - c: 3, -}; - -[err]: The key '%s' is not sorted alphabetically diff --git a/test/rules/object-literal-sort-keys/default/tslint.json b/test/rules/object-literal-sort-keys/default/tslint.json deleted file mode 100644 index 280382fe390..00000000000 --- a/test/rules/object-literal-sort-keys/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": true - } -} diff --git a/test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint b/test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint deleted file mode 100644 index 328b2911a5d..00000000000 --- a/test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -var testPassA = { - a: 'a', - - b: 'b', - - c: 'c', -}; - -var testFailA = { - b: 'b', - - a: 'a', - ~ [err % ('a')] - c: 'c', -}; - -var testFailB = { - a: 'a', - - c: 'c', - - b: 'b', - ~ [err % ('b')] -}; - -[err]: The key '%s' is not sorted alphabetically \ No newline at end of file diff --git a/test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json b/test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json deleted file mode 100644 index fd1360f919a..00000000000 --- a/test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": [true, "ignore-blank-lines"] - } -} diff --git a/test/rules/object-literal-sort-keys/ignore-case/test.ts.lint b/test/rules/object-literal-sort-keys/ignore-case/test.ts.lint deleted file mode 100644 index b706a1a6145..00000000000 --- a/test/rules/object-literal-sort-keys/ignore-case/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -const a = { - array: [], - objList: [{}, {}], - object: {}, - ~~~~~~ [The key 'object' is not sorted alphabetically] -} - -const b = { - array: [], - object: {}, - objList: [{}, {}], -} diff --git a/test/rules/object-literal-sort-keys/ignore-case/tslint.json b/test/rules/object-literal-sort-keys/ignore-case/tslint.json deleted file mode 100644 index 0e35ccdd33c..00000000000 --- a/test/rules/object-literal-sort-keys/ignore-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": [true, "ignore-case"] - } -} diff --git a/test/rules/object-literal-sort-keys/locale-compare/test.ts.lint b/test/rules/object-literal-sort-keys/locale-compare/test.ts.lint deleted file mode 100644 index df4899f4926..00000000000 --- a/test/rules/object-literal-sort-keys/locale-compare/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -const a = { - autor: 1, - título: 2, - type: 3 -} - -const b = { - autor: 1, - type: 3, - título: 2 - ~~~~~~ [The key 'título' is not sorted alphabetically] -} diff --git a/test/rules/object-literal-sort-keys/locale-compare/tslint.json b/test/rules/object-literal-sort-keys/locale-compare/tslint.json deleted file mode 100644 index 43f902bfea3..00000000000 --- a/test/rules/object-literal-sort-keys/locale-compare/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": [true, "locale-compare"] - } -} diff --git a/test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint b/test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint deleted file mode 100644 index 7064efedcfc..00000000000 --- a/test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint +++ /dev/null @@ -1,71 +0,0 @@ -interface I { - b; - a; -} - -declare function f(i: I): void; - -const a = 0, b = 0; - -f({ b, a }); - -f({ a, b }); - ~ [0 % ('b', 'I')] - -// Resets ordering after spread operator. - -f({ a, ...x, b }); - -f({ a, ...x, a, b }); - ~ [0 % ('b', 'I')] - - -// Methods and getters/setters work like any other key. - -f({ b() {}, a() {} }); - -f({ a() {}, b() {} }); - ~ [0 % ('b', 'I')] - -f({ - get b() {}, - a, - set b(v) {}, - ~ [0 % ('b', 'I')] -}); - -f({ - get b() {}, - set b() {}, - a, -}); - -// Ignores computed properties. Does not ignore string / number keys. - -interface J { - "foo"; - 2; - [Symol.iterator]; -} -declare function j(j: J): void; -j({ [Symbol.iterator]: 1, "foo": 1, 2: 1 }); -j({ [Symbol.iterator]: 1, 2: 1, "foo": 1 }); - ~~~~~ [0 % ('foo', 'J')] - -// Works with anonymous type too. -type T = { b, a }; -const o: T = { a, b }; - ~ [0 % ('b', 'T')] - -const o: { b, a } = { a, b }; - ~ [1 % ('b')] - -// Non-alphabetical ordering is fine, even if it can't find a type. - -const o = { - b, - a, -}; - -[0]: The key '%s' is not in the same order as it is in '%s'. -[1]: The key '%s' is not in the same order as it is in its type declaration. diff --git a/test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json b/test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json deleted file mode 100644 index 9e26dfeeb6e..00000000000 --- a/test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json b/test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json deleted file mode 100644 index c4100bcda48..00000000000 --- a/test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": [true, "ignore-case", "match-declaration-order-only"] - } -} diff --git a/test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint b/test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint deleted file mode 100644 index 3d2079221d1..00000000000 --- a/test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint +++ /dev/null @@ -1,72 +0,0 @@ -interface I { - b; - a; -} - -declare function f(i: I): void; - -const a = 0, b = 0; - -f({ b, a }); - -f({ a, b }); - ~ [0 % ('b', 'I')] - -// Resets ordering after spread operator. - -f({ a, ...x, b }); - -f({ a, ...x, a, b }); - ~ [0 % ('b', 'I')] - - -// Methods and getters/setters work like any other key. - -f({ b() {}, a() {} }); - -f({ a() {}, b() {} }); - ~ [0 % ('b', 'I')] - -f({ - get b() {}, - a, - set b(v) {}, - ~ [0 % ('b', 'I')] -}); - -f({ - get b() {}, - set b() {}, - a, -}); - -// Ignores computed properties. Does not ignore string / number keys. - -interface J { - "foo"; - 2; - [Symol.iterator]; -} -declare function j(j: J): void; -j({ [Symbol.iterator]: 1, "foo": 1, 2: 1 }); -j({ [Symbol.iterator]: 1, 2: 1, "foo": 1 }); - ~~~~~ [0 % ('foo', 'J')] - -// Works with anonymous type too. -type T = { b, a }; -const o: T = { a, b }; - ~ [0 % ('b', 'T')] - -const o: { b, a } = { a, b }; - ~ [1 % ('b')] - -// Goes with alphabetical ordering if it can't find a type. - -const o = { - b, - a, - ~ [The key 'a' is not sorted alphabetically] -}; - -[0]: The key '%s' is not in the same order as it is in '%s'. -[1]: The key '%s' is not in the same order as it is in its type declaration. diff --git a/test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json b/test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json deleted file mode 100644 index 9e26dfeeb6e..00000000000 --- a/test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/rules/object-literal-sort-keys/match-declaration-order/tslint.json b/test/rules/object-literal-sort-keys/match-declaration-order/tslint.json deleted file mode 100644 index c4d505791fe..00000000000 --- a/test/rules/object-literal-sort-keys/match-declaration-order/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": [true, "ignore-case", "match-declaration-order"] - } -} diff --git a/test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint b/test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint deleted file mode 100644 index 7dea783d978..00000000000 --- a/test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint +++ /dev/null @@ -1,79 +0,0 @@ -const a = 'a' -const c = 'c' -const x = {} - -const fail1 = { - a, - b: 'b', - c, - ~ [shorthandErr % ('c')] - d: 'd', -} - -const fail2 = { - c, - a, - ~ [alphaErr % ('a')] - b: 'b', - d: 'd', -} - -const fail3 = { - a, - c, - d: 'd', - b: 'b', - ~ [alphaErr % ('b')] -} - -const fail4 = { - c, - ...x, - a, - d: 'd', - b: 'b', - ~ [alphaErr % ('b')] -} - -const pass1 = { - a, - c, - b: 'b', - d: 'd', -} - -const pass2 = { - ...x, - a, - c, - b: 'b', - d: 'd', -} - -const pass3 = { - a, - c, - ...x, - b: 'b', - d: 'd', -} - -const pass4 = { - c, - ...x, - a, - b: 'b', - d: 'd', -} - -const pass5 = { - d: 'd', - ...x, - c, - ...x, - a, - b: 'b', -} - -[alphaErr]: The key '%s' is not sorted alphabetically -[shorthandErr]: The shorthand property '%s' should appear before normal properties diff --git a/test/rules/object-literal-sort-keys/shorthand-first/tslint.json b/test/rules/object-literal-sort-keys/shorthand-first/tslint.json deleted file mode 100644 index 9ba03e3c2c9..00000000000 --- a/test/rules/object-literal-sort-keys/shorthand-first/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "object-literal-sort-keys": [true, "shorthand-first"] - } -} diff --git a/test/rules/one-line/all/test.ts.fix b/test/rules/one-line/all/test.ts.fix deleted file mode 100644 index ccd729f9841..00000000000 --- a/test/rules/one-line/all/test.ts.fix +++ /dev/null @@ -1,152 +0,0 @@ -module Module { - export enum Enumeration { - A, - B, - C, - D - } - - export function Call() { - if (x == 3) { - x = 4; - } else { - x = 5; - } - return "called"; - } -} - -interface Class { - variable: string; -} - -var object = { - a: 1, - b: 2 -}; - -for(var x= 0; x < 1; ++x) { - ++i; -} - -switch(y) { - case 0: { - x--; - break; - } - default: - x++; - break; -} - -try { - throw new Error("hi"); -} catch (e) { - throw(e); -} finally { - // do something -} - -try { - foo(); -} finally { - bar(); -} - -try { - foo(); -} catch(e) { - bar(); -} finally { - baz(); -} - -while(x < 10) { - x++; -} - -function f(): - number { - - return 5; -} - -class BarBooBaz { - -} - -class FooBarBaz { -} - -// Valid multiline declarations -export class LongDescriptiveClassName, S> - extends SomeAbstractBaseClass implements IImportantInterface { -} - -export interface LongDescriptiveInterfaceName - extends AThirdInterface { -} - -function longFunctionNameWithLotsOfParams( - x: number, - y: number, - z: number, - a: T) { -} - -let geoConfig: { - maximumAge?: number; - timeout?: number; - enableHighAccuracy?: boolean; -} = { - maximumAge: 3000, - timeout: 5000, - enableHighAccuracy: false -}; - -declare module "*"; -declare module "someLibrary/*"; - -// No error if there are no braces -if (true) - true; -else - false; - -class Foo< - Bar, - Baz, - Bas -> { - // works for multiline type parameters -} - -type Foo = { - bar, -}; -type Bar = { bar }; -type Baz = { [K in T]: T }; -type Bas = "a"; - -{ - {}{}{} // just some random blocks -} - -if (true) { - true; -} else { - false; -} - -// don't crash on parse error -interface InvalidInterface = { - foo: string, -} - -class InvalidClass = { - foo: string, -} - -foo = class InvalidClassExpression = { - foo: string, -} diff --git a/test/rules/one-line/all/test.ts.lint b/test/rules/one-line/all/test.ts.lint deleted file mode 100644 index 15ec7d1ccf0..00000000000 --- a/test/rules/one-line/all/test.ts.lint +++ /dev/null @@ -1,197 +0,0 @@ -module Module -{ -~ [misplaced opening brace] - export enum Enumeration - { - ~ [misplaced opening brace] - A, - B, - C, - D - } - - export function Call() - { - ~ [misplaced opening brace] - if (x == 3) - { - ~ [misplaced opening brace] - x = 4; - } - else { - ~~~~ [misplaced 'else'] - x = 5; - } - return "called"; - } -} - -interface Class -{ -~ [misplaced opening brace] - variable: string; -} - -var object = -{ -~ [misplaced opening brace] - a: 1, - b: 2 -}; - -for(var x= 0; x < 1; ++x) -{ -~ [misplaced opening brace] - ++i; -} - -switch(y) -{ -~ [misplaced opening brace] - case 0: - { - ~ [misplaced opening brace] - x--; - break; - } - default: - x++; - break; -} - -try -{ -~ [misplaced opening brace] - throw new Error("hi"); -} -catch (e) -~~~~~ [misplaced 'catch'] -{ -~ [misplaced opening brace] - throw(e); -} -finally -~~~~~~~ [misplaced 'finally'] -{ -~ [misplaced opening brace] - // do something -} - -try { - foo(); -} -finally -~~~~~~~ [misplaced 'finally'] -{ -~ [misplaced opening brace] - bar(); -} - -try{ - ~ [missing whitespace] - foo(); -} catch(e){ - ~ [missing whitespace] - bar(); -} finally{ - ~ [missing whitespace] - baz(); -} - -while(x < 10){ - ~ [missing whitespace] - x++; -} - -function f(): - number { - - return 5; -} - -class BarBooBaz -{ -~ [misplaced opening brace] - -} - -class FooBarBaz { -} - -// Valid multiline declarations -export class LongDescriptiveClassName, S> - extends SomeAbstractBaseClass implements IImportantInterface { -} - -export interface LongDescriptiveInterfaceName - extends AThirdInterface { -} - -function longFunctionNameWithLotsOfParams( - x: number, - y: number, - z: number, - a: T) { -} - -let geoConfig: { - maximumAge?: number; - timeout?: number; - enableHighAccuracy?: boolean; -} = { - maximumAge: 3000, - timeout: 5000, - enableHighAccuracy: false -}; - -declare module "*"; -declare module "someLibrary/*"; - -// No error if there are no braces -if (true) - true; -else - false; - -class Foo< - Bar, - Baz, - Bas -> { - // works for multiline type parameters -} - -type Foo = { - bar, -}; -type Bar = -{ bar }; -~ [misplaced opening brace] -type Baz = -{ [K in T]: T }; -~ [misplaced opening brace] -type Bas = "a"; - -{ - {}{}{} // just some random blocks -} - -if (true) { - true; -}else { - ~~~~ [missing whitespace] - false; -} - -// don't crash on parse error -interface InvalidInterface = { - foo: string, -} - -class InvalidClass = { - foo: string, -} - -foo = class InvalidClassExpression = { - foo: string, -} diff --git a/test/rules/one-line/all/tslint.json b/test/rules/one-line/all/tslint.json deleted file mode 100644 index d8a064cc2e5..00000000000 --- a/test/rules/one-line/all/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-finally", "check-whitespace"] - } -} diff --git a/test/rules/one-line/no-whitespace/test.ts.fix b/test/rules/one-line/no-whitespace/test.ts.fix deleted file mode 100644 index e4e1ceb0770..00000000000 --- a/test/rules/one-line/no-whitespace/test.ts.fix +++ /dev/null @@ -1,132 +0,0 @@ -module Module{ - export enum Enumeration{ - A, - B, - C, - D - } - - export function Call(){ - if (x == 3){ - x = 4; - }else { - x = 5; - } - return "called"; - } -} - -interface Class{ - variable: string; -} - -var object ={ - a: 1, - b: 2 -}; - -for(var x= 0; x < 1; ++x){ - ++i; -} - -switch(y){ - case 0: - x--; - break; - default: - x++; - break; -} - -try{ - throw new Error("hi"); -}catch (e){ - throw(e); -}finally{ - // do something -} - -try { - foo(); -}finally{ - bar(); -} - -try{ - foo(); -} catch(e){ - bar(); -} finally{ - baz(); -} - -while(x < 10){ - x++; -} - -function f(): - number { - - return 5; -} - -class BarBooBaz{ - -} - -class FooBarBaz { -} - -// Valid multiline declarations -export class LongDescriptiveClassName, S> - extends SomeAbstractBaseClass implements IImportantInterface { -} - -export interface LongDescriptiveInterfaceName - extends AThirdInterface { -} - -function longFunctionNameWithLotsOfParams( - x: number, - y: number, - z: number, - a: T) { -} - -let geoConfig: { - maximumAge?: number; - timeout?: number; - enableHighAccuracy?: boolean; -} = { - maximumAge: 3000, - timeout: 5000, - enableHighAccuracy: false -}; - -declare module "*"; -declare module "someLibrary/*"; - -// No error if there are no braces -if (true) - true; -else - false; - -class Foo< - Bar, - Baz, - Bas -> { - // works for multiline type parameters -} - -type Foo = { - bar, -}; -type Bar ={ bar }; -type Baz ={ [K in T]: T }; -type Bas = "a"; - -{ - {}{}{} // just some random blocks -} diff --git a/test/rules/one-line/no-whitespace/test.ts.lint b/test/rules/one-line/no-whitespace/test.ts.lint deleted file mode 100644 index 6ed6e4de9a2..00000000000 --- a/test/rules/one-line/no-whitespace/test.ts.lint +++ /dev/null @@ -1,170 +0,0 @@ -module Module -{ -~ [misplaced opening brace] - export enum Enumeration - { - ~ [misplaced opening brace] - A, - B, - C, - D - } - - export function Call() - { - ~ [misplaced opening brace] - if (x == 3) - { - ~ [misplaced opening brace] - x = 4; - } - else { - ~~~~ [misplaced 'else'] - x = 5; - } - return "called"; - } -} - -interface Class -{ -~ [misplaced opening brace] - variable: string; -} - -var object = -{ -~ [misplaced opening brace] - a: 1, - b: 2 -}; - -for(var x= 0; x < 1; ++x) -{ -~ [misplaced opening brace] - ++i; -} - -switch(y) -{ -~ [misplaced opening brace] - case 0: - x--; - break; - default: - x++; - break; -} - -try -{ -~ [misplaced opening brace] - throw new Error("hi"); -} -catch (e) -~~~~~ [misplaced 'catch'] -{ -~ [misplaced opening brace] - throw(e); -} -finally -~~~~~~~ [misplaced 'finally'] -{ -~ [misplaced opening brace] - // do something -} - -try { - foo(); -} -finally -~~~~~~~ [misplaced 'finally'] -{ -~ [misplaced opening brace] - bar(); -} - -try{ - foo(); -} catch(e){ - bar(); -} finally{ - baz(); -} - -while(x < 10){ - x++; -} - -function f(): - number { - - return 5; -} - -class BarBooBaz -{ -~ [misplaced opening brace] - -} - -class FooBarBaz { -} - -// Valid multiline declarations -export class LongDescriptiveClassName, S> - extends SomeAbstractBaseClass implements IImportantInterface { -} - -export interface LongDescriptiveInterfaceName - extends AThirdInterface { -} - -function longFunctionNameWithLotsOfParams( - x: number, - y: number, - z: number, - a: T) { -} - -let geoConfig: { - maximumAge?: number; - timeout?: number; - enableHighAccuracy?: boolean; -} = { - maximumAge: 3000, - timeout: 5000, - enableHighAccuracy: false -}; - -declare module "*"; -declare module "someLibrary/*"; - -// No error if there are no braces -if (true) - true; -else - false; - -class Foo< - Bar, - Baz, - Bas -> { - // works for multiline type parameters -} - -type Foo = { - bar, -}; -type Bar = -{ bar }; -~ [misplaced opening brace] -type Baz = -{ [K in T]: T }; -~ [misplaced opening brace] -type Bas = "a"; - -{ - {}{}{} // just some random blocks -} diff --git a/test/rules/one-line/no-whitespace/tslint.json b/test/rules/one-line/no-whitespace/tslint.json deleted file mode 100644 index 80fd92e4cd0..00000000000 --- a/test/rules/one-line/no-whitespace/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-finally"] - } -} diff --git a/test/rules/one-line/none/test.ts.lint b/test/rules/one-line/none/test.ts.lint deleted file mode 100644 index 1e974841c1f..00000000000 --- a/test/rules/one-line/none/test.ts.lint +++ /dev/null @@ -1,130 +0,0 @@ -module Module -{ - export enum Enumeration - { - A, - B, - C, - D - } - - export function Call() - { - if (x == 3) - { - x = 4; - } - else { - x = 5; - } - return "called"; - } -} - -interface Class -{ - variable: string; -} - -var object = -{ - a: 1, - b: 2 -}; - -for(var x= 0; x < 1; ++x) -{ - ++i; -} - -switch(y) -{ - case 0: - x--; - break; - default: - x++; - break; -} - -try -{ - throw new Error("hi"); -} -catch (e) -{ - throw(e); -} -finally -{ - // do something -} - -try { - foo(); -} -finally -{ - bar(); -} - -try{ - foo(); -} catch(e){ - bar(); -} finally{ - baz(); -} - -while(x < 10){ - x++; -} - -function f(): - number { - - return 5; -} - -class BarBooBaz -{ - -} - -class FooBarBaz { -} - -// Valid multiline declarations -export class LongDescriptiveClassName, S> - extends SomeAbstractBaseClass implements IImportantInterface { -} - -export interface LongDescriptiveInterfaceName - extends AThirdInterface { -} - -function longFunctionNameWithLotsOfParams( - x: number, - y: number, - z: number, - a: T) { -} - -let geoConfig: { - maximumAge?: number; - timeout?: number; - enableHighAccuracy?: boolean; -} = { - maximumAge: 3000, - timeout: 5000, - enableHighAccuracy: false -}; - -declare module "*"; -declare module "someLibrary/*"; - -// No error if there are no braces -if (true) - true; -else - false; diff --git a/test/rules/one-line/none/tslint.json b/test/rules/one-line/none/tslint.json deleted file mode 100644 index ea05ac32938..00000000000 --- a/test/rules/one-line/none/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "one-line": true - } -} diff --git a/test/rules/one-variable-per-declaration/default/test.ts.lint b/test/rules/one-variable-per-declaration/default/test.ts.lint deleted file mode 100644 index 8869d8a119a..00000000000 --- a/test/rules/one-variable-per-declaration/default/test.ts.lint +++ /dev/null @@ -1,45 +0,0 @@ -// valid cases -var foo1; -var foo2: number; -var foo3 = 1; - -let foo4; -let foo5: number; -let foo6 = 1; - -const foo7: number = 1; -const foo8 = 1; - -for (var i = 0; i > 1; i++) {} -for (let i = 0; i > 1; i++) {} -for (const i = 0; i > 1;) {} - -// invalid cases -var foo9, foo10; -~~~~~~~~~~~~~~~~ [0] -var foo11: number, foo12: number; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -var foo13 = 1, foo14 = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -let foo15, foo16; -~~~~~~~~~~~~~~~~~ [0] -let foo17: number, foo18: number; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let foo19 = 1, foo20 = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const foo21: number = 1, foo22: number = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -const foo23 = 1, foo24 = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -for (var i = 0, j = 0; i > 1; i++) {} - ~~~~~~~~~~~~~~~~ [0] -for (let i = 0, j = 0; i > 1; i++) {} - ~~~~~~~~~~~~~~~~ [0] -for (const i = 0, j = 0; i > 1;) {} - ~~~~~~~~~~~~~~~~~~ [0] - -[0]: Multiple variable declarations in the same statement are forbidden - diff --git a/test/rules/one-variable-per-declaration/default/tslint.json b/test/rules/one-variable-per-declaration/default/tslint.json deleted file mode 100644 index 3d64c8fa578..00000000000 --- a/test/rules/one-variable-per-declaration/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "one-variable-per-declaration": true - } -} diff --git a/test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint b/test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint deleted file mode 100644 index 44d835fef07..00000000000 --- a/test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint +++ /dev/null @@ -1,30 +0,0 @@ -// valid cases -for (var i = 0; i > 1; i++) {} -for (let i = 0; i > 1; i++) {} -for (const i = 0; i > 1;) {} -for (var i = 0, j = 0; i > 1; i++) {} -for (let i = 0, j = 0; i > 1; i++) {} -for (const i = 0, j = 0; i > 1;) {} - -// invalid cases -var foo1, foo2; -~~~~~~~~~~~~~~~ [0] -var foo3: number, foo4: number; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -var foo5 = 1, foo6 = 1; -~~~~~~~~~~~~~~~~~~~~~~~ [0] - -let foo7, foo8; -~~~~~~~~~~~~~~~ [0] -let foo9: number, foo10: number; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -let foo11 = 1, foo12 = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const foo13: number = 1, foo14: number = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -const foo15 = 1, foo16 = 1; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: Multiple variable declarations in the same statement are forbidden - diff --git a/test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json b/test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json deleted file mode 100644 index 657afeded5d..00000000000 --- a/test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "one-variable-per-declaration": [true, - "ignore-for-loop" - ] - } -} diff --git a/test/rules/only-arrow-functions/allow-declarations/test.ts.lint b/test/rules/only-arrow-functions/allow-declarations/test.ts.lint deleted file mode 100644 index 6b0ce7a08a8..00000000000 --- a/test/rules/only-arrow-functions/allow-declarations/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -function foo(a: any) : any { - return; -} - -let a = () => {}; -let b = function () {}; - ~~~~~~~~ [0] - -function c() {} - -function () { - // ... -} - -((func) => func())(function e(): void {}); - ~~~~~~~~ [0] - -((func) => func())(() => {}); - -function* generator() {} -let generator = function*() {} - -function hasThisParameter(this) {} -let hasThisParameter = function(this) {} - -[0]: non-arrow functions are forbidden diff --git a/test/rules/only-arrow-functions/allow-declarations/tslint.json b/test/rules/only-arrow-functions/allow-declarations/tslint.json deleted file mode 100644 index 89262ad4c12..00000000000 --- a/test/rules/only-arrow-functions/allow-declarations/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "only-arrow-functions": [true, "allow-declarations"] - } -} diff --git a/test/rules/only-arrow-functions/allow-named-functions/test.ts.lint b/test/rules/only-arrow-functions/allow-named-functions/test.ts.lint deleted file mode 100644 index 6563488db2b..00000000000 --- a/test/rules/only-arrow-functions/allow-named-functions/test.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -const x = function() {} - ~~~~~~~~ [0] -const y = function y() {} - -function z() {} - -[0]: non-arrow functions are forbidden diff --git a/test/rules/only-arrow-functions/allow-named-functions/tslint.json b/test/rules/only-arrow-functions/allow-named-functions/tslint.json deleted file mode 100644 index f63eab14bd9..00000000000 --- a/test/rules/only-arrow-functions/allow-named-functions/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "only-arrow-functions": [true, "allow-named-functions"] - } -} diff --git a/test/rules/only-arrow-functions/default/test.ts.lint b/test/rules/only-arrow-functions/default/test.ts.lint deleted file mode 100644 index 19bc9c36cb7..00000000000 --- a/test/rules/only-arrow-functions/default/test.ts.lint +++ /dev/null @@ -1,47 +0,0 @@ -function foo(a: any) : any { -~~~~~~~~ [0] - return; -} - -let a = () => {}; -let b = function () {}; - ~~~~~~~~ [0] - -function c() {} -~~~~~~~~ [0] - -function () { -~~~~~~~~ [0] - // ... -} - -((func) => func())(function e(): void {}); - ~~~~~~~~ [0] - -((func) => func())(() => {}); - -function* generator() {} -let generator = function*() {} - -function hasThisParameter(this) {} -let hasThisParameter = function(this) {} - -let usesThis = function() { this; } -let usesThis2 = function(foo = this) {} - -let notUsesThis = function() { - ~~~~~~~~ [0] - function f() { this; } -} -let notUsesThis2 = function() { - ~~~~~~~~ [0] - return class { method() { this; } } -} - -export function exported() {} - ~~~~~~~~ [0] - -async function asyncFunction() {} - ~~~~~~~~ [0] - -[0]: non-arrow functions are forbidden diff --git a/test/rules/only-arrow-functions/default/tslint.json b/test/rules/only-arrow-functions/default/tslint.json deleted file mode 100644 index 2e69b360a49..00000000000 --- a/test/rules/only-arrow-functions/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "only-arrow-functions": true - } -} diff --git a/test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix b/test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix deleted file mode 100644 index 31b9a3fddf0..00000000000 --- a/test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix +++ /dev/null @@ -1,48 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {A, B} from 'foo'; // failure - -// Case is irrelevant for named import ordering. -import {A, bz, C} from 'foo'; // failure -import {A, b, C} from 'zfoo'; - -// Underscores come first. -import {_b, A, C, d} from 'zfoo'; // failure -import {_b, A, C, d} from 'zfoo'; - -import {g} from "y"; // failure -import { - a as d, - b as c, -} from "z"; - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as bar from 'bar'; // failure -import * as foo from 'foo'; - -// ignore quotes -import * as bar from 'bar'; -import * as foo from "foo"; - -import * as bar from "bar"; -import * as foo from 'foo'; - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault from "module"; -import "something"; -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; - -// do not fix cases where a newline is missing -import * as foo from 'foo'; import * as bar from 'bar'; - -import * as bar from 'bar'; -import * as foo from 'foo'; diff --git a/test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint b/test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint deleted file mode 100644 index 1ab7bbe5114..00000000000 --- a/test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint +++ /dev/null @@ -1,61 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {B, A} from 'foo'; // failure - ~~~~ [ordered-imports] - -// Case is irrelevant for named import ordering. -import {A, b, C} from 'zfoo'; -import {bz, A, C} from 'foo'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - ~~~~~ [Named imports must be alphabetized.] - -// Underscores come first. -import {A, _b, C, d} from 'zfoo'; // failure - ~~~~~ [Named imports must be alphabetized.] -import {_b, A, C, d} from 'zfoo'; - -import { - b as c, - ~~~~~~~ - a as d, -~~~~~~~~~~ [Named imports must be alphabetized.] -} from "z"; -import {g} from "y"; // failure -~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as foo from 'foo'; -import * as bar from 'bar'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -// ignore quotes -import * as bar from 'bar'; -import * as foo from "foo"; - -import * as bar from "bar"; -import * as foo from 'foo'; - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import "something"; - -// do not fix cases where a newline is missing -import * as foo from 'foo'; import * as bar from 'bar'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -import * as foo from 'foo'; -import * as bar from 'bar'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -[ordered-imports]: Named imports must be alphabetized. -[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/case-insensitive-legacy/tslint.json b/test/rules/ordered-imports/case-insensitive-legacy/tslint.json deleted file mode 100644 index 611601029ac..00000000000 --- a/test/rules/ordered-imports/case-insensitive-legacy/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, - { - "import-sources-order": "case-insensitive-legacy", - "named-imports-order": "case-insensitive-legacy" - } - ] - } -} diff --git a/test/rules/ordered-imports/case-insensitive/test.ts.fix b/test/rules/ordered-imports/case-insensitive/test.ts.fix deleted file mode 100644 index 11a5c889203..00000000000 --- a/test/rules/ordered-imports/case-insensitive/test.ts.fix +++ /dev/null @@ -1,48 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {A, B} from 'foo'; // failure - -// Case is irrelevant for named import ordering. -import {A, bz, C} from 'foo'; // failure -import {A, b, C} from 'zfoo'; - -// Underscores come last. -import {A, C, d, _b} from 'zfoo'; // failure -import {A, C, d, _b} from 'zfoo'; - -import {g} from "y"; // failure -import { - a as d, - b as c, -} from "z"; - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as bar from 'bar'; // failure -import * as foo from 'foo'; - -// ignore quotes -import * as bar from 'bar'; -import * as foo from "foo"; - -import * as bar from "bar"; -import * as foo from 'foo'; - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault from "module"; -import "something"; -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; - -// do not fix cases where a newline is missing -import * as foo from 'foo'; import * as bar from 'bar'; - -import * as bar from 'bar'; -import * as foo from 'foo'; diff --git a/test/rules/ordered-imports/case-insensitive/test.ts.lint b/test/rules/ordered-imports/case-insensitive/test.ts.lint deleted file mode 100644 index ee69fe602f0..00000000000 --- a/test/rules/ordered-imports/case-insensitive/test.ts.lint +++ /dev/null @@ -1,61 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {B, A} from 'foo'; // failure - ~~~~ [ordered-imports] - -// Case is irrelevant for named import ordering. -import {A, b, C} from 'zfoo'; -import {bz, A, C} from 'foo'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - ~~~~~ [Named imports must be alphabetized.] - -// Underscores come last. -import {A, _b, C, d} from 'zfoo'; // failure - ~~~~~ [Named imports must be alphabetized.] -import {A, C, d, _b} from 'zfoo'; - -import { - b as c, - ~~~~~~~ - a as d, -~~~~~~~~~~ [Named imports must be alphabetized.] -} from "z"; -import {g} from "y"; // failure -~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as foo from 'foo'; -import * as bar from 'bar'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -// ignore quotes -import * as bar from 'bar'; -import * as foo from "foo"; - -import * as bar from "bar"; -import * as foo from 'foo'; - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import "something"; - -// do not fix cases where a newline is missing -import * as foo from 'foo'; import * as bar from 'bar'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -import * as foo from 'foo'; -import * as bar from 'bar'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -[ordered-imports]: Named imports must be alphabetized. -[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/case-insensitive/tslint.json b/test/rules/ordered-imports/case-insensitive/tslint.json deleted file mode 100644 index 714e6c81bc9..00000000000 --- a/test/rules/ordered-imports/case-insensitive/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": true - } -} diff --git a/test/rules/ordered-imports/grouped-imports/test.ts.fix b/test/rules/ordered-imports/grouped-imports/test.ts.fix deleted file mode 100644 index 13a8cc71812..00000000000 --- a/test/rules/ordered-imports/grouped-imports/test.ts.fix +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node -/* Test the case where import should be grouped using default grouping. */ - -import {afoo, foo} from 'foo'; -import x = require('y'); - -import {bar} from '../bar'; - -import './baa'; -import './baz'; // required -import './caa'; - -export class Test {} diff --git a/test/rules/ordered-imports/grouped-imports/test.ts.lint b/test/rules/ordered-imports/grouped-imports/test.ts.lint deleted file mode 100644 index 321bbc51bde..00000000000 --- a/test/rules/ordered-imports/grouped-imports/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node -/* Test the case where import should be grouped using default grouping. */ - -import {bar} from '../bar'; - -import {foo, afoo} from 'foo'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: libraries, parent directories, current directory.] - ~~~~~~~~~ [Named imports must be alphabetized.] - -import './baz'; // required -import './baa'; -~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -import './caa'; - -import x = require('y'); - -export class Test {} diff --git a/test/rules/ordered-imports/grouped-imports/tslint.json b/test/rules/ordered-imports/grouped-imports/tslint.json deleted file mode 100644 index 307aed99054..00000000000 --- a/test/rules/ordered-imports/grouped-imports/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "grouped-imports": true - }] - } -} diff --git a/test/rules/ordered-imports/groups-complex/test.ts.fix b/test/rules/ordered-imports/groups-complex/test.ts.fix deleted file mode 100644 index f9ee5865e32..00000000000 --- a/test/rules/ordered-imports/groups-complex/test.ts.fix +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node -/* Test a more complex set of split up groups. */ - -// comment outside of imports -import {afoo, foo} from 'foo'; -import x = require('y'); - -import {app_b} from 'app/bar'; -import {app_f} from 'app/foo'; - -// comment pkg/bar -import {a} from '@pkg/bar'; -import {x} from '@pkg/foo'; - -import './baa'; -import './baz'; // required - -import {bar} from '../bar'; -import {xbar} from '../xbar'; -x.fnCall(); - - - -export class Test {} diff --git a/test/rules/ordered-imports/groups-complex/test.ts.lint b/test/rules/ordered-imports/groups-complex/test.ts.lint deleted file mode 100644 index 36772342a19..00000000000 --- a/test/rules/ordered-imports/groups-complex/test.ts.lint +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node -/* Test a more complex set of split up groups. */ - -// comment outside of imports -import {app_f} from 'app/foo'; -import {x} from '@pkg/foo'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: extra, /^app/, /^@pkg/, current dir, parent_dir.] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -import {app_b} from 'app/bar'; -// comment pkg/bar -import {a} from '@pkg/bar'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -import {xbar} from '../xbar'; - -import {bar} from '../bar'; - -import {foo, afoo} from 'foo'; - ~~~~~~~~~ [Named imports must be alphabetized.] - -import x = require('y'); -x.fnCall(); - -import './baz'; // required -import './baa'; -~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - - -export class Test {} diff --git a/test/rules/ordered-imports/groups-complex/tslint.json b/test/rules/ordered-imports/groups-complex/tslint.json deleted file mode 100644 index dd444e141fc..00000000000 --- a/test/rules/ordered-imports/groups-complex/tslint.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, - { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "grouped-imports": true, - "groups": [ - { "match": "^app", "order": 20 }, - { "match": "^@pkg", "order": 30 }, - { "name": "parent_dir", "match": "^\\.\\.", "order": 50 }, - { "name": "current dir", "match": "^\\.", "order": 40 }, - { "name": "extra", "match": ".*", "order": 5 } - ] - } - ] - } -} diff --git a/test/rules/ordered-imports/groups-shared-order/test.ts.fix b/test/rules/ordered-imports/groups-shared-order/test.ts.fix deleted file mode 100644 index 7a50b6b2858..00000000000 --- a/test/rules/ordered-imports/groups-shared-order/test.ts.fix +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node -/* Test the case where multiple matches have the same order value. */ - -import {y} from 'app_a/bar'; -import {x} from 'app_a/foo'; -import {f} from 'app_b/foo'; - -import {b} from '@pkg/bar'; -import {a} from '@pkg/foo'; - -import {o} from 'other/bar'; - -export class Test {} diff --git a/test/rules/ordered-imports/groups-shared-order/test.ts.lint b/test/rules/ordered-imports/groups-shared-order/test.ts.lint deleted file mode 100644 index 1d518fd824f..00000000000 --- a/test/rules/ordered-imports/groups-shared-order/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node -/* Test the case where multiple matches have the same order value. */ - -import {f} from 'app_b/foo'; -import {x} from 'app_a/foo'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import {y} from 'app_a/bar'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - - -import {a} from '@pkg/foo'; - -import {b} from '@pkg/bar'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: /^app_b/, /^app_a/, /^@pkg/.] - -import {o} from 'other/bar'; - -export class Test {} diff --git a/test/rules/ordered-imports/groups-shared-order/tslint.json b/test/rules/ordered-imports/groups-shared-order/tslint.json deleted file mode 100644 index f74cab4f9ca..00000000000 --- a/test/rules/ordered-imports/groups-shared-order/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, - { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "grouped-imports": true, - "groups": [ - { "match": "^app_b", "order": 10 }, - { "match": "^app_a", "order": 10 }, - { "match": "^@pkg", "order": 20 } - ] - } - ] - } -} diff --git a/test/rules/ordered-imports/groups-string-list/test.ts.fix b/test/rules/ordered-imports/groups-string-list/test.ts.fix deleted file mode 100644 index c8a7d7bca4a..00000000000 --- a/test/rules/ordered-imports/groups-string-list/test.ts.fix +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node -/* Test import grouping where only a list or regex strings is passed to config. */ - -import { app_b } from "app/bar"; -import { app_f } from "app/foo"; - -import { a } from "@pkg/bar"; -import { x } from "@pkg/foo"; - -import { bar } from "../bar"; -import { xbar } from "../xbar"; - -import "./baa"; -import "./baz"; - -import { foo } from "foo"; - -export class Test {} diff --git a/test/rules/ordered-imports/groups-string-list/test.ts.lint b/test/rules/ordered-imports/groups-string-list/test.ts.lint deleted file mode 100644 index 28d518d3cb6..00000000000 --- a/test/rules/ordered-imports/groups-string-list/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env node -/* Test import grouping where only a list or regex strings is passed to config. */ - -import { x } from "@pkg/foo"; -import { app_f } from "app/foo"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: /^app/, /^@pkg/, /^\.\./, /^\./.] - -import { a } from "@pkg/bar"; -import { app_b } from "app/bar"; - -import { xbar } from "../xbar"; - -import { bar } from "../bar"; - -import { foo } from "foo"; - -import "./baa"; -import "./baz"; - -export class Test {} diff --git a/test/rules/ordered-imports/groups-string-list/tslint.json b/test/rules/ordered-imports/groups-string-list/tslint.json deleted file mode 100644 index cf049d8e990..00000000000 --- a/test/rules/ordered-imports/groups-string-list/tslint.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, - { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "grouped-imports": true, - "groups": ["^app", "^@pkg", "^\\.\\.", "^\\."] - } - ] - } -} diff --git a/test/rules/ordered-imports/groups-unmatched/test.ts.fix b/test/rules/ordered-imports/groups-unmatched/test.ts.fix deleted file mode 100644 index 5cd8ca747ea..00000000000 --- a/test/rules/ordered-imports/groups-unmatched/test.ts.fix +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env node -/* Test to check that all unmatched imports end up in unmatched group at end.*/ - -import {app_b} from 'app/bar'; -import {app_f} from 'app/foo'; - -import {a} from '@pkg/bar'; -import {x} from '@pkg/foo'; - -import {foo} from 'foo'; -import {xbar} from '../xbar'; -import {b} from './ybar'; - -export class Test {} diff --git a/test/rules/ordered-imports/groups-unmatched/test.ts.lint b/test/rules/ordered-imports/groups-unmatched/test.ts.lint deleted file mode 100644 index bc1dd250ff1..00000000000 --- a/test/rules/ordered-imports/groups-unmatched/test.ts.lint +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node -/* Test to check that all unmatched imports end up in unmatched group at end.*/ - -import {app_f} from 'app/foo'; - -import {x} from '@pkg/foo'; - -import {app_b} from 'app/bar'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: /^app/, /^@pkg/.] - -import {a} from '@pkg/bar'; - -import {xbar} from '../xbar'; - -import {foo} from 'foo'; -import {b} from './ybar'; - -export class Test {} diff --git a/test/rules/ordered-imports/groups-unmatched/tslint.json b/test/rules/ordered-imports/groups-unmatched/tslint.json deleted file mode 100644 index 7b810a8f933..00000000000 --- a/test/rules/ordered-imports/groups-unmatched/tslint.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, - { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "grouped-imports": true, - "groups": [{ "match": "^app", "order": 20 }, { "match": "^@pkg", "order": 30 }] - } - ] - } -} diff --git a/test/rules/ordered-imports/import-sources-any/default/test.ts.fix b/test/rules/ordered-imports/import-sources-any/default/test.ts.fix deleted file mode 100644 index 36552bd9588..00000000000 --- a/test/rules/ordered-imports/import-sources-any/default/test.ts.fix +++ /dev/null @@ -1,31 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {A, B} from 'foo'; // failure - -// Case is irrelevant for named import ordering. -import {A, b, C} from 'zfoo'; -import {A, bz, C} from 'foo'; // failure - -// Import sources don't need to be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as foo from 'foo'; -import * as bar from 'bar'; // should not fail - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -import "something"; - -// contains ImportEqualsDeclaration -import c = require('./c'); -import * as a from './a'; -import b from './b'; - diff --git a/test/rules/ordered-imports/import-sources-any/default/test.ts.lint b/test/rules/ordered-imports/import-sources-any/default/test.ts.lint deleted file mode 100644 index 2404b2e0f6f..00000000000 --- a/test/rules/ordered-imports/import-sources-any/default/test.ts.lint +++ /dev/null @@ -1,35 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {B, A} from 'foo'; // failure - ~~~~ [ordered-imports] - -// Case is irrelevant for named import ordering. -import {A, b, C} from 'zfoo'; -import {bz, A, C} from 'foo'; // failure - ~~~~~ [ordered-imports] - -// Import sources don't need to be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as foo from 'foo'; -import * as bar from 'bar'; // should not fail - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -import "something"; - -// contains ImportEqualsDeclaration -import c = require('./c'); -import * as a from './a'; -import b from './b'; - -[ordered-imports]: Named imports must be alphabetized. -[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/import-sources-any/default/tslint.json b/test/rules/ordered-imports/import-sources-any/default/tslint.json deleted file mode 100644 index a88bcb08b5d..00000000000 --- a/test/rules/ordered-imports/import-sources-any/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": [true, {"import-sources-order": "any"}] - } -} diff --git a/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix b/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix deleted file mode 100644 index f620876650b..00000000000 --- a/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix +++ /dev/null @@ -1,4 +0,0 @@ -import { getOr } from 'lodash/fp' -import { Request } from 'express' - -import { getStatusCode } from './errors' diff --git a/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint b/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint deleted file mode 100644 index cef72a1ee8b..00000000000 --- a/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint +++ /dev/null @@ -1,5 +0,0 @@ -import { getOr } from 'lodash/fp' - -import { Request } from 'express' -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: libraries, parent directories, current directory.] -import { getStatusCode } from './errors' diff --git a/test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json b/test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json deleted file mode 100644 index c49cdb90188..00000000000 --- a/test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": [true, {"import-sources-order": "any", "grouped-imports": true}] - } - } diff --git a/test/rules/ordered-imports/inside-module-declaration/test.ts.lint b/test/rules/ordered-imports/inside-module-declaration/test.ts.lint deleted file mode 100644 index 59f908d8334..00000000000 --- a/test/rules/ordered-imports/inside-module-declaration/test.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -declare module "foo" { - import y from "y"; - import x from "x"; - ~~~~~~~~~~~~~~~~~~ [0] -} - -[0]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/inside-module-declaration/tslint.json b/test/rules/ordered-imports/inside-module-declaration/tslint.json deleted file mode 100644 index 9f79dbd1712..00000000000 --- a/test/rules/ordered-imports/inside-module-declaration/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": [true] - } -} diff --git a/test/rules/ordered-imports/lowercase-first/test.ts.fix b/test/rules/ordered-imports/lowercase-first/test.ts.fix deleted file mode 100644 index c1a1e3682f8..00000000000 --- a/test/rules/ordered-imports/lowercase-first/test.ts.fix +++ /dev/null @@ -1,31 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {A, B} from 'foo'; // failure - -// Lowercase comes before uppercase. -import {bz, A, C} from 'foo'; // failure -import {b, A, C} from 'zfoo'; - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as bar from 'bar'; // failure -import * as foo from 'foo'; - -// Lowercase comes before uppercase -import {A, B} from 'baz'; -import {A, B} from 'Bar'; -import {A, B} from 'Foo'; - -// Other styles of import statements. -import someDefault from "module"; -import "something"; -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; - -// contains ImportEqualsDeclaration -import * as a from './a'; -import b from './b'; -import c = require('./c'); - diff --git a/test/rules/ordered-imports/lowercase-first/test.ts.lint b/test/rules/ordered-imports/lowercase-first/test.ts.lint deleted file mode 100644 index bac65e93568..00000000000 --- a/test/rules/ordered-imports/lowercase-first/test.ts.lint +++ /dev/null @@ -1,40 +0,0 @@ -// Named imports should be alphabetized. -import {A, B} from 'foo'; -import {B, A} from 'foo'; // failure - ~~~~ [ordered-imports] - -// Lowercase comes before uppercase. -import {A, b, C} from 'zfoo'; - ~~~~ [Named imports must be alphabetized.] -import {bz, A, C} from 'foo'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as foo from 'foo'; -import * as bar from 'bar'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -// Lowercase comes before uppercase -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] -import {A, B} from 'Foo'; - -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import "something"; - -// contains ImportEqualsDeclaration -import c = require('./c'); -import * as a from './a'; -~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] -import b from './b'; - -[ordered-imports]: Named imports must be alphabetized. -[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/lowercase-first/tslint.json b/test/rules/ordered-imports/lowercase-first/tslint.json deleted file mode 100644 index 62b8787a617..00000000000 --- a/test/rules/ordered-imports/lowercase-first/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": [true, {"import-sources-order": "lowercase-first", "named-imports-order": "lowercase-first"}] - } -} diff --git a/test/rules/ordered-imports/module-source-path/test.ts.fix b/test/rules/ordered-imports/module-source-path/test.ts.fix deleted file mode 100644 index 11b341b29ef..00000000000 --- a/test/rules/ordered-imports/module-source-path/test.ts.fix +++ /dev/null @@ -1,19 +0,0 @@ -// Other styles of import statements. -import someDefault from "module"; -import "something"; -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; - -// contains relative path & ImportEqualsDeclaration -import a from './foo/a'; -import b from './bar/b'; -import c = require('./baz/c'); - -// contains relative path & ImportEqualsDeclaration -import a from '../../foo/a'; -import b from './bar/b'; -import c = require('./baz/c'); - -// contains scoped import -import a from 'foo/a'; -import b = require('foo/b'); -import c from 'foo/c'; diff --git a/test/rules/ordered-imports/module-source-path/test.ts.lint b/test/rules/ordered-imports/module-source-path/test.ts.lint deleted file mode 100644 index 3ced77fc1c5..00000000000 --- a/test/rules/ordered-imports/module-source-path/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import "something"; - -// contains relative path & ImportEqualsDeclaration -import c = require('./baz/c'); -import a from './foo/a'; -~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import b from './bar/b'; - -// contains relative path & ImportEqualsDeclaration -import c = require('./baz/c'); -import a from '../../foo/a'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import b from './bar/b'; - -// contains scoped import -import b = require('foo/b'); -import a from 'foo/a'; -~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import c from 'foo/c'; diff --git a/test/rules/ordered-imports/module-source-path/tslint.json b/test/rules/ordered-imports/module-source-path/tslint.json deleted file mode 100644 index 93b97002867..00000000000 --- a/test/rules/ordered-imports/module-source-path/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": [true, {"module-source-path": "basename"}] - } -} diff --git a/test/rules/ordered-imports/named-imports-any/test.ts.fix b/test/rules/ordered-imports/named-imports-any/test.ts.fix deleted file mode 100644 index d43cf75eb33..00000000000 --- a/test/rules/ordered-imports/named-imports-any/test.ts.fix +++ /dev/null @@ -1,42 +0,0 @@ -// Named imports do not need to be alphabetized. -import {A, B} from 'foo'; -import {B, A} from 'foo'; // should not fail - -// Case is irrelevant for named import ordering. -import {bz, A, C} from 'foo'; // should not fail -import {A, b, C} from 'zfoo'; - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as bar from 'bar'; // failure -import * as foo from 'foo'; - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault from "module"; -import "something"; -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; - -// contains ImportEqualsDeclaration -import * as a from './a'; -import b from './b'; -import c = require('./c'); - -import * as a from './a'; -import b from './b'; -import c = require('./c'); - -import * as a from './a'; -import b from './b'; -import c = require('./c'); - -import c = require('./c'); -import d = require('./d'); - diff --git a/test/rules/ordered-imports/named-imports-any/test.ts.lint b/test/rules/ordered-imports/named-imports-any/test.ts.lint deleted file mode 100644 index 400879083c5..00000000000 --- a/test/rules/ordered-imports/named-imports-any/test.ts.lint +++ /dev/null @@ -1,52 +0,0 @@ -// Named imports do not need to be alphabetized. -import {A, B} from 'foo'; -import {B, A} from 'foo'; // should not fail - -// Case is irrelevant for named import ordering. -import {A, b, C} from 'zfoo'; -import {bz, A, C} from 'foo'; // should not fail -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] - -// Import sources should be alphabetized. -import * as bar from 'bar'; -import * as foo from 'foo'; - -import * as abc from 'abc'; -import * as foo from 'foo'; -import * as bar from 'bar'; // failure -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -// Case is irrelevant for source import ordering. -import {A, B} from 'Bar'; -import {A, B} from 'baz'; -import {A, B} from 'Foo'; // should not fail - -// Other styles of import statements. -import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; -import someDefault from "module"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] -import "something"; - -// contains ImportEqualsDeclaration -import c = require('./c'); -import * as a from './a'; -~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] -import b from './b'; - -import * as a from './a'; -import c = require('./c'); -import b from './b'; -~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -import c = require('./c'); -import b from './b'; -~~~~~~~~~~~~~~~~~~~~ [ordered-sources] -import * as a from './a'; -~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -import d = require('./d'); -import c = require('./c'); -~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] - -[ordered-imports]: Named imports must be alphabetized. -[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/named-imports-any/tslint.json b/test/rules/ordered-imports/named-imports-any/tslint.json deleted file mode 100644 index 89be91b2528..00000000000 --- a/test/rules/ordered-imports/named-imports-any/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "ordered-imports": [true, {"named-imports-order": "any"}] - } -} diff --git a/test/rules/ordered-imports/standalone-grouped-import/test.ts.fix b/test/rules/ordered-imports/standalone-grouped-import/test.ts.fix deleted file mode 100644 index b1ac69a33bd..00000000000 --- a/test/rules/ordered-imports/standalone-grouped-import/test.ts.fix +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env node - -import {a} from 'foo'; -import x = require('y'); - -import './baa'; -import './baz'; -import './caa'; - -export class Test {} diff --git a/test/rules/ordered-imports/standalone-grouped-import/test.ts.lint b/test/rules/ordered-imports/standalone-grouped-import/test.ts.lint deleted file mode 100644 index 9ce6cefb980..00000000000 --- a/test/rules/ordered-imports/standalone-grouped-import/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node - -import {a} from 'foo'; - -import './baa'; -import './baz'; - -import './caa'; -~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: libraries, parent directories, current directory.] - -import x = require('y'); - -export class Test {} diff --git a/test/rules/ordered-imports/standalone-grouped-import/tslint.json b/test/rules/ordered-imports/standalone-grouped-import/tslint.json deleted file mode 100644 index 307aed99054..00000000000 --- a/test/rules/ordered-imports/standalone-grouped-import/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "ordered-imports": [ - true, { - "import-sources-order": "case-insensitive", - "named-imports-order": "case-insensitive", - "grouped-imports": true - }] - } -} diff --git a/test/rules/prefer-conditional-expression/check-else-if/test.ts.lint b/test/rules/prefer-conditional-expression/check-else-if/test.ts.lint deleted file mode 100644 index 0424780d9f4..00000000000 --- a/test/rules/prefer-conditional-expression/check-else-if/test.ts.lint +++ /dev/null @@ -1,106 +0,0 @@ -let x; -if (true) { -~~ [err % ('x')] - x = 1; -} else { - x = 2; -} - -if (true) -~~ [err % ('x')] - x = "TRUE"; -else if (false) - x = "FALSE"; -else - x = "FILE_NOT_FOUND"; - -// Must assign same variable -if (true) { - x = 1; -} else { - y = 2; -} - -// All branches must be present -if (true) { - x = 1; -} - -// Must not be a multi-statement block. -if (true) { - x = 1; -} else { - x = 2; - y = 3; -} - -// Or even multi-line. -if (true) - x = [ - 1, - 2 - ]; -else - x = 3; - -// Works for complex left hand side. -if (true) { -~~ [err % ('foo(bar).baz')] - foo(bar).baz = 0; -} else { - foo(bar).baz = 1; -} - -if (length === 0) { -~~ [err % ('x')] - x = "foo"; -} else if (length === 1) { - x = "bar"; -} else if (length === 2) { - x = "something else"; -} else { - x = "unknown"; -} - -if (length === 0) { -~~ [err % ('x')] - x = "foo"; -} else { - if (length === 1) { - x = "bar"; - } else { - if (length === 2) { - x = "something else"; - } else { - x = "unknown"; - } - } -} - -if (length === 0) { - y = "foo"; -} else if (length === 1) { - ~~ [err % ('x')] - x = "bar"; -} else if (length === 2) { - x = "something else"; -} else { - x = "unknown"; -} - -if (length === 0) { - y = "foo"; -} else { - if (length === 1) { - ~~ [err % ('x')] - x = "bar"; - } else { - if (length === 2) { - x = "something else"; - } else { - x = "unknown"; - } - } -} - -[err]: Use a conditional expression instead of assigning to '%s' in multiple places. diff --git a/test/rules/prefer-conditional-expression/check-else-if/tslint.json b/test/rules/prefer-conditional-expression/check-else-if/tslint.json deleted file mode 100644 index 07c97a9338a..00000000000 --- a/test/rules/prefer-conditional-expression/check-else-if/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-conditional-expression": [true, "check-else-if"] - } -} diff --git a/test/rules/prefer-conditional-expression/default/test.ts.lint b/test/rules/prefer-conditional-expression/default/test.ts.lint deleted file mode 100644 index ead36e4f3dd..00000000000 --- a/test/rules/prefer-conditional-expression/default/test.ts.lint +++ /dev/null @@ -1,95 +0,0 @@ -let x; -if (true) { -~~ [err % ('x')] - x = 1; -} else { - x = 2; -} - -if (true) - x = "TRUE"; -else if (false) - x = "FALSE"; -else - x = "FILE_NOT_FOUND"; - -// Must assign same variable -if (true) { - x = 1; -} else { - y = 2; -} - -// All branches must be present -if (true) { - x = 1; -} - -// Must not be a multi-statement block. -if (true) { - x = 1; -} else { - x = 2; - y = 3; -} - -// Or even multi-line. -if (true) - x = [ - 1, - 2 - ]; -else - x = 3; - -// Works for complex left hand side. -if (true) { -~~ [err % ('foo(bar).baz')] - foo(bar).baz = 0; -} else { - foo(bar).baz = 1; -} - -// leave nested if statements alone -if (length === 0) { - x = "foo"; -} else if (length === 1) { - x = "bar"; -} else if (length === 2) { - x = "something else"; -} else { - x = "unknown"; -} - -if (length === 0) { - x = "foo"; -} else { - if (length === 1) { - x = "bar"; - } else { - if (length === 2) { - x = "something else"; - } else { - x = "unknown"; - } - } -} - -if (length === 0) { - x = "foo"; -} else if (length === 1) { - x = "bar"; -} else if (length === 2) { - x = "something else"; -} else { - foo(); - // detects nested if statements when not direct child of else - if (bar) { - ~~ [err % ('x')] - x = 1; - } else { - x = 2; - } -} - -[err]: Use a conditional expression instead of assigning to '%s' in multiple places. diff --git a/test/rules/prefer-conditional-expression/default/tslint.json b/test/rules/prefer-conditional-expression/default/tslint.json deleted file mode 100644 index 8f68fd2c6a0..00000000000 --- a/test/rules/prefer-conditional-expression/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-conditional-expression": true - } -} diff --git a/test/rules/prefer-const/default/ambient.d.ts.lint b/test/rules/prefer-const/default/ambient.d.ts.lint deleted file mode 100644 index 5a9f881717c..00000000000 --- a/test/rules/prefer-const/default/ambient.d.ts.lint +++ /dev/null @@ -1,5 +0,0 @@ -// no errors in declaration files -let foo = 0; -namespace bar { - let foo = 0; -} \ No newline at end of file diff --git a/test/rules/prefer-const/default/global.ts.lint b/test/rules/prefer-const/default/global.ts.lint deleted file mode 100644 index a941fd89b18..00000000000 --- a/test/rules/prefer-const/default/global.ts.lint +++ /dev/null @@ -1,17 +0,0 @@ -// this is not an external module -// variables in the global scope are ignored by prefer-const -let var1 = 0; -let var2 = 0; -{ - let var2 = 1; - { - var2 = 2; - } - var var3 = 0; - { - let var3 = 1; - var3 = 2; - let var4 = 0; - ~~~~ [Identifier 'var4' is never reassigned; use 'const' instead of 'let'.] - } -} \ No newline at end of file diff --git a/test/rules/prefer-const/default/spread.ts.lint b/test/rules/prefer-const/default/spread.ts.lint deleted file mode 100644 index 7847c8db97a..00000000000 --- a/test/rules/prefer-const/default/spread.ts.lint +++ /dev/null @@ -1,24 +0,0 @@ -{ - let d1 = 0; - let d2 = 0; - let d3 = 0; - let d4 = 0; - [(d1), ([d2]), ...[d3 = 1, ...(d4)]] = []; -} - -{ - let d1 = 0; - let d2 = 0; - let d3 = 0; - let d4 = 0; - let d5 = 0; - ({ - d1 = 2, - foo: d2, - bar: { - ...d3 - }, - baz: {d4} = {}, - ...(d5), - } = {}); -} \ No newline at end of file diff --git a/test/rules/prefer-const/default/test.ts.fix b/test/rules/prefer-const/default/test.ts.fix deleted file mode 100644 index 987b880694e..00000000000 --- a/test/rules/prefer-const/default/test.ts.fix +++ /dev/null @@ -1,228 +0,0 @@ -const a = 1; - -// different reassignments -let b = 1; -b = 2; -let b1 = 1; -b1++; -let b2 = 1; -b2--; -let b3 = 1; -b3 /= 2; -let b4 = 1; ---b4; - -// basic failure -const c = 1; // failure - -// multiple declarations -const c5 = 5, c6 = 6; -const c1 = 1, c2 = 2; // 2 failures -let c3 = 1, c4 = 2; // 1 failure -c3 = 4; - -// destructuring -{ - let destructLater = 4; - [destructLater] = 5; - let a: number; - let b: number; - let c: any; - ({ eh: a, b, ...c } = { eh: 0, b: 1 }); -} - -let {h, i} = {h: 1, i: 1}; // failure for 'h' -let [j, k] = [1, 1]; // failure for 'j' -let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 -let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // failure for 'r' -i = 2; -k = 2; -q = 4; -x2 = 5; - -// functions -function myFunc(d: number, e: number) { - const f = 1; // failure - const g = 1; - d = 2; -} -function myFunc2() { - let [l, m] = [1, 1]; // failure for 'l' - m = 2; - return l; -} - -// for-of -for (const n of [1, 1]) { // failure for 'n' - console.log(n); -} -for (let {o, p} of [{1, 1}, {1, 1}]) { - console.log(o); - p = 2; -} - -// for loop -for (let i1 = 0; i1 < 4; i1++) { -} -for (const i2 = 0;;) { // failure -} -for (const i2 = 0;;) { -} - -// scope -let sc = 0; -const sc1 = 0; -let sc2 = 0; -let sc3 = 0; -{ - sc = 1; -} -for(;;) { - sc2 = 3; -} -class MyClass { - private classVar = 5; - public Increment() { - let sc4 = 0; - const sc5 = 0; // error - this.classVar++; - sc3++; - sc4++; - } -} - -// separate declaration and assignment (no error) -let x: number; -x = 5; - -// ignores RHS of declaration -const usedAsRHS = 3; -const LHS: number | string = usedAsRHS; - -// handle nested declaration -const nest = () => { - const a = 4; - let b = 0; - const c = 1; - b = 2; - return a + b + c; -}; - -const nest2 = () => { - const error = false; - try { - } catch(error) { - // variable error is block scoped - error = true; - } -} - -// export -export let x = 4; - -// array -const arr = []; -arr.push(0); -arr[1] = 1; -arr.length = 1; - -// reassignment of the forward declaration -function useOfForwardDecl() { - forwardDecl = 1; -} - -let forwardDecl: number; - -module E { - const x = 1; -} - -switch (1) { - case 1: - const x = 1; - break; - case 2: - const y = 1; - break; -} - -var someVariable = 0; -function funcxion(someVariable, someParameter) { - someVariable = 1; - { - var var1 = 0; - var var2 = 0; - } - { - var1 = 1; - } - { - let var2 = 1; - var2 = 2; - } -} - -const shadowed1 = 0; -const shadowed2 = 0; -const shadowed3 = 0; -function shadowVariables({shadowed1, ...shadowed2}, shadowed3) { - shadowed1 = 1; - shadowed2 = 1; - shadowed3 = 1; -} - -// no error in for loop initializer -for (let i = 1, l = arr.length; i < l; ++i) { -} - -{ - const var1 = 0; - let var2 = 0; - function foo(var1 = var2 = 1, var2 = var1 = 1) {} - function foo2(p1 = var2 = 1) { - const var2 = 0; - } -} - -// cannot fix, because of uninitialized variables -let uninitialized; -let initialized1 = 0, uninitialized2; - -// ambient declarations are not checked -declare let ambient = 0; - -declare namespace ambient { - let foo = 0; -} - -{ - let someVar: string; - for (someVar in someObj) {} -} -{ - let someVar: string; - for (someVar of someArr) {} -} -{ - let someVar: string, someVar2: string; - for ({someVar, foo: someVar2} of someArr) {} -} -{ - let someVar: string, someObj: any; - for ({someVar: someObj.val} of someArr) {} -} -for (let [var1, var2] of someArr) { - var1 = null; -} -for (const [var1, var2] of someArr) {} -for (let {var1, var2} of someArr) { - var2 = null; -} - -{ - let k: any = 0; - function foo(param: {[k: string]: string}) { - k = param; - } -} - diff --git a/test/rules/prefer-const/default/test.ts.lint b/test/rules/prefer-const/default/test.ts.lint deleted file mode 100644 index 5b379fce273..00000000000 --- a/test/rules/prefer-const/default/test.ts.lint +++ /dev/null @@ -1,270 +0,0 @@ -const a = 1; - -// different reassignments -let b = 1; -b = 2; -let b1 = 1; -b1++; -let b2 = 1; -b2--; -let b3 = 1; -b3 /= 2; -let b4 = 1; ---b4; - -// basic failure -let c = 1; // failure - ~ [let % ('c')] - -// multiple declarations -const c5 = 5, c6 = 6; -let c1 = 1, c2 = 2; // 2 failures - ~~ [let % ('c1')] - ~~ [let % ('c2')] -let c3 = 1, c4 = 2; // 1 failure - ~~ [let % ('c4')] -c3 = 4; - -// destructuring -{ - let destructLater = 4; - [destructLater] = 5; - let a: number; - let b: number; - let c: any; - ({ eh: a, b, ...c } = { eh: 0, b: 1 }); -} - -let {h, i} = {h: 1, i: 1}; // failure for 'h' - ~ [let % ('h')] -let [j, k] = [1, 1]; // failure for 'j' - ~ [let % ('j')] -let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 - ~~ [let % ('x1')] - ~~ [let % ('x3')] -let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // failure for 'r' - ~ [let % ('r')] -i = 2; -k = 2; -q = 4; -x2 = 5; - -// functions -function myFunc(d: number, e: number) { - let f = 1; // failure - ~ [let % ('f')] - const g = 1; - d = 2; -} -function myFunc2() { - let [l, m] = [1, 1]; // failure for 'l' - ~ [let % ('l')] - m = 2; - return l; -} - -// for-of -for (let n of [1, 1]) { // failure for 'n' - ~ [let % ('n')] - console.log(n); -} -for (let {o, p} of [{1, 1}, {1, 1}]) { - console.log(o); - p = 2; -} - -// for loop -for (let i1 = 0; i1 < 4; i1++) { -} -for (let i2 = 0;;) { // failure - ~~ [let % ('i2')] -} -for (const i2 = 0;;) { -} - -// scope -let sc = 0; -let sc1 = 0; - ~~~ [let % ('sc1')] -let sc2 = 0; -let sc3 = 0; -{ - sc = 1; -} -for(;;) { - sc2 = 3; -} -class MyClass { - private classVar = 5; - public Increment() { - let sc4 = 0; - let sc5 = 0; // error - ~~~ [let % ('sc5')] - this.classVar++; - sc3++; - sc4++; - } -} - -// separate declaration and assignment (no error) -let x: number; -x = 5; - -// ignores RHS of declaration -let usedAsRHS = 3; - ~~~~~~~~~ [let % ('usedAsRHS')] -let LHS: number | string = usedAsRHS; - ~~~ [let % ('LHS')] - -// handle nested declaration -let nest = () => { - ~~~~ [let % ('nest')] - const a = 4; - let b = 0; - let c = 1; - ~ [let % ('c')] - b = 2; - return a + b + c; -}; - -let nest2 = () => { - ~~~~~ [let % ('nest2')] - let error = false; - ~~~~~ [let % ('error')] - try { - } catch(error) { - // variable error is block scoped - error = true; - } -} - -// export -export let x = 4; - -// array -let arr = []; - ~~~ [let % ('arr')] -arr.push(0); -arr[1] = 1; -arr.length = 1; - -// reassignment of the forward declaration -function useOfForwardDecl() { - forwardDecl = 1; -} - -let forwardDecl: number; - -module E { - let x = 1; - ~ [let % ('x')] -} - -switch (1) { - case 1: - let x = 1; - ~ [let % ('x')] - break; - case 2: - let y = 1; - ~ [let % ('y')] - break; -} - -var someVariable = 0; - ~~~~~~~~~~~~ [var % ('someVariable')] -function funcxion(someVariable, someParameter) { - someVariable = 1; - { - var var1 = 0; - var var2 = 0; - ~~~~ [var % ('var2')] - } - { - var1 = 1; - } - { - let var2 = 1; - var2 = 2; - } -} - -let shadowed1 = 0; - ~~~~~~~~~ [let % ('shadowed1')] -let shadowed2 = 0; - ~~~~~~~~~ [let % ('shadowed2')] -let shadowed3 = 0; - ~~~~~~~~~ [let % ('shadowed3')] -function shadowVariables({shadowed1, ...shadowed2}, shadowed3) { - shadowed1 = 1; - shadowed2 = 1; - shadowed3 = 1; -} - -// no error in for loop initializer -for (let i = 1, l = arr.length; i < l; ++i) { -} - -{ - let var1 = 0; - ~~~~ [let % ('var1')] - let var2 = 0; - function foo(var1 = var2 = 1, var2 = var1 = 1) {} - function foo2(p1 = var2 = 1) { - let var2 = 0; - ~~~~ [let % ('var2')] - } -} - -// cannot fix, because of uninitialized variables -let uninitialized; - ~~~~~~~~~~~~~ [let % ('uninitialized')] -let initialized1 = 0, uninitialized2; - ~~~~~~~~~~~~ [let % ('initialized1')] - ~~~~~~~~~~~~~~ [let % ('uninitialized2')] - -// ambient declarations are not checked -declare let ambient = 0; - -declare namespace ambient { - let foo = 0; -} - -{ - let someVar: string; - for (someVar in someObj) {} -} -{ - let someVar: string; - for (someVar of someArr) {} -} -{ - let someVar: string, someVar2: string; - for ({someVar, foo: someVar2} of someArr) {} -} -{ - let someVar: string, someObj: any; - ~~~~~~~ [let % ('someVar')] - ~~~~~~~ [let % ('someObj')] - for ({someVar: someObj.val} of someArr) {} -} -for (let [var1, var2] of someArr) { - var1 = null; -} -for (let [var1, var2] of someArr) {} - ~~~~ [let % ('var1')] - ~~~~ [let % ('var2')] -for (let {var1, var2} of someArr) { - var2 = null; -} - -{ - let k: any = 0; - function foo(param: {[k: string]: string}) { - k = param; - } -} - -[_base]: Identifier '%%s' is never reassigned; use 'const' instead of '%s'. -[let]: _base % ('let') -[var]: _base % ('var') diff --git a/test/rules/prefer-const/default/tslint.json b/test/rules/prefer-const/default/tslint.json deleted file mode 100644 index 369865b3ae9..00000000000 --- a/test/rules/prefer-const/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-const": true - } -} diff --git a/test/rules/prefer-const/destructuring-all/test.ts.fix b/test/rules/prefer-const/destructuring-all/test.ts.fix deleted file mode 100644 index f89ce0a5ba3..00000000000 --- a/test/rules/prefer-const/destructuring-all/test.ts.fix +++ /dev/null @@ -1,28 +0,0 @@ -export let foo = 1; -// destructuring -{ - let destructLater = 4; - [destructLater] = 5; - let a: number; - let b: number; - let c: any; - ({ eh: a, b, ...c } = { eh: 0, b: 1 }); -} - -let {h, i} = {h: 1, i: 1}; // 'h' can be const -let [j, k] = [1, 1]; // 'j' can be const -let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 -let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // 'r' can be const -i = 2; -k = 2; -q = 4; -x2 = 5; - -for (let {o, p} of [{1, 1}, {1, 1}]) { // 'o' can be const - console.log(o); - p = 2; -} - -{ - const [d1, d2] = []; -} diff --git a/test/rules/prefer-const/destructuring-all/test.ts.lint b/test/rules/prefer-const/destructuring-all/test.ts.lint deleted file mode 100644 index e0144287017..00000000000 --- a/test/rules/prefer-const/destructuring-all/test.ts.lint +++ /dev/null @@ -1,34 +0,0 @@ -export let foo = 1; -// destructuring -{ - let destructLater = 4; - [destructLater] = 5; - let a: number; - let b: number; - let c: any; - ({ eh: a, b, ...c } = { eh: 0, b: 1 }); -} - -let {h, i} = {h: 1, i: 1}; // 'h' can be const -let [j, k] = [1, 1]; // 'j' can be const -let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 - ~~ [let % ('x1')] - ~~ [let % ('x3')] -let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // 'r' can be const -i = 2; -k = 2; -q = 4; -x2 = 5; - -for (let {o, p} of [{1, 1}, {1, 1}]) { // 'o' can be const - console.log(o); - p = 2; -} - -{ - let [d1, d2] = []; - ~~ [let % ('d1')] - ~~ [let % ('d2')] -} - -[let]: Identifier '%s' is never reassigned; use 'const' instead of 'let'. \ No newline at end of file diff --git a/test/rules/prefer-const/destructuring-all/tslint.json b/test/rules/prefer-const/destructuring-all/tslint.json deleted file mode 100644 index 10b347a8c1c..00000000000 --- a/test/rules/prefer-const/destructuring-all/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "prefer-const": [ - true, - {"destructuring": "all"} - ] - } -} diff --git a/test/rules/prefer-for-of/test.ts.lint b/test/rules/prefer-for-of/test.ts.lint deleted file mode 100644 index 8338a67fdb9..00000000000 --- a/test/rules/prefer-for-of/test.ts.lint +++ /dev/null @@ -1,197 +0,0 @@ -// should not flag (#2159) -const columns = [{ data: [1] }]; -for (let i = 0; i < columns[0].data.length; i++) { - columns.map((x) => x.data[i]); -} - -function sampleFunc() { - // issue #1931, should not error - const value1 = [1]; - const value2 = [2]; - for (let i = 0; i < (value1).length; i++) { - const x = (value1)[i] === (value2)[i]; - } - - // This loop only uses the iterator to access the array item, so we can recommend a for-of loop here - for (var a = 0; a < obj.arr.length; a++) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - console.log(obj.arr[a]); - } - - // Same as above, but no curly braces - for (var b = 0; b < obj.arr.length; b++) console.log(obj.arr[b]); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - // the index is used by itself, so a normal for loop is allowed here - for (var c = 0; c < arr.length; c++) { - doMath(c); - } - - // Same as above, but no curly braces - for (var d = 0; d < arr.length; d++) doMath(d); - - // the index is used by itself, so a normal for loop is allowed here - for (var e = 0; e < arr.length; e++) { - if(e > 5) { - doMath(e); - } - console.log(arr[e]); - } - - // This iterates off of a hard-coded number and should be allowed - for (var f = 0; f <= 40; f++) { - doMath(f); - } - - // Same as above, but no curly braces - for (var g = 0; g <= 40; g++) doMath(g); - - // multiple operations in the initializer - for(var h=0, len=arr.length; h < len; h++) {} - - // Same as above, but no curly braces - for(var i=0, len=arr.length; i < len; i++) arr[i]; - - // Odd for loop setups - var m = 0; - for (;;) { - if (m > 3) break; - console.log(m); - m++; - } - - var n = 0; - for (; n < 9; n++) { - console.log(n); - } - - var o = 0; - for (; o < arr.length; o++) { - console.log(arr[o]); - } - - // Prefix incrementor - for(let p = 0; p < arr.length; ++p) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - arr[p].whatever(); - } - - // empty - for(let x = 0; x < arr.length; x++) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - // missing - for(; x < arr.length; x++) {} - for(let x = 0;; x++) {} - for(let x = 0; x < arr.length;) {} - - // mismatch - for(let x = 0; NOTX < arr.length; x++) {} - for(let x = 0; x < arr.length; NOTX++) {} - for(let NOTX = 0; x < arr.length; x++) {} - - // decrement - for(let x = 0; x < arr.length; x--) {} - - // not `<` - for(let x = 0; x <= arr.length; x++) {} - - // wrong starting point - for(let x = 1; x < arr.length; x++) {} - - // not `length` property - for(let x = 0; x < arr.length(); x++) {} - - // alternate incrementor - for(let x = 0; x < arr.length; x+=1) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - for(let x = 0; x < arr.length; x=x+1) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - for(let x = 0; x < arr.length; x=1+x) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - - // adds too much - for(let x = 0; x < arr.length; x+=11) {} - for(let x = 0; x < arr.length; x=x+11) {} - - for(let x = 0; x < arr.length; x++) { - x++; - } - - // unexpected condition - for(let x = 0; true; x++) {} - - // For-in loops ARE allowed - for (var q in obj) { - if (obj.hasOwnProperty(q)) { - console.log(q); - } - } - - // For-of loops ARE allowed - for (var r of arr) { - console.log(r); - } - - // array element is assigned a new value - for (let x = 0; x < arr.length; x++) { - arr[x] = 4; - } - - // access element other than current - for (let x = 0; x < arr.length; x++) { - let y = arr[x + 1]; - } -} - -for (let shadow = 0; shadow < arr.length; shadow++) { -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - for (let shadow = 0; shadow < arr.length; shadow++) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - } -} - -for (let i = 0; i < arr.length; i++) { - delete arr[i]; -} - -for (let i = 0; i < arr.length; ++i) { -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - { - let i = 1; - let x = i; - let obj = {i, x}; - } - i: while(true) { - let obj = {i: 1}; - break i; - } - - let node = arr[i]; -} - -function test() { - function print() { - console.log(arr[i]) - } - for (var i = 0, i < arr.length, ++i) - print(); -} - -for (let i = 0; i < arr.length; ++i) { - arr[i]++; -} - -for (let i = 0; i < arr.length; ++i) { - ({...arr[i]} = foo); -} - -for (let i = 0; i < arr.length; ++i) { - for (arr[i] of otherArr) {} -} - -for (let i = 0; i < arr.length; ++i) { - ++(arr[i]); -} - -[0]: Expected a 'for-of' loop instead of a 'for' loop with this simple iteration diff --git a/test/rules/prefer-for-of/tslint.json b/test/rules/prefer-for-of/tslint.json deleted file mode 100644 index a7d6263e98a..00000000000 --- a/test/rules/prefer-for-of/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-for-of": true - } -} diff --git a/test/rules/prefer-function-over-method/allow-protected/test.ts.lint b/test/rules/prefer-function-over-method/allow-protected/test.ts.lint deleted file mode 100644 index 880413a27ec..00000000000 --- a/test/rules/prefer-function-over-method/allow-protected/test.ts.lint +++ /dev/null @@ -1,9 +0,0 @@ -class C { - a() {} - ~ [0] - protected b() {} - private c() {} - ~ [0] -} - -[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/allow-protected/tslint.json b/test/rules/prefer-function-over-method/allow-protected/tslint.json deleted file mode 100644 index c5c1ff87b7e..00000000000 --- a/test/rules/prefer-function-over-method/allow-protected/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-function-over-method": [true, "allow-protected"] - } -} diff --git a/test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint b/test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint deleted file mode 100644 index bef8ec11b35..00000000000 --- a/test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint +++ /dev/null @@ -1,8 +0,0 @@ -class C { - a() {} - protected b() {} - private c() {} - ~ [0] -} - -[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json b/test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json deleted file mode 100644 index c60d1b2b86e..00000000000 --- a/test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-function-over-method": [true, "allow-public", "allow-protected"] - } -} diff --git a/test/rules/prefer-function-over-method/allow-public/test.ts.lint b/test/rules/prefer-function-over-method/allow-public/test.ts.lint deleted file mode 100644 index 9781d94bf63..00000000000 --- a/test/rules/prefer-function-over-method/allow-public/test.ts.lint +++ /dev/null @@ -1,9 +0,0 @@ -class C { - a() {} - protected b() {} - ~ [0] - private c() {} - ~ [0] -} - -[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/allow-public/tslint.json b/test/rules/prefer-function-over-method/allow-public/tslint.json deleted file mode 100644 index 3b9071c84a8..00000000000 --- a/test/rules/prefer-function-over-method/allow-public/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-function-over-method": [true, "allow-public"] - } -} diff --git a/test/rules/prefer-function-over-method/default/test.ts.lint b/test/rules/prefer-function-over-method/default/test.ts.lint deleted file mode 100644 index 3001e60be6a..00000000000 --- a/test/rules/prefer-function-over-method/default/test.ts.lint +++ /dev/null @@ -1,66 +0,0 @@ -class C { - static s() {} - - plain() {} - ~~~~~ [0] - - thisInFunction() { - ~~~~~~~~~~~~~~ [0] - function() { - this; - } - } - - thisInObjectMethod() { - ~~~~~~~~~~~~~~~~~~ [0] - return { x() { this; } } - } - - recur() { - ~~~~~ [0] - this.recur(); - } - - thisInParameter(this: string) {} - ~~~~~~~~~~~~~~~ [0] - - thisInParameterDefault(x = this) {} - - thisUsed() { - this; - } - - super() { - super; - } - - protected protected() {} - ~~~~~~~~~ [0] - - private private() {} - ~~~~~~~ [0] - - [Symbol.iterator]() {} - ~~~~~~~~~~~~~~~~~ [0] - - thisType(foo: this): this { - ~~~~~~~~ [0] - return foo; - } - - overload(): void; - overload(foo): void; - overload(foo?): void { - return this; - } -} - -abstract class C2 { - abstract abstract(): void; -} - -const o = { - x() {} -} - -[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/default/tslint.json b/test/rules/prefer-function-over-method/default/tslint.json deleted file mode 100644 index eabdb99d86a..00000000000 --- a/test/rules/prefer-function-over-method/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-function-over-method": true - } -} diff --git a/test/rules/prefer-method-signature/test.ts.fix b/test/rules/prefer-method-signature/test.ts.fix deleted file mode 100644 index ceb3f0ad236..00000000000 --- a/test/rules/prefer-method-signature/test.ts.fix +++ /dev/null @@ -1,18 +0,0 @@ -interface I { - foo(): void; - bar(): T; -} - -type T = { - foo?(): void; -} - -class C { - // OK in class - foo: () => void; -} - -export interface Bar { - someMethod(someArg: Pick): string; -} - diff --git a/test/rules/prefer-method-signature/test.ts.lint b/test/rules/prefer-method-signature/test.ts.lint deleted file mode 100644 index 4cea96b42b0..00000000000 --- a/test/rules/prefer-method-signature/test.ts.lint +++ /dev/null @@ -1,25 +0,0 @@ -interface I { - foo: () => void; - ~~~ [0] - bar: () => T; - ~~~ [0] -} - -type T = { - foo?: () => void; - ~~~ [0] -} - -class C { - // OK in class - foo: () => void; -} - -export interface Bar { - someMethod: ( - ~~~~~~~~~~ [0] - someArg: Pick - ) => string; -} - -[0]: Use a method signature instead of a property signature of function type. diff --git a/test/rules/prefer-method-signature/tslint.json b/test/rules/prefer-method-signature/tslint.json deleted file mode 100644 index ca95816c0f3..00000000000 --- a/test/rules/prefer-method-signature/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-method-signature": true - } -} diff --git a/test/rules/prefer-object-spread/test.ts.fix b/test/rules/prefer-object-spread/test.ts.fix deleted file mode 100644 index 6ab5c8e3b99..00000000000 --- a/test/rules/prefer-object-spread/test.ts.fix +++ /dev/null @@ -1,30 +0,0 @@ -const form = Object.assign({}, this); -const foo = Object.assign(bar, this); -const foo = Object.assign({}, bar, baz, this); -const original = {a: 1, b:2}; -{...original, c: 3}; -{a: 1, b: 2, c: 3}; -Object.assign({a:1}, ...[{b: 2}, {c: 3}]) -Object.assign(original, {c: 3}); -var result = {...original, c: 3}; -result = {...original, c: 3}; -var result = {...original, c: 3}; -foo({...original, c: 3}); -[{...original, c: 3}]; -({ - foo: {...original, c: 3} -}) - -{a: 1,}; -{a: 1, ...(foo ? {b: 2} : {c: 3})}; -{a: 1, ...{b: 2}}; -{}; -{}; - -// allowed -result = Object.assign(new Foo(), {}); -result = Object.assign(createFoo(), {}); -result = Object.assign(function() {}, {}); -result = Object.assign(() => {}, {}); - -let fn = () => ({...original}); diff --git a/test/rules/prefer-object-spread/test.ts.lint b/test/rules/prefer-object-spread/test.ts.lint deleted file mode 100644 index 298394f2afa..00000000000 --- a/test/rules/prefer-object-spread/test.ts.lint +++ /dev/null @@ -1,46 +0,0 @@ -const form = Object.assign({}, this); -const foo = Object.assign(bar, this); -const foo = Object.assign({}, bar, baz, this); -const original = {a: 1, b:2}; -Object.assign({}, original, {c: 3}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Object.assign({a: 1, b: 2}, {c: 3}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Object.assign({a:1}, ...[{b: 2}, {c: 3}]) -Object.assign(original, {c: 3}); -var result = Object.assign(original, {c: 3}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] -result = Object.assign(original, {c: 3}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] -var result = Object.assign({}, original, {c: 3}); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -foo(Object.assign(original, {c: 3})); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] -[Object.assign(original, {c: 3})]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] -({ - foo: Object.assign(original, {c: 3}) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] -}) - -Object.assign({}, {}, {a: 1,},); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Object.assign({a: 1}, foo ? {b: 2} : {c: 3}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Object.assign({a: 1, ...{b: 2}}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -Object.assign({}, {}); -~~~~~~~~~~~~~~~~~~~~~ [0] -Object.assign({}, {},); -~~~~~~~~~~~~~~~~~~~~~~ [0] - -// allowed -result = Object.assign(new Foo(), {}); -result = Object.assign(createFoo(), {}); -result = Object.assign(function() {}, {}); -result = Object.assign(() => {}, {}); - -let fn = () => Object.assign({}, original); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -[0]: Use the object spread operator instead. -[1]: 'Object.assign' returns the first argument. Prefer object spread if you want a new object. diff --git a/test/rules/prefer-object-spread/tslint.json b/test/rules/prefer-object-spread/tslint.json deleted file mode 100644 index 43b88cfa0d5..00000000000 --- a/test/rules/prefer-object-spread/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-object-spread": true - } -} \ No newline at end of file diff --git a/test/rules/prefer-readonly/default/test.ts.fix b/test/rules/prefer-readonly/default/test.ts.fix deleted file mode 100644 index 49b701351a9..00000000000 --- a/test/rules/prefer-readonly/default/test.ts.fix +++ /dev/null @@ -1,155 +0,0 @@ -class SampleClass { - private static readonly correctlyReadonlyStatic = 7; - - private static readonly incorrectlyModifiableStatic = 7; - - private static readonly incorrectlyModifiableStaticArrow = () => {}; - - private static correctlyModifiableStatic = 7; - - private static correctlyModifiableByParameterProperty = 7; - - private readonly correctlyReadonlyInline = 7; - - private readonly correctlyReadonlyDelayed; - - private readonly incorrectlyModifiableInline = 7; - - private readonly incorrectlyModifiableDelayed; - - private correctlyModifiableInline = 7; - - private correctlyModifiableDelayed; - - private correctlyModifiableDeleted = 7; - - private readonly childClassExpressionModifiable = 7; - - private correctlyModifiableWithinConstructor; - - private correctlyModifiableWithinConstructorInArrowFunction; - - private correctlyModifiableWithinConstructorInFunctionExpression; - - private correctlyModifiableWithinConstructorInGetAccessor; - - private correctlyModifiableWithinConstructorInMethodDeclaration; - - private correctlyModifiableWithinConstructorInSetAccessor; - - private correctlyModifiablePostDecremented; - - private correctlyModifiablePostIncremented; - - private readonly incorrectlyModifiablePostMinus; - - private readonly incorrectlyModifiablePostPlus; - - private correctlyModifiablePreDecremented; - - private correctlyModifiablePreIncremented; - - private readonly incorrectlyModifiablePreMinus; - - private readonly incorrectlyModifiablePrePlus; - - private readonly overlappingClassVariable = 7; - - protected protectedModifiable = 7; - - protected publicModifiable = 7; - - public constructor( - private readonly correctlyReadonlyParameter: number = 7, - private readonly incorrectlyModifiableParameter: number = 7, - private correctlyModifiableParameter: number = 7, - public correctlyModifiablePublicParameter: number = (() => { - return SampleClass.correctlyModifiableByParameterProperty = 7; - })(); - ) { - this.correctlyReadonlyDelayed = 7; - this.incorrectlyModifiableDelayed = 7; - this.incorrectlyModifiableParameter = 7; - - (() => { - const self = this; - - this.correctlyModifiableWithinConstructor = 7; - - (() => { - this.correctlyModifiableWithinConstructorInArrowFunction = 7; - })(); - - (function () { - self.correctlyModifiableWithinConstructorInFunctionExpression = 7; - })(); - - const confusingObject = { - get getAccessor() { - return self.correctlyModifiableWithinConstructorInGetAccessor = 7; - } - - methodDeclaration() { - self.correctlyModifiableWithinConstructorInMethodDeclaration = 7; - } - - set setAccessor() { - self.correctlyModifiableWithinConstructorInSetAccessor = 7; - } - }; - })(); - - SampleClass.correctlyModifiableStatic += 1; - } - - public mutate() { - this.correctlyModifiableDelayed = 7; - this.correctlyModifiableInline = 7; - this.correctlyModifiableMember = () => {}; - this.correctlyModifiableParameter = 7; - - delete this.correctlyModifiableDeleted; - - this.correctlyModifiablePostDecremented--; - this.correctlyModifiablePostIncremented++; - this.incorrectlyModifiablePostMinus+; - this.incorrectlyModifiablePostPlus+; - --this.correctlyModifiablePreDecremented; - ++this.correctlyModifiablePreIncremented; - -this.incorrectlyModifiablePreMinus; - +this.incorrectlyModifiablePrePlus; - } - - public createConfusingChildClass() { - return class { - private correctlyModifiableInline = 7; - - private readonly incorrectlyModifiableInline = 7; - - private readonly incorrectlyUniqueModifiableInline = 7; - - private childClassExpressionModifiable = 7; - - mutate() { - this.correctlyModifiableInline = 7; - this.childClassExpressionModifiable = 7; - } - } - } - - public workWithSimilarClass(other: SimilarClass) { - other.overlappingClassVariable = 7; - } - - private readonly incorrectlyModifiableMember = () => { }; - - private correctlyModifiableMember = () => { }; -} - -class SimilarClass { - public overlappingClassVariable = 7; -} - -declare class DeclaredClass { - private declaredMember = 7; -} diff --git a/test/rules/prefer-readonly/default/test.ts.lint b/test/rules/prefer-readonly/default/test.ts.lint deleted file mode 100644 index dd02f62316e..00000000000 --- a/test/rules/prefer-readonly/default/test.ts.lint +++ /dev/null @@ -1,169 +0,0 @@ -class SampleClass { - private static readonly correctlyReadonlyStatic = 7; - - private static incorrectlyModifiableStatic = 7; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private static variable 'incorrectlyModifiableStatic' is never reassigned; mark it as 'readonly'.] - - private static incorrectlyModifiableStaticArrow = () => {}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private static variable 'incorrectlyModifiableStaticArrow' is never reassigned; mark it as 'readonly'.] - - private static correctlyModifiableStatic = 7; - - private static correctlyModifiableByParameterProperty = 7; - - private readonly correctlyReadonlyInline = 7; - - private readonly correctlyReadonlyDelayed; - - private incorrectlyModifiableInline = 7; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableInline' is never reassigned; mark it as 'readonly'.] - - private incorrectlyModifiableDelayed; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableDelayed' is never reassigned; mark it as 'readonly'.] - - private correctlyModifiableInline = 7; - - private correctlyModifiableDelayed; - - private correctlyModifiableDeleted = 7; - - private childClassExpressionModifiable = 7; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'childClassExpressionModifiable' is never reassigned; mark it as 'readonly'.] - - private correctlyModifiableWithinConstructor; - - private correctlyModifiableWithinConstructorInArrowFunction; - - private correctlyModifiableWithinConstructorInFunctionExpression; - - private correctlyModifiableWithinConstructorInGetAccessor; - - private correctlyModifiableWithinConstructorInMethodDeclaration; - - private correctlyModifiableWithinConstructorInSetAccessor; - - private correctlyModifiablePostDecremented; - - private correctlyModifiablePostIncremented; - - private incorrectlyModifiablePostMinus; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePostMinus' is never reassigned; mark it as 'readonly'.] - - private incorrectlyModifiablePostPlus; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePostPlus' is never reassigned; mark it as 'readonly'.] - - private correctlyModifiablePreDecremented; - - private correctlyModifiablePreIncremented; - - private incorrectlyModifiablePreMinus; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePreMinus' is never reassigned; mark it as 'readonly'.] - - private incorrectlyModifiablePrePlus; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePrePlus' is never reassigned; mark it as 'readonly'.] - - private overlappingClassVariable = 7; - ~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'overlappingClassVariable' is never reassigned; mark it as 'readonly'.] - - protected protectedModifiable = 7; - - protected publicModifiable = 7; - - public constructor( - private readonly correctlyReadonlyParameter: number = 7, - private incorrectlyModifiableParameter: number = 7, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableParameter' is never reassigned; mark it as 'readonly'.] - private correctlyModifiableParameter: number = 7, - public correctlyModifiablePublicParameter: number = (() => { - return SampleClass.correctlyModifiableByParameterProperty = 7; - })(); - ) { - this.correctlyReadonlyDelayed = 7; - this.incorrectlyModifiableDelayed = 7; - this.incorrectlyModifiableParameter = 7; - - (() => { - const self = this; - - this.correctlyModifiableWithinConstructor = 7; - - (() => { - this.correctlyModifiableWithinConstructorInArrowFunction = 7; - })(); - - (function () { - self.correctlyModifiableWithinConstructorInFunctionExpression = 7; - })(); - - const confusingObject = { - get getAccessor() { - return self.correctlyModifiableWithinConstructorInGetAccessor = 7; - } - - methodDeclaration() { - self.correctlyModifiableWithinConstructorInMethodDeclaration = 7; - } - - set setAccessor() { - self.correctlyModifiableWithinConstructorInSetAccessor = 7; - } - }; - })(); - - SampleClass.correctlyModifiableStatic += 1; - } - - public mutate() { - this.correctlyModifiableDelayed = 7; - this.correctlyModifiableInline = 7; - this.correctlyModifiableMember = () => {}; - this.correctlyModifiableParameter = 7; - - delete this.correctlyModifiableDeleted; - - this.correctlyModifiablePostDecremented--; - this.correctlyModifiablePostIncremented++; - this.incorrectlyModifiablePostMinus+; - this.incorrectlyModifiablePostPlus+; - --this.correctlyModifiablePreDecremented; - ++this.correctlyModifiablePreIncremented; - -this.incorrectlyModifiablePreMinus; - +this.incorrectlyModifiablePrePlus; - } - - public createConfusingChildClass() { - return class { - private correctlyModifiableInline = 7; - - private incorrectlyModifiableInline = 7; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableInline' is never reassigned; mark it as 'readonly'.] - - private incorrectlyUniqueModifiableInline = 7; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyUniqueModifiableInline' is never reassigned; mark it as 'readonly'.] - - private childClassExpressionModifiable = 7; - - mutate() { - this.correctlyModifiableInline = 7; - this.childClassExpressionModifiable = 7; - } - } - } - - public workWithSimilarClass(other: SimilarClass) { - other.overlappingClassVariable = 7; - } - - private incorrectlyModifiableMember = () => { }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableMember' is never reassigned; mark it as 'readonly'.] - - private correctlyModifiableMember = () => { }; -} - -class SimilarClass { - public overlappingClassVariable = 7; -} - -declare class DeclaredClass { - private declaredMember = 7; -} diff --git a/test/rules/prefer-readonly/default/tsconfig.json b/test/rules/prefer-readonly/default/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/prefer-readonly/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/prefer-readonly/default/tslint.json b/test/rules/prefer-readonly/default/tslint.json deleted file mode 100644 index 4eabc221064..00000000000 --- a/test/rules/prefer-readonly/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-readonly": true - } -} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix b/test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix deleted file mode 100644 index c3a23eddf40..00000000000 --- a/test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix +++ /dev/null @@ -1,28 +0,0 @@ -class SampleClass { - private readonly correctlyReadonlyDelayedArrow: () => void; - - private readonly correctlyReadonlyInlineArrow = () => {} - - private readonly correctlyReadonlyValue = 7; - - private correctlyModifiableDelayedArrow: () => void; - - private incorrectlyModifiableDelayedArrow: () => void; - - private readonly incorrectlyModifiableInlineArrow = () => {} - - private correctlyModifiableInlineArrow = () => {} - - private correctlyModifiableValue = 7; - - public constructor() { - this.correctlyModifiableDelayedArrow = () => {}; - this.incorrectlyModifiableDelayedArrow = () => {}; - } - - public mutate() { - this.correctlyModifiableDelayedArrow = () => {}; - this.correctlyModifiableInlineArrow = () => {}; - this.correctlyModifiableValue += 1; - } -} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint b/test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint deleted file mode 100644 index 344109ae72c..00000000000 --- a/test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint +++ /dev/null @@ -1,29 +0,0 @@ -class SampleClass { - private readonly correctlyReadonlyDelayedArrow: () => void; - - private readonly correctlyReadonlyInlineArrow = () => {} - - private readonly correctlyReadonlyValue = 7; - - private correctlyModifiableDelayedArrow: () => void; - - private incorrectlyModifiableDelayedArrow: () => void; - - private incorrectlyModifiableInlineArrow = () => {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableInlineArrow' is never reassigned; mark it as 'readonly'.] - - private correctlyModifiableInlineArrow = () => {} - - private correctlyModifiableValue = 7; - - public constructor() { - this.correctlyModifiableDelayedArrow = () => {}; - this.incorrectlyModifiableDelayedArrow = () => {}; - } - - public mutate() { - this.correctlyModifiableDelayedArrow = () => {}; - this.correctlyModifiableInlineArrow = () => {}; - this.correctlyModifiableValue += 1; - } -} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json b/test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/tslint.json b/test/rules/prefer-readonly/only-inline-lambdas/tslint.json deleted file mode 100644 index 2ac8a95230e..00000000000 --- a/test/rules/prefer-readonly/only-inline-lambdas/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-readonly": [true, "only-inline-lambdas"] - } -} diff --git a/test/rules/prefer-switch/default/test.ts.lint b/test/rules/prefer-switch/default/test.ts.lint deleted file mode 100644 index b8d2bd2f44e..00000000000 --- a/test/rules/prefer-switch/default/test.ts.lint +++ /dev/null @@ -1,79 +0,0 @@ -if (x === 1 || x === 2) {} - -if (x === 1 || x === 2 || x === 3) {} - -if (x === 1 || x === 2 || x === 3) {} - -if (x === 1 || x === 2 || x === -3) {} - -if (x === 1 || x === 2 || x === null) {} - -if (x === 1 || x === 2 || x === true) {} - -if (x === 1 || x === 2 || x === false) {} - -if (x === 1 || x === 2 || x === `123`) {} - -if (x === 1 || x === 2 && x === `123`) {} - -if (x === 1) {} - ~~~~~~~ [0] -else if (x === 2) {} -else if (x === 3) {} - -if (x === 1) {} - ~~~~~~~ [0] -else if (x === 2) {} -else if (x === 3) {} -else {} - -if (x === 1 || x === 2) {} - ~~~~~~~~~~~~~~~~~~ [0] -else if (x === 3) {} - -if (x === 1 || x === 2) {} -else {} - -if (x === 1 || x === 2 || && x === 3) {} -else if (x === 4) {} -else if (x === 5) {} -else {} - -if (x === 1 && x === 2) {} -else if (x === 3) {} -else if (x === 4) {} - -if (x === 1 && x === 2) {} -else if (x === 3) {} -else if (x === 4) {} -else {} - - -if (x === 1 || y === 2) {} -else if (x === 3) {} -else if (x === 4) {} -else {} - - -if (x === 1 && y === 2) {} -else if (x === 3) {} -else if (x === 4 && x === 5) {} -else {} - -if (x === 1 && y === 2) {} -else if (x === 3) {} -else if (x === 4 && x === 5) {} - -export enum ItemType { - FIRST = "FIRST", - SECOND = "SECOND", - THIRD = "THIRD", -} - -if ( - item.type === ItemType.FIRST || - item.type === ItemType.SECOND || - item.type === ItemType.THIRD -) {} - -[0]: Use a switch statement instead of using multiple '===' checks. diff --git a/test/rules/prefer-switch/default/tslint.json b/test/rules/prefer-switch/default/tslint.json deleted file mode 100644 index 82d257e645d..00000000000 --- a/test/rules/prefer-switch/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-switch": true - } -} diff --git a/test/rules/prefer-switch/min-cases-2/test.ts.lint b/test/rules/prefer-switch/min-cases-2/test.ts.lint deleted file mode 100644 index f7ae69c9967..00000000000 --- a/test/rules/prefer-switch/min-cases-2/test.ts.lint +++ /dev/null @@ -1,52 +0,0 @@ -if (x === 1) {} - ~~~~~~~ [0] -else if (x === 2) {} // Notice that we don't get *another* error here. -// Dangling `else` OK (this becomes `default:`) -else if (x === 3) {} -else {} - -if (x === 1) {} else if (x === 2) {} - ~~~~~~~ [0] - -// Works with `||` -if (this === 1 || this === 2) {} - -if (this === 1 || this === 2 || this === 3) {} - - -if (x === 1) {} - ~~~~~~~ [0] -else if (x === 2) {} -else if (x === 3) {} - -if (x === 1) {} - ~~~~~~~ [0] -else if (x === 2) {} - - -// Default minumum of 2 cases. -if (x === 1) {} else {} - -// Different variables, no failure -if (x === 1) {} else if (y === 2) {} - -// Non-simple cases, no failure -if (x === f()) {} else if (x === g()) {} - -// Allow properties -if (x.y.z === a.b) else if (x.y.z === c.d) {} - ~~~~~~~~~~~~~ [0] - -export enum ItemType { - FIRST = "FIRST", - SECOND = "SECOND", - THIRD = "THIRD", -} - -if ( - item.type === ItemType.FIRST || - item.type === ItemType.SECOND || - item.type === ItemType.THIRD -) {} - -[0]: Use a switch statement instead of using multiple '===' checks. diff --git a/test/rules/prefer-switch/min-cases-2/tslint.json b/test/rules/prefer-switch/min-cases-2/tslint.json deleted file mode 100644 index e776dd404f0..00000000000 --- a/test/rules/prefer-switch/min-cases-2/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "prefer-switch": [true, { - "min-cases": 2 - }] - } -} diff --git a/test/rules/prefer-template/allow-single-concat/test.ts.lint b/test/rules/prefer-template/allow-single-concat/test.ts.lint deleted file mode 100644 index 205068dd80d..00000000000 --- a/test/rules/prefer-template/allow-single-concat/test.ts.lint +++ /dev/null @@ -1,37 +0,0 @@ -"a" + x; -x + "a"; - -"a" + x + "b"; -~~~~~~~~~~~~~ [0] - -x + "a" + y; -~~~~~~~~~~~ [0] - -"a" + x + y; -~~~~~~~~~~~ [0] - -"a" + x + "b" + y + "c"; -~~~~~~~~~~~~~~~~~~~~~~~ [0] - -`a` + x + `b${y}c`; -~~~~~~~~~~~~~~~~~~ [0] - -"a" + "b" + "c"; - -x`a` + y; // OK, can't simplify something with a tag - -"a" + "b"; // OK to concatenate regular strings. - -"a\n" + "b"; -~~~~~~~~~~~ [1] - -"a" + "\nb"; -~~~~~~~~~~~ [1] - -1 + 1; -1 + 1 + "a"; -~~~~~~~~~~~ [0] -x + y; - -[0]: Use a template literal instead of concatenating with a string literal. -[1]: Use a multiline template literal instead of concatenating string literals with newlines. diff --git a/test/rules/prefer-template/allow-single-concat/tslint.json b/test/rules/prefer-template/allow-single-concat/tslint.json deleted file mode 100644 index 96d0735c320..00000000000 --- a/test/rules/prefer-template/allow-single-concat/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-template": [true, "allow-single-concat"] - } -} \ No newline at end of file diff --git a/test/rules/prefer-template/default/test.ts.lint b/test/rules/prefer-template/default/test.ts.lint deleted file mode 100644 index 430f5e455f2..00000000000 --- a/test/rules/prefer-template/default/test.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -"a" + x; -~~~~~~~ [0] -x + "a"; -~~~~~~~ [0] - -"a" + x + "b"; -~~~~~~~~~~~~~ [0] - -x + "a" + y; -~~~~~~~~~~~ [0] - -"a" + x + y; -~~~~~~~~~~~ [0] - -"a" + x + "b" + y + "c"; -~~~~~~~~~~~~~~~~~~~~~~~ [0] - -`a` + x + `b${y}c`; -~~~~~~~~~~~~~~~~~~ [0] - -"a" + "b" + "c"; - -x`a` + y; // OK, can't simplify something with a tag - -"a" + "b"; // OK to concatenate strings without newlines. - -"a\n" + "b"; -~~~~~~~~~~~ [1] - -"a" + "\nb"; -~~~~~~~~~~~ [1] - -1 + 1; -1 + 1 + "a"; -~~~~~~~~~~~ [0] -x + y; - -[0]: Use a template literal instead of concatenating with a string literal. -[1]: Use a multiline template literal instead of concatenating string literals with newlines. diff --git a/test/rules/prefer-template/default/tslint.json b/test/rules/prefer-template/default/tslint.json deleted file mode 100644 index 1b743e18ad9..00000000000 --- a/test/rules/prefer-template/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-template": [true] - } -} \ No newline at end of file diff --git a/test/rules/prefer-while/test.ts.fix b/test/rules/prefer-while/test.ts.fix deleted file mode 100644 index 248cc3cc822..00000000000 --- a/test/rules/prefer-while/test.ts.fix +++ /dev/null @@ -1,24 +0,0 @@ -// for loops without an initializer, termination condition, and incrementor should be updated -while (true) { - console.log('Hello World'); -} - -// for loops without an initializer and incrementor should be updated -while (true===true) { - console.log('Hello World'); -} - -// for loops with an initializer, termination condition, and incrementor using '++' should remain untouched -for (let i = 1; i < 10; i++) { - console.log(i); -} - -// for loops with an initializer, termination condition, and incrementor using '+=' should remain untouched -for (let i = 0; i < 10; i+=1) { - console.log(i); -} - -// for loops with an initializer and termination condition should remain untouched -for (let i = 0; i < 10;) { - i += 1; -} diff --git a/test/rules/prefer-while/test.ts.lint b/test/rules/prefer-while/test.ts.lint deleted file mode 100644 index 0b0cad78dd2..00000000000 --- a/test/rules/prefer-while/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -// for loops without an initializer, termination condition, and incrementor should be updated -for(;;) { -~~~~~~~ [Prefer `while` loops instead of `for` loops without an initializer and incrementor.] - console.log('Hello World'); -} - -// for loops without an initializer and incrementor should be updated -for(;true===true;) { -~~~~~~~~~~~~~~~~~~ [Prefer `while` loops instead of `for` loops without an initializer and incrementor.] - console.log('Hello World'); -} - -// for loops with an initializer, termination condition, and incrementor using '++' should remain untouched -for (let i = 1; i < 10; i++) { - console.log(i); -} - -// for loops with an initializer, termination condition, and incrementor using '+=' should remain untouched -for (let i = 0; i < 10; i+=1) { - console.log(i); -} - -// for loops with an initializer and termination condition should remain untouched -for (let i = 0; i < 10;) { - i += 1; -} diff --git a/test/rules/prefer-while/tslint.json b/test/rules/prefer-while/tslint.json deleted file mode 100644 index 87f765de49f..00000000000 --- a/test/rules/prefer-while/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "prefer-while": true - } -} diff --git a/test/rules/promise-function-async/test.ts.lint b/test/rules/promise-function-async/test.ts.lint deleted file mode 100644 index c85dc8c7139..00000000000 --- a/test/rules/promise-function-async/test.ts.lint +++ /dev/null @@ -1,74 +0,0 @@ -declare class Promise{} - -const nonAsyncPromiseFunctionExpressionA = function(p: Promise) { return p; }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const nonAsyncPromiseFunctionExpressionB = function() { return new Promise(); }; - ~~~~~~~~~~ [0] - -// 'async' 'Promise'-returning function expressions are allowed -const asyncPromiseFunctionExpressionA = async function(p: Promise) { return p; }; -const asyncPromiseFunctionExpressionB = async function() { return new Promise(); }; - -// non-'async' non-'Promise'-returning function expressions are allowed -const nonAsyncNonPromiseFunctionExpression = function(n: number) { return n; }; - -function nonAsyncPromiseFunctionDeclarationA(p: Promise) { return p; } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -function nonAsyncPromiseFunctionDeclarationB() { return new Promise(); } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -// 'async' 'Promise'-returning function declarations are allowed -async function asyncPromiseFunctionDeclarationA(p: Promise) { return p; } -async function asyncPromiseFunctionDeclarationB() { return new Promise(); } - -// non-'async' non-'Promise'-returning function declarations are allowed -function nonAsyncNonPromiseFunctionDeclaration(n: number) { return n; } - -const nonAsyncPromiseArrowFunctionA = (p: Promise) => p; - ~~~~~~~~~~~~~~~~~~~~~ [0] - -const nonAsyncPromiseArrowFunctionB = () => new Promise(); - ~~~~~ [0] - -// 'async' 'Promise'-returning arrow functions are allowed -const asyncPromiseArrowFunctionA = async (p: Promise) => p; -const asyncPromiseArrowFunctionB = async () => new Promise(); - -// non-'async' non-'Promise'-returning arrow functions are allowed -const nonAsyncNonPromiseArrowFunction = (n: number) => n; -const nonAsyncNonPromiseArrowFunctionParenthesisOne = (n: number) => (n); -const nonAsyncNonPromiseArrowFunctionParenthesisTwo = (n: number) => ((n)); - -class Test { - public nonAsyncPromiseMethodA(p: Promise) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - return p; - } - - public nonAsyncPromiseMethodB() { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - return new Promise(); - } - - // 'async' 'Promise'-returning methods are allowed - public async asyncPromiseMethodA(p: Promise) { - return p; - } - public async asyncPromiseMethodB() { - return new Promise(); - } - - // non-'async' non-'Promise'-returning methods are allowed - public nonAsyncNonPromiseMethod(n: number) { - return n; - } - - // single statement lamda functions that delegate to another promise-returning function are allowed - public delegatingMethod = () => this.asyncPromiseMethodB(1); - public delegatingMethodParenthesisOne = () => (this.asyncPromiseMethodB(1)); - public delegatingMethodParenthesisTwo = () => ((this.asyncPromiseMethodB(1))); -} - -[0]: functions that return promises must be async diff --git a/test/rules/promise-function-async/tsconfig.json b/test/rules/promise-function-async/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/promise-function-async/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/promise-function-async/tslint.json b/test/rules/promise-function-async/tslint.json deleted file mode 100644 index c4546e54179..00000000000 --- a/test/rules/promise-function-async/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "promise-function-async": true - } -} diff --git a/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix b/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix deleted file mode 100644 index f3e005b4d9f..00000000000 --- a/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix +++ /dev/null @@ -1,13 +0,0 @@ -if (typeof v === `string`) {} - -if (typeof `string` === `number`) {} - -const object: { - "optional-prop"?: `hello-optional` - "optional-function"?(): void - "another-kebab": `hello-value` -} = { - "optional-prop": undefined, - "optional-function"() {}, - "another-kebab": `hello-value` -}; diff --git a/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint b/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint deleted file mode 100644 index 1f33caa5d7b..00000000000 --- a/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint +++ /dev/null @@ -1,21 +0,0 @@ -[typescript]: >=2.7.1 -if (typeof v === "string") {} - ~~~~~~~~ [double] - -if (typeof "string" === 'number') {} - ~~~~~~~~ [double] - ~~~~~~~~ [single] - -const object: { - "optional-prop"?: `hello-optional` - "optional-function"?(): void - "another-kebab": "hello-value" - ~~~~~~~~~~~~~ [double] -} = { - "optional-prop": undefined, - "optional-function"() {}, - "another-kebab": "hello-value" - ~~~~~~~~~~~~~ [double] -}; -[single]: ' should be ` -[double]: " should be ` diff --git a/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix b/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix deleted file mode 100644 index 30b5e84aaa9..00000000000 --- a/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix +++ /dev/null @@ -1,11 +0,0 @@ -if (typeof v === "string") {} - -if (typeof `string` === 'number') {} - -const object: { - "optional-prop"?: "hello-optional" - "another-kebab": "hello-value" -} = { - "optional-prop": undefined, - "another-kebab": "hello-value" -}; diff --git a/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint b/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint deleted file mode 100644 index c4ee7762f0c..00000000000 --- a/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint +++ /dev/null @@ -1,15 +0,0 @@ -[typescript]: <2.7.1 -if (typeof v === "string") {} - -if (typeof "string" === 'number') {} - ~~~~~~~~ [double] - -const object: { - "optional-prop"?: "hello-optional" - "another-kebab": "hello-value" -} = { - "optional-prop": undefined, - "another-kebab": "hello-value" -}; -[single]: ' should be ` -[double]: " should be ` diff --git a/test/rules/quotemark/backtick/test.ts.fix b/test/rules/quotemark/backtick/test.ts.fix deleted file mode 100644 index 55cf8ac4dc2..00000000000 --- a/test/rules/quotemark/backtick/test.ts.fix +++ /dev/null @@ -1,80 +0,0 @@ -"use strict" - -import { Something } from "some-package" -export { SomethingElse } from "another-package" - -enum Sides { - '<- Left', - 'Right ->' -} - -const octalEscapeSequence = '\1' -const octalEscapeSequence2 = '\7' -const octalEscapeSequence3 = '\77' -const octalEscapeSequence4 = '\377' -const octalEscapeSequence5 = '\123' -// Prefix (\47) is an octal escape sequence -const octalEscapeSequence6 = '\477' -const octalEscapeSequence7 = '\\77 \77 \\37 \\77' - -const notOctalEscapeSequence = `\877` -const notOctalEscapeSequence2 = `\017` -const notOctalEscapeSequence3 = `\t` -const notOctalEscapeSequence4 = `\0` -const notOctalEscapeSequence4 = `\\77 \\37 \\\\47 \\\\\\77` - -function strictFunction() { - "use strict" - - const str = `use strict` -} - -var single = `single`; - var double = `married`; -var singleWithinDouble = `'singleWithinDouble'`; -var doubleWithinSingle = `"doubleWithinSingle"`; -var tabNewlineWithinSingle = `tab\tNewline\nWithinSingle`; - -var array: Array<"literal string"> = []; -var arrayTwo: Array<"literal string" | number> = []; -var arrayThree: Array<"literal string" | "hello world"> = []; -var arrayFour: Array<"literal string" | "hello world" | "foo bar"> = []; -var array: Array<"literal string"> = []; -var arrayTwo: Array<"literal string" & number> = []; -var arrayFour: Array<"literal string" | "hello world" & "foo bar"> = []; - -function test() { - -} - -function test() { - -} - -declare var obj: { - helloWorldString: string -} - -interface obj2 { - helloWorldString: string -} - -type objHello = typeof obj["helloWorldString"] -type objHello2 = obj2["helloWorldString"] -let helloValue = obj[`helloWorldString`] - -helloValue = obj[`helloWorldString`] - -const obj3: { - value: typeof obj["helloWorldString"] -} = { - value: obj[`helloWorldString`] -} - -const callback = () => `hi` as number | string - -var hello: `world`; -`escaped'quotemark`; - -// "avoid-template" option is not set. -`foo`; diff --git a/test/rules/quotemark/backtick/test.ts.lint b/test/rules/quotemark/backtick/test.ts.lint deleted file mode 100644 index 99329be41f4..00000000000 --- a/test/rules/quotemark/backtick/test.ts.lint +++ /dev/null @@ -1,99 +0,0 @@ -"use strict" - -import { Something } from "some-package" -export { SomethingElse } from "another-package" - -enum Sides { - '<- Left', - 'Right ->' -} - -const octalEscapeSequence = '\1' -const octalEscapeSequence2 = '\7' -const octalEscapeSequence3 = '\77' -const octalEscapeSequence4 = '\377' -const octalEscapeSequence5 = '\123' -// Prefix (\47) is an octal escape sequence -const octalEscapeSequence6 = '\477' -const octalEscapeSequence7 = '\\77 \77 \\37 \\77' - -const notOctalEscapeSequence = '\877' - ~~~~~~ [single] -const notOctalEscapeSequence2 = '\017' - ~~~~~~ [single] -const notOctalEscapeSequence3 = '\t' - ~~~~ [single] -const notOctalEscapeSequence4 = '\0' - ~~~~ [single] -const notOctalEscapeSequence4 = '\\77 \\37 \\\\47 \\\\\\77' - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [single] - -function strictFunction() { - "use strict" - - const str = "use strict" - ~~~~~~~~~~~~ [double] -} - -var single = 'single'; - ~~~~~~~~ [single] - var double = "married"; - ~~~~~~~~~ [double] -var singleWithinDouble = "'singleWithinDouble'"; - ~~~~~~~~~~~~~~~~~~~~~~ [double] -var doubleWithinSingle = '"doubleWithinSingle"'; - ~~~~~~~~~~~~~~~~~~~~~~ [single] -var tabNewlineWithinSingle = 'tab\tNewline\nWithinSingle'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [single] - -var array: Array<"literal string"> = []; -var arrayTwo: Array<"literal string" | number> = []; -var arrayThree: Array<"literal string" | "hello world"> = []; -var arrayFour: Array<"literal string" | "hello world" | "foo bar"> = []; -var array: Array<"literal string"> = []; -var arrayTwo: Array<"literal string" & number> = []; -var arrayFour: Array<"literal string" | "hello world" & "foo bar"> = []; - -function test() { - -} - -function test() { - -} - -declare var obj: { - helloWorldString: string -} - -interface obj2 { - helloWorldString: string -} - -type objHello = typeof obj["helloWorldString"] -type objHello2 = obj2["helloWorldString"] -let helloValue = obj["helloWorldString"] - ~~~~~~~~~~~~~~~~~~ [double] - -helloValue = obj["helloWorldString"] - ~~~~~~~~~~~~~~~~~~ [double] - -const obj3: { - value: typeof obj["helloWorldString"] -} = { - value: obj["helloWorldString"] - ~~~~~~~~~~~~~~~~~~ [double] -} - -const callback = () => "hi" as number | string - ~~~~ [double] - -var hello: "world"; - ~~~~~~~ [double] -'escaped\'quotemark'; -~~~~~~~~~~~~~~~~~~~~ [single] - -// "avoid-template" option is not set. -`foo`; -[single]: ' should be ` -[double]: " should be ` diff --git a/test/rules/quotemark/backtick/tslint.json b/test/rules/quotemark/backtick/tslint.json deleted file mode 100644 index f10ebc2f972..00000000000 --- a/test/rules/quotemark/backtick/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "backtick"] - } -} diff --git a/test/rules/quotemark/double-avoid-escape/test.ts.fix b/test/rules/quotemark/double-avoid-escape/test.ts.fix deleted file mode 100644 index 249ce46b38e..00000000000 --- a/test/rules/quotemark/double-avoid-escape/test.ts.fix +++ /dev/null @@ -1,5 +0,0 @@ -var single = "single"; - var double = "married"; -var singleWithinDouble = "'singleWithinDouble'"; -var doubleWithinSingle = '"doubleWithinSingle"'; -var tabNewlineWithinSingle = "tab\tNewline\nWithinSingle"; diff --git a/test/rules/quotemark/double-avoid-escape/test.ts.lint b/test/rules/quotemark/double-avoid-escape/test.ts.lint deleted file mode 100644 index 720edf1cd5d..00000000000 --- a/test/rules/quotemark/double-avoid-escape/test.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -var single = 'single'; - ~~~~~~~~ [' should be "] - var double = "married"; -var singleWithinDouble = "'singleWithinDouble'"; -var doubleWithinSingle = '"doubleWithinSingle"'; -var tabNewlineWithinSingle = 'tab\tNewline\nWithinSingle'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] diff --git a/test/rules/quotemark/double-avoid-escape/tslint.json b/test/rules/quotemark/double-avoid-escape/tslint.json deleted file mode 100644 index 6c0f14e3051..00000000000 --- a/test/rules/quotemark/double-avoid-escape/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double", "avoid-escape"] - } -} diff --git a/test/rules/quotemark/double-avoid-template/test.ts.fix b/test/rules/quotemark/double-avoid-template/test.ts.fix deleted file mode 100644 index df3dfeacb23..00000000000 --- a/test/rules/quotemark/double-avoid-template/test.ts.fix +++ /dev/null @@ -1,20 +0,0 @@ -"fo`o"; - -"a 'quote'"; - -'a "quote"'; - -`a "quote" 'quote'`; - -// Allow multi-line templates -` -foo -bar -`; - -// Allow tagged templates and templates with substitutions -foo``; -`${foo}`; - -this.toastCtrl.present('Please tick "Yes" to confirm'); - diff --git a/test/rules/quotemark/double-avoid-template/test.ts.lint b/test/rules/quotemark/double-avoid-template/test.ts.lint deleted file mode 100644 index eb0d6f9481f..00000000000 --- a/test/rules/quotemark/double-avoid-template/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -`fo\`o`; -~~~~~~~ [0] - -`a 'quote'`; -~~~~~~~~~~~ [0] - -`a "quote"`; -~~~~~~~~~~~ [1] - -`a "quote" 'quote'`; - -// Allow multi-line templates -` -foo -bar -`; - -// Allow tagged templates and templates with substitutions -foo``; -`${foo}`; - -this.toastCtrl.present(`Please tick "Yes" to confirm`); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] - -[0]: ` should be " -[1]: ` should be ' diff --git a/test/rules/quotemark/double-avoid-template/tslint.json b/test/rules/quotemark/double-avoid-template/tslint.json deleted file mode 100644 index dbeffb1d574..00000000000 --- a/test/rules/quotemark/double-avoid-template/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double", "avoid-escape", "avoid-template"] - } -} diff --git a/test/rules/quotemark/double/test.ts.fix b/test/rules/quotemark/double/test.ts.fix deleted file mode 100644 index 77531382b02..00000000000 --- a/test/rules/quotemark/double/test.ts.fix +++ /dev/null @@ -1,9 +0,0 @@ -var single = "single"; - var double = "married"; -var singleWithinDouble = "'singleWithinDouble'"; -var doubleWithinSingle = "\"doubleWithinSingle\""; -var tabNewlineWithinSingle = "tab\tNewline\nWithinSingle"; -"escaped'quotemark"; - -// "avoid-template" option is not set. -`foo`; diff --git a/test/rules/quotemark/double/test.ts.lint b/test/rules/quotemark/double/test.ts.lint deleted file mode 100644 index 32fc8dd6f34..00000000000 --- a/test/rules/quotemark/double/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -var single = 'single'; - ~~~~~~~~ [' should be "] - var double = "married"; -var singleWithinDouble = "'singleWithinDouble'"; -var doubleWithinSingle = '"doubleWithinSingle"'; - ~~~~~~~~~~~~~~~~~~~~~~ [' should be "] -var tabNewlineWithinSingle = 'tab\tNewline\nWithinSingle'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] -'escaped\'quotemark'; -~~~~~~~~~~~~~~~~~~~~ [' should be "] - -// "avoid-template" option is not set. -`foo`; diff --git a/test/rules/quotemark/double/tslint.json b/test/rules/quotemark/double/tslint.json deleted file mode 100644 index 9318e0d53e4..00000000000 --- a/test/rules/quotemark/double/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double"] - } -} diff --git a/test/rules/quotemark/invalid-double/test.ts.fix b/test/rules/quotemark/invalid-double/test.ts.fix deleted file mode 100644 index 1e5ab6769e1..00000000000 --- a/test/rules/quotemark/invalid-double/test.ts.fix +++ /dev/null @@ -1,2 +0,0 @@ -var single = "single"; -var unbalancedSingleAfter = ('a) diff --git a/test/rules/quotemark/invalid-double/test.ts.lint b/test/rules/quotemark/invalid-double/test.ts.lint deleted file mode 100644 index 8bf8e15d4f9..00000000000 --- a/test/rules/quotemark/invalid-double/test.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -var single = 'single'; - ~~~~~~~~ [' should be "] -var unbalancedSingleAfter = ('a) diff --git a/test/rules/quotemark/invalid-double/tslint.json b/test/rules/quotemark/invalid-double/tslint.json deleted file mode 100644 index 9318e0d53e4..00000000000 --- a/test/rules/quotemark/invalid-double/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double"] - } -} diff --git a/test/rules/quotemark/invalid-single/test.ts.fix b/test/rules/quotemark/invalid-single/test.ts.fix deleted file mode 100644 index 16e11a81288..00000000000 --- a/test/rules/quotemark/invalid-single/test.ts.fix +++ /dev/null @@ -1,2 +0,0 @@ -var single = 'single'; -var unbalancedSingleAfter = ("a) diff --git a/test/rules/quotemark/invalid-single/test.ts.lint b/test/rules/quotemark/invalid-single/test.ts.lint deleted file mode 100644 index e5525bef1ce..00000000000 --- a/test/rules/quotemark/invalid-single/test.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -var single = "single"; - ~~~~~~~~ [" should be '] -var unbalancedSingleAfter = ("a) diff --git a/test/rules/quotemark/invalid-single/tslint.json b/test/rules/quotemark/invalid-single/tslint.json deleted file mode 100644 index 4a5f880d8ab..00000000000 --- a/test/rules/quotemark/invalid-single/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "single"] - } -} diff --git a/test/rules/quotemark/jsx-double/test.tsx.fix b/test/rules/quotemark/jsx-double/test.tsx.fix deleted file mode 100644 index 52aee4810f8..00000000000 --- a/test/rules/quotemark/jsx-double/test.tsx.fix +++ /dev/null @@ -1,4 +0,0 @@ -import * as React from 'react'; - -export const a = ( -
diff --git a/test/rules/quotemark/jsx-double/test.tsx.lint b/test/rules/quotemark/jsx-double/test.tsx.lint deleted file mode 100644 index ef33be82556..00000000000 --- a/test/rules/quotemark/jsx-double/test.tsx.lint +++ /dev/null @@ -1,8 +0,0 @@ -import * as React from "react"; - ~~~~~~~ [" should be '] - -export const a = ( -
- ~~~~ [' should be "] - ~~~ [" should be '] - ~~~~~~~~~ [" should be '] diff --git a/test/rules/quotemark/jsx-double/tslint.json b/test/rules/quotemark/jsx-double/tslint.json deleted file mode 100644 index 2cd40c48b47..00000000000 --- a/test/rules/quotemark/jsx-double/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true,"jsx-double", "single"] - } -} diff --git a/test/rules/quotemark/jsx-single/test.tsx.fix b/test/rules/quotemark/jsx-single/test.tsx.fix deleted file mode 100644 index 4e9df3a01ce..00000000000 --- a/test/rules/quotemark/jsx-single/test.tsx.fix +++ /dev/null @@ -1,4 +0,0 @@ -import * as React from "react"; - -export const a = ( -
diff --git a/test/rules/quotemark/jsx-single/test.tsx.lint b/test/rules/quotemark/jsx-single/test.tsx.lint deleted file mode 100644 index 9dbc3f68f05..00000000000 --- a/test/rules/quotemark/jsx-single/test.tsx.lint +++ /dev/null @@ -1,7 +0,0 @@ -import * as React from "react"; - -export const a = ( -
- ~~~~~~~ [" should be '] - ~~~ [' should be "] - ~~~~~~~~~ [' should be "] diff --git a/test/rules/quotemark/jsx-single/tslint.json b/test/rules/quotemark/jsx-single/tslint.json deleted file mode 100644 index 587153999f1..00000000000 --- a/test/rules/quotemark/jsx-single/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "double", "jsx-single"] - } -} diff --git a/test/rules/quotemark/single-avoid-escape/test.ts.fix b/test/rules/quotemark/single-avoid-escape/test.ts.fix deleted file mode 100644 index 2b3ee390fe7..00000000000 --- a/test/rules/quotemark/single-avoid-escape/test.ts.fix +++ /dev/null @@ -1,5 +0,0 @@ -var single = 'single'; - var double = 'married'; -var singleWithinDouble = "'singleWithinDouble'"; -var doubleWithinSingle = '"doubleWithinSingle"'; -var tabNewlineWithinDouble = 'tab\tNewline\nWithinDouble'; diff --git a/test/rules/quotemark/single-avoid-escape/test.ts.lint b/test/rules/quotemark/single-avoid-escape/test.ts.lint deleted file mode 100644 index 2084df32b57..00000000000 --- a/test/rules/quotemark/single-avoid-escape/test.ts.lint +++ /dev/null @@ -1,7 +0,0 @@ -var single = 'single'; - var double = "married"; - ~~~~~~~~~ [" should be '] -var singleWithinDouble = "'singleWithinDouble'"; -var doubleWithinSingle = '"doubleWithinSingle"'; -var tabNewlineWithinDouble = "tab\tNewline\nWithinDouble"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [" should be '] diff --git a/test/rules/quotemark/single-avoid-escape/tslint.json b/test/rules/quotemark/single-avoid-escape/tslint.json deleted file mode 100644 index c360887f9d7..00000000000 --- a/test/rules/quotemark/single-avoid-escape/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "single", "avoid-escape"] - } -} diff --git a/test/rules/quotemark/single-avoid-template/test.ts.fix b/test/rules/quotemark/single-avoid-template/test.ts.fix deleted file mode 100644 index 5f26f410553..00000000000 --- a/test/rules/quotemark/single-avoid-template/test.ts.fix +++ /dev/null @@ -1,20 +0,0 @@ -'fo`o'; - -"a 'quote'"; - -'a "quote"'; - -`a "quote" 'quote'`; - -// Allow multi-line templates -` -foo -bar -`; - -// Allow tagged templates and templates with substitutions -foo``; -`${foo}`; - -this.toastCtrl.present('Please tick "Yes" to confirm'); - diff --git a/test/rules/quotemark/single-avoid-template/test.ts.lint b/test/rules/quotemark/single-avoid-template/test.ts.lint deleted file mode 100644 index 8bf33978e84..00000000000 --- a/test/rules/quotemark/single-avoid-template/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -`fo\`o`; -~~~~~~~ [0] - -`a 'quote'`; -~~~~~~~~~~~ [1] - -`a "quote"`; -~~~~~~~~~~~ [0] - -`a "quote" 'quote'`; - -// Allow multi-line templates -` -foo -bar -`; - -// Allow tagged templates and templates with substitutions -foo``; -`${foo}`; - -this.toastCtrl.present(`Please tick "Yes" to confirm`); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: ` should be ' -[1]: ` should be " diff --git a/test/rules/quotemark/single-avoid-template/tslint.json b/test/rules/quotemark/single-avoid-template/tslint.json deleted file mode 100644 index f5eb55e4f0c..00000000000 --- a/test/rules/quotemark/single-avoid-template/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "single", "avoid-escape", "avoid-template"] - } -} diff --git a/test/rules/quotemark/single/test.ts.fix b/test/rules/quotemark/single/test.ts.fix deleted file mode 100644 index 2ed41df170d..00000000000 --- a/test/rules/quotemark/single/test.ts.fix +++ /dev/null @@ -1,6 +0,0 @@ -var single = 'single'; - var double = 'married'; -var singleWithinDouble = '\'singleWithinDouble\''; -var doubleWithinSingle = '"doubleWithinSingle"'; -var tabNewlineWithinDouble = 'tab\tNewline\nWithinDouble'; -'escaped"quotemark'; diff --git a/test/rules/quotemark/single/test.ts.lint b/test/rules/quotemark/single/test.ts.lint deleted file mode 100644 index 292791dcceb..00000000000 --- a/test/rules/quotemark/single/test.ts.lint +++ /dev/null @@ -1,10 +0,0 @@ -var single = 'single'; - var double = "married"; - ~~~~~~~~~ [" should be '] -var singleWithinDouble = "'singleWithinDouble'"; - ~~~~~~~~~~~~~~~~~~~~~~ [" should be '] -var doubleWithinSingle = '"doubleWithinSingle"'; -var tabNewlineWithinDouble = "tab\tNewline\nWithinDouble"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [" should be '] -"escaped\"quotemark"; -~~~~~~~~~~~~~~~~~~~~ [" should be '] diff --git a/test/rules/quotemark/single/test.tsx.lint b/test/rules/quotemark/single/test.tsx.lint deleted file mode 100644 index 08e15a52b36..00000000000 --- a/test/rules/quotemark/single/test.tsx.lint +++ /dev/null @@ -1,2 +0,0 @@ -let foo = - ~~~~~ [" should be '] diff --git a/test/rules/quotemark/single/tslint.json b/test/rules/quotemark/single/tslint.json deleted file mode 100644 index 4a5f880d8ab..00000000000 --- a/test/rules/quotemark/single/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "quotemark": [true, "single"] - } -} diff --git a/test/rules/radix/test.ts.lint b/test/rules/radix/test.ts.lint deleted file mode 100644 index fc1c61e898d..00000000000 --- a/test/rules/radix/test.ts.lint +++ /dev/null @@ -1,28 +0,0 @@ -var x = parseInt(3, 10) + - parseInt(4); - ~~~~~~~~~~~ [Missing radix parameter] -var y = parseFloat("2.5"); - -parser.parseInt("123"); -obj.parser.parseInt("123"); - -global.parseInt("123"); -~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] -global.global.parseInt("123"); -window.parseInt("123"); -~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] - -Number.parseInt("123", 10); -Number.parseInt("123"); -~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] -other.Number.parseInt("123"); - -global.Number.parseInt("123", 10); -global.Number.parseInt("123"); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] -other.global.Number.parseInt("123"); - -window.Number.parseInt("123", 10); -window.Number.parseInt("123"); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] -other.window.Number.parseInt("123"); diff --git a/test/rules/radix/tslint.json b/test/rules/radix/tslint.json deleted file mode 100644 index 38441411292..00000000000 --- a/test/rules/radix/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "radix": true - } -} diff --git a/test/rules/restrict-plus-operands/default/test.ts.lint b/test/rules/restrict-plus-operands/default/test.ts.lint deleted file mode 100644 index f1c604d3efe..00000000000 --- a/test/rules/restrict-plus-operands/default/test.ts.lint +++ /dev/null @@ -1,68 +0,0 @@ -// aliases for number -type MyNumber = number; -type MyString = string; -interface NumberStringPair { - first: MyNumber, - second: MyString -} - -var x = 5; -var y = "10"; -var z = 8.2; -var w = "6.5"; -var pair: NumberStringPair = { - first: 5, - second: "10" -}; - -// bad -var bad1 = 5 + "10"; - ~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5 + "10". Consider using template literals.] -var bad2 = [] + 5; - ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + 5] -var bad3 = [] + {}; - ~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + {}] -var bad4 = [] + []; - ~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + []] -var bad4 = 5 + []; - ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5 + []] -var bad5 = "5" + {}; - ~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found "5" + {}. Consider using template literals.] -var bad6 = 5.5 + "5"; - ~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5.5 + "5". Consider using template literals.] -var bad7 = "5.5" + 5; - ~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found "5.5" + 5. Consider using template literals.] -var bad8 = x + y; - ~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + string. Consider using template literals.] -var bad9 = y + x; - ~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found string + number. Consider using template literals.] -var bad10 = x + {}; - ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + {}] -var bad11 = [] + y; - ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + string. Consider using template literals.] -var bad12 = pair.first + "10"; - ~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + "10". Consider using template literals.] -var bad13 = 5 + pair.second; - ~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5 + string. Consider using template literals.] -var bad14 = pair + pair; - ~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found NumberStringPair + NumberStringPair] -var anyTyped: any = 5; -var bad15 = anyTyped + 12; - ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found any + 12] - -// good -var good1 = 5 + 10; -var good2 = "5.5" + "10"; -var good3 = parseFloat("5.5", 10), + 10; -var good4 = x + z; -var good5 = y + w; - -var good6 = pair.first + 10; -var good7 = pair.first + (10 as MyNumber); -var good8 = "5.5" + pair.second; -var good9 = ("5.5" as MyString) + pair.second; -const good10 = 'hello' + (someBoolean ? 'a' : 'b') + (() => someBoolean ? 'c' : 'd')() + 'e'; - -// don't check other binary expressions -const balls = true; -balls === true; diff --git a/test/rules/restrict-plus-operands/default/tsconfig.json b/test/rules/restrict-plus-operands/default/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/restrict-plus-operands/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/restrict-plus-operands/default/tslint.json b/test/rules/restrict-plus-operands/default/tslint.json deleted file mode 100644 index 8389b1de47a..00000000000 --- a/test/rules/restrict-plus-operands/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "restrict-plus-operands": true - } -} diff --git a/test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint b/test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint deleted file mode 100644 index b8ddc80558c..00000000000 --- a/test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -[typescript]: >= 3.2.0 -type MyNumber = number; -type MyString = string; -type MyBigInt = bigint; -interface NumberStringBigint { - first: MyNumber, - second: MyString, - third: MyBigInt -} - -var x = 5; -var y = "10"; -var bigintVar = BigInt(200); -var anyVar: any = 200; -var pair: NumberStringBigint = { - first: 5, first: 5, - second: "10" second: "10", - third: BigInt(100), -}; - -const bigIntPassA = BigInt(1) + BigInt(2); -const bigIntPassB = BigInt(1) + 100n; -const bigIntFailA = BigInt(1) + 2; - ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + 2] -const bigIntFailB = BigInt(1) + "failureString"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + "failureString". Consider using template literals.] - -const bigIntFailC = bigintVar + x; - ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + number] -const bigIntFailD = y + bigintVar; - ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found string + bigint. Consider using template literals.] -const bigIntFailE = bigintVar + anyVar; - ~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + any] - -const bigIntFailF = pair.first + pair.third; - ~~~~~~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + bigint] -const bigIntFailG = pair.third + pair.second; - ~~~~~~~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + string. Consider using template literals.] -const bigIntFailH = bigintVar + []; - ~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + []] -const bigIntFailI = bigintVar + {}; - ~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + {}] diff --git a/test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json b/test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json deleted file mode 100644 index 0d58d115f70..00000000000 --- a/test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext" - } -} diff --git a/test/rules/restrict-plus-operands/esnext-bigint/tslint.json b/test/rules/restrict-plus-operands/esnext-bigint/tslint.json deleted file mode 100644 index e5801e9ba40..00000000000 --- a/test/rules/restrict-plus-operands/esnext-bigint/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "restrict-plus-operands": true - } -} diff --git a/test/rules/return-undefined/default/test.ts.lint b/test/rules/return-undefined/default/test.ts.lint deleted file mode 100644 index e672954f38d..00000000000 --- a/test/rules/return-undefined/default/test.ts.lint +++ /dev/null @@ -1,92 +0,0 @@ -class Promise { - then(): Promise; -} -function valueWrong(): number | undefined { - return; - ~~~~~~~ [UNDEFINED] -} -function valueRight(): number | undefined { - return undefined; -} - -function voidWrong(): void { - return undefined; - ~~~~~~~~~~~~~~~~~ [VOID] -} -function voidRight(): void { - return; -} - -// Infers type from context. -[].forEach(() => { - return undefined; - ~~~~~~~~~~~~~~~~~ [VOID] -}); -[].map(() => { - return; - ~~~~~~~ [UNDEFINED] -}); - -type Cb = () => void; -declare function badContextualType(cb: Cb | Cb[]): void; -// Uses typeAtLocation instead of contextual type. -badContextualType(() => { - if (1 === 2) return 1; - else return; - ~~~~~~~ [UNDEFINED] -}); - -// Allow anything in callback taking 'any'. -function takesAnyCb(cb: () => any): void; -takesAnyCb(() => { return; }); -takesAnyCb(() => { return undefined; }); -takesAnyCb(() => { - if (1 === 2) return; - else return 1; -}); -takesAnyCb(() => { - if (1 === 2) return; - else return undefined; -}); -takesAnyCb((): void => { - if (1 === 2) return; - else return undefined; - ~~~~~~~~~~~~~~~~~ [VOID] -}); - -async function promiseVoid(): Promise { - if (1 === 2) return; - else return undefined; - ~~~~~~~~~~~~~~~~~ [VOID] -} - -async function promiseValue(): Promise { - if (1 === 2) return 1; - else return; - ~~~~~~~ [UNDEFINED] -} - -declare function test(cb: () => Promise | void): void; - -test(async () => { - if (1 === 2) return; - else return undefined; - ~~~~~~~~~~~~~~~~~ [VOID] -}); - - -function * generator(returnNothing: boolean) { - if (returnNothing) return; - yield 1; - return yield * [2, 3]; -} - -class ClassWithGeneratorMethod { - * generatorMethod(returnNothing: boolean) { - if (returnNothing) return; - yield 1; - } -} - -[VOID]: `void` function should use `return;`, not `return undefined;`. -[UNDEFINED]: Value-returning function should use `return undefined;`, not just `return;`. diff --git a/test/rules/return-undefined/default/tsconfig.json b/test/rules/return-undefined/default/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/return-undefined/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/return-undefined/default/tslint.json b/test/rules/return-undefined/default/tslint.json deleted file mode 100644 index 475b28dc589..00000000000 --- a/test/rules/return-undefined/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "return-undefined": true - } -} diff --git a/test/rules/return-undefined/pre-ts-3.6/test.ts.lint b/test/rules/return-undefined/pre-ts-3.6/test.ts.lint deleted file mode 100644 index b58b43f5719..00000000000 --- a/test/rules/return-undefined/pre-ts-3.6/test.ts.lint +++ /dev/null @@ -1,9 +0,0 @@ -[typescript]: <= 3.6.0 - -// in TS 3.6 and later, the type checker infers this anonymous function as returning 'unknown' -declare function f(action: () => T | undefined): void; -f(() => { return undefined; }); - ~~~~~~~~~~~~~~~~~ [VOID] - -[VOID]: `void` function should use `return;`, not `return undefined;`. -[UNDEFINED]: Value-returning function should use `return undefined;`, not just `return;`. diff --git a/test/rules/return-undefined/pre-ts-3.6/tsconfig.json b/test/rules/return-undefined/pre-ts-3.6/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/return-undefined/pre-ts-3.6/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/return-undefined/pre-ts-3.6/tslint.json b/test/rules/return-undefined/pre-ts-3.6/tslint.json deleted file mode 100644 index 475b28dc589..00000000000 --- a/test/rules/return-undefined/pre-ts-3.6/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "return-undefined": true - } -} diff --git a/test/rules/semicolon/always/test.ts.fix b/test/rules/semicolon/always/test.ts.fix deleted file mode 100644 index 3d15200c279..00000000000 --- a/test/rules/semicolon/always/test.ts.fix +++ /dev/null @@ -1,96 +0,0 @@ -declare module "*"; -declare module "foo" {} -var x = 3; -a += b; - -c = () => { -}; - -d = function() { }; - -console.log("i am adam, am i?"); - -function xyz() { - return; -} - -switch(xyz) { - case 1: - break; - case 2: - continue; -} - -throw new Error("some error"); - -do { - var a = 4; -} while(x == 3); - -debugger; - -import v = require("i"); -module M { - export var x; - export function f(s: string): string; - export function f(n: number): number; - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number; -} - -function useStrictMissingSemicolon() { - "use strict"; - return null; -} - -class MyClass { - public name : string; - private index : number; - private email : string; - - public initializedProperty = 6; - public initializedMethodProperty = () => { - return "hi"; - } - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; - public someMethod(): void; - public someMethod(param): void; - public someMethod(param?) { - return; - } -} - -interface ITest { - foo?: string; - bar: number; // handles comment - qux: string; // handles comment - baz: boolean; - readonly raz: number; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib'; - -export default LoginPage; -export default LoginPage; -export = Date; -export = Date; -type t = number; -type t = number; - -if (true); -for(;;); - - diff --git a/test/rules/semicolon/always/test.ts.lint b/test/rules/semicolon/always/test.ts.lint deleted file mode 100644 index 494175afbf4..00000000000 --- a/test/rules/semicolon/always/test.ts.lint +++ /dev/null @@ -1,131 +0,0 @@ -declare module "*" - ~nil [Missing semicolon] -declare module "foo" {} -var x = 3 - ~nil [Missing semicolon] -a += b - ~nil [Missing semicolon] - -c = () => { -} - ~nil [Missing semicolon] - -d = function() { } - ~nil [Missing semicolon] - -console.log("i am adam, am i?") - ~nil [Missing semicolon] - -function xyz() { - return - ~nil [Missing semicolon] -} - -switch(xyz) { - case 1: - break - ~nil [Missing semicolon] - case 2: - continue - ~nil [Missing semicolon] -} - -throw new Error("some error") - ~nil [Missing semicolon] - -do { - var a = 4 - ~nil [Missing semicolon] -} while(x == 3) - ~nil [Missing semicolon] - -debugger - ~nil [Missing semicolon] - -import v = require("i") - ~nil [Missing semicolon] -module M { - export var x - ~nil [Missing semicolon] - export function f(s: string): string; - export function f(n: number): number - ~nil [Missing semicolon] - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number - ~nil [Missing semicolon] -} - -function useStrictMissingSemicolon() { - "use strict" - ~nil [Missing semicolon] - return null; -} - -class MyClass { - public name : string - ~nil [Missing semicolon] - private index : number - ~nil [Missing semicolon] - private email : string; - - public initializedProperty = 6 - ~nil [Missing semicolon] - public initializedMethodProperty = () => { - return "hi"; - }; - ~ [Unnecessary semicolon] - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } - ~nil [Missing semicolon] - public someMethod(): void; - public someMethod(param): void - ~nil [Missing semicolon] - public someMethod(param?) { - return; - }; - ~ [Unnecessary semicolon] -}; - ~ [Unnecessary semicolon] - -interface ITest { - foo?: string - ~nil [Missing semicolon] - bar: number // handles comment - ~nil [Missing semicolon] - qux: string, // handles comment - ~ [Properties should be separated by semicolons] - baz: boolean; - readonly raz: number; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib' - ~nil [Missing semicolon] - -export default LoginPage; -export default LoginPage - ~nil [Missing semicolon] -export = Date; -export = Date - ~nil [Missing semicolon] -type t = number; -type t = number - ~nil [Missing semicolon] - -if (true); - ~ [Unnecessary semicolon] -for(;;); - -; -~ [Unnecessary semicolon] diff --git a/test/rules/semicolon/always/tslint.json b/test/rules/semicolon/always/tslint.json deleted file mode 100644 index 3df79679a99..00000000000 --- a/test/rules/semicolon/always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "semicolon": [true, "always"] - } -} diff --git a/test/rules/semicolon/enabled/test.ts.fix b/test/rules/semicolon/enabled/test.ts.fix deleted file mode 100644 index b25bb6b528e..00000000000 --- a/test/rules/semicolon/enabled/test.ts.fix +++ /dev/null @@ -1,87 +0,0 @@ -var x = 3; -a += b; - -c = () => { -}; - -f(() => { - return 1; -}); - -d = function() { }; - -console.log("i am adam, am i?"); - -function xyz() { - return; -} - -switch(xyz) { - case 1: - break; - case 2: - continue; -} - -throw new Error("some error"); - -do { - var a = 4; -} while(x == 3); - -debugger; - -import v = require("i"); -module M { - export var x; - export function f(s: string): string; - export function f(n: number): number; - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number; -} - -function useStrictMissingSemicolon() { - "use strict"; - return null; -} - -class MyClass { - public name : string; - private index : number; - private email : string; - - public initializedProperty = 6; - public initializedMethodProperty: mytype = () => { - return "hi"; - } - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; -} - -interface ITest { - foo?: string; - bar: number; - qux: string; - baz: boolean; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib'; - -export default LoginPage; -export default LoginPage; -export = Date; -export = Date; -type t = number; -type t = number; diff --git a/test/rules/semicolon/enabled/test.ts.lint b/test/rules/semicolon/enabled/test.ts.lint deleted file mode 100644 index 9e4f9553030..00000000000 --- a/test/rules/semicolon/enabled/test.ts.lint +++ /dev/null @@ -1,116 +0,0 @@ -var x = 3 - ~nil [Missing semicolon] -a += b - ~nil [Missing semicolon] - -c = () => { -} - ~nil [Missing semicolon] - -f(() => { - return 1; -}); - -d = function() { } - ~nil [Missing semicolon] - -console.log("i am adam, am i?") - ~nil [Missing semicolon] - -function xyz() { - return - ~nil [Missing semicolon] -} - -switch(xyz) { - case 1: - break - ~nil [Missing semicolon] - case 2: - continue - ~nil [Missing semicolon] -} - -throw new Error("some error") - ~nil [Missing semicolon] - -do { - var a = 4 - ~nil [Missing semicolon] -} while(x == 3) - ~nil [Missing semicolon] - -debugger - ~nil [Missing semicolon] - -import v = require("i") - ~nil [Missing semicolon] -module M { - export var x - ~nil [Missing semicolon] - export function f(s: string): string; - export function f(n: number): number - ~nil [Missing semicolon] - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number - ~nil [Missing semicolon] -} - -function useStrictMissingSemicolon() { - "use strict" - ~nil [Missing semicolon] - return null; -} - -class MyClass { - public name : string - ~nil [Missing semicolon] - private index : number - ~nil [Missing semicolon] - private email : string; - - public initializedProperty = 6 - ~nil [Missing semicolon] - public initializedMethodProperty: mytype = () => { - return "hi"; - }; - ~ [Unnecessary semicolon] - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } - ~nil [Missing semicolon] -} - -interface ITest { - foo?: string - ~nil [Missing semicolon] - bar: number - ~nil [Missing semicolon] - qux: string, - ~ [Properties should be separated by semicolons] - baz: boolean; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib' - ~nil [Missing semicolon] - -export default LoginPage; -export default LoginPage - ~nil [Missing semicolon] -export = Date; -export = Date - ~nil [Missing semicolon] -type t = number; -type t = number - ~nil [Missing semicolon] diff --git a/test/rules/semicolon/enabled/tslint.json b/test/rules/semicolon/enabled/tslint.json deleted file mode 100644 index 7a7a8e7d42a..00000000000 --- a/test/rules/semicolon/enabled/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "semicolon": true - } -} diff --git a/test/rules/semicolon/ignore-bound-class-methods/test.ts.fix b/test/rules/semicolon/ignore-bound-class-methods/test.ts.fix deleted file mode 100644 index e31a7abf17b..00000000000 --- a/test/rules/semicolon/ignore-bound-class-methods/test.ts.fix +++ /dev/null @@ -1,83 +0,0 @@ -var x = 3; -a += b; - -c = () => { -}; - -d = function() { }; - -console.log("i am adam, am i?"); - -function xyz() { - return; -} - -switch(xyz) { - case 1: - break; - case 2: - continue; -} - -throw new Error("some error"); - -do { - var a = 4; -} while(x == 3); - -debugger; - -import v = require("i"); -module M { - export var x; - export function f(s: string): string; - export function f(n: number): number; - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number; -} - -function useStrictMissingSemicolon() { - "use strict"; - return null; -} - -class MyClass { - public name : string; - private index : number; - private email : string; - - public initializedProperty = 6; - public initializedMethodProperty = () => { - return "hi"; - }; - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; -} - -interface ITest { - foo?: string; - bar: number; - qux: string; - baz: boolean; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib'; - -export default LoginPage; -export default LoginPage; -export = Date; -export = Date; -type t = number; -type t = number; diff --git a/test/rules/semicolon/ignore-bound-class-methods/test.ts.lint b/test/rules/semicolon/ignore-bound-class-methods/test.ts.lint deleted file mode 100644 index 34f605eb816..00000000000 --- a/test/rules/semicolon/ignore-bound-class-methods/test.ts.lint +++ /dev/null @@ -1,111 +0,0 @@ -var x = 3 - ~nil [Missing semicolon] -a += b - ~nil [Missing semicolon] - -c = () => { -} - ~nil [Missing semicolon] - -d = function() { } - ~nil [Missing semicolon] - -console.log("i am adam, am i?") - ~nil [Missing semicolon] - -function xyz() { - return - ~nil [Missing semicolon] -} - -switch(xyz) { - case 1: - break - ~nil [Missing semicolon] - case 2: - continue - ~nil [Missing semicolon] -} - -throw new Error("some error") - ~nil [Missing semicolon] - -do { - var a = 4 - ~nil [Missing semicolon] -} while(x == 3) - ~nil [Missing semicolon] - -debugger - ~nil [Missing semicolon] - -import v = require("i") - ~nil [Missing semicolon] -module M { - export var x - ~nil [Missing semicolon] - export function f(s: string): string; - export function f(n: number): number - ~nil [Missing semicolon] - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number - ~nil [Missing semicolon] -} - -function useStrictMissingSemicolon() { - "use strict" - ~nil [Missing semicolon] - return null; -} - -class MyClass { - public name : string - ~nil [Missing semicolon] - private index : number - ~nil [Missing semicolon] - private email : string; - - public initializedProperty = 6 - ~nil [Missing semicolon] - public initializedMethodProperty = () => { - return "hi"; - }; - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } - ~nil [Missing semicolon] -} - -interface ITest { - foo?: string - ~nil [Missing semicolon] - bar: number - ~nil [Missing semicolon] - qux: string, - ~ [Properties should be separated by semicolons] - baz: boolean; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib' - ~nil [Missing semicolon] - -export default LoginPage; -export default LoginPage - ~nil [Missing semicolon] -export = Date; -export = Date - ~nil [Missing semicolon] -type t = number; -type t = number - ~nil [Missing semicolon] diff --git a/test/rules/semicolon/ignore-bound-class-methods/tslint.json b/test/rules/semicolon/ignore-bound-class-methods/tslint.json deleted file mode 100644 index 52bef362d4b..00000000000 --- a/test/rules/semicolon/ignore-bound-class-methods/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "semicolon": [true, "always", "ignore-bound-class-methods"] - } -} diff --git a/test/rules/semicolon/ignore-interfaces/test.ts.fix b/test/rules/semicolon/ignore-interfaces/test.ts.fix deleted file mode 100644 index f0fce8929a3..00000000000 --- a/test/rules/semicolon/ignore-interfaces/test.ts.fix +++ /dev/null @@ -1,83 +0,0 @@ -var x = 3; -a += b; - -c = () => { -}; - -d = function() { }; - -console.log("i am adam, am i?"); - -function xyz() { - return; -} - -switch(xyz) { - case 1: - break; - case 2: - continue; -} - -throw new Error("some error"); - -do { - var a = 4; -} while(x == 3); - -debugger; - -import v = require("i"); -module M { - export var x; - export function f(s: string): string; - export function f(n: number): number; - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number; -} - -function useStrictMissingSemicolon() { - "use strict"; - return null; -} - -class MyClass { - public name : string; - private index : number; - private email : string; - - public initializedProperty = 6; - public initializedMethodProperty = () => { - return "hi"; - } - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; -} - -interface ITest { - foo?: string - bar: number - qux: string, - baz: boolean; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib'; - -export default LoginPage; -export default LoginPage; -export = Date; -export = Date; -type t = number; -type t = number; diff --git a/test/rules/semicolon/ignore-interfaces/test.ts.lint b/test/rules/semicolon/ignore-interfaces/test.ts.lint deleted file mode 100644 index 3cad904d7ec..00000000000 --- a/test/rules/semicolon/ignore-interfaces/test.ts.lint +++ /dev/null @@ -1,109 +0,0 @@ -var x = 3 - ~nil [Missing semicolon] -a += b - ~nil [Missing semicolon] - -c = () => { -} - ~nil [Missing semicolon] - -d = function() { } - ~nil [Missing semicolon] - -console.log("i am adam, am i?") - ~nil [Missing semicolon] - -function xyz() { - return - ~nil [Missing semicolon] -} - -switch(xyz) { - case 1: - break - ~nil [Missing semicolon] - case 2: - continue - ~nil [Missing semicolon] -} - -throw new Error("some error") - ~nil [Missing semicolon] - -do { - var a = 4 - ~nil [Missing semicolon] -} while(x == 3) - ~nil [Missing semicolon] - -debugger - ~nil [Missing semicolon] - -import v = require("i") - ~nil [Missing semicolon] -module M { - export var x - ~nil [Missing semicolon] - export function f(s: string): string; - export function f(n: number): number - ~nil [Missing semicolon] - export function f(x: any) { return x; } -} - -declare module "M" { - function f(): number; - function g(): number - ~nil [Missing semicolon] -} - -function useStrictMissingSemicolon() { - "use strict" - ~nil [Missing semicolon] - return null; -} - -class MyClass { - public name : string - ~nil [Missing semicolon] - private index : number - ~nil [Missing semicolon] - private email : string; - - public initializedProperty = 6 - ~nil [Missing semicolon] - public initializedMethodProperty = () => { - return "hi"; - }; - ~ [Unnecessary semicolon] - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } - ~nil [Missing semicolon] -} - -interface ITest { - foo?: string - bar: number - qux: string, - baz: boolean; -} - -import {Router} from 'aurelia-router'; - -import {Controller} from 'my-lib' - ~nil [Missing semicolon] - -export default LoginPage; -export default LoginPage - ~nil [Missing semicolon] -export = Date; -export = Date - ~nil [Missing semicolon] -type t = number; -type t = number - ~nil [Missing semicolon] diff --git a/test/rules/semicolon/ignore-interfaces/tslint.json b/test/rules/semicolon/ignore-interfaces/tslint.json deleted file mode 100644 index a81b2d1b4a4..00000000000 --- a/test/rules/semicolon/ignore-interfaces/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "semicolon": [true, "always", "ignore-interfaces"] - } -} diff --git a/test/rules/semicolon/never/eof1.ts.lint b/test/rules/semicolon/never/eof1.ts.lint deleted file mode 100644 index 1e1cb6b6940..00000000000 --- a/test/rules/semicolon/never/eof1.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -var foo = bar; - ~ [Unnecessary semicolon] \ No newline at end of file diff --git a/test/rules/semicolon/never/eof2.ts.lint b/test/rules/semicolon/never/eof2.ts.lint deleted file mode 100644 index 518b947922c..00000000000 --- a/test/rules/semicolon/never/eof2.ts.lint +++ /dev/null @@ -1,2 +0,0 @@ -return; - ~ [Unnecessary semicolon] \ No newline at end of file diff --git a/test/rules/semicolon/never/test.ts.fix b/test/rules/semicolon/never/test.ts.fix deleted file mode 100644 index f79d5be4a4e..00000000000 --- a/test/rules/semicolon/never/test.ts.fix +++ /dev/null @@ -1,227 +0,0 @@ -declare module "*" -declare module "foo" {} -var x = 3 -a += b - -c = () => { -} - -d = function() { } - -console.log("i am adam, am i?") - -function xyz() { - return -} - -switch(xyz) { - case 1: - break - case 2: - continue -} - -throw new Error("some error") - -do { - var a = 4 -} while(x == 3) - -debugger - -import v = require("i") -module M { - export var x - [] - export var y = x; - [] - export function f(s: string): string - export function f(n: number): number - export function f(x: any) { return x } -} - -declare module "M" { - function f(): number - function g(): number -} - -function useStrictUnnecessarySemicolon() { - "use strict" - return null -} - -class MyClass { - public name : string - private index : number - private email : string - public initializedProperty = 6 - public initializedMethodProperty = () => { - return "hi" - } - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again" - } - - public initializedMethodProperty1Line = () => { return "hi" } - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again" } - public someMethod(): void - public someMethod(param): void - public someMethod(param?) { - return - } -} - -interface ITest { - foo?: string - bar: number - qux: string, - baz: boolean - bas: never} - -import {Router} from 'aurelia-router' - -import {Controller} from 'my-lib' - -// Edge cases when not omitting semicolon needs to be supported - -var a = 1; -("1" + "2").length - -var a = 1; -[].length - -var a = 1; -+"a" - -var a = 1; --1 - -var a = 1 -;("1" + "2").length - -var a = 1 -;[].length - -var a = 1 -;+"a" - -var a = 1 -;-1 - -// For loops uses semicolons as well so make sure we aren't breaking those - -for (var i = 0; i < 10; ++i) { - // do something -} - -export default LoginPage -export default LoginPage - -export = Date -export = Date - -type t = number -type t = number - -if (true); -for(;;); - - - -switch(foo.bar) { - case 'header': header = foo; break - case 'sidebar': sidebar = foo; break - case 'track': track = foo; /* some comment */ break -} - -switch(foo.bar) { - case 'header': header = foo - break - case 'sidebar': sidebar = foo /* some comment - */ break - case 'track': track = foo // some comment - break -} - -const x = f(() => - 0); const y = 2 - -a = b -++c - -foo(); -(bar).foo() - -foo(); -(bar as Bar).foo() - -foo(); -bar.foo() - -foo(); -() => {} - -foo(); -`bar` - -foo(); -`bar${baz}` - -a; -/b/g - -a; -/=b/i - -function bar(foo) { if (foo) return true; return false } -function bar(foo) { if (foo) {return true} return false} - -class Foo { - public [foo] - ['moo'] - public bar = foo; - ['foo'] - public baz = () => true; - ['foobar'] - public baz2 = () => () => {return true} - ['foobarbaz'] - public bas = () => {return true} - ['barfoo'] - public moar = () => - true; - ['barbaz'] -} - -declare module "foo"; -{ /* don't remove semicolon, otherwise the shorthand module get's a body */ } - -function *gen() { - yield - [] - yield 1; - [] - if (foo) - return yield - [] - if (!foo) - return yield 1 || yield - [] - return yield 1; - [] -} - -var foo = () => {} -[] -var bar; var foo = function() {}; -[] - -var -[] - -const -[] - -let -[] diff --git a/test/rules/semicolon/never/test.ts.lint b/test/rules/semicolon/never/test.ts.lint deleted file mode 100644 index f99acd149a6..00000000000 --- a/test/rules/semicolon/never/test.ts.lint +++ /dev/null @@ -1,281 +0,0 @@ -declare module "*"; - ~ [0] -declare module "foo" {} -var x = 3; - ~ [0] -a += b; - ~ [0] - -c = () => { -}; - ~ [0] - -d = function() { }; - ~ [0] - -console.log("i am adam, am i?"); - ~ [0] - -function xyz() { - return; - ~ [0] -} - -switch(xyz) { - case 1: - break; - ~ [0] - case 2: - continue; - ~ [0] -} - -throw new Error("some error"); - ~ [0] - -do { - var a = 4; - ~ [0] -} while(x == 3); - ~ [0] - -debugger; - ~ [0] - -import v = require("i"); - ~ [0] -module M { - export var x; - ~ [0] - [] - export var y = x; - [] - export function f(s: string): string; - ~ [0] - export function f(n: number): number - export function f(x: any) { return x; } - ~ [0] -} - -declare module "M" { - function f(): number; - ~ [0] - function g(): number -} - -function useStrictUnnecessarySemicolon() { - "use strict"; - ~ [0] - return null -} - -class MyClass { - public name : string; - ~ [0] - private index : number; - ~ [0] - private email : string - public initializedProperty = 6 - public initializedMethodProperty = () => { - return "hi"; - ~ [0] - }; - ~ [0] - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - ~ [0] - } - - public initializedMethodProperty1Line = () => { return "hi"; }; - ~ [0] - ~ [0] - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } - ~ [0] - public someMethod(): void; - ~ [0] - public someMethod(param): void - public someMethod(param?) { - return - }; - ~ [0] -}; - ~ [0] - -interface ITest { - foo?: string; - ~ [0] - bar: number; - ~ [0] - qux: string, - baz: boolean - bas: never;} - ~ [0] - -import {Router} from 'aurelia-router' - -import {Controller} from 'my-lib'; - ~ [0] - -// Edge cases when not omitting semicolon needs to be supported - -var a = 1; -("1" + "2").length - -var a = 1; -[].length - -var a = 1; -+"a" - -var a = 1; --1 - -var a = 1 -;("1" + "2").length - -var a = 1 -;[].length - -var a = 1 -;+"a" - -var a = 1 -;-1 - -// For loops uses semicolons as well so make sure we aren't breaking those - -for (var i = 0; i < 10; ++i) { - // do something -} - -export default LoginPage; - ~ [0] -export default LoginPage - -export = Date; - ~ [0] -export = Date - -type t = number; - ~ [0] -type t = number - -if (true); - ~ [0] -for(;;); - -; -~ [0] - -switch(foo.bar) { - case 'header': header = foo; break - case 'sidebar': sidebar = foo; break - case 'track': track = foo; /* some comment */ break -} - -switch(foo.bar) { - case 'header': header = foo; - ~ [0] - break - case 'sidebar': sidebar = foo; /* some comment - ~ [0] - */ break - case 'track': track = foo; // some comment - ~ [0] - break -} - -const x = f(() => - 0); const y = 2 - -a = b; - ~ [0] -++c - -foo(); -(bar).foo() - -foo(); -(bar as Bar).foo() - -foo(); -bar.foo() - -foo(); -() => {} - -foo(); -`bar` - -foo(); -`bar${baz}` - -a; -/b/g - -a; -/=b/i - -function bar(foo) { if (foo) return true; return false } -function bar(foo) { if (foo) {return true;} return false;} - ~ [0] - ~ [0] - -class Foo { - public [foo]; - ~ [0] - ['moo'] - public bar = foo; - ['foo'] - public baz = () => true; - ['foobar'] - public baz2 = () => () => {return true}; - ~ [0] - ['foobarbaz'] - public bas = () => {return true}; - ~ [0] - ['barfoo'] - public moar = () => - true; - ['barbaz'] -} - -declare module "foo"; -{ /* don't remove semicolon, otherwise the shorthand module get's a body */ } - -function *gen() { - yield; - ~ [0] - [] - yield 1; - [] - if (foo) - return yield; - ~ [0] - [] - if (!foo) - return yield 1 || yield; - ~ [0] - [] - return yield 1; - [] -} - -var foo = () => {}; - ~ [0] -[] -var bar; var foo = function() {}; -[] - -var -[] - -const -[] - -let -[] - -[0]: Unnecessary semicolon \ No newline at end of file diff --git a/test/rules/semicolon/never/tslint.json b/test/rules/semicolon/never/tslint.json deleted file mode 100644 index 94dc12a5077..00000000000 --- a/test/rules/semicolon/never/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "semicolon": [true, "never"] - } -} diff --git a/test/rules/semicolon/strict-bound-class-methods/test.ts.fix b/test/rules/semicolon/strict-bound-class-methods/test.ts.fix deleted file mode 100644 index faeb16b4135..00000000000 --- a/test/rules/semicolon/strict-bound-class-methods/test.ts.fix +++ /dev/null @@ -1,22 +0,0 @@ -class MyClass { - public name : string; - private index : number; - private email : string; - - public initializedProperty = 6; - public initializedMethodProperty = () => { - return "hi"; - }; - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - }; - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; - public realMethod() {} - public multilineRealMethod() { - return "foo"; - } -} diff --git a/test/rules/semicolon/strict-bound-class-methods/test.ts.lint b/test/rules/semicolon/strict-bound-class-methods/test.ts.lint deleted file mode 100644 index 2cc42b71ad6..00000000000 --- a/test/rules/semicolon/strict-bound-class-methods/test.ts.lint +++ /dev/null @@ -1,27 +0,0 @@ -class MyClass { - public name : string - ~nil [Missing semicolon] - private index : number - ~nil [Missing semicolon] - private email : string; - - public initializedProperty = 6 - ~nil [Missing semicolon] - public initializedMethodProperty = () => { - return "hi"; - }; - - public initializedMethodPropertyWithoutSemicolon = () => { - return "hi again"; - } - ~nil [Missing semicolon] - - public initializedMethodProperty1Line = () => { return "hi"; }; - - public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } - ~nil [Missing semicolon] - public realMethod() {} - public multilineRealMethod() { - return "foo"; - } -} diff --git a/test/rules/semicolon/strict-bound-class-methods/tslint.json b/test/rules/semicolon/strict-bound-class-methods/tslint.json deleted file mode 100644 index f29bda5b7c7..00000000000 --- a/test/rules/semicolon/strict-bound-class-methods/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "semicolon": [true, "always", "strict-bound-class-methods"] - } -} diff --git a/test/rules/space-before-function-paren/always/test.ts.fix b/test/rules/space-before-function-paren/always/test.ts.fix deleted file mode 100644 index 4322ebd07f9..00000000000 --- a/test/rules/space-before-function-paren/always/test.ts.fix +++ /dev/null @@ -1,75 +0,0 @@ -// Anonymous -function () {} -function (): void { -} -function (a: string, cb: ()=>{}): void {} - -var f = function () {}; -var f = function (): void { -}; -var f = function (a: string, cb: ()=>{}): void {}; - -function () {} -var f = function () {}; - -// Named -function foobar (){} -function foobar (): void{ -} -function foobar (a: string, cb: ()=>{}): void{} - -var f = function foobar (){}; -var f = function foobar (): void{ -}; -var f = function foobar (a: string, cb: ()=>{}): void{}; - -function foobar () {} -var f = function foobar () {} - -// Default export (name ommited) -export default function () {} - -// Async Arrow -// ignore -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -async x => x; - -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -// Method -interface IMyInterface { - one (); - two (): void; - three (a: string, cb: ()=>{}): void; - four (); -} -class MyClass { - one () {} - two (): void { - } - three (a: string, cb: ()=>{}): void {} - four () {} -} - - -// Constructor -class MyClass { - constructor () {} -} -class MyClass { - constructor (): void { - } -} -class MyClass { - constructor (a: string, cb: ()=>{}): void {} -} - diff --git a/test/rules/space-before-function-paren/always/test.ts.lint b/test/rules/space-before-function-paren/always/test.ts.lint deleted file mode 100644 index 5698a0baab7..00000000000 --- a/test/rules/space-before-function-paren/always/test.ts.lint +++ /dev/null @@ -1,104 +0,0 @@ -// Anonymous -function() {} - ~ [space-before-function-paren] -function(): void { - ~ [space-before-function-paren] -} -function(a: string, cb: ()=>{}): void {} - ~ [space-before-function-paren] - -var f = function() {}; - ~ [space-before-function-paren] -var f = function(): void { - ~ [space-before-function-paren] -}; -var f = function(a: string, cb: ()=>{}): void {}; - ~ [space-before-function-paren] - -function () {} -var f = function () {}; - -// Named -function foobar(){} - ~ [space-before-function-paren] -function foobar(): void{ - ~ [space-before-function-paren] -} -function foobar(a: string, cb: ()=>{}): void{} - ~ [space-before-function-paren] - -var f = function foobar(){}; - ~ [space-before-function-paren] -var f = function foobar(): void{ - ~ [space-before-function-paren] -}; -var f = function foobar(a: string, cb: ()=>{}): void{}; - ~ [space-before-function-paren] - -function foobar() {} - ~ [space-before-function-paren] -var f = function foobar() {} - ~ [space-before-function-paren] - -// Default export (name ommited) -export default function() {} - ~ [space-before-function-paren] - -// Async Arrow -// ignore -() => {}; -var arrow = () => {}; - -async() => {}; - ~ [space-before-function-paren] -var arrow = async() => {}; - ~ [space-before-function-paren] - -async x => x; - -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -// Method -interface IMyInterface { - one(); - ~ [space-before-function-paren] - two(): void; - ~ [space-before-function-paren] - three(a: string, cb: ()=>{}): void; - ~ [space-before-function-paren] - four(); - ~ [space-before-function-paren] -} -class MyClass { - one() {} - ~ [space-before-function-paren] - two(): void { - ~ [space-before-function-paren] - } - three(a: string, cb: ()=>{}): void {} - ~ [space-before-function-paren] - four() {} - ~ [space-before-function-paren] -} - - -// Constructor -class MyClass { - constructor() {} - ~ [space-before-function-paren] -} -class MyClass { - constructor(): void { - ~ [space-before-function-paren] - } -} -class MyClass { - constructor(a: string, cb: ()=>{}): void {} - ~ [space-before-function-paren] -} - -[space-before-function-paren]: Missing whitespace before function parens diff --git a/test/rules/space-before-function-paren/always/tslint.json b/test/rules/space-before-function-paren/always/tslint.json deleted file mode 100644 index 57c0714d282..00000000000 --- a/test/rules/space-before-function-paren/always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "space-before-function-paren": true - } -} diff --git a/test/rules/space-before-function-paren/mixed/test.ts.fix b/test/rules/space-before-function-paren/mixed/test.ts.fix deleted file mode 100644 index d087d46fe17..00000000000 --- a/test/rules/space-before-function-paren/mixed/test.ts.fix +++ /dev/null @@ -1,65 +0,0 @@ -// Anonymous -var f = function () {}; -var f = function (): void { -}; -var f = function (a: string, cb: ()=>{}): void {}; - -function () {} -var f = function () {}; - -// Named -function foobar(){} -function foobar(): void{ -} -function foobar(a: string, cb: ()=>{}): void{} - -var f = function foobar(){}; -var f = function foobar(): void{ -}; -var f = function foobar(a: string, cb: ()=>{}): void{}; - -function foobar() {} -var f = function foobar() {} - -// Default export (name ommited) -export default function () {} - -// Async Arrow -// ignore -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -// Method -interface IMyInterface { - one(); - two(): void; - three(a: string, cb: ()=>{}): void; - four(); -} -class MyClass { - one() {} - two(): void { - } - three(a: string, cb: ()=>{}): void {} - four() {} -} - - -// Constructor ignored -class MyClass { - constructor () {} -} -class MyClass { - constructor(): void { - } -} - diff --git a/test/rules/space-before-function-paren/mixed/test.ts.lint b/test/rules/space-before-function-paren/mixed/test.ts.lint deleted file mode 100644 index e7e4379d5f6..00000000000 --- a/test/rules/space-before-function-paren/mixed/test.ts.lint +++ /dev/null @@ -1,89 +0,0 @@ -// Anonymous -var f = function() {}; - ~ [missing-space] -var f = function(): void { - ~ [missing-space] -}; -var f = function(a: string, cb: ()=>{}): void {}; - ~ [missing-space] - -function () {} -var f = function () {}; - -// Named -function foobar (){} - ~ [invalid-space] -function foobar (): void{ - ~ [invalid-space] -} -function foobar (a: string, cb: ()=>{}): void{} - ~ [invalid-space] - -var f = function foobar (){}; - ~ [invalid-space] -var f = function foobar (): void{ - ~ [invalid-space] -}; -var f = function foobar (a: string, cb: ()=>{}): void{}; - ~ [invalid-space] - -function foobar () {} - ~ [invalid-space] -var f = function foobar () {} - ~ [invalid-space] - -// Default export (name ommited) -export default function() {} - ~ [missing-space] - -// Async Arrow -// ignore -() => {}; -var arrow = () => {}; - -async() => {}; - ~ [missing-space] -var arrow = async() => {}; - ~ [missing-space] - -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -// Method -interface IMyInterface { - one (); - ~ [invalid-space] - two (): void; - ~ [invalid-space] - three (a: string, cb: ()=>{}): void; - ~ [invalid-space] - four (); - ~ [invalid-space] -} -class MyClass { - one () {} - ~ [invalid-space] - two (): void { - ~ [invalid-space] - } - three (a: string, cb: ()=>{}): void {} - ~ [invalid-space] - four () {} - ~ [invalid-space] -} - - -// Constructor ignored -class MyClass { - constructor () {} -} -class MyClass { - constructor(): void { - } -} - -[missing-space]: Missing whitespace before function parens -[invalid-space]: Spaces before function parens are disallowed diff --git a/test/rules/space-before-function-paren/mixed/tslint.json b/test/rules/space-before-function-paren/mixed/tslint.json deleted file mode 100644 index f7402bba11a..00000000000 --- a/test/rules/space-before-function-paren/mixed/tslint.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "rules": { - "space-before-function-paren": [ - true, - { - "anonymous": "always", - "asyncArrow": "always", - "constructor": "ignore", - "method": "never", - "named": "never" - } - ] - } -} diff --git a/test/rules/space-before-function-paren/never/test.ts.fix b/test/rules/space-before-function-paren/never/test.ts.fix deleted file mode 100644 index 13090928064..00000000000 --- a/test/rules/space-before-function-paren/never/test.ts.fix +++ /dev/null @@ -1,76 +0,0 @@ -// Anonymous -function() {} -function(): void { -} -function(a: string, cb: ()=>{}): void {} - -var f = function() {}; -var f = function(): void { -}; -var f = function(a: string, cb: ()=>{}): void {}; - -function () {} -var f = function () {}; - -// Named -function foobar(){} -function foobar(): void{ -} -function foobar(a: string, cb: ()=>{}): void{} - -var f = function foobar(){}; -var f = function foobar(): void{ -}; -var f = function foobar(a: string, cb: ()=>{}): void{}; - -function foobar() {} -var f = function foobar() {} - -// Default export (name ommited) -export default function() {} - -// Async Arrow -// ignore -() => {}; -var arrow = () => {}; - -async() => {}; -var arrow = async() => {}; - -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -// Method -interface IMyInterface { - one(); - two(): void; - three(a: string, cb: ()=>{}): void; - four(); -} -class MyClass { - one() {} - two(): void { - } - three(a: string, cb: ()=>{}): void {} - four() {} - - get a() {} - set a() {} -} - - -// Constructor -class MyClass { - constructor() {} -} -class MyClass { - constructor(): void { - } -} -class MyClass { - constructor(a: string, cb: ()=>{}): void {} -} - diff --git a/test/rules/space-before-function-paren/never/test.ts.lint b/test/rules/space-before-function-paren/never/test.ts.lint deleted file mode 100644 index 58aae5922ef..00000000000 --- a/test/rules/space-before-function-paren/never/test.ts.lint +++ /dev/null @@ -1,107 +0,0 @@ -// Anonymous -function () {} - ~ [0] -function (): void { - ~ [0] -} -function (a: string, cb: ()=>{}): void {} - ~ [0] - -var f = function () {}; - ~ [0] -var f = function (): void { - ~ [0] -}; -var f = function (a: string, cb: ()=>{}): void {}; - ~ [0] - -function () {} -var f = function () {}; - -// Named -function foobar (){} - ~ [0] -function foobar (): void{ - ~ [0] -} -function foobar (a: string, cb: ()=>{}): void{} - ~ [0] - -var f = function foobar (){}; - ~ [0] -var f = function foobar (): void{ - ~ [0] -}; -var f = function foobar (a: string, cb: ()=>{}): void{}; - ~ [0] - -function foobar () {} - ~ [0] -var f = function foobar () {} - ~ [0] - -// Default export (name ommited) -export default function () {} - ~ [0] - -// Async Arrow -// ignore -() => {}; -var arrow = () => {}; - -async () => {}; - ~ [0] -var arrow = async () => {}; - ~ [0] - -() => {}; -var arrow = () => {}; - -async () => {}; -var arrow = async () => {}; - -// Method -interface IMyInterface { - one (); - ~ [0] - two (): void; - ~ [0] - three (a: string, cb: ()=>{}): void; - ~ [0] - four (); - ~ [0] -} -class MyClass { - one () {} - ~ [0] - two (): void { - ~ [0] - } - three (a: string, cb: ()=>{}): void {} - ~ [0] - four () {} - ~ [0] - - get a () {} - ~ [0] - set a () {} - ~ [0] -} - - -// Constructor -class MyClass { - constructor () {} - ~ [0] -} -class MyClass { - constructor (): void { - ~ [0] - } -} -class MyClass { - constructor (a: string, cb: ()=>{}): void {} - ~ [0] -} - -[0]: Spaces before function parens are disallowed diff --git a/test/rules/space-before-function-paren/never/tslint.json b/test/rules/space-before-function-paren/never/tslint.json deleted file mode 100644 index 7c3e5f86d59..00000000000 --- a/test/rules/space-before-function-paren/never/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "space-before-function-paren": [true, "never"] - } -} diff --git a/test/rules/space-within-parens/force-one-space/test.ts.fix b/test/rules/space-within-parens/force-one-space/test.ts.fix deleted file mode 100644 index 542a92bfd4a..00000000000 --- a/test/rules/space-within-parens/force-one-space/test.ts.fix +++ /dev/null @@ -1,11 +0,0 @@ -// export statement -export function rgb2lab( r : number, g : number, b : number ) : { L : number; a : number; b: number } { - var xyz = Conversion.rgb2xyz( r, g, b ); - return Conversion.xyz2lab( xyz.x, xyz.y, xyz.z ); -} - -foo( /*no param*/ ); - -// empty parens are always allowed -foo(); - diff --git a/test/rules/space-within-parens/force-one-space/test.ts.lint b/test/rules/space-within-parens/force-one-space/test.ts.lint deleted file mode 100644 index 5ec16cbe06e..00000000000 --- a/test/rules/space-within-parens/force-one-space/test.ts.lint +++ /dev/null @@ -1,21 +0,0 @@ -// export statement -export function rgb2lab(r : number, g : number, b : number) : { L : number; a : number; b: number } { - ~nil [0] - ~nil [0] - var xyz = Conversion.rgb2xyz(r, g, b ); - ~nil [0] - ~ [1] - return Conversion.xyz2lab( xyz.x, xyz.y, xyz.z); - ~~ [1] - ~nil [0] -} - -foo(/*no param*/); - ~nil [0] - ~nil [0] - -// empty parens are always allowed -foo(); - -[0]: Needs 1 whitespace within parentheses -[1]: No more than 1 whitespace within parentheses allowed diff --git a/test/rules/space-within-parens/force-one-space/tslint.json b/test/rules/space-within-parens/force-one-space/tslint.json deleted file mode 100644 index 5727ff26f5c..00000000000 --- a/test/rules/space-within-parens/force-one-space/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "space-within-parens": [true, 1] - } -} diff --git a/test/rules/space-within-parens/force-two-spaces/test.ts.fix b/test/rules/space-within-parens/force-two-spaces/test.ts.fix deleted file mode 100644 index 28b39ff3820..00000000000 --- a/test/rules/space-within-parens/force-two-spaces/test.ts.fix +++ /dev/null @@ -1,28 +0,0 @@ -// simple expression -var x = [{ - a: 1, - b: 2, - d: 34, - c: ( a + b ), -}]; - -// simple expression on one liner -var b = [{a: 1, b: 2, d: 34, c: ( a + b )}]; - -// function parameters -function foo( bar: string, baz: string ); - -// conditional & nested expression -if ( x === y ) { - return ( {result: true, error: ( x + y )} ); -} - -// expected number of spaces provided -new Foo( ); - -// empty parens are always allowed -new Foo(); - -// Missing a space -new Foo( ); - diff --git a/test/rules/space-within-parens/force-two-spaces/test.ts.lint b/test/rules/space-within-parens/force-two-spaces/test.ts.lint deleted file mode 100644 index 268505cbf01..00000000000 --- a/test/rules/space-within-parens/force-two-spaces/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -// simple expression -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b ), - ~nil [1] - ~ [2] -}]; - -// simple expression on one liner -var b = [{a: 1, b: 2, d: 34, c: ( a + b)}]; - ~ [2] - ~nil [1] - -// function parameters -function foo( bar: string, baz: string); - ~nil [0] - ~nil [1] - -// conditional & nested expression -if (x === y) { - ~nil [1] - ~nil [1] - return ({result: true, error: ( x + y )} ); - ~nil [1] - ~ [2] -} - -// expected number of spaces provided -new Foo( ); - -// empty parens are always allowed -new Foo(); - -// Missing a space -new Foo( ); - ~nil [0] - -[0]: Needs 1 whitespace within parentheses -[1]: Needs 2 whitespaces within parentheses -[2]: No more than 2 whitespaces within parentheses allowed diff --git a/test/rules/space-within-parens/force-two-spaces/tslint.json b/test/rules/space-within-parens/force-two-spaces/tslint.json deleted file mode 100644 index d9b45796039..00000000000 --- a/test/rules/space-within-parens/force-two-spaces/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "space-within-parens": [true, 2] - } -} diff --git a/test/rules/space-within-parens/no-space/test.ts.fix b/test/rules/space-within-parens/no-space/test.ts.fix deleted file mode 100644 index c00e7d19386..00000000000 --- a/test/rules/space-within-parens/no-space/test.ts.fix +++ /dev/null @@ -1,37 +0,0 @@ -// simple call -console.clear(); - -// multiline call, this should be skipped -foo( - first, - second, -); - -// conditional -if (process.env === 'production') { - console.log('start'); -} - -// conditional and nested -if (x === 'string' && - y === 'object') { - - // skip this conditional - if ( - true === true && false !=== false - ) { - // load - foo(); - } - console.log('test'); -} - -// other expresions -switch (typeof x) { - default: - break; -} - -// empty parens are always allowed -foo(); - diff --git a/test/rules/space-within-parens/no-space/test.ts.lint b/test/rules/space-within-parens/no-space/test.ts.lint deleted file mode 100644 index fcb1215a5fa..00000000000 --- a/test/rules/space-within-parens/no-space/test.ts.lint +++ /dev/null @@ -1,50 +0,0 @@ -// simple call -console.clear( ); - ~ [0] - -// multiline call, this should be skipped -foo( - first, - second, -); - -// conditional -if ( process.env === 'production' ) { - ~ [0] - ~ [0] - console.log( 'start' ); - ~ [0] - ~ [0] -} - -// conditional and nested -if ( x === 'string' && - ~~ [0] - y === 'object' ) { - ~~ [0] - - // skip this conditional - if ( - true === true && false !=== false - ) { - // load - foo( ); - ~ [0] - } - console.log( 'test' ); - ~ [0] - ~~ [0] -} - -// other expresions -switch ( typeof x ) { - ~~ [0] - ~ [0] - default: - break; -} - -// empty parens are always allowed -foo(); - -[0]: Whitespace within parentheses is not allowed diff --git a/test/rules/space-within-parens/no-space/tslint.json b/test/rules/space-within-parens/no-space/tslint.json deleted file mode 100644 index 4b2d0644357..00000000000 --- a/test/rules/space-within-parens/no-space/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "space-within-parens": [true, 0] - } -} diff --git a/test/rules/static-this/test.ts.fix b/test/rules/static-this/test.ts.fix deleted file mode 100644 index 5d40d646df2..00000000000 --- a/test/rules/static-this/test.ts.fix +++ /dev/null @@ -1,77 +0,0 @@ -class StaticThis { - static value = 0; - static staticValue = StaticThis.value; - - static _color = undefined; - - static get color() { - return StaticThis._color; - } - - static set color(color) { - StaticThis._color = color; - } - - static getTypeOf() { - return StaticThis; - } - - private _value = 5; - - getValue() { - return this._value; - } - - get length() { - return this._value; - } - - set length(value) { - this._value = value; - } -} - -class Child extends StaticThis { - static word = 'Hello'; - static staticValue = Child.word; - - static getTypeOf() { - return Child; - } -} - -const AnonymClass = class { - static getTypeOf() { - return this; - } -} - -class AnonymClassChild extends AnonymClass { - static getTypeOf() { - return AnonymClassChild; - } -} - -const NamedClass = class Name { - static getTypeOf() { - return Name; - } -} - -class NamedClassChild extends NamedClass { - static getTypeOf() { - return NamedClassChild; - } -} - -interface Bar {} - -class Foo { - public static higherOrderComponent(): any { - return class implements Bar { - public constructor() { - console.log(this); - } - }; - } -} diff --git a/test/rules/static-this/test.ts.lint b/test/rules/static-this/test.ts.lint deleted file mode 100644 index 4666f61d9a5..00000000000 --- a/test/rules/static-this/test.ts.lint +++ /dev/null @@ -1,87 +0,0 @@ -class StaticThis { - static value = 0; - static staticValue = this.value; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - - static _color = undefined; - - static get color() { - return this._color; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } - - static set color(color) { - this._color = color; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } - - static getTypeOf() { - return this; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } - - private _value = 5; - - getValue() { - return this._value; - } - - get length() { - return this._value; - } - - set length(value) { - this._value = value; - } -} - -class Child extends StaticThis { - static word = 'Hello'; - static staticValue = this.word; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - - static getTypeOf() { - return this; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } -} - -const AnonymClass = class { - static getTypeOf() { - return this; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } -} - -class AnonymClassChild extends AnonymClass { - static getTypeOf() { - return this; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } -} - -const NamedClass = class Name { - static getTypeOf() { - return this; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } -} - -class NamedClassChild extends NamedClass { - static getTypeOf() { - return this; - ~~~~ [Use the parent class name instead of `this` when in a `static` context.] - } -} - -interface Bar {} - -class Foo { - public static higherOrderComponent(): any { - return class implements Bar { - public constructor() { - console.log(this); - } - }; - } -} diff --git a/test/rules/static-this/tslint.json b/test/rules/static-this/tslint.json deleted file mode 100644 index 76bded512b3..00000000000 --- a/test/rules/static-this/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "static-this": true - } -} diff --git a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint deleted file mode 100644 index 1b97b9d01fd..00000000000 --- a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint +++ /dev/null @@ -1,36 +0,0 @@ -declare function get(): T; - -declare const bu: boolean | undefined; -if (get()) {} -if (get()) {} -if (get()) {} -if (get()) {} - -if (get()) {} -if (get()) {} -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')] -if (get()) {} - ~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')] - -if (get()) {} - ~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'could be undefined')] -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'could be null')] - -// Type of the condition is actually boolean | RegExp, but OK since we check each part separately. -if (get() || get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("operand for the '||' operator", 'could be undefined')] - -// This still fails of course! -if (get() || get()) {} - ~~~~~~~~~~~~~ [err % ("operand for the '||' operator", 'is always truthy')] - ~~~~~~~~~~~~~ [err % ("operand for the '||' operator", 'is always truthy')] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'could be undefined')] - -[err]: This type is not allowed in the %s because it %s. Allowed types are boolean or boolean-or-undefined. \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json deleted file mode 100644 index 60445d1d0fc..00000000000 --- a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-boolean-or-undefined"] - } -} diff --git a/test/rules/strict-boolean-expressions/allow-enum/test.ts.lint b/test/rules/strict-boolean-expressions/allow-enum/test.ts.lint deleted file mode 100644 index 7ff3a6f39bf..00000000000 --- a/test/rules/strict-boolean-expressions/allow-enum/test.ts.lint +++ /dev/null @@ -1,6 +0,0 @@ -declare function get(): T; - -if (get()) {} - -enum E {} -if (get()) {} diff --git a/test/rules/strict-boolean-expressions/allow-enum/tsconfig.json b/test/rules/strict-boolean-expressions/allow-enum/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-enum/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-enum/tslint.json b/test/rules/strict-boolean-expressions/allow-enum/tslint.json deleted file mode 100644 index e7872f36cdb..00000000000 --- a/test/rules/strict-boolean-expressions/allow-enum/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-enum"] - } -} diff --git a/test/rules/strict-boolean-expressions/allow-mix/test.ts.lint b/test/rules/strict-boolean-expressions/allow-mix/test.ts.lint deleted file mode 100644 index 33de775911f..00000000000 --- a/test/rules/strict-boolean-expressions/allow-mix/test.ts.lint +++ /dev/null @@ -1,20 +0,0 @@ -declare function get(): T; - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be a number. Allowed types are boolean, undefined-union, or string.] - -if (get()) {} - -if (get()) {} - -if (get()) {} -if (get()) {} -if (get()) {} - -if (get<"" | "foo">()) {} - -// Mix of truthy values OK -if (get<"foo" | "bar" | undefined>()) {} - -// Mix of falsy values not OK -if (get<"" | boolean>()) {} diff --git a/test/rules/strict-boolean-expressions/allow-mix/tsconfig.json b/test/rules/strict-boolean-expressions/allow-mix/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-mix/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-mix/tslint.json b/test/rules/strict-boolean-expressions/allow-mix/tslint.json deleted file mode 100644 index 0a36db5f45a..00000000000 --- a/test/rules/strict-boolean-expressions/allow-mix/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-string", "allow-undefined-union", "allow-mix"] - } -} diff --git a/test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint b/test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint deleted file mode 100644 index f74cc3614b9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -declare function get(): T; - -if (get()) {} - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or null-union.] - -if (get()) {} - ~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or null-union.] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be undefined. Allowed types are boolean or null-union.] diff --git a/test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json b/test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-null-union/tslint.json b/test/rules/strict-boolean-expressions/allow-null-union/tslint.json deleted file mode 100644 index 68d81e95e18..00000000000 --- a/test/rules/strict-boolean-expressions/allow-null-union/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-null-union"] - } -} diff --git a/test/rules/strict-boolean-expressions/allow-number/test.ts.lint b/test/rules/strict-boolean-expressions/allow-number/test.ts.lint deleted file mode 100644 index 4252ea97086..00000000000 --- a/test/rules/strict-boolean-expressions/allow-number/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -declare function get(): T; - -if (get()) {} - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or number.] - -enum E {} -if (get()) {} - ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Allowed types are boolean or number.] - -if (get<1 | 2>()) {} - ~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Allowed types are boolean or number.] - -if (get<0>()) {} - ~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or number.] - -if (get<0 | 1>()) {} - diff --git a/test/rules/strict-boolean-expressions/allow-number/tsconfig.json b/test/rules/strict-boolean-expressions/allow-number/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-number/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-number/tslint.json b/test/rules/strict-boolean-expressions/allow-number/tslint.json deleted file mode 100644 index e11c8f93fcc..00000000000 --- a/test/rules/strict-boolean-expressions/allow-number/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-number"] - } -} diff --git a/test/rules/strict-boolean-expressions/allow-string/test.ts.lint b/test/rules/strict-boolean-expressions/allow-string/test.ts.lint deleted file mode 100644 index 89930bf3052..00000000000 --- a/test/rules/strict-boolean-expressions/allow-string/test.ts.lint +++ /dev/null @@ -1,14 +0,0 @@ -declare function get(): T; - -if (get()) {} - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or string.] - -if (get<"foo" | "bar">()) {} - ~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Allowed types are boolean or string.] - -if (get<"">()) {} - ~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or string.] - -if (get<"foo" | "">()) {} diff --git a/test/rules/strict-boolean-expressions/allow-string/tsconfig.json b/test/rules/strict-boolean-expressions/allow-string/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-string/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-string/tslint.json b/test/rules/strict-boolean-expressions/allow-string/tslint.json deleted file mode 100644 index 356b40389f6..00000000000 --- a/test/rules/strict-boolean-expressions/allow-string/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-string"] - } -} diff --git a/test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint b/test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint deleted file mode 100644 index 12ff9344f46..00000000000 --- a/test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint +++ /dev/null @@ -1,28 +0,0 @@ -declare function get(): T; - -if (get()) {} - -declare const bu: boolean | undefined; -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or undefined-union.] - -// If it's always undefined, testing for it is wrong. -if (get()) {} - ~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or undefined-union.] - -if (get()) {} - ~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or undefined-union.] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be null. Allowed types are boolean or undefined-union.] - -// Type of the condition is actually boolean | RegExp, but OK since we check each part separately. -if (get() || get()) {} - -// This still fails of course! -if (get() || get()) {} - ~~~~~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Allowed types are boolean or undefined-union.] - ~~~~~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Allowed types are boolean or undefined-union.] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be a number. Allowed types are boolean or undefined-union.] diff --git a/test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json b/test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json b/test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json deleted file mode 100644 index ea0d9855d30..00000000000 --- a/test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-undefined-union"] - } -} diff --git a/test/rules/strict-boolean-expressions/default/test.ts.lint b/test/rules/strict-boolean-expressions/default/test.ts.lint deleted file mode 100644 index b1b1cfff6b5..00000000000 --- a/test/rules/strict-boolean-expressions/default/test.ts.lint +++ /dev/null @@ -1,235 +0,0 @@ -class C { } -enum MyEnum { - A, B, C -} -let anyType: {}; -let boolType: boolean; -let boolType2: boolean; -let bwrapType: Boolean; -let numType = 9; -let strType = "string"; -let objType = new Object(); -let classType = new C(); -let enumType = MyEnum.A; -let boolFn = () => { return true; }; -let strFn = () => { return strType; }; -let numFn = () => { return numType; }; -let boolExpr = (strType !== undefined); - -/*** Binary Expressions ***/ -/*** Invalid Boolean Expressions ***/ -classType && boolType; -~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] -anyType && boolType; -~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] -numType && boolType; -~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] -boolType && strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] -boolType && objType && enumType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] - ~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is an enum. Only booleans are allowed.] -bwrapType && boolType; -~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] - -boolType || classType; - ~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] -boolType || anyType; - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] -boolType || numType; - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] -strType || boolType; -~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] -bwrapType || boolType; -~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] -objType || boolType || enumType; -~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] - ~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is an enum. Only booleans are allowed.] - -boolExpr && strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] -numType || boolExpr; -~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] -numType && boolExpr || strType; -~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] -bwrapType || boolExpr && bwrapType; -~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] - ~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] - -/*** Valid Boolean Expressions ***/ -boolType && boolType2; -boolExpr || boolType; -(numType > 0) && boolFn(); -(strType !== "bool") && boolExpr; -(numType > 0) && (strType !== "bool"); -(strType !== undefined) || (numType < 0); - -/*** ConditionalExpression ***/ -/*** Invalid ***/ -strType ? strType : numType; -~~~~~~~ [This type is not allowed in the condition because it is a string. Only booleans are allowed.] -numType ? numType : numFn(); -~~~~~~~ [This type is not allowed in the condition because it is a number. Only booleans are allowed.] -objType ? objType : boolExpr; -~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.] -classType ? strType : undefined; -~~~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.] -bwrapType ? 1 : 0; -~~~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.] -enumType ? 0 : 1; -~~~~~~~~ [This type is not allowed in the condition because it is an enum. Only booleans are allowed.] - -/*** Valid ***/ -boolFn() ? numType : strType; -boolType ? strType : undefined; - -/*** PrefixUnary Expressions ***/ -/*** Invalid ***/ -!!numType; - ~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is a number. Only booleans are allowed.] -!strType; - ~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is a string. Only booleans are allowed.] -!objType; - ~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.] -!enumType; - ~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is an enum. Only booleans are allowed.] -!!classType; - ~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.] -!bwrapType; - ~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.] -!!undefined; - ~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always falsy. Only booleans are allowed.] - -/*** Valid ***/ -!!boolFn(); -!boolExpr; -!!boolType; - -/*** If Statement ***/ -/*** Invalid ***/ -if (numType) { } - ~~~~~~~ [This type is not allowed in the 'if' condition because it is a number. Only booleans are allowed.] -if (objType) { } - ~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] -if (strType) { } - ~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Only booleans are allowed.] -if (bwrapType) { } - ~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] -if (strFn()) { } - ~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Only booleans are allowed.] -if (MyEnum.A) { } - ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Only booleans are allowed.] -if (classType) { } - ~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] - -/*** Valid ***/ -if (boolFn()) { } -if (boolExpr) { } -if (boolType) { } - -/*** While Statement ***/ -/*** Invalid ***/ -while (numType) { break; } - ~~~~~~~ [This type is not allowed in the 'while' condition because it is a number. Only booleans are allowed.] -while (objType) { break; } - ~~~~~~~ [This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.] -while (strType) { break; } - ~~~~~~~ [This type is not allowed in the 'while' condition because it is a string. Only booleans are allowed.] -while (strFn()) { break; } - ~~~~~~~ [This type is not allowed in the 'while' condition because it is a string. Only booleans are allowed.] -while (bwrapType) { break; } - ~~~~~~~~~ [This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.] -while (MyEnum.A) { break; } - ~~~~~~~~ [This type is not allowed in the 'while' condition because it is an enum. Only booleans are allowed.] -while (classType) { break; } - ~~~~~~~~~ [This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.] - -/*** Valid ***/ -while (boolFn()) { break; } -while (boolExpr) { break; } -while (boolType) { break; } - -/*** Do Statement ***/ -/*** Invalid ***/ -do { break; } while (numType); - ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is a number. Only booleans are allowed.] -do { break; } while (objType); - ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is always truthy. Only booleans are allowed.] -do { break; } while (strType); - ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is a string. Only booleans are allowed.] -do { break; } while (bwrapType); - ~~~~~~~~~ [This type is not allowed in the 'do-while' condition because it is always truthy. Only booleans are allowed.] -do { break; } while (strFn()); - ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is a string. Only booleans are allowed.] -do { break; } while (MyEnum.A); - ~~~~~~~~ [This type is not allowed in the 'do-while' condition because it is an enum. Only booleans are allowed.] -do { break; } while (classType); - ~~~~~~~~~ [This type is not allowed in the 'do-while' condition because it is always truthy. Only booleans are allowed.] - -/*** Valid ***/ -do { break; } while (boolFn()); -do { break; } while (boolExpr); -do { break; } while (boolType); - -/*** For Statement ***/ -/*** Invalid ***/ -for (let j = 0; j; j++) { break; } - ~ [This type is not allowed in the 'for' condition because it is a number. Only booleans are allowed.] -/*** Valid ***/ -for (let j = 0; j > numType; j++) { break; } - -// Allow always-truthy or always-falsy in the case of 'true' and 'false' -while (true) {} -if (false) {} -// Do *not* allow 'true' in a union -declare var trueOrDate: true | Date; -if (trueOrDate) {} - ~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] - -declare var a: any; -// Allow 'any' -if (a) {} - -let bool1:boolean = true -let bool2:boolean = true -let obj:{}|undefined = {} - - bool1 && obj && bool2 - ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] - bool1 && bool2 && obj - ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] - boolExpr && numType || strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] - boolExpr || numType || strType; - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] - boolExpr || numType && strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] - boolExpr && numType && strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] - boolExpr || boolType && strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] - boolExpr || boolType || strType; - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] - boolExpr && boolType || strType; - ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] - - bool1 && obj && bool2 - ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] - - obj && bool2 && obj - ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] - ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] - - obj || bool2 || obj - ~~~ [This type is not allowed in the operand for the '||' operator because it could be undefined. Only booleans are allowed.] - ~~~ [This type is not allowed in the operand for the '||' operator because it could be undefined. Only booleans are allowed.] - - obj || bool2 && obj - ~~~ [This type is not allowed in the operand for the '||' operator because it could be undefined. Only booleans are allowed.] - ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] - diff --git a/test/rules/strict-boolean-expressions/default/tsconfig.json b/test/rules/strict-boolean-expressions/default/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/default/tslint.json b/test/rules/strict-boolean-expressions/default/tslint.json deleted file mode 100644 index 153f37560a7..00000000000 --- a/test/rules/strict-boolean-expressions/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": true - } -} diff --git a/test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint b/test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint deleted file mode 100644 index e1d41ea2198..00000000000 --- a/test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint +++ /dev/null @@ -1,78 +0,0 @@ -class C { } -enum MyEnum { - A, B, C -} -let anyType: {}; -let boolType: boolean; -let boolType2: boolean; -let bwrapType: Boolean; -let numType = 9; -let strType = "string"; -let objType = new Object(); -let classType = new C(); -let enumType = MyEnum.A; -let boolFn = () => { return true; }; -let strFn = () => { return strType; }; -let numFn = () => { return numType; }; -let boolExpr = (strType !== undefined); - -/*** Binary Expressions ***/ -/*** Invalid Boolean Expressions ***/ -classType && boolType; -~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] -anyType && boolType; -~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] -numType && boolType; -~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] -boolType && strType; - -boolType && objType && enumType; - -boolType && objType || enumType; - -boolType || objType && enumType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] - -boolType || objType || enumType; - -bwrapType && boolType; -~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] - -boolType || classType; -boolType || anyType; -boolType || numType; - -strType || boolType; -~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] - -bwrapType || boolType; -~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] - -objType || boolType || enumType; -~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] - -boolExpr && strType; - -numType || boolExpr; -~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] - -numType && boolExpr || strType; -~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] - -bwrapType || boolExpr && bwrapType; -~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] - -let bool1:boolean = true -let bool2:boolean = true -let obj:{}|undefined = {} - -bool1 && obj && bool2 -bool1 && bool2 && obj -boolExpr && numType || strType; -boolExpr || numType || strType; -boolExpr || numType && strType; - ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] -boolExpr && numType && strType; -boolExpr || boolType && strType; -boolExpr || boolType || strType; -boolExpr && boolType || strType; diff --git a/test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json b/test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json deleted file mode 100644 index c4d430eb449..00000000000 --- a/test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} diff --git a/test/rules/strict-boolean-expressions/ignore-rhs/tslint.json b/test/rules/strict-boolean-expressions/ignore-rhs/tslint.json deleted file mode 100644 index 9e38e7b80ff..00000000000 --- a/test/rules/strict-boolean-expressions/ignore-rhs/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "ignore-rhs"] - } -} diff --git a/test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint b/test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint deleted file mode 100644 index 884aa5fcaa1..00000000000 --- a/test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint +++ /dev/null @@ -1,28 +0,0 @@ -declare function get(): T; - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be a number. Allowed types are boolean, undefined-union, or string.] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [mix] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~ [mix] - -if (get()) {} -if (get()) {} -if (get()) {} - -if (get<"" | "foo">()) {} - -// Mix of truthy values OK -if (get<"foo" | "bar" | undefined>()) {} - -// Mix of falsy values not OK -if (get<"" | boolean>()) {} - ~~~~~~~~~~~~~~~~~~~ [mix] - -// Mix of 1 falsy with any number of truthy OK -if (get()) {} - -[mix]: This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean, undefined-union, or string. diff --git a/test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json b/test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/no-allow-mix/tslint.json b/test/rules/strict-boolean-expressions/no-allow-mix/tslint.json deleted file mode 100644 index 01f7ab6fe2a..00000000000 --- a/test/rules/strict-boolean-expressions/no-allow-mix/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-string", "allow-undefined-union"] - } -} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint deleted file mode 100644 index b050100493c..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint +++ /dev/null @@ -1,17 +0,0 @@ -declare function get(): T; - -// Everything except string/number/enum is allowed. -if (get<{ x: number }>) {} - -if (get()) {} - ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Allowed types are boolean or null-union.] - -if (get()) {} - ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a number. Allowed types are boolean or null-union.] - -enum E {} -if (get()) {} - ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Allowed types are boolean or null-union.] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be an enum. Allowed types are boolean or null-union.] diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json deleted file mode 100644 index 32e6931d462..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "strictNullChecks": false - } -} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json deleted file mode 100644 index 68d81e95e18..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-null-union"] - } -} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint deleted file mode 100644 index 4b4f8876962..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint +++ /dev/null @@ -1,9 +0,0 @@ -declare function get(): T; - -if (get()) {} - -if (get()) {} - -enum E {} -if (get()) {} - ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Allowed types are boolean, string, or number.] diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json deleted file mode 100644 index 7cbb28510b8..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": false - } -} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json deleted file mode 100644 index 584f5f112f6..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": [true, "allow-number", "allow-string"] - } -} diff --git a/test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint b/test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint deleted file mode 100644 index 35c82de1b14..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint +++ /dev/null @@ -1,17 +0,0 @@ -declare function get(): T; - -if (get<{ x: number }>) {} - ~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. It may be null/undefined, but neither 'allow-null-union' nor 'allow-undefined-union' is set. Only booleans are allowed.] - -if (get()) {} - ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Only booleans are allowed.] - -if (get()) {} - ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a number. Only booleans are allowed.] - -enum E {} -if (get()) {} - ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Only booleans are allowed.] - -if (get()) {} - ~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be an enum. Only booleans are allowed.] diff --git a/test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json b/test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/strict-boolean-expressions/no-null-checks/tslint.json b/test/rules/strict-boolean-expressions/no-null-checks/tslint.json deleted file mode 100644 index 153f37560a7..00000000000 --- a/test/rules/strict-boolean-expressions/no-null-checks/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-boolean-expressions": true - } -} diff --git a/test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint b/test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint deleted file mode 100644 index 1a939a87458..00000000000 --- a/test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint +++ /dev/null @@ -1,182 +0,0 @@ -if (2) {} -if (2 > 1) {} -if (2 < 1) {} -if (2 >= 1) {} -if (2 <= 1) {} -if (2 == 1) {} -if (2 === 1) {} -if (2 != 1) {} -if (2 !== 1) {} -if (2 > undefined) {} - ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (undefined === 1) {} -if (2 > undefined) {} - ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (true) {} -if (true > false) {} - ~~~~~~~~~~~~ [CANNOT_USE % (">", "boolean")] -if (true < false) {} - ~~~~~~~~~~~~ [CANNOT_USE % ("<", "boolean")] -if (true >= false) {} - ~~~~~~~~~~~~~ [CANNOT_USE % (">=", "boolean")] -if (true <= false) {} - ~~~~~~~~~~~~~ [CANNOT_USE % ("<=", "boolean")] -if (true == false) {} -if (true === false) {} -if (true != false) {} -if (true !== false) {} -if ('') {} -if ('' > '') {} - ~~~~~~~ [CANNOT_USE % (">", "string")] -if ('' < '') {} - ~~~~~~~ [CANNOT_USE % ("<", "string")] -if ('' >= '') {} - ~~~~~~~~ [CANNOT_USE % (">=", "string")] -if ('' <= '') {} - ~~~~~~~~ [CANNOT_USE % ("<=", "string")] -if ('' == '') {} -if ('' === '') {} -if ('' != '') {} -if ('' !== '') {} -if ({}) {} -if ({} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "object")] -if ({} < {}) {} - ~~~~~~~ [CANNOT_USE % ("<", "object")] -if ({} >= {}) {} - ~~~~~~~~ [CANNOT_USE % (">=", "object")] -if ({} <= {}) {} - ~~~~~~~~ [CANNOT_USE % ("<=", "object")] -if ({} == {}) {} -if ({} === {}) {} -if ({} != {}) {} -if ({} !== {}) {} -if ([] === []) {} - -if (3 > 2 || 2 > 1 && true === true) {} -if ('' > '' || 2 > 1 || {} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "string")] - ~~~~~~~ [CANNOT_USE % (">", "object")] -if ('' > '' && 2 > 1 && {} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "string")] - ~~~~~~~ [CANNOT_USE % (">", "object")] - -if ({} === null) {} -if (null === {}) {} -if ({} === undefined) {} -if (undefined === {}) {} - -function sameObject(a: T, b: T): boolean { - return a === b; -} - -function sameObject(a: any, b: any): boolean { - return a === b; -} - -type myNumber = number; -const a1: myNumber = 1 -const a2: myNumber = 2 - -if (a1 < a2) {} -if (a2 < a1) {} - -type myString = string; -const b1: myString = '' -const b2: myString = '' - -if (b1 === b2) {} -if (b2 === b1) {} - -type myObject = Object; -const c1: myObject = {} -const c2: myObject = {} - -if (c1 === c2) {} -if (c2 === c1) {} - -const d1: any = 'string' -const d2: any = 2 -if (d1 === d2) {} -if (d2 === d1) {} - -enum TestNumericEnum { - One = 1, - Two = 2, -} - -const e1: TestNumericEnum = TestNumericEnum.One - -#if typescript > 2.1 -if (e1 === TestNumericEnum.Two) {} -if (TestNumericEnum.Two === e1) {} -if (e1 > TestNumericEnum.Two) {} -if (TestNumericEnum.Two > e1) {} -#endif - -const f1: TestNumericEnum | undefined -const f2: TestNumericEnum | undefined - -if (f1 === f2) {} -if (f2 === f1) {} - -enum TestStringEnum { - One = 'one', - Two = 'two', -} - -const g1: TestStringEnum = TestStringEnum.One - -#if typescript > 2.1 -if (g1 === TestStringEnum.Two) {} -if (TestStringEnum.Two === g1) {} -if (g1 > TestStringEnum.Two) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] -if (TestStringEnum.Two > g1) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] -#endif - -const h1: string | number = Math.random() > 0.5 ? 'text' : 5; -const h2: string | number = Math.random() > 0.5 ? 'test' : 2; -if (h1 > h2) {} - ~~~~~~~ [Cannot use '>' comparator for type 'string'.] -if (h2 > h1) {} - ~~~~~~~ [Cannot use '>' comparator for type 'string'.] -if (h1 === h2) {} -if (h2 === h1) {} - -if (undefined === null) {} -if (null !== undefined) {} - -if (1 > null) {} - ~~~~~~~~ [CANNOT_COMPARE % ("number", "null")] -if (null > 1) {} - ~~~~~~~~ [CANNOT_COMPARE % ("null", "number")] -if (1 >= undefined) {} - ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (undefined >= 1) {} - ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "number")] -if (undefined <= null) {} - ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "null")] -if (null >= undefined) {} - ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("null", "undefined")] - -const func = (param?: boolean): boolean => { - return param === undefined ? false : param; -} -const func = (param?: boolean): boolean => { - return param === null ? false : true; -} -const func = (param: number): number => { - return param + 1; -} -const func = (arg1: number, arg2: number): boolean => { - return arg1 === arg2; -} -const func = (param: string | null = null) => { - if (param !== null) {} - if (param !== undefined) {} -} - -[CANNOT_USE]: Cannot use '%s' comparator for type '%s'. -[CANNOT_COMPARE]: Cannot compare type '%s' to type '%s'. diff --git a/test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json b/test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json b/test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json deleted file mode 100644 index dd0d1e1c181..00000000000 --- a/test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "strict-comparisons": [ - true, - { - "allow-object-equal-comparison": true - } - ] - } -} diff --git a/test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint b/test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint deleted file mode 100644 index 30c5405f0d5..00000000000 --- a/test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint +++ /dev/null @@ -1,178 +0,0 @@ -if (2) {} -if (2 > 1) {} -if (2 < 1) {} -if (2 >= 1) {} -if (2 <= 1) {} -if (2 == 1) {} -if (2 === 1) {} -if (2 != 1) {} -if (2 !== 1) {} -if (2 > undefined) {} - ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (undefined === 1) {} -if (2 > undefined) {} - ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (true) {} -if (true > false) {} - ~~~~~~~~~~~~ [CANNOT_USE % (">", "boolean")] -if (true < false) {} - ~~~~~~~~~~~~ [CANNOT_USE % ("<", "boolean")] -if (true >= false) {} - ~~~~~~~~~~~~~ [CANNOT_USE % (">=", "boolean")] -if (true <= false) {} - ~~~~~~~~~~~~~ [CANNOT_USE % ("<=", "boolean")] -if (true == false) {} -if (true === false) {} -if (true != false) {} -if (true !== false) {} -if ('') {} -if ('' > '') {} -if ('' < '') {} -if ('' >= '') {} -if ('' <= '') {} -if ('' == '') {} -if ('' === '') {} -if ('' != '') {} -if ('' !== '') {} -if ({}) {} -if ({} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "object")] -if ({} < {}) {} - ~~~~~~~ [CANNOT_USE % ("<", "object")] -if ({} >= {}) {} - ~~~~~~~~ [CANNOT_USE % (">=", "object")] -if ({} <= {}) {} - ~~~~~~~~ [CANNOT_USE % ("<=", "object")] -if ({} == {}) {} - ~~~~~~~~ [CANNOT_USE % ("==", "object")] -if ({} === {}) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] -if ({} != {}) {} - ~~~~~~~~ [CANNOT_USE % ("!=", "object")] -if ({} !== {}) {} - ~~~~~~~~~ [CANNOT_USE % ("!==", "object")] -if ([] === []) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] - -if (3 > 2 || 2 > 1 && true === true) {} -if ('' > '' || 2 > 1 || {} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "object")] -if ('' > '' && 2 > 1 && {} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "object")] - -if ({} === null) {} -if (null === {}) {} -if ({} === undefined) {} -if (undefined === {}) {} - -function sameObject(a: T, b: T): boolean { - return a === b; - ~~~~~~~ [CANNOT_USE % ("===", "object")] -} - -function sameObject(a: any, b: any): boolean { - return a === b; -} - -type myNumber = number; -const a1: myNumber = 1 -const a2: myNumber = 2 - -if (a1 < a2) {} -if (a2 < a1) {} - -type myString = string; -const b1: myString = '' -const b2: myString = '' - -if (b1 === b2) {} -if (b2 === b1) {} - -type myObject = Object; -const c1: myObject = {} -const c2: myObject = {} - -if (c1 === c2) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] -if (c2 === c1) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] - -const d1: any = 'string' -const d2: any = 2 -if (d1 === d2) {} -if (d2 === d1) {} - -enum TestNumericEnum { - One = 1, - Two = 2, -} - -const e1: TestNumericEnum = TestNumericEnum.One - -#if typescript > 2.1 -if (e1 === TestNumericEnum.Two) {} -if (TestNumericEnum.Two === e1) {} -if (e1 > TestNumericEnum.Two) {} -if (TestNumericEnum.Two > e1) {} - -const f1: TestNumericEnum | undefined -const f2: TestNumericEnum | undefined - -if (f1 === f2) {} -if (f2 === f1) {} - -enum TestStringEnum { - One = 'one', - Two = 'two', -} - -const g1: TestStringEnum = TestStringEnum.One - -if (g1 === TestStringEnum.Two) {} -if (TestStringEnum.Two === g1) {} -if (g1 > TestStringEnum.Two) {} -if (TestStringEnum.Two > g1) {} -#endif - -const h1: string | number = Math.random() > 0.5 ? 'text' : 5; -const h2: string | number = Math.random() > 0.5 ? 'test' : 2; -if (h1 > h2) {} -if (h2 > h1) {} -if (h1 === h2) {} -if (h2 === h1) {} - -if (undefined === null) {} -if (null !== undefined) {} - -if (1 > null) {} - ~~~~~~~~ [CANNOT_COMPARE % ("number", "null")] -if (null > 1) {} - ~~~~~~~~ [CANNOT_COMPARE % ("null", "number")] -if (1 >= undefined) {} - ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (undefined >= 1) {} - ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "number")] -if (undefined <= null) {} - ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "null")] -if (null >= undefined) {} - ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("null", "undefined")] - -const func = (param?: boolean): boolean => { - return param === undefined ? false : param; -} -const func = (param?: boolean): boolean => { - return param === null ? false : true; -} -const func = (param: number): number => { - return param + 1; -} -const func = (arg1: number, arg2: number): boolean => { - return arg1 === arg2; -} -const func = (param: string | null = null) => { - if (param !== null) {} - if (param !== undefined) {} -} - -[CANNOT_USE]: Cannot use '%s' comparator for type '%s'. -[CANNOT_COMPARE]: Cannot compare type '%s' to type '%s'. diff --git a/test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json b/test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/strict-comparisons/allow-string-order-comparison/tslint.json b/test/rules/strict-comparisons/allow-string-order-comparison/tslint.json deleted file mode 100644 index 3e54a84a891..00000000000 --- a/test/rules/strict-comparisons/allow-string-order-comparison/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "strict-comparisons": [ - true, - { - "allow-string-order-comparison": true - } - ] - } -} diff --git a/test/rules/strict-comparisons/default/test.ts.lint b/test/rules/strict-comparisons/default/test.ts.lint deleted file mode 100644 index 8a1a7a83744..00000000000 --- a/test/rules/strict-comparisons/default/test.ts.lint +++ /dev/null @@ -1,190 +0,0 @@ -if (2) {} -if (2 > 1) {} -if (2 < 1) {} -if (2 >= 1) {} -if (2 <= 1) {} -if (2 == 1) {} -if (2 === 1) {} -if (2 != 1) {} -if (2 !== 1) {} -if (2 > undefined) {} - ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (undefined === 1) {} -if (2 > undefined) {} - ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (true) {} -if (true > false) {} - ~~~~~~~~~~~~ [CANNOT_USE % (">", "boolean")] -if (true < false) {} - ~~~~~~~~~~~~ [CANNOT_USE % ("<", "boolean")] -if (true >= false) {} - ~~~~~~~~~~~~~ [CANNOT_USE % (">=", "boolean")] -if (true <= false) {} - ~~~~~~~~~~~~~ [CANNOT_USE % ("<=", "boolean")] -if (true == false) {} -if (true === false) {} -if (true != false) {} -if (true !== false) {} -if ('') {} -if ('' > '') {} - ~~~~~~~ [CANNOT_USE % (">", "string")] -if ('' < '') {} - ~~~~~~~ [CANNOT_USE % ("<", "string")] -if ('' >= '') {} - ~~~~~~~~ [CANNOT_USE % (">=", "string")] -if ('' <= '') {} - ~~~~~~~~ [CANNOT_USE % ("<=", "string")] -if ('' == '') {} -if ('' === '') {} -if ('' != '') {} -if ('' !== '') {} -if ({}) {} -if ({} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "object")] -if ({} < {}) {} - ~~~~~~~ [CANNOT_USE % ("<", "object")] -if ({} >= {}) {} - ~~~~~~~~ [CANNOT_USE % (">=", "object")] -if ({} <= {}) {} - ~~~~~~~~ [CANNOT_USE % ("<=", "object")] -if ({} == {}) {} - ~~~~~~~~ [CANNOT_USE % ("==", "object")] -if ({} === {}) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] -if ({} != {}) {} - ~~~~~~~~ [CANNOT_USE % ("!=", "object")] -if ({} !== {}) {} - ~~~~~~~~~ [CANNOT_USE % ("!==", "object")] -if ([] === []) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] - -if (3 > 2 || 2 > 1 && true === true) {} -if ('' > '' || 2 > 1 || {} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "string")] - ~~~~~~~ [CANNOT_USE % (">", "object")] -if ('' > '' && 2 > 1 && {} > {}) {} - ~~~~~~~ [CANNOT_USE % (">", "string")] - ~~~~~~~ [CANNOT_USE % (">", "object")] - -if ({} === null) {} -if (null === {}) {} -if ({} === undefined) {} -if (undefined === {}) {} - -function sameObject(a: T, b: T): boolean { - return a === b; - ~~~~~~~ [CANNOT_USE % ("===", "object")] -} - -function sameObject(a: any, b: any): boolean { - return a === b; -} - -type myNumber = number; -const a1: myNumber = 1 -const a2: myNumber = 2 - -if (a1 < a2) {} -if (a2 < a1) {} - -type myString = string; -const b1: myString = '' -const b2: myString = '' - -if (b1 === b2) {} -if (b2 === b1) {} - -type myObject = Object; -const c1: myObject = {} -const c2: myObject = {} - -if (c1 === c2) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] -if (c2 === c1) {} - ~~~~~~~~~ [CANNOT_USE % ("===", "object")] - -const d1: any = 'string' -const d2: any = 2 -if (d1 === d2) {} -if (d2 === d1) {} - -enum TestNumericEnum { - One = 1, - Two = 2, -} - -const e1: TestNumericEnum = TestNumericEnum.One - -#if typescript > 2.1 -if (e1 === TestNumericEnum.Two) {} -if (TestNumericEnum.Two === e1) {} -if (e1 > TestNumericEnum.Two) {} -if (TestNumericEnum.Two > e1) {} -#endif - -const f1: TestNumericEnum | undefined -const f2: TestNumericEnum | undefined - -#if typescript > 2.1 -if (f1 === f2) {} -if (f2 === f1) {} - -enum TestStringEnum { - One = 'one', - Two = 'two', -} - -const g1: TestStringEnum = TestStringEnum.One - -if (g1 === TestStringEnum.Two) {} -if (TestStringEnum.Two === g1) {} -if (g1 > TestStringEnum.Two) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] -if (TestStringEnum.Two > g1) {} - ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] -#endif - -const h1: string | number = Math.random() > 0.5 ? 'text' : 5; -const h2: string | number = Math.random() > 0.5 ? 'test' : 2; -if (h1 > h2) {} - ~~~~~~~ [CANNOT_USE % (">", "string")] -if (h2 > h1) {} - ~~~~~~~ [CANNOT_USE % (">", "string")] -if (h1 === h2) {} -if (h2 === h1) {} - -if (undefined === null) {} -if (null !== undefined) {} - -if (1 > null) {} - ~~~~~~~~ [CANNOT_COMPARE % ("number", "null")] -if (null > 1) {} - ~~~~~~~~ [CANNOT_COMPARE % ("null", "number")] -if (1 >= undefined) {} - ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] -if (undefined >= 1) {} - ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "number")] -if (undefined <= null) {} - ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "null")] -if (null >= undefined) {} - ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("null", "undefined")] - -const func = (param?: boolean): boolean => { - return param === undefined ? false : param; -} -const func = (param?: boolean): boolean => { - return param === null ? false : true; -} -const func = (param: number): number => { - return param + 1; -} -const func = (arg1: number, arg2: number): boolean => { - return arg1 === arg2; -} -const func = (param: string | null = null) => { - if (param !== null) {} - if (param !== undefined) {} -} - -[CANNOT_USE]: Cannot use '%s' comparator for type '%s'. -[CANNOT_COMPARE]: Cannot compare type '%s' to type '%s'. diff --git a/test/rules/strict-comparisons/default/tsconfig.json b/test/rules/strict-comparisons/default/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/strict-comparisons/default/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/strict-comparisons/default/tslint.json b/test/rules/strict-comparisons/default/tslint.json deleted file mode 100644 index 6c559289264..00000000000 --- a/test/rules/strict-comparisons/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-comparisons": true - } -} diff --git a/test/rules/strict-string-expressions/allow-empty-types/test.ts.fix b/test/rules/strict-string-expressions/allow-empty-types/test.ts.fix deleted file mode 100644 index ed0c9eec177..00000000000 --- a/test/rules/strict-string-expressions/allow-empty-types/test.ts.fix +++ /dev/null @@ -1,133 +0,0 @@ - const fooAny: any; - const fooStr: string = 'foo'; - const fooNumber = 2; - class FooClass {} - class ClassWithToString { - public static toString () { return ''; } - public toString () { return ''; } - } - const classWithToString = new ClassWithToString(); - const FooStr = new String('foo'); - const fooArr = ['foo']; - const emptyArr = []; - const stringUni = "foo" | "bar"; - const booleanVar: boolean; - - `foo` - `${'str literal'}` - `${123}` - `${booleanVar}` - `${fooAny}` - `${fooStr}` - `${stringUni}` - `${fooNumber}` - `${(typeof window)}` - `${String(FooClass)}` - `${String(ClassWithToString)}` - `${String(classWithToString)}` - `${String(FooStr)}` - `${String(fooArr)}` - `${String(emptyArr)}` - - `${String('str literal')}` - `${String(123)}` - `${String(booleanVar)}` - `${String(fooAny)}` - `${String(fooStr)}` - `${String(stringUni)}` - `${String(fooNumber)}` - `${String((typeof window))}` - `${String(FooClass)}` - `${String(ClassWithToString)}` - `${String(classWithToString)}` - `${String(FooStr)}` - `${String(fooArr)}` - `${String(emptyArr)}` - - `${'str literal'.toString()}` - `${123..toString()}` - `${booleanVar.toString()}` - `${fooAny.toString()}` - `${fooStr.toString()}` - `${stringUni.toString()}` - `${fooNumber.toString()}` - `${(typeof window).toString()}` - `${FooClass.toString()}` - `${ClassWithToString.toString()}` - `${classWithToString.toString()}` - `${FooStr.toString()}` - `${fooArr.toString()}` - `${emptyArr.toString()}` - - 'str' + 'str literal' + 'str' - 'str' + 123 + 'str' - 'str' + booleanVar + 'str' - 'str' + fooAny + 'str' - 'str' + fooStr + 'str' - 'str' + stringUni + 'str' - 'str' + fooNumber + 'str' - 'str' + (typeof window) + 'str' - 'str' + String(FooClass) + 'str' - 'str' + String(ClassWithToString) + 'str' - 'str' + String(classWithToString) + 'str' - 'str' + String(FooStr) + 'str' - 'str' + String(fooArr) + 'str' - 'str' + String(emptyArr) + 'str' - - 'str' + String('str literal') + 'str' - 'str' + String(123) + 'str' - 'str' + String(booleanVar) + 'str' - 'str' + String(fooAny) + 'str' - 'str' + String(fooStr) + 'str' - 'str' + String(stringUni) + 'str' - 'str' + String(fooNumber) + 'str' - 'str' + String((typeof window)) + 'str' - 'str' + String(FooClass) + 'str' - 'str' + String(ClassWithToString) + 'str' - 'str' + String(classWithToString) + 'str' - 'str' + String(FooStr) + 'str' - 'str' + String(fooArr) + 'str' - 'str' + String(emptyArr) + 'str' - - 'str' + 'str literal'.toString() + 'str' - 'str' + 123..toString() + 'str' - 'str' + booleanVar.toString() + 'str' - 'str' + fooAny.toString() + 'str' - 'str' + fooStr.toString() + 'str' - 'str' + stringUni.toString() + 'str' - 'str' + fooNumber.toString() + 'str' - 'str' + (typeof window).toString() + 'str' - 'str' + FooClass.toString() + 'str' - 'str' + ClassWithToString.toString() + 'str' - 'str' + classWithToString.toString() + 'str' - 'str' + FooStr.toString() + 'str' - 'str' + fooArr.toString() + 'str' - 'str' + emptyArr.toString() + 'str' - - const barFooStrOrUndef: string | undefined; - const barFooStrOrNull: string | null; - const neverType: never; - - `${barFooStrOrUndef}` - `${barFooStrOrNull}` - `${neverType}` - - `${String(barFooStrOrUndef)}` - `${String(barFooStrOrNull)}` - `${String(neverType)}` - - `${barFooStrOrUndef.toString()}` - `${barFooStrOrNull.toString()}` - `${neverType.toString()}` - - 'str' + barFooStrOrUndef + 'str' - 'str' + barFooStrOrNull + 'str' - 'str' + neverType + 'str' - - 'str' + String(barFooStrOrUndef) + 'str' - 'str' + String(barFooStrOrNull) + 'str' - 'str' + String(neverType) + 'str' - - 'str' + barFooStrOrUndef.toString() + 'str' - 'str' + barFooStrOrNull.toString() + 'str' - 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/allow-empty-types/test.ts.lint b/test/rules/strict-string-expressions/allow-empty-types/test.ts.lint deleted file mode 100644 index 0660ca94379..00000000000 --- a/test/rules/strict-string-expressions/allow-empty-types/test.ts.lint +++ /dev/null @@ -1,145 +0,0 @@ - const fooAny: any; - const fooStr: string = 'foo'; - const fooNumber = 2; - class FooClass {} - class ClassWithToString { - public static toString () { return ''; } - public toString () { return ''; } - } - const classWithToString = new ClassWithToString(); - const FooStr = new String('foo'); - const fooArr = ['foo']; - const emptyArr = []; - const stringUni = "foo" | "bar"; - const booleanVar: boolean; - - `foo` - `${'str literal'}` - `${123}` - `${booleanVar}` - `${fooAny}` - `${fooStr}` - `${stringUni}` - `${fooNumber}` - `${(typeof window)}` - `${FooClass}` - ~~~~~~~~~~ [Explicit conversion to string type required] - `${ClassWithToString}` - ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - `${classWithToString}` - ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - `${FooStr}` - ~~~~~~~~ [Explicit conversion to string type required] - `${fooArr}` - ~~~~~~~~ [Explicit conversion to string type required] - `${emptyArr}` - ~~~~~~~~~~ [Explicit conversion to string type required] - - `${String('str literal')}` - `${String(123)}` - `${String(booleanVar)}` - `${String(fooAny)}` - `${String(fooStr)}` - `${String(stringUni)}` - `${String(fooNumber)}` - `${String((typeof window))}` - `${String(FooClass)}` - `${String(ClassWithToString)}` - `${String(classWithToString)}` - `${String(FooStr)}` - `${String(fooArr)}` - `${String(emptyArr)}` - - `${'str literal'.toString()}` - `${123..toString()}` - `${booleanVar.toString()}` - `${fooAny.toString()}` - `${fooStr.toString()}` - `${stringUni.toString()}` - `${fooNumber.toString()}` - `${(typeof window).toString()}` - `${FooClass.toString()}` - `${ClassWithToString.toString()}` - `${classWithToString.toString()}` - `${FooStr.toString()}` - `${fooArr.toString()}` - `${emptyArr.toString()}` - - 'str' + 'str literal' + 'str' - 'str' + 123 + 'str' - 'str' + booleanVar + 'str' - 'str' + fooAny + 'str' - 'str' + fooStr + 'str' - 'str' + stringUni + 'str' - 'str' + fooNumber + 'str' - 'str' + (typeof window) + 'str' - 'str' + FooClass + 'str' - ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + ClassWithToString + 'str' - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + classWithToString + 'str' - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + FooStr + 'str' - ~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + fooArr + 'str' - ~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + emptyArr + 'str' - ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - - 'str' + String('str literal') + 'str' - 'str' + String(123) + 'str' - 'str' + String(booleanVar) + 'str' - 'str' + String(fooAny) + 'str' - 'str' + String(fooStr) + 'str' - 'str' + String(stringUni) + 'str' - 'str' + String(fooNumber) + 'str' - 'str' + String((typeof window)) + 'str' - 'str' + String(FooClass) + 'str' - 'str' + String(ClassWithToString) + 'str' - 'str' + String(classWithToString) + 'str' - 'str' + String(FooStr) + 'str' - 'str' + String(fooArr) + 'str' - 'str' + String(emptyArr) + 'str' - - 'str' + 'str literal'.toString() + 'str' - 'str' + 123..toString() + 'str' - 'str' + booleanVar.toString() + 'str' - 'str' + fooAny.toString() + 'str' - 'str' + fooStr.toString() + 'str' - 'str' + stringUni.toString() + 'str' - 'str' + fooNumber.toString() + 'str' - 'str' + (typeof window).toString() + 'str' - 'str' + FooClass.toString() + 'str' - 'str' + ClassWithToString.toString() + 'str' - 'str' + classWithToString.toString() + 'str' - 'str' + FooStr.toString() + 'str' - 'str' + fooArr.toString() + 'str' - 'str' + emptyArr.toString() + 'str' - - const barFooStrOrUndef: string | undefined; - const barFooStrOrNull: string | null; - const neverType: never; - - `${barFooStrOrUndef}` - `${barFooStrOrNull}` - `${neverType}` - - `${String(barFooStrOrUndef)}` - `${String(barFooStrOrNull)}` - `${String(neverType)}` - - `${barFooStrOrUndef.toString()}` - `${barFooStrOrNull.toString()}` - `${neverType.toString()}` - - 'str' + barFooStrOrUndef + 'str' - 'str' + barFooStrOrNull + 'str' - 'str' + neverType + 'str' - - 'str' + String(barFooStrOrUndef) + 'str' - 'str' + String(barFooStrOrNull) + 'str' - 'str' + String(neverType) + 'str' - - 'str' + barFooStrOrUndef.toString() + 'str' - 'str' + barFooStrOrNull.toString() + 'str' - 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/allow-empty-types/tsconfig.json b/test/rules/strict-string-expressions/allow-empty-types/tsconfig.json deleted file mode 100644 index aa5798f3ce6..00000000000 --- a/test/rules/strict-string-expressions/allow-empty-types/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "compilerOptions": { - } -} diff --git a/test/rules/strict-string-expressions/allow-empty-types/tslint.json b/test/rules/strict-string-expressions/allow-empty-types/tslint.json deleted file mode 100644 index 270026fc7f4..00000000000 --- a/test/rules/strict-string-expressions/allow-empty-types/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "strict-string-expressions": [ - true, - { - "allow-empty-types": true - } - ] - } -} diff --git a/test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix b/test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix deleted file mode 100644 index dd4b6ee8d2c..00000000000 --- a/test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix +++ /dev/null @@ -1,133 +0,0 @@ - const fooAny: any; - const fooStr: string = 'foo'; - const fooNumber = 2; - class FooClass {} - class ClassWithToString { - public static toString () { return ''; } - public toString () { return ''; } - } - const classWithToString = new ClassWithToString(); - const FooStr = new String('foo'); - const fooArr = ['foo']; - const emptyArr = []; - const stringUni = "foo" | "bar"; - const booleanVar: boolean; - - `foo` - `${'str literal'}` - `${123}` - `${fooAny}` - `${fooStr}` - `${stringUni}` - `${fooNumber}` - `${(typeof window)}` - `${String(FooClass)}` - `${String(ClassWithToString)}` - `${String(classWithToString)}` - `${String(FooStr)}` - `${String(fooArr)}` - `${String(emptyArr)}` - `${booleanVar}` - - `${String('str literal')}` - `${String(123)}` - `${String(fooAny)}` - `${String(fooStr)}` - `${String(stringUni)}` - `${String(fooNumber)}` - `${String((typeof window))}` - `${String(FooClass)}` - `${String(ClassWithToString)}` - `${String(classWithToString)}` - `${String(FooStr)}` - `${String(fooArr)}` - `${String(emptyArr)}` - `${String(booleanVar)}` - - `${'str literal'.toString()}` - `${123..toString()}` - `${fooAny.toString()}` - `${fooStr.toString()}` - `${stringUni.toString()}` - `${fooNumber.toString()}` - `${(typeof window).toString()}` - `${FooClass.toString()}` - `${ClassWithToString.toString()}` - `${classWithToString.toString()}` - `${FooStr.toString()}` - `${fooArr.toString()}` - `${emptyArr.toString()}` - `${booleanVar.toString()}` - - 'str' + 'str literal' + 'str' - 'str' + 123 + 'str' - 'str' + fooAny + 'str' - 'str' + fooStr + 'str' - 'str' + stringUni + 'str' - 'str' + fooNumber + 'str' - 'str' + (typeof window) + 'str' - 'str' + String(FooClass) + 'str' - 'str' + String(ClassWithToString) + 'str' - 'str' + String(classWithToString) + 'str' - 'str' + String(FooStr) + 'str' - 'str' + String(fooArr) + 'str' - 'str' + String(emptyArr) + 'str' - 'str' + booleanVar + 'str' - - 'str' + String('str literal') + 'str' - 'str' + String(123) + 'str' - 'str' + String(fooAny) + 'str' - 'str' + String(fooStr) + 'str' - 'str' + String(stringUni) + 'str' - 'str' + String(fooNumber) + 'str' - 'str' + String((typeof window)) + 'str' - 'str' + String(FooClass) + 'str' - 'str' + String(ClassWithToString) + 'str' - 'str' + String(classWithToString) + 'str' - 'str' + String(FooStr) + 'str' - 'str' + String(fooArr) + 'str' - 'str' + String(emptyArr) + 'str' - 'str' + String(booleanVar) + 'str' - - 'str' + 'str literal'.toString() + 'str' - 'str' + 123..toString() + 'str' - 'str' + fooAny.toString() + 'str' - 'str' + fooStr.toString() + 'str' - 'str' + stringUni.toString() + 'str' - 'str' + fooNumber.toString() + 'str' - 'str' + (typeof window).toString() + 'str' - 'str' + FooClass.toString() + 'str' - 'str' + ClassWithToString.toString() + 'str' - 'str' + classWithToString.toString() + 'str' - 'str' + FooStr.toString() + 'str' - 'str' + fooArr.toString() + 'str' - 'str' + emptyArr.toString() + 'str' - 'str' + booleanVar.toString() + 'str' - - const barFooStrOrUndef: string | undefined; - const barFooStrOrNull: string | null; - const neverType: never; - - `${String(barFooStrOrUndef)}` - `${String(barFooStrOrNull)}` - `${String(neverType)}` - - `${String(barFooStrOrUndef)}` - `${String(barFooStrOrNull)}` - `${String(neverType)}` - - `${barFooStrOrUndef.toString()}` - `${barFooStrOrNull.toString()}` - `${neverType.toString()}` - - 'str' + String(barFooStrOrUndef) + 'str' - 'str' + String(barFooStrOrNull) + 'str' - 'str' + String(neverType) + 'str' - - 'str' + String(barFooStrOrUndef) + 'str' - 'str' + String(barFooStrOrNull) + 'str' - 'str' + String(neverType) + 'str' - - 'str' + barFooStrOrUndef.toString() + 'str' - 'str' + barFooStrOrNull.toString() + 'str' - 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint b/test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint deleted file mode 100644 index b7f29b9ed0c..00000000000 --- a/test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint +++ /dev/null @@ -1,151 +0,0 @@ - const fooAny: any; - const fooStr: string = 'foo'; - const fooNumber = 2; - class FooClass {} - class ClassWithToString { - public static toString () { return ''; } - public toString () { return ''; } - } - const classWithToString = new ClassWithToString(); - const FooStr = new String('foo'); - const fooArr = ['foo']; - const emptyArr = []; - const stringUni = "foo" | "bar"; - const booleanVar: boolean; - - `foo` - `${'str literal'}` - `${123}` - `${fooAny}` - `${fooStr}` - `${stringUni}` - `${fooNumber}` - `${(typeof window)}` - `${FooClass}` - ~~~~~~~~~~ [Explicit conversion to string type required] - `${ClassWithToString}` - ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - `${classWithToString}` - ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - `${FooStr}` - ~~~~~~~~ [Explicit conversion to string type required] - `${fooArr}` - ~~~~~~~~ [Explicit conversion to string type required] - `${emptyArr}` - ~~~~~~~~~~ [Explicit conversion to string type required] - `${booleanVar}` - - `${String('str literal')}` - `${String(123)}` - `${String(fooAny)}` - `${String(fooStr)}` - `${String(stringUni)}` - `${String(fooNumber)}` - `${String((typeof window))}` - `${String(FooClass)}` - `${String(ClassWithToString)}` - `${String(classWithToString)}` - `${String(FooStr)}` - `${String(fooArr)}` - `${String(emptyArr)}` - `${String(booleanVar)}` - - `${'str literal'.toString()}` - `${123..toString()}` - `${fooAny.toString()}` - `${fooStr.toString()}` - `${stringUni.toString()}` - `${fooNumber.toString()}` - `${(typeof window).toString()}` - `${FooClass.toString()}` - `${ClassWithToString.toString()}` - `${classWithToString.toString()}` - `${FooStr.toString()}` - `${fooArr.toString()}` - `${emptyArr.toString()}` - `${booleanVar.toString()}` - - 'str' + 'str literal' + 'str' - 'str' + 123 + 'str' - 'str' + fooAny + 'str' - 'str' + fooStr + 'str' - 'str' + stringUni + 'str' - 'str' + fooNumber + 'str' - 'str' + (typeof window) + 'str' - 'str' + FooClass + 'str' - ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + ClassWithToString + 'str' - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + classWithToString + 'str' - ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + FooStr + 'str' - ~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + fooArr + 'str' - ~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + emptyArr + 'str' - ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + booleanVar + 'str' - - 'str' + String('str literal') + 'str' - 'str' + String(123) + 'str' - 'str' + String(fooAny) + 'str' - 'str' + String(fooStr) + 'str' - 'str' + String(stringUni) + 'str' - 'str' + String(fooNumber) + 'str' - 'str' + String((typeof window)) + 'str' - 'str' + String(FooClass) + 'str' - 'str' + String(ClassWithToString) + 'str' - 'str' + String(classWithToString) + 'str' - 'str' + String(FooStr) + 'str' - 'str' + String(fooArr) + 'str' - 'str' + String(emptyArr) + 'str' - 'str' + String(booleanVar) + 'str' - - 'str' + 'str literal'.toString() + 'str' - 'str' + 123..toString() + 'str' - 'str' + fooAny.toString() + 'str' - 'str' + fooStr.toString() + 'str' - 'str' + stringUni.toString() + 'str' - 'str' + fooNumber.toString() + 'str' - 'str' + (typeof window).toString() + 'str' - 'str' + FooClass.toString() + 'str' - 'str' + ClassWithToString.toString() + 'str' - 'str' + classWithToString.toString() + 'str' - 'str' + FooStr.toString() + 'str' - 'str' + fooArr.toString() + 'str' - 'str' + emptyArr.toString() + 'str' - 'str' + booleanVar.toString() + 'str' - - const barFooStrOrUndef: string | undefined; - const barFooStrOrNull: string | null; - const neverType: never; - - `${barFooStrOrUndef}` - ~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - `${barFooStrOrNull}` - ~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - `${neverType}` - ~~~~~~~~~~~ [Explicit conversion to string type required] - - `${String(barFooStrOrUndef)}` - `${String(barFooStrOrNull)}` - `${String(neverType)}` - - `${barFooStrOrUndef.toString()}` - `${barFooStrOrNull.toString()}` - `${neverType.toString()}` - - 'str' + barFooStrOrUndef + 'str' - ~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + barFooStrOrNull + 'str' - ~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - 'str' + neverType + 'str' - ~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] - - 'str' + String(barFooStrOrUndef) + 'str' - 'str' + String(barFooStrOrNull) + 'str' - 'str' + String(neverType) + 'str' - - 'str' + barFooStrOrUndef.toString() + 'str' - 'str' + barFooStrOrNull.toString() + 'str' - 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json b/test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json deleted file mode 100644 index c4d430eb449..00000000000 --- a/test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} diff --git a/test/rules/strict-string-expressions/disallow-empty-types/tslint.json b/test/rules/strict-string-expressions/disallow-empty-types/tslint.json deleted file mode 100644 index 265d57b2aaf..00000000000 --- a/test/rules/strict-string-expressions/disallow-empty-types/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "strict-string-expressions": [ - true, - { - "allow-empty-types": false - } - ] - } -} diff --git a/test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint b/test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint deleted file mode 100644 index bfa10b37067..00000000000 --- a/test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint +++ /dev/null @@ -1,156 +0,0 @@ -declare function get(): T; - -// typeof undefined -{ - typeof get() === "undefined"; - - typeof get() === "undefined"; - - typeof get() === "undefined"; - - declare const c: any; - typeof get() === "undefined"; - - // 'undefined' is not assignable to '{}' - typeof get<{}>() === "undefined"; -} - -// typeof boolean -{ - declare const a: boolean; - typeof get() === "boolean"; - - typeof get() === "boolean"; - - typeof get() === "boolean"; - - typeof get<{}>() === "boolean"; -} - -// typeof number -{ - enum E {} - - typeof get() === "number"; - - typeof get() === "number"; -} - -// typeof string -{ - typeof get<"abc" | "def">() === "string"; - - typeof get() === "string"; - - typeof get<"abc" | undefined>() === "string"; -} - -// typeof symbol -{ - typeof get() === "symbol"; - - typeof get() === "symbol"; - - typeof get() === "symbol"; -} - -// typeof function -{ - typeof get<() => void>() === "function"; - - typeof get() === "function"; - - - typeof get() === "function"; - - typeof get void)>() === "function"; - - class X {} - typeof X === "function"; - typeof X === "object"; - - // Works with union - class Foo { } - typeof get === "function"; -} - -// typeof object -{ - typeof get void) | Function>() === "object"; - - typeof get<{}> === "object"; -} - -// === null / undefined -{ - get() === null; - - get() === null; - - get() === undefined; - - get() === undefined; - - // 'null' and 'undefined' are not assignable to '{}' - - get<{}>() === null; - - get<{}>() === undefined; - - get() == null; - - get() == undefined; - - get() == null; - - get() == undefined; - - get() != null; - - get<{}>() == null; - - get() == null; - get() != undefined; - - get() == null; - get() != undefined; -} - -// negation -{ - get() !== null; - - get() !== null; - - get() !== undefined; - - get() !== undefined; - - typeof get() !== "string"; -} - -// reverse left/right -{ - "string" === typeof get(); - - undefined === get(); -} - -// type parameters -{ - function f(t: T) { - typeof t === "boolean"; - } - - // TODO: Would be nice to catch this. - function g(t: T) { - typeof t === "boolean"; - } -} - -// Detects bad typeof -{ - typeof get() === true; - - typeof get() === "orbject"; -} diff --git a/test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json b/test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json deleted file mode 100644 index 67394b4f5a1..00000000000 --- a/test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - // strictNullChecks not enabled - } -} \ No newline at end of file diff --git a/test/rules/strict-type-predicates/no-strict-null-checks/tslint.json b/test/rules/strict-type-predicates/no-strict-null-checks/tslint.json deleted file mode 100644 index bb5f9231e91..00000000000 --- a/test/rules/strict-type-predicates/no-strict-null-checks/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-type-predicates": true - } -} diff --git a/test/rules/strict-type-predicates/strict-null-checks/test.ts.lint b/test/rules/strict-type-predicates/strict-null-checks/test.ts.lint deleted file mode 100644 index 2f45d333a2f..00000000000 --- a/test/rules/strict-type-predicates/strict-null-checks/test.ts.lint +++ /dev/null @@ -1,215 +0,0 @@ -declare function get(): T; - -// typeof undefined -{ - typeof get() === "undefined"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - typeof get() === "undefined"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - typeof get() === "undefined"; - - declare const c: any; - typeof get() === "undefined"; - - // 'undefined' is not assignable to '{}' - typeof get<{}>() === "undefined"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] -} - -// typeof boolean -{ - declare const a: boolean; - typeof get() === "boolean"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - typeof get() === "boolean"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - typeof get() === "boolean"; - - typeof get<{}>() === "boolean"; -} - -// typeof number -{ - enum E {} - - typeof get() === "number"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - typeof get() === "number"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] -} - -// typeof string -{ - typeof get<"abc" | "def">() === "string"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - typeof get() === "string"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - typeof get<"abc" | undefined>() === "string"; -} - -// typeof symbol -{ - typeof get() === "symbol"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - typeof get() === "symbol"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - typeof get() === "symbol"; -} - -// typeof function -{ - typeof get<() => void>() === "function"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - typeof get() === "function"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - - typeof get() === "function"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - typeof get void)>() === "function"; - - class X {} - typeof X === "function"; - ~~~~~~~~~~~~~~~~~~~~~~~ [T] - typeof X === "object"; - ~~~~~~~~~~~~~~~~~~~~~ [F] - - // Works with union - class Foo { } - typeof get === "function"; -} - -// typeof object -{ - typeof get void) | Function>() === "object"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - typeof get<{}> === "object"; -} - -// === null / undefined -{ - get() === null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - get() === null; - - get() === undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - get() === undefined; - - // 'null' and 'undefined' are not assignable to '{}' - - get<{}>() === null; - ~~~~~~~~~~~~~~~~~~ [F] - - get<{}>() === undefined; - ~~~~~~~~~~~~~~~~~~~~~~~ [F] - - get() == null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== undefined' instead.] - - get() == undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== null' instead.] - - get() == null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== null' instead.] - - get() == undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== undefined' instead.] - - get() != null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '!== undefined' instead.] - - get<{}>() == null; - ~~~~~~~~~~~~~~~~~ [F] - - get() == null; - get() != undefined; - - get() == null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - get() != undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] -} - -// negation -{ - get() !== null; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - get() !== null; - - get() !== undefined; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] - - get() !== undefined; - - typeof get() !== "string"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] -} - -// reverse left/right -{ - "string" === typeof get(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] - - undefined === get(); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [T] -} - -// type parameters -{ - function f(t: T) { - typeof t === "boolean"; - } - - // TODO: Would be nice to catch this. - function g(t: T) { - typeof t === "boolean"; - } -} - -// Detects bad typeof -{ - typeof get() === true; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] - - typeof get() === "orbject"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] - - typeof get() === `string`; - typeof get() === `stirng`; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] - - typeof get() === "unknown"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] - - let a: string, b: string; - typeof a === typeof b; - typeof a === b; - a === typeof b; - typeof a === undefined; - ~~~~~~~~~~~~~~~~~~~~~~ [F] - - undefined === typeof a; - ~~~~~~~~~~~~~~~~~~~~~~ [typeof] - null === typeof b; - ~~~~~~~~~~~~~~~~~ [typeof] -} - -[T]: Expression is always true. -[F]: Expression is always false. -[typeof]: Bad comparison for 'typeof'. diff --git a/test/rules/strict-type-predicates/strict-null-checks/tsconfig.json b/test/rules/strict-type-predicates/strict-null-checks/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-type-predicates/strict-null-checks/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-type-predicates/strict-null-checks/tslint.json b/test/rules/strict-type-predicates/strict-null-checks/tslint.json deleted file mode 100644 index bb5f9231e91..00000000000 --- a/test/rules/strict-type-predicates/strict-null-checks/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-type-predicates": true - } -} diff --git a/test/rules/strict-type-predicates/unknown/test.ts.lint b/test/rules/strict-type-predicates/unknown/test.ts.lint deleted file mode 100644 index 40dd5d0da99..00000000000 --- a/test/rules/strict-type-predicates/unknown/test.ts.lint +++ /dev/null @@ -1,42 +0,0 @@ -[typescript]: >= 3.0.0 - -declare function get(): T; - -// typeof -{ - typeof get() === "undefined"; - typeof get() === "boolean"; - typeof get() === "number"; - typeof get() === "string"; - typeof get() === "symbol"; - typeof get() === "function"; - typeof get() === "object"; -} - -// negation -{ - get() !== null; - get() !== undefined; -} - -// reverse left/right -{ - "string" === typeof get(); - - undefined === get(); -} - -// type parameters -{ - function f(t: T) { - typeof t === "boolean"; - } -} - -const body: unknown = 'test'; -if (typeof body === 'object') - console.log('a'); - -let test: unknown = undefined; -if (test !== undefined) - console.log('b'); diff --git a/test/rules/strict-type-predicates/unknown/tsconfig.json b/test/rules/strict-type-predicates/unknown/tsconfig.json deleted file mode 100644 index 1cc3bc85ee9..00000000000 --- a/test/rules/strict-type-predicates/unknown/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true - } -} \ No newline at end of file diff --git a/test/rules/strict-type-predicates/unknown/tslint.json b/test/rules/strict-type-predicates/unknown/tslint.json deleted file mode 100644 index bb5f9231e91..00000000000 --- a/test/rules/strict-type-predicates/unknown/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "strict-type-predicates": true - } -} diff --git a/test/rules/switch-default/test.ts.lint b/test/rules/switch-default/test.ts.lint deleted file mode 100644 index 2f33aba2eb5..00000000000 --- a/test/rules/switch-default/test.ts.lint +++ /dev/null @@ -1,74 +0,0 @@ -switch (foo) { -~~~~~~~~~~~~~~ -case 1: -~~~~~~~ - bar(); -~~~~~~~~~~ - break; -~~~~~~~~~~ -} -~ [Switch statement should include a 'default' case] - -switch (foo) { -~~~~~~~~~~~~~~ -case 1: -~~~~~~~ - bar(); -~~~~~~~~~~ - break; -~~~~~~~~~~ -case 2: -~~~~~~~ - bar(); -~~~~~~~~~~ - break; -~~~~~~~~~~ -case 3: -~~~~~~~ - bar(); -~~~~~~~~~~ - break; -~~~~~~~~~~ -} -~ [Switch statement should include a 'default' case] - -// valid -switch (foo) { -case 1: - bar(); - break; -default: - break; -} - -// valid -switch (foo) { -default: - bar(); - break; -case 1: - bar(); - break; -} - -// valid -switch (foo) { -case 1: - bar(); - break; -default: - break; -case 2: - break; -} - -// valid -baz: -while (true){ - switch(foo) { - case 1: - bar(); - continue baz; - default: - } -} diff --git a/test/rules/switch-default/tslint.json b/test/rules/switch-default/tslint.json deleted file mode 100644 index 05e34955935..00000000000 --- a/test/rules/switch-default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "switch-default": true - } -} diff --git a/test/rules/switch-final-break/always/test.ts.fix b/test/rules/switch-final-break/always/test.ts.fix deleted file mode 100644 index f0ee2fa6552..00000000000 --- a/test/rules/switch-final-break/always/test.ts.fix +++ /dev/null @@ -1,49 +0,0 @@ -switch (x) { - case 0: - foo(); - break; -} - -switch (x) { - case 0: { - foo(); - break; - } -} - -switch (x) { - case 0: - foo(); - break; -} - -switch (x) { - case 0: { - foo(); - break; - } -} - -switch (x) { - default: - foo(); - break; -} - -switch (x) { - default: - foo(); - break; -} - -switch (x) { - default: { - foo(); - break; - } -} - -switch (x) { - case 0: break; -} - diff --git a/test/rules/switch-final-break/always/test.ts.lint b/test/rules/switch-final-break/always/test.ts.lint deleted file mode 100644 index 10bab6aa4ea..00000000000 --- a/test/rules/switch-final-break/always/test.ts.lint +++ /dev/null @@ -1,51 +0,0 @@ -switch (x) { - case 0: - ~~~~ [0] - foo(); -} - -switch (x) { - case 0: { - ~~~~ [0] - foo(); - } -} - -switch (x) { - case 0: - foo(); - break; -} - -switch (x) { - case 0: { - foo(); - break; - } -} - -switch (x) { - default: - foo(); - break; -} - -switch (x) { - default: - ~~~~~~~ [0] - foo(); -} - -switch (x) { - default: { - ~~~~~~~ [0] - foo(); - } -} - -switch (x) { - case 0: - ~~~~ [0] -} - -[0]: Final clause in 'switch' statement should end with 'break;'. diff --git a/test/rules/switch-final-break/always/tslint.json b/test/rules/switch-final-break/always/tslint.json deleted file mode 100644 index 977f95f8ad0..00000000000 --- a/test/rules/switch-final-break/always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "switch-final-break": [true, "always"] - } -} diff --git a/test/rules/switch-final-break/default/test.ts.fix b/test/rules/switch-final-break/default/test.ts.fix deleted file mode 100644 index 638af1e03ae..00000000000 --- a/test/rules/switch-final-break/default/test.ts.fix +++ /dev/null @@ -1,61 +0,0 @@ -switch (x) { - case 0: - foo(); -} - -switch (x) { - case 0: { - foo(); - } -} - -switch (x) { - case 0: - foo(); -} - -switch (x) { - case 0: { - foo(); - } -} - -switch (x) { - default: - foo(); -} - -switch (x) { - default: - foo(); -} - -switch (x) { - default: { - foo(); - } -} - -switch (x) { - case 0: -} - -outer: while (true) { - switch (x) { - case 0: - x++; - break; - default: - break outer; - } -} - -outer2: while (true) { - inner: switch (x) { - case 0: - ++x; - break; - default: - } -} - diff --git a/test/rules/switch-final-break/default/test.ts.lint b/test/rules/switch-final-break/default/test.ts.lint deleted file mode 100644 index 67b87b7fe64..00000000000 --- a/test/rules/switch-final-break/default/test.ts.lint +++ /dev/null @@ -1,70 +0,0 @@ -switch (x) { - case 0: - foo(); -} - -switch (x) { - case 0: { - foo(); - } -} - -switch (x) { - case 0: - foo(); - break; - ~~~~~~ [0] -} - -switch (x) { - case 0: { - foo(); - break; - ~~~~~~ [0] - } -} - -switch (x) { - default: - foo(); - break; - ~~~~~~ [0] -} - -switch (x) { - default: - foo(); -} - -switch (x) { - default: { - foo(); - } -} - -switch (x) { - case 0: -} - -outer: while (true) { - switch (x) { - case 0: - x++; - break; - default: - break outer; - } -} - -outer2: while (true) { - inner: switch (x) { - case 0: - ++x; - break; - default: - break inner; - ~~~~~~~~~~~~ [0] - } -} - -[0]: Final clause in 'switch' statement should not end with 'break;'. diff --git a/test/rules/switch-final-break/default/tslint.json b/test/rules/switch-final-break/default/tslint.json deleted file mode 100644 index 5fe1dee0d65..00000000000 --- a/test/rules/switch-final-break/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "switch-final-break": true - } -} diff --git a/test/rules/trailing-comma/multiline-always/test.ts.fix b/test/rules/trailing-comma/multiline-always/test.ts.fix deleted file mode 100644 index f392b5179d4..00000000000 --- a/test/rules/trailing-comma/multiline-always/test.ts.fix +++ /dev/null @@ -1,602 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7, -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1, -}; - -var ss = [ - 6, -]; - -var tt = [ - 7, -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1, -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA, -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo, -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA, -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo, -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT, -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ, -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string, -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43, -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo", -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string, -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string, - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string, - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - } - >() { return 42; } - - set bar(foo: string) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string, - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - - new (bar: U): ITest; - - new (bar: U, baz: V,): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string, - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz, -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2, -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -export { - foo, - bar, -}; - -// don't crash -new Foo - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - -let foo = (bar): - | 1 - | 2 - | 3 => 1; diff --git a/test/rules/trailing-comma/multiline-always/test.ts.lint b/test/rules/trailing-comma/multiline-always/test.ts.lint deleted file mode 100644 index a12c0d9b4ed..00000000000 --- a/test/rules/trailing-comma/multiline-always/test.ts.lint +++ /dev/null @@ -1,636 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) - ~nil [Missing trailing comma] -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 - ~nil [Missing trailing comma] -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 - ~nil [Missing trailing comma] -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 - ~nil [Missing trailing comma] -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 - ~nil [Missing trailing comma] -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA - ~nil [Missing trailing comma] -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo - ~nil [Missing trailing comma] -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA - ~nil [Missing trailing comma] -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo - ~nil [Missing trailing comma] -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT - ~nil [Missing trailing comma] -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ - ~nil [Missing trailing comma] -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string - ~nil [Missing trailing comma] -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string - ~nil [Missing trailing comma] -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string - ~nil [Missing trailing comma] -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string - ~nil [Missing trailing comma] -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 - ~nil [Missing trailing comma] -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" - ~nil [Missing trailing comma] -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string - ~nil [Missing trailing comma] -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ~nil [Missing trailing comma] - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ~nil [Missing trailing comma] - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - } - >() { return 42; } - - set bar(foo: string) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string - ~nil [Missing trailing comma] - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - - new (bar: U): ITest; - - new (bar: U, baz: V,): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ~nil [Missing trailing comma] - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz - ~nil [Missing trailing comma] -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 - ~nil [Missing trailing comma] -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -export { - foo, - bar - ~nil [Missing trailing comma] -}; - -// don't crash -new Foo - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let { - ...x - ~nil [Missing trailing comma] -} = {}; -let [ - ...y - ~nil [Missing trailing comma] -] = []; - -[ - ...y - ~nil [Missing trailing comma] -] = []; -({ - ...y - ~nil [Missing trailing comma] -} = {}) -function foo( - ...z - ~nil [Missing trailing comma] -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - -let foo = (bar): - | 1 - | 2 - | 3 => 1; diff --git a/test/rules/trailing-comma/multiline-always/tslint.json b/test/rules/trailing-comma/multiline-always/tslint.json deleted file mode 100644 index b9d77c2ab7c..00000000000 --- a/test/rules/trailing-comma/multiline-always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "trailing-comma": [true, {"multiline": "always"}] - } -} diff --git a/test/rules/trailing-comma/multiline-custom/always/test.ts.lint b/test/rules/trailing-comma/multiline-custom/always/test.ts.lint deleted file mode 100644 index 77d4f47fee5..00000000000 --- a/test/rules/trailing-comma/multiline-custom/always/test.ts.lint +++ /dev/null @@ -1,578 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) - ~nil [Missing trailing comma] -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 - ~nil [Missing trailing comma] -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 - ~nil [Missing trailing comma] -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 - ~nil [Missing trailing comma] -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 - ~nil [Missing trailing comma] -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA - ~nil [Missing trailing comma] -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo - ~nil [Missing trailing comma] -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA - ~nil [Missing trailing comma] -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo - ~nil [Missing trailing comma] -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT - ~nil [Missing trailing comma] -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ - ~nil [Missing trailing comma] -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string - ~nil [Missing trailing comma] -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string - ~nil [Missing trailing comma] -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string - ~nil [Missing trailing comma] -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string - ~nil [Missing trailing comma] -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string - ~nil [Missing trailing comma] -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 - ~nil [Missing trailing comma] -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" - ~nil [Missing trailing comma] -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string - ~nil [Missing trailing comma] -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ~nil [Missing trailing comma] - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ~nil [Missing trailing comma] - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - } - >() { return 42; } - - set bar(foo: string) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string - ~nil [Missing trailing comma] - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - - new (bar: U): ITest; - - new (bar: U, baz: V,): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ~nil [Missing trailing comma] - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz - ~nil [Missing trailing comma] -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 - ~nil [Missing trailing comma] -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -export { - foo, - bar - ~nil [Missing trailing comma] -}; - -// don't crash -new Foo diff --git a/test/rules/trailing-comma/multiline-custom/always/tslint.json b/test/rules/trailing-comma/multiline-custom/always/tslint.json deleted file mode 100644 index d793508231c..00000000000 --- a/test/rules/trailing-comma/multiline-custom/always/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "multiline": { - "arrays": "always", - "exports": "always", - "functions": "always", - "imports": "always", - "objects": "always", - "typeLiterals": "always" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint b/test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint deleted file mode 100644 index b5f96410fb2..00000000000 --- a/test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint +++ /dev/null @@ -1,549 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - } - >() { return 42; } - - set bar(foo: string) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - - new (bar: U): ITest; - - new (bar: U, baz: V,): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -export { - foo, - bar -}; - -// don't crash -new Foo diff --git a/test/rules/trailing-comma/multiline-custom/ignore/tslint.json b/test/rules/trailing-comma/multiline-custom/ignore/tslint.json deleted file mode 100644 index 4ae13a80c11..00000000000 --- a/test/rules/trailing-comma/multiline-custom/ignore/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "multiline": { - "arrays": "ignore", - "exports": "ignore", - "functions": "ignore", - "imports": "ignore", - "objects": "ignore", - "typeLiteral": "ignore" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint b/test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint deleted file mode 100644 index 11a4550a30f..00000000000 --- a/test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint +++ /dev/null @@ -1,78 +0,0 @@ -var a = [ - 'foo', - 'bar', - ~ [Unnecessary trailing comma] -] - -var a = [ - 'foo', - 'bar' -] - -export { - foo, - bar - ~nil [Missing trailing comma] -} - -export { - foo, - bar, -} - -function foo( - bar, - baz, -) - -function bar( - foo, - bar -) - -foo( - bar, - baz, -) - -foo( - bar, - baz -) - -import { - foo, - bar, - ~ [Unnecessary trailing comma] -} from 'foo' - -import { - foo, - bar -} from 'foo' - -var o = { - foo: 'foo', - bar: 'bar' - ~nil [Missing trailing comma] -} - -var o = { - foo: 'foo', - bar: 'bar', -} - -interface Foo { - foo: string, - bar: string -} - -interface Foo { - foo: string, - bar: string, -} - -interface Foo { - foo: string; - bar: string; -} diff --git a/test/rules/trailing-comma/multiline-custom/mixed/tslint.json b/test/rules/trailing-comma/multiline-custom/mixed/tslint.json deleted file mode 100644 index b888c1a0cf6..00000000000 --- a/test/rules/trailing-comma/multiline-custom/mixed/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "multiline": { - "arrays": "never", - "exports": "always", - "functions": "ignore", - "imports": "never", - "objects": "always", - "typeLiterals": "ignore" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/multiline-custom/never/test.ts.fix b/test/rules/trailing-comma/multiline-custom/never/test.ts.fix deleted file mode 100644 index bd92433c252..00000000000 --- a/test/rules/trailing-comma/multiline-custom/never/test.ts.fix +++ /dev/null @@ -1,498 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6 -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24 -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6 -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24 -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA -} = s; - -var { - tA -} = t; - -var { - yA, - yB -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number -] = null; - -import { - ClassS -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43 -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo" -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >() { return 42; } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2 -} - diff --git a/test/rules/trailing-comma/multiline-custom/never/test.ts.lint b/test/rules/trailing-comma/multiline-custom/never/test.ts.lint deleted file mode 100644 index 910d09ebe9d..00000000000 --- a/test/rules/trailing-comma/multiline-custom/never/test.ts.lint +++ /dev/null @@ -1,527 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), - ~ [Unnecessary trailing comma] -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, - ~ [Unnecessary trailing comma] -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, - ~ [Unnecessary trailing comma] -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, - ~ [Unnecessary trailing comma] -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, - ~ [Unnecessary trailing comma] -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, - ~ [Unnecessary trailing comma] -} = s; - -var { - tA -} = t; - -var { - yA, - yB, - ~ [Unnecessary trailing comma] -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, - ~ [Unnecessary trailing comma] -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, - ~ [Unnecessary trailing comma] -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number -] = null; - -import { - ClassS, - ~ [Unnecessary trailing comma] -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, - ~ [Unnecessary trailing comma] -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, - ~ [Unnecessary trailing comma] -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, - ~ [Unnecessary trailing comma] -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", - ~ [Unnecessary trailing comma] -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, - ~ [Unnecessary trailing comma] -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ~ [Unnecessary trailing comma] - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ~ [Unnecessary trailing comma] - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >() { return 42; } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ~ [Unnecessary trailing comma] - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, - ~ [Unnecessary trailing comma] -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, - ~ [Unnecessary trailing comma] -} - diff --git a/test/rules/trailing-comma/multiline-custom/never/tslint.json b/test/rules/trailing-comma/multiline-custom/never/tslint.json deleted file mode 100644 index 5509ed2ea5b..00000000000 --- a/test/rules/trailing-comma/multiline-custom/never/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "multiline": { - "arrays": "never", - "exports": "never", - "functions": "never", - "imports": "never", - "objects": "never", - "typeLiterals": "never" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/multiline-never/test.ts.fix b/test/rules/trailing-comma/multiline-never/test.ts.fix deleted file mode 100644 index 9847bac3e8d..00000000000 --- a/test/rules/trailing-comma/multiline-never/test.ts.fix +++ /dev/null @@ -1,545 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6 -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24 -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6 -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24 -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA -} = s; - -var { - tA -} = t; - -var { - yA, - yB -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number -] = null; - -import { - ClassS -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43 -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo" -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >() { return 42; } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2 -} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} diff --git a/test/rules/trailing-comma/multiline-never/test.ts.lint b/test/rules/trailing-comma/multiline-never/test.ts.lint deleted file mode 100644 index f3e0937fa2f..00000000000 --- a/test/rules/trailing-comma/multiline-never/test.ts.lint +++ /dev/null @@ -1,579 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), - ~ [Unnecessary trailing comma] -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, - ~ [Unnecessary trailing comma] -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, - ~ [Unnecessary trailing comma] -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, - ~ [Unnecessary trailing comma] -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, - ~ [Unnecessary trailing comma] -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, - ~ [Unnecessary trailing comma] -} = s; - -var { - tA -} = t; - -var { - yA, - yB, - ~ [Unnecessary trailing comma] -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, - ~ [Unnecessary trailing comma] -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, - ~ [Unnecessary trailing comma] -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number -] = null; - -import { - ClassS, - ~ [Unnecessary trailing comma] -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, - ~ [Unnecessary trailing comma] -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, - ~ [Unnecessary trailing comma] -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, - ~ [Unnecessary trailing comma] -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", - ~ [Unnecessary trailing comma] -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, - ~ [Unnecessary trailing comma] -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ~ [Unnecessary trailing comma] - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ~ [Unnecessary trailing comma] - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >() { return 42; } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ~ [Unnecessary trailing comma] - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ~ [Unnecessary trailing comma] - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, - ~ [Unnecessary trailing comma] -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, - ~ [Unnecessary trailing comma] -} - -let { - ...x, - ~ [Unnecessary trailing comma] -} = {}; -let [ - ...y, - ~ [Unnecessary trailing comma] -] = []; - -[ - ...y, - ~ [Unnecessary trailing comma] -] = []; -({ - ...y, - ~ [Unnecessary trailing comma] -} = {}) -function foo( - ...z, - ~ [Unnecessary trailing comma] -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} diff --git a/test/rules/trailing-comma/multiline-never/tslint.json b/test/rules/trailing-comma/multiline-never/tslint.json deleted file mode 100644 index 4ad240b0790..00000000000 --- a/test/rules/trailing-comma/multiline-never/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "trailing-comma": [true, {"multiline": "never"}] - } -} diff --git a/test/rules/trailing-comma/singleline-always/test.ts.fix b/test/rules/trailing-comma/singleline-always/test.ts.fix deleted file mode 100644 index 9f84332cca8..00000000000 --- a/test/rules/trailing-comma/singleline-always/test.ts.fix +++ /dev/null @@ -1,597 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -},]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1,}; - -var cc = [42, 24,]; - -var dd = [2, 1,]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo,} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo,] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD,} from "module"; - -function foo(bar: string, baz: string,); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string,) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string,) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string,) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43,); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo",); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string, }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string,) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string,) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } - - set bar(foo: string,) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - - new (bar: U,): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string,); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ, } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let foo = bar => bar; -let foo = (bar => bar); -let foo = async (bar,) => bar; -let foo = (async bar => bar); - -let foo = (bar,): - | 1 - | 2 - | 3 => 1; diff --git a/test/rules/trailing-comma/singleline-always/test.ts.lint b/test/rules/trailing-comma/singleline-always/test.ts.lint deleted file mode 100644 index 5284963dfe4..00000000000 --- a/test/rules/trailing-comma/singleline-always/test.ts.lint +++ /dev/null @@ -1,629 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - ~nil [Missing trailing comma] - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - ~nil [Missing trailing comma] - ~nil [Missing trailing comma] - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - ~nil [Missing trailing comma] - -var cc = [42, 24,]; - -var dd = [2, 1]; - ~nil [Missing trailing comma] - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - ~nil [Missing trailing comma] - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - ~nil [Missing trailing comma] - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - ~nil [Missing trailing comma] - -function foo(bar: string, baz: string); - ~nil [Missing trailing comma] - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - ~nil [Missing trailing comma] - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - ~nil [Missing trailing comma] - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - ~nil [Missing trailing comma] - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - ~nil [Missing trailing comma] - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - ~nil [Missing trailing comma] - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - ~nil [Missing trailing comma] - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - ~nil [Missing trailing comma] - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - ~nil [Missing trailing comma] - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - ~nil [Missing trailing comma] - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - ~nil [Missing trailing comma] - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - ~nil [Missing trailing comma] - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } - - set bar(foo: string) { } - ~nil [Missing trailing comma] - - set bar2(foo: string,) { } - - set bar3( - foo: string - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - - new (bar: U): ITest; - ~nil [Missing trailing comma] - - new < - U, - V - >( - bar: U, - baz: U, - ack: V - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - ~nil [Missing trailing comma] - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - ~nil [Missing trailing comma] - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - ~nil [Missing trailing comma] - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x,} = {}; -let [...y,] = []; -[...y,] = []; -({...y,} = {}) -function foo(...z,) {} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; - ~nil [Missing trailing comma] -let [...y] = []; - ~nil [Missing trailing comma] -[...y] = []; - ~nil [Missing trailing comma] -({...y} = {}) - ~nil [Missing trailing comma] -function foo(...z) {} - ~nil [Missing trailing comma] - -let foo = bar => bar; -let foo = (bar => bar); -let foo = async (bar) => bar; - ~nil [Missing trailing comma] -let foo = (async bar => bar); - -let foo = (bar): - ~nil [Missing trailing comma] - | 1 - | 2 - | 3 => 1; diff --git a/test/rules/trailing-comma/singleline-always/tslint.json b/test/rules/trailing-comma/singleline-always/tslint.json deleted file mode 100644 index 05767a6a9fc..00000000000 --- a/test/rules/trailing-comma/singleline-always/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "trailing-comma": [true, {"singleline": "always"}] - } -} diff --git a/test/rules/trailing-comma/singleline-custom/always/test.ts.fix b/test/rules/trailing-comma/singleline-custom/always/test.ts.fix deleted file mode 100644 index 2aa1e2ec29b..00000000000 --- a/test/rules/trailing-comma/singleline-custom/always/test.ts.fix +++ /dev/null @@ -1,540 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -},]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1,}; - -var cc = [42, 24,]; - -var dd = [2, 1,]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo,} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo,] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD,} from "module"; - -function foo(bar: string, baz: string,); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string,) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string,) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string,) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43,); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo",); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string, }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string,) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string,) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } - - set bar(foo: string,) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - - new (bar: U,): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string,); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ, } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - diff --git a/test/rules/trailing-comma/singleline-custom/always/test.ts.lint b/test/rules/trailing-comma/singleline-custom/always/test.ts.lint deleted file mode 100644 index e2fb321bdda..00000000000 --- a/test/rules/trailing-comma/singleline-custom/always/test.ts.lint +++ /dev/null @@ -1,565 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - ~nil [Missing trailing comma] - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - ~nil [Missing trailing comma] - ~nil [Missing trailing comma] - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - ~nil [Missing trailing comma] - -var cc = [42, 24,]; - -var dd = [2, 1]; - ~nil [Missing trailing comma] - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - ~nil [Missing trailing comma] - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - ~nil [Missing trailing comma] - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - ~nil [Missing trailing comma] - -function foo(bar: string, baz: string); - ~nil [Missing trailing comma] - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - ~nil [Missing trailing comma] - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - ~nil [Missing trailing comma] - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - ~nil [Missing trailing comma] - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - ~nil [Missing trailing comma] - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - ~nil [Missing trailing comma] - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - ~nil [Missing trailing comma] - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - ~nil [Missing trailing comma] - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - ~nil [Missing trailing comma] - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - ~nil [Missing trailing comma] - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - ~nil [Missing trailing comma] - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - ~nil [Missing trailing comma] - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } - - set bar(foo: string) { } - ~nil [Missing trailing comma] - - set bar2(foo: string,) { } - - set bar3( - foo: string - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - - new (bar: U): ITest; - ~nil [Missing trailing comma] - - new < - U, - V - >( - bar: U, - baz: U, - ack: V - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - ~nil [Missing trailing comma] - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - ~nil [Missing trailing comma] - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - ~nil [Missing trailing comma] - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - diff --git a/test/rules/trailing-comma/singleline-custom/always/tslint.json b/test/rules/trailing-comma/singleline-custom/always/tslint.json deleted file mode 100644 index 12cabc47ee2..00000000000 --- a/test/rules/trailing-comma/singleline-custom/always/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "singleline": { - "arrays": "always", - "exports": "always", - "functions": "always", - "imports": "always", - "objects": "always", - "typeLiterals": "always" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint b/test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint deleted file mode 100644 index 2204c42ff1a..00000000000 --- a/test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint +++ /dev/null @@ -1,540 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } - - set bar(foo: string) { } - - set bar2(foo: string,) { } - - set bar3( - foo: string - ) { } - - set bar4( - foo: string, - ) { } -} - -class Test2 { } - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - - new (bar: U): ITest; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V - ): ITest< - U, - U, - V - >; - - new < - U, - V - >( - bar: U, - baz: U, - ack: V, - foo: V, - ): ITest< - U, - U, - V - >; - - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A; bar: B; }, - U extends { foo: A; bar: B; }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - diff --git a/test/rules/trailing-comma/singleline-custom/ignore/tslint.json b/test/rules/trailing-comma/singleline-custom/ignore/tslint.json deleted file mode 100644 index 0e6bca24404..00000000000 --- a/test/rules/trailing-comma/singleline-custom/ignore/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "singleline": { - "arrays": "ignore", - "exports": "ignore", - "functions": "ignore", - "imports": "ignore", - "objects": "ignore", - "typeLiterals": "ignore" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint b/test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint deleted file mode 100644 index e2c80e4a8b1..00000000000 --- a/test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint +++ /dev/null @@ -1,28 +0,0 @@ -var a = ['foo', 'bar',] - ~ [Unnecessary trailing comma] - -var a = ['foo', 'bar'] - -export { foo, bar } - ~nil [Missing trailing comma] - -export { foo, bar, } - -function foo(bar, baz,) - -function bar(foo, bar) - -foo(bar, baz,) - -foo(bar, baz) - -import { foo, bar, } from 'foo' - ~ [Unnecessary trailing comma] - -import { foo, bar } from 'foo' - -interface Foo { foo: string, bar: string } - -interface Foo { foo: string, bar: string, } - -interface Foo { foo: string; bar: string; } diff --git a/test/rules/trailing-comma/singleline-custom/mixed/tslint.json b/test/rules/trailing-comma/singleline-custom/mixed/tslint.json deleted file mode 100644 index 0afeee9475b..00000000000 --- a/test/rules/trailing-comma/singleline-custom/mixed/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "singleline": { - "arrays": "never", - "exports": "always", - "functions": "ignore", - "imports": "never", - "objects": "always", - "typeLiterals": "ignore" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/singleline-custom/never/test.ts.fix b/test/rules/trailing-comma/singleline-custom/never/test.ts.fix deleted file mode 100644 index 5198ed5e6d3..00000000000 --- a/test/rules/trailing-comma/singleline-custom/never/test.ts.fix +++ /dev/null @@ -1,500 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -}]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo"); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } -} - -class Test2 { } - - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - diff --git a/test/rules/trailing-comma/singleline-custom/never/test.ts.lint b/test/rules/trailing-comma/singleline-custom/never/test.ts.lint deleted file mode 100644 index e1d597707fb..00000000000 --- a/test/rules/trailing-comma/singleline-custom/never/test.ts.lint +++ /dev/null @@ -1,523 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - ~ [Unnecessary trailing comma] - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - ~ [Unnecessary trailing comma] - ~ [Unnecessary trailing comma] - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - ~ [Unnecessary trailing comma] - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - ~ [Unnecessary trailing comma] - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - ~ [Unnecessary trailing comma] - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - ~ [Unnecessary trailing comma] - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - ~ [Unnecessary trailing comma] - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - ~ [Unnecessary trailing comma] - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - ~ [Unnecessary trailing comma] - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - ~ [Unnecessary trailing comma] - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - ~ [Unnecessary trailing comma] - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - ~ [Unnecessary trailing comma] - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - ~ [Unnecessary trailing comma] - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - ~ [Unnecessary trailing comma] - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - ~ [Unnecessary trailing comma] - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - ~ [Unnecessary trailing comma] - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - ~ [Unnecessary trailing comma] - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - ~ [Unnecessary trailing comma] - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - ~ [Unnecessary trailing comma] - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } -} - -class Test2 { } - - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - ~ [Unnecessary trailing comma] - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - ~ [Unnecessary trailing comma] - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - ~ [Unnecessary trailing comma] - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - diff --git a/test/rules/trailing-comma/singleline-custom/never/tslint.json b/test/rules/trailing-comma/singleline-custom/never/tslint.json deleted file mode 100644 index 375e4b0d1f5..00000000000 --- a/test/rules/trailing-comma/singleline-custom/never/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "singleline": { - "arrays": "never", - "exports": "never", - "functions": "never", - "imports": "never", - "objects": "never", - "typeLiterals": "never" - } - } - ] - } -} diff --git a/test/rules/trailing-comma/singleline-never/test.ts.fix b/test/rules/trailing-comma/singleline-never/test.ts.fix deleted file mode 100644 index b01f2ab7b6d..00000000000 --- a/test/rules/trailing-comma/singleline-never/test.ts.fix +++ /dev/null @@ -1,550 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -}]; - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24}; - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24]; - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB} = c; - -var {dOne, dTwo} = d; - -var [ccA, ccB] = cc; - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB} from "module"; - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string); - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string) { return 42; } - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string) => 42; - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string) => number = null; - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string) => number; - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43); - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo"); - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string }; - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string) { } - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string) { - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } -} - -class Test2 { } - - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string); - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ } - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - -let foo = bar => bar; -let foo = (bar => bar); diff --git a/test/rules/trailing-comma/singleline-never/test.ts.lint b/test/rules/trailing-comma/singleline-never/test.ts.lint deleted file mode 100644 index 3d033030a6d..00000000000 --- a/test/rules/trailing-comma/singleline-never/test.ts.lint +++ /dev/null @@ -1,578 +0,0 @@ -var v = [{ - a: 1, - b: 2, - d: 34, - c: (a + b), -},]; - ~ [Unnecessary trailing comma] - -var x = [{ - a: 1, - b: 2, - d: 34, - c: (a + b) -}]; - -var s = { - sA: 6, -}; - -var t = { - tA: 7 -} - -var y = { - yA: 42, - yB: 24, -}; - -var z = { - zOne: 2, - zTwo: 1 -}; - -var ss = [ - 6, -]; - -var tt = [ - 7 -]; - -var yy = [ - 42, - 24, -]; - -var zz = [ - 2, - 1 -]; - -var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; - ~ [Unnecessary trailing comma] - ~ [Unnecessary trailing comma] - -var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; - -var c = {cA: 42, cB: 24,}; - ~ [Unnecessary trailing comma] - -var d = {dOne: 2, dTwo: 1}; - -var cc = [42, 24,]; - ~ [Unnecessary trailing comma] - -var dd = [2, 1]; - -var { - sA, -} = s; - -var { - tA -} = t; - -var { - yA, - yB, -} = y; - -var { - zOne, - zTwo -} = z; - -var [ - ssA, -] = ss; - -var [ - ttA -] = tt; - -var [ - yyA, - yyB, -] = yy; - -var [ - zzOne, - zzTwo -] = zz; - -var {cA, cB,} = c; - ~ [Unnecessary trailing comma] - -var {dOne, dTwo} = d; - -var [ccA, ccB,] = cc; - ~ [Unnecessary trailing comma] - -var [ddOne, ddTwo] = dd; - -var a: [string, number] = null; - -var a: [string, number,] = null; - -var a: [ - string, - number -] = null; - -var a: [ - string, - number, -] = null; - - -import { - ClassS, -} from "module"; - -import { - ClassT -} from "module"; - -import { - ClassV, - ClassX, -} from "module"; - -import { - ClassY, - ClassZ -} from "module"; - -import {ClassA, ClassB,} from "module"; - ~ [Unnecessary trailing comma] - -import {ClassC, ClassD} from "module"; - -function foo(bar: string, baz: string); - -function foo(bar: string, baz: string,); - ~ [Unnecessary trailing comma] - -function foo( - bar: string, - baz: string -); - -function foo( - bar: string, - baz: string, -); - -var foo = function(bar: string, baz: string) { return 42; }; - -var foo = function(bar: string, baz: string,) { return 42; }; - ~ [Unnecessary trailing comma] - -var foo = function( - bar: string, - baz: string -) { - return 42; -}; - -var foo = function( - bar: string, - baz: string, -) { - return 42; -}; - -function foo(bar: string, baz: string) { return 42; } - -function foo(bar: string, baz: string,) { return 42; } - ~ [Unnecessary trailing comma] - -function foo( - bar: string, - baz: string -) { - return 42; -} - -function foo( - bar: string, - baz: string, -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string -) { - return 42; -} - -function foo(bar: string, baz: string, - ack: string, -) { - return 42; -} - -var foo = (bar: string, baz: string) => 42; - -var foo = (bar: string, baz: string,) => 42; - ~ [Unnecessary trailing comma] - -var foo = ( - bar: string, - baz: string -) => 42; - -var foo = ( - bar: string, - baz: string, -) => 42; - -var foo: (bar: string, baz: string) => number = null; - -var foo: (bar: string, baz: string,) => number = null; - ~ [Unnecessary trailing comma] - -var foo: ( - bar: string, - baz: string -) => number = null; - -var foo: ( - bar: string, - baz: string, -) => number = null; - -var foo: (bar: string, baz: string) => number; - -var foo: (bar: string, baz: string,) => number; - ~ [Unnecessary trailing comma] - -var foo: ( - bar: string, - baz: string -) => number; - -var foo: ( - bar: string, - baz: string, -) => number; - -var foo: new (bar: string, baz: string) => Test; - -var foo: new (bar: string, baz: string,) => Test; - ~ [Unnecessary trailing comma] - -var foo: new ( - bar: string, - baz: string -) => Test; - -var foo: new ( - bar: string, - baz: string, -) => Test; - -var x = foo(42, 43); - -var x = foo(42, 43,); - ~ [Unnecessary trailing comma] - -var x = foo( - 42, - 43 -); - -var x = foo( - 42, - 43, -); - -var x = new Test("foo"); - -var x = new Test("foo",); - ~ [Unnecessary trailing comma] - -var x = new Test( - "foo" -); - -var x = new Test( - "foo", -); - -var x: { foo: string; bar: string }; - -var x: { foo: string; bar: string; }; - -var x: { - foo: string; - bar: string -}; - -var x: { - foo: string; - bar: string; -}; - -var x: { foo: string, bar: string }; - -var x: { foo: string, bar: string, }; - ~ [Unnecessary trailing comma] - -var x: { - foo: string, - bar: string -}; - -var x: { - foo: string, - bar: string, -}; - -class Test { - - constructor(bar: string) { } - - constructor(bar: string, baz: string,) { } - ~ [Unnecessary trailing comma] - - constructor( - bar: string, - baz: string, - ack: string - ) { } - - constructor( - bar: string, - baz: string, - ack: string, - foo: string, - ) { } - - public foo(bar: string, baz: string) { - return 42; - } - - private foo2(bar: string, baz: string,) { - ~ [Unnecessary trailing comma] - return 42; - } - - public static foo3( - bar: string, - baz: string - ) { - return 42; - } - - private static foo4( - bar: string, - baz: string, - ) { - return 42; - } - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ) { - return 42; - } - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string, - ]; - }, - >() { return 42; } -} - -class Test2 { } - - -class Test3< - A, - B, - C -> { } - -class Test4< - A, - B, - C, -> { } - -interface ITest { - foo(bar: string, baz: string); - - foo2(bar: string, baz: string,); - ~ [Unnecessary trailing comma] - - foo3( - bar: string, - baz: string - ); - - foo4( - bar: string, - baz: string, - ); - - foo5< - T extends Test<[A, A], [A, A], A>, - U extends Test, - V extends Test< - [ - C, - C - ], - [ - C, - C, - ], - C - > - >( - bar: A, - baz: T, - ); - - foo6< - T extends { foo: A, bar: B }, - U extends { foo: A, bar: B }, - V extends { - foo: A; - bar: B; - }, - W extends { - foo: [ - string, - string - ]; - } - >(); -} - -interface ITest2 { } - -interface ITest3< - A, - B, - C -> { } - -interface ITest4< - A, - B, - C, -> { } - -enum Foo { BAR, BAZ } - -enum Foo { BAR, BAZ, } - ~ [Unnecessary trailing comma] - -enum Foo { - Bar, - Baz -} - -enum Foo { - Bar, - Baz, -} - -const enum Foo { BAR = 1, BAZ = 2 } - -const enum Foo { BAR = 1, BAZ = 2, } - ~ [Unnecessary trailing comma] - -const enum Foo { - Bar = 1, - Baz = 2 -} - -const enum Foo { - Bar = 1, - Baz = 2, -} - -let { - ...x, -} = {}; -let [ - ...y, -] = []; - -[ - ...y, -] = []; -({ - ...y, -} = {}) -function foo( - ...z, -) {} - - -let {...x,} = {}; - ~ [Unnecessary trailing comma] -let [...y,] = []; - ~ [Unnecessary trailing comma] -[...y,] = []; - ~ [Unnecessary trailing comma] -({...y,} = {}) - ~ [Unnecessary trailing comma] -function foo(...z,) {} - ~ [Unnecessary trailing comma] - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - -let foo = bar => bar; -let foo = (bar => bar); diff --git a/test/rules/trailing-comma/singleline-never/tslint.json b/test/rules/trailing-comma/singleline-never/tslint.json deleted file mode 100644 index 9cf46fd84b6..00000000000 --- a/test/rules/trailing-comma/singleline-never/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "trailing-comma": [true, {"singleline": "never"}] - } -} diff --git a/test/rules/trailing-comma/spec-compliant/test.ts.fix b/test/rules/trailing-comma/spec-compliant/test.ts.fix deleted file mode 100644 index 73c83825bb4..00000000000 --- a/test/rules/trailing-comma/spec-compliant/test.ts.fix +++ /dev/null @@ -1,66 +0,0 @@ -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - - -[...y] = [...y,]; -({ - ...x -} = { - ...x, -}); -({ - ...x -} = { - ...x, - y, -}) -foo(...y,); - -function combined([a, ...arr], {b, ...obj}, regular,) {} - -function combined([a, ...arr], {b, ...obj}, regular,) {} diff --git a/test/rules/trailing-comma/spec-compliant/test.ts.lint b/test/rules/trailing-comma/spec-compliant/test.ts.lint deleted file mode 100644 index a2b896d2409..00000000000 --- a/test/rules/trailing-comma/spec-compliant/test.ts.lint +++ /dev/null @@ -1,83 +0,0 @@ -let { - ...x, - ~ [Forbidden trailing comma] -} = {}; -let [ - ...y, - ~ [Forbidden trailing comma] -] = []; - -[ - ...y, - ~ [Forbidden trailing comma] -] = []; -({ - ...y, - ~ [Forbidden trailing comma] -} = {}) -function foo( - ...z, - ~ [Forbidden trailing comma] -) {} - - -let {...x,} = {}; - ~ [Forbidden trailing comma] -let [...y,] = []; - ~ [Forbidden trailing comma] -[...y,] = []; - ~ [Forbidden trailing comma] -({...y,} = {}) - ~ [Forbidden trailing comma] -function foo(...z,) {} - ~ [Forbidden trailing comma] - -let { - ...x -} = {}; -let [ - ...y -] = []; - -[ - ...y -] = []; -({ - ...y -} = {}) -function foo( - ...z -) {} - - -let {...x} = {}; -let [...y] = []; -[...y] = []; -({...y} = {}) -function foo(...z) {} - - -[...y] = [...y]; - ~nil [Missing trailing comma] -({ - ...x -} = { - ...x - ~nil [Missing trailing comma] -}); -({ - ...x -} = { - ...x, - y - ~nil [Missing trailing comma] -}) -foo(...y); - ~nil [Missing trailing comma] - -function combined([a, ...arr], {b, ...obj}, regular) {} - ~nil [Missing trailing comma] - -function combined([a, ...arr,], {b, ...obj,}, regular,) {} - ~ [Forbidden trailing comma] - ~ [Forbidden trailing comma] diff --git a/test/rules/trailing-comma/spec-compliant/tslint.json b/test/rules/trailing-comma/spec-compliant/tslint.json deleted file mode 100644 index 3005eb3add4..00000000000 --- a/test/rules/trailing-comma/spec-compliant/tslint.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "rules": { - "trailing-comma": [ - true, - { - "multiline": "always", - "singleline": "always", - "esSpecCompliant": true - } - ] - } -} diff --git a/test/rules/triple-equals/allow-null-check/test.ts.lint b/test/rules/triple-equals/allow-null-check/test.ts.lint deleted file mode 100644 index 6fddcf97283..00000000000 --- a/test/rules/triple-equals/allow-null-check/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -var testVariable = 123; - -function testFunction() { - if (x === testFunction && y == 4) { - ~~ [== should be ===] - console.log("called"); - } - - var z = (x + 3) != 5; - ~~ [!= should be !==] - return; -} - -// disallow double-equality undefined checks -var x = (y == undefined) ? 1 : 2; - ~~ [== should be ===] - -// allow double-equality null checks -var x = (y == null) ? 1 : 2; diff --git a/test/rules/triple-equals/allow-null-check/tslint.json b/test/rules/triple-equals/allow-null-check/tslint.json deleted file mode 100644 index b60bf169ef6..00000000000 --- a/test/rules/triple-equals/allow-null-check/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "triple-equals": [true, "allow-null-check"] - } -} diff --git a/test/rules/triple-equals/allow-undefined-check/test.ts.lint b/test/rules/triple-equals/allow-undefined-check/test.ts.lint deleted file mode 100644 index a3e2136f538..00000000000 --- a/test/rules/triple-equals/allow-undefined-check/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -var testVariable = 123; - -function testFunction() { - if (x === testFunction && y == 4) { - ~~ [== should be ===] - console.log("called"); - } - - var z = (x + 3) != 5; - ~~ [!= should be !==] - return; -} - -// allow double-equality undefined checks -var x = (y == undefined) ? 1 : 2; - -// disallow double-equality null checks -var x = (y == null) ? 1 : 2; - ~~ [== should be ===] diff --git a/test/rules/triple-equals/allow-undefined-check/tslint.json b/test/rules/triple-equals/allow-undefined-check/tslint.json deleted file mode 100644 index 1ab9dce6344..00000000000 --- a/test/rules/triple-equals/allow-undefined-check/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "triple-equals": [true, "allow-undefined-check"] - } -} diff --git a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix deleted file mode 100644 index 75bb20c25af..00000000000 --- a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix +++ /dev/null @@ -1,21 +0,0 @@ -type T = { - x: number; - y: string; -}; - -type T = { - x: number; - y: string; -}; - -type T = { - x: number; - y: string; -}; - -type T = { x: number; y: string }; - -// Works even when there's extra whitespace -type T = { x: number ; y: number }; -type T = { x: number ; y: number }; - diff --git a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint deleted file mode 100644 index d5b99e77592..00000000000 --- a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint +++ /dev/null @@ -1,30 +0,0 @@ -type T = { - x: number, - ~ [COMMA] - y: string - ~ [MISSING] -}; - -type T = { - x: number - ~ [MISSING] - y: string, - ~ [COMMA] -}; - -type T = { - x: number; - y: string; -}; - -type T = { x: number; y: string }; - -// Works even when there's extra whitespace -type T = { x: number ; y: number }; -type T = { x: number , y: number ; }; - ~ [COMMA] - ~ [EXTRA] - -[MISSING]: Expected type literal to use ';' to separate members. -[COMMA]: Expected type literal to use ';' instead of ','. -[EXTRA]: Did not expect single-line type literal to have a trailing ';'. diff --git a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json deleted file mode 100644 index ba33191cc21..00000000000 --- a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "type-literal-delimiter": true - } -} diff --git a/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix b/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix deleted file mode 100644 index 7d8243768e1..00000000000 --- a/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix +++ /dev/null @@ -1,21 +0,0 @@ -type T = { - x: number; - y: string; -}; - -type T = { - x: number; - y: string; -}; - -type T = { - x: number; - y: string; -}; - -type T = { x: number; y: string; }; - -// Works even when there's extra whitespace -type T = { x: number ; y: number; }; -type T = { x: number ; y: number ; }; - diff --git a/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint b/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint deleted file mode 100644 index 49c25a3699a..00000000000 --- a/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint +++ /dev/null @@ -1,31 +0,0 @@ -type T = { - x: number, - ~ [COMMA] - y: string - ~ [MISSING] -}; - -type T = { - x: number - ~ [MISSING] - y: string, - ~ [COMMA] -}; - -type T = { - x: number; - y: string; -}; - -type T = { x: number; y: string }; - ~ [MISSING] - -// Works even when there's extra whitespace -type T = { x: number ; y: number }; - ~ [MISSING] -type T = { x: number , y: number ; }; - ~ [COMMA] - -[MISSING]: Expected type literal to use ';' to separate members. -[COMMA]: Expected type literal to use ';' instead of ','. -[EXTRA]: Did not expect single-line type literal to have a trailing ';'. diff --git a/test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json b/test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json deleted file mode 100644 index a7f4da3afc2..00000000000 --- a/test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "type-literal-delimiter": [ - true, - { - "singleLine": "always" - } - ] - } -} diff --git a/test/rules/typedef-whitespace/both/nospace/test.ts.lint b/test/rules/typedef-whitespace/both/nospace/test.ts.lint deleted file mode 100644 index 23252dd10c3..00000000000 --- a/test/rules/typedef-whitespace/both/nospace/test.ts.lint +++ /dev/null @@ -1,905 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - ~ [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~ [before-call] - ~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~ [before-call] - ~~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~~~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~~~ [before-call] - ~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~~ [before-call] - ~~~ [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; - ~ [after-property] -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~~~ [after-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; - ~ [before-property] -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; - ~ [before-property] - ~ [after-property] -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; - ~ [before-property] - ~~~ [after-property] -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~~~ [before-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; - ~~~ [before-property] - ~ [after-property] -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; - ~~~ [before-property] - ~~~ [after-property] -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - ~ [after-parameter] - ~ [after-parameter] - ~ [after-call] - var c: number = a + b; - ~ [after-variable] - var d: number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~~~ [after-parameter] - ~~~ [after-parameter] - ~~~ [after-call] - var c: number = a + b; - ~~~ [after-variable] - var d: number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - ~ [before-parameter] - ~ [before-parameter] - ~ [before-call] - var c :number = a + b; - ~ [before-variable] - var d :number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - ~ [before-parameter] - ~ [after-parameter] - ~ [before-parameter] - ~ [after-parameter] - ~ [before-call] - ~ [after-call] - var c : number = a + b; - ~ [before-variable] - ~ [after-variable] - var d : number = a - b; - ~ [before-variable] - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - ~ [before-parameter] - ~~~ [after-parameter] - ~ [before-parameter] - ~~~ [after-parameter] - ~ [before-call] - ~~~ [after-call] - var c : number = a + b; - ~ [before-variable] - ~~~ [after-variable] - var d : number = a - b; - ~ [before-variable] - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~~~ [before-parameter] - ~~~ [before-parameter] - ~~~ [before-call] - var c :number = a + b; - ~~~ [before-variable] - var d :number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - ~~~ [before-parameter] - ~ [after-parameter] - ~~~ [before-parameter] - ~ [after-parameter] - ~~~ [before-call] - ~ [after-call] - var c : number = a + b; - ~~~ [before-variable] - ~ [after-variable] - var d : number = a - b; - ~~~ [before-variable] - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - ~~~ [before-parameter] - ~~~ [after-parameter] - ~~~ [before-parameter] - ~~~ [after-parameter] - ~~~ [before-call] - ~~~ [after-call] - var c : number = a + b; - ~~~ [before-variable] - ~~~ [after-variable] - var d : number = a - b; - ~~~ [before-variable] - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - ~~~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - number, b: - number): - number { - var c: - number = a + b; - var d - : number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex: - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - b:number -):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - ~ [after-parameter] - b: number - ~ [after-parameter] -): number { - ~ [after-call] - var c: number = a + b; - ~ [after-variable] - var d: number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~~~ [after-parameter] - b: number - ~~~ [after-parameter] -): number { - ~~~ [after-call] - var c: number = a + b; - ~~~ [after-variable] - var d: number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - ~ [before-parameter] - b :number - ~ [before-parameter] -) :number { - ~ [before-call] - var c :number = a + b; - ~ [before-variable] - var d :number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - ~ [before-parameter] - ~ [after-parameter] - b : number - ~ [before-parameter] - ~ [after-parameter] -) : number { - ~ [before-call] - ~ [after-call] - var c : number = a + b; - ~ [before-variable] - ~ [after-variable] - var d : number = a - b; - ~ [before-variable] - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - ~ [before-parameter] - ~~~ [after-parameter] - b : number - ~ [before-parameter] - ~~~ [after-parameter] -) : number { - ~ [before-call] - ~~~ [after-call] - var c : number = a + b; - ~ [before-variable] - ~~~ [after-variable] - var d : number = a - b; - ~ [before-variable] - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~~~ [before-parameter] - b :number - ~~~ [before-parameter] -) :number { - ~~~ [before-call] - var c :number = a + b; - ~~~ [before-variable] - var d :number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - ~~~ [before-parameter] - ~ [after-parameter] - b : number - ~~~ [before-parameter] - ~ [after-parameter] -) : number { - ~~~ [before-call] - ~ [after-call] - var c : number = a + b; - ~~~ [before-variable] - ~ [after-variable] - var d : number = a - b; - ~~~ [before-variable] - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - ~~~ [before-parameter] - ~~~ [after-parameter] - b : number - ~~~ [before-parameter] - ~~~ [after-parameter] -) : number { - ~~~ [before-call] - ~~~ [after-call] - var c : number = a + b; - ~~~ [before-variable] - ~~~ [after-variable] - var d : number = a - b; - ~~~ [before-variable] - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - ~~~ [after-variable] - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - ~ [after-call] - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~~~ [after-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - ~ [before-call] - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - ~ [before-call] - ~ [after-call] - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - ~ [before-call] - ~~~ [after-call] - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~~~ [before-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - ~~~ [before-call] - ~ [after-call] - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - ~~~ [before-call] - ~~~ [after-call] - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - - Prop:string = "some property"; - - public get name():string { - return "some name"; - } - - public set name(a:string):void {} - - public shemp( - a:number, - b:number - ):void {} -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - ~ [after-parameter] - ~ [after-index] - - Prop: string = "some property"; - ~ [after-property] - - public get name(): string { - ~ [after-call] - return "some name"; - } - - public set name(a: string): void {} - ~ [after-parameter] - ~ [after-call] - - public shemp( - a: number, - ~ [after-parameter] - b: number - ~ [after-parameter] - ): void {} - ~ [after-call] -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~~~ [after-parameter] - ~~~ [after-index] - - Prop: string = "some property"; - ~~~ [after-property] - - public get name(): string { - ~~~ [after-call] - return "some name"; - } - - public set name(a: string): void {} - ~~~ [after-parameter] - ~~~ [after-call] - - public shemp( - a: number, - ~~~ [after-parameter] - b: number - ~~~ [after-parameter] - ): void {} - ~~~ [after-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - ~ [before-parameter] - ~ [before-index] - - Prop :string = "some property"; - ~ [before-property] - - public get name() :string { - ~ [before-call] - return "some name"; - } - - public set name(a :string) :void {} - ~ [before-parameter] - ~ [before-call] - - public shemp( - a :number, - ~ [before-parameter] - b :number - ~ [before-parameter] - ) :void {} - ~ [before-call] -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - ~ [before-parameter] - ~ [after-parameter] - ~ [before-index] - ~ [after-index] - - Prop : string = "some property"; - ~ [before-property] - ~ [after-property] - - public get name() : string { - ~ [before-call] - ~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~ [before-parameter] - ~ [after-parameter] - ~ [before-call] - ~ [after-call] - - public shemp( - a : number, - ~ [before-parameter] - ~ [after-parameter] - b : number - ~ [before-parameter] - ~ [after-parameter] - ) : void {} - ~ [before-call] - ~ [after-call] -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - ~ [before-parameter] - ~~~ [after-parameter] - ~ [before-index] - ~~~ [after-index] - - Prop : string = "some property"; - ~ [before-property] - ~~~ [after-property] - - public get name() : string { - ~ [before-call] - ~~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~ [before-parameter] - ~~~ [after-parameter] - ~ [before-call] - ~~~ [after-call] - - public shemp( - a : number, - ~ [before-parameter] - ~~~ [after-parameter] - b : number - ~ [before-parameter] - ~~~ [after-parameter] - ) : void {} - ~ [before-call] - ~~~ [after-call] -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~~~ [before-parameter] - ~~~ [before-index] - - Prop :string = "some property"; - ~~~ [before-property] - - public get name() :string { - ~~~ [before-call] - return "some name"; - } - - public set name(a :string) :void {} - ~~~ [before-parameter] - ~~~ [before-call] - - public shemp( - a :number, - ~~~ [before-parameter] - b :number - ~~~ [before-parameter] - ) :void {} - ~~~ [before-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - ~~~ [before-parameter] - ~ [after-parameter] - ~~~ [before-index] - ~ [after-index] - - Prop : string = "some property"; - ~~~ [before-property] - ~ [after-property] - - public get name() : string { - ~~~ [before-call] - ~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~~ [before-parameter] - ~ [after-parameter] - ~~~ [before-call] - ~ [after-call] - - public shemp( - a : number, - ~~~ [before-parameter] - ~ [after-parameter] - b : number - ~~~ [before-parameter] - ~ [after-parameter] - ) : void {} - ~~~ [before-call] - ~ [after-call] -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - ~~~ [before-parameter] - ~~~ [after-parameter] - ~~~ [before-index] - ~~~ [after-index] - - Prop : string = "some property"; - ~~~ [before-property] - ~~~ [after-property] - - public get name() : string { - ~~~ [before-call] - ~~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~~ [before-parameter] - ~~~ [after-parameter] - ~~~ [before-call] - ~~~ [after-call] - - public shemp( - a : number, - ~~~ [before-parameter] - ~~~ [after-parameter] - b : number - ~~~ [before-parameter] - ~~~ [after-parameter] - ) : void {} - ~~~ [before-call] - ~~~ [after-call] -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - string - - Prop: - string = "some property"; - - public get name(): - string { - return "some name"; - } - - public set name(a: - string): - void {} - - public shemp( - a: - number, - b: - number - ): - void {} -} - -let foo = ():void => {}; -let foo = () : void => {}; - ~ [before-call] - ~ [after-call] -let foo = () : void => {}; - ~~~ [before-call] - ~~~ [after-call] - -interface Foo { - new() : Bar; - ~ [before-call] - ~ [after-call] - () : void; - ~ [before-call] - ~ [after-call] -} - -// endregion - -[_base]: expected nospace %s colon in %s -[before-call]: _base % ('before', 'call-signature') -[after-call]: _base % ('after', 'call-signature') -[before-parameter]: _base % ('before', 'parameter') -[after-parameter]: _base % ('after', 'parameter') -[before-index]: _base % ('before', 'index-signature') -[after-index]: _base % ('after', 'index-signature') -[before-variable]: _base % ('before', 'variable-declaration') -[after-variable]: _base % ('after', 'variable-declaration') -[before-property]: _base % ('before', 'property-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/both/nospace/tslint.json b/test/rules/typedef-whitespace/both/nospace/tslint.json deleted file mode 100644 index 459b9de0890..00000000000 --- a/test/rules/typedef-whitespace/both/nospace/tslint.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true, - "typedef-whitespace": [true, { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }, { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }] - } -} diff --git a/test/rules/typedef-whitespace/both/onespace/test.ts.lint b/test/rules/typedef-whitespace/both/onespace/test.ts.lint deleted file mode 100644 index b8759bcf8be..00000000000 --- a/test/rules/typedef-whitespace/both/onespace/test.ts.lint +++ /dev/null @@ -1,913 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - ~nil [before-call] - ~nil [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - ~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~~ [before-call] - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [before-call] - ~~ [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - ~nil [before-call] - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; - ~nil [before-property] - ~nil [after-property] -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; - ~nil [before-property] -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~nil [before-property] - ~~ [after-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; - ~~ [after-property] -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~~ [before-property] - ~nil [after-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; - ~~ [before-property] -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; - ~~ [before-property] - ~~ [after-property] -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - ~nil [before-property] - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-call] - ~nil [after-call] - var c:number = a + b; - ~nil [before-variable] - ~nil [after-variable] - var d:number = a - b; - ~nil [before-variable] - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~nil [before-parameter] - ~~ [after-parameter] - ~nil [before-parameter] - ~~ [after-parameter] - ~nil [before-call] - ~~ [after-call] - var c: number = a + b; - ~nil [before-variable] - ~~ [after-variable] - var d: number = a - b; - ~nil [before-variable] - ~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - ~~ [after-parameter] - ~~ [after-parameter] - ~~ [after-call] - var c : number = a + b; - ~~ [after-variable] - var d : number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~~ [before-parameter] - ~nil [after-parameter] - ~~ [before-parameter] - ~nil [after-parameter] - ~~ [before-call] - ~nil [after-call] - var c :number = a + b; - ~~ [before-variable] - ~nil [after-variable] - var d :number = a - b; - ~~ [before-variable] - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~ [before-variable] - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - ~~ [before-parameter] - ~~ [before-parameter] - ~~ [before-call] - var c : number = a + b; - ~~ [before-variable] - var d : number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - ~~ [before-parameter] - ~~ [after-parameter] - ~~ [before-parameter] - ~~ [after-parameter] - ~~ [before-call] - ~~ [after-call] - var c : number = a + b; - ~~ [before-variable] - ~~ [after-variable] - var d : number = a - b; - ~~ [before-variable] - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - ~~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - ~nil [before-parameter] - number, b: - ~nil [before-parameter] - number): - ~nil [before-call] - number { - var c: - ~nil [before-variable] - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - ~nil [before-variable] - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - ~nil [before-parameter] - ~nil [after-parameter] - b:number - ~nil [before-parameter] - ~nil [after-parameter] -):number { - ~nil [before-call] - ~nil [after-call] - var c:number = a + b; - ~nil [before-variable] - ~nil [after-variable] - var d:number = a - b; - ~nil [before-variable] - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~nil [before-parameter] - ~~ [after-parameter] - b: number - ~nil [before-parameter] - ~~ [after-parameter] -): number { - ~nil [before-call] - ~~ [after-call] - var c: number = a + b; - ~nil [before-variable] - ~~ [after-variable] - var d: number = a - b; - ~nil [before-variable] - ~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - ~~ [after-parameter] - b : number - ~~ [after-parameter] -) : number { - ~~ [after-call] - var c : number = a + b; - ~~ [after-variable] - var d : number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~~ [before-parameter] - ~nil [after-parameter] - b :number - ~~ [before-parameter] - ~nil [after-parameter] -) :number { - ~~ [before-call] - ~nil [after-call] - var c :number = a + b; - ~~ [before-variable] - ~nil [after-variable] - var d :number = a - b; - ~~ [before-variable] - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~ [before-variable] - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - ~~ [before-parameter] - b : number - ~~ [before-parameter] -) : number { - ~~ [before-call] - var c : number = a + b; - ~~ [before-variable] - var d : number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - ~~ [before-parameter] - ~~ [after-parameter] - b : number - ~~ [before-parameter] - ~~ [after-parameter] -) : number { - ~~ [before-call] - ~~ [after-call] - var c : number = a + b; - ~~ [before-variable] - ~~ [after-variable] - var d : number = a - b; - ~~ [before-variable] - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - ~~ [after-variable] - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - ~nil [before-call] - ~nil [after-call] - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - ~nil [before-call] - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~nil [before-call] - ~~ [after-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - ~~ [after-call] - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~~ [before-call] - ~nil [after-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - ~~ [before-call] - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - ~~ [before-call] - ~~ [after-call] - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - ~nil [before-call] - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-index] - ~nil [after-index] - - Prop:string = "some property"; - ~nil [before-property] - ~nil [after-property] - - public get name():string { - ~nil [before-call] - ~nil [after-call] - return "some name"; - } - - public set name(a:string):void {} - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-call] - ~nil [after-call] - - public shemp( - a:number, - ~nil [before-parameter] - ~nil [after-parameter] - b:number - ~nil [before-parameter] - ~nil [after-parameter] - ):void {} - ~nil [before-call] - ~nil [after-call] -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~nil [before-parameter] - ~~ [after-parameter] - ~nil [before-index] - ~~ [after-index] - - Prop: string = "some property"; - ~nil [before-property] - ~~ [after-property] - - public get name(): string { - ~nil [before-call] - ~~ [after-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~~ [after-parameter] - ~nil [before-call] - ~~ [after-call] - - public shemp( - a: number, - ~nil [before-parameter] - ~~ [after-parameter] - b: number - ~nil [before-parameter] - ~~ [after-parameter] - ): void {} - ~nil [before-call] - ~~ [after-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - ~~ [after-parameter] - ~~ [after-index] - - Prop : string = "some property"; - ~~ [after-property] - - public get name() : string { - ~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [after-parameter] - ~~ [after-call] - - public shemp( - a : number, - ~~ [after-parameter] - b : number - ~~ [after-parameter] - ) : void {} - ~~ [after-call] -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~~ [before-parameter] - ~nil [after-parameter] - ~~ [before-index] - ~nil [after-index] - - Prop :string = "some property"; - ~~ [before-property] - ~nil [after-property] - - public get name() :string { - ~~ [before-call] - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~~ [before-parameter] - ~nil [after-parameter] - ~~ [before-call] - ~nil [after-call] - - public shemp( - a :number, - ~~ [before-parameter] - ~nil [after-parameter] - b :number - ~~ [before-parameter] - ~nil [after-parameter] - ) :void {} - ~~ [before-call] - ~nil [after-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - ~~ [before-parameter] - ~~ [before-index] - - Prop : string = "some property"; - ~~ [before-property] - - public get name() : string { - ~~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [before-parameter] - ~~ [before-call] - - public shemp( - a : number, - ~~ [before-parameter] - b : number - ~~ [before-parameter] - ) : void {} - ~~ [before-call] -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - ~~ [before-parameter] - ~~ [after-parameter] - ~~ [before-index] - ~~ [after-index] - - Prop : string = "some property"; - ~~ [before-property] - ~~ [after-property] - - public get name() : string { - ~~ [before-call] - ~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [before-parameter] - ~~ [after-parameter] - ~~ [before-call] - ~~ [after-call] - - public shemp( - a : number, - ~~ [before-parameter] - ~~ [after-parameter] - b : number - ~~ [before-parameter] - ~~ [after-parameter] - ) : void {} - ~~ [before-call] - ~~ [after-call] -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-index] - string - - Prop: - ~nil [before-property] - string = "some property"; - - public get name(): - ~nil [before-call] - string { - return "some name"; - } - - public set name(a: - ~nil [before-parameter] - string): - ~nil [before-call] - void {} - - public shemp( - a: - ~nil [before-parameter] - number, - b: - ~nil [before-parameter] - number - ): - ~nil [before-call] - void {} -} - -let foo = ():void => {}; - ~nil [before-call] - ~nil [after-call] -let foo = () : void => {}; -let foo = () : void => {}; - ~~ [before-call] - ~~ [after-call] - -// endregion - -[_base]: expected onespace %s colon in %s -[before-call]: _base % ('before', 'call-signature') -[after-call]: _base % ('after', 'call-signature') -[before-parameter]: _base % ('before', 'parameter') -[after-parameter]: _base % ('after', 'parameter') -[before-index]: _base % ('before', 'index-signature') -[after-index]: _base % ('after', 'index-signature') -[before-variable]: _base % ('before', 'variable-declaration') -[after-variable]: _base % ('after', 'variable-declaration') -[before-property]: _base % ('before', 'property-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/both/onespace/tslint.json b/test/rules/typedef-whitespace/both/onespace/tslint.json deleted file mode 100644 index fcf1d6674eb..00000000000 --- a/test/rules/typedef-whitespace/both/onespace/tslint.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true, - "typedef-whitespace": [true, { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - }, { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - }] - } -} diff --git a/test/rules/typedef-whitespace/both/space/test.ts.lint b/test/rules/typedef-whitespace/both/space/test.ts.lint deleted file mode 100644 index 3ba0bcc341f..00000000000 --- a/test/rules/typedef-whitespace/both/space/test.ts.lint +++ /dev/null @@ -1,767 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - ~nil [before-call] - ~nil [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - ~nil [before-call] - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; - ~nil [before-property] - ~nil [after-property] -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; - ~nil [before-property] -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~nil [before-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - ~nil [before-property] - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-call] - ~nil [after-call] - var c:number = a + b; - ~nil [before-variable] - ~nil [after-variable] - var d:number = a - b; - ~nil [before-variable] - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - ~nil [before-parameter] - number, b: - ~nil [before-parameter] - number): - ~nil [before-call] - number { - var c: - ~nil [before-variable] - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - ~nil [before-variable] - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - ~nil [before-parameter] - ~nil [after-parameter] - b:number - ~nil [before-parameter] - ~nil [after-parameter] -):number { - ~nil [before-call] - ~nil [after-call] - var c:number = a + b; - ~nil [before-variable] - ~nil [after-variable] - var d:number = a - b; - ~nil [before-variable] - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - ~nil [before-call] - ~nil [after-call] - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - ~nil [before-call] - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~nil [before-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - ~nil [before-call] - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-index] - ~nil [after-index] - - Prop:string = "some property"; - ~nil [before-property] - ~nil [after-property] - - public get name():string { - ~nil [before-call] - ~nil [after-call] - return "some name"; - } - - public set name(a:string):void {} - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-call] - ~nil [after-call] - - public shemp( - a:number, - ~nil [before-parameter] - ~nil [after-parameter] - b:number - ~nil [before-parameter] - ~nil [after-parameter] - ):void {} - ~nil [before-call] - ~nil [after-call] -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - ~nil [before-parameter] - ~nil [after-parameter] - ~nil [before-index] - string - - Prop: - ~nil [before-property] - string = "some property"; - - public get name(): - ~nil [before-call] - string { - return "some name"; - } - - public set name(a: - ~nil [before-parameter] - string): - ~nil [before-call] - void {} - - public shemp( - a: - ~nil [before-parameter] - number, - b: - ~nil [before-parameter] - number - ): - ~nil [before-call] - void {} -} - -let foo = ():void => {}; - ~nil [before-call] - ~nil [after-call] -let foo = () : void => {}; -let foo = () : void => {}; - -// endregion - -[_base]: expected space %s colon in %s -[before-call]: _base % ('before', 'call-signature') -[after-call]: _base % ('after', 'call-signature') -[before-parameter]: _base % ('before', 'parameter') -[after-parameter]: _base % ('after', 'parameter') -[before-index]: _base % ('before', 'index-signature') -[after-index]: _base % ('after', 'index-signature') -[before-variable]: _base % ('before', 'variable-declaration') -[after-variable]: _base % ('after', 'variable-declaration') -[before-property]: _base % ('before', 'property-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/both/space/tslint.json b/test/rules/typedef-whitespace/both/space/tslint.json deleted file mode 100644 index 44bbc56c01f..00000000000 --- a/test/rules/typedef-whitespace/both/space/tslint.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true, - "typedef-whitespace": [true, { - "call-signature": "space", - "index-signature": "space", - "parameter": "space", - "property-declaration": "space", - "variable-declaration": "space" - }, { - "call-signature": "space", - "index-signature": "space", - "parameter": "space", - "property-declaration": "space", - "variable-declaration": "space" - }] - } -} diff --git a/test/rules/typedef-whitespace/left/nospace/test.ts.lint b/test/rules/typedef-whitespace/left/nospace/test.ts.lint deleted file mode 100644 index 6ee93d35296..00000000000 --- a/test/rules/typedef-whitespace/left/nospace/test.ts.lint +++ /dev/null @@ -1,745 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~~~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~~~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~~ [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; - ~ [before-property] -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; - ~ [before-property] -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; - ~ [before-property] -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~~~ [before-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; - ~~~ [before-property] -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; - ~~~ [before-property] -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - ~ [before-parameter] - ~ [before-parameter] - ~ [before-call] - var c :number = a + b; - ~ [before-variable] - var d :number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - ~ [before-parameter] - ~ [before-parameter] - ~ [before-call] - var c : number = a + b; - ~ [before-variable] - var d : number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - ~ [before-parameter] - ~ [before-parameter] - ~ [before-call] - var c : number = a + b; - ~ [before-variable] - var d : number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~~~ [before-parameter] - ~~~ [before-parameter] - ~~~ [before-call] - var c :number = a + b; - ~~~ [before-variable] - var d :number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - ~~~ [before-parameter] - ~~~ [before-parameter] - ~~~ [before-call] - var c : number = a + b; - ~~~ [before-variable] - var d : number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - ~~~ [before-parameter] - ~~~ [before-parameter] - ~~~ [before-call] - var c : number = a + b; - ~~~ [before-variable] - var d : number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - number, b: - number): - number { - var c: - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - b:number -):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - ~ [before-parameter] - b :number - ~ [before-parameter] -) :number { - ~ [before-call] - var c :number = a + b; - ~ [before-variable] - var d :number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - ~ [before-parameter] - b : number - ~ [before-parameter] -) : number { - ~ [before-call] - var c : number = a + b; - ~ [before-variable] - var d : number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - ~ [before-parameter] - b : number - ~ [before-parameter] -) : number { - ~ [before-call] - var c : number = a + b; - ~ [before-variable] - var d : number = a - b; - ~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~~~ [before-parameter] - b :number - ~~~ [before-parameter] -) :number { - ~~~ [before-call] - var c :number = a + b; - ~~~ [before-variable] - var d :number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - ~~~ [before-parameter] - b : number - ~~~ [before-parameter] -) : number { - ~~~ [before-call] - var c : number = a + b; - ~~~ [before-variable] - var d : number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - ~~~ [before-parameter] - b : number - ~~~ [before-parameter] -) : number { - ~~~ [before-call] - var c : number = a + b; - ~~~ [before-variable] - var d : number = a - b; - ~~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [before-variable] - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - ~ [before-call] - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - ~ [before-call] - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - ~ [before-call] - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~~~ [before-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - ~~~ [before-call] - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - ~~~ [before-call] - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - - Prop:string = "some property"; - - public get name():string { - return "some name"; - } - - public set name(a:string):void {} - - public shemp( - a:number, - b:number - ):void {} -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - ~ [before-parameter] - ~ [before-index] - - Prop :string = "some property"; - ~ [before-property] - - public get name() :string { - ~ [before-call] - return "some name"; - } - - public set name(a :string) :void {} - ~ [before-parameter] - ~ [before-call] - - public shemp( - a :number, - ~ [before-parameter] - b :number - ~ [before-parameter] - ) :void {} - ~ [before-call] -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - ~ [before-parameter] - ~ [before-index] - - Prop : string = "some property"; - ~ [before-property] - - public get name() : string { - ~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~ [before-parameter] - ~ [before-call] - - public shemp( - a : number, - ~ [before-parameter] - b : number - ~ [before-parameter] - ) : void {} - ~ [before-call] -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - ~ [before-parameter] - ~ [before-index] - - Prop : string = "some property"; - ~ [before-property] - - public get name() : string { - ~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~ [before-parameter] - ~ [before-call] - - public shemp( - a : number, - ~ [before-parameter] - b : number - ~ [before-parameter] - ) : void {} - ~ [before-call] -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~~~ [before-parameter] - ~~~ [before-index] - - Prop :string = "some property"; - ~~~ [before-property] - - public get name() :string { - ~~~ [before-call] - return "some name"; - } - - public set name(a :string) :void {} - ~~~ [before-parameter] - ~~~ [before-call] - - public shemp( - a :number, - ~~~ [before-parameter] - b :number - ~~~ [before-parameter] - ) :void {} - ~~~ [before-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - ~~~ [before-parameter] - ~~~ [before-index] - - Prop : string = "some property"; - ~~~ [before-property] - - public get name() : string { - ~~~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~~ [before-parameter] - ~~~ [before-call] - - public shemp( - a : number, - ~~~ [before-parameter] - b : number - ~~~ [before-parameter] - ) : void {} - ~~~ [before-call] -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - ~~~ [before-parameter] - ~~~ [before-index] - - Prop : string = "some property"; - ~~~ [before-property] - - public get name() : string { - ~~~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~~ [before-parameter] - ~~~ [before-call] - - public shemp( - a : number, - ~~~ [before-parameter] - b : number - ~~~ [before-parameter] - ) : void {} - ~~~ [before-call] -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - string - - Prop: - string = "some property"; - - public get name(): - string { - return "some name"; - } - - public set name(a: - string): - void {} - - public shemp( - a: - number, - b: - number - ): - void {} -} - -let foo = ():void => {}; -let foo = () : void => {}; - ~ [before-call] -let foo = () : void => {}; - ~~~ [before-call] - -// endregion - -[_base]: expected nospace %s colon in %s -[before-call]: _base % ('before', 'call-signature') -[before-parameter]: _base % ('before', 'parameter') -[before-index]: _base % ('before', 'index-signature') -[before-variable]: _base % ('before', 'variable-declaration') -[before-property]: _base % ('before', 'property-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/left/nospace/tslint.json b/test/rules/typedef-whitespace/left/nospace/tslint.json deleted file mode 100644 index 55e481c3176..00000000000 --- a/test/rules/typedef-whitespace/left/nospace/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "typedef-whitespace": [true, { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }] - } -} diff --git a/test/rules/typedef-whitespace/left/onespace/test.ts.lint b/test/rules/typedef-whitespace/left/onespace/test.ts.lint deleted file mode 100644 index cd2182c989a..00000000000 --- a/test/rules/typedef-whitespace/left/onespace/test.ts.lint +++ /dev/null @@ -1,762 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - ~nil [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [before-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - ~nil [before-call] - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; - ~nil [before-property] -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; - ~nil [before-property] -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~nil [before-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~~ [before-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; - ~~ [before-property] -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; - ~~ [before-property] -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - ~nil [before-property] - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c:number = a + b; - ~nil [before-variable] - var d:number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~~ [before-parameter] - ~~ [before-parameter] - ~~ [before-call] - var c :number = a + b; - ~~ [before-variable] - var d :number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - ~~ [before-parameter] - ~~ [before-parameter] - ~~ [before-call] - var c : number = a + b; - ~~ [before-variable] - var d : number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - ~~ [before-parameter] - ~~ [before-parameter] - ~~ [before-call] - var c : number = a + b; - ~~ [before-variable] - var d : number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - ~nil [before-parameter] - number, b: - ~nil [before-parameter] - number): - ~nil [before-call] - number { - var c: - ~nil [before-variable] - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - ~nil [before-variable] - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - ~nil [before-parameter] - b:number - ~nil [before-parameter] -):number { - ~nil [before-call] - var c:number = a + b; - ~nil [before-variable] - var d:number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~~ [before-parameter] - b :number - ~~ [before-parameter] -) :number { - ~~ [before-call] - var c :number = a + b; - ~~ [before-variable] - var d :number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - ~~ [before-parameter] - b : number - ~~ [before-parameter] -) : number { - ~~ [before-call] - var c : number = a + b; - ~~ [before-variable] - var d : number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - ~~ [before-parameter] - b : number - ~~ [before-parameter] -) : number { - ~~ [before-call] - var c : number = a + b; - ~~ [before-variable] - var d : number = a - b; - ~~ [before-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [before-variable] - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - ~nil [before-call] - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - ~nil [before-call] - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~nil [before-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~~ [before-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - ~~ [before-call] - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - ~~ [before-call] - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - ~nil [before-call] - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - ~nil [before-parameter] - ~nil [before-index] - - Prop:string = "some property"; - ~nil [before-property] - - public get name():string { - ~nil [before-call] - return "some name"; - } - - public set name(a:string):void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a:number, - ~nil [before-parameter] - b:number - ~nil [before-parameter] - ):void {} - ~nil [before-call] -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~~ [before-parameter] - ~~ [before-index] - - Prop :string = "some property"; - ~~ [before-property] - - public get name() :string { - ~~ [before-call] - return "some name"; - } - - public set name(a :string) :void {} - ~~ [before-parameter] - ~~ [before-call] - - public shemp( - a :number, - ~~ [before-parameter] - b :number - ~~ [before-parameter] - ) :void {} - ~~ [before-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - ~~ [before-parameter] - ~~ [before-index] - - Prop : string = "some property"; - ~~ [before-property] - - public get name() : string { - ~~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [before-parameter] - ~~ [before-call] - - public shemp( - a : number, - ~~ [before-parameter] - b : number - ~~ [before-parameter] - ) : void {} - ~~ [before-call] -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - ~~ [before-parameter] - ~~ [before-index] - - Prop : string = "some property"; - ~~ [before-property] - - public get name() : string { - ~~ [before-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [before-parameter] - ~~ [before-call] - - public shemp( - a : number, - ~~ [before-parameter] - b : number - ~~ [before-parameter] - ) : void {} - ~~ [before-call] -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - ~nil [before-parameter] - ~nil [before-index] - string - - Prop: - ~nil [before-property] - string = "some property"; - - public get name(): - ~nil [before-call] - string { - return "some name"; - } - - public set name(a: - ~nil [before-parameter] - string): - ~nil [before-call] - void {} - - public shemp( - a: - ~nil [before-parameter] - number, - b: - ~nil [before-parameter] - number - ): - ~nil [before-call] - void {} -} - -let foo = ():void => {}; - ~nil [before-call] -let foo = () : void => {}; -let foo = () : void => {}; - ~~ [before-call] - -// endregion - -[_base]: expected onespace %s colon in %s -[before-call]: _base % ('before', 'call-signature') -[before-parameter]: _base % ('before', 'parameter') -[before-index]: _base % ('before', 'index-signature') -[before-variable]: _base % ('before', 'variable-declaration') -[before-property]: _base % ('before', 'property-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/left/onespace/tslint.json b/test/rules/typedef-whitespace/left/onespace/tslint.json deleted file mode 100644 index aff33c3aa84..00000000000 --- a/test/rules/typedef-whitespace/left/onespace/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "typedef-whitespace": [true, { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - }] - } -} diff --git a/test/rules/typedef-whitespace/left/space/test.ts.lint b/test/rules/typedef-whitespace/left/space/test.ts.lint deleted file mode 100644 index b28c78ae7de..00000000000 --- a/test/rules/typedef-whitespace/left/space/test.ts.lint +++ /dev/null @@ -1,689 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - ~nil [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~nil [before-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - ~nil [before-call] - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; - ~nil [before-property] -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; - ~nil [before-property] -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~nil [before-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - ~nil [before-property] - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c:number = a + b; - ~nil [before-variable] - var d:number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~nil [before-parameter] - ~nil [before-parameter] - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - ~nil [before-parameter] - number, b: - ~nil [before-parameter] - number): - ~nil [before-call] - number { - var c: - ~nil [before-variable] - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - ~nil [before-variable] - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - ~nil [before-parameter] - b:number - ~nil [before-parameter] -):number { - ~nil [before-call] - var c:number = a + b; - ~nil [before-variable] - var d:number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] -): number { - ~nil [before-call] - var c: number = a + b; - ~nil [before-variable] - var d: number = a - b; - ~nil [before-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~nil [before-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - ~nil [before-call] - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - ~nil [before-call] - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~nil [before-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - ~nil [before-call] - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - ~nil [before-parameter] - ~nil [before-index] - - Prop:string = "some property"; - ~nil [before-property] - - public get name():string { - ~nil [before-call] - return "some name"; - } - - public set name(a:string):void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a:number, - ~nil [before-parameter] - b:number - ~nil [before-parameter] - ):void {} - ~nil [before-call] -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~nil [before-parameter] - ~nil [before-index] - - Prop: string = "some property"; - ~nil [before-property] - - public get name(): string { - ~nil [before-call] - return "some name"; - } - - public set name(a: string): void {} - ~nil [before-parameter] - ~nil [before-call] - - public shemp( - a: number, - ~nil [before-parameter] - b: number - ~nil [before-parameter] - ): void {} - ~nil [before-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - ~nil [before-parameter] - ~nil [before-index] - string - - Prop: - ~nil [before-property] - string = "some property"; - - public get name(): - ~nil [before-call] - string { - return "some name"; - } - - public set name(a: - ~nil [before-parameter] - string): - ~nil [before-call] - void {} - - public shemp( - a: - ~nil [before-parameter] - number, - b: - ~nil [before-parameter] - number - ): - ~nil [before-call] - void {} -} - -let foo = ():void => {}; - ~nil [before-call] -let foo = () : void => {}; -let foo = () : void => {}; - -// endregion - -[_base]: expected space %s colon in %s -[before-call]: _base % ('before', 'call-signature') -[before-parameter]: _base % ('before', 'parameter') -[before-index]: _base % ('before', 'index-signature') -[before-variable]: _base % ('before', 'variable-declaration') -[before-property]: _base % ('before', 'property-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/left/space/tslint.json b/test/rules/typedef-whitespace/left/space/tslint.json deleted file mode 100644 index b4da3d889fa..00000000000 --- a/test/rules/typedef-whitespace/left/space/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rules": { - "typedef-whitespace": [true, { - "call-signature": "space", - "index-signature": "space", - "parameter": "space", - "property-declaration": "space", - "variable-declaration": "space" - }] - } -} diff --git a/test/rules/typedef-whitespace/none/test.ts.lint b/test/rules/typedef-whitespace/none/test.ts.lint deleted file mode 100644 index 3815729540f..00000000000 --- a/test/rules/typedef-whitespace/none/test.ts.lint +++ /dev/null @@ -1,527 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - b:number -):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - - Prop:string = "some property"; - - public get name():string { - return "some name"; - } - - public set name(a:string):void {} - - public shemp( - a:number, - b:number - ):void {} -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -// endregion diff --git a/test/rules/typedef-whitespace/none/tslint.json b/test/rules/typedef-whitespace/none/tslint.json deleted file mode 100644 index 09c46892473..00000000000 --- a/test/rules/typedef-whitespace/none/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "typedef-whitespace": true - } -} diff --git a/test/rules/typedef-whitespace/right/nospace/test.ts.lint b/test/rules/typedef-whitespace/right/nospace/test.ts.lint deleted file mode 100644 index 736a420e3c6..00000000000 --- a/test/rules/typedef-whitespace/right/nospace/test.ts.lint +++ /dev/null @@ -1,745 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - ~ [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - ~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~~ [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; - ~ [after-property] -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~~~ [after-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; - ~ [after-property] -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; - ~~~ [after-property] -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; - ~ [after-property] -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; - ~~~ [after-property] -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - ~ [after-parameter] - ~ [after-parameter] - ~ [after-call] - var c: number = a + b; - ~ [after-variable] - var d: number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~~~ [after-parameter] - ~~~ [after-parameter] - ~~~ [after-call] - var c: number = a + b; - ~~~ [after-variable] - var d: number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - ~ [after-parameter] - ~ [after-parameter] - ~ [after-call] - var c : number = a + b; - ~ [after-variable] - var d : number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - ~~~ [after-parameter] - ~~~ [after-parameter] - ~~~ [after-call] - var c : number = a + b; - ~~~ [after-variable] - var d : number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - ~ [after-parameter] - ~ [after-parameter] - ~ [after-call] - var c : number = a + b; - ~ [after-variable] - var d : number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - ~~~ [after-parameter] - ~~~ [after-parameter] - ~~~ [after-call] - var c : number = a + b; - ~~~ [after-variable] - var d : number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - number, b: - number): - number { - var c: - number = a + b; - var d - : number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex: - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - b:number -):number { - var c:number = a + b; - var d:number = a - b; - - try { - return c / d; - } catch (ex:Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - ~ [after-parameter] - b: number - ~ [after-parameter] -): number { - ~ [after-call] - var c: number = a + b; - ~ [after-variable] - var d: number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~~~ [after-parameter] - b: number - ~~~ [after-parameter] -): number { - ~~~ [after-call] - var c: number = a + b; - ~~~ [after-variable] - var d: number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - ~ [after-parameter] - b : number - ~ [after-parameter] -) : number { - ~ [after-call] - var c : number = a + b; - ~ [after-variable] - var d : number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - ~~~ [after-parameter] - b : number - ~~~ [after-parameter] -) : number { - ~~~ [after-call] - var c : number = a + b; - ~~~ [after-variable] - var d : number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - b :number -) :number { - var c :number = a + b; - var d :number = a - b; - - try { - return c / d; - } catch (ex :Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - ~ [after-parameter] - b : number - ~ [after-parameter] -) : number { - ~ [after-call] - var c : number = a + b; - ~ [after-variable] - var d : number = a - b; - ~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - ~~~ [after-parameter] - b : number - ~~~ [after-parameter] -) : number { - ~~~ [after-call] - var c : number = a + b; - ~~~ [after-variable] - var d : number = a - b; - ~~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~~ [after-variable] - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - ~ [after-call] - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~~~ [after-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - ~ [after-call] - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - ~~~ [after-call] - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - ~ [after-call] - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - ~~~ [after-call] - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - - Prop:string = "some property"; - - public get name():string { - return "some name"; - } - - public set name(a:string):void {} - - public shemp( - a:number, - b:number - ):void {} -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - ~ [after-parameter] - ~ [after-index] - - Prop: string = "some property"; - ~ [after-property] - - public get name(): string { - ~ [after-call] - return "some name"; - } - - public set name(a: string): void {} - ~ [after-parameter] - ~ [after-call] - - public shemp( - a: number, - ~ [after-parameter] - b: number - ~ [after-parameter] - ): void {} - ~ [after-call] -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~~~ [after-parameter] - ~~~ [after-index] - - Prop: string = "some property"; - ~~~ [after-property] - - public get name(): string { - ~~~ [after-call] - return "some name"; - } - - public set name(a: string): void {} - ~~~ [after-parameter] - ~~~ [after-call] - - public shemp( - a: number, - ~~~ [after-parameter] - b: number - ~~~ [after-parameter] - ): void {} - ~~~ [after-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - ~ [after-parameter] - ~ [after-index] - - Prop : string = "some property"; - ~ [after-property] - - public get name() : string { - ~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~ [after-parameter] - ~ [after-call] - - public shemp( - a : number, - ~ [after-parameter] - b : number - ~ [after-parameter] - ) : void {} - ~ [after-call] -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - ~~~ [after-parameter] - ~~~ [after-index] - - Prop : string = "some property"; - ~~~ [after-property] - - public get name() : string { - ~~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~~ [after-parameter] - ~~~ [after-call] - - public shemp( - a : number, - ~~~ [after-parameter] - b : number - ~~~ [after-parameter] - ) : void {} - ~~~ [after-call] -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - - Prop :string = "some property"; - - public get name() :string { - return "some name"; - } - - public set name(a :string) :void {} - - public shemp( - a :number, - b :number - ) :void {} -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - ~ [after-parameter] - ~ [after-index] - - Prop : string = "some property"; - ~ [after-property] - - public get name() : string { - ~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~ [after-parameter] - ~ [after-call] - - public shemp( - a : number, - ~ [after-parameter] - b : number - ~ [after-parameter] - ) : void {} - ~ [after-call] -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - ~~~ [after-parameter] - ~~~ [after-index] - - Prop : string = "some property"; - ~~~ [after-property] - - public get name() : string { - ~~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~~ [after-parameter] - ~~~ [after-call] - - public shemp( - a : number, - ~~~ [after-parameter] - b : number - ~~~ [after-parameter] - ) : void {} - ~~~ [after-call] -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - string - - Prop: - string = "some property"; - - public get name(): - string { - return "some name"; - } - - public set name(a: - string): - void {} - - public shemp( - a: - number, - b: - number - ): - void {} -} - -let foo = ():void => {}; -let foo = () : void => {}; - ~ [after-call] -let foo = () : void => {}; - ~~~ [after-call] - -// endregion - -[_base]: expected nospace %s colon in %s -[after-call]: _base % ('after', 'call-signature') -[after-parameter]: _base % ('after', 'parameter') -[after-index]: _base % ('after', 'index-signature') -[after-variable]: _base % ('after', 'variable-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/right/nospace/tslint.json b/test/rules/typedef-whitespace/right/nospace/tslint.json deleted file mode 100644 index 779f842dcc4..00000000000 --- a/test/rules/typedef-whitespace/right/nospace/tslint.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true, - "typedef-whitespace": [true, {}, { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }] - } -} diff --git a/test/rules/typedef-whitespace/right/onespace/test.ts.lint b/test/rules/typedef-whitespace/right/onespace/test.ts.lint deleted file mode 100644 index 69d3d585fa9..00000000000 --- a/test/rules/typedef-whitespace/right/onespace/test.ts.lint +++ /dev/null @@ -1,745 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - ~nil [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - ~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - ~~ [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; - ~nil [after-property] -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; - ~~ [after-property] -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; - ~~ [after-property] -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; - ~~ [after-property] -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c:number = a + b; - ~nil [after-variable] - var d:number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - ~~ [after-parameter] - ~~ [after-parameter] - ~~ [after-call] - var c: number = a + b; - ~~ [after-variable] - var d: number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - ~~ [after-parameter] - ~~ [after-parameter] - ~~ [after-call] - var c : number = a + b; - ~~ [after-variable] - var d : number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - ~~ [after-parameter] - ~~ [after-parameter] - ~~ [after-call] - var c : number = a + b; - ~~ [after-variable] - var d : number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - number, b: - number): - number { - var c: - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - ~nil [after-parameter] - b:number - ~nil [after-parameter] -):number { - ~nil [after-call] - var c:number = a + b; - ~nil [after-variable] - var d:number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - ~~ [after-parameter] - b: number - ~~ [after-parameter] -): number { - ~~ [after-call] - var c: number = a + b; - ~~ [after-variable] - var d: number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex: Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - ~~ [after-parameter] - b : number - ~~ [after-parameter] -) : number { - ~~ [after-call] - var c : number = a + b; - ~~ [after-variable] - var d : number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - ~~ [after-parameter] - b : number - ~~ [after-parameter] -) : number { - ~~ [after-call] - var c : number = a + b; - ~~ [after-variable] - var d : number = a - b; - ~~ [after-variable] - - try { - return c / d; - } catch (ex : Exception) { - ~~ [after-variable] - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - ~nil [after-call] - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - ~~ [after-call] - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - ~~ [after-call] - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - ~~ [after-call] - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - ~nil [after-parameter] - ~nil [after-index] - - Prop:string = "some property"; - ~nil [after-property] - - public get name():string { - ~nil [after-call] - return "some name"; - } - - public set name(a:string):void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a:number, - ~nil [after-parameter] - b:number - ~nil [after-parameter] - ):void {} - ~nil [after-call] -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - ~~ [after-parameter] - ~~ [after-index] - - Prop: string = "some property"; - ~~ [after-property] - - public get name(): string { - ~~ [after-call] - return "some name"; - } - - public set name(a: string): void {} - ~~ [after-parameter] - ~~ [after-call] - - public shemp( - a: number, - ~~ [after-parameter] - b: number - ~~ [after-parameter] - ): void {} - ~~ [after-call] -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - ~~ [after-parameter] - ~~ [after-index] - - Prop : string = "some property"; - ~~ [after-property] - - public get name() : string { - ~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [after-parameter] - ~~ [after-call] - - public shemp( - a : number, - ~~ [after-parameter] - b : number - ~~ [after-parameter] - ) : void {} - ~~ [after-call] -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - ~~ [after-parameter] - ~~ [after-index] - - Prop : string = "some property"; - ~~ [after-property] - - public get name() : string { - ~~ [after-call] - return "some name"; - } - - public set name(a : string) : void {} - ~~ [after-parameter] - ~~ [after-call] - - public shemp( - a : number, - ~~ [after-parameter] - b : number - ~~ [after-parameter] - ) : void {} - ~~ [after-call] -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - ~nil [after-parameter] - string - - Prop: - string = "some property"; - - public get name(): - string { - return "some name"; - } - - public set name(a: - string): - void {} - - public shemp( - a: - number, - b: - number - ): - void {} -} - -let foo = ():void => {}; - ~nil [after-call] -let foo = () : void => {}; -let foo = () : void => {}; - ~~ [after-call] - -// endregion - -[_base]: expected onespace %s colon in %s -[after-call]: _base % ('after', 'call-signature') -[after-parameter]: _base % ('after', 'parameter') -[after-index]: _base % ('after', 'index-signature') -[after-variable]: _base % ('after', 'variable-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/right/onespace/tslint.json b/test/rules/typedef-whitespace/right/onespace/tslint.json deleted file mode 100644 index ec35766ca4d..00000000000 --- a/test/rules/typedef-whitespace/right/onespace/tslint.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true, - "typedef-whitespace": [true, {}, { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - }] - } -} diff --git a/test/rules/typedef-whitespace/right/space/test.ts.lint b/test/rules/typedef-whitespace/right/space/test.ts.lint deleted file mode 100644 index 86a91e08702..00000000000 --- a/test/rules/typedef-whitespace/right/space/test.ts.lint +++ /dev/null @@ -1,672 +0,0 @@ -// region ObjectLiteralWithPropertyGetter - -var noPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop():string { - ~nil [after-call] - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop(): string { - return this._Prop; - } -}; - -var withPreceedingSpaceNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpaceWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesNoSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() :string { - ~nil [after-call] - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpaceObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var withPreceedingSpacesWithSubsequentSpacesObject = { - _Prop: "some property", - - get Prop() : string { - return this._Prop; - } -}; - -var noPreceedingSpaceWithSubsequentNewLineObject = { - _Prop: - "some property", - - get Prop(): - string { - return this._Prop; - } -}; - -// endregion - -// region Interface - -interface NoPreceedingSpaceNoSubsequentSpaceInterface { - Prop:string; - ~nil [after-property] -} - -interface NoPreceedingSpaceWithSubsequentSpaceInterface { - Prop: string; -} - -interface NoPreceedingSpaceWithSubsequentSpacesInterface { - Prop: string; -} - -interface WithPreceedingSpaceNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpaceWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpaceWithSubsequentSpacesInterface { - Prop : string; -} - -interface WithPreceedingSpacesNoSubsequentSpaceInterface { - Prop :string; - ~nil [after-property] -} - -interface WithPreceedingSpacesWithSubsequentSpaceInterface { - Prop : string; -} - -interface WithPreceedingSpacesWithSubsequentSpacesInterface { - Prop : string; -} - -interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { - Prop: - string; -} - -// endregion - -// region Function - -function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c:number = a + b; - ~nil [after-variable] - var d:number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { - ~nil [after-parameter] - ~nil [after-parameter] - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: - number, b: - number): - number { - var c: - number = a + b; - var d - : number = a - b; - - try { - return c / d; - } catch (ex: - Exception) { - console.log(ex); - } -} - -// endregion - -// region Function multi-line signature - -function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a:number, - ~nil [after-parameter] - b:number - ~nil [after-parameter] -):number { - ~nil [after-call] - var c:number = a + b; - ~nil [after-variable] - var d:number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex:Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a: number, - b: number -): number { - var c: number = a + b; - var d: number = a - b; - - try { - return c / d; - } catch (ex: Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] -) :number { - ~nil [after-call] - var c :number = a + b; - ~nil [after-variable] - var d :number = a - b; - ~nil [after-variable] - - try { - return c / d; - } catch (ex :Exception) { - ~nil [after-variable] - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( - a : number, - b : number -) : number { - var c : number = a + b; - var d : number = a - b; - - try { - return c / d; - } catch (ex : Exception) { - console.log(ex); - } -} - -// endregion - -// region CallSignaturePaddedParams - -function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; - ~nil [after-call] - -function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; - -function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; - -function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; - -function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; - ~nil [after-call] - -function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; - -function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; - -function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): - {}; - -// endregion - -// region Class - -class NoPreceedingSpaceNoSubsequentSpaceClass { - [index:number]:string - ~nil [after-parameter] - ~nil [after-index] - - Prop:string = "some property"; - ~nil [after-property] - - public get name():string { - ~nil [after-call] - return "some name"; - } - - public set name(a:string):void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a:number, - ~nil [after-parameter] - b:number - ~nil [after-parameter] - ):void {} - ~nil [after-call] -} - -class NoPreceedingSpaceWithSubsequentSpaceClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class NoPreceedingSpaceWithSubsequentSpacesClass { - [index: number]: string - - Prop: string = "some property"; - - public get name(): string { - return "some name"; - } - - public set name(a: string): void {} - - public shemp( - a: number, - b: number - ): void {} -} - -class WithPreceedingSpaceNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpaceWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpaceWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesNoSubsequentSpaceClass { - [index :number] :string - ~nil [after-parameter] - ~nil [after-index] - - Prop :string = "some property"; - ~nil [after-property] - - public get name() :string { - ~nil [after-call] - return "some name"; - } - - public set name(a :string) :void {} - ~nil [after-parameter] - ~nil [after-call] - - public shemp( - a :number, - ~nil [after-parameter] - b :number - ~nil [after-parameter] - ) :void {} - ~nil [after-call] -} - -class WithPreceedingSpacesWithSubsequentSpaceClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class WithPreceedingSpacesWithSubsequentSpacesClass { - [index : number] : string - - Prop : string = "some property"; - - public get name() : string { - return "some name"; - } - - public set name(a : string) : void {} - - public shemp( - a : number, - b : number - ) : void {} -} - -class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { - [index:number]: - ~nil [after-parameter] - string - - Prop: - string = "some property"; - - public get name(): - string { - return "some name"; - } - - public set name(a: - string): - void {} - - public shemp( - a: - number, - b: - number - ): - void {} -} - -let foo = ():void => {}; - ~nil [after-call] -let foo = () : void => {}; -let foo = () : void => {}; - -// endregion - -[_base]: expected space %s colon in %s -[after-call]: _base % ('after', 'call-signature') -[after-parameter]: _base % ('after', 'parameter') -[after-index]: _base % ('after', 'index-signature') -[after-variable]: _base % ('after', 'variable-declaration') -[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/right/space/tslint.json b/test/rules/typedef-whitespace/right/space/tslint.json deleted file mode 100644 index 2a839372c24..00000000000 --- a/test/rules/typedef-whitespace/right/space/tslint.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "rules": { - "no-trailing-whitespace": true, - "typedef-whitespace": [true, {}, { - "call-signature": "space", - "index-signature": "space", - "parameter": "space", - "property-declaration": "space", - "variable-declaration": "space" - }] - } -} diff --git a/test/rules/typedef/all/test.ts.lint b/test/rules/typedef/all/test.ts.lint deleted file mode 100644 index 60256bce0f7..00000000000 --- a/test/rules/typedef/all/test.ts.lint +++ /dev/null @@ -1,107 +0,0 @@ -// should not error with missing exception type -try { -} catch (e) { -} - -var NoTypeObjectLiteralWithPropertyGetter = { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [expected variable-declaration: 'NoTypeObjectLiteralWithPropertyGetter' to have a typedef] - Prop: "some property", - - get PropDef() { - ~~~~~~~ [expected call-signature: 'PropDef' to have a typedef] - return this.Prop; - }, - - methodDef() { - ~~~~~~~~~ [expected call-signature: 'methodDef' to have a typedef] - return 'untyped'; - }, - - anotherMethodDef: function() { - ~~ [expected call-signature to have a typedef] - return 'also untyped'; - }, - - arrowMethodDef: () => { - ~~ [expected arrow-call-signature to have a typedef] - return 'also untyped'; - } -}; - -interface NoTypeInterface { - Prop; - ~~~~ [expected property-declaration: 'Prop' to have a typedef] - PropWithType: string; -} - -var NoTypesFn = function (a, b) { - ~~~~~~~~~ [expected variable-declaration: 'NoTypesFn' to have a typedef] - ~ [expected parameter: 'a' to have a typedef] - ~ [expected parameter: 'b' to have a typedef] - ~~~~~~ [expected call-signature to have a typedef] - var c = a + b, - ~ [expected variable-declaration: 'c' to have a typedef] - d = a - b; - ~ [expected variable-declaration: 'd' to have a typedef] - -class TsLint { - helloWorld() { - ~~~~~~~~~~ [expected call-signature: 'helloWorld' to have a typedef] - return 'Hello World'; - }; - - regularMemberWithType: string = this.getValue(); - - regularMemberWithoutType = this.getValue(); - ~~~~~~~~~~~~~~~~~~~~~~~~ [expected member-variable-declaration: 'regularMemberWithoutType' to have a typedef] - - arrowHelloWorld = () => { - ~~ [expected arrow-call-signature to have a typedef] - return this.helloWorld(); - }; - - arrowHelloWorldWithArgsNoTypedef = (arg1) => { - ~~~~ [expected member-variable-declaration: 'arg1' to have a typedef] - ~~~~~~ [expected arrow-call-signature to have a typedef] - return this.helloWorld(); - }; - - arrowHelloWorldWithArgsTypedefProperty: (arg1: string) => string = (arg1) => { - return this.helloWorld(); - }; - - arrowHelloWorldWithArgsTypedefInline = (arg1: string): string => { - return this.helloWorld(); - }; -} - -setTimeout(() => {}, 1000); - ~~ [expected arrow-call-signature to have a typedef] -setTimeout(function() {}, 1000); - ~~ [expected call-signature to have a typedef] - -someFunc(n => n+1); - ~~~ [expected arrow-call-signature to have a typedef] - ~ [expected arrow-parameter: 'n' to have a typedef] -someFunc(n => {}); - ~~~ [expected arrow-call-signature to have a typedef] - ~ [expected arrow-parameter: 'n' to have a typedef] - -class A { - // property w/o an initializer - public foo; - ~~~ [expected member-variable-declaration: 'foo' to have a typedef] - private bar: number; -} - - -const { paramA, paramB } = { paramA: "test", paramB: 15 }; - ~~~~~~~~~~~~~~~~~~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] - -const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; - -const [ paramA, paramB ] = [15, 'test']; - ~~~~~~~~~~~~~~~~~~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] - -const [ paramA3, paramB3 ]: [ number, string ] = [15, 'test']; - diff --git a/test/rules/typedef/all/tslint.json b/test/rules/typedef/all/tslint.json deleted file mode 100644 index 70ecde71823..00000000000 --- a/test/rules/typedef/all/tslint.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "rules": { - "typedef": [true, - "call-signature", - "arrow-call-signature", - "parameter", - "arrow-parameter", - "variable-declaration", - "property-declaration", - "member-variable-declaration", - "object-destructuring", - "array-destructuring" - ] - } -} diff --git a/test/rules/typedef/array-destructuring/test.ts.lint b/test/rules/typedef/array-destructuring/test.ts.lint deleted file mode 100644 index 2781fce8f6a..00000000000 --- a/test/rules/typedef/array-destructuring/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -const [ paramA, paramB ] = [15, 'test']; - ~~~~~~~~~~~~~~~~~~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] - -const [ paramA3, paramB3 ]: { number: string, paramB1: string } = [15, 'test']; diff --git a/test/rules/typedef/array-destructuring/tslint.json b/test/rules/typedef/array-destructuring/tslint.json deleted file mode 100644 index fcc56d55361..00000000000 --- a/test/rules/typedef/array-destructuring/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "array-destructuring" - ] - } -} diff --git a/test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint b/test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint deleted file mode 100644 index b2ebdc7a502..00000000000 --- a/test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint +++ /dev/null @@ -1,12 +0,0 @@ -class AComponent { - private _test(): void { - this._foo.test({ - callback: () => { - // asd - }, - }); - } -} - -function foo(bar: any) :void {} -foo({bar: ()=>{}}); \ No newline at end of file diff --git a/test/rules/typedef/arrow-call-signature-and-parameter/tslint.json b/test/rules/typedef/arrow-call-signature-and-parameter/tslint.json deleted file mode 100644 index fd636ff1fa4..00000000000 --- a/test/rules/typedef/arrow-call-signature-and-parameter/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "typedef": [true, - "parameter", - "call-signature" - ] - } -} diff --git a/test/rules/typedef/arrow-call-signature/test.ts.lint b/test/rules/typedef/arrow-call-signature/test.ts.lint deleted file mode 100644 index 37ca4446442..00000000000 --- a/test/rules/typedef/arrow-call-signature/test.ts.lint +++ /dev/null @@ -1,30 +0,0 @@ -function foge() {} - -class TsLint { - helloWorld() { - return 'Hello World'; - }; - - arrowHelloWorld = () => { - ~~ [expected arrow-call-signature to have a typedef] - return this.helloWorld(); - }; -} - -var obj = { - foge: function() {}, - bar: () => {} - ~~ [expected arrow-call-signature to have a typedef] -} - -setTimeout(() => {}, 1000); - ~~ [expected arrow-call-signature to have a typedef] -setTimeout(function() {}, 1000); - -const foo = n => n+1 - ~~~~ [expected arrow-call-signature to have a typedef] - -someFunc(n => n+1); - ~~~ [expected arrow-call-signature to have a typedef] -someFunc(n => {}); - ~~~ [expected arrow-call-signature to have a typedef] diff --git a/test/rules/typedef/arrow-call-signature/tslint.json b/test/rules/typedef/arrow-call-signature/tslint.json deleted file mode 100644 index fe8057f1088..00000000000 --- a/test/rules/typedef/arrow-call-signature/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "arrow-call-signature" - ] - } -} diff --git a/test/rules/typedef/arrow-parameter/test.ts.lint b/test/rules/typedef/arrow-parameter/test.ts.lint deleted file mode 100644 index 1a8a2180dc1..00000000000 --- a/test/rules/typedef/arrow-parameter/test.ts.lint +++ /dev/null @@ -1,13 +0,0 @@ -var NoTypesFn = function (a, b) {} - -var NoTypesArrowFn = (a, b) => {} - ~ [expected arrow-parameter: 'a' to have a typedef] - ~ [expected arrow-parameter: 'b' to have a typedef] - -someFunc(n => n+1); - ~ [expected arrow-parameter: 'n' to have a typedef] -someFunc((n) => n+1); - ~ [expected arrow-parameter: 'n' to have a typedef] -someFunc((n,m) => n+m); - ~ [expected arrow-parameter: 'n' to have a typedef] - ~ [expected arrow-parameter: 'm' to have a typedef] diff --git a/test/rules/typedef/arrow-parameter/tslint.json b/test/rules/typedef/arrow-parameter/tslint.json deleted file mode 100644 index fe7a8c4e913..00000000000 --- a/test/rules/typedef/arrow-parameter/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "arrow-parameter" - ] - } -} diff --git a/test/rules/typedef/call-signature/test.ts.lint b/test/rules/typedef/call-signature/test.ts.lint deleted file mode 100644 index fe695835056..00000000000 --- a/test/rules/typedef/call-signature/test.ts.lint +++ /dev/null @@ -1,39 +0,0 @@ -function foge() {} - ~~~~ [expected call-signature: 'foge' to have a typedef] - -class TsLint { - helloWorld() { - ~~~~~~~~~~ [expected call-signature: 'helloWorld' to have a typedef] - return 'Hello World'; - }; - - arrowHelloWorld = () => { - return this.helloWorld(); - }; -} - -var obj = { - foge: function() {}, - ~~ [expected call-signature to have a typedef] - bar: () => {} -} - -setTimeout(() => {}, 1000); -setTimeout(function() {}, 1000); - ~~ [expected call-signature to have a typedef] - -someFunc(n => n+1); -someFunc(n => {}); - -class AComponent { - private _test(): void { - this._foo.test({ - callback: () => { - // asd - }, - }); - } -} - -function foo(bar: any) :void {} -foo({bar: ()=>{}}); diff --git a/test/rules/typedef/call-signature/tslint.json b/test/rules/typedef/call-signature/tslint.json deleted file mode 100644 index 067259a15fe..00000000000 --- a/test/rules/typedef/call-signature/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "call-signature" - ] - } -} diff --git a/test/rules/typedef/member-variable-declaration/test.ts.lint b/test/rules/typedef/member-variable-declaration/test.ts.lint deleted file mode 100644 index a437c7b7d58..00000000000 --- a/test/rules/typedef/member-variable-declaration/test.ts.lint +++ /dev/null @@ -1,16 +0,0 @@ -class TypesMemberArrowFn { - fn: (param: string) => void = (param) => {} -} - -class TypesInFunctionMemberArrowFn { - fn = (param: string) => {} -} - -class TypesInFunctionWithReturnMemberArrowFn { - fn = (param: string): void => {} -} - -class NoTypesMemberArrowFn { - fn = (param) => {} - ~~~~~ [expected member-variable-declaration: 'param' to have a typedef] -} diff --git a/test/rules/typedef/member-variable-declaration/tslint.json b/test/rules/typedef/member-variable-declaration/tslint.json deleted file mode 100644 index d6bef7c0dbe..00000000000 --- a/test/rules/typedef/member-variable-declaration/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "member-variable-declaration" - ] - } -} diff --git a/test/rules/typedef/none/test.ts.lint b/test/rules/typedef/none/test.ts.lint deleted file mode 100644 index 3af21a467cb..00000000000 --- a/test/rules/typedef/none/test.ts.lint +++ /dev/null @@ -1,87 +0,0 @@ -var NoTypeObjectLiteralWithPropertyGetter = { - Prop: "some property", - - get PropDef() { - return this.Prop; - }, - - methodDef() { - return 'untyped'; - }, - - anotherMethodDef: function() { - return 'also untyped'; - }, - - arrowMethodDef: () => { - return 'also untyped'; - } -}; - -interface NoTypeInterface { - Prop; - PropWithType: string; -} - -var NoTypesFn = function ( - a, - b) { - var c = a + b, - d = a - b; -}; - -class NoTypesClass { - [index: number]: number; - - Member = "some property"; - - public get name() { - return "some name"; - } - - private unTyped() { - return null; - } -} - -class ConstructorUnTyped { - constructor(type) { - - } -} - -function anotherNoTypesFn(a, b) { - return b; -} - -function forInFn(): void { - for (var p in []) {} -} - -function spreadFunction(...n) : number { - return ns[0]; -} - -class NoReturnTypeForSetAccessor { - set name(value: string) { - } -} - -try { - return 123; -} catch (e) { // should not be a failure; catch clause can't have typedef - console.log(e); -} - -// should not fail, typedefs not allowed in for-of loops -for (let i of [1, 2, 3]) { - -} - -const [ paramA, paramB ] = [ 'test', 15 ]; - -const { paramA, paramB } = { paramA: "test", paramB: 15 }; - -const [ paramA3, paramB3 ]: [ number, string ] = [15, 'test']; - -const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; diff --git a/test/rules/typedef/none/tslint.json b/test/rules/typedef/none/tslint.json deleted file mode 100644 index 08b740b4692..00000000000 --- a/test/rules/typedef/none/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "typedef": true - } -} diff --git a/test/rules/typedef/object-destructuring/test.ts.lint b/test/rules/typedef/object-destructuring/test.ts.lint deleted file mode 100644 index 8f222db7f6d..00000000000 --- a/test/rules/typedef/object-destructuring/test.ts.lint +++ /dev/null @@ -1,4 +0,0 @@ -const { paramA, paramB } = { paramA: "test", paramB: 15 }; - ~~~~~~~~~~~~~~~~~~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] - -const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; diff --git a/test/rules/typedef/object-destructuring/tslint.json b/test/rules/typedef/object-destructuring/tslint.json deleted file mode 100644 index fec26c5acc2..00000000000 --- a/test/rules/typedef/object-destructuring/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "object-destructuring" - ] - } -} diff --git a/test/rules/typedef/parameter/test.ts.lint b/test/rules/typedef/parameter/test.ts.lint deleted file mode 100644 index 309c04fcc93..00000000000 --- a/test/rules/typedef/parameter/test.ts.lint +++ /dev/null @@ -1,19 +0,0 @@ -var NoTypesFn = function (a, b) { - ~ [expected parameter: 'a' to have a typedef] - ~ [expected parameter: 'b' to have a typedef] -} - -var NoTypesArrowFn = (a, b) => {} - -class AComponent { - private _test(): void { - this._foo.test({ - callback: () => { - // asd - }, - }); - } -} - -function foo(bar: any) :void {} -foo({bar: ()=>{}}); diff --git a/test/rules/typedef/parameter/tslint.json b/test/rules/typedef/parameter/tslint.json deleted file mode 100644 index 11d12816d90..00000000000 --- a/test/rules/typedef/parameter/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "parameter" - ] - } -} diff --git a/test/rules/typedef/variable-declaration-ignore-function/test.ts.lint b/test/rules/typedef/variable-declaration-ignore-function/test.ts.lint deleted file mode 100644 index d9f013a93a0..00000000000 --- a/test/rules/typedef/variable-declaration-ignore-function/test.ts.lint +++ /dev/null @@ -1,23 +0,0 @@ -var foo = function(): void {}; -let foo = function(): void {}; -const foo = function(): void {}; - -var foo = (): void => {}; -let foo = (): void => {}; -const foo = (): void => {}; - -class Foo { - foo = (): void => {}; - foo = function(): void {}; -} - -const foo: () => void = (): void => {}; -const foo: () => void = function(): void {}; - -var noTypeDef = 'Should still fail'; - ~~~~~~~~~ [expected variable-declaration: 'noTypeDef' to have a typedef] - -class NoTypeDef { - public noTypeDef = 'Should still fail'; - ~~~~~~~~~ [expected member-variable-declaration: 'noTypeDef' to have a typedef] -} diff --git a/test/rules/typedef/variable-declaration-ignore-function/tslint.json b/test/rules/typedef/variable-declaration-ignore-function/tslint.json deleted file mode 100644 index f815790c07b..00000000000 --- a/test/rules/typedef/variable-declaration-ignore-function/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "typedef": [ - true, - "variable-declaration", - "member-variable-declaration", - "variable-declaration-ignore-function" - ] - } -} diff --git a/test/rules/typedef/variable-declaration/test.ts.lint b/test/rules/typedef/variable-declaration/test.ts.lint deleted file mode 100644 index 0547e0b2013..00000000000 --- a/test/rules/typedef/variable-declaration/test.ts.lint +++ /dev/null @@ -1,5 +0,0 @@ -var v = { } - ~ [expected variable-declaration: 'v' to have a typedef] - -const { paramA, paramB } = { paramA: "test", paramB: 15 }; -const [ paramA, paramB ] = [15, 'test']; diff --git a/test/rules/typedef/variable-declaration/tslint.json b/test/rules/typedef/variable-declaration/tslint.json deleted file mode 100644 index 15593c2829e..00000000000 --- a/test/rules/typedef/variable-declaration/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "rules": { - "typedef": [true, - "variable-declaration" - ] - } -} diff --git a/test/rules/typeof-compare/test.ts.lint b/test/rules/typeof-compare/test.ts.lint deleted file mode 100644 index 788f0ea6c0a..00000000000 --- a/test/rules/typeof-compare/test.ts.lint +++ /dev/null @@ -1,109 +0,0 @@ -var testVariable = 123; - -function testFunction() { - if (typeof x === 'null') { - ~~~~~~~~~~~~~~~~~~~ [0] - console.log("called"); - } - const x = typeof foo === 'undefied' - ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -console.log(typeof window == 'object ') - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] - -const string = "string"; -typeof bar === string -typeof bar === `${string}`; -typeof bar === `${"s"}tring`; - -var num = 123; -typeof num !== "number"; -typeof num !== "object"; -typeof num !== "string"; -typeof num !== "boolean"; -typeof num !== "function"; -typeof num !== "symbol"; -typeof num !== "undefined"; - -"number" !== typeof num; -"object" !== typeof num; -"string" !== typeof num; -"boolean" !== typeof num; -"function" !== typeof num; -"symbol" !== typeof num; -"undefined" !== typeof num; - -typeof num === "number"; -typeof num === "object"; -typeof num === "string"; -typeof num === "boolean"; -typeof num === "function"; -typeof num === "symbol"; -typeof num === "undefined"; - -"number" === typeof num; -"object" === typeof num; -"string" === typeof num; -"boolean" === typeof num; -"function" === typeof num; -"symbol" === typeof num; -"undefined" === typeof num; - -typeof num == "number"; -typeof num == "object"; -typeof num == "string"; -typeof num == "boolean"; -typeof num == "function"; -typeof num == "symbol"; -typeof num == "undefined"; - -"number" == typeof num; -"object" == typeof num; -"string" == typeof num; -"boolean" == typeof num; -"function" == typeof num; -"symbol" == typeof num; -"undefined" == typeof num; - -typeof num != "number"; -typeof num != "object"; -typeof num != "string"; -typeof num != "boolean"; -typeof num != "function"; -typeof num != "symbol"; -typeof num != "undefined"; - -"number" == typeof num; -"object" == typeof num; -"string" == typeof num; -"boolean" == typeof num; -"function" == typeof num; -"symbol" == typeof num; -"undefined" == typeof num; -"frizzle" == typeof num; -~~~~~~~~~~~~~~~~~~~~~~~ [0] - -typeof bar === 123 -~~~~~~~~~~~~~~~~~~ [0] -typeof bar === undefined -~~~~~~~~~~~~~~~~~~~~~~~~ [0] -typeof bar === null -~~~~~~~~~~~~~~~~~~~ [0] -typeof bar === true -~~~~~~~~~~~~~~~~~~~ [0] -typeof bar === false -~~~~~~~~~~~~~~~~~~~~ [0] - -123 === typeof bar -~~~~~~~~~~~~~~~~~~ [0] -undefined === typeof bar -~~~~~~~~~~~~~~~~~~~~~~~~ [0] -null === typeof bar -~~~~~~~~~~~~~~~~~~~ [0] -true === typeof bar -~~~~~~~~~~~~~~~~~~~ [0] -false === typeof bar -~~~~~~~~~~~~~~~~~~~~ [0] - -[0]: 'typeof' expression must be compared to one of: "undefined", "string", "boolean", "number", "function", "object", "symbol" diff --git a/test/rules/typeof-compare/tslint.json b/test/rules/typeof-compare/tslint.json deleted file mode 100644 index 39fd5bded31..00000000000 --- a/test/rules/typeof-compare/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "typeof-compare": true - } -} diff --git a/test/rules/unified-signatures/test.d.ts.lint b/test/rules/unified-signatures/test.d.ts.lint deleted file mode 100644 index ed4b0268b9f..00000000000 --- a/test/rules/unified-signatures/test.d.ts.lint +++ /dev/null @@ -1,99 +0,0 @@ -interface I { - // For 3 or more overloads, mentions the line. - a0(): void; - a0(x: string): string; - a0(x: number): void; - ~~~~~~~~~ [This overload and the one on line 3 can be combined into one signature with an optional parameter.] - - // Error for extra parameter. - a1(): void; - a1(x: number): void; - ~~~~~~~~~ [0] - - // No error for arity difference greater than 1. - a2(): void; - a2(x: number, y: number): void; - - // Error for arity difference greater than 1 if the additional parameters are all optional/rest. - a3(): void; - a3(x: number, y?: number, ...z: number[]): void; - ~~~~~~~~~~~~~~ [These overloads can be combined into one signature with a rest parameter.] - - // No error for different return types. - a4(): void; - a4(x: number): number; - - // No error if one takes a type parameter and the other doesn't. - a5(x: T): T; - a5(x: number): number; - - // Error if only one defines a rest parameter. - b(): void; - b(...x: number[]): void; - ~~~~~~~~~~~~~~ [1] - - // No error if one is a rest parameter and other isn't. - b2(x: string): void; - b2(...x: number[]): void; - - // No error if both are rest parameters. (https://github.com/Microsoft/TypeScript/issues/5077) - b3(...x: number[]): void; - b3(...x: string[]): void; - - // Error if only one defines an optional parameter. - c(): void; - c(x?: number): void; - ~~~~~~~~~~ [0] - - // Error if both are optional. - c2(x?: number): void; - c2(x?: string): void; - ~~~~~~~~~~ [These overloads can be combined into one signature taking `number | string`.] - - // No error if one is optional and the other isn't. - c3(x: number): void; - c3(x?: string): void; - - // Error for different types (could be a union) - d(x: string): void; - d(x: number): void; - ~~~~~~~~~ [These overloads can be combined into one signature taking `string | number`.] - - // No error if they differ by 2 or more parameters. - d2(x: string, y: number): void; - d2(x: number, y: string): void; -} - -// Works for type literal too. -type T = { - // Works for call signature too. - (): void; - (x: number): void; - ~~~~~~~~~ [0] -} - -declare class C { - // Works for constructor. - constructor(); - constructor(x: number); - ~~~~~~~~~ [0] -} - -declare class D { - // No conflict between static/non-static members. - static a(); - a(x: number); -} - -// Allow separate overloads if one is generic and the other isn't. -interface Generic { - x(): void; - x(x: T[]): void; - - y(x: T[]): void; - y(x: T): void; - ~~~~ [These overloads can be combined into one signature taking `T[] | T`.] -} - -[0]: These overloads can be combined into one signature with an optional parameter. -[1]: These overloads can be combined into one signature with a rest parameter. diff --git a/test/rules/unified-signatures/test.ts.lint b/test/rules/unified-signatures/test.ts.lint deleted file mode 100644 index a6843a4328a..00000000000 --- a/test/rules/unified-signatures/test.ts.lint +++ /dev/null @@ -1,31 +0,0 @@ -// Works in non-declaration file too. -function f(x: number): void; -function f(x: string): void; - ~~~~~~~~~ [These overloads can be combined into one signature taking `number | string`.] -function f(x: any): any { - return x; -} - -// Body does *not* count as a signature. -function g(): void; -function g(a: number, b: number): void; -function g(a?: number, b?: number): void {} - -class C { - constructor(); - constructor(a: number, b: number); - constructor(a?: number, b?: number) {} - - a(): void; - a(a: number, b: number): void; - a(a?: number, b?: number): void {} -} - -function rest(...xs: number[]): void; -function rest(xs: number[], y: string): void; -function rest(...args: any[]) {} - -function opt(xs?: number[]): void; -function opt(xs: number[], y: string): void; - ~~~~~~~~~ [These overloads can be combined into one signature with an optional parameter.] -function opt(...args: any[]) {} diff --git a/test/rules/unified-signatures/tslint.json b/test/rules/unified-signatures/tslint.json deleted file mode 100644 index a9d166dc010..00000000000 --- a/test/rules/unified-signatures/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "unified-signatures": true - } -} diff --git a/test/rules/unnecessary-bind/typed/test.ts.lint b/test/rules/unnecessary-bind/typed/test.ts.lint deleted file mode 100644 index 1edebe3976f..00000000000 --- a/test/rules/unnecessary-bind/typed/test.ts.lint +++ /dev/null @@ -1,73 +0,0 @@ -const arrowLambda = () => {}; -const functionVar = function () {}; - -declare const stubDecorator: any; - -class Class { - public constructor() { } - - public bind() { } - - public method() { } - - public boundFunction = function () {}.bind(this) - ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] - - public boundAsyncFunction = (async function () {}).bind(this) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] - - @stubDecorator - public decorated = function () {}.bind(this) -} - -const instance = new Class(); - -arrowLambda.bind(this); -~~~~~~~~~~~~~~~~~~~~~~ [arrow] -arrowLambda.bind(arrowLambda); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] -arrowLambda.bind(undefined); -~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] -arrowLambda.bind(this, 1); -arrowLambda.bind(this, undefined); - -functionVar.bind(this); -functionVar.bind(functionVar); -functionVar.bind(undefined); -functionVar.bind(this, 1); -functionVar.bind(this, undefined); - -const immediatelyBoundFunction = function () {}.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionReturn = function (i: number): number { return i; }.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionWrapped = (function () {}).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionWrappedReturn = (function (i: number): number { return i; }).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionArgs = function (i: number): number {}.bind(this, 1); -const immediatelyBoundFunctionArgsReturn = function (i: number): number { return i; }.bind(this, 1); -const immediatelyBoundFunctionNameUnused = function foo() { functionVar(); }.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionNameUsed = function foo() { foo(); }.bind(this); - -const immediatelyBoundArrow = ((i: number) => i).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] -const immediatelyBoundArrowArgs = ((i: number) => i).bind(this, 1); -const immediatelyBoundArrowArgsReturn = function (i: number): number { return i; }.bind(this, 1); - -const asyncFunction = async function () {}.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const asyncFunctionReturn = async function (): number { return 1; }.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const asyncArrow = (async () => {}).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] -const asyncArrowReturn = (async (): number => { return 1; }).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] - -(function* generator() {}).bind(this); -instance.method.bind(this); -instance.bind(this); -Class.bind(this); -[arrow]: Don't bind scopes to arrow lambdas, as they already have a bound scope. -[function]: Don't bind `this` without arguments as a scope to a function. Use an arrow lambda instead. diff --git a/test/rules/unnecessary-bind/typed/tsconfig.json b/test/rules/unnecessary-bind/typed/tsconfig.json deleted file mode 100644 index 744a66c893a..00000000000 --- a/test/rules/unnecessary-bind/typed/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs" - } -} diff --git a/test/rules/unnecessary-bind/typed/tslint.json b/test/rules/unnecessary-bind/typed/tslint.json deleted file mode 100644 index 3a5cc6c8d6f..00000000000 --- a/test/rules/unnecessary-bind/typed/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "unnecessary-bind": true - } -} diff --git a/test/rules/unnecessary-bind/untyped/test.ts.lint b/test/rules/unnecessary-bind/untyped/test.ts.lint deleted file mode 100644 index 48cbdff01d4..00000000000 --- a/test/rules/unnecessary-bind/untyped/test.ts.lint +++ /dev/null @@ -1,62 +0,0 @@ -const arrowLambda = () => {}; -const functionVar = function () {}; - -class Class { - public constructor() { } - - public bind() { } - - public method() { } - - public boundFunction = function () {}.bind(this) - ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] - - public boundAsyncFunction = (async function () {}).bind(this) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -} - -const instance = new Class(); - -arrowLambda.bind(this); -arrowLambda.bind(arrowLambda); -arrowLambda.bind(undefined); -arrowLambda.bind(this, 1); -arrowLambda.bind(this, undefined); - -functionVar.bind(this); -functionVar.bind(functionVar); -functionVar.bind(undefined); -functionVar.bind(this, 1); -functionVar.bind(this, undefined); - -const immediatelyBoundFunction = function () {}.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionReturn = function (i: number): number { return i; }.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionWrapped = (function () {}).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionWrappedReturn = (function (i: number): number { return i; }).bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionArgs = function (i: number): number {}.bind(this, 1); -const immediatelyBoundFunctionArgsReturn = function (i: number): number { return i; }.bind(this, 1); -const immediatelyBoundFunctionNameUnused = function foo() { functionVar(); }.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const immediatelyBoundFunctionNameUsed = function foo() { foo(); }.bind(this); - -const immediatelyBoundArrow = ((i: number) => i).bind(this); -const immediatelyBoundArrowArgs = ((i: number) => i).bind(this, 1); -const immediatelyBoundArrowArgsReturn = function (i: number): number { return i; }.bind(this, 1); - -const asyncFunction = async function () {}.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const asyncFunctionReturn = async function (): number { return 1; }.bind(this); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] -const asyncArrow = (async () => {}).bind(this); -const asyncArrowReturn = (async (): number => { return 1; }).bind(this); - -(function* generator() {}).bind(this); -instance.method.bind(this); -instance.bind(this); -Class.bind(this); -[arrow]: Don't bind scopes to arrow lambdas, as they already have a bound scope. -[function]: Don't bind `this` without arguments as a scope to a function. Use an arrow lambda instead. diff --git a/test/rules/unnecessary-bind/untyped/tslint.json b/test/rules/unnecessary-bind/untyped/tslint.json deleted file mode 100644 index 3a5cc6c8d6f..00000000000 --- a/test/rules/unnecessary-bind/untyped/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "unnecessary-bind": true - } -} diff --git a/test/rules/unnecessary-constructor/check-super-calls/test.ts.fix b/test/rules/unnecessary-constructor/check-super-calls/test.ts.fix deleted file mode 100644 index a5c97d4ba14..00000000000 --- a/test/rules/unnecessary-constructor/check-super-calls/test.ts.fix +++ /dev/null @@ -1,147 +0,0 @@ -export class ExportedClass { -} - -class PublicConstructor { -} - -class ProtectedConstructor { - protected constructor() { } -} - -class PrivateConstructor { - private constructor() { } -} - -class SameLine { } - -class WithPrecedingMember { - public member: string; -} - -class WithFollowingMethod { - public method() {} -} - -const classExpression = class { -} - -class ContainsContents { - constructor() { - console.log("Hello!"); - } -} - -class CallsSuper extends PublicConstructor { -} - -class ContainsParameter { -} - -class PrivateContainsParameter { - private constructor(x: number) { } -} - -class ProtectedContainsParameter { - protected constructor(x: number) { } -} - -class ContainsParameterDeclaration { - constructor(public x: number) { } -} - -class ContainsParameterAndParameterDeclaration { - constructor(x: number, public y: number) { } -} - -class ConstructorOverload { -} - -interface IConstructorSignature { - new(): {}; -} - -class DecoratedParameters { - constructor(@Optional x: number) {} -} - -class X { - constructor(private param1: number, param2: number) {} -} - -export class Y extends X { - constructor(param1: number) { - super(param1, 2); - } -} - -class Base { - constructor(public param: number) {} -} - -class Super extends Base { - public param: number; - constructor(param1: number) { - super(param1); - this.param = param1; - } -} - -class Super extends Base { -} - -class Super extends Base { - constructor(param1: number, public param2: number) { - super(param1); - } -} - -class Super extends Base { -} - -class Super extends Base { - constructor(param1: number) { - super(param1 + 1); - } -} - -class Super extends Base { - constructor() { - super(1); - } -} - -class Super extends Base { - constructor(param1: number) { - super(1); - } -} - -const test = (param: number) => number; - -class Super extends Base { - constructor(param1: number) { - super(test(param1)); - } -} - -class Base2 { - constructor(public param1: number, param2: number) {} -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - super(test(param2), param1); - } -} - -class Super extends Base2 { -} - -class Super extends Base { - public param1: number; - constructor(public param2: number) { - super(param2); - this.param1 = param2; - } -} - diff --git a/test/rules/unnecessary-constructor/check-super-calls/test.ts.lint b/test/rules/unnecessary-constructor/check-super-calls/test.ts.lint deleted file mode 100644 index fe419035572..00000000000 --- a/test/rules/unnecessary-constructor/check-super-calls/test.ts.lint +++ /dev/null @@ -1,188 +0,0 @@ -export class ExportedClass { - constructor() { } - ~~~~~~~~~~~~~~~~~ [0] -} - -class PublicConstructor { - public constructor() { } - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -class ProtectedConstructor { - protected constructor() { } -} - -class PrivateConstructor { - private constructor() { } -} - -class SameLine { constructor() { } } - ~~~~~~~~~~~~~~~~~ [0] - -class WithPrecedingMember { - public member: string; - constructor() {} - ~~~~~~~~~~~~~~~~ [0] -} - -class WithFollowingMethod { - constructor() {} - ~~~~~~~~~~~~~~~~ [0] - public method() {} -} - -const classExpression = class { - constructor() { } - ~~~~~~~~~~~~~~~~~ [0] -} - -class ContainsContents { - constructor() { - console.log("Hello!"); - } -} - -class CallsSuper extends PublicConstructor { - constructor() { - ~~~~~~~~~~~~~~~ - super(); -~~~~~~~~~~~~~~~~ - } -~~~~~ [0] -} - -class ContainsParameter { - constructor(x: number) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -class PrivateContainsParameter { - private constructor(x: number) { } -} - -class ProtectedContainsParameter { - protected constructor(x: number) { } -} - -class ContainsParameterDeclaration { - constructor(public x: number) { } -} - -class ContainsParameterAndParameterDeclaration { - constructor(x: number, public y: number) { } -} - -class ConstructorOverload { - constructor(x: number); - constructor(x: number, y?: number) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -interface IConstructorSignature { - new(): {}; -} - -class DecoratedParameters { - constructor(@Optional x: number) {} -} - -class X { - constructor(private param1: number, param2: number) {} -} - -export class Y extends X { - constructor(param1: number) { - super(param1, 2); - } -} - -class Base { - constructor(public param: number) {} -} - -class Super extends Base { - public param: number; - constructor(param1: number) { - super(param1); - this.param = param1; - } -} - -class Super extends Base { - constructor(param: number) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - super(param); -~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [0] -} - -class Super extends Base { - constructor(param1: number, public param2: number) { - super(param1); - } -} - -class Super extends Base { - constructor(param1: number, param2: number) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - super(param1); -~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [0] -} - -class Super extends Base { - constructor(param1: number) { - super(param1 + 1); - } -} - -class Super extends Base { - constructor() { - super(1); - } -} - -class Super extends Base { - constructor(param1: number) { - super(1); - } -} - -const test = (param: number) => number; - -class Super extends Base { - constructor(param1: number) { - super(test(param1)); - } -} - -class Base2 { - constructor(public param1: number, param2: number) {} -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - super(test(param2), param1); - } -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - super(param2, param1); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - } -~~~~~ [0] -} - -class Super extends Base { - public param1: number; - constructor(public param2: number) { - super(param2); - this.param1 = param2; - } -} - -[0]: Remove unnecessary empty constructor. diff --git a/test/rules/unnecessary-constructor/check-super-calls/tslint.json b/test/rules/unnecessary-constructor/check-super-calls/tslint.json deleted file mode 100644 index 387e6c2b68e..00000000000 --- a/test/rules/unnecessary-constructor/check-super-calls/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "unnecessary-constructor": [ - true, - { "check-super-calls": true } - ] - } -} diff --git a/test/rules/unnecessary-constructor/default/test.ts.fix b/test/rules/unnecessary-constructor/default/test.ts.fix deleted file mode 100644 index a274aa9f2f7..00000000000 --- a/test/rules/unnecessary-constructor/default/test.ts.fix +++ /dev/null @@ -1,159 +0,0 @@ -export class ExportedClass { -} - -class PublicConstructor { -} - -class ProtectedConstructor { - protected constructor() { } -} - -class PrivateConstructor { - private constructor() { } -} - -class SameLine { } - -class WithPrecedingMember { - public member: string; -} - -class WithFollowingMethod { - public method() {} -} - -const classExpression = class { -} - -class ContainsContents { - constructor() { - console.log("Hello!"); - } -} - -class CallsSuper extends PublicConstructor { - constructor() { - super(); - } -} - -class ContainsParameter { -} - -class PrivateContainsParameter { - private constructor(x: number) { } -} - -class ProtectedContainsParameter { - protected constructor(x: number) { } -} - -class ContainsParameterDeclaration { - constructor(public x: number) { } -} - -class ContainsParameterAndParameterDeclaration { - constructor(x: number, public y: number) { } -} - -class ConstructorOverload { -} - -interface IConstructorSignature { - new(): {}; -} - -class DecoratedParameters { - constructor(@Optional x: number) {} -} - -class X { - constructor(private param1: number, param2: number) {} -} - -export class Y extends X { - constructor(param1: number) { - super(param1, 2); - } -} - -class Base { - constructor(public param: number) {} -} - -class Super extends Base { - public param: number; - constructor(param1: number) { - super(param1); - this.param = param1; - } -} - -class Super extends Base { - constructor(param: number) { - super(param); - } -} - -class Super extends Base { - constructor(param1: number, public param2: number) { - super(param1); - } -} - -class Super extends Base { - constructor(param1: number, param2: number) { - super(param1); - } -} - -class Super extends Base { - constructor(param1: number) { - super(param1 + 1); - } -} - -class Super extends Base { - constructor() { - super(1); - } -} - -class Super extends Base { - constructor(param1: number) { - super(1); - } -} - -const test = (param: number) => number; - -class Super extends Base { - constructor(param1: number) { - super(test(param1)); - } -} - -class Base2 { - constructor(public param1: number, param2: number) {} -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - super(test(param2), param1); - } -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - super(param2, param1); - } -} - -class Super extends Base { - public param1: number; - constructor(public param2: number) { - super(param2); - this.param1 = param2; - } -} - diff --git a/test/rules/unnecessary-constructor/default/test.ts.lint b/test/rules/unnecessary-constructor/default/test.ts.lint deleted file mode 100644 index 0203b8cf994..00000000000 --- a/test/rules/unnecessary-constructor/default/test.ts.lint +++ /dev/null @@ -1,176 +0,0 @@ -export class ExportedClass { - constructor() { } - ~~~~~~~~~~~~~~~~~ [0] -} - -class PublicConstructor { - public constructor() { } - ~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -class ProtectedConstructor { - protected constructor() { } -} - -class PrivateConstructor { - private constructor() { } -} - -class SameLine { constructor() { } } - ~~~~~~~~~~~~~~~~~ [0] - -class WithPrecedingMember { - public member: string; - constructor() {} - ~~~~~~~~~~~~~~~~ [0] -} - -class WithFollowingMethod { - constructor() {} - ~~~~~~~~~~~~~~~~ [0] - public method() {} -} - -const classExpression = class { - constructor() { } - ~~~~~~~~~~~~~~~~~ [0] -} - -class ContainsContents { - constructor() { - console.log("Hello!"); - } -} - -class CallsSuper extends PublicConstructor { - constructor() { - super(); - } -} - -class ContainsParameter { - constructor(x: number) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -class PrivateContainsParameter { - private constructor(x: number) { } -} - -class ProtectedContainsParameter { - protected constructor(x: number) { } -} - -class ContainsParameterDeclaration { - constructor(public x: number) { } -} - -class ContainsParameterAndParameterDeclaration { - constructor(x: number, public y: number) { } -} - -class ConstructorOverload { - constructor(x: number); - constructor(x: number, y?: number) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] -} - -interface IConstructorSignature { - new(): {}; -} - -class DecoratedParameters { - constructor(@Optional x: number) {} -} - -class X { - constructor(private param1: number, param2: number) {} -} - -export class Y extends X { - constructor(param1: number) { - super(param1, 2); - } -} - -class Base { - constructor(public param: number) {} -} - -class Super extends Base { - public param: number; - constructor(param1: number) { - super(param1); - this.param = param1; - } -} - -class Super extends Base { - constructor(param: number) { - super(param); - } -} - -class Super extends Base { - constructor(param1: number, public param2: number) { - super(param1); - } -} - -class Super extends Base { - constructor(param1: number, param2: number) { - super(param1); - } -} - -class Super extends Base { - constructor(param1: number) { - super(param1 + 1); - } -} - -class Super extends Base { - constructor() { - super(1); - } -} - -class Super extends Base { - constructor(param1: number) { - super(1); - } -} - -const test = (param: number) => number; - -class Super extends Base { - constructor(param1: number) { - super(test(param1)); - } -} - -class Base2 { - constructor(public param1: number, param2: number) {} -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - super(test(param2), param1); - } -} - -class Super extends Base2 { - constructor(param1: number, param2: number) { - super(param2, param1); - } -} - -class Super extends Base { - public param1: number; - constructor(public param2: number) { - super(param2); - this.param1 = param2; - } -} - -[0]: Remove unnecessary empty constructor. diff --git a/test/rules/unnecessary-constructor/default/tslint.json b/test/rules/unnecessary-constructor/default/tslint.json deleted file mode 100644 index 53a2dfbba1b..00000000000 --- a/test/rules/unnecessary-constructor/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "unnecessary-constructor": true - } -} diff --git a/test/rules/unnecessary-else/allow-else-if/test.ts.lint b/test/rules/unnecessary-else/allow-else-if/test.ts.lint deleted file mode 100644 index 96d1fc50ab6..00000000000 --- a/test/rules/unnecessary-else/allow-else-if/test.ts.lint +++ /dev/null @@ -1,255 +0,0 @@ -const testReturn = (a) => { - if (a===0) { - return 0; - } else { - ~~~~ [return] - return a; - } -} - -const testReturn = (a) => { - if (a===0) return 0; - else return a; - ~~~~ [return] -} - -const testReturn = (a) => { - if (a===0) - return 0; - else - ~~~~ [return] - return a; -} - -const testReturn = (a) => { - if (a>0) { - if (a%2 ===0) { - return "even" ; - } else { - ~~~~ [return] - return "odd"; - } - } - return "negative"; -} - -const testReturn = (a) => { - if (a===0) { - return 0; - } - return a; -} - -const testReturn = (a) => { - if (a<0) { - return; - } else if (a>0) { - if (a%2 === 0) { - return ; - } else if (a === 0) { - return ; - } - } - return; -} - -const testReturn = (a) => { - if (a<0) { - return; - } - if (a===1) { - return ; - } else { - ~~~~ [return] - return ; - } -} - -const testReturn = (a) => { - if (a>0) { - if (a%3===0) { - return; - } else { - ~~~~ [return] - console.log(a) - } - } - else { - console.log("negative"); - } -} - -const testThrow = (a) => { - if ( a===0 ) { - throw "error"; - } else { - ~~~~ [throw] - return 100/a; - } -} - -const testThrow = (a) => { - if (a===0) - throw "error; - else if (a < 0) - console.log(100/a); -} - -const testThrow = (a) => { - if (a===0) throw "error; - else console.log(100/a); - ~~~~ [throw] -} - -const testThrow = (a) => { - switch (a) { - case 1: - break; - case 2: - if (true) { - throw "error"; - } else { - ~~~~ [throw] - break; - } - default : - break; - } -} - -const testThrow = (a) => { - let i = 1; - do { - if (a-i === 0) { - throw "error; - } else { - ~~~~ [throw] - console.log(i/a-i); - } - ++i; - } -} - -const testThrow = (a) => { - if (a===0) { - throw "error"; - } - return 100/a; -} - -const testThrow = (a) => { - if (a===0) throw "error"; - return 100/a; -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===8) { - continue ; - } else { - ~~~~ [continue] - console.log(i); - } - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===8) continue ; - else console.log(i); - ~~~~ [continue] - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===8) - continue ; - else - ~~~~ [continue] - console.log(i); - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===4) { - continue ; - } - console.log(i); - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===4) - continue ; - console.log(i); - } -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) { - break ; - } else { - ~~~~ [break] - i++; - } - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) { - break ; - } - i++; - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) - break ; - i++; - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) break ; - i++; - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) break ; - else i++; - ~~~~ [break] - } - return i-1; -} - -const testNoJump = (a) => { - if (a % 2 === 0) { - console.log(a); - } else { - console.log(a * 2); - } -} - -[return]: The preceding `if` block ends with a `return` statement. This `else` is unnecessary. -[throw]: The preceding `if` block ends with a `throw` statement. This `else` is unnecessary. -[break]: The preceding `if` block ends with a `break` statement. This `else` is unnecessary. -[continue]: The preceding `if` block ends with a `continue` statement. This `else` is unnecessary. diff --git a/test/rules/unnecessary-else/allow-else-if/tslint.json b/test/rules/unnecessary-else/allow-else-if/tslint.json deleted file mode 100644 index 8ae348723a7..00000000000 --- a/test/rules/unnecessary-else/allow-else-if/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "unnecessary-else": [true, { "allow-else-if": true }] - } -} diff --git a/test/rules/unnecessary-else/default/test.ts.lint b/test/rules/unnecessary-else/default/test.ts.lint deleted file mode 100644 index b36386fb80b..00000000000 --- a/test/rules/unnecessary-else/default/test.ts.lint +++ /dev/null @@ -1,337 +0,0 @@ -const testReturn = (a) => { - if (a===0) { - return 0; - } else { - ~~~~ [return] - return a; - } -} - -const testReturn = (a) => { - if (a===0) return 0; - else return a; - ~~~~ [return] -} - -const testReturn = (a) => { - if (a===0) - return 0; - else - ~~~~ [return] - return a; -} - -const testReturn = (a) => { - if (a>0) { - if (a%2 ===0) { - return "even" ; - } else { - ~~~~ [return] - return "odd"; - } - } - return "negative"; -} - -const testReturn = (a) => { - if (a===0) { - return 0; - } - return a; -} - -const testReturn = (a) => { - if (a<0) { - return; - } else if (a>0) { - ~~~~ [return] - if (a%2 === 0) { - return ; - } else { - ~~~~ [return] - return ; - } - } - return; -} - -const testReturn = (a) => { - if (a<0) { - return; - } - if (a===1) { - return ; - } else { - ~~~~ [return] - return ; - } -} - -const testReturn = (a) => { - if (a>0) { - if (a%3===0) { - return; - } else { - ~~~~ [return] - console.log(a) - } - } - else { - console.log("negative"); - } -} - -const testThrow = (a) => { - if ( a===0 ) { - throw "error"; - } else { - ~~~~ [throw] - return 100/a; - } -} - -const testThrow = (a) => { - if (a===0) - throw "error; - else - ~~~~ [throw] - console.log(100/a); -} - -const testThrow = (a) => { - if (a===0) throw "error; - else console.log(100/a); - ~~~~ [throw] -} - -const testThrow = (a) => { - switch (a) { - case 1: - break; - case 2: - if (true) { - throw "error"; - } else { - ~~~~ [throw] - break; - } - default : - break; - } -} - -const testThrow = (a) => { - let i = 1; - do { - if (a-i === 0) { - throw "error; - } else { - ~~~~ [throw] - console.log(i/a-i); - } - ++i; - } -} - -const testThrow = (a) => { - if (a===0) { - throw "error"; - } - return 100/a; -} - -const testThrow = (a) => { - if (a===0) throw "error"; - return 100/a; -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===8) { - continue ; - } else { - ~~~~ [continue] - console.log(i); - } - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===8) continue ; - else console.log(i); - ~~~~ [continue] - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===8) - continue ; - else - ~~~~ [continue] - console.log(i); - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===4) { - continue ; - } - console.log(i); - } -} - -const testContinue = () => { - for (let i = 1; i < 10; i++) { - if (i===4) - continue ; - console.log(i); - } -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) { - break ; - } else { - ~~~~ [break] - i++; - } - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) { - break ; - } - i++; - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) - break ; - i++; - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) break ; - i++; - } - return i-1; -} - -const testBreak = (a) => { - let i = 0; - while(i < 20) { - if (i === a) break ; - else i++; - ~~~~ [break] - } - return i-1; -} - -const testNoJump = (a) => { - if (a % 2 === 0) { - console.log(a); - } else { - console.log(a * 2); - } -} - -const testConsoleLogIf = (a) => { - if (a) { - // ... - } else if (!a) { - // ... - } -} - -const testNonJumpingElse = (a) => { - if (a === 1) { - console.log("a"); - } else if (a === 2) { - return; - } else { - console.log("b"); - } - - console.log("c"); -} - -const testNonJumpingIf = (a) => { - if (a === 1) { - console.log("a"); - } else if (a === 2) { - return; - } else if (a % 2 === 1) { - console.log("b"); - } - - console.log("c"); -} - -const testNonJumpingIfNestedJumping = (a) => { - if (a === 1) { - if (a) { - return; - } - else { } - ~~~~ [return] - } else if (a === 2) { - return; - } else if (a % 2 === 1) { - console.log("b"); - } - - console.log("c"); -} - -const testNonJumpingIfNestedNonJumping = (a) => { - if (a === 1) { - if (a) {} - else if (a) { - return; - } - else { } - } else if (a === 2) { - return; - } else if (a % 2 === 1) { - console.log("b"); - } - - console.log("c"); -} - -const testNonJumpingIfAndUnrelated = (a) => { - if (a === 1) { - console.log("a"); - if (a) {} - else if (a) { } - else { } - } else if (a === 2) { - return; - } else if (a % 2 === 1) { - console.log("b"); - } - - console.log("c"); -} - -[return]: The preceding `if` block ends with a `return` statement. This `else` is unnecessary. -[throw]: The preceding `if` block ends with a `throw` statement. This `else` is unnecessary. -[break]: The preceding `if` block ends with a `break` statement. This `else` is unnecessary. -[continue]: The preceding `if` block ends with a `continue` statement. This `else` is unnecessary. diff --git a/test/rules/unnecessary-else/default/tslint.json b/test/rules/unnecessary-else/default/tslint.json deleted file mode 100644 index 5e3f2360d32..00000000000 --- a/test/rules/unnecessary-else/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "unnecessary-else": true - } -} diff --git a/test/rules/use-default-type-parameter/test.ts.fix b/test/rules/use-default-type-parameter/test.ts.fix deleted file mode 100644 index 8930a90507a..00000000000 --- a/test/rules/use-default-type-parameter/test.ts.fix +++ /dev/null @@ -1,18 +0,0 @@ - -function f() {} -f(); -f(); - -function g() {} -g(); -g(); // Must specify 1st type parameter if 2nd is different than default. - - -class C {} -function h(c: C) {} -new C(); -class D extends C {} - -interface I {} -class Impl implements I {} - diff --git a/test/rules/use-default-type-parameter/test.ts.lint b/test/rules/use-default-type-parameter/test.ts.lint deleted file mode 100644 index 516caf71c5b..00000000000 --- a/test/rules/use-default-type-parameter/test.ts.lint +++ /dev/null @@ -1,26 +0,0 @@ -[typescript]: >= 2.3.0 - -function f() {} -f(); - ~~~~~~ [0] -f(); - -function g() {} -g(); - ~~~~~~ [0] -g(); // Must specify 1st type parameter if 2nd is different than default. - - -class C {} -function h(c: C) {} - ~~~~~~ [0] -new C(); - ~~~~~~ [0] -class D extends C {} - ~~~~~~ [0] - -interface I {} -class Impl implements I {} - ~~~~~~ [0] - -[0]: This is the default value for this type parameter, so it can be omitted. diff --git a/test/rules/use-default-type-parameter/tsconfig.json b/test/rules/use-default-type-parameter/tsconfig.json deleted file mode 100644 index 9e26dfeeb6e..00000000000 --- a/test/rules/use-default-type-parameter/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/rules/use-default-type-parameter/tslint.json b/test/rules/use-default-type-parameter/tslint.json deleted file mode 100644 index d5a2fb118d1..00000000000 --- a/test/rules/use-default-type-parameter/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "use-default-type-parameter": true - } -} diff --git a/test/rules/use-isnan/test.ts.lint b/test/rules/use-isnan/test.ts.lint deleted file mode 100644 index 27119c9a3e9..00000000000 --- a/test/rules/use-isnan/test.ts.lint +++ /dev/null @@ -1,64 +0,0 @@ - -// no violation for comparing NaN using isNaN -if (isNaN(NaN)) { -} - -// no violation for correctly checking for isNaN -if (isNaN(something)) { } - -// no violation for assignments -let x = 0; -x = NaN; -x += NaN; -x -= NaN; -x /= NaN; -x *= NaN; -x %= NaN; -x **= NaN; -x <<= NaN; -x >>= NaN; -x >>>= NaN; -x &= NaN; -x ^= NaN; -x |= NaN; - -// no violation for arithmetic operators -x = x + NaN; -x = NaN - x; -x = x / NaN; -x = NaN * x; -x = x % NaN; -x = NaN ** x; - -// no violation for bitwise operators -x = x & NaN; -x = NaN | x; -x = x ^ NaN; -x = NaN << x; -x = x >> NaN; -x = NaN >>> x; -x = x & NaN; - -// no violation for other operators -if (x instanceof NaN) { } -if (NaN in x) { } - -// do not use equality operators to compare for NaN -if (foo == NaN) { } - ~~~~~~~~~~ [Found an invalid comparison for NaN: foo == NaN] -if (NaN === foo) { } - ~~~~~~~~~~~ [Found an invalid comparison for NaN: NaN === foo] -if (foo != NaN) { } - ~~~~~~~~~~ [Found an invalid comparison for NaN: foo != NaN] -if (NaN !== foo) { } - ~~~~~~~~~~~ [Found an invalid comparison for NaN: NaN !== foo] - -// do not use any binary operators to compare for NaN -if (foo > NaN) { } - ~~~~~~~~~ [Found an invalid comparison for NaN: foo > NaN] -if (NaN >= foo) { } - ~~~~~~~~~~ [Found an invalid comparison for NaN: NaN >= foo] -if (foo < NaN) { } - ~~~~~~~~~ [Found an invalid comparison for NaN: foo < NaN] -if (NaN <= foo) { } - ~~~~~~~~~~ [Found an invalid comparison for NaN: NaN <= foo] diff --git a/test/rules/use-isnan/tslint.json b/test/rules/use-isnan/tslint.json deleted file mode 100644 index 880adde9812..00000000000 --- a/test/rules/use-isnan/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "use-isnan": true - } -} diff --git a/test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint b/test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint deleted file mode 100644 index a1cf5b656da..00000000000 --- a/test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint +++ /dev/null @@ -1,47 +0,0 @@ -var validName1 = "hi"; -var VALIDNAME2 = "there"; -var InvalidName1 = ","; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -var invalid_name2 = " "; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -class Test { - private Invalid_name3 = "how"; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - private _optionallyValid = "are"; // sometimes a failure -} - -function test() { - () => { - var InVaLiDnAmE4 = "you"; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - }; -} - -declare var DeclaresAreValid: any; - -export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures - ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let { foo, bar } = { foo: 1, bar: 2 }; -let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let optionallyValid_ = "bar"; -let _$httpBackend_ = "leading and trailing"; diff --git a/test/rules/variable-name/allow-leading-trailing-underscore/tslint.json b/test/rules/variable-name/allow-leading-trailing-underscore/tslint.json deleted file mode 100644 index c5d657add43..00000000000 --- a/test/rules/variable-name/allow-leading-trailing-underscore/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "allow-leading-underscore", "allow-trailing-underscore"] - } -} diff --git a/test/rules/variable-name/allow-leading-underscore/test.ts.lint b/test/rules/variable-name/allow-leading-underscore/test.ts.lint deleted file mode 100644 index 6f9150814df..00000000000 --- a/test/rules/variable-name/allow-leading-underscore/test.ts.lint +++ /dev/null @@ -1,49 +0,0 @@ -var validName1 = "hi"; -var VALIDNAME2 = "there"; -var InvalidName1 = ","; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -var invalid_name2 = " "; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -class Test { - private Invalid_name3 = "how"; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - private _optionallyValid = "are"; // sometimes a failure -} - -function test() { - () => { - var InVaLiDnAmE4 = "you"; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - }; -} - -declare var DeclaresAreValid: any; - -export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures - ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let { foo, bar } = { foo: 1, bar: 2 }; -let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let optionallyValid_ = "bar"; - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -let _$httpBackend_ = "leading and trailing"; - ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] diff --git a/test/rules/variable-name/allow-leading-underscore/tslint.json b/test/rules/variable-name/allow-leading-underscore/tslint.json deleted file mode 100644 index 4f9cde74fec..00000000000 --- a/test/rules/variable-name/allow-leading-underscore/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "allow-leading-underscore"] - } -} diff --git a/test/rules/variable-name/allow-pascal-case/test.ts.lint b/test/rules/variable-name/allow-pascal-case/test.ts.lint deleted file mode 100644 index eec49b268f1..00000000000 --- a/test/rules/variable-name/allow-pascal-case/test.ts.lint +++ /dev/null @@ -1,50 +0,0 @@ -var validName1 = "hi"; -var VALIDNAME2 = "there"; -var ValidName3 = ","; -var invalid_name1 = " "; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - -class Test { - private Invalid_name3 = "how"; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - private _optionallyValid = "are"; // sometimes a failure - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] -} - -function test() { - () => { - var InVaLiDnAmE4 = "you"; - }; -} - -declare var DeclaresAreValid: any; - -export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 1 failure - ~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - // -} - -let { foo, bar } = { foo: 1, bar: 2 }; -let [ invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures - ~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - -export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 1 failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - // -} - -export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure - ~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - // -} - -let optionallyValid_ = "bar"; - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] -let _$httpBackend_ = "leading and trailing"; - ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] - -// don't crash on syntax errors - -class {} -let {bar:} = foo; diff --git a/test/rules/variable-name/allow-pascal-case/tslint.json b/test/rules/variable-name/allow-pascal-case/tslint.json deleted file mode 100644 index 2552fcdc0d7..00000000000 --- a/test/rules/variable-name/allow-pascal-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "allow-pascal-case"] - } -} diff --git a/test/rules/variable-name/allow-snake-case/test.ts.lint b/test/rules/variable-name/allow-snake-case/test.ts.lint deleted file mode 100644 index 548e443fb0c..00000000000 --- a/test/rules/variable-name/allow-snake-case/test.ts.lint +++ /dev/null @@ -1,64 +0,0 @@ -var validName1 = "hi"; -var VALIDNAME2 = "there"; -var valid_name3 = "tslint"; -var Invalid_name1 = " "; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] -var InvalidName2 = " "; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - -class Test { - private valid_name = " "; - private Invalid_name1 = "how"; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - private _optionallyValid = "are"; // sometimes a failure - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] -} - -function test() { - () => { - var valid_name = " "; - var InVaLiDnAmE4 = "you"; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - }; -} - -declare var DeclaresAreValid: any; - -export function functionWithInvalidParamNames (ok_name, BadName) { // 1 failure - ~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] -} - -let { foo, bar } = { foo: 1, bar: 2 }; -let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 1 failure - ~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - -export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 1 failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - // -} - -export function functionWithInvalidSpread(InvalidArg: ...number) { // 1 failure - ~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - // -} - -let optionallyValid_ = "bar"; - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] -let _$httpBackend_ = "leading and trailing"; - ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - -// Aliases. -class X { - ValidAlias = ValidAlias; -} - -var ValidAlias = some.ValidAlias; -var ValidAlias = some.InValidAlias; - ~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] - -var someObject = {MoreValidAlias: 1}; -var {MoreValidAlias: localVar} = someObject; -var {MoreValidAlias: local_var} = someObject; -var {MoreValidAlias: LocalVar} = someObject; - ~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] -var {MoreValidAlias} = someObject; diff --git a/test/rules/variable-name/allow-snake-case/tslint.json b/test/rules/variable-name/allow-snake-case/tslint.json deleted file mode 100644 index 16bbbfb2052..00000000000 --- a/test/rules/variable-name/allow-snake-case/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "allow-snake-case"] - } -} diff --git a/test/rules/variable-name/allow-trailing-underscore/test.ts.lint b/test/rules/variable-name/allow-trailing-underscore/test.ts.lint deleted file mode 100644 index d635af62bc0..00000000000 --- a/test/rules/variable-name/allow-trailing-underscore/test.ts.lint +++ /dev/null @@ -1,49 +0,0 @@ -var validName1 = "hi"; -var VALIDNAME2 = "there"; -var InvalidName1 = ","; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -var invalid_name2 = " "; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -class Test { - private Invalid_name3 = "how"; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - private _optionallyValid = "are"; // sometimes a failure - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -} - -function test() { - () => { - var InVaLiDnAmE4 = "you"; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - }; -} - -declare var DeclaresAreValid: any; - -export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures - ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let { foo, bar } = { foo: 1, bar: 2 }; -let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let optionallyValid_ = "bar"; -let _$httpBackend_ = "leading and trailing"; - ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] diff --git a/test/rules/variable-name/allow-trailing-underscore/tslint.json b/test/rules/variable-name/allow-trailing-underscore/tslint.json deleted file mode 100644 index 86b02a3ad4f..00000000000 --- a/test/rules/variable-name/allow-trailing-underscore/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "allow-trailing-underscore"] - } -} diff --git a/test/rules/variable-name/ban-keywords/test.ts.lint b/test/rules/variable-name/ban-keywords/test.ts.lint deleted file mode 100644 index 3bf0f62aa0e..00000000000 --- a/test/rules/variable-name/ban-keywords/test.ts.lint +++ /dev/null @@ -1,21 +0,0 @@ -let undefined = 8; - ~~~~~~~~~ [variable name clashes with keyword/type] -let boolean: boolean; - ~~~~~~~ [variable name clashes with keyword/type] -function bad(any: any) { } - ~~~ [variable name clashes with keyword/type] -let [number] = [3]; - ~~~~~~ [variable name clashes with keyword/type] -let {String} = {String: 1}; - ~~~~~~ [variable name clashes with keyword/type] - -// good: -let foo = 2; -let bar: any; -function good(baz: any) { } -let [faz] = [5]; -const {pom} = {pom: 5}; - -interface Wob { - number: string; -} diff --git a/test/rules/variable-name/ban-keywords/tslint.json b/test/rules/variable-name/ban-keywords/tslint.json deleted file mode 100644 index 9b5db62cf01..00000000000 --- a/test/rules/variable-name/ban-keywords/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "ban-keywords"] - } -} diff --git a/test/rules/variable-name/const-only-for-caps/test.ts.lint b/test/rules/variable-name/const-only-for-caps/test.ts.lint deleted file mode 100644 index 8a092a64932..00000000000 --- a/test/rules/variable-name/const-only-for-caps/test.ts.lint +++ /dev/null @@ -1,38 +0,0 @@ -var snake_case_var; - ~~~~~~~~~~~~~~ [regular-case] - -var camelCaseVar; - -var PascalCaseVar; - ~~~~~~~~~~~~~ [regular-case] - -var UPPER_CASE_VAR; - ~~~~~~~~~~~~~~ [const] - -let snake_case_let; - ~~~~~~~~~~~~~~ [regular-case] - -let camelCaseLet; - -let PascalCaseLet; - ~~~~~~~~~~~~~ [regular-case] - -let UPPER_CASE_LET; - ~~~~~~~~~~~~~~ [const] - -const snake_case_const; - ~~~~~~~~~~~~~~~~ [regular-case] - -const camelCaseConst; - -const PascalCaseConst; - ~~~~~~~~~~~~~~~ [regular-case] - -const UPPER_CASE_CONST; - -class Test { - public static readonly MY_FIELD = 10; -} - -[const]: Only `const` variables may be UPPER_CASE. -[regular-case]: variable name must be in lowerCamelCase or UPPER_CASE diff --git a/test/rules/variable-name/const-only-for-caps/tslint.json b/test/rules/variable-name/const-only-for-caps/tslint.json deleted file mode 100644 index 991cbcb344e..00000000000 --- a/test/rules/variable-name/const-only-for-caps/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": [true, "require-const-for-all-caps"] - } -} diff --git a/test/rules/variable-name/default/test.ts.lint b/test/rules/variable-name/default/test.ts.lint deleted file mode 100644 index ade3be266b2..00000000000 --- a/test/rules/variable-name/default/test.ts.lint +++ /dev/null @@ -1,65 +0,0 @@ -var validName1 = "hi"; -var VALIDNAME2 = "there"; -var InvalidName1 = ","; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -var invalid_name2 = " "; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -class Test { - private Invalid_name3 = "how"; // failure - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - private _optionallyValid = "are"; // sometimes a failure - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -} - -function test() { - () => { - var InVaLiDnAmE4 = "you"; // failure - ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - }; -} - -declare var DeclaresAreValid: any; - -export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures - ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let { foo, bar } = { foo: 1, bar: 2 }; -let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure - ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - // -} - -let optionallyValid_ = "bar"; - ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -let _$httpBackend_ = "leading and trailing"; - ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -// Aliases. -class X { - ValidAlias = ValidAlias; -} - -var ValidAlias = some.ValidAlias; -var ValidAlias = some.InValidAlias; - ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] - -var someObject = {MoreValidAlias: 1}; -var {MoreValidAlias: localVar} = someObject; -var {MoreValidAlias: LocalVar} = someObject; - ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] -var {MoreValidAlias} = someObject; diff --git a/test/rules/variable-name/default/tslint.json b/test/rules/variable-name/default/tslint.json deleted file mode 100644 index 4c41fc82fc7..00000000000 --- a/test/rules/variable-name/default/tslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "variable-name": true - } -} diff --git a/test/rules/whitespace/all/bom.ts.lint b/test/rules/whitespace/all/bom.ts.lint deleted file mode 100644 index 4d075454a73..00000000000 --- a/test/rules/whitespace/all/bom.ts.lint +++ /dev/null @@ -1 +0,0 @@ -import * as $t from 't'; diff --git a/test/rules/whitespace/all/import-type.lint b/test/rules/whitespace/all/import-type.lint deleted file mode 100644 index 64ef7f5cb5f..00000000000 --- a/test/rules/whitespace/all/import-type.lint +++ /dev/null @@ -1,32 +0,0 @@ -[typescript]: >=2.9.0 - -const foo: import("bar"); -const foo: import ("bar"); - -function foo(a: import("bar")): import("baz") {} -function foo(a: import ("bar")): import ("baz") {} - -const foo = (a: import("bar")): import("baz") => {}; -const foo = (a: import ("bar")): import ("baz") => {}; - -type foo = { bar: import("baz") } & import("qux"); -type foo = { bar: import ("baz") } & import ("qux"); - -interface Foo { - bar: import("baz"); - qux: import ("quux"); -} - -class Foo { - bar: import("baz"); - qux: import ("quux"); -} - -/** - * @param bar { import("qux") } - * @param baz { import ("qux") } - */ -function foo(bar, baz) { } - -type foo = Bar; -type foo = Bar; diff --git a/test/rules/whitespace/all/import.ts.lint b/test/rules/whitespace/all/import.ts.lint deleted file mode 100644 index aaa73d65808..00000000000 --- a/test/rules/whitespace/all/import.ts.lint +++ /dev/null @@ -1,3 +0,0 @@ -[typescript]: >=2.4.0 -import('./foo') -.then(foo => { foo.setup(); }); diff --git a/test/rules/whitespace/all/test.ts.fix b/test/rules/whitespace/all/test.ts.fix deleted file mode 100644 index d5cc53cab29..00000000000 --- a/test/rules/whitespace/all/test.ts.fix +++ /dev/null @@ -1,135 +0,0 @@ -import ast = AST; -module M { - export var ast = AST; - - var x: number; - - var y = (x === 10) ? 1 : 2; - - var zz = (y === 4); - - var z = y; - - var a, b; - - switch (x) { - case 1: break; - default: break; - } - - for (x = 1; x < 2; ++x) { - goto: console.log("hi"); - } - - for (x = 2; x--;) {} - for (;;) {} - - while (i < 1) { - ++i; - } - - var q; - q.forEach(() => 3); - q.forEach(() => { - return 3; - }); - - var r: () => string; - var s: new () => string; - var a = "10"; - var a = "10"; -} - -var a; - -export = a; - -a.then(() => { - return 1; -}).if(() => { - return 1; -}); - -var name = "something"; -var test = ` - -
3); - ~ [missing whitespace] - ~ [missing whitespace] - q.forEach(()=>{ - ~ [missing whitespace] - ~ [missing whitespace] - return 3; - }); - - var r: ()=>string; - ~ [missing whitespace] - ~ [missing whitespace] - var s: new ()=>string; - ~ [missing whitespace] - ~ [missing whitespace] - var a = "10"; - ~ [missing whitespace] - var a = "10"; -} - -var a; - -export=a; - ~ [missing whitespace] - ~ [missing whitespace] - -a.then(() => { - return 1; -}).if(() => { - return 1; -}); - -var name = "something"; -var test = ` - -
3); - q.forEach(()=>{ - return 3; - }); - - var r: ()=>string; - var s: new ()=>string; - var a = "10"; - var a = "10"; -} - -var a; - -export=a; - -a.then(() => { - return 1; -}).if(() => { - return 1; -}); - -var name = "something"; -var test = ` - -
Date: Thu, 28 Nov 2019 13:21:56 -0500 Subject: [PATCH 5/7] added test files back in --- .../_integration/enable-disable/test.ts.lint | 146 +++ .../_integration/enable-disable/test.tsx.lint | 69 ++ .../_integration/enable-disable/tslint.json | 11 + .../_integration/error-format/test.ts.lint | 37 + .../_integration/error-format/tslint.json | 5 + .../rules/_integration/react/invalid.tsx.lint | 6 + test/rules/_integration/react/test.tsx.lint | 58 ++ test/rules/_integration/react/tslint.json | 21 + .../typescript-version/correct.js.lint | 3 + .../typescript-version/correct.ts.fix | 1 + .../typescript-version/correct.ts.lint | 3 + .../typescript-version/if-else.ts.lint | 21 + .../typescript-version/skip.js.lint | 2 + .../typescript-version/skip.ts.lint | 2 + .../typescript-version/substitution.ts.lint | 4 + .../typescript-version/tslint.json | 8 + .../default/test.ts.lint | 166 ++++ .../default/tslint.json | 5 + .../ignore-accessors/test.ts.lint | 11 + .../ignore-accessors/tslint.json | 5 + test/rules/align/arguments/test.ts.fix | 149 +++ test/rules/align/arguments/test.ts.lint | 152 +++ test/rules/align/arguments/tslint.json | 5 + test/rules/align/elements/test.ts.fix | 47 + test/rules/align/elements/test.ts.lint | 53 + test/rules/align/elements/tslint.json | 5 + test/rules/align/members/test.ts.fix | 40 + test/rules/align/members/test.ts.lint | 53 + test/rules/align/members/tslint.json | 5 + test/rules/align/parameters/test.ts.fix | 32 + test/rules/align/parameters/test.ts.lint | 39 + test/rules/align/parameters/tslint.json | 5 + test/rules/align/statements/bom.ts.fix | 3 + test/rules/align/statements/bom.ts.lint | 4 + test/rules/align/statements/test.ts.fix | 157 +++ test/rules/align/statements/test.ts.lint | 159 +++ test/rules/align/statements/tslint.json | 5 + .../rules/array-type/array-simple/test.ts.fix | 65 ++ .../array-type/array-simple/test.ts.lint | 86 ++ .../rules/array-type/array-simple/tslint.json | 5 + test/rules/array-type/array/test.ts.fix | 50 + test/rules/array-type/array/test.ts.lint | 65 ++ test/rules/array-type/array/tslint.json | 5 + test/rules/array-type/generic/test.ts.fix | 50 + test/rules/array-type/generic/test.ts.lint | 65 ++ test/rules/array-type/generic/tslint.json | 5 + .../ban-single-arg-parens/test.ts.fix | 51 + .../ban-single-arg-parens/test.ts.lint | 70 ++ .../ban-single-arg-parens/tslint.json | 8 + test/rules/arrow-parens/default/test.ts.fix | 27 + test/rules/arrow-parens/default/test.ts.lint | 29 + test/rules/arrow-parens/default/tslint.json | 5 + .../default/test.ts.fix | 21 + .../default/test.ts.lint | 31 + .../default/tslint.json | 5 + .../multiline/test.ts.fix | 20 + .../multiline/test.ts.lint | 34 + .../multiline/tslint.json | 5 + .../await-promise/custom-promise/test.ts.lint | 78 ++ .../custom-promise/tsconfig.json | 5 + .../await-promise/custom-promise/tslint.json | 8 + .../await-promise/es6-promise/test.ts.lint | 58 ++ .../await-promise/es6-promise/tsconfig.json | 5 + .../await-promise/es6-promise/tslint.json | 5 + .../await-promise/for-await-of/test.ts.lint | 51 + .../await-promise/for-await-of/tsconfig.json | 5 + .../await-promise/for-await-of/tslint.json | 5 + test/rules/ban-comma-operator/test.ts.lint | 23 + test/rules/ban-comma-operator/tslint.json | 5 + test/rules/ban-ts-ignore/test.ts.lint | 33 + test/rules/ban-ts-ignore/tslint.json | 6 + test/rules/ban-types/test.ts.lint | 20 + test/rules/ban-types/tslint.json | 10 + test/rules/ban/test.ts.lint | 41 + test/rules/ban/tslint.json | 17 + .../test.ts.lint | 45 + .../tslint.json | 5 + test/rules/callable-types/test.ts.fix | 34 + test/rules/callable-types/test.ts.lint | 74 ++ test/rules/callable-types/tslint.json | 5 + test/rules/class-name/test.ts.lint | 26 + test/rules/class-name/tslint.json | 5 + .../allow-trailing-lowercase/test.ts.fix | 15 + .../allow-trailing-lowercase/test.ts.lint | 20 + .../allow-trailing-lowercase/tslint.json | 5 + .../exceptions-pattern/test.ts.fix | 30 + .../exceptions-pattern/test.ts.lint | 39 + .../exceptions-pattern/tslint.json | 5 + .../exceptions-words/test.ts.fix | 29 + .../exceptions-words/test.ts.lint | 39 + .../exceptions-words/tslint.json | 5 + test/rules/comment-format/lower/test.ts.fix | 20 + test/rules/comment-format/lower/test.ts.lint | 27 + test/rules/comment-format/lower/test.tsx.fix | 9 + test/rules/comment-format/lower/test.tsx.lint | 12 + test/rules/comment-format/lower/tslint.json | 5 + test/rules/comment-format/upper/test.ts.fix | 27 + test/rules/comment-format/upper/test.ts.lint | 37 + test/rules/comment-format/upper/tslint.json | 5 + test/rules/comment-type/combo/test.ts.lint | 25 + test/rules/comment-type/combo/tslint.json | 5 + .../comment-type/directive/test.ts.tslint | 29 + test/rules/comment-type/directive/tslint.json | 5 + test/rules/comment-type/doc/test.ts.lint | 27 + test/rules/comment-type/doc/tslint.json | 5 + .../rules/comment-type/multiline/test.ts.lint | 25 + test/rules/comment-type/multiline/tslint.json | 5 + .../comment-type/single-line/test.ts.lint | 29 + .../comment-type/single-line/tslint.json | 5 + test/rules/curly/as-needed/test.ts.lint | 53 + test/rules/curly/as-needed/tslint.json | 5 + test/rules/curly/defaults/test.ts.fix | 103 ++ test/rules/curly/defaults/test.ts.lint | 123 +++ test/rules/curly/defaults/tslint.json | 5 + test/rules/curly/ignore-same-line/test.ts.fix | 93 ++ .../rules/curly/ignore-same-line/test.ts.lint | 101 ++ test/rules/curly/ignore-same-line/tslint.json | 5 + .../defaultThreshold/test.ts.lint | 68 ++ .../defaultThreshold/tslint.json | 5 + .../invalidThreshold/test.ts.lint | 25 + .../invalidThreshold/tslint.json | 5 + .../specifiedThreshold/test.ts.lint | 383 ++++++++ .../specifiedThreshold/tslint.json | 5 + test/rules/deprecation/other.test.ts | 34 + test/rules/deprecation/other2.test.ts | 3 + test/rules/deprecation/test.ts.lint | 174 ++++ test/rules/deprecation/tsconfig.json | 5 + test/rules/deprecation/tslint.json | 5 + test/rules/encoding/tslint.json | 5 + test/rules/encoding/utf16be.ts.lint | Bin 0 -> 138 bytes test/rules/encoding/utf16le.ts.lint | Bin 0 -> 144 bytes test/rules/encoding/utf8-bom.ts.lint | 2 + test/rules/encoding/utf8.ts.lint | 0 test/rules/eofline/comment.ts.lint | 3 + test/rules/eofline/disabled.ts.lint | 2 + test/rules/eofline/empty.ts.lint | 0 test/rules/eofline/invalid.ts.fix | 1 + test/rules/eofline/invalid.ts.lint | 2 + test/rules/eofline/only-whitespace.ts.fix | 2 + test/rules/eofline/only-whitespace.ts.lint | 3 + test/rules/eofline/tslint.json | 5 + test/rules/eofline/valid.ts.lint | 1 + test/rules/eofline/whitespace.ts.lint | 2 + .../rules/file-header/bad-newline/test.ts.fix | 11 + .../file-header/bad-newline/test.ts.lint | 11 + .../rules/file-header/bad-newline/tslint.json | 5 + .../rules/file-header/bad-shebang/test.ts.fix | 21 + .../file-header/bad-shebang/test.ts.lint | 18 + .../rules/file-header/bad-shebang/tslint.json | 5 + .../file-header/bad-single-line/test.ts.fix | 17 + .../file-header/bad-single-line/test.ts.lint | 14 + .../file-header/bad-single-line/tslint.json | 5 + .../bad-single-newline/test.ts.fix | 12 + .../bad-single-newline/test.ts.lint | 9 + .../bad-single-newline/tslint.json | 5 + .../file-header/bad-use-strict/test.ts.fix | 21 + .../file-header/bad-use-strict/test.ts.lint | 18 + .../file-header/bad-use-strict/tslint.json | 5 + test/rules/file-header/bad/test.ts.fix | 19 + test/rules/file-header/bad/test.ts.lint | 16 + test/rules/file-header/bad/test2.ts.fix | 7 + test/rules/file-header/bad/test2.ts.lint | 4 + test/rules/file-header/bad/tslint.json | 5 + .../rules/file-header/empty-file/test.ts.lint | 2 + test/rules/file-header/empty-file/tslint.json | 5 + .../test.ts.lint | 4 + .../tslint.json | 8 + .../file-header/good-newline/test.ts.lint | 3 + .../file-header/good-newline/tslint.json | 10 + .../file-header/good-shebang/test.ts.lint | 14 + .../file-header/good-shebang/tslint.json | 5 + .../file-header/good-single-line/test.ts.lint | 9 + .../file-header/good-single-line/tslint.json | 5 + .../file-header/good-use-strict/test.ts.lint | 13 + .../file-header/good-use-strict/tslint.json | 5 + test/rules/file-header/good/test.ts.fix | 12 + test/rules/file-header/good/test.ts.lint | 12 + test/rules/file-header/good/tslint.json | 5 + .../camel-case/camelCase.ts.lint | 0 .../camel-case/no-camel-case.ts.lint | 2 + .../file-name-casing/camel-case/tslint.json | 5 + .../complex/ComponentName.tsx.lint | 0 .../complex/InvalidNonComponentName.ts.lint | 2 + .../complex/invalid-component-name.tsx.lint | 2 + .../complex/my-button.component.ts.lint | 2 + .../complex/nonComponentName.ts.lint | 0 .../file-name-casing/complex/tslint.json | 9 + .../file-matcher/PascalCase.ts.lint | 0 .../file-matcher/camelCase.ts.lint | 0 .../file-matcher/notPascalCase.ts.lint | 2 + .../file-matcher/not_camel_case.ts.lint | 2 + .../file-matcher/not_kebab_case.tsx.lint | 2 + .../file-name-casing/file-matcher/tslint.json | 13 + .../ignore/complaint.tsx.lint | 2 + .../file-name-casing/ignore/file.ts.lint | 0 .../rules/file-name-casing/ignore/tslint.json | 8 + .../invalid-option/snake_case.ts.lint | 0 .../invalid-option/tslint.json | 5 + .../kebab-case/kebab-case.ts.lint | 0 .../kebab-case/noKebabCase.ts.lint | 2 + .../file-name-casing/kebab-case/tslint.json | 5 + .../pascal-case/PascalCase.ts.lint | 0 .../pascal-case/no-pascal-case.ts.lint | 2 + .../file-name-casing/pascal-case/tslint.json | 5 + .../snake-case/no-snake-case.ts.lint | 2 + .../snake-case/snake_case.ts.lint | 0 .../file-name-casing/snake-case/tslint.json | 5 + test/rules/forin/test.ts.lint | 41 + test/rules/forin/tslint.json | 5 + test/rules/function-constructor/test.ts.lint | 19 + test/rules/function-constructor/tslint.json | 5 + test/rules/import-blacklist/test.ts.lint | 55 ++ test/rules/import-blacklist/tslint.json | 5 + test/rules/import-spacing/test.ts.lint | 157 +++ test/rules/import-spacing/tslint.json | 5 + .../allow-post/test.ts.fix | 20 + .../allow-post/test.ts.lint | 26 + .../allow-post/tslint.json | 5 + .../increment-decrement/default/test.ts.fix | 29 + .../increment-decrement/default/test.ts.lint | 45 + .../increment-decrement/default/tslint.json | 5 + test/rules/indent/spaces-2/test.ts.fix | 139 +++ test/rules/indent/spaces-2/test.ts.lint | 162 ++++ test/rules/indent/spaces-2/test.tsx.lint | 17 + test/rules/indent/spaces-2/tslint.json | 5 + test/rules/indent/spaces-4/test.ts.fix | 139 +++ test/rules/indent/spaces-4/test.ts.lint | 162 ++++ test/rules/indent/spaces-4/tslint.json | 5 + test/rules/indent/tabs-2/test.ts.fix | 141 +++ test/rules/indent/tabs-2/test.ts.lint | 164 ++++ test/rules/indent/tabs-2/tslint.json | 5 + test/rules/indent/tabs-4/test.ts.fix | 141 +++ test/rules/indent/tabs-4/test.ts.lint | 164 ++++ test/rules/indent/tabs-4/tslint.json | 5 + .../interface-name/always-prefix/test.ts.lint | 34 + .../interface-name/always-prefix/tslint.json | 5 + .../rules/interface-name/default/test.ts.lint | 7 + test/rules/interface-name/default/tslint.json | 5 + .../interface-name/never-prefix/test.ts.lint | 35 + .../interface-name/never-prefix/tslint.json | 5 + .../interface-over-type-literal/test.ts.fix | 10 + .../interface-over-type-literal/test.ts.lint | 14 + .../interface-over-type-literal/tslint.json | 5 + .../allow-generics/false/test.ts.lint | 16 + .../allow-generics/false/tslint.json | 7 + .../allow-generics/true/test.ts.lint | 11 + .../allow-generics/true/tslint.json | 7 + .../allow-generics/whitelist/test.ts.lint | 12 + .../allow-generics/whitelist/tslint.json | 7 + test/rules/invalid-void/default/test.ts.lint | 127 +++ test/rules/invalid-void/default/tslint.json | 5 + .../check-multiline-start/test.ts.lint | 10 + .../check-multiline-start/tslint.json | 5 + .../jsdoc-format/default/jsdoc-bom.ts.lint | 3 + .../default/jsdoc-windows.ts.lint | 24 + test/rules/jsdoc-format/default/jsdoc.ts.lint | 88 ++ test/rules/jsdoc-format/default/tslint.json | 5 + test/rules/label-position/test.ts.lint | 38 + test/rules/label-position/tslint.json | 5 + .../linebreak-style/emptyFile/test.ts.lint | 0 .../linebreak-style/emptyFile/tslint.json | 5 + .../linebreak-style/failure/CRLF/test.ts.fix | 4 + .../linebreak-style/failure/CRLF/test.ts.lint | 8 + .../linebreak-style/failure/CRLF/tslint.json | 5 + .../linebreak-style/failure/LF/test.ts.fix | 4 + .../linebreak-style/failure/LF/test.ts.lint | 8 + .../linebreak-style/failure/LF/tslint.json | 5 + .../linebreak-style/success/CRLF/test.ts.lint | 4 + .../linebreak-style/success/CRLF/tslint.json | 5 + .../linebreak-style/success/LF/test.ts.lint | 4 + .../linebreak-style/success/LF/tslint.json | 5 + .../anonymous.test.ts | 1 + .../match-default-export-name/named.test.ts | 1 + .../match-default-export-name/test.ts.lint | 3 + .../match-default-export-name/tsconfig.json | 5 + .../match-default-export-name/tslint.json | 5 + .../max-classes-per-file/one/test.ts.lint | 35 + .../max-classes-per-file/one/tslint.json | 5 + .../max-classes-per-file/two/test.ts.lint | 23 + .../max-classes-per-file/two/tslint.json | 5 + .../max-file-line-count/default/test.ts.lint | 23 + .../max-file-line-count/default/tslint.json | 5 + .../max-file-line-count/disabled/test.ts.lint | 24 + .../max-file-line-count/disabled/tslint.json | 5 + .../check-strings-and-regex/test.ts.lint | 33 + .../check-strings-and-regex/tslint.json | 10 + .../max-line-length/default/test.ts.lint | 25 + .../rules/max-line-length/default/tslint.json | 7 + test/rules/member-access/accessor/test.ts.fix | 17 + .../rules/member-access/accessor/test.ts.lint | 19 + test/rules/member-access/accessor/tslint.json | 5 + .../member-access/constructor/test.ts.fix | 10 + .../member-access/constructor/test.ts.lint | 13 + .../member-access/constructor/tslint.json | 5 + test/rules/member-access/default/test.ts.fix | 54 ++ test/rules/member-access/default/test.ts.lint | 67 ++ test/rules/member-access/default/tslint.json | 5 + .../rules/member-access/no-public/test.ts.fix | 12 + .../member-access/no-public/test.ts.lint | 19 + .../rules/member-access/no-public/tslint.json | 5 + .../parameter-property/test.ts.fix | 17 + .../parameter-property/test.ts.lint | 20 + .../parameter-property/tslint.json | 5 + .../alphabetize-nested/test.ts.fix | 14 + .../alphabetize-nested/test.ts.lint | 17 + .../alphabetize-nested/tslint.json | 8 + .../member-ordering/alphabetize/test.ts.fix | 32 + .../member-ordering/alphabetize/test.ts.lint | 38 + .../member-ordering/alphabetize/tslint.json | 8 + .../custom-categories/test.ts.fix | 9 + .../custom-categories/test.ts.lint | 10 + .../custom-categories/tslint.json | 18 + test/rules/member-ordering/custom/test.ts.fix | 35 + .../rules/member-ordering/custom/test.ts.lint | 36 + test/rules/member-ordering/custom/tslint.json | 8 + .../member-ordering/fields-first/test.ts.fix | 37 + .../member-ordering/fields-first/test.ts.lint | 39 + .../member-ordering/fields-first/tslint.json | 5 + .../member-ordering/fix-trivia/test.ts.fix | 23 + .../member-ordering/fix-trivia/test.ts.lint | 26 + .../member-ordering/fix-trivia/tslint.json | 8 + .../instance-sandwich/test.ts.fix | 37 + .../instance-sandwich/test.ts.lint | 40 + .../instance-sandwich/tslint.json | 5 + .../mix-old-options/test.ts.fix | 15 + .../mix-old-options/test.ts.lint | 16 + .../mix-old-options/tslint.json | 9 + .../omit-access-modifier/test.ts.fix | 11 + .../omit-access-modifier/test.ts.lint | 12 + .../omit-access-modifier/tslint.json | 9 + .../public-before-private/test.ts.fix | 8 + .../public-before-private/test.ts.lint | 10 + .../public-before-private/tslint.json | 5 + .../static-before-instance/test.ts.fix | 8 + .../static-before-instance/test.ts.lint | 10 + .../static-before-instance/tslint.json | 5 + .../member-ordering/statics-first/test.ts.fix | 37 + .../statics-first/test.ts.lint | 41 + .../member-ordering/statics-first/tslint.json | 5 + .../variables-before-functions/test.ts.fix | 63 ++ .../variables-before-functions/test.ts.lint | 71 ++ .../variables-before-functions/tslint.json | 5 + test/rules/new-parens/test.ts.lint | 14 + test/rules/new-parens/tslint.json | 5 + .../newline-before-return/default/test.ts.fix | 126 +++ .../default/test.ts.lint | 124 +++ .../default/test.tsx.fix | 17 + .../default/test.tsx.lint | 18 + .../newline-before-return/default/tslint.json | 5 + .../default/test.ts.lint | 120 +++ .../default/tslint.json | 5 + .../test.ts.fix | 52 + .../test.ts.lint | 73 ++ .../tslint.json | 5 + test/rules/no-any/default/test.ts.lint | 34 + test/rules/no-any/default/tslint.json | 5 + .../no-any/ignore-rest-args/test.ts.lint | 38 + .../rules/no-any/ignore-rest-args/tslint.json | 5 + test/rules/no-arg/test.ts.lint | 12 + test/rules/no-arg/tslint.json | 5 + .../rules/no-async-without-await/test.ts.lint | 165 ++++ test/rules/no-async-without-await/tslint.json | 5 + test/rules/no-bitwise/test.ts.lint | 6 + test/rules/no-bitwise/tslint.json | 5 + .../no-boolean-literal-compare/test.ts.fix | 30 + .../no-boolean-literal-compare/test.ts.lint | 45 + .../no-boolean-literal-compare/tsconfig.json | 5 + .../no-boolean-literal-compare/tslint.json | 5 + .../no-conditional-assignment/test.ts.lint | 79 ++ .../no-conditional-assignment/tslint.json | 5 + .../default/test.ts.fix | 27 + .../default/test.ts.lint | 42 + .../default/tslint.json | 5 + .../invalid-option/test.ts.lint | 30 + .../invalid-option/tslint.json | 5 + .../multiple/test.ts.fix | 28 + .../multiple/test.ts.lint | 40 + .../multiple/tslint.json | 5 + test/rules/no-console/all/test.ts.lint | 22 + test/rules/no-console/all/tslint.json | 5 + test/rules/no-console/list/test.ts.lint | 13 + test/rules/no-console/list/tslint.json | 5 + test/rules/no-construct/test.ts.lint | 13 + test/rules/no-construct/tslint.json | 5 + test/rules/no-debugger/test.ts.lint | 8 + test/rules/no-debugger/tslint.json | 5 + test/rules/no-default-export/test.ts.lint | 46 + test/rules/no-default-export/tslint.json | 5 + .../no-default-import/default/test.ts.lint | 36 + .../no-default-import/default/tslint.json | 5 + .../fromModules/test.ts.lint | 24 + .../no-default-import/fromModules/tslint.json | 10 + .../allow-namespace-imports/test.d.ts.lint | 6 + .../allow-namespace-imports/test.ts.lint | 14 + .../allow-namespace-imports/tslint.json | 10 + .../default/test.d.ts.lint | 7 + .../no-duplicate-imports/default/test.ts.lint | 20 + .../default/test2.d.ts.lint | 8 + .../default/test3.d.ts.lint | 11 + .../no-duplicate-imports/default/tslint.json | 5 + test/rules/no-duplicate-super/test.ts.lint | 280 ++++++ test/rules/no-duplicate-super/tslint.json | 5 + .../no-duplicate-switch-case/test.ts.lint | 82 ++ .../no-duplicate-switch-case/tslint.json | 5 + .../check-parameters/test.ts.lint | 180 ++++ .../check-parameters/tslint.json | 5 + .../default/test.ts.lint | 177 ++++ .../no-duplicate-variable/default/tslint.json | 5 + test/rules/no-dynamic-delete/test.ts.fix | 19 + test/rules/no-dynamic-delete/test.ts.lint | 29 + test/rules/no-dynamic-delete/tslint.json | 5 + test/rules/no-empty-interface/test.ts.lint | 14 + test/rules/no-empty-interface/tslint.json | 5 + .../no-empty/allow-empty-catch/test.ts.lint | 86 ++ .../no-empty/allow-empty-catch/tslint.json | 5 + .../allow-empty-functions/test.ts.lint | 81 ++ .../allow-empty-functions/tslint.json | 5 + test/rules/no-empty/default/test.ts.lint | 87 ++ test/rules/no-empty/default/tslint.json | 5 + test/rules/no-eval/test.ts.lint | 10 + test/rules/no-eval/tslint.json | 5 + .../jquerypromise/test.ts.lint | 17 + .../jquerypromise/tsconfig.json | 5 + .../jquerypromise/tslint.json | 5 + .../promises/test.ts.lint | 161 +++ .../promises/tsconfig.json | 5 + .../no-floating-promises/promises/tslint.json | 5 + test/rules/no-for-in-array/test.ts.lint | 45 + test/rules/no-for-in-array/tsconfig.json | 5 + test/rules/no-for-in-array/tslint.json | 5 + test/rules/no-for-in/test.ts.lint | 20 + test/rules/no-for-in/tslint.json | 5 + .../default/bom/package.json | 5 + .../default/bom/test.ts.lint | 2 + .../default/builtin-only.ts.lint | 4 + .../default/malformed/package.json | 3 + .../default/malformed/tets.ts.lint | 2 + .../default/nested-package/package.json | 7 + .../default/nested-package/test.ts.lint | 24 + .../default/subdir/test.ts.lint | 26 + .../default/test.js.lint | 10 + .../default/test.ts.lint | 24 + .../default/tslint.json | 8 + .../no-implicit-dependencies/dev/test.ts.lint | 14 + .../no-implicit-dependencies/dev/tslint.json | 5 + .../optional/test.ts.lint | 13 + .../optional/tslint.json | 5 + .../no-implicit-dependencies/package.json | 19 + .../whitelist-with-dev/test.ts.lint | 10 + .../whitelist-with-dev/tslint.json | 5 + .../whitelist/test.ts.lint | 20 + .../whitelist/tslint.json | 5 + .../default/test.ts.lint | 22 + .../no-import-side-effect/default/tslint.json | 5 + .../ignore-module/test.ts.lint | 18 + .../ignore-module/tslint.json | 10 + .../no-inferrable-types/default/test.ts.fix | 35 + .../no-inferrable-types/default/test.ts.lint | 51 + .../no-inferrable-types/default/tslint.json | 5 + .../ignore-params/test.ts.fix | 34 + .../ignore-params/test.ts.lint | 43 + .../ignore-params/tslint.json | 8 + .../ignore-properties/test.ts.fix | 33 + .../ignore-properties/test.ts.lint | 42 + .../ignore-properties/tslint.json | 5 + .../test.ts.lint | 92 ++ .../tsconfig.json | 5 + .../no-inferred-empty-object-type/tslint.json | 5 + test/rules/no-internal-module/test.ts.fix | 62 ++ test/rules/no-internal-module/test.ts.lint | 76 ++ test/rules/no-internal-module/tslint.json | 5 + .../no-invalid-template-strings/test.ts.lint | 41 + .../no-invalid-template-strings/tslint.json | 5 + .../no-invalid-this/enabled/test.ts.lint | 118 +++ .../rules/no-invalid-this/enabled/tslint.json | 8 + .../no-irregular-whitespace/test.builder.ts | 41 + .../rules/no-irregular-whitespace/test.ts.fix | 22 + .../no-irregular-whitespace/test.ts.lint | 44 + .../rules/no-irregular-whitespace/tslint.json | 5 + .../allowed-numbers/test.ts.lint | 23 + .../allowed-numbers/tslint.json | 7 + .../no-magic-numbers/custom/test.ts.lint | 23 + .../rules/no-magic-numbers/custom/tslint.json | 5 + .../default-jsx/test.tsx.lint | 8 + .../no-magic-numbers/default-jsx/tslint.json | 5 + .../no-magic-numbers/default/test.ts.lint | 48 + .../no-magic-numbers/default/tslint.json | 5 + .../no-magic-numbers/ignore-jsx/test.tsx.lint | 10 + .../no-magic-numbers/ignore-jsx/tslint.json | 7 + .../rules/no-mergeable-namespace/test.ts.lint | 41 + test/rules/no-mergeable-namespace/tslint.json | 5 + test/rules/no-misused-new/test.ts.lint | 32 + test/rules/no-misused-new/tslint.json | 5 + .../allow-declarations/test.d.ts.lint | 1 + .../allow-declarations/test.ts.lint | 8 + .../allow-declarations/tslint.json | 5 + .../rules/no-namespace/default/test.d.ts.lint | 2 + test/rules/no-namespace/default/test.ts.lint | 25 + test/rules/no-namespace/default/tslint.json | 5 + test/rules/no-non-null-assertion/test.ts.lint | 4 + test/rules/no-non-null-assertion/tslint.json | 5 + test/rules/no-null-keyword/test.ts.fix | 12 + test/rules/no-null-keyword/test.ts.lint | 18 + test/rules/no-null-keyword/tslint.json | 5 + .../no-null-undefined-union/test.ts.lint | 85 ++ .../no-null-undefined-union/ts350.ts.lint | 12 + .../no-null-undefined-union/tsconfig.json | 19 + .../rules/no-null-undefined-union/tslint.json | 5 + .../allow-arguments/test.ts.lint | 23 + .../allow-arguments/tslint.json | 5 + .../default/test.ts.lint | 31 + .../default/tslint.json | 5 + .../no-parameter-properties/test.ts.lint | 24 + .../rules/no-parameter-properties/tslint.json | 5 + .../no-parameter-reassignment/test.ts.lint | 34 + .../no-parameter-reassignment/tslint.json | 5 + .../custom-promise/test.ts.lint | 37 + .../custom-promise/tsconfig.json | 6 + .../custom-promise/tslint.json | 5 + .../es6-promise/test.ts.lint | 66 ++ .../es6-promise/tsconfig.json | 6 + .../es6-promise/tslint.json | 5 + test/rules/no-redundant-jsdoc/test.ts.lint | 59 ++ test/rules/no-redundant-jsdoc/tslint.json | 5 + test/rules/no-reference-import/test.d.ts.lint | 12 + .../rules/no-reference-import/ts240.d.ts.lint | 12 + test/rules/no-reference-import/tslint.json | 5 + test/rules/no-reference/test.ts.lint | 3 + test/rules/no-reference/ts240.ts.lint | 3 + test/rules/no-reference/tslint.json | 5 + test/rules/no-require-imports/test.ts.lint | 24 + test/rules/no-require-imports/tslint.json | 5 + .../no-restricted-globals/custom-global.d.ts | 2 + test/rules/no-restricted-globals/foo.d.ts | 1 + .../no-restricted-globals/namespace.ts.lint | 10 + test/rules/no-restricted-globals/test.ts.lint | 75 ++ .../rules/no-restricted-globals/tsconfig.json | 8 + test/rules/no-restricted-globals/tslint.json | 11 + test/rules/no-return-await/test.ts.fix | 80 ++ test/rules/no-return-await/test.ts.lint | 94 ++ test/rules/no-return-await/tslint.json | 5 + .../default/ambient.d.ts.lint | 7 + .../no-shadowed-variable/default/test.ts.lint | 384 ++++++++ .../no-shadowed-variable/default/tslint.json | 5 + .../ignore-class/test.ts.lint | 16 + .../ignore-class/tslint.json | 5 + .../ignore-import/test.ts.lint | 13 + .../ignore-import/tslint.json | 5 + .../ignore-underscore/test.ts.lint | 10 + .../ignore-underscore/tslint.json | 5 + .../temporal-dead-zone/test.ts.lint | 89 ++ .../temporal-dead-zone/tslint.json | 10 + test/rules/no-sparse-arrays/test.ts.lint | 24 + test/rules/no-sparse-arrays/tslint.json | 5 + test/rules/no-string-literal/test.ts.fix | 29 + test/rules/no-string-literal/test.ts.lint | 36 + test/rules/no-string-literal/tslint.json | 5 + test/rules/no-string-throw/test.ts.fix | 30 + test/rules/no-string-throw/test.ts.lint | 42 + test/rules/no-string-throw/tslint.json | 5 + .../dynamic-imports/test.ts.lint | 28 + .../dynamic-imports/tslint.json | 5 + .../static-imports/test.ts.lint | 73 ++ .../static-imports/tslint.json | 5 + .../no-switch-case-fall-through/test.ts.lint | 144 +++ .../no-switch-case-fall-through/tslint.json | 5 + .../no-tautology-expression/test.ts.lint | 159 +++ .../rules/no-tautology-expression/tslint.json | 5 + .../allow-destructuring/test.ts.lint | 13 + .../allow-destructuring/tslint.json | 7 + .../allowed-names/test.ts.lint | 8 + .../allowed-names/tslint.json | 7 + .../no-this-assignment/default/test.ts.lint | 46 + .../no-this-assignment/default/tslint.json | 5 + .../default/test.ts.fix | 33 + .../default/test.ts.lint | 49 + .../default/tslint.json | 5 + .../ignore-comments/test.ts.fix | 30 + .../ignore-comments/test.ts.lint | 38 + .../ignore-comments/tslint.json | 5 + .../ignore-jsdoc/test.ts.fix | 30 + .../ignore-jsdoc/test.ts.lint | 42 + .../ignore-jsdoc/tslint.json | 5 + .../ignore-template-strings/test.ts.fix | 33 + .../ignore-template-strings/test.ts.lint | 47 + .../ignore-template-strings/tslint.json | 8 + .../skip-blank-lines/test.ts.fix | 34 + .../skip-blank-lines/test.ts.lint | 46 + .../skip-blank-lines/tslint.json | 5 + .../zero-width-no-break-space/test.ts.lint | 4 + .../zero-width-no-break-space/test2.ts.lint | 5 + .../zero-width-no-break-space/tslint.json | 5 + .../no-unbound-method/default/test.ts.lint | 14 + .../no-unbound-method/default/test.tsx.lint | 68 ++ .../no-unbound-method/default/tsconfig.json | 5 + .../no-unbound-method/default/tslint.json | 5 + .../ignore-static/test.tsx.lint | 46 + .../ignore-static/tsconfig.json | 5 + .../ignore-static/tslint.json | 8 + .../no-unbound-method/whitelist/test.tsx.lint | 80 ++ .../no-unbound-method/whitelist/tsconfig.json | 5 + .../no-unbound-method/whitelist/tslint.json | 8 + .../test.ts.fix | 27 + .../test.ts.lint | 32 + .../tslint.json | 5 + .../allow-constructor-only/test.ts.lint | 156 +++ .../allow-constructor-only/tslint.json | 5 + .../allow-empty/test.ts.lint | 151 +++ .../allow-empty/tslint.json | 5 + .../allow-static-only/test.ts.lint | 136 +++ .../allow-static-only/tslint.json | 5 + .../no-unnecessary-class/default/test.ts.lint | 146 +++ .../no-unnecessary-class/default/tslint.json | 5 + .../no-unnecessary-initializer/test.ts.fix | 18 + .../no-unnecessary-initializer/test.ts.lint | 28 + .../no-unnecessary-initializer/tslint.json | 5 + .../arguments.ts.lint | 12 + test/rules/no-unnecessary-qualifier/b.test.ts | 1 + .../test-global-2.ts.lint | 4 + .../test-global.ts.fix | 5 + .../test-global.ts.lint | 6 + .../no-unnecessary-qualifier/test.ts.fix | 41 + .../no-unnecessary-qualifier/test.ts.lint | 54 ++ .../no-unnecessary-qualifier/tsconfig.json | 5 + .../no-unnecessary-qualifier/tslint.json | 5 + .../noStrictNullChecks/test.ts.lint | 6 + .../noStrictNullChecks/tsconfig.json | 1 + .../noStrictNullChecks/tslint.json | 5 + .../strict/test.ts.fix | 104 ++ .../strict/test.ts.lint | 125 +++ .../strict/tsconfig.json | 6 + .../strict/tslint.json | 5 + .../strictNullChecks/test.ts.fix | 104 ++ .../strictNullChecks/test.ts.lint | 124 +++ .../strictNullChecks/tsconfig.json | 6 + .../strictNullChecks/tslint.json | 5 + .../no-unsafe-any/default/commonjsModule.ts | 3 + test/rules/no-unsafe-any/default/es6Module.ts | 8 + test/rules/no-unsafe-any/default/test.ts.lint | 348 +++++++ .../rules/no-unsafe-any/default/tsconfig.json | 7 + test/rules/no-unsafe-any/default/tslint.json | 5 + test/rules/no-unsafe-any/jsx/test.tsx.lint | 15 + test/rules/no-unsafe-any/jsx/tsconfig.json | 8 + test/rules/no-unsafe-any/jsx/tslint.json | 5 + test/rules/no-unsafe-any/unknown/test.ts.lint | 83 ++ .../rules/no-unsafe-any/unknown/tsconfig.json | 7 + test/rules/no-unsafe-any/unknown/tslint.json | 5 + test/rules/no-unsafe-finally/test.ts.lint | 376 ++++++++ test/rules/no-unsafe-finally/tslint.json | 5 + .../allow-fast-null-checks/test.ts.lint | 143 +++ .../allow-fast-null-checks/tslint.json | 5 + .../allow-new/test.ts.lint | 145 +++ .../allow-new/tslint.json | 9 + .../allow-tagged-template/test.ts.lint | 194 ++++ .../allow-tagged-template/tslint.json | 8 + .../no-unused-expression/default/test.ts.lint | 226 +++++ .../no-unused-expression/default/tslint.json | 5 + .../check-parameters/test.ts.lint | 88 ++ .../check-parameters/tsconfig.json | 5 + .../check-parameters/tslint.json | 5 + .../no-unused-variable/default/class.ts.lint | 31 + .../default/false-positives.ts.lint | 69 ++ .../default/function.ts.lint | 39 + .../no-unused-variable/default/import.ts.fix | 53 + .../no-unused-variable/default/import.ts.lint | 91 ++ .../default/node_modules/a.ts | 2 + .../default/node_modules/react.ts | 1 + .../default/node_modules/react/addons.ts | 1 + .../default/react-addons1.tsx.lint | 5 + .../default/react-addons2.tsx.lint | 4 + .../default/react-addons3.tsx.lint | 7 + .../default/react1.tsx.lint | 5 + .../default/react2.tsx.lint | 4 + .../default/react3.tsx.lint | 7 + .../default/react4.tsx.lint | 7 + .../no-unused-variable/default/tsconfig.json | 5 + .../no-unused-variable/default/tslint.json | 5 + .../no-unused-variable/default/var.ts.lint | 92 ++ .../ignore-pattern/a.test.ts | 1 + .../ignore-pattern/tsconfig.json | 5 + .../ignore-pattern/tslint.json | 5 + .../ignore-pattern/var.ts.lint | 107 ++ .../no-unused-variable/type-checked/a.test.ts | 2 + .../type-checked/destructuring.ts.lint | 15 + .../type-checked/some.test.ts | 3 + .../type-checked/test.ts.lint | 6 + .../type-checked/tsconfig.json | 5 + .../type-checked/tslint.json | 5 + test/rules/no-use-before-declare/$.ts | 0 .../ImportAliasSecond.ts | 0 .../ImportAliasWithComment.ts | 0 .../ImportRegularAlias.ts | 0 .../ImportWithLineBreaks.ts | 0 .../no-use-before-declare/InterfaceFile.ts | 0 test/rules/no-use-before-declare/lib.ts | 0 test/rules/no-use-before-declare/test.ts.lint | 105 ++ .../rules/no-use-before-declare/tsconfig.json | 5 + test/rules/no-use-before-declare/tslint.json | 5 + .../rules/no-use-before-declare/underscore.ts | 0 test/rules/no-var-keyword/global.d.ts.lint | 8 + test/rules/no-var-keyword/module.d.ts.lint | 17 + test/rules/no-var-keyword/test.ts.fix | 44 + test/rules/no-var-keyword/test.ts.lint | 56 ++ test/rules/no-var-keyword/tslint.json | 5 + test/rules/no-var-requires/test.ts.lint | 3 + test/rules/no-var-requires/tslint.json | 5 + .../no-void-expression/default/test.ts.lint | 29 + .../no-void-expression/default/tsconfig.json | 6 + .../no-void-expression/default/tslint.json | 5 + .../test.ts.lint | 10 + .../tsconfig.json | 5 + .../tslint.json | 5 + test/rules/number-literal-format/test.ts.fix | 47 + test/rules/number-literal-format/test.ts.lint | 77 ++ test/rules/number-literal-format/tslint.json | 5 + .../always/test.ts.fix | 20 + .../always/test.ts.lint | 26 + .../always/tslint.json | 5 + .../as-needed/test.ts.fix | 23 + .../as-needed/test.ts.lint | 27 + .../as-needed/tslint.json | 5 + .../consistent-as-needed/test.ts.fix | 43 + .../consistent-as-needed/test.ts.lint | 52 + .../consistent-as-needed/tslint.json | 5 + .../consistent/test.ts.lint | 43 + .../consistent/tslint.json | 5 + .../always/test.ts.fix | 43 + .../always/test.ts.lint | 55 ++ .../always/tslint.json | 5 + .../never/test.ts.fix | 59 ++ .../never/test.ts.lint | 72 ++ .../never/tslint.json | 6 + .../onlyMethods/test.ts.fix | 45 + .../onlyMethods/test.ts.lint | 58 ++ .../onlyMethods/tslint.json | 11 + .../default/crlf.ts.lint | 6 + .../default/test.ts.lint | 319 ++++++ .../default/tslint.json | 5 + .../ignore-blank-lines/test.ts.lint | 26 + .../ignore-blank-lines/tslint.json | 5 + .../ignore-case/test.ts.lint | 12 + .../ignore-case/tslint.json | 5 + .../locale-compare/test.ts.lint | 12 + .../locale-compare/tslint.json | 5 + .../match-declaration-order-only/test.ts.lint | 71 ++ .../tsconfig.json | 1 + .../match-declaration-order-only/tslint.json | 5 + .../match-declaration-order/test.ts.lint | 72 ++ .../match-declaration-order/tsconfig.json | 1 + .../match-declaration-order/tslint.json | 5 + .../shorthand-first/test.ts.lint | 79 ++ .../shorthand-first/tslint.json | 5 + test/rules/one-line/all/test.ts.fix | 152 +++ test/rules/one-line/all/test.ts.lint | 197 ++++ test/rules/one-line/all/tslint.json | 5 + test/rules/one-line/no-whitespace/test.ts.fix | 132 +++ .../rules/one-line/no-whitespace/test.ts.lint | 170 ++++ test/rules/one-line/no-whitespace/tslint.json | 5 + test/rules/one-line/none/test.ts.lint | 130 +++ test/rules/one-line/none/tslint.json | 5 + .../default/test.ts.lint | 45 + .../default/tslint.json | 5 + .../ignore-for-loop/test.ts.lint | 30 + .../ignore-for-loop/tslint.json | 7 + .../allow-declarations/test.ts.lint | 26 + .../allow-declarations/tslint.json | 5 + .../allow-named-functions/test.ts.lint | 7 + .../allow-named-functions/tslint.json | 5 + .../only-arrow-functions/default/test.ts.lint | 47 + .../only-arrow-functions/default/tslint.json | 5 + .../case-insensitive-legacy/test.ts.fix | 48 + .../case-insensitive-legacy/test.ts.lint | 61 ++ .../case-insensitive-legacy/tslint.json | 11 + .../case-insensitive/test.ts.fix | 48 + .../case-insensitive/test.ts.lint | 61 ++ .../case-insensitive/tslint.json | 5 + .../grouped-imports/test.ts.fix | 13 + .../grouped-imports/test.ts.lint | 18 + .../grouped-imports/tslint.json | 10 + .../groups-complex/test.ts.fix | 24 + .../groups-complex/test.ts.lint | 30 + .../groups-complex/tslint.json | 19 + .../groups-shared-order/test.ts.fix | 13 + .../groups-shared-order/test.ts.lint | 18 + .../groups-shared-order/tslint.json | 17 + .../groups-string-list/test.ts.fix | 18 + .../groups-string-list/test.ts.lint | 20 + .../groups-string-list/tslint.json | 13 + .../groups-unmatched/test.ts.fix | 14 + .../groups-unmatched/test.ts.lint | 18 + .../groups-unmatched/tslint.json | 13 + .../import-sources-any/default/test.ts.fix | 31 + .../import-sources-any/default/test.ts.lint | 35 + .../import-sources-any/default/tslint.json | 5 + .../grouped-imports/test.ts.fix | 4 + .../grouped-imports/test.ts.lint | 5 + .../grouped-imports/tslint.json | 5 + .../inside-module-declaration/test.ts.lint | 7 + .../inside-module-declaration/tslint.json | 5 + .../lowercase-first/test.ts.fix | 31 + .../lowercase-first/test.ts.lint | 40 + .../lowercase-first/tslint.json | 5 + .../module-source-path/test.ts.fix | 19 + .../module-source-path/test.ts.lint | 23 + .../module-source-path/tslint.json | 5 + .../named-imports-any/test.ts.fix | 42 + .../named-imports-any/test.ts.lint | 52 + .../named-imports-any/tslint.json | 5 + .../standalone-grouped-import/test.ts.fix | 10 + .../standalone-grouped-import/test.ts.lint | 13 + .../standalone-grouped-import/tslint.json | 10 + .../check-else-if/test.ts.lint | 106 ++ .../check-else-if/tslint.json | 5 + .../default/test.ts.lint | 95 ++ .../default/tslint.json | 5 + .../prefer-const/default/ambient.d.ts.lint | 5 + .../rules/prefer-const/default/global.ts.lint | 17 + .../rules/prefer-const/default/spread.ts.lint | 24 + test/rules/prefer-const/default/test.ts.fix | 228 +++++ test/rules/prefer-const/default/test.ts.lint | 270 ++++++ test/rules/prefer-const/default/tslint.json | 5 + .../destructuring-all/test.ts.fix | 28 + .../destructuring-all/test.ts.lint | 34 + .../destructuring-all/tslint.json | 8 + test/rules/prefer-for-of/test.ts.lint | 197 ++++ test/rules/prefer-for-of/tslint.json | 5 + .../allow-protected/test.ts.lint | 9 + .../allow-protected/tslint.json | 5 + .../allow-public-and-protected/test.ts.lint | 8 + .../allow-public-and-protected/tslint.json | 5 + .../allow-public/test.ts.lint | 9 + .../allow-public/tslint.json | 5 + .../default/test.ts.lint | 66 ++ .../default/tslint.json | 5 + .../rules/prefer-method-signature/test.ts.fix | 18 + .../prefer-method-signature/test.ts.lint | 25 + .../rules/prefer-method-signature/tslint.json | 5 + test/rules/prefer-object-spread/test.ts.fix | 30 + test/rules/prefer-object-spread/test.ts.lint | 46 + test/rules/prefer-object-spread/tslint.json | 5 + .../rules/prefer-readonly/default/test.ts.fix | 155 +++ .../prefer-readonly/default/test.ts.lint | 169 ++++ .../prefer-readonly/default/tsconfig.json | 5 + .../rules/prefer-readonly/default/tslint.json | 5 + .../only-inline-lambdas/test.ts.fix | 28 + .../only-inline-lambdas/test.ts.lint | 29 + .../only-inline-lambdas/tsconfig.json | 5 + .../only-inline-lambdas/tslint.json | 5 + test/rules/prefer-switch/default/test.ts.lint | 79 ++ test/rules/prefer-switch/default/tslint.json | 5 + .../prefer-switch/min-cases-2/test.ts.lint | 52 + .../prefer-switch/min-cases-2/tslint.json | 7 + .../allow-single-concat/test.ts.lint | 37 + .../allow-single-concat/tslint.json | 5 + .../prefer-template/default/test.ts.lint | 39 + .../rules/prefer-template/default/tslint.json | 5 + test/rules/prefer-while/test.ts.fix | 24 + test/rules/prefer-while/test.ts.lint | 26 + test/rules/prefer-while/tslint.json | 5 + .../rules/promise-function-async/test.ts.lint | 74 ++ .../promise-function-async/tsconfig.json | 5 + test/rules/promise-function-async/tslint.json | 5 + .../backtick/test-post-2.7.1-syntax.ts.fix | 13 + .../backtick/test-post-2.7.1-syntax.ts.lint | 21 + .../backtick/test-pre-2.7.1-syntax.ts.fix | 11 + .../backtick/test-pre-2.7.1-syntax.ts.lint | 15 + test/rules/quotemark/backtick/test.ts.fix | 80 ++ test/rules/quotemark/backtick/test.ts.lint | 99 ++ test/rules/quotemark/backtick/tslint.json | 5 + .../quotemark/double-avoid-escape/test.ts.fix | 5 + .../double-avoid-escape/test.ts.lint | 7 + .../quotemark/double-avoid-escape/tslint.json | 5 + .../double-avoid-template/test.ts.fix | 20 + .../double-avoid-template/test.ts.lint | 26 + .../double-avoid-template/tslint.json | 5 + test/rules/quotemark/double/test.ts.fix | 9 + test/rules/quotemark/double/test.ts.lint | 13 + test/rules/quotemark/double/tslint.json | 5 + .../quotemark/invalid-double/test.ts.fix | 2 + .../quotemark/invalid-double/test.ts.lint | 3 + .../quotemark/invalid-double/tslint.json | 5 + .../quotemark/invalid-single/test.ts.fix | 2 + .../quotemark/invalid-single/test.ts.lint | 3 + .../quotemark/invalid-single/tslint.json | 5 + test/rules/quotemark/jsx-double/test.tsx.fix | 4 + test/rules/quotemark/jsx-double/test.tsx.lint | 8 + test/rules/quotemark/jsx-double/tslint.json | 5 + test/rules/quotemark/jsx-single/test.tsx.fix | 4 + test/rules/quotemark/jsx-single/test.tsx.lint | 7 + test/rules/quotemark/jsx-single/tslint.json | 5 + .../quotemark/single-avoid-escape/test.ts.fix | 5 + .../single-avoid-escape/test.ts.lint | 7 + .../quotemark/single-avoid-escape/tslint.json | 5 + .../single-avoid-template/test.ts.fix | 20 + .../single-avoid-template/test.ts.lint | 26 + .../single-avoid-template/tslint.json | 5 + test/rules/quotemark/single/test.ts.fix | 6 + test/rules/quotemark/single/test.ts.lint | 10 + test/rules/quotemark/single/test.tsx.lint | 2 + test/rules/quotemark/single/tslint.json | 5 + test/rules/radix/test.ts.lint | 28 + test/rules/radix/tslint.json | 5 + .../default/test.ts.lint | 68 ++ .../default/tsconfig.json | 5 + .../default/tslint.json | 5 + .../esnext-bigint/test.ts.lint | 42 + .../esnext-bigint/tsconfig.json | 5 + .../esnext-bigint/tslint.json | 5 + .../return-undefined/default/test.ts.lint | 92 ++ .../return-undefined/default/tsconfig.json | 5 + .../return-undefined/default/tslint.json | 5 + .../return-undefined/pre-ts-3.6/test.ts.lint | 9 + .../return-undefined/pre-ts-3.6/tsconfig.json | 5 + .../return-undefined/pre-ts-3.6/tslint.json | 5 + test/rules/semicolon/always/test.ts.fix | 96 ++ test/rules/semicolon/always/test.ts.lint | 131 +++ test/rules/semicolon/always/tslint.json | 5 + test/rules/semicolon/enabled/test.ts.fix | 87 ++ test/rules/semicolon/enabled/test.ts.lint | 116 +++ test/rules/semicolon/enabled/tslint.json | 5 + .../ignore-bound-class-methods/test.ts.fix | 83 ++ .../ignore-bound-class-methods/test.ts.lint | 111 +++ .../ignore-bound-class-methods/tslint.json | 5 + .../semicolon/ignore-interfaces/test.ts.fix | 83 ++ .../semicolon/ignore-interfaces/test.ts.lint | 109 +++ .../semicolon/ignore-interfaces/tslint.json | 5 + test/rules/semicolon/never/eof1.ts.lint | 2 + test/rules/semicolon/never/eof2.ts.lint | 2 + test/rules/semicolon/never/test.ts.fix | 227 +++++ test/rules/semicolon/never/test.ts.lint | 281 ++++++ test/rules/semicolon/never/tslint.json | 5 + .../strict-bound-class-methods/test.ts.fix | 22 + .../strict-bound-class-methods/test.ts.lint | 27 + .../strict-bound-class-methods/tslint.json | 5 + .../always/test.ts.fix | 75 ++ .../always/test.ts.lint | 104 ++ .../always/tslint.json | 5 + .../mixed/test.ts.fix | 65 ++ .../mixed/test.ts.lint | 89 ++ .../mixed/tslint.json | 14 + .../never/test.ts.fix | 76 ++ .../never/test.ts.lint | 107 ++ .../never/tslint.json | 5 + .../force-one-space/test.ts.fix | 11 + .../force-one-space/test.ts.lint | 21 + .../force-one-space/tslint.json | 5 + .../force-two-spaces/test.ts.fix | 28 + .../force-two-spaces/test.ts.lint | 42 + .../force-two-spaces/tslint.json | 5 + .../space-within-parens/no-space/test.ts.fix | 37 + .../space-within-parens/no-space/test.ts.lint | 50 + .../space-within-parens/no-space/tslint.json | 5 + test/rules/static-this/test.ts.fix | 77 ++ test/rules/static-this/test.ts.lint | 87 ++ test/rules/static-this/tslint.json | 5 + .../test.ts.lint | 36 + .../tsconfig.json | 5 + .../allow-boolean-undefined-union/tslint.json | 5 + .../allow-enum/test.ts.lint | 6 + .../allow-enum/tsconfig.json | 5 + .../allow-enum/tslint.json | 5 + .../allow-mix/test.ts.lint | 20 + .../allow-mix/tsconfig.json | 5 + .../allow-mix/tslint.json | 5 + .../allow-null-union/test.ts.lint | 12 + .../allow-null-union/tsconfig.json | 5 + .../allow-null-union/tslint.json | 5 + .../allow-number/test.ts.lint | 19 + .../allow-number/tsconfig.json | 5 + .../allow-number/tslint.json | 5 + .../allow-string/test.ts.lint | 14 + .../allow-string/tsconfig.json | 5 + .../allow-string/tslint.json | 5 + .../allow-undefined-union/test.ts.lint | 28 + .../allow-undefined-union/tsconfig.json | 5 + .../allow-undefined-union/tslint.json | 5 + .../default/test.ts.lint | 235 +++++ .../default/tsconfig.json | 5 + .../default/tslint.json | 5 + .../ignore-rhs/test.ts.lint | 78 ++ .../ignore-rhs/tsconfig.json | 5 + .../ignore-rhs/tslint.json | 5 + .../no-allow-mix/test.ts.lint | 28 + .../no-allow-mix/tsconfig.json | 5 + .../no-allow-mix/tslint.json | 5 + .../test.ts.lint | 17 + .../tsconfig.json | 6 + .../tslint.json | 5 + .../test.ts.lint | 9 + .../tsconfig.json | 5 + .../tslint.json | 5 + .../no-null-checks/test.ts.lint | 17 + .../no-null-checks/tsconfig.json | 5 + .../no-null-checks/tslint.json | 5 + .../test.ts.lint | 182 ++++ .../tsconfig.json | 5 + .../allow-object-equal-comparison/tslint.json | 10 + .../test.ts.lint | 178 ++++ .../tsconfig.json | 5 + .../allow-string-order-comparison/tslint.json | 10 + .../strict-comparisons/default/test.ts.lint | 190 ++++ .../strict-comparisons/default/tsconfig.json | 5 + .../strict-comparisons/default/tslint.json | 5 + .../allow-empty-types/test.ts.fix | 133 +++ .../allow-empty-types/test.ts.lint | 145 +++ .../allow-empty-types/tsconfig.json | 4 + .../allow-empty-types/tslint.json | 10 + .../disallow-empty-types/test.ts.fix | 133 +++ .../disallow-empty-types/test.ts.lint | 151 +++ .../disallow-empty-types/tsconfig.json | 5 + .../disallow-empty-types/tslint.json | 10 + .../no-strict-null-checks/test.ts.lint | 156 +++ .../no-strict-null-checks/tsconfig.json | 5 + .../no-strict-null-checks/tslint.json | 5 + .../strict-null-checks/test.ts.lint | 215 +++++ .../strict-null-checks/tsconfig.json | 5 + .../strict-null-checks/tslint.json | 5 + .../unknown/test.ts.lint | 42 + .../unknown/tsconfig.json | 5 + .../unknown/tslint.json | 5 + test/rules/switch-default/test.ts.lint | 74 ++ test/rules/switch-default/tslint.json | 5 + .../switch-final-break/always/test.ts.fix | 49 + .../switch-final-break/always/test.ts.lint | 51 + .../switch-final-break/always/tslint.json | 5 + .../switch-final-break/default/test.ts.fix | 61 ++ .../switch-final-break/default/test.ts.lint | 70 ++ .../switch-final-break/default/tslint.json | 5 + .../multiline-always/test.ts.fix | 602 ++++++++++++ .../multiline-always/test.ts.lint | 636 ++++++++++++ .../multiline-always/tslint.json | 5 + .../multiline-custom/always/test.ts.lint | 578 +++++++++++ .../multiline-custom/always/tslint.json | 17 + .../multiline-custom/ignore/test.ts.lint | 549 +++++++++++ .../multiline-custom/ignore/tslint.json | 17 + .../multiline-custom/mixed/test.ts.lint | 78 ++ .../multiline-custom/mixed/tslint.json | 17 + .../multiline-custom/never/test.ts.fix | 498 ++++++++++ .../multiline-custom/never/test.ts.lint | 527 ++++++++++ .../multiline-custom/never/tslint.json | 17 + .../multiline-never/test.ts.fix | 545 +++++++++++ .../multiline-never/test.ts.lint | 579 +++++++++++ .../multiline-never/tslint.json | 5 + .../singleline-always/test.ts.fix | 597 ++++++++++++ .../singleline-always/test.ts.lint | 629 ++++++++++++ .../singleline-always/tslint.json | 5 + .../singleline-custom/always/test.ts.fix | 540 +++++++++++ .../singleline-custom/always/test.ts.lint | 565 +++++++++++ .../singleline-custom/always/tslint.json | 17 + .../singleline-custom/ignore/test.ts.lint | 540 +++++++++++ .../singleline-custom/ignore/tslint.json | 17 + .../singleline-custom/mixed/test.ts.lint | 28 + .../singleline-custom/mixed/tslint.json | 17 + .../singleline-custom/never/test.ts.fix | 500 ++++++++++ .../singleline-custom/never/test.ts.lint | 523 ++++++++++ .../singleline-custom/never/tslint.json | 17 + .../singleline-never/test.ts.fix | 550 +++++++++++ .../singleline-never/test.ts.lint | 578 +++++++++++ .../singleline-never/tslint.json | 5 + .../trailing-comma/spec-compliant/test.ts.fix | 66 ++ .../spec-compliant/test.ts.lint | 83 ++ .../trailing-comma/spec-compliant/tslint.json | 12 + .../allow-null-check/test.ts.lint | 19 + .../allow-null-check/tslint.json | 5 + .../allow-undefined-check/test.ts.lint | 19 + .../allow-undefined-check/tslint.json | 5 + .../one-liners-with-no-trailings/test.ts.fix | 21 + .../one-liners-with-no-trailings/test.ts.lint | 30 + .../one-liners-with-no-trailings/tslint.json | 5 + .../one-liners-with-trailings/test.ts.fix | 21 + .../one-liners-with-trailings/test.ts.lint | 31 + .../one-liners-with-trailings/tslint.json | 10 + .../both/nospace/test.ts.lint | 905 +++++++++++++++++ .../both/nospace/tslint.json | 18 + .../both/onespace/test.ts.lint | 913 ++++++++++++++++++ .../both/onespace/tslint.json | 18 + .../both/space/test.ts.lint | 767 +++++++++++++++ .../typedef-whitespace/both/space/tslint.json | 18 + .../left/nospace/test.ts.lint | 745 ++++++++++++++ .../left/nospace/tslint.json | 11 + .../left/onespace/test.ts.lint | 762 +++++++++++++++ .../left/onespace/tslint.json | 11 + .../left/space/test.ts.lint | 689 +++++++++++++ .../typedef-whitespace/left/space/tslint.json | 11 + .../typedef-whitespace/none/test.ts.lint | 527 ++++++++++ .../rules/typedef-whitespace/none/tslint.json | 5 + .../right/nospace/test.ts.lint | 745 ++++++++++++++ .../right/nospace/tslint.json | 12 + .../right/onespace/test.ts.lint | 745 ++++++++++++++ .../right/onespace/tslint.json | 12 + .../right/space/test.ts.lint | 672 +++++++++++++ .../right/space/tslint.json | 12 + test/rules/typedef/all/test.ts.lint | 107 ++ test/rules/typedef/all/tslint.json | 15 + .../typedef/array-destructuring/test.ts.lint | 4 + .../typedef/array-destructuring/tslint.json | 7 + .../test.ts.lint | 12 + .../tslint.json | 8 + .../typedef/arrow-call-signature/test.ts.lint | 30 + .../typedef/arrow-call-signature/tslint.json | 7 + .../typedef/arrow-parameter/test.ts.lint | 13 + .../rules/typedef/arrow-parameter/tslint.json | 7 + .../rules/typedef/call-signature/test.ts.lint | 39 + test/rules/typedef/call-signature/tslint.json | 7 + .../member-variable-declaration/test.ts.lint | 16 + .../member-variable-declaration/tslint.json | 7 + test/rules/typedef/none/test.ts.lint | 87 ++ test/rules/typedef/none/tslint.json | 5 + .../typedef/object-destructuring/test.ts.lint | 4 + .../typedef/object-destructuring/tslint.json | 7 + test/rules/typedef/parameter/test.ts.lint | 19 + test/rules/typedef/parameter/tslint.json | 7 + .../test.ts.lint | 23 + .../tslint.json | 10 + .../typedef/variable-declaration/test.ts.lint | 5 + .../typedef/variable-declaration/tslint.json | 7 + test/rules/typeof-compare/test.ts.lint | 109 +++ test/rules/typeof-compare/tslint.json | 5 + test/rules/unified-signatures/test.d.ts.lint | 99 ++ test/rules/unified-signatures/test.ts.lint | 31 + test/rules/unified-signatures/tslint.json | 5 + .../rules/unnecessary-bind/typed/test.ts.lint | 73 ++ .../unnecessary-bind/typed/tsconfig.json | 5 + test/rules/unnecessary-bind/typed/tslint.json | 5 + .../unnecessary-bind/untyped/test.ts.lint | 62 ++ .../unnecessary-bind/untyped/tslint.json | 5 + .../check-super-calls/test.ts.fix | 147 +++ .../check-super-calls/test.ts.lint | 188 ++++ .../check-super-calls/tslint.json | 8 + .../default/test.ts.fix | 159 +++ .../default/test.ts.lint | 176 ++++ .../default/tslint.json | 5 + .../allow-else-if/test.ts.lint | 255 +++++ .../allow-else-if/tslint.json | 5 + .../unnecessary-else/default/test.ts.lint | 337 +++++++ .../unnecessary-else/default/tslint.json | 5 + .../use-default-type-parameter/test.ts.fix | 18 + .../use-default-type-parameter/test.ts.lint | 26 + .../use-default-type-parameter/tsconfig.json | 1 + .../use-default-type-parameter/tslint.json | 5 + test/rules/use-isnan/test.ts.lint | 64 ++ test/rules/use-isnan/tslint.json | 5 + .../test.ts.lint | 47 + .../tslint.json | 5 + .../allow-leading-underscore/test.ts.lint | 49 + .../allow-leading-underscore/tslint.json | 5 + .../allow-pascal-case/test.ts.lint | 50 + .../allow-pascal-case/tslint.json | 5 + .../allow-snake-case/test.ts.lint | 64 ++ .../allow-snake-case/tslint.json | 5 + .../allow-trailing-underscore/test.ts.lint | 49 + .../allow-trailing-underscore/tslint.json | 5 + .../variable-name/ban-keywords/test.ts.lint | 21 + .../variable-name/ban-keywords/tslint.json | 5 + .../const-only-for-caps/test.ts.lint | 38 + .../const-only-for-caps/tslint.json | 5 + test/rules/variable-name/default/test.ts.lint | 65 ++ test/rules/variable-name/default/tslint.json | 5 + test/rules/whitespace/all/bom.ts.lint | 1 + test/rules/whitespace/all/import-type.lint | 32 + test/rules/whitespace/all/import.ts.lint | 3 + test/rules/whitespace/all/test.ts.fix | 135 +++ test/rules/whitespace/all/test.ts.lint | 220 +++++ test/rules/whitespace/all/tslint.json | 16 + .../whitespace/check-postbrace/test.ts.fix | 5 + .../whitespace/check-postbrace/test.ts.lint | 6 + .../whitespace/check-postbrace/tslint.json | 5 + .../whitespace/check-separator/test.ts.lint | 1 + .../whitespace/check-separator/tslint.json | 5 + test/rules/whitespace/none/test.ts.lint | 102 ++ test/rules/whitespace/none/tslint.json | 5 + 1171 files changed, 51122 insertions(+) create mode 100644 test/rules/_integration/enable-disable/test.ts.lint create mode 100644 test/rules/_integration/enable-disable/test.tsx.lint create mode 100644 test/rules/_integration/enable-disable/tslint.json create mode 100644 test/rules/_integration/error-format/test.ts.lint create mode 100644 test/rules/_integration/error-format/tslint.json create mode 100644 test/rules/_integration/react/invalid.tsx.lint create mode 100644 test/rules/_integration/react/test.tsx.lint create mode 100644 test/rules/_integration/react/tslint.json create mode 100644 test/rules/_integration/typescript-version/correct.js.lint create mode 100644 test/rules/_integration/typescript-version/correct.ts.fix create mode 100644 test/rules/_integration/typescript-version/correct.ts.lint create mode 100644 test/rules/_integration/typescript-version/if-else.ts.lint create mode 100644 test/rules/_integration/typescript-version/skip.js.lint create mode 100644 test/rules/_integration/typescript-version/skip.ts.lint create mode 100644 test/rules/_integration/typescript-version/substitution.ts.lint create mode 100644 test/rules/_integration/typescript-version/tslint.json create mode 100644 test/rules/adjacent-overload-signatures/default/test.ts.lint create mode 100644 test/rules/adjacent-overload-signatures/default/tslint.json create mode 100644 test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint create mode 100644 test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json create mode 100644 test/rules/align/arguments/test.ts.fix create mode 100644 test/rules/align/arguments/test.ts.lint create mode 100644 test/rules/align/arguments/tslint.json create mode 100644 test/rules/align/elements/test.ts.fix create mode 100644 test/rules/align/elements/test.ts.lint create mode 100644 test/rules/align/elements/tslint.json create mode 100644 test/rules/align/members/test.ts.fix create mode 100644 test/rules/align/members/test.ts.lint create mode 100644 test/rules/align/members/tslint.json create mode 100644 test/rules/align/parameters/test.ts.fix create mode 100644 test/rules/align/parameters/test.ts.lint create mode 100644 test/rules/align/parameters/tslint.json create mode 100644 test/rules/align/statements/bom.ts.fix create mode 100644 test/rules/align/statements/bom.ts.lint create mode 100644 test/rules/align/statements/test.ts.fix create mode 100644 test/rules/align/statements/test.ts.lint create mode 100644 test/rules/align/statements/tslint.json create mode 100644 test/rules/array-type/array-simple/test.ts.fix create mode 100644 test/rules/array-type/array-simple/test.ts.lint create mode 100644 test/rules/array-type/array-simple/tslint.json create mode 100644 test/rules/array-type/array/test.ts.fix create mode 100644 test/rules/array-type/array/test.ts.lint create mode 100644 test/rules/array-type/array/tslint.json create mode 100644 test/rules/array-type/generic/test.ts.fix create mode 100644 test/rules/array-type/generic/test.ts.lint create mode 100644 test/rules/array-type/generic/tslint.json create mode 100644 test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix create mode 100644 test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint create mode 100644 test/rules/arrow-parens/ban-single-arg-parens/tslint.json create mode 100644 test/rules/arrow-parens/default/test.ts.fix create mode 100644 test/rules/arrow-parens/default/test.ts.lint create mode 100644 test/rules/arrow-parens/default/tslint.json create mode 100644 test/rules/arrow-return-shorthand/default/test.ts.fix create mode 100644 test/rules/arrow-return-shorthand/default/test.ts.lint create mode 100644 test/rules/arrow-return-shorthand/default/tslint.json create mode 100644 test/rules/arrow-return-shorthand/multiline/test.ts.fix create mode 100644 test/rules/arrow-return-shorthand/multiline/test.ts.lint create mode 100644 test/rules/arrow-return-shorthand/multiline/tslint.json create mode 100644 test/rules/await-promise/custom-promise/test.ts.lint create mode 100644 test/rules/await-promise/custom-promise/tsconfig.json create mode 100644 test/rules/await-promise/custom-promise/tslint.json create mode 100644 test/rules/await-promise/es6-promise/test.ts.lint create mode 100644 test/rules/await-promise/es6-promise/tsconfig.json create mode 100644 test/rules/await-promise/es6-promise/tslint.json create mode 100644 test/rules/await-promise/for-await-of/test.ts.lint create mode 100644 test/rules/await-promise/for-await-of/tsconfig.json create mode 100644 test/rules/await-promise/for-await-of/tslint.json create mode 100644 test/rules/ban-comma-operator/test.ts.lint create mode 100644 test/rules/ban-comma-operator/tslint.json create mode 100644 test/rules/ban-ts-ignore/test.ts.lint create mode 100644 test/rules/ban-ts-ignore/tslint.json create mode 100644 test/rules/ban-types/test.ts.lint create mode 100644 test/rules/ban-types/tslint.json create mode 100644 test/rules/ban/test.ts.lint create mode 100644 test/rules/ban/tslint.json create mode 100644 test/rules/binary-expression-operand-order/test.ts.lint create mode 100644 test/rules/binary-expression-operand-order/tslint.json create mode 100644 test/rules/callable-types/test.ts.fix create mode 100644 test/rules/callable-types/test.ts.lint create mode 100644 test/rules/callable-types/tslint.json create mode 100644 test/rules/class-name/test.ts.lint create mode 100644 test/rules/class-name/tslint.json create mode 100644 test/rules/comment-format/allow-trailing-lowercase/test.ts.fix create mode 100644 test/rules/comment-format/allow-trailing-lowercase/test.ts.lint create mode 100644 test/rules/comment-format/allow-trailing-lowercase/tslint.json create mode 100644 test/rules/comment-format/exceptions-pattern/test.ts.fix create mode 100644 test/rules/comment-format/exceptions-pattern/test.ts.lint create mode 100644 test/rules/comment-format/exceptions-pattern/tslint.json create mode 100644 test/rules/comment-format/exceptions-words/test.ts.fix create mode 100644 test/rules/comment-format/exceptions-words/test.ts.lint create mode 100644 test/rules/comment-format/exceptions-words/tslint.json create mode 100644 test/rules/comment-format/lower/test.ts.fix create mode 100644 test/rules/comment-format/lower/test.ts.lint create mode 100644 test/rules/comment-format/lower/test.tsx.fix create mode 100644 test/rules/comment-format/lower/test.tsx.lint create mode 100644 test/rules/comment-format/lower/tslint.json create mode 100644 test/rules/comment-format/upper/test.ts.fix create mode 100644 test/rules/comment-format/upper/test.ts.lint create mode 100644 test/rules/comment-format/upper/tslint.json create mode 100644 test/rules/comment-type/combo/test.ts.lint create mode 100644 test/rules/comment-type/combo/tslint.json create mode 100644 test/rules/comment-type/directive/test.ts.tslint create mode 100644 test/rules/comment-type/directive/tslint.json create mode 100644 test/rules/comment-type/doc/test.ts.lint create mode 100644 test/rules/comment-type/doc/tslint.json create mode 100644 test/rules/comment-type/multiline/test.ts.lint create mode 100644 test/rules/comment-type/multiline/tslint.json create mode 100644 test/rules/comment-type/single-line/test.ts.lint create mode 100644 test/rules/comment-type/single-line/tslint.json create mode 100644 test/rules/curly/as-needed/test.ts.lint create mode 100644 test/rules/curly/as-needed/tslint.json create mode 100644 test/rules/curly/defaults/test.ts.fix create mode 100644 test/rules/curly/defaults/test.ts.lint create mode 100644 test/rules/curly/defaults/tslint.json create mode 100644 test/rules/curly/ignore-same-line/test.ts.fix create mode 100644 test/rules/curly/ignore-same-line/test.ts.lint create mode 100644 test/rules/curly/ignore-same-line/tslint.json create mode 100644 test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint create mode 100644 test/rules/cyclomatic-complexity/defaultThreshold/tslint.json create mode 100644 test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint create mode 100644 test/rules/cyclomatic-complexity/invalidThreshold/tslint.json create mode 100644 test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint create mode 100644 test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json create mode 100644 test/rules/deprecation/other.test.ts create mode 100644 test/rules/deprecation/other2.test.ts create mode 100644 test/rules/deprecation/test.ts.lint create mode 100644 test/rules/deprecation/tsconfig.json create mode 100644 test/rules/deprecation/tslint.json create mode 100644 test/rules/encoding/tslint.json create mode 100644 test/rules/encoding/utf16be.ts.lint create mode 100644 test/rules/encoding/utf16le.ts.lint create mode 100644 test/rules/encoding/utf8-bom.ts.lint create mode 100644 test/rules/encoding/utf8.ts.lint create mode 100644 test/rules/eofline/comment.ts.lint create mode 100644 test/rules/eofline/disabled.ts.lint create mode 100644 test/rules/eofline/empty.ts.lint create mode 100644 test/rules/eofline/invalid.ts.fix create mode 100644 test/rules/eofline/invalid.ts.lint create mode 100644 test/rules/eofline/only-whitespace.ts.fix create mode 100644 test/rules/eofline/only-whitespace.ts.lint create mode 100644 test/rules/eofline/tslint.json create mode 100644 test/rules/eofline/valid.ts.lint create mode 100644 test/rules/eofline/whitespace.ts.lint create mode 100644 test/rules/file-header/bad-newline/test.ts.fix create mode 100644 test/rules/file-header/bad-newline/test.ts.lint create mode 100644 test/rules/file-header/bad-newline/tslint.json create mode 100644 test/rules/file-header/bad-shebang/test.ts.fix create mode 100644 test/rules/file-header/bad-shebang/test.ts.lint create mode 100644 test/rules/file-header/bad-shebang/tslint.json create mode 100644 test/rules/file-header/bad-single-line/test.ts.fix create mode 100644 test/rules/file-header/bad-single-line/test.ts.lint create mode 100644 test/rules/file-header/bad-single-line/tslint.json create mode 100644 test/rules/file-header/bad-single-newline/test.ts.fix create mode 100644 test/rules/file-header/bad-single-newline/test.ts.lint create mode 100644 test/rules/file-header/bad-single-newline/tslint.json create mode 100644 test/rules/file-header/bad-use-strict/test.ts.fix create mode 100644 test/rules/file-header/bad-use-strict/test.ts.lint create mode 100644 test/rules/file-header/bad-use-strict/tslint.json create mode 100644 test/rules/file-header/bad/test.ts.fix create mode 100644 test/rules/file-header/bad/test.ts.lint create mode 100644 test/rules/file-header/bad/test2.ts.fix create mode 100644 test/rules/file-header/bad/test2.ts.lint create mode 100644 test/rules/file-header/bad/tslint.json create mode 100644 test/rules/file-header/empty-file/test.ts.lint create mode 100644 test/rules/file-header/empty-file/tslint.json create mode 100644 test/rules/file-header/good-allow-single-line-comments/test.ts.lint create mode 100644 test/rules/file-header/good-allow-single-line-comments/tslint.json create mode 100644 test/rules/file-header/good-newline/test.ts.lint create mode 100644 test/rules/file-header/good-newline/tslint.json create mode 100644 test/rules/file-header/good-shebang/test.ts.lint create mode 100644 test/rules/file-header/good-shebang/tslint.json create mode 100644 test/rules/file-header/good-single-line/test.ts.lint create mode 100644 test/rules/file-header/good-single-line/tslint.json create mode 100644 test/rules/file-header/good-use-strict/test.ts.lint create mode 100644 test/rules/file-header/good-use-strict/tslint.json create mode 100644 test/rules/file-header/good/test.ts.fix create mode 100644 test/rules/file-header/good/test.ts.lint create mode 100644 test/rules/file-header/good/tslint.json create mode 100644 test/rules/file-name-casing/camel-case/camelCase.ts.lint create mode 100644 test/rules/file-name-casing/camel-case/no-camel-case.ts.lint create mode 100644 test/rules/file-name-casing/camel-case/tslint.json create mode 100644 test/rules/file-name-casing/complex/ComponentName.tsx.lint create mode 100644 test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint create mode 100644 test/rules/file-name-casing/complex/invalid-component-name.tsx.lint create mode 100644 test/rules/file-name-casing/complex/my-button.component.ts.lint create mode 100644 test/rules/file-name-casing/complex/nonComponentName.ts.lint create mode 100644 test/rules/file-name-casing/complex/tslint.json create mode 100644 test/rules/file-name-casing/file-matcher/PascalCase.ts.lint create mode 100644 test/rules/file-name-casing/file-matcher/camelCase.ts.lint create mode 100644 test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint create mode 100644 test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint create mode 100644 test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint create mode 100644 test/rules/file-name-casing/file-matcher/tslint.json create mode 100644 test/rules/file-name-casing/ignore/complaint.tsx.lint create mode 100644 test/rules/file-name-casing/ignore/file.ts.lint create mode 100644 test/rules/file-name-casing/ignore/tslint.json create mode 100644 test/rules/file-name-casing/invalid-option/snake_case.ts.lint create mode 100644 test/rules/file-name-casing/invalid-option/tslint.json create mode 100644 test/rules/file-name-casing/kebab-case/kebab-case.ts.lint create mode 100644 test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint create mode 100644 test/rules/file-name-casing/kebab-case/tslint.json create mode 100644 test/rules/file-name-casing/pascal-case/PascalCase.ts.lint create mode 100644 test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint create mode 100644 test/rules/file-name-casing/pascal-case/tslint.json create mode 100644 test/rules/file-name-casing/snake-case/no-snake-case.ts.lint create mode 100644 test/rules/file-name-casing/snake-case/snake_case.ts.lint create mode 100644 test/rules/file-name-casing/snake-case/tslint.json create mode 100644 test/rules/forin/test.ts.lint create mode 100644 test/rules/forin/tslint.json create mode 100644 test/rules/function-constructor/test.ts.lint create mode 100644 test/rules/function-constructor/tslint.json create mode 100644 test/rules/import-blacklist/test.ts.lint create mode 100644 test/rules/import-blacklist/tslint.json create mode 100644 test/rules/import-spacing/test.ts.lint create mode 100644 test/rules/import-spacing/tslint.json create mode 100644 test/rules/increment-decrement/allow-post/test.ts.fix create mode 100644 test/rules/increment-decrement/allow-post/test.ts.lint create mode 100644 test/rules/increment-decrement/allow-post/tslint.json create mode 100644 test/rules/increment-decrement/default/test.ts.fix create mode 100644 test/rules/increment-decrement/default/test.ts.lint create mode 100644 test/rules/increment-decrement/default/tslint.json create mode 100644 test/rules/indent/spaces-2/test.ts.fix create mode 100644 test/rules/indent/spaces-2/test.ts.lint create mode 100644 test/rules/indent/spaces-2/test.tsx.lint create mode 100644 test/rules/indent/spaces-2/tslint.json create mode 100644 test/rules/indent/spaces-4/test.ts.fix create mode 100644 test/rules/indent/spaces-4/test.ts.lint create mode 100644 test/rules/indent/spaces-4/tslint.json create mode 100644 test/rules/indent/tabs-2/test.ts.fix create mode 100644 test/rules/indent/tabs-2/test.ts.lint create mode 100644 test/rules/indent/tabs-2/tslint.json create mode 100644 test/rules/indent/tabs-4/test.ts.fix create mode 100644 test/rules/indent/tabs-4/test.ts.lint create mode 100644 test/rules/indent/tabs-4/tslint.json create mode 100644 test/rules/interface-name/always-prefix/test.ts.lint create mode 100644 test/rules/interface-name/always-prefix/tslint.json create mode 100644 test/rules/interface-name/default/test.ts.lint create mode 100644 test/rules/interface-name/default/tslint.json create mode 100644 test/rules/interface-name/never-prefix/test.ts.lint create mode 100644 test/rules/interface-name/never-prefix/tslint.json create mode 100644 test/rules/interface-over-type-literal/test.ts.fix create mode 100644 test/rules/interface-over-type-literal/test.ts.lint create mode 100644 test/rules/interface-over-type-literal/tslint.json create mode 100644 test/rules/invalid-void/allow-generics/false/test.ts.lint create mode 100644 test/rules/invalid-void/allow-generics/false/tslint.json create mode 100644 test/rules/invalid-void/allow-generics/true/test.ts.lint create mode 100644 test/rules/invalid-void/allow-generics/true/tslint.json create mode 100644 test/rules/invalid-void/allow-generics/whitelist/test.ts.lint create mode 100644 test/rules/invalid-void/allow-generics/whitelist/tslint.json create mode 100644 test/rules/invalid-void/default/test.ts.lint create mode 100644 test/rules/invalid-void/default/tslint.json create mode 100644 test/rules/jsdoc-format/check-multiline-start/test.ts.lint create mode 100644 test/rules/jsdoc-format/check-multiline-start/tslint.json create mode 100644 test/rules/jsdoc-format/default/jsdoc-bom.ts.lint create mode 100644 test/rules/jsdoc-format/default/jsdoc-windows.ts.lint create mode 100644 test/rules/jsdoc-format/default/jsdoc.ts.lint create mode 100644 test/rules/jsdoc-format/default/tslint.json create mode 100644 test/rules/label-position/test.ts.lint create mode 100644 test/rules/label-position/tslint.json create mode 100644 test/rules/linebreak-style/emptyFile/test.ts.lint create mode 100644 test/rules/linebreak-style/emptyFile/tslint.json create mode 100644 test/rules/linebreak-style/failure/CRLF/test.ts.fix create mode 100644 test/rules/linebreak-style/failure/CRLF/test.ts.lint create mode 100644 test/rules/linebreak-style/failure/CRLF/tslint.json create mode 100644 test/rules/linebreak-style/failure/LF/test.ts.fix create mode 100644 test/rules/linebreak-style/failure/LF/test.ts.lint create mode 100644 test/rules/linebreak-style/failure/LF/tslint.json create mode 100644 test/rules/linebreak-style/success/CRLF/test.ts.lint create mode 100644 test/rules/linebreak-style/success/CRLF/tslint.json create mode 100644 test/rules/linebreak-style/success/LF/test.ts.lint create mode 100644 test/rules/linebreak-style/success/LF/tslint.json create mode 100644 test/rules/match-default-export-name/anonymous.test.ts create mode 100644 test/rules/match-default-export-name/named.test.ts create mode 100644 test/rules/match-default-export-name/test.ts.lint create mode 100644 test/rules/match-default-export-name/tsconfig.json create mode 100644 test/rules/match-default-export-name/tslint.json create mode 100644 test/rules/max-classes-per-file/one/test.ts.lint create mode 100644 test/rules/max-classes-per-file/one/tslint.json create mode 100644 test/rules/max-classes-per-file/two/test.ts.lint create mode 100644 test/rules/max-classes-per-file/two/tslint.json create mode 100644 test/rules/max-file-line-count/default/test.ts.lint create mode 100644 test/rules/max-file-line-count/default/tslint.json create mode 100644 test/rules/max-file-line-count/disabled/test.ts.lint create mode 100644 test/rules/max-file-line-count/disabled/tslint.json create mode 100644 test/rules/max-line-length/check-strings-and-regex/test.ts.lint create mode 100644 test/rules/max-line-length/check-strings-and-regex/tslint.json create mode 100644 test/rules/max-line-length/default/test.ts.lint create mode 100644 test/rules/max-line-length/default/tslint.json create mode 100644 test/rules/member-access/accessor/test.ts.fix create mode 100644 test/rules/member-access/accessor/test.ts.lint create mode 100644 test/rules/member-access/accessor/tslint.json create mode 100644 test/rules/member-access/constructor/test.ts.fix create mode 100644 test/rules/member-access/constructor/test.ts.lint create mode 100644 test/rules/member-access/constructor/tslint.json create mode 100644 test/rules/member-access/default/test.ts.fix create mode 100644 test/rules/member-access/default/test.ts.lint create mode 100644 test/rules/member-access/default/tslint.json create mode 100644 test/rules/member-access/no-public/test.ts.fix create mode 100644 test/rules/member-access/no-public/test.ts.lint create mode 100644 test/rules/member-access/no-public/tslint.json create mode 100644 test/rules/member-access/parameter-property/test.ts.fix create mode 100644 test/rules/member-access/parameter-property/test.ts.lint create mode 100644 test/rules/member-access/parameter-property/tslint.json create mode 100644 test/rules/member-ordering/alphabetize-nested/test.ts.fix create mode 100644 test/rules/member-ordering/alphabetize-nested/test.ts.lint create mode 100644 test/rules/member-ordering/alphabetize-nested/tslint.json create mode 100644 test/rules/member-ordering/alphabetize/test.ts.fix create mode 100644 test/rules/member-ordering/alphabetize/test.ts.lint create mode 100644 test/rules/member-ordering/alphabetize/tslint.json create mode 100644 test/rules/member-ordering/custom-categories/test.ts.fix create mode 100644 test/rules/member-ordering/custom-categories/test.ts.lint create mode 100644 test/rules/member-ordering/custom-categories/tslint.json create mode 100644 test/rules/member-ordering/custom/test.ts.fix create mode 100644 test/rules/member-ordering/custom/test.ts.lint create mode 100644 test/rules/member-ordering/custom/tslint.json create mode 100644 test/rules/member-ordering/fields-first/test.ts.fix create mode 100644 test/rules/member-ordering/fields-first/test.ts.lint create mode 100644 test/rules/member-ordering/fields-first/tslint.json create mode 100644 test/rules/member-ordering/fix-trivia/test.ts.fix create mode 100644 test/rules/member-ordering/fix-trivia/test.ts.lint create mode 100644 test/rules/member-ordering/fix-trivia/tslint.json create mode 100644 test/rules/member-ordering/instance-sandwich/test.ts.fix create mode 100644 test/rules/member-ordering/instance-sandwich/test.ts.lint create mode 100644 test/rules/member-ordering/instance-sandwich/tslint.json create mode 100644 test/rules/member-ordering/mix-old-options/test.ts.fix create mode 100644 test/rules/member-ordering/mix-old-options/test.ts.lint create mode 100644 test/rules/member-ordering/mix-old-options/tslint.json create mode 100644 test/rules/member-ordering/omit-access-modifier/test.ts.fix create mode 100644 test/rules/member-ordering/omit-access-modifier/test.ts.lint create mode 100644 test/rules/member-ordering/omit-access-modifier/tslint.json create mode 100644 test/rules/member-ordering/public-before-private/test.ts.fix create mode 100644 test/rules/member-ordering/public-before-private/test.ts.lint create mode 100644 test/rules/member-ordering/public-before-private/tslint.json create mode 100644 test/rules/member-ordering/static-before-instance/test.ts.fix create mode 100644 test/rules/member-ordering/static-before-instance/test.ts.lint create mode 100644 test/rules/member-ordering/static-before-instance/tslint.json create mode 100644 test/rules/member-ordering/statics-first/test.ts.fix create mode 100644 test/rules/member-ordering/statics-first/test.ts.lint create mode 100644 test/rules/member-ordering/statics-first/tslint.json create mode 100644 test/rules/member-ordering/variables-before-functions/test.ts.fix create mode 100644 test/rules/member-ordering/variables-before-functions/test.ts.lint create mode 100644 test/rules/member-ordering/variables-before-functions/tslint.json create mode 100644 test/rules/new-parens/test.ts.lint create mode 100644 test/rules/new-parens/tslint.json create mode 100644 test/rules/newline-before-return/default/test.ts.fix create mode 100644 test/rules/newline-before-return/default/test.ts.lint create mode 100644 test/rules/newline-before-return/default/test.tsx.fix create mode 100644 test/rules/newline-before-return/default/test.tsx.lint create mode 100644 test/rules/newline-before-return/default/tslint.json create mode 100644 test/rules/newline-per-chained-call/default/test.ts.lint create mode 100644 test/rules/newline-per-chained-call/default/tslint.json create mode 100644 test/rules/no-angle-bracket-type-assertion/test.ts.fix create mode 100644 test/rules/no-angle-bracket-type-assertion/test.ts.lint create mode 100644 test/rules/no-angle-bracket-type-assertion/tslint.json create mode 100644 test/rules/no-any/default/test.ts.lint create mode 100644 test/rules/no-any/default/tslint.json create mode 100644 test/rules/no-any/ignore-rest-args/test.ts.lint create mode 100644 test/rules/no-any/ignore-rest-args/tslint.json create mode 100644 test/rules/no-arg/test.ts.lint create mode 100644 test/rules/no-arg/tslint.json create mode 100644 test/rules/no-async-without-await/test.ts.lint create mode 100644 test/rules/no-async-without-await/tslint.json create mode 100644 test/rules/no-bitwise/test.ts.lint create mode 100644 test/rules/no-bitwise/tslint.json create mode 100644 test/rules/no-boolean-literal-compare/test.ts.fix create mode 100644 test/rules/no-boolean-literal-compare/test.ts.lint create mode 100644 test/rules/no-boolean-literal-compare/tsconfig.json create mode 100644 test/rules/no-boolean-literal-compare/tslint.json create mode 100644 test/rules/no-conditional-assignment/test.ts.lint create mode 100644 test/rules/no-conditional-assignment/tslint.json create mode 100644 test/rules/no-consecutive-blank-lines/default/test.ts.fix create mode 100644 test/rules/no-consecutive-blank-lines/default/test.ts.lint create mode 100644 test/rules/no-consecutive-blank-lines/default/tslint.json create mode 100644 test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint create mode 100644 test/rules/no-consecutive-blank-lines/invalid-option/tslint.json create mode 100644 test/rules/no-consecutive-blank-lines/multiple/test.ts.fix create mode 100644 test/rules/no-consecutive-blank-lines/multiple/test.ts.lint create mode 100644 test/rules/no-consecutive-blank-lines/multiple/tslint.json create mode 100644 test/rules/no-console/all/test.ts.lint create mode 100644 test/rules/no-console/all/tslint.json create mode 100644 test/rules/no-console/list/test.ts.lint create mode 100644 test/rules/no-console/list/tslint.json create mode 100644 test/rules/no-construct/test.ts.lint create mode 100644 test/rules/no-construct/tslint.json create mode 100644 test/rules/no-debugger/test.ts.lint create mode 100644 test/rules/no-debugger/tslint.json create mode 100644 test/rules/no-default-export/test.ts.lint create mode 100644 test/rules/no-default-export/tslint.json create mode 100644 test/rules/no-default-import/default/test.ts.lint create mode 100644 test/rules/no-default-import/default/tslint.json create mode 100644 test/rules/no-default-import/fromModules/test.ts.lint create mode 100644 test/rules/no-default-import/fromModules/tslint.json create mode 100644 test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint create mode 100644 test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint create mode 100644 test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json create mode 100644 test/rules/no-duplicate-imports/default/test.d.ts.lint create mode 100644 test/rules/no-duplicate-imports/default/test.ts.lint create mode 100644 test/rules/no-duplicate-imports/default/test2.d.ts.lint create mode 100644 test/rules/no-duplicate-imports/default/test3.d.ts.lint create mode 100644 test/rules/no-duplicate-imports/default/tslint.json create mode 100644 test/rules/no-duplicate-super/test.ts.lint create mode 100644 test/rules/no-duplicate-super/tslint.json create mode 100644 test/rules/no-duplicate-switch-case/test.ts.lint create mode 100644 test/rules/no-duplicate-switch-case/tslint.json create mode 100644 test/rules/no-duplicate-variable/check-parameters/test.ts.lint create mode 100644 test/rules/no-duplicate-variable/check-parameters/tslint.json create mode 100644 test/rules/no-duplicate-variable/default/test.ts.lint create mode 100644 test/rules/no-duplicate-variable/default/tslint.json create mode 100644 test/rules/no-dynamic-delete/test.ts.fix create mode 100644 test/rules/no-dynamic-delete/test.ts.lint create mode 100644 test/rules/no-dynamic-delete/tslint.json create mode 100644 test/rules/no-empty-interface/test.ts.lint create mode 100644 test/rules/no-empty-interface/tslint.json create mode 100644 test/rules/no-empty/allow-empty-catch/test.ts.lint create mode 100644 test/rules/no-empty/allow-empty-catch/tslint.json create mode 100644 test/rules/no-empty/allow-empty-functions/test.ts.lint create mode 100644 test/rules/no-empty/allow-empty-functions/tslint.json create mode 100644 test/rules/no-empty/default/test.ts.lint create mode 100644 test/rules/no-empty/default/tslint.json create mode 100644 test/rules/no-eval/test.ts.lint create mode 100644 test/rules/no-eval/tslint.json create mode 100644 test/rules/no-floating-promises/jquerypromise/test.ts.lint create mode 100644 test/rules/no-floating-promises/jquerypromise/tsconfig.json create mode 100644 test/rules/no-floating-promises/jquerypromise/tslint.json create mode 100644 test/rules/no-floating-promises/promises/test.ts.lint create mode 100644 test/rules/no-floating-promises/promises/tsconfig.json create mode 100644 test/rules/no-floating-promises/promises/tslint.json create mode 100644 test/rules/no-for-in-array/test.ts.lint create mode 100644 test/rules/no-for-in-array/tsconfig.json create mode 100644 test/rules/no-for-in-array/tslint.json create mode 100644 test/rules/no-for-in/test.ts.lint create mode 100644 test/rules/no-for-in/tslint.json create mode 100644 test/rules/no-implicit-dependencies/default/bom/package.json create mode 100644 test/rules/no-implicit-dependencies/default/bom/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/default/builtin-only.ts.lint create mode 100644 test/rules/no-implicit-dependencies/default/malformed/package.json create mode 100644 test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint create mode 100644 test/rules/no-implicit-dependencies/default/nested-package/package.json create mode 100644 test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/default/subdir/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/default/test.js.lint create mode 100644 test/rules/no-implicit-dependencies/default/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/default/tslint.json create mode 100644 test/rules/no-implicit-dependencies/dev/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/dev/tslint.json create mode 100644 test/rules/no-implicit-dependencies/optional/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/optional/tslint.json create mode 100644 test/rules/no-implicit-dependencies/package.json create mode 100644 test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json create mode 100644 test/rules/no-implicit-dependencies/whitelist/test.ts.lint create mode 100644 test/rules/no-implicit-dependencies/whitelist/tslint.json create mode 100644 test/rules/no-import-side-effect/default/test.ts.lint create mode 100644 test/rules/no-import-side-effect/default/tslint.json create mode 100644 test/rules/no-import-side-effect/ignore-module/test.ts.lint create mode 100644 test/rules/no-import-side-effect/ignore-module/tslint.json create mode 100644 test/rules/no-inferrable-types/default/test.ts.fix create mode 100644 test/rules/no-inferrable-types/default/test.ts.lint create mode 100644 test/rules/no-inferrable-types/default/tslint.json create mode 100644 test/rules/no-inferrable-types/ignore-params/test.ts.fix create mode 100644 test/rules/no-inferrable-types/ignore-params/test.ts.lint create mode 100644 test/rules/no-inferrable-types/ignore-params/tslint.json create mode 100644 test/rules/no-inferrable-types/ignore-properties/test.ts.fix create mode 100644 test/rules/no-inferrable-types/ignore-properties/test.ts.lint create mode 100644 test/rules/no-inferrable-types/ignore-properties/tslint.json create mode 100644 test/rules/no-inferred-empty-object-type/test.ts.lint create mode 100644 test/rules/no-inferred-empty-object-type/tsconfig.json create mode 100644 test/rules/no-inferred-empty-object-type/tslint.json create mode 100644 test/rules/no-internal-module/test.ts.fix create mode 100644 test/rules/no-internal-module/test.ts.lint create mode 100644 test/rules/no-internal-module/tslint.json create mode 100644 test/rules/no-invalid-template-strings/test.ts.lint create mode 100644 test/rules/no-invalid-template-strings/tslint.json create mode 100644 test/rules/no-invalid-this/enabled/test.ts.lint create mode 100644 test/rules/no-invalid-this/enabled/tslint.json create mode 100644 test/rules/no-irregular-whitespace/test.builder.ts create mode 100644 test/rules/no-irregular-whitespace/test.ts.fix create mode 100644 test/rules/no-irregular-whitespace/test.ts.lint create mode 100644 test/rules/no-irregular-whitespace/tslint.json create mode 100644 test/rules/no-magic-numbers/allowed-numbers/test.ts.lint create mode 100644 test/rules/no-magic-numbers/allowed-numbers/tslint.json create mode 100644 test/rules/no-magic-numbers/custom/test.ts.lint create mode 100644 test/rules/no-magic-numbers/custom/tslint.json create mode 100644 test/rules/no-magic-numbers/default-jsx/test.tsx.lint create mode 100644 test/rules/no-magic-numbers/default-jsx/tslint.json create mode 100644 test/rules/no-magic-numbers/default/test.ts.lint create mode 100644 test/rules/no-magic-numbers/default/tslint.json create mode 100644 test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint create mode 100644 test/rules/no-magic-numbers/ignore-jsx/tslint.json create mode 100644 test/rules/no-mergeable-namespace/test.ts.lint create mode 100644 test/rules/no-mergeable-namespace/tslint.json create mode 100644 test/rules/no-misused-new/test.ts.lint create mode 100644 test/rules/no-misused-new/tslint.json create mode 100644 test/rules/no-namespace/allow-declarations/test.d.ts.lint create mode 100644 test/rules/no-namespace/allow-declarations/test.ts.lint create mode 100644 test/rules/no-namespace/allow-declarations/tslint.json create mode 100644 test/rules/no-namespace/default/test.d.ts.lint create mode 100644 test/rules/no-namespace/default/test.ts.lint create mode 100644 test/rules/no-namespace/default/tslint.json create mode 100644 test/rules/no-non-null-assertion/test.ts.lint create mode 100644 test/rules/no-non-null-assertion/tslint.json create mode 100644 test/rules/no-null-keyword/test.ts.fix create mode 100644 test/rules/no-null-keyword/test.ts.lint create mode 100644 test/rules/no-null-keyword/tslint.json create mode 100644 test/rules/no-null-undefined-union/test.ts.lint create mode 100644 test/rules/no-null-undefined-union/ts350.ts.lint create mode 100644 test/rules/no-null-undefined-union/tsconfig.json create mode 100644 test/rules/no-null-undefined-union/tslint.json create mode 100644 test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint create mode 100644 test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json create mode 100644 test/rules/no-object-literal-type-assertion/default/test.ts.lint create mode 100644 test/rules/no-object-literal-type-assertion/default/tslint.json create mode 100644 test/rules/no-parameter-properties/test.ts.lint create mode 100644 test/rules/no-parameter-properties/tslint.json create mode 100644 test/rules/no-parameter-reassignment/test.ts.lint create mode 100644 test/rules/no-parameter-reassignment/tslint.json create mode 100644 test/rules/no-promise-as-boolean/custom-promise/test.ts.lint create mode 100644 test/rules/no-promise-as-boolean/custom-promise/tsconfig.json create mode 100644 test/rules/no-promise-as-boolean/custom-promise/tslint.json create mode 100644 test/rules/no-promise-as-boolean/es6-promise/test.ts.lint create mode 100644 test/rules/no-promise-as-boolean/es6-promise/tsconfig.json create mode 100644 test/rules/no-promise-as-boolean/es6-promise/tslint.json create mode 100644 test/rules/no-redundant-jsdoc/test.ts.lint create mode 100644 test/rules/no-redundant-jsdoc/tslint.json create mode 100644 test/rules/no-reference-import/test.d.ts.lint create mode 100644 test/rules/no-reference-import/ts240.d.ts.lint create mode 100644 test/rules/no-reference-import/tslint.json create mode 100644 test/rules/no-reference/test.ts.lint create mode 100644 test/rules/no-reference/ts240.ts.lint create mode 100644 test/rules/no-reference/tslint.json create mode 100644 test/rules/no-require-imports/test.ts.lint create mode 100644 test/rules/no-require-imports/tslint.json create mode 100644 test/rules/no-restricted-globals/custom-global.d.ts create mode 100644 test/rules/no-restricted-globals/foo.d.ts create mode 100644 test/rules/no-restricted-globals/namespace.ts.lint create mode 100644 test/rules/no-restricted-globals/test.ts.lint create mode 100644 test/rules/no-restricted-globals/tsconfig.json create mode 100644 test/rules/no-restricted-globals/tslint.json create mode 100644 test/rules/no-return-await/test.ts.fix create mode 100644 test/rules/no-return-await/test.ts.lint create mode 100644 test/rules/no-return-await/tslint.json create mode 100644 test/rules/no-shadowed-variable/default/ambient.d.ts.lint create mode 100644 test/rules/no-shadowed-variable/default/test.ts.lint create mode 100644 test/rules/no-shadowed-variable/default/tslint.json create mode 100644 test/rules/no-shadowed-variable/ignore-class/test.ts.lint create mode 100644 test/rules/no-shadowed-variable/ignore-class/tslint.json create mode 100644 test/rules/no-shadowed-variable/ignore-import/test.ts.lint create mode 100644 test/rules/no-shadowed-variable/ignore-import/tslint.json create mode 100644 test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint create mode 100644 test/rules/no-shadowed-variable/ignore-underscore/tslint.json create mode 100644 test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint create mode 100644 test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json create mode 100644 test/rules/no-sparse-arrays/test.ts.lint create mode 100644 test/rules/no-sparse-arrays/tslint.json create mode 100644 test/rules/no-string-literal/test.ts.fix create mode 100644 test/rules/no-string-literal/test.ts.lint create mode 100644 test/rules/no-string-literal/tslint.json create mode 100644 test/rules/no-string-throw/test.ts.fix create mode 100644 test/rules/no-string-throw/test.ts.lint create mode 100644 test/rules/no-string-throw/tslint.json create mode 100644 test/rules/no-submodule-imports/dynamic-imports/test.ts.lint create mode 100644 test/rules/no-submodule-imports/dynamic-imports/tslint.json create mode 100644 test/rules/no-submodule-imports/static-imports/test.ts.lint create mode 100644 test/rules/no-submodule-imports/static-imports/tslint.json create mode 100644 test/rules/no-switch-case-fall-through/test.ts.lint create mode 100644 test/rules/no-switch-case-fall-through/tslint.json create mode 100644 test/rules/no-tautology-expression/test.ts.lint create mode 100644 test/rules/no-tautology-expression/tslint.json create mode 100644 test/rules/no-this-assignment/allow-destructuring/test.ts.lint create mode 100644 test/rules/no-this-assignment/allow-destructuring/tslint.json create mode 100644 test/rules/no-this-assignment/allowed-names/test.ts.lint create mode 100644 test/rules/no-this-assignment/allowed-names/tslint.json create mode 100644 test/rules/no-this-assignment/default/test.ts.lint create mode 100644 test/rules/no-this-assignment/default/tslint.json create mode 100644 test/rules/no-trailing-whitespace/default/test.ts.fix create mode 100644 test/rules/no-trailing-whitespace/default/test.ts.lint create mode 100644 test/rules/no-trailing-whitespace/default/tslint.json create mode 100644 test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix create mode 100644 test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint create mode 100644 test/rules/no-trailing-whitespace/ignore-comments/tslint.json create mode 100644 test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix create mode 100644 test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint create mode 100644 test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json create mode 100644 test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix create mode 100644 test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint create mode 100644 test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json create mode 100644 test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix create mode 100644 test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint create mode 100644 test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json create mode 100644 test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint create mode 100644 test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint create mode 100644 test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json create mode 100644 test/rules/no-unbound-method/default/test.ts.lint create mode 100644 test/rules/no-unbound-method/default/test.tsx.lint create mode 100644 test/rules/no-unbound-method/default/tsconfig.json create mode 100644 test/rules/no-unbound-method/default/tslint.json create mode 100644 test/rules/no-unbound-method/ignore-static/test.tsx.lint create mode 100644 test/rules/no-unbound-method/ignore-static/tsconfig.json create mode 100644 test/rules/no-unbound-method/ignore-static/tslint.json create mode 100644 test/rules/no-unbound-method/whitelist/test.tsx.lint create mode 100644 test/rules/no-unbound-method/whitelist/tsconfig.json create mode 100644 test/rules/no-unbound-method/whitelist/tslint.json create mode 100644 test/rules/no-unnecessary-callback-wrapper/test.ts.fix create mode 100644 test/rules/no-unnecessary-callback-wrapper/test.ts.lint create mode 100644 test/rules/no-unnecessary-callback-wrapper/tslint.json create mode 100644 test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint create mode 100644 test/rules/no-unnecessary-class/allow-constructor-only/tslint.json create mode 100644 test/rules/no-unnecessary-class/allow-empty/test.ts.lint create mode 100644 test/rules/no-unnecessary-class/allow-empty/tslint.json create mode 100644 test/rules/no-unnecessary-class/allow-static-only/test.ts.lint create mode 100644 test/rules/no-unnecessary-class/allow-static-only/tslint.json create mode 100644 test/rules/no-unnecessary-class/default/test.ts.lint create mode 100644 test/rules/no-unnecessary-class/default/tslint.json create mode 100644 test/rules/no-unnecessary-initializer/test.ts.fix create mode 100644 test/rules/no-unnecessary-initializer/test.ts.lint create mode 100644 test/rules/no-unnecessary-initializer/tslint.json create mode 100644 test/rules/no-unnecessary-qualifier/arguments.ts.lint create mode 100644 test/rules/no-unnecessary-qualifier/b.test.ts create mode 100644 test/rules/no-unnecessary-qualifier/test-global-2.ts.lint create mode 100644 test/rules/no-unnecessary-qualifier/test-global.ts.fix create mode 100644 test/rules/no-unnecessary-qualifier/test-global.ts.lint create mode 100644 test/rules/no-unnecessary-qualifier/test.ts.fix create mode 100644 test/rules/no-unnecessary-qualifier/test.ts.lint create mode 100644 test/rules/no-unnecessary-qualifier/tsconfig.json create mode 100644 test/rules/no-unnecessary-qualifier/tslint.json create mode 100644 test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint create mode 100644 test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json create mode 100644 test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json create mode 100644 test/rules/no-unnecessary-type-assertion/strict/test.ts.fix create mode 100644 test/rules/no-unnecessary-type-assertion/strict/test.ts.lint create mode 100644 test/rules/no-unnecessary-type-assertion/strict/tsconfig.json create mode 100644 test/rules/no-unnecessary-type-assertion/strict/tslint.json create mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix create mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint create mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json create mode 100644 test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json create mode 100644 test/rules/no-unsafe-any/default/commonjsModule.ts create mode 100644 test/rules/no-unsafe-any/default/es6Module.ts create mode 100644 test/rules/no-unsafe-any/default/test.ts.lint create mode 100644 test/rules/no-unsafe-any/default/tsconfig.json create mode 100644 test/rules/no-unsafe-any/default/tslint.json create mode 100644 test/rules/no-unsafe-any/jsx/test.tsx.lint create mode 100644 test/rules/no-unsafe-any/jsx/tsconfig.json create mode 100644 test/rules/no-unsafe-any/jsx/tslint.json create mode 100644 test/rules/no-unsafe-any/unknown/test.ts.lint create mode 100644 test/rules/no-unsafe-any/unknown/tsconfig.json create mode 100644 test/rules/no-unsafe-any/unknown/tslint.json create mode 100644 test/rules/no-unsafe-finally/test.ts.lint create mode 100644 test/rules/no-unsafe-finally/tslint.json create mode 100644 test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint create mode 100644 test/rules/no-unused-expression/allow-fast-null-checks/tslint.json create mode 100644 test/rules/no-unused-expression/allow-new/test.ts.lint create mode 100644 test/rules/no-unused-expression/allow-new/tslint.json create mode 100644 test/rules/no-unused-expression/allow-tagged-template/test.ts.lint create mode 100644 test/rules/no-unused-expression/allow-tagged-template/tslint.json create mode 100644 test/rules/no-unused-expression/default/test.ts.lint create mode 100644 test/rules/no-unused-expression/default/tslint.json create mode 100644 test/rules/no-unused-variable/check-parameters/test.ts.lint create mode 100644 test/rules/no-unused-variable/check-parameters/tsconfig.json create mode 100644 test/rules/no-unused-variable/check-parameters/tslint.json create mode 100644 test/rules/no-unused-variable/default/class.ts.lint create mode 100644 test/rules/no-unused-variable/default/false-positives.ts.lint create mode 100644 test/rules/no-unused-variable/default/function.ts.lint create mode 100644 test/rules/no-unused-variable/default/import.ts.fix create mode 100644 test/rules/no-unused-variable/default/import.ts.lint create mode 100644 test/rules/no-unused-variable/default/node_modules/a.ts create mode 100644 test/rules/no-unused-variable/default/node_modules/react.ts create mode 100644 test/rules/no-unused-variable/default/node_modules/react/addons.ts create mode 100644 test/rules/no-unused-variable/default/react-addons1.tsx.lint create mode 100644 test/rules/no-unused-variable/default/react-addons2.tsx.lint create mode 100644 test/rules/no-unused-variable/default/react-addons3.tsx.lint create mode 100644 test/rules/no-unused-variable/default/react1.tsx.lint create mode 100644 test/rules/no-unused-variable/default/react2.tsx.lint create mode 100644 test/rules/no-unused-variable/default/react3.tsx.lint create mode 100644 test/rules/no-unused-variable/default/react4.tsx.lint create mode 100644 test/rules/no-unused-variable/default/tsconfig.json create mode 100644 test/rules/no-unused-variable/default/tslint.json create mode 100644 test/rules/no-unused-variable/default/var.ts.lint create mode 100644 test/rules/no-unused-variable/ignore-pattern/a.test.ts create mode 100644 test/rules/no-unused-variable/ignore-pattern/tsconfig.json create mode 100644 test/rules/no-unused-variable/ignore-pattern/tslint.json create mode 100644 test/rules/no-unused-variable/ignore-pattern/var.ts.lint create mode 100644 test/rules/no-unused-variable/type-checked/a.test.ts create mode 100644 test/rules/no-unused-variable/type-checked/destructuring.ts.lint create mode 100644 test/rules/no-unused-variable/type-checked/some.test.ts create mode 100644 test/rules/no-unused-variable/type-checked/test.ts.lint create mode 100644 test/rules/no-unused-variable/type-checked/tsconfig.json create mode 100644 test/rules/no-unused-variable/type-checked/tslint.json create mode 100644 test/rules/no-use-before-declare/$.ts create mode 100644 test/rules/no-use-before-declare/ImportAliasSecond.ts create mode 100644 test/rules/no-use-before-declare/ImportAliasWithComment.ts create mode 100644 test/rules/no-use-before-declare/ImportRegularAlias.ts create mode 100644 test/rules/no-use-before-declare/ImportWithLineBreaks.ts create mode 100644 test/rules/no-use-before-declare/InterfaceFile.ts create mode 100644 test/rules/no-use-before-declare/lib.ts create mode 100644 test/rules/no-use-before-declare/test.ts.lint create mode 100644 test/rules/no-use-before-declare/tsconfig.json create mode 100644 test/rules/no-use-before-declare/tslint.json create mode 100644 test/rules/no-use-before-declare/underscore.ts create mode 100644 test/rules/no-var-keyword/global.d.ts.lint create mode 100644 test/rules/no-var-keyword/module.d.ts.lint create mode 100644 test/rules/no-var-keyword/test.ts.fix create mode 100644 test/rules/no-var-keyword/test.ts.lint create mode 100644 test/rules/no-var-keyword/tslint.json create mode 100644 test/rules/no-var-requires/test.ts.lint create mode 100644 test/rules/no-var-requires/tslint.json create mode 100644 test/rules/no-void-expression/default/test.ts.lint create mode 100644 test/rules/no-void-expression/default/tsconfig.json create mode 100644 test/rules/no-void-expression/default/tslint.json create mode 100644 test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint create mode 100644 test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json create mode 100644 test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json create mode 100644 test/rules/number-literal-format/test.ts.fix create mode 100644 test/rules/number-literal-format/test.ts.lint create mode 100644 test/rules/number-literal-format/tslint.json create mode 100644 test/rules/object-literal-key-quotes/always/test.ts.fix create mode 100644 test/rules/object-literal-key-quotes/always/test.ts.lint create mode 100644 test/rules/object-literal-key-quotes/always/tslint.json create mode 100644 test/rules/object-literal-key-quotes/as-needed/test.ts.fix create mode 100644 test/rules/object-literal-key-quotes/as-needed/test.ts.lint create mode 100644 test/rules/object-literal-key-quotes/as-needed/tslint.json create mode 100644 test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix create mode 100644 test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint create mode 100644 test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json create mode 100644 test/rules/object-literal-key-quotes/consistent/test.ts.lint create mode 100644 test/rules/object-literal-key-quotes/consistent/tslint.json create mode 100644 test/rules/object-literal-shorthand/always/test.ts.fix create mode 100644 test/rules/object-literal-shorthand/always/test.ts.lint create mode 100644 test/rules/object-literal-shorthand/always/tslint.json create mode 100644 test/rules/object-literal-shorthand/never/test.ts.fix create mode 100644 test/rules/object-literal-shorthand/never/test.ts.lint create mode 100644 test/rules/object-literal-shorthand/never/tslint.json create mode 100644 test/rules/object-literal-shorthand/onlyMethods/test.ts.fix create mode 100644 test/rules/object-literal-shorthand/onlyMethods/test.ts.lint create mode 100644 test/rules/object-literal-shorthand/onlyMethods/tslint.json create mode 100644 test/rules/object-literal-sort-keys/default/crlf.ts.lint create mode 100644 test/rules/object-literal-sort-keys/default/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/default/tslint.json create mode 100644 test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json create mode 100644 test/rules/object-literal-sort-keys/ignore-case/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/ignore-case/tslint.json create mode 100644 test/rules/object-literal-sort-keys/locale-compare/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/locale-compare/tslint.json create mode 100644 test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json create mode 100644 test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json create mode 100644 test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json create mode 100644 test/rules/object-literal-sort-keys/match-declaration-order/tslint.json create mode 100644 test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint create mode 100644 test/rules/object-literal-sort-keys/shorthand-first/tslint.json create mode 100644 test/rules/one-line/all/test.ts.fix create mode 100644 test/rules/one-line/all/test.ts.lint create mode 100644 test/rules/one-line/all/tslint.json create mode 100644 test/rules/one-line/no-whitespace/test.ts.fix create mode 100644 test/rules/one-line/no-whitespace/test.ts.lint create mode 100644 test/rules/one-line/no-whitespace/tslint.json create mode 100644 test/rules/one-line/none/test.ts.lint create mode 100644 test/rules/one-line/none/tslint.json create mode 100644 test/rules/one-variable-per-declaration/default/test.ts.lint create mode 100644 test/rules/one-variable-per-declaration/default/tslint.json create mode 100644 test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint create mode 100644 test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json create mode 100644 test/rules/only-arrow-functions/allow-declarations/test.ts.lint create mode 100644 test/rules/only-arrow-functions/allow-declarations/tslint.json create mode 100644 test/rules/only-arrow-functions/allow-named-functions/test.ts.lint create mode 100644 test/rules/only-arrow-functions/allow-named-functions/tslint.json create mode 100644 test/rules/only-arrow-functions/default/test.ts.lint create mode 100644 test/rules/only-arrow-functions/default/tslint.json create mode 100644 test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix create mode 100644 test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint create mode 100644 test/rules/ordered-imports/case-insensitive-legacy/tslint.json create mode 100644 test/rules/ordered-imports/case-insensitive/test.ts.fix create mode 100644 test/rules/ordered-imports/case-insensitive/test.ts.lint create mode 100644 test/rules/ordered-imports/case-insensitive/tslint.json create mode 100644 test/rules/ordered-imports/grouped-imports/test.ts.fix create mode 100644 test/rules/ordered-imports/grouped-imports/test.ts.lint create mode 100644 test/rules/ordered-imports/grouped-imports/tslint.json create mode 100644 test/rules/ordered-imports/groups-complex/test.ts.fix create mode 100644 test/rules/ordered-imports/groups-complex/test.ts.lint create mode 100644 test/rules/ordered-imports/groups-complex/tslint.json create mode 100644 test/rules/ordered-imports/groups-shared-order/test.ts.fix create mode 100644 test/rules/ordered-imports/groups-shared-order/test.ts.lint create mode 100644 test/rules/ordered-imports/groups-shared-order/tslint.json create mode 100644 test/rules/ordered-imports/groups-string-list/test.ts.fix create mode 100644 test/rules/ordered-imports/groups-string-list/test.ts.lint create mode 100644 test/rules/ordered-imports/groups-string-list/tslint.json create mode 100644 test/rules/ordered-imports/groups-unmatched/test.ts.fix create mode 100644 test/rules/ordered-imports/groups-unmatched/test.ts.lint create mode 100644 test/rules/ordered-imports/groups-unmatched/tslint.json create mode 100644 test/rules/ordered-imports/import-sources-any/default/test.ts.fix create mode 100644 test/rules/ordered-imports/import-sources-any/default/test.ts.lint create mode 100644 test/rules/ordered-imports/import-sources-any/default/tslint.json create mode 100644 test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix create mode 100644 test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint create mode 100644 test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json create mode 100644 test/rules/ordered-imports/inside-module-declaration/test.ts.lint create mode 100644 test/rules/ordered-imports/inside-module-declaration/tslint.json create mode 100644 test/rules/ordered-imports/lowercase-first/test.ts.fix create mode 100644 test/rules/ordered-imports/lowercase-first/test.ts.lint create mode 100644 test/rules/ordered-imports/lowercase-first/tslint.json create mode 100644 test/rules/ordered-imports/module-source-path/test.ts.fix create mode 100644 test/rules/ordered-imports/module-source-path/test.ts.lint create mode 100644 test/rules/ordered-imports/module-source-path/tslint.json create mode 100644 test/rules/ordered-imports/named-imports-any/test.ts.fix create mode 100644 test/rules/ordered-imports/named-imports-any/test.ts.lint create mode 100644 test/rules/ordered-imports/named-imports-any/tslint.json create mode 100644 test/rules/ordered-imports/standalone-grouped-import/test.ts.fix create mode 100644 test/rules/ordered-imports/standalone-grouped-import/test.ts.lint create mode 100644 test/rules/ordered-imports/standalone-grouped-import/tslint.json create mode 100644 test/rules/prefer-conditional-expression/check-else-if/test.ts.lint create mode 100644 test/rules/prefer-conditional-expression/check-else-if/tslint.json create mode 100644 test/rules/prefer-conditional-expression/default/test.ts.lint create mode 100644 test/rules/prefer-conditional-expression/default/tslint.json create mode 100644 test/rules/prefer-const/default/ambient.d.ts.lint create mode 100644 test/rules/prefer-const/default/global.ts.lint create mode 100644 test/rules/prefer-const/default/spread.ts.lint create mode 100644 test/rules/prefer-const/default/test.ts.fix create mode 100644 test/rules/prefer-const/default/test.ts.lint create mode 100644 test/rules/prefer-const/default/tslint.json create mode 100644 test/rules/prefer-const/destructuring-all/test.ts.fix create mode 100644 test/rules/prefer-const/destructuring-all/test.ts.lint create mode 100644 test/rules/prefer-const/destructuring-all/tslint.json create mode 100644 test/rules/prefer-for-of/test.ts.lint create mode 100644 test/rules/prefer-for-of/tslint.json create mode 100644 test/rules/prefer-function-over-method/allow-protected/test.ts.lint create mode 100644 test/rules/prefer-function-over-method/allow-protected/tslint.json create mode 100644 test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint create mode 100644 test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json create mode 100644 test/rules/prefer-function-over-method/allow-public/test.ts.lint create mode 100644 test/rules/prefer-function-over-method/allow-public/tslint.json create mode 100644 test/rules/prefer-function-over-method/default/test.ts.lint create mode 100644 test/rules/prefer-function-over-method/default/tslint.json create mode 100644 test/rules/prefer-method-signature/test.ts.fix create mode 100644 test/rules/prefer-method-signature/test.ts.lint create mode 100644 test/rules/prefer-method-signature/tslint.json create mode 100644 test/rules/prefer-object-spread/test.ts.fix create mode 100644 test/rules/prefer-object-spread/test.ts.lint create mode 100644 test/rules/prefer-object-spread/tslint.json create mode 100644 test/rules/prefer-readonly/default/test.ts.fix create mode 100644 test/rules/prefer-readonly/default/test.ts.lint create mode 100644 test/rules/prefer-readonly/default/tsconfig.json create mode 100644 test/rules/prefer-readonly/default/tslint.json create mode 100644 test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix create mode 100644 test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint create mode 100644 test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json create mode 100644 test/rules/prefer-readonly/only-inline-lambdas/tslint.json create mode 100644 test/rules/prefer-switch/default/test.ts.lint create mode 100644 test/rules/prefer-switch/default/tslint.json create mode 100644 test/rules/prefer-switch/min-cases-2/test.ts.lint create mode 100644 test/rules/prefer-switch/min-cases-2/tslint.json create mode 100644 test/rules/prefer-template/allow-single-concat/test.ts.lint create mode 100644 test/rules/prefer-template/allow-single-concat/tslint.json create mode 100644 test/rules/prefer-template/default/test.ts.lint create mode 100644 test/rules/prefer-template/default/tslint.json create mode 100644 test/rules/prefer-while/test.ts.fix create mode 100644 test/rules/prefer-while/test.ts.lint create mode 100644 test/rules/prefer-while/tslint.json create mode 100644 test/rules/promise-function-async/test.ts.lint create mode 100644 test/rules/promise-function-async/tsconfig.json create mode 100644 test/rules/promise-function-async/tslint.json create mode 100644 test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix create mode 100644 test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint create mode 100644 test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix create mode 100644 test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint create mode 100644 test/rules/quotemark/backtick/test.ts.fix create mode 100644 test/rules/quotemark/backtick/test.ts.lint create mode 100644 test/rules/quotemark/backtick/tslint.json create mode 100644 test/rules/quotemark/double-avoid-escape/test.ts.fix create mode 100644 test/rules/quotemark/double-avoid-escape/test.ts.lint create mode 100644 test/rules/quotemark/double-avoid-escape/tslint.json create mode 100644 test/rules/quotemark/double-avoid-template/test.ts.fix create mode 100644 test/rules/quotemark/double-avoid-template/test.ts.lint create mode 100644 test/rules/quotemark/double-avoid-template/tslint.json create mode 100644 test/rules/quotemark/double/test.ts.fix create mode 100644 test/rules/quotemark/double/test.ts.lint create mode 100644 test/rules/quotemark/double/tslint.json create mode 100644 test/rules/quotemark/invalid-double/test.ts.fix create mode 100644 test/rules/quotemark/invalid-double/test.ts.lint create mode 100644 test/rules/quotemark/invalid-double/tslint.json create mode 100644 test/rules/quotemark/invalid-single/test.ts.fix create mode 100644 test/rules/quotemark/invalid-single/test.ts.lint create mode 100644 test/rules/quotemark/invalid-single/tslint.json create mode 100644 test/rules/quotemark/jsx-double/test.tsx.fix create mode 100644 test/rules/quotemark/jsx-double/test.tsx.lint create mode 100644 test/rules/quotemark/jsx-double/tslint.json create mode 100644 test/rules/quotemark/jsx-single/test.tsx.fix create mode 100644 test/rules/quotemark/jsx-single/test.tsx.lint create mode 100644 test/rules/quotemark/jsx-single/tslint.json create mode 100644 test/rules/quotemark/single-avoid-escape/test.ts.fix create mode 100644 test/rules/quotemark/single-avoid-escape/test.ts.lint create mode 100644 test/rules/quotemark/single-avoid-escape/tslint.json create mode 100644 test/rules/quotemark/single-avoid-template/test.ts.fix create mode 100644 test/rules/quotemark/single-avoid-template/test.ts.lint create mode 100644 test/rules/quotemark/single-avoid-template/tslint.json create mode 100644 test/rules/quotemark/single/test.ts.fix create mode 100644 test/rules/quotemark/single/test.ts.lint create mode 100644 test/rules/quotemark/single/test.tsx.lint create mode 100644 test/rules/quotemark/single/tslint.json create mode 100644 test/rules/radix/test.ts.lint create mode 100644 test/rules/radix/tslint.json create mode 100644 test/rules/restrict-plus-operands/default/test.ts.lint create mode 100644 test/rules/restrict-plus-operands/default/tsconfig.json create mode 100644 test/rules/restrict-plus-operands/default/tslint.json create mode 100644 test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint create mode 100644 test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json create mode 100644 test/rules/restrict-plus-operands/esnext-bigint/tslint.json create mode 100644 test/rules/return-undefined/default/test.ts.lint create mode 100644 test/rules/return-undefined/default/tsconfig.json create mode 100644 test/rules/return-undefined/default/tslint.json create mode 100644 test/rules/return-undefined/pre-ts-3.6/test.ts.lint create mode 100644 test/rules/return-undefined/pre-ts-3.6/tsconfig.json create mode 100644 test/rules/return-undefined/pre-ts-3.6/tslint.json create mode 100644 test/rules/semicolon/always/test.ts.fix create mode 100644 test/rules/semicolon/always/test.ts.lint create mode 100644 test/rules/semicolon/always/tslint.json create mode 100644 test/rules/semicolon/enabled/test.ts.fix create mode 100644 test/rules/semicolon/enabled/test.ts.lint create mode 100644 test/rules/semicolon/enabled/tslint.json create mode 100644 test/rules/semicolon/ignore-bound-class-methods/test.ts.fix create mode 100644 test/rules/semicolon/ignore-bound-class-methods/test.ts.lint create mode 100644 test/rules/semicolon/ignore-bound-class-methods/tslint.json create mode 100644 test/rules/semicolon/ignore-interfaces/test.ts.fix create mode 100644 test/rules/semicolon/ignore-interfaces/test.ts.lint create mode 100644 test/rules/semicolon/ignore-interfaces/tslint.json create mode 100644 test/rules/semicolon/never/eof1.ts.lint create mode 100644 test/rules/semicolon/never/eof2.ts.lint create mode 100644 test/rules/semicolon/never/test.ts.fix create mode 100644 test/rules/semicolon/never/test.ts.lint create mode 100644 test/rules/semicolon/never/tslint.json create mode 100644 test/rules/semicolon/strict-bound-class-methods/test.ts.fix create mode 100644 test/rules/semicolon/strict-bound-class-methods/test.ts.lint create mode 100644 test/rules/semicolon/strict-bound-class-methods/tslint.json create mode 100644 test/rules/space-before-function-paren/always/test.ts.fix create mode 100644 test/rules/space-before-function-paren/always/test.ts.lint create mode 100644 test/rules/space-before-function-paren/always/tslint.json create mode 100644 test/rules/space-before-function-paren/mixed/test.ts.fix create mode 100644 test/rules/space-before-function-paren/mixed/test.ts.lint create mode 100644 test/rules/space-before-function-paren/mixed/tslint.json create mode 100644 test/rules/space-before-function-paren/never/test.ts.fix create mode 100644 test/rules/space-before-function-paren/never/test.ts.lint create mode 100644 test/rules/space-before-function-paren/never/tslint.json create mode 100644 test/rules/space-within-parens/force-one-space/test.ts.fix create mode 100644 test/rules/space-within-parens/force-one-space/test.ts.lint create mode 100644 test/rules/space-within-parens/force-one-space/tslint.json create mode 100644 test/rules/space-within-parens/force-two-spaces/test.ts.fix create mode 100644 test/rules/space-within-parens/force-two-spaces/test.ts.lint create mode 100644 test/rules/space-within-parens/force-two-spaces/tslint.json create mode 100644 test/rules/space-within-parens/no-space/test.ts.fix create mode 100644 test/rules/space-within-parens/no-space/test.ts.lint create mode 100644 test/rules/space-within-parens/no-space/tslint.json create mode 100644 test/rules/static-this/test.ts.fix create mode 100644 test/rules/static-this/test.ts.lint create mode 100644 test/rules/static-this/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-enum/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-enum/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-enum/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-mix/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-mix/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-mix/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-null-union/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-number/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-number/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-number/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-string/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-string/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-string/tslint.json create mode 100644 test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json create mode 100644 test/rules/strict-boolean-expressions/default/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/default/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/default/tslint.json create mode 100644 test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/ignore-rhs/tslint.json create mode 100644 test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/no-allow-mix/tslint.json create mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json create mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json create mode 100644 test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint create mode 100644 test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json create mode 100644 test/rules/strict-boolean-expressions/no-null-checks/tslint.json create mode 100644 test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint create mode 100644 test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json create mode 100644 test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json create mode 100644 test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint create mode 100644 test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json create mode 100644 test/rules/strict-comparisons/allow-string-order-comparison/tslint.json create mode 100644 test/rules/strict-comparisons/default/test.ts.lint create mode 100644 test/rules/strict-comparisons/default/tsconfig.json create mode 100644 test/rules/strict-comparisons/default/tslint.json create mode 100644 test/rules/strict-string-expressions/allow-empty-types/test.ts.fix create mode 100644 test/rules/strict-string-expressions/allow-empty-types/test.ts.lint create mode 100644 test/rules/strict-string-expressions/allow-empty-types/tsconfig.json create mode 100644 test/rules/strict-string-expressions/allow-empty-types/tslint.json create mode 100644 test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix create mode 100644 test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint create mode 100644 test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json create mode 100644 test/rules/strict-string-expressions/disallow-empty-types/tslint.json create mode 100644 test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint create mode 100644 test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json create mode 100644 test/rules/strict-type-predicates/no-strict-null-checks/tslint.json create mode 100644 test/rules/strict-type-predicates/strict-null-checks/test.ts.lint create mode 100644 test/rules/strict-type-predicates/strict-null-checks/tsconfig.json create mode 100644 test/rules/strict-type-predicates/strict-null-checks/tslint.json create mode 100644 test/rules/strict-type-predicates/unknown/test.ts.lint create mode 100644 test/rules/strict-type-predicates/unknown/tsconfig.json create mode 100644 test/rules/strict-type-predicates/unknown/tslint.json create mode 100644 test/rules/switch-default/test.ts.lint create mode 100644 test/rules/switch-default/tslint.json create mode 100644 test/rules/switch-final-break/always/test.ts.fix create mode 100644 test/rules/switch-final-break/always/test.ts.lint create mode 100644 test/rules/switch-final-break/always/tslint.json create mode 100644 test/rules/switch-final-break/default/test.ts.fix create mode 100644 test/rules/switch-final-break/default/test.ts.lint create mode 100644 test/rules/switch-final-break/default/tslint.json create mode 100644 test/rules/trailing-comma/multiline-always/test.ts.fix create mode 100644 test/rules/trailing-comma/multiline-always/test.ts.lint create mode 100644 test/rules/trailing-comma/multiline-always/tslint.json create mode 100644 test/rules/trailing-comma/multiline-custom/always/test.ts.lint create mode 100644 test/rules/trailing-comma/multiline-custom/always/tslint.json create mode 100644 test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint create mode 100644 test/rules/trailing-comma/multiline-custom/ignore/tslint.json create mode 100644 test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint create mode 100644 test/rules/trailing-comma/multiline-custom/mixed/tslint.json create mode 100644 test/rules/trailing-comma/multiline-custom/never/test.ts.fix create mode 100644 test/rules/trailing-comma/multiline-custom/never/test.ts.lint create mode 100644 test/rules/trailing-comma/multiline-custom/never/tslint.json create mode 100644 test/rules/trailing-comma/multiline-never/test.ts.fix create mode 100644 test/rules/trailing-comma/multiline-never/test.ts.lint create mode 100644 test/rules/trailing-comma/multiline-never/tslint.json create mode 100644 test/rules/trailing-comma/singleline-always/test.ts.fix create mode 100644 test/rules/trailing-comma/singleline-always/test.ts.lint create mode 100644 test/rules/trailing-comma/singleline-always/tslint.json create mode 100644 test/rules/trailing-comma/singleline-custom/always/test.ts.fix create mode 100644 test/rules/trailing-comma/singleline-custom/always/test.ts.lint create mode 100644 test/rules/trailing-comma/singleline-custom/always/tslint.json create mode 100644 test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint create mode 100644 test/rules/trailing-comma/singleline-custom/ignore/tslint.json create mode 100644 test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint create mode 100644 test/rules/trailing-comma/singleline-custom/mixed/tslint.json create mode 100644 test/rules/trailing-comma/singleline-custom/never/test.ts.fix create mode 100644 test/rules/trailing-comma/singleline-custom/never/test.ts.lint create mode 100644 test/rules/trailing-comma/singleline-custom/never/tslint.json create mode 100644 test/rules/trailing-comma/singleline-never/test.ts.fix create mode 100644 test/rules/trailing-comma/singleline-never/test.ts.lint create mode 100644 test/rules/trailing-comma/singleline-never/tslint.json create mode 100644 test/rules/trailing-comma/spec-compliant/test.ts.fix create mode 100644 test/rules/trailing-comma/spec-compliant/test.ts.lint create mode 100644 test/rules/trailing-comma/spec-compliant/tslint.json create mode 100644 test/rules/triple-equals/allow-null-check/test.ts.lint create mode 100644 test/rules/triple-equals/allow-null-check/tslint.json create mode 100644 test/rules/triple-equals/allow-undefined-check/test.ts.lint create mode 100644 test/rules/triple-equals/allow-undefined-check/tslint.json create mode 100644 test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix create mode 100644 test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint create mode 100644 test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json create mode 100644 test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix create mode 100644 test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint create mode 100644 test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json create mode 100644 test/rules/typedef-whitespace/both/nospace/test.ts.lint create mode 100644 test/rules/typedef-whitespace/both/nospace/tslint.json create mode 100644 test/rules/typedef-whitespace/both/onespace/test.ts.lint create mode 100644 test/rules/typedef-whitespace/both/onespace/tslint.json create mode 100644 test/rules/typedef-whitespace/both/space/test.ts.lint create mode 100644 test/rules/typedef-whitespace/both/space/tslint.json create mode 100644 test/rules/typedef-whitespace/left/nospace/test.ts.lint create mode 100644 test/rules/typedef-whitespace/left/nospace/tslint.json create mode 100644 test/rules/typedef-whitespace/left/onespace/test.ts.lint create mode 100644 test/rules/typedef-whitespace/left/onespace/tslint.json create mode 100644 test/rules/typedef-whitespace/left/space/test.ts.lint create mode 100644 test/rules/typedef-whitespace/left/space/tslint.json create mode 100644 test/rules/typedef-whitespace/none/test.ts.lint create mode 100644 test/rules/typedef-whitespace/none/tslint.json create mode 100644 test/rules/typedef-whitespace/right/nospace/test.ts.lint create mode 100644 test/rules/typedef-whitespace/right/nospace/tslint.json create mode 100644 test/rules/typedef-whitespace/right/onespace/test.ts.lint create mode 100644 test/rules/typedef-whitespace/right/onespace/tslint.json create mode 100644 test/rules/typedef-whitespace/right/space/test.ts.lint create mode 100644 test/rules/typedef-whitespace/right/space/tslint.json create mode 100644 test/rules/typedef/all/test.ts.lint create mode 100644 test/rules/typedef/all/tslint.json create mode 100644 test/rules/typedef/array-destructuring/test.ts.lint create mode 100644 test/rules/typedef/array-destructuring/tslint.json create mode 100644 test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint create mode 100644 test/rules/typedef/arrow-call-signature-and-parameter/tslint.json create mode 100644 test/rules/typedef/arrow-call-signature/test.ts.lint create mode 100644 test/rules/typedef/arrow-call-signature/tslint.json create mode 100644 test/rules/typedef/arrow-parameter/test.ts.lint create mode 100644 test/rules/typedef/arrow-parameter/tslint.json create mode 100644 test/rules/typedef/call-signature/test.ts.lint create mode 100644 test/rules/typedef/call-signature/tslint.json create mode 100644 test/rules/typedef/member-variable-declaration/test.ts.lint create mode 100644 test/rules/typedef/member-variable-declaration/tslint.json create mode 100644 test/rules/typedef/none/test.ts.lint create mode 100644 test/rules/typedef/none/tslint.json create mode 100644 test/rules/typedef/object-destructuring/test.ts.lint create mode 100644 test/rules/typedef/object-destructuring/tslint.json create mode 100644 test/rules/typedef/parameter/test.ts.lint create mode 100644 test/rules/typedef/parameter/tslint.json create mode 100644 test/rules/typedef/variable-declaration-ignore-function/test.ts.lint create mode 100644 test/rules/typedef/variable-declaration-ignore-function/tslint.json create mode 100644 test/rules/typedef/variable-declaration/test.ts.lint create mode 100644 test/rules/typedef/variable-declaration/tslint.json create mode 100644 test/rules/typeof-compare/test.ts.lint create mode 100644 test/rules/typeof-compare/tslint.json create mode 100644 test/rules/unified-signatures/test.d.ts.lint create mode 100644 test/rules/unified-signatures/test.ts.lint create mode 100644 test/rules/unified-signatures/tslint.json create mode 100644 test/rules/unnecessary-bind/typed/test.ts.lint create mode 100644 test/rules/unnecessary-bind/typed/tsconfig.json create mode 100644 test/rules/unnecessary-bind/typed/tslint.json create mode 100644 test/rules/unnecessary-bind/untyped/test.ts.lint create mode 100644 test/rules/unnecessary-bind/untyped/tslint.json create mode 100644 test/rules/unnecessary-constructor/check-super-calls/test.ts.fix create mode 100644 test/rules/unnecessary-constructor/check-super-calls/test.ts.lint create mode 100644 test/rules/unnecessary-constructor/check-super-calls/tslint.json create mode 100644 test/rules/unnecessary-constructor/default/test.ts.fix create mode 100644 test/rules/unnecessary-constructor/default/test.ts.lint create mode 100644 test/rules/unnecessary-constructor/default/tslint.json create mode 100644 test/rules/unnecessary-else/allow-else-if/test.ts.lint create mode 100644 test/rules/unnecessary-else/allow-else-if/tslint.json create mode 100644 test/rules/unnecessary-else/default/test.ts.lint create mode 100644 test/rules/unnecessary-else/default/tslint.json create mode 100644 test/rules/use-default-type-parameter/test.ts.fix create mode 100644 test/rules/use-default-type-parameter/test.ts.lint create mode 100644 test/rules/use-default-type-parameter/tsconfig.json create mode 100644 test/rules/use-default-type-parameter/tslint.json create mode 100644 test/rules/use-isnan/test.ts.lint create mode 100644 test/rules/use-isnan/tslint.json create mode 100644 test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint create mode 100644 test/rules/variable-name/allow-leading-trailing-underscore/tslint.json create mode 100644 test/rules/variable-name/allow-leading-underscore/test.ts.lint create mode 100644 test/rules/variable-name/allow-leading-underscore/tslint.json create mode 100644 test/rules/variable-name/allow-pascal-case/test.ts.lint create mode 100644 test/rules/variable-name/allow-pascal-case/tslint.json create mode 100644 test/rules/variable-name/allow-snake-case/test.ts.lint create mode 100644 test/rules/variable-name/allow-snake-case/tslint.json create mode 100644 test/rules/variable-name/allow-trailing-underscore/test.ts.lint create mode 100644 test/rules/variable-name/allow-trailing-underscore/tslint.json create mode 100644 test/rules/variable-name/ban-keywords/test.ts.lint create mode 100644 test/rules/variable-name/ban-keywords/tslint.json create mode 100644 test/rules/variable-name/const-only-for-caps/test.ts.lint create mode 100644 test/rules/variable-name/const-only-for-caps/tslint.json create mode 100644 test/rules/variable-name/default/test.ts.lint create mode 100644 test/rules/variable-name/default/tslint.json create mode 100644 test/rules/whitespace/all/bom.ts.lint create mode 100644 test/rules/whitespace/all/import-type.lint create mode 100644 test/rules/whitespace/all/import.ts.lint create mode 100644 test/rules/whitespace/all/test.ts.fix create mode 100644 test/rules/whitespace/all/test.ts.lint create mode 100644 test/rules/whitespace/all/tslint.json create mode 100644 test/rules/whitespace/check-postbrace/test.ts.fix create mode 100644 test/rules/whitespace/check-postbrace/test.ts.lint create mode 100644 test/rules/whitespace/check-postbrace/tslint.json create mode 100644 test/rules/whitespace/check-separator/test.ts.lint create mode 100644 test/rules/whitespace/check-separator/tslint.json create mode 100644 test/rules/whitespace/none/test.ts.lint create mode 100644 test/rules/whitespace/none/tslint.json diff --git a/test/rules/_integration/enable-disable/test.ts.lint b/test/rules/_integration/enable-disable/test.ts.lint new file mode 100644 index 00000000000..3aae677ef36 --- /dev/null +++ b/test/rules/_integration/enable-disable/test.ts.lint @@ -0,0 +1,146 @@ +/* tslint:enable */ +var AAAaA = 'test' + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] +/* tslint:disable */ +var AAAaA = 'test' +/* tslint:disable */ +var AAAaA = 'test' +/* tslint:enable:quotemark */ +var AAAaA = 'test' + ~~~~~~ [' should be "] +/* tslint:enable */ +var AAAaA = 'test' + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] +/* tslint:disable:quotemark variable-name */ +var AAAaA = 'test' +/* tslint:disable:quotemark */ +var AAAaA = 'test' +/* tslint:enable:quotemark */ +var AAAaA = 'test' + ~~~~~~ [' should be "] +/* tslint:disable */ +var AAAaA = 'test' +/* tslint:enable:zasdadsa */ +var AAAaA = 'test' + +/* tslint:enable quotemark */ +var AAAaA = 'test' + ~~~~~~ [' should be "] +/* tslint:disable */ +var AAAaA = 'test' +/* tslint:enable quotemark variable-name */ +var AAAaA = 'test' + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] +/* tslint:disable quotemark */ +var AAAaA = 'test' + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +/* tslint:enable */ +var re; +re = /`/; + +// tslint:disable +var AAAaA = 'test' +// tslint:enable + +var AAAaA = 'test' // tslint:disable-line +var AAAaA = 'test' /* tslint:disable-line */ + +// tslint:disable-next-line:quotemark variable-name +var AAAaA = 'test' +/* tslint:disable-next-line:quotemark variable-name */ +var AAAaA = 'test' + +// tslint:disable +var AAAaA = 'test' // tslint:enable-line:quotemark + ~~~~~~ [' should be "] +// tslint:enable-next-line:variable-name +var AAAaA = 'test' + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +// tslint:enable + +/* tslint:disable:quotemark */ +var s = 'xxx'; + +// Test case for issue #1624 +// tslint:disable:quotemark variable-name +var AAAaA = 'test' // tslint:disable-line:quotemark +// tslint:disable-next-line:variable-name +var AAAaA = 'test' // previously `quotemark` rule was enabled after previous line + +var AAAaA = 'test' // previously both `quotemark` and `variable-name` rules were enabled after previous lines + +// tslint:enable:quotemark +// tslint:disable +var AAAaA = 'test' // tslint:disable-line:quotemark +var AAAaA = 'test' // ensure that disable-line rule correctly handles previous `enable rule - disable all` switches + +// tslint:enable:no-var-keyword +var AAAaA = 'test' // ensure that disabled in config rule isn't enabled + +/* tslint:enable-next-line: */ +var AAAaA = 'test' // ensure that nothing is enabled with explicit separator and empty list of rules + +/* tslint:enable-next-line quotemark*/ +var AAAaA = 'test' // ensure that comment end is handled correctly with implicit separator + ~~~~~~ [' should be "] + +/* tslint:enable-next-line:quotemark*/ +var AAAaA = 'test' // ensure that comment end is handled correctly with explicit separator + ~~~~~~ [' should be "] + +// ensure that line switches switch the whole line +var AAAaA = 'test'; /* tslint:enable-line quotemark */ var AAAaA = 'test' + ~~~~~~ [' should be "] + ~~~~~~ [' should be "] +var AAAaA = 'test' // line should not be affected + +// ensure that next-line switch only switches next line +var AAAaA = 'test'; /*tslint:enable-next-line*/ var AAAaA = 'test' +var AAAaA = 'test' + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] +var AAAaA = 'test' +var AAAaA = 'test'; //tslint:enable-next-line + + +// ensure that enable/disable switch switches at start of comment +var AAAaA = 'test'; //tslint:enable + ~~~~~~~~~~~~~ [comment must start with a space] +var AAAaA = 'test'; //tslint:disable + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] +var AAAaA = 'test' + +// ensure that "all" switches all rules +var AAAaA = 'test'; //tslint:enable-line all + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] + ~~~~~~~~~~~~~~~~~~~~~~ [comment must start with a space] + +// ensure that "all" switches all rules even if others are in the list +var AAAaA = 'test'; //tslint:enable-line quotemark all + ~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~ [' should be "] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [comment must start with a space] + +// ensure line switches only switch the next line +//tslint:enable-next-line:quotemark +'foo'; +~~~~~ [' should be "] +'bar'; +'baz'; // tslint:enable-line:quotemark +~~~~~ [' should be "] +'bas'; + +//tslint:enable:quotemark +//tslint:disable-next-line:quotemark +'foo'; +'bar'; +~~~~~ [' should be "] +'baz'; // tslint:disable-line:quotemark +'bas'; +~~~~~ [' should be "] diff --git a/test/rules/_integration/enable-disable/test.tsx.lint b/test/rules/_integration/enable-disable/test.tsx.lint new file mode 100644 index 00000000000..e6bab97957b --- /dev/null +++ b/test/rules/_integration/enable-disable/test.tsx.lint @@ -0,0 +1,69 @@ +const span = ( + + /* tslint:disable */ + { + x + 'test' + ~~~~~~ [' should be "] + } + text + +); + +const span = ( + + // tslint:disable-next-line + {x + 'test'} + ~~~~~~ [' should be "] + text + +); + +const span = ( + + {x + 'comment is ignored with text'} // tslint:disable-line + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] + works with text + +); + +const span = ( + + {x + 'comment is ignored without text'} // tslint:disable-line + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] + +); + +const span = ( + + /* tslint:disable */ {x + 'ignores comments before element if not root'} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] + +); + +const span = ( + + {x + 'ignores comments after element if not root'} /* tslint:disable-line */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] + +); + +const span = ( + /* tslint:disable-next-line */ + {x + 'ignores trailing comments of root element'} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] + +); + +const span = ( + + {{x + 'works for comments inside JsxExpression'} /* tslint:disable-line */} + +); + +const span = ( + + {/* tslint:disable-next-line */} + {x + 'works for comment-only expressions'} + text + +); diff --git a/test/rules/_integration/enable-disable/tslint.json b/test/rules/_integration/enable-disable/tslint.json new file mode 100644 index 00000000000..7038f339ba2 --- /dev/null +++ b/test/rules/_integration/enable-disable/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "quotemark": [true, "double"], + "variable-name": true, + "no-var-keyword": false, + "comment-format": [ + true, + "check-space" + ] + } +} diff --git a/test/rules/_integration/error-format/test.ts.lint b/test/rules/_integration/error-format/test.ts.lint new file mode 100644 index 00000000000..bb67e417440 --- /dev/null +++ b/test/rules/_integration/error-format/test.ts.lint @@ -0,0 +1,37 @@ +import {} from 'foo'; + +let noSubstitution; + ~~~~~~~~~~~~~~ [Identifier 'noSubstitution' is never reassigned; use 'const' instead of 'let'.] +let noFormat; + ~~~~~~~~ [no_format] +let format; + ~~~~~~ [let_base % ('format')] +let formatMultiArgs; + ~~~~~~~~~~~~~~~ [base % ('formatMultiArgs', 'let')] +var formatMultiArgsTrailingComma; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [base % ('formatMultiArgsTrailingComma', 'var', )] +let indirection; + ~~~~~~~~~~~ [let % ('indirection')] +var indirection2; + ~~~~~~~~~~~~ [var % ('indirection2')] +let indirection3; + ~~~~~~~~~~~~ [partial_format % ('let')] +var formatInSubstitution; + ~~~~~~~~~~~~~~~~~~~~ [preformatted] +let worksWithEscape; + ~~~~~~~~~~~~~~~ [full-substitution % ('Identifier \'worksWithEscape\' is never reassigned; use \'const\' instead of \'let\'.')] +var worksWithDoubleQuotes; + ~~~~~~~~~~~~~~~~~~~~~ [full-substitution % ("Identifier 'worksWithDoubleQuotes' is never reassigned; use 'const' instead of 'var'.")] +let doesntTrimSpaces; + ~~~~~~~~~~~~~~~~ [base3 % ("Identifier 'doesntTrimSpaces' is never reassigned; ", " 'let'")] + +[no_format]: Identifier 'noFormat' is never reassigned; use 'const' instead of 'let'. +[base]: Identifier '%s' is never reassigned; use 'const' instead of '%s'. +[let_base]: Identifier '%s' is never reassigned; use 'const' instead of 'let'. +[base2]: Identifier '%%s' is never reassigned; use 'const' instead of '%s'. +[let]: base2 % ('let') +[var]: base2 % ('var') +[partial_format]: base % ('indirection3') +[preformatted]: base % ('formatInSubstitution', 'var') +[full-substitution]: %s +[base3]: %suse 'const' instead of%s. \ No newline at end of file diff --git a/test/rules/_integration/error-format/tslint.json b/test/rules/_integration/error-format/tslint.json new file mode 100644 index 00000000000..369865b3ae9 --- /dev/null +++ b/test/rules/_integration/error-format/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-const": true + } +} diff --git a/test/rules/_integration/react/invalid.tsx.lint b/test/rules/_integration/react/invalid.tsx.lint new file mode 100644 index 00000000000..de36dea81c9 --- /dev/null +++ b/test/rules/_integration/react/invalid.tsx.lint @@ -0,0 +1,6 @@ +// don't crash on invalid jsx +// tslint:disable +const a = + + diff --git a/test/rules/_integration/react/test.tsx.lint b/test/rules/_integration/react/test.tsx.lint new file mode 100644 index 00000000000..cd7b705f2b2 --- /dev/null +++ b/test/rules/_integration/react/test.tsx.lint @@ -0,0 +1,58 @@ +import * as React from 'react'; // quotemark failure + ~~~~~~~ [' should be "] + +class BazComponent extends React.Component, {}> { + public render() { + return ( +
+ ); + } +} + +interface IFooProps extends React.Props { + fooProp: string; +} + +interface IFooState { + bar:string[]; // whitespace failure + ~ [missing whitespace] +} + +export class FooComponent extends React.Component { + public state = { + bar: [] as string[] + }; + + public render() { + return ( +
this.onClick()} class={true===false?"foo":"bar"}> + ~ [missing whitespace] + ~ [missing whitespace] + ~ [missing whitespace] + ~ [missing whitespace] + ~ [missing whitespace] + ~ [missing whitespace] + {this.state.bar.map((s) => {s})} + +
+ ); + } // indent failure +~ [space indentation expected] + + private onClick() { + console.info("foo component clicked"); + } +} + +export function buildFooComponent(): JSX.Element { + let x: string = "test"; + return ; +} + +// test false positive for JSX spread (https://github.com/palantir/tslint/issues/658) +class MyComponent extends React.Component<{}, {}> { + public render() { + let props = { foo: "bar" }; + return
; + } +} diff --git a/test/rules/_integration/react/tslint.json b/test/rules/_integration/react/tslint.json new file mode 100644 index 00000000000..bf90872d231 --- /dev/null +++ b/test/rules/_integration/react/tslint.json @@ -0,0 +1,21 @@ +{ + "rules": { + "curly": true, + "eofline": true, + "indent": [true, "spaces"], + "max-line-length": [true, 120], + "no-bitwise": true, + "no-unused-expression": true, + "quotemark": [true, "double"], + "semicolon": [true, "always"], + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-module", + "check-separator", + "check-type", + "check-typecast" + ] + } +} diff --git a/test/rules/_integration/typescript-version/correct.js.lint b/test/rules/_integration/typescript-version/correct.js.lint new file mode 100644 index 00000000000..c73eab3c737 --- /dev/null +++ b/test/rules/_integration/typescript-version/correct.js.lint @@ -0,0 +1,3 @@ +[typescript]: >= 2.0.0 +'foo'; +~~~~~ [' should be "] \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/correct.ts.fix b/test/rules/_integration/typescript-version/correct.ts.fix new file mode 100644 index 00000000000..00d7c9624e9 --- /dev/null +++ b/test/rules/_integration/typescript-version/correct.ts.fix @@ -0,0 +1 @@ +"foo"; \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/correct.ts.lint b/test/rules/_integration/typescript-version/correct.ts.lint new file mode 100644 index 00000000000..c73eab3c737 --- /dev/null +++ b/test/rules/_integration/typescript-version/correct.ts.lint @@ -0,0 +1,3 @@ +[typescript]: >= 2.0.0 +'foo'; +~~~~~ [' should be "] \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/if-else.ts.lint b/test/rules/_integration/typescript-version/if-else.ts.lint new file mode 100644 index 00000000000..a30dcdf1ce6 --- /dev/null +++ b/test/rules/_integration/typescript-version/if-else.ts.lint @@ -0,0 +1,21 @@ +'foo'; +~~~~~ [' should be "] +#if typescript 0.0.0 +'bar' +#else +"bar" +#endif + +#if typescript >= 2.0.0 +'baz' +#else +"baz" +#endif +~~~~~ [err] + +'bas' +~~~~~ [err] + +#if typescript >= 2.0.0 +[err]: ' should be " +#endif diff --git a/test/rules/_integration/typescript-version/skip.js.lint b/test/rules/_integration/typescript-version/skip.js.lint new file mode 100644 index 00000000000..75aca5a3539 --- /dev/null +++ b/test/rules/_integration/typescript-version/skip.js.lint @@ -0,0 +1,2 @@ +[typescript]: < 2.0.0 +'foo'; \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/skip.ts.lint b/test/rules/_integration/typescript-version/skip.ts.lint new file mode 100644 index 00000000000..0cb99adb064 --- /dev/null +++ b/test/rules/_integration/typescript-version/skip.ts.lint @@ -0,0 +1,2 @@ +[typescript]: 0.0.0 +'foo'; \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/substitution.ts.lint b/test/rules/_integration/typescript-version/substitution.ts.lint new file mode 100644 index 00000000000..d0b23d919e3 --- /dev/null +++ b/test/rules/_integration/typescript-version/substitution.ts.lint @@ -0,0 +1,4 @@ +[typescript]: >= 2.0.0 +'foo'; // substition has the same key as the version requirement, but still works +~~~~~ [typescript] +[typescript]: ' should be " \ No newline at end of file diff --git a/test/rules/_integration/typescript-version/tslint.json b/test/rules/_integration/typescript-version/tslint.json new file mode 100644 index 00000000000..4e380ea41bb --- /dev/null +++ b/test/rules/_integration/typescript-version/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "quotemark": [true, "double"] + }, + "jsRules": { + "quotemark": [true, "double"] + } +} diff --git a/test/rules/adjacent-overload-signatures/default/test.ts.lint b/test/rules/adjacent-overload-signatures/default/test.ts.lint new file mode 100644 index 00000000000..13bb2c09867 --- /dev/null +++ b/test/rules/adjacent-overload-signatures/default/test.ts.lint @@ -0,0 +1,166 @@ +// good + +interface i1 { + a(); + a(x: number); + b(); + b(x: string); +} + +interface i2 { + a(); + a(x: number); + a(): void; + b(); + b(x: string); +} + +interface i3 { + a(); + "a"(); +} + +interface i4 { + a(); + ["a"](); +} + +interface i5 { + a(): string; + bar: { + a(): number; + } +} + +interface i6 { + // ensure no false positives for properties/methods available from prototype chain + toString(): string; +} + +interface i7 { + // Computed properties with different source code text OK + [Symbol.iterator](): void; + [Symbol.toStringTag](): void; +} + +interface i8 { + // Computed property with same source code text as regular property OK + [Symbol.iterator](): void; + x: number; + "Symbol.iterator"(): void; +} + + +// bad + +interface b1 { + a(); + a(x: number); + b(); + b(x: string); + a(x: string); + ~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] +} + +interface b2 { + a(); + a(x: number); + b(); + b(x: string); + a(): void; + ~~~~~~~~~~ [All 'a' signatures should be adjacent] +} + +interface b3 { + a(); + 12(); + "a"(); + ~~~~~~ [All 'a' signatures should be adjacent] + 12(); + ~~~~~ [All '12' signatures should be adjacent] +} + +interface b4 { + a(); + b(): void; + ["a"](v: number): void; + ~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] +} + +interface b5 { + a(): string; + bar: { + a(): number; + b(); + a(b: number): void; + ~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] + } +} + +interface b6 { + (): void; + x: number; + (x: number): number; + ~~~~~~~~~~~~~~~~~~~~ [All '()' signatures should be adjacent] +} + +// Also works in classes, source files, modules, namespaces + +class C { + a(): void; + b(): void; + a(x: number): void; + ~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] +} + +declare function a(): void; +declare function b(): void; +declare function a(x: number): void; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] + +declare module "m" { + export function a(): void; + export function b(): void; + export function a(x: number): void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] +} + +declare namespace N { + export function a(): void; + export function b(): void; + export function a(x: number): void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'a' signatures should be adjacent] +} + +class Foo { + public static bar() {} + private constructor() {} + public bar() {} + public constructor(foo: any) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'constructor' signatures should be adjacent] +} + +// A semicolon on its own is a SemicolonClassElement, but still consider them adjacent. +class Bar { + get test() { return 0; }; + set test(v: number) {}; +} + +interface I { + // Catches computed properties with same source code text + [Symbol.iterator](): void; + x: number; + [Symbol.iterator](): void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'Symbol.iterator' signatures should be adjacent] +} + +class Accessors { + private x: number; + private y: number; + get x() {return this.x;} + get y() {return this.y;} + set x(newX: number) {this.x = newX;} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'x' signatures should be adjacent] + set y(newY: number) {this.y = newY;} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [All 'y' signatures should be adjacent] +} diff --git a/test/rules/adjacent-overload-signatures/default/tslint.json b/test/rules/adjacent-overload-signatures/default/tslint.json new file mode 100644 index 00000000000..69957950dd9 --- /dev/null +++ b/test/rules/adjacent-overload-signatures/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "adjacent-overload-signatures": true + } +} diff --git a/test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint b/test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint new file mode 100644 index 00000000000..536581f2871 --- /dev/null +++ b/test/rules/adjacent-overload-signatures/ignore-accessors/test.ts.lint @@ -0,0 +1,11 @@ +// good + +class Accessors { + private x: number; + private y: number; + get x() {return this.x;} + get y() {return this.y;} + // setter is not considered as an overload of getter + set x(newX: number) {this.x = newX;} + set y(newY: number) {this.y = newY;} +} diff --git a/test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json b/test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json new file mode 100644 index 00000000000..76ecf8ce198 --- /dev/null +++ b/test/rules/adjacent-overload-signatures/ignore-accessors/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "adjacent-overload-signatures": [true, { "ignore-accessors": true }] + } +} diff --git a/test/rules/align/arguments/test.ts.fix b/test/rules/align/arguments/test.ts.fix new file mode 100644 index 00000000000..7f30959b034 --- /dev/null +++ b/test/rules/align/arguments/test.ts.fix @@ -0,0 +1,149 @@ +function invalidParametersAlignment1(a: number, +b: number) { + var i = 0; +} + +function invalidParametersAlignment2(a: number, b: number, +c: number) { + var i = 0; +} + +function invalidParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +class C1 { + invalidParametersAlignment(a: number, + b: number) + { + } +} + +class InvalidAlignmentInConstructor { + constructor(a: number, + str: string) + { + } +} + +var invalidParametersAlignment4 = function(xxx: foo, + yyy: bar) { return true; } + +function validParametersAlignment1(a: number, b: number) { + var i = 0; +} + +function validParametersAlignment2(a: number, b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment4( + a: number, + b: number, + c: number) { + var i = 0; +} + +var validParametersAlignment6 = function(xxx: foo, + yyy: bar) { return true; } + +/////// + +function invalidArgumentsAlignment1() +{ + f(10, + 'abcd', 0); +} + +function invalidArgumentsAlignment2() +{ + f(10, + 'abcd', + 0); + +} + +class Foo { + constructor(a: number, + str: string) + { + } +} + +var invalidConstructorArgsAlignment = new foo(10, + "abcd"); + +function validArgumentsAlignment1() +{ + f(101, 'xyz', 'abc'); +} + +function validArgumentsAlignment2() +{ + f(1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f( + 1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f(1, 2, + 3, 4); +} + +//////// + +function invalidStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function invalidStatementsAlignment1() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function validStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function validStatementsAlignment2() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function shouldntCrash() { + let f = new Foo; +} diff --git a/test/rules/align/arguments/test.ts.lint b/test/rules/align/arguments/test.ts.lint new file mode 100644 index 00000000000..0202a35c2fd --- /dev/null +++ b/test/rules/align/arguments/test.ts.lint @@ -0,0 +1,152 @@ +function invalidParametersAlignment1(a: number, +b: number) { + var i = 0; +} + +function invalidParametersAlignment2(a: number, b: number, +c: number) { + var i = 0; +} + +function invalidParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +class C1 { + invalidParametersAlignment(a: number, + b: number) + { + } +} + +class InvalidAlignmentInConstructor { + constructor(a: number, + str: string) + { + } +} + +var invalidParametersAlignment4 = function(xxx: foo, + yyy: bar) { return true; } + +function validParametersAlignment1(a: number, b: number) { + var i = 0; +} + +function validParametersAlignment2(a: number, b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment4( + a: number, + b: number, + c: number) { + var i = 0; +} + +var validParametersAlignment6 = function(xxx: foo, + yyy: bar) { return true; } + +/////// + +function invalidArgumentsAlignment1() +{ + f(10, + 'abcd', 0); + ~~~~~~ [arguments are not aligned] +} + +function invalidArgumentsAlignment2() +{ + f(10, + 'abcd', + 0); + ~ [arguments are not aligned] + +} + +class Foo { + constructor(a: number, + str: string) + { + } +} + +var invalidConstructorArgsAlignment = new foo(10, + "abcd"); + ~~~~~~ [arguments are not aligned] + +function validArgumentsAlignment1() +{ + f(101, 'xyz', 'abc'); +} + +function validArgumentsAlignment2() +{ + f(1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f( + 1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f(1, 2, + 3, 4); +} + +//////// + +function invalidStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function invalidStatementsAlignment1() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function validStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function validStatementsAlignment2() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function shouldntCrash() { + let f = new Foo; +} diff --git a/test/rules/align/arguments/tslint.json b/test/rules/align/arguments/tslint.json new file mode 100644 index 00000000000..642cc953dcf --- /dev/null +++ b/test/rules/align/arguments/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "align": [true, "arguments"] + } +} diff --git a/test/rules/align/elements/test.ts.fix b/test/rules/align/elements/test.ts.fix new file mode 100644 index 00000000000..9c67ce0083a --- /dev/null +++ b/test/rules/align/elements/test.ts.fix @@ -0,0 +1,47 @@ +let foo = []; +let foo = [1, 2]; +let foo = [ + 1, 2 +]; +let foo = [ + 1, + 2 +]; +let foo = [ + 1, + 2 +]; +let foo = [ + ...foo, + 1 +]; +let foo = [ + , + 1, + , + , +]; +let foo = [ + , + 1, + , + , +] + +let [foo, bar] = foo; +let [ + foo, bar +] = foo; +let [foo, + bar +] = foo; +let [ + , + ...foo +] = foo; + +let foo: [number, number]; +let foo = [ + number + , number +] \ No newline at end of file diff --git a/test/rules/align/elements/test.ts.lint b/test/rules/align/elements/test.ts.lint new file mode 100644 index 00000000000..bcada281103 --- /dev/null +++ b/test/rules/align/elements/test.ts.lint @@ -0,0 +1,53 @@ +let foo = []; +let foo = [1, 2]; +let foo = [ + 1, 2 +]; +let foo = [ + 1, + 2 +]; +let foo = [ + 1, + 2 + ~ [elements are not aligned] +]; +let foo = [ + ...foo, + 1 + ~ [elements are not aligned] +]; +let foo = [ + , + 1, + , + , +]; +let foo = [ + , + 1, + ~ [elements are not aligned] + , + ~nil [elements are not aligned] + , +] + +let [foo, bar] = foo; +let [ + foo, bar +] = foo; +let [foo, + bar + ~~~ [elements are not aligned] +] = foo; +let [ + , + ...foo +] = foo; + +let foo: [number, number]; +let foo = [ + number + , number + ~~~~~~ [elements are not aligned] +] \ No newline at end of file diff --git a/test/rules/align/elements/tslint.json b/test/rules/align/elements/tslint.json new file mode 100644 index 00000000000..ce5e6722b9d --- /dev/null +++ b/test/rules/align/elements/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "align": [true, "elements"] + } +} diff --git a/test/rules/align/members/test.ts.fix b/test/rules/align/members/test.ts.fix new file mode 100644 index 00000000000..8b59a0a624e --- /dev/null +++ b/test/rules/align/members/test.ts.fix @@ -0,0 +1,40 @@ +interface Foo { + bar, + baz + bas + foo; +} + +class Foo { + bar, + baz() { + + }; + get bas() {} + foo; +} + +let Bar = class { + bar, + foo +} + +let foo = { + foo, + moep, + baz, + baz: foo, +} + +let { + foo, + boo, + baz, + baz, +} = foo; + +let foo: { + foo + bar + baz +} diff --git a/test/rules/align/members/test.ts.lint b/test/rules/align/members/test.ts.lint new file mode 100644 index 00000000000..51a20b69be1 --- /dev/null +++ b/test/rules/align/members/test.ts.lint @@ -0,0 +1,53 @@ +interface Foo { + bar, + baz + bas + ~~~ [0] + foo; + ~~~~ [0] +} + +class Foo { + bar, + baz() { + + }; + get bas() {} + ~~~~~~~~~~~~ [0] + foo; + ~~~~ [0] +} + +let Bar = class { + bar, + foo + ~~~ [0] +} + +let foo = { + foo, + moep, + baz, + ~~~ [0] + baz: foo, + ~~~~~~~~ [0] +} + +let { + foo, + boo, + baz, + ~~~ [0] + baz, + ~~~ [0] +} = foo; + +let foo: { + foo + bar + ~~~ [0] + baz + ~~~ [0] +} + +[0]: members are not aligned \ No newline at end of file diff --git a/test/rules/align/members/tslint.json b/test/rules/align/members/tslint.json new file mode 100644 index 00000000000..ee50416d766 --- /dev/null +++ b/test/rules/align/members/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "align": [true, "members"] + } +} diff --git a/test/rules/align/parameters/test.ts.fix b/test/rules/align/parameters/test.ts.fix new file mode 100644 index 00000000000..476991849a0 --- /dev/null +++ b/test/rules/align/parameters/test.ts.fix @@ -0,0 +1,32 @@ +function invalidParametersAlignment1(a: number, + b: number) { + var i = 0; +} + +function invalidParametersAlignment2(a: number, b: number, + c: number) { + var i = 0; +} + +function invalidParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +class C1 { + invalidParametersAlignment(a: number, + b: number) + { + } +} + +class InvalidAlignmentInConstructor { + constructor(a: number, + str: string) + { + } +} + +var invalidParametersAlignment4 = function(xxx: foo, + yyy: bar) { return true; } diff --git a/test/rules/align/parameters/test.ts.lint b/test/rules/align/parameters/test.ts.lint new file mode 100644 index 00000000000..a38a5152672 --- /dev/null +++ b/test/rules/align/parameters/test.ts.lint @@ -0,0 +1,39 @@ +function invalidParametersAlignment1(a: number, +b: number) { +~~~~~~~~~ [parameters are not aligned] + var i = 0; +} + +function invalidParametersAlignment2(a: number, b: number, +c: number) { +~~~~~~~~~ [parameters are not aligned] + var i = 0; +} + +function invalidParametersAlignment3(a: number, + b: number, + ~~~~~~~~~ [parameters are not aligned] + c: number) { + ~~~~~~~~~ [parameters are not aligned] + var i = 0; +} + +class C1 { + invalidParametersAlignment(a: number, + b: number) + ~~~~~~~~~ [parameters are not aligned] + { + } +} + +class InvalidAlignmentInConstructor { + constructor(a: number, + str: string) + ~~~~~~~~~~~ [parameters are not aligned] + { + } +} + +var invalidParametersAlignment4 = function(xxx: foo, + yyy: bar) { return true; } + ~~~~~~~~ [parameters are not aligned] diff --git a/test/rules/align/parameters/tslint.json b/test/rules/align/parameters/tslint.json new file mode 100644 index 00000000000..b9360403062 --- /dev/null +++ b/test/rules/align/parameters/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "align": [true, "parameters"] + } +} diff --git a/test/rules/align/statements/bom.ts.fix b/test/rules/align/statements/bom.ts.fix new file mode 100644 index 00000000000..1168a0b3915 --- /dev/null +++ b/test/rules/align/statements/bom.ts.fix @@ -0,0 +1,3 @@ +var foo = 1; +var bar = 2; +var baz = 3; diff --git a/test/rules/align/statements/bom.ts.lint b/test/rules/align/statements/bom.ts.lint new file mode 100644 index 00000000000..9defdf3f4f5 --- /dev/null +++ b/test/rules/align/statements/bom.ts.lint @@ -0,0 +1,4 @@ +var foo = 1; +var bar = 2; + var baz = 3; + ~~~~~~~~~~~~ [statements are not aligned] diff --git a/test/rules/align/statements/test.ts.fix b/test/rules/align/statements/test.ts.fix new file mode 100644 index 00000000000..ab62ae38cc1 --- /dev/null +++ b/test/rules/align/statements/test.ts.fix @@ -0,0 +1,157 @@ +function invalidParametersAlignment1(a: number, +b: number) { + var i = 0; +} + +function invalidParametersAlignment2(a: number, b: number, +c: number) { + var i = 0; +} + +function invalidParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +class C1 { + invalidParametersAlignment(a: number, + b: number) + { + } +} + +class InvalidAlignmentInConstructor { + constructor(a: number, + str: string) + { + } +} + +var invalidParametersAlignment4 = function(xxx: foo, + yyy: bar) { return true; } + +function validParametersAlignment1(a: number, b: number) { + var i = 0; +} + +function validParametersAlignment2(a: number, b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment4( + a: number, + b: number, + c: number) { + var i = 0; +} + +var validParametersAlignment6 = function(xxx: foo, + yyy: bar) { return true; } + + +/////// + +function invalidArgumentsAlignment1() +{ + f(10, + 'abcd', 0); +} + +function invalidArgumentsAlignment2() +{ + f(10, + 'abcd', + 0); +} + +class Foo { + constructor(a: number, + str: string) + { + } +} + +var invalidConstructorArgsAlignment = new foo(10, + "abcd"); + +function validArgumentsAlignment1() +{ + f(101, 'xyz', 'abc'); +} + +function validArgumentsAlignment2() +{ + f(1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f( + 1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f(1, 2, + 3, 4); +} + +//////// + +function invalidStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function invalidStatementsAlignment1() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function validStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function validStatementsAlignment2() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function shouldntCrash() { + let f = new Foo; +} + +if (foo) { + bar; +}; + +if (foo) { + bar; +} /* should not be removed */; diff --git a/test/rules/align/statements/test.ts.lint b/test/rules/align/statements/test.ts.lint new file mode 100644 index 00000000000..412c6dfdd81 --- /dev/null +++ b/test/rules/align/statements/test.ts.lint @@ -0,0 +1,159 @@ +function invalidParametersAlignment1(a: number, +b: number) { + var i = 0; +} + +function invalidParametersAlignment2(a: number, b: number, +c: number) { + var i = 0; +} + +function invalidParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +class C1 { + invalidParametersAlignment(a: number, + b: number) + { + } +} + +class InvalidAlignmentInConstructor { + constructor(a: number, + str: string) + { + } +} + +var invalidParametersAlignment4 = function(xxx: foo, + yyy: bar) { return true; } + +function validParametersAlignment1(a: number, b: number) { + var i = 0; +} + +function validParametersAlignment2(a: number, b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment3(a: number, + b: number, + c: number) { + var i = 0; +} + +function validParametersAlignment4( + a: number, + b: number, + c: number) { + var i = 0; +} + +var validParametersAlignment6 = function(xxx: foo, + yyy: bar) { return true; } + + +/////// + +function invalidArgumentsAlignment1() +{ + f(10, + 'abcd', 0); +} + +function invalidArgumentsAlignment2() +{ + f(10, + 'abcd', + 0); +} + +class Foo { + constructor(a: number, + str: string) + { + } +} + +var invalidConstructorArgsAlignment = new foo(10, + "abcd"); + +function validArgumentsAlignment1() +{ + f(101, 'xyz', 'abc'); +} + +function validArgumentsAlignment2() +{ + f(1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f( + 1, + 2, + 3, + 4); +} + +function validArgumentsAlignment3() +{ + f(1, 2, + 3, 4); +} + +//////// + +function invalidStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; + ~~~~~~~~~~ [statements are not aligned] +} + +function invalidStatementsAlignment1() +{ + var i = 0; + { + var j = 0; + var k = 1; + ~~~~~~~~~~ [statements are not aligned] + } +} + +function validStatementsAlignment1() +{ + var i = 0; + var j = 0; + var k = 1; +} + +function validStatementsAlignment2() +{ + var i = 0; + { + var j = 0; + var k = 1; + } +} + +function shouldntCrash() { + let f = new Foo; +} + +if (foo) { + bar; +}; + +if (foo) { + bar; +} /* should not be removed */; diff --git a/test/rules/align/statements/tslint.json b/test/rules/align/statements/tslint.json new file mode 100644 index 00000000000..3bd25ec81d8 --- /dev/null +++ b/test/rules/align/statements/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "align": [true, "statements"] + } +} diff --git a/test/rules/array-type/array-simple/test.ts.fix b/test/rules/array-type/array-simple/test.ts.fix new file mode 100644 index 00000000000..9fe94f1a5af --- /dev/null +++ b/test/rules/array-type/array-simple/test.ts.fix @@ -0,0 +1,65 @@ +let x: undefined[] = [undefined] as undefined[]; +let xx: object[] = []; +let y: string[] = ["2"]; +let z: any[] = [3, "4"]; +let u: unknown[] = []; + +let xx: number[][] = [[1, 2], [3]]; +let yy: number[][] = [[4, 5], [6]]; + +let ya = [[1, "2"]] as Array<[number, string]>; + +type Arr = T[]; +type ParenthesisArr = (T)[]; +type DoubleParenthesisArr = ((T))[]; + +// Ignore user defined aliases +let yyyy: Arr>>> = [[[["2"]]]]; + +interface ArrayClass { + foo: T[]; + bar: T[]; + baz: Arr; + xyz: this[]; +} + +function fooFunction(foo: Array>) { + return foo.map(e => e.foo); +} + +function barFunction(bar: Array>) { + return bar.map(e => e.bar); +} + +function bazFunction(baz: Arr>) { + return baz.map(e => e.baz); +} + +let fooVar: Array<(c: number) => number>; +let barVar: Array<(c: number) => number>; + +type fooUnion = Array; +type barUnion = Array; +type bazUnion = Array<(string|number|boolean)>; + +type fooIntersection = Array; +type barIntersection = Array; +type bazIntersection = Array<(string & number)>; + +namespace fooName { + type BarType = { bar: string }; + type BazType = Arr; +} + +let v: fooName.BarType[] = [{ bar: "bar" }]; + +let w: Array> = [["baz"]]; + +interface FooInterface { + '.bar': {baz: string[];}; +} + +// Test an unknown Array +let t: unknown[] = []; +let u: unknown[] = []; + diff --git a/test/rules/array-type/array-simple/test.ts.lint b/test/rules/array-type/array-simple/test.ts.lint new file mode 100644 index 00000000000..18605baac0f --- /dev/null +++ b/test/rules/array-type/array-simple/test.ts.lint @@ -0,0 +1,86 @@ +let x: Array = [undefined] as undefined[]; + ~~~~~~~~~~~~~~~~ [0] +let xx: Array = []; + ~~~~~~~~~~~~~ [0] +let y: string[] = >["2"]; + ~~~~~~~~~~~~~ [0] +let z: Array = [3, "4"]; + ~~~~~ [0] +let u: Array = []; + ~~~~~~~~~~~~~~ [0] + +let xx: Array> = [[1, 2], [3]]; + ~~~~~~~~~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~~ [0] +let yy: number[][] = [[4, 5], [6]]; + +let ya = [[1, "2"]] as[number, string][]; + ~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + +type Arr = Array; + ~~~~~~~~ [0] +type ParenthesisArr = (T)[]; +type DoubleParenthesisArr = ((T))[]; + +// Ignore user defined aliases +let yyyy: Arr>[]> = [[[["2"]]]]; + ~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + +interface ArrayClass { + foo: Array; + ~~~~~~~~ [0] + bar: T[]; + baz: Arr; + xyz: this[]; +} + +function fooFunction(foo: Array>) { + return foo.map(e => e.foo); +} + +function barFunction(bar: ArrayClass[]) { + ~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + return bar.map(e => e.bar); +} + +function bazFunction(baz: Arr>) { + return baz.map(e => e.baz); +} + +let fooVar: Array<(c: number) => number>; +let barVar: ((c: number) => number)[]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + +type fooUnion = Array; +type barUnion = (string|number|boolean)[]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] +type bazUnion = ((string|number|boolean))[]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + +type fooIntersection = Array; +type barIntersection = (string & number)[]; + ~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] +type bazIntersection = ((string & number))[]; + ~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + +namespace fooName { + type BarType = { bar: string }; + type BazType = Arr; +} + +let v: Array = [{ bar: "bar" }]; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +let w: fooName.BazType[] = [["baz"]]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead.] + +interface FooInterface { + '.bar': {baz: string[];}; +} + +// Test an unknown Array +let t: unknown[] = []; +let u: Array = []; + ~~~~~~~~~~~~~~ [0] + +[0]: Array type using 'Array' is forbidden for simple types. Use 'T[]' instead. diff --git a/test/rules/array-type/array-simple/tslint.json b/test/rules/array-type/array-simple/tslint.json new file mode 100644 index 00000000000..a483323c7cb --- /dev/null +++ b/test/rules/array-type/array-simple/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "array-type": [true, "array-simple"] + } +} diff --git a/test/rules/array-type/array/test.ts.fix b/test/rules/array-type/array/test.ts.fix new file mode 100644 index 00000000000..99dd1bef794 --- /dev/null +++ b/test/rules/array-type/array/test.ts.fix @@ -0,0 +1,50 @@ +let x: undefined[] = [undefined] as undefined[]; +let y: string[] = ["2"]; +let z: any[] = [3, "4"]; +let u: unknown[] = []; + +let xx: number[][] = [[1, 2], [3]]; +let yy: number[][] = [[4, 5], [6]]; + +let ya = [[1, "2"]] as[number, string][]; + +type Arr = T[]; + +// Ignore user defined aliases +let yyyy: Arr[][]> = [[[["2"]]]]; + +interface ArrayClass { + foo: T[]; + bar: T[]; + baz: Arr; +} + +function fooFunction(foo: ArrayClass[]) { + return foo.map(e => e.foo); +} + +function barFunction(bar: ArrayClass[]) { + return bar.map(e => e.bar); +} + +function bazFunction(baz: Arr>) { + return baz.map(e => e.baz); +} + +let fooVar: ((c: number) => number)[]; +let barVar: ((c: number) => number)[]; + +type fooUnion = (string|number|boolean)[]; +type barUnion = (string|number|boolean)[]; + +type fooIntersection = (string & number)[]; +type barIntersection = (string & number)[]; + +interface FooInterface { + '.bar': {baz: string[];}; +} + +// Test an unknown Array +let t: unknown[] = []; +let u: unknown[] = []; + diff --git a/test/rules/array-type/array/test.ts.lint b/test/rules/array-type/array/test.ts.lint new file mode 100644 index 00000000000..d7b4efe095f --- /dev/null +++ b/test/rules/array-type/array/test.ts.lint @@ -0,0 +1,65 @@ +let x: Array = [undefined] as undefined[]; + ~~~~~~~~~~~~~~~~ [0] +let y: string[] = >["2"]; + ~~~~~~~~~~~~~ [0] +let z: Array = [3, "4"]; + ~~~~~ [0] +let u: Array = []; + ~~~~~~~~~~~~~~ [0] + +let xx: Array> = [[1, 2], [3]]; + ~~~~~~~~~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~~ [0] +let yy: number[][] = [[4, 5], [6]]; + +let ya = [[1, "2"]] as[number, string][]; + +type Arr = Array; + ~~~~~~~~ [0] + +// Ignore user defined aliases +let yyyy: Arr>[]> = [[[["2"]]]]; + ~~~~~~~~~~~~~~~~~~ [0] + +interface ArrayClass { + foo: Array; + ~~~~~~~~ [0] + bar: T[]; + baz: Arr; +} + +function fooFunction(foo: Array>) { + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + return foo.map(e => e.foo); +} + +function barFunction(bar: ArrayClass[]) { + return bar.map(e => e.bar); +} + +function bazFunction(baz: Arr>) { + return baz.map(e => e.baz); +} + +let fooVar: Array<(c: number) => number>; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let barVar: ((c: number) => number)[]; + +type fooUnion = Array; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +type barUnion = (string|number|boolean)[]; + +type fooIntersection = Array; + ~~~~~~~~~~~~~~~~~~~~~~ [0] +type barIntersection = (string & number)[]; + +interface FooInterface { + '.bar': {baz: string[];}; +} + +// Test an unknown Array +let t: unknown[] = []; +let u: Array = []; + ~~~~~~~~~~~~~~ [0] + +[0]: Array type using 'Array' is forbidden. Use 'T[]' instead. diff --git a/test/rules/array-type/array/tslint.json b/test/rules/array-type/array/tslint.json new file mode 100644 index 00000000000..184d4606431 --- /dev/null +++ b/test/rules/array-type/array/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "array-type": [true, "array"] + } +} diff --git a/test/rules/array-type/generic/test.ts.fix b/test/rules/array-type/generic/test.ts.fix new file mode 100644 index 00000000000..f67b3148f24 --- /dev/null +++ b/test/rules/array-type/generic/test.ts.fix @@ -0,0 +1,50 @@ +let x: Array = [1] as Array; +let y: Array = >["2"]; +let z: Array = [3, "4"]; +let u: Array = []; + +let xx: Array> = [[1, 2], [3]]; +let yy: Array> = [[4, 5], [6]]; + +let ya = [[1, "2"]] as Array<[number, string]>; + +type Arr = Array; + +// Ignore user defined aliases +let yyyy: Arr>>> = [[[["2"]]]]; + +interface ArrayClass { + foo: Array; + bar: Array; + baz: Arr; +} + +function fooFunction(foo: Array>) { + return foo.map(e => e.foo); +} + +function barFunction(bar: Array>) { + return bar.map(e => e.bar); +} + +function bazFunction(baz: Arr>) { + return baz.map(e => e.baz); +} + +let fooVar: Array<(c: number) => number>; +let barVar: Array<(c: number) => number>; + +type fooUnion = Array; +type barUnion = Array; + +type fooIntersection = Array; +type barIntersection = Array; + +interface FooInterface { + '.bar': {baz: Array;}; +} + +// Test an unknown Array +let t: Array = []; +let u: Array = []; + diff --git a/test/rules/array-type/generic/test.ts.lint b/test/rules/array-type/generic/test.ts.lint new file mode 100644 index 00000000000..c3f4496c5e7 --- /dev/null +++ b/test/rules/array-type/generic/test.ts.lint @@ -0,0 +1,65 @@ +let x: Array = [1] as number[]; + ~~~~~~~~ [0] +let y: string[] = >["2"]; + ~~~~~~~~ [0] +let z: Array = [3, "4"]; +let u: unknown[] = []; + ~~~~~~~~~ [0] + +let xx: Array> = [[1, 2], [3]]; +let yy: number[][] = [[4, 5], [6]]; + ~~~~~~~~~~ [0] + ~~~~~~~~ [0] + +let ya = [[1, "2"]] as[number, string][]; + ~~~~~~~~~~~~~~~~~~ [0] + +type Arr = Array; + +// Ignore user defined aliases +let yyyy: Arr>[]> = [[[["2"]]]]; + ~~~~~~~~~~~~~~~~~~~~ [0] + +interface ArrayClass { + foo: Array; + bar: T[]; + ~~~ [0] + baz: Arr; +} + +function fooFunction(foo: Array>) { + return foo.map(e => e.foo); +} + +function barFunction(bar: ArrayClass[]) { + ~~~~~~~~~~~~~~~~~~~~ [0] + return bar.map(e => e.bar); +} + +function bazFunction(baz: Arr>) { + return baz.map(e => e.baz); +} + +let fooVar: Array<(c: number) => number>; +let barVar: ((c: number) => number)[]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +type fooUnion = Array; +type barUnion = (string|number|boolean)[]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +type fooIntersection = Array; +type barIntersection = (string & number)[]; + ~~~~~~~~~~~~~~~~~~~ [0] + +interface FooInterface { + '.bar': {baz: string[];}; + ~~~~~~~~ [0] +} + +// Test an unknown Array +let t: unknown[] = []; + ~~~~~~~~~ [0] +let u: Array = []; + +[0]: Array type using 'T[]' is forbidden. Use 'Array' instead. diff --git a/test/rules/array-type/generic/tslint.json b/test/rules/array-type/generic/tslint.json new file mode 100644 index 00000000000..610c20100a8 --- /dev/null +++ b/test/rules/array-type/generic/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "array-type": [true, "generic"] + } +} diff --git a/test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix b/test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix new file mode 100644 index 00000000000..5e19f335993 --- /dev/null +++ b/test/rules/arrow-parens/ban-single-arg-parens/test.ts.fix @@ -0,0 +1,51 @@ +// valid case +var a = ([x, y]) => {}; +var aa = ({x, y}) => {}; +var b = (a: number) => {}; +var c = (a, b) => {}; +var f = (...rest) => {}; +var f = a: number => {}; // TSLint don't warn. But syntax is wrong. +var bar = (method: () => T) => { + method(); +}; +var barbar = (method: (a: any) => T) => { + method(""); +}; +var barbarbar = (method: (a) => T) => { + method(""); +}; +var piyo = (method: () => T) => { + method(); +}; +const validAsync = async (param: any) => {}; + +var e = (a => {})(1); +var f = ab => {}; + +arr.map(a => b); + +// invalid case +var a =a => {}; +const invalidAsync = async param => {}; +const invalidAsync = async param => {}; + +// parens required when return type annotation is present +const fn = (param): void => {}; + +let foo =bar => bar; + +let foo =bar => bar; + +let foo =bar => bar; + +let foo = async bar => bar; + +arr.map(a => b); + +foo(async a => b); + +function *gen() { yield a => b; } + +export default a => b; + +throw a => b; diff --git a/test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint b/test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint new file mode 100644 index 00000000000..6e59800db6a --- /dev/null +++ b/test/rules/arrow-parens/ban-single-arg-parens/test.ts.lint @@ -0,0 +1,70 @@ +// valid case +var a = ([x, y]) => {}; +var aa = ({x, y}) => {}; +var b = (a: number) => {}; +var c = (a, b) => {}; +var f = (...rest) => {}; +var f = a: number => {}; // TSLint don't warn. But syntax is wrong. +var bar = (method: () => T) => { + method(); +}; +var barbar = (method: (a: any) => T) => { + method(""); +}; +var barbarbar = (method: (a) => T) => { + method(""); +}; +var piyo = (method: () => T) => { + method(); +}; +const validAsync = async (param: any) => {}; + +var e = (a => {})(1); +var f = ab => {}; + +arr.map(a => b); + +// invalid case +var a = (a) => {}; + ~ [0] +const invalidAsync = async (param) => {}; + ~~~~~ [0] +const invalidAsync = async(param) => {}; + ~~~~~ [0] + +// parens required when return type annotation is present +const fn = (param): void => {}; + +let foo = (bar,) => bar; + ~~~ [0] + +let foo = ( + bar + ~~~ [0] +) => bar; + +let foo = ( + bar, + ~~~ [0] +) => bar; + +let foo = async ( + bar, + ~~~ [0] +) => bar; + +arr.map((a) => b); + ~ [0] + +foo(async (a) => b); + ~ [0] + +function *gen() { yield (a) => b; } + ~ [0] + +export default (a) => b; + ~ [0] + +throw (a) => b; + ~ [0] +[0]: Parentheses are prohibited around the parameter in this single parameter arrow function diff --git a/test/rules/arrow-parens/ban-single-arg-parens/tslint.json b/test/rules/arrow-parens/ban-single-arg-parens/tslint.json new file mode 100644 index 00000000000..972351cafb9 --- /dev/null +++ b/test/rules/arrow-parens/ban-single-arg-parens/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "arrow-parens": [ + true, + "ban-single-arg-parens" + ] + } +} diff --git a/test/rules/arrow-parens/default/test.ts.fix b/test/rules/arrow-parens/default/test.ts.fix new file mode 100644 index 00000000000..780c4f61339 --- /dev/null +++ b/test/rules/arrow-parens/default/test.ts.fix @@ -0,0 +1,27 @@ +// valid case +var a = (a) => {}; +var b = (a: number) => {}; +var c = (a, b) => {}; +var f = (...rest) => {}; +var f = a: number => {}; // TSLint don't warn. But syntax is wrong. +class Foo { + a: (a) =>{} +} +var bar = (method: () => T) => { + method(); +}; +var barbar = (method: (a: any) => T) => { + method(""); +}; +var barbarbar = (method: (a) => T) => { + method(""); +}; +var piyo = (method: () => T) => { + method(); +}; +const validAsync = async (param: any) => {}; +const validAsync = async (param) => {}; + +// invalid case +var e = ((a) => {})(1); +var f = (ab) => {}; diff --git a/test/rules/arrow-parens/default/test.ts.lint b/test/rules/arrow-parens/default/test.ts.lint new file mode 100644 index 00000000000..463decd2270 --- /dev/null +++ b/test/rules/arrow-parens/default/test.ts.lint @@ -0,0 +1,29 @@ +// valid case +var a = (a) => {}; +var b = (a: number) => {}; +var c = (a, b) => {}; +var f = (...rest) => {}; +var f = a: number => {}; // TSLint don't warn. But syntax is wrong. +class Foo { + a: (a) =>{} +} +var bar = (method: () => T) => { + method(); +}; +var barbar = (method: (a: any) => T) => { + method(""); +}; +var barbarbar = (method: (a) => T) => { + method(""); +}; +var piyo = (method: () => T) => { + method(); +}; +const validAsync = async (param: any) => {}; +const validAsync = async (param) => {}; + +// invalid case +var e = (a => {})(1); + ~ [Parentheses are required around the parameters of an arrow function definition] +var f = ab => {}; + ~~ [Parentheses are required around the parameters of an arrow function definition] diff --git a/test/rules/arrow-parens/default/tslint.json b/test/rules/arrow-parens/default/tslint.json new file mode 100644 index 00000000000..f2bb606a314 --- /dev/null +++ b/test/rules/arrow-parens/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "arrow-parens": true + } +} diff --git a/test/rules/arrow-return-shorthand/default/test.ts.fix b/test/rules/arrow-return-shorthand/default/test.ts.fix new file mode 100644 index 00000000000..2c485de7c8f --- /dev/null +++ b/test/rules/arrow-return-shorthand/default/test.ts.fix @@ -0,0 +1,21 @@ +// Invalid: +(() => 0); +(() => ({ x: 1 })); +(() => { + return 0; +}); + +// Valid: +(() => 0); +(() => {}); +(() => { throw 0; }) +(() => { const x = 0; return x; }); + +// No fix if there's a comment. +(() => /**/ { return 0; }); +(() => { /**/ return 0; }); +(() => { return /**/ 0; }); +(() => { return 0 /**/ }); +(() => { return 0 /**/; }); +(() => { return 0; /**/ }); + diff --git a/test/rules/arrow-return-shorthand/default/test.ts.lint b/test/rules/arrow-return-shorthand/default/test.ts.lint new file mode 100644 index 00000000000..b922ef93192 --- /dev/null +++ b/test/rules/arrow-return-shorthand/default/test.ts.lint @@ -0,0 +1,31 @@ +// Invalid: +(() => { return 0; }); + ~~~~~~~~~~~~~ [0] +(() => { return { x: 1 } }); + ~~~~~~~~~~~~~~~~~~~ [1] +(() => { + return 0; +}); + +// Valid: +(() => 0); +(() => {}); +(() => { throw 0; }) +(() => { const x = 0; return x; }); + +// No fix if there's a comment. +(() => /**/ { return 0; }); + ~~~~~~~~~~~~~ [0] +(() => { /**/ return 0; }); + ~~~~~~~~~~~~~~~~~~ [0] +(() => { return /**/ 0; }); + ~~~~~~~~~~~~~~~~~~ [0] +(() => { return 0 /**/ }); + ~~~~~~~~~~~~~~~~~ [0] +(() => { return 0 /**/; }); + ~~~~~~~~~~~~~~~~~~ [0] +(() => { return 0; /**/ }); + ~~~~~~~~~~~~~~~~~~ [0] + +[0]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return'. +[1]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return', and wrapping the object literal in parentheses. diff --git a/test/rules/arrow-return-shorthand/default/tslint.json b/test/rules/arrow-return-shorthand/default/tslint.json new file mode 100644 index 00000000000..880c0cf113e --- /dev/null +++ b/test/rules/arrow-return-shorthand/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "arrow-return-shorthand": true + } +} diff --git a/test/rules/arrow-return-shorthand/multiline/test.ts.fix b/test/rules/arrow-return-shorthand/multiline/test.ts.fix new file mode 100644 index 00000000000..f80bb6ed8f4 --- /dev/null +++ b/test/rules/arrow-return-shorthand/multiline/test.ts.fix @@ -0,0 +1,20 @@ +// Invalid: +(() => 0); +(() => ({ x: 1 })); +(() => + 0); + +// Valid: +(() => 0); +(() => {}); +(() => { throw 0; }) +(() => { const x = 0; return x; }); + +// No fix if there's a comment. +(() => /**/ { return 0; }); +(() => { /**/ return 0; }); +(() => { return /**/ 0; }); +(() => { return 0 /**/ }); +(() => { return 0 /**/; }); +(() => { return 0; /**/ }); + diff --git a/test/rules/arrow-return-shorthand/multiline/test.ts.lint b/test/rules/arrow-return-shorthand/multiline/test.ts.lint new file mode 100644 index 00000000000..98d54b9d245 --- /dev/null +++ b/test/rules/arrow-return-shorthand/multiline/test.ts.lint @@ -0,0 +1,34 @@ +// Invalid: +(() => { return 0; }); + ~~~~~~~~~~~~~ [0] +(() => { return { x: 1 } }); + ~~~~~~~~~~~~~~~~~~~ [1] +(() => { + ~ + return 0; +~~~~~~~~~~~~~ +}); +~ [0] + +// Valid: +(() => 0); +(() => {}); +(() => { throw 0; }) +(() => { const x = 0; return x; }); + +// No fix if there's a comment. +(() => /**/ { return 0; }); + ~~~~~~~~~~~~~ [0] +(() => { /**/ return 0; }); + ~~~~~~~~~~~~~~~~~~ [0] +(() => { return /**/ 0; }); + ~~~~~~~~~~~~~~~~~~ [0] +(() => { return 0 /**/ }); + ~~~~~~~~~~~~~~~~~ [0] +(() => { return 0 /**/; }); + ~~~~~~~~~~~~~~~~~~ [0] +(() => { return 0; /**/ }); + ~~~~~~~~~~~~~~~~~~ [0] + +[0]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return'. +[1]: This arrow function body can be simplified by omitting the curly braces and the keyword 'return', and wrapping the object literal in parentheses. diff --git a/test/rules/arrow-return-shorthand/multiline/tslint.json b/test/rules/arrow-return-shorthand/multiline/tslint.json new file mode 100644 index 00000000000..429bf4cc655 --- /dev/null +++ b/test/rules/arrow-return-shorthand/multiline/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "arrow-return-shorthand": [true, "multiline"] + } +} diff --git a/test/rules/await-promise/custom-promise/test.ts.lint b/test/rules/await-promise/custom-promise/test.ts.lint new file mode 100644 index 00000000000..24b3614ded9 --- /dev/null +++ b/test/rules/await-promise/custom-promise/test.ts.lint @@ -0,0 +1,78 @@ +class CustomPromise {} + +async function fAny() { + const isAny: any = 1; + + // any type + await isAny; + + // union type with any type + await (Math.random() > 0.5 ? isAny : 0); +} + +async function fNonPromise() { + // number type + await 0; + ~~~~~~~ [0] + + // union type without Promise + await (Math.random() > 0.5 ? "" : 0); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + // non Promise type + class NonPromise extends Array {} + await new NonPromise(); + ~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +async function fStandardPromise() { + // direct type + const numberPromise: Promise; + await numberPromise; + + // 1st level base type + class Foo extends Promise {} + const foo: Foo = Foo.resolve(2); + await foo; + + // 2nd level base type + class Bar extends Foo {} + const bar: Bar = Bar.resolve(2); + await bar; + + // union type + await (Math.random() > 0.5 ? numberPromise : 0); + await (Math.random() > 0.5 ? foo : 0); + await (Math.random() > 0.5 ? bar : 0); + + // intersection type + const intersectionPromise: Promise & number; + await intersectionPromise; +} + +async function fCustomPromise() { + // direct type + const numberPromise: CustomPromise; + await numberPromise; + + // 1st level base type + class Foo extends CustomPromise {} + const foo: Foo = Foo.resolve(2); + await foo; + + // 2nd level base type + class Bar extends Foo {} + const bar: Bar = Bar.resolve(2); + await bar; + + // union type + await (Math.random() > 0.5 ? numberPromise : 0); + await (Math.random() > 0.5 ? foo : 0); + await (Math.random() > 0.5 ? bar : 0); + + // intersection type + const intersectionPromise: CustomPromise & number; + await intersectionPromise; +} + +[0]: Invalid 'await' of a non-Promise value. diff --git a/test/rules/await-promise/custom-promise/tsconfig.json b/test/rules/await-promise/custom-promise/tsconfig.json new file mode 100644 index 00000000000..ea71f9415cf --- /dev/null +++ b/test/rules/await-promise/custom-promise/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "target": "es6" + } +} \ No newline at end of file diff --git a/test/rules/await-promise/custom-promise/tslint.json b/test/rules/await-promise/custom-promise/tslint.json new file mode 100644 index 00000000000..9c27c722ced --- /dev/null +++ b/test/rules/await-promise/custom-promise/tslint.json @@ -0,0 +1,8 @@ +{ + "linterOptions": { + "typeCheck": true + }, + "rules": { + "await-promise": [true, "CustomPromise"] + } +} diff --git a/test/rules/await-promise/es6-promise/test.ts.lint b/test/rules/await-promise/es6-promise/test.ts.lint new file mode 100644 index 00000000000..6544b984781 --- /dev/null +++ b/test/rules/await-promise/es6-promise/test.ts.lint @@ -0,0 +1,58 @@ +async function fAny() { + const isAny: any = 1; + + // any type + await isAny; + + // union type with any type + await (Math.random() > 0.5 ? isAny : 0); +} + +async function fNonPromise() { + // number type + await 0; + ~~~~~~~ [0] + + // union type without Promise + await (Math.random() > 0.5 ? "" : 0); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + // non Promise type + class NonPromise extends Array {} + await new NonPromise(); + ~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +async function fPromise() { + // direct type + const numberPromise: Promise; + await numberPromise; + + // 1st level base type + class Foo extends Promise {} + const foo: Foo = Foo.resolve(2); + await foo; + + // 2nd level base type + class Bar extends Foo {} + const bar: Bar = Bar.resolve(2); + await bar; + + // union type + await (Math.random() > 0.5 ? numberPromise : 0); + await (Math.random() > 0.5 ? foo : 0); + await (Math.random() > 0.5 ? bar : 0); + + // intersection type + const intersectionPromise: Promise & number; + await intersectionPromise; +} + +type AxiosResponse = T; +interface AxiosPromise extends Promise> {} + +async function extendsPromise(v: AxiosPromise) { + await v; +} + +[0]: Invalid 'await' of a non-Promise value. diff --git a/test/rules/await-promise/es6-promise/tsconfig.json b/test/rules/await-promise/es6-promise/tsconfig.json new file mode 100644 index 00000000000..ea71f9415cf --- /dev/null +++ b/test/rules/await-promise/es6-promise/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "target": "es6" + } +} \ No newline at end of file diff --git a/test/rules/await-promise/es6-promise/tslint.json b/test/rules/await-promise/es6-promise/tslint.json new file mode 100644 index 00000000000..8f307816f9b --- /dev/null +++ b/test/rules/await-promise/es6-promise/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "await-promise": true + } +} diff --git a/test/rules/await-promise/for-await-of/test.ts.lint b/test/rules/await-promise/for-await-of/test.ts.lint new file mode 100644 index 00000000000..cc753ea5de0 --- /dev/null +++ b/test/rules/await-promise/for-await-of/test.ts.lint @@ -0,0 +1,51 @@ +[typescript]: >= 2.3.0 +async function correct(foo: AsyncIterableIterator) { + for await (const element of foo) {} +} + +async function correct2() { + for await (const element of asyncGenerator()) {} +} + +async function correct(foo: AsyncIterable) { + for await (const element of foo) {} +} + +async function correct3(foo: AsyncIterableIterator | AsyncIterableIterator) { + for await (const element of foo) {} +} + +async function incorrect(foo: Array) { + for await (const element of foo) {} + ~~~ [0] +} + +async function incorrect2(foo: IterableIterator>) { + for await (const element of foo) {} + ~~~ [0] +} + +async function incorrect3() { + for await (const element of asyncGenerator) {} + ~~~~~~~~~~~~~~ [0] +} + +async function incorrect4() { + for await (const element of generator()) {} + ~~~~~~~~~~~ [0] +} + +async function incorrect5(foo: Iterable) { + for await (const element of foo) {} + ~~~ [0] +} + +async function* asyncGenerator() { + yield 1; +} + +function* generator() { + yield 1; +} + +[0]: Invalid 'for-await-of' of a non-AsyncIterable value. diff --git a/test/rules/await-promise/for-await-of/tsconfig.json b/test/rules/await-promise/for-await-of/tsconfig.json new file mode 100644 index 00000000000..0d58d115f70 --- /dev/null +++ b/test/rules/await-promise/for-await-of/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "target": "esnext" + } +} diff --git a/test/rules/await-promise/for-await-of/tslint.json b/test/rules/await-promise/for-await-of/tslint.json new file mode 100644 index 00000000000..8f307816f9b --- /dev/null +++ b/test/rules/await-promise/for-await-of/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "await-promise": true + } +} diff --git a/test/rules/ban-comma-operator/test.ts.lint b/test/rules/ban-comma-operator/test.ts.lint new file mode 100644 index 00000000000..5e65d1e787e --- /dev/null +++ b/test/rules/ban-comma-operator/test.ts.lint @@ -0,0 +1,23 @@ +let x = (y = 1, z = 2); + ~~~~~~~~~~~~ [0] + +// Error prone: forgot to add parens around arguments. +(x, y => x + y)(a, b); + ~~~~~~~~~~~~~ [0] + +foo((bar, baz)); + ~~~~~~~~ [0] + +switch (blah) { + case 1, 2: // equals `case 2` - probably intended `case 1: case2:` + ~~~~ [0] + return true; + case 3: + return false; +} + +for(let i = 0, j = 0; i < 10, j < 10; i++, j++) { + ~~~~~~~~~~~~~~ [0] +} + +[0]: Do not use comma operator here because it can be easily misunderstood or lead to unintended bugs. diff --git a/test/rules/ban-comma-operator/tslint.json b/test/rules/ban-comma-operator/tslint.json new file mode 100644 index 00000000000..4f4d95561fa --- /dev/null +++ b/test/rules/ban-comma-operator/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ban-comma-operator": true + } +} diff --git a/test/rules/ban-ts-ignore/test.ts.lint b/test/rules/ban-ts-ignore/test.ts.lint new file mode 100644 index 00000000000..b093491e3b0 --- /dev/null +++ b/test/rules/ban-ts-ignore/test.ts.lint @@ -0,0 +1,33 @@ +if (false) { + // @ts-ignore: Unreachable code error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] + console.log("hello"); // Random comments. +} + +var x = 0; + +/// @ts-ignore Triple-slash +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] +x(); + +/// @ts-ignore +~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] +x( + 2, + 3); + +// come comment + +// @ts-ignore Multiple comments +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] + +// some other comment + +// @anohter + +x(); + +x( // @ts-ignore inline + ~~~~~~~~~~~~~~~~~~~~ [Do not use "// @ts-ignore" comments because they suppress compilation errors.] + 2, + 3); diff --git a/test/rules/ban-ts-ignore/tslint.json b/test/rules/ban-ts-ignore/tslint.json new file mode 100644 index 00000000000..103785c3dda --- /dev/null +++ b/test/rules/ban-ts-ignore/tslint.json @@ -0,0 +1,6 @@ +{ + "rules": { + "ban-ts-ignore": true + } + } + \ No newline at end of file diff --git a/test/rules/ban-types/test.ts.lint b/test/rules/ban-types/test.ts.lint new file mode 100644 index 00000000000..4e813ab2ccd --- /dev/null +++ b/test/rules/ban-types/test.ts.lint @@ -0,0 +1,20 @@ +let a: Object; + ~~~~~~ [Don't use 'Object' as a type.] +let b: {c: String}; + ~~~~~~ [Don't use 'String' as a type. Use 'string' instead.] +function foo(a: String) {} + ~~~~~~ [Don't use 'String' as a type. Use 'string' instead.] +'a' as String; + ~~~~~~ [Don't use 'String' as a type. Use 'string' instead.] +let c: F; + ~ [Don't use 'F' as a type.] +let d: Foooooo; + ~~~~~~~ [Don't use 'Foooooo' as a type.] + +// no warning for separately scoped types +let e: foo.String; + +// no warning for actual uses. +let f = Object(); +let g = Object.create(null); +let h = String(false); \ No newline at end of file diff --git a/test/rules/ban-types/tslint.json b/test/rules/ban-types/tslint.json new file mode 100644 index 00000000000..738570950f6 --- /dev/null +++ b/test/rules/ban-types/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "ban-types": [ + true, + ["String", "Use 'string' instead."], + ["Object"], + ["Fo*"] + ] + } +} diff --git a/test/rules/ban/test.ts.lint b/test/rules/ban/test.ts.lint new file mode 100644 index 00000000000..bc487516a86 --- /dev/null +++ b/test/rules/ban/test.ts.lint @@ -0,0 +1,41 @@ +console.time(); +window.toString(); +~~~~~~~~~~~~~~~ [err % ('window.toString')] +console.log(); +document.window.toString(); +reference.randomContainer.window.toString(); +globals.getDocument().window.toString(); +_.keys(obj).forEach(fun); +~~~~~~~~~~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] +_.map(fun, (x) => x); +~~~~~ [err % ('_.map')] +_.filter(array); +~~~~~~~~ [err % ('_.filter', "Use the native JavaScript 'myArray.filter' instead.")] +describe("some text", () => {}); +xdescribe("some text", () => {}); +~~~~~~~~~ [err % ('xdescribe')] +fdescribe("some text", () => {}); +~~~~~~~~~ [err % ('fdescribe')] +it("some text", () => {}); +xit("some text", () => {}); +~~~ [err % ('xit')] +fit("some text", () => {}); +~~~ [err % ('fit')] +someObject.fit() +chai.assert.equal(1, "1"); +~~~~~~~~~~~~~~~~~ [err % ('chai.assert.equal', "Use 'strictEqual' instead.")] +chai.equal(1, "1"); +assert.equal(1, "1"); +foo.assert.equal(1, "1"); +someObject.chai.assert.equal(1, "1"); +[].forEach(() => {}); +~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] +arr.forEach(() => {}); +~~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] +someObject.someProperty.forEach(() => {}); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('*.forEach', 'Use a regular for loop instead.')] +someObject._id.toString(); +~~~~~~~~~~~~~~~~~~~~~~~ [err % ('*._id.toString', "Use 'toHexString' instead.")] +someObject.toString(); + +[err]: Calls to '%s' are not allowed. \ No newline at end of file diff --git a/test/rules/ban/tslint.json b/test/rules/ban/tslint.json new file mode 100644 index 00000000000..739ed951c37 --- /dev/null +++ b/test/rules/ban/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "ban": [ + true, + "xit", + {"name": "fit"}, + {"name": ["xdescribe"]}, + ["fdescribe"], + ["window", "toString"], + {"name": ["_", "map"]}, + ["_", "filter", "Use the native JavaScript 'myArray.filter' instead."], + {"name": ["*", "forEach"], "message": "Use a regular for loop instead."}, + {"name": ["chai", "assert", "equal"], "message": "Use 'strictEqual' instead."}, + {"name": ["*", "_id", "toString"], "message": "Use 'toHexString' instead."} + ] + } +} diff --git a/test/rules/binary-expression-operand-order/test.ts.lint b/test/rules/binary-expression-operand-order/test.ts.lint new file mode 100644 index 00000000000..e551edd1458 --- /dev/null +++ b/test/rules/binary-expression-operand-order/test.ts.lint @@ -0,0 +1,45 @@ +"red" !== x; +~~~~~~~~~~~ [0] + +true === x; +~~~~~~~~~~ [0] + +false === x; +~~~~~~~~~~~ [0] + +null == x; +~~~~~~~~~ [0] + +undefined != x; +~~~~~~~~~~~~~~ [0] + +5 < x; +~~~~~ [0] + +-1 + x; +~~~~~~ [0] + +(-1) + x; +~~~~~~~~ [0] + +// Allows string literal left hand side. +"foo" + x; + +// Allows certain ordered operators. +1 - x; +1 / x; +1 % x; +1 << x; +1 >> x; +1 >>> x; +2 ** x; +"key" in x; +"foo", x; + +// Allows literals on both sides. +1 + 1; +1 + 1 + 1; +1 + x + 1; +~~~~~ [0] + +[0]: Literal expression should be on the right-hand side of a binary expression. diff --git a/test/rules/binary-expression-operand-order/tslint.json b/test/rules/binary-expression-operand-order/tslint.json new file mode 100644 index 00000000000..346b91833a5 --- /dev/null +++ b/test/rules/binary-expression-operand-order/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "binary-expression-operand-order": true + } +} diff --git a/test/rules/callable-types/test.ts.fix b/test/rules/callable-types/test.ts.fix new file mode 100644 index 00000000000..350ce4ca699 --- /dev/null +++ b/test/rules/callable-types/test.ts.fix @@ -0,0 +1,34 @@ +type I = () => void; + +type J = () => void; + +type K = (param1: U, param2: T) => U; + +type L = () => T + +type T = () => void; + +type U = (t: T) => T + +var fn: () => void; +function f(x: () => void): void; +function f(x: string | (() => void)): void; +function f(x: string | (() => void)): void; +function f(x: (() => string) | (() => number)): void; +function f(x: string & (() => void)): void; +function f(x: (() => string) & (() => number)): void; +function f(x: (() => string)[]): void; + +// Overloads OK +interface K { + (x: number): number; + (x: string): string; +} + +// handle modifiers +export type I0 = () => void; + +export type I1 = new () => void; + +export type T = () => void + diff --git a/test/rules/callable-types/test.ts.lint b/test/rules/callable-types/test.ts.lint new file mode 100644 index 00000000000..fc36bcb058f --- /dev/null +++ b/test/rules/callable-types/test.ts.lint @@ -0,0 +1,74 @@ +interface I { + (): void; + ~~~~~~~~~ [interface % ('type I = () => void;')] +} + +interface J extends Function { + (): void; + ~~~~~~~~~ [interface % ('type J = () => void;')] +} + +interface K { + (param1: U, param2: T): U; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [interface % ('type K = (param1: U, param2: T) => U;')] +} + +interface L { + (): T + ~~~~~ [interface % ('type L = () => T')] +} + +type T = { + (): void; + ~~~~~~~~~ [type % ('() => void')] +}; + +type U = { + (t: T): T; + ~~~~~~~~~~~~~ [type % ('(t: T) => T')] +} + +var fn: {(): void;}; + ~~~~~~~~~ [type % ('() => void')] +function f(x: { (): void }): void; + ~~~~~~~~ [type % ('() => void')] +function f(x: string | { (): void }): void; + ~~~~~~~~ [type % ('(() => void)')] +function f(x: string | ({ (): void })): void; + ~~~~~~~~ [type % ('() => void')] +function f(x: { (): string } | { (): number }): void; + ~~~~~~~~~~ [type % ('(() => string)')] + ~~~~~~~~~~ [type % ('(() => number)')] +function f(x: string & { (): void }): void; + ~~~~~~~~ [type % ('(() => void)')] +function f(x: { (): string } & { (): number }): void; + ~~~~~~~~~~ [type % ('(() => string)')] + ~~~~~~~~~~ [type % ('(() => number)')] +function f(x: { (): string }[]): void; + ~~~~~~~~~~ [type % ('(() => string)')] + +// Overloads OK +interface K { + (x: number): number; + (x: string): string; +} + +// handle modifiers +export interface I0 { + (): void; + ~~~~~~~~~ [interface % ('type I0 = () => void;')] +} + +export interface I1 { + new (): void; + ~~~~~~~~~~~~~ [interface % ('type I1 = new () => void;')] +} + +export type T = { + (): void; + ~~~~~~~~~ [type % ('() => void')] +} + +[_base]: %s has only a call signature — use `%s` instead. +[interface]: _base % ('Interface') +[type]: _base % ('Type literal') diff --git a/test/rules/callable-types/tslint.json b/test/rules/callable-types/tslint.json new file mode 100644 index 00000000000..d24a06daec4 --- /dev/null +++ b/test/rules/callable-types/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "callable-types": true + } +} diff --git a/test/rules/class-name/test.ts.lint b/test/rules/class-name/test.ts.lint new file mode 100644 index 00000000000..62436a26f20 --- /dev/null +++ b/test/rules/class-name/test.ts.lint @@ -0,0 +1,26 @@ +class ValidClassName { + +} + +class invalidClassName { + ~~~~~~~~~~~~~~~~ [0] +} + +class Another_Invalid_Class_Name { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +export default class { + // should not fail +} + +// anonymous class expression +var foo = class {}; +var bar = class invalidName {} + ~~~~~~~~~~~ [0] + +interface someInterface {} + ~~~~~~~~~~~~~ [0] +interface SomeInterface {} + +[0]: Class name must be in pascal case diff --git a/test/rules/class-name/tslint.json b/test/rules/class-name/tslint.json new file mode 100644 index 00000000000..fcaed86a61e --- /dev/null +++ b/test/rules/class-name/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "class-name": true + } +} diff --git a/test/rules/comment-format/allow-trailing-lowercase/test.ts.fix b/test/rules/comment-format/allow-trailing-lowercase/test.ts.fix new file mode 100644 index 00000000000..29c8535bbd0 --- /dev/null +++ b/test/rules/comment-format/allow-trailing-lowercase/test.ts.fix @@ -0,0 +1,15 @@ +// This is a valid +// multiline comment + +// This is an invalid +// multiline + +let a = 1; // Some description +let b = "foo"; // Another description + +// Another multiline +// comment .. +// +// With multiple +// paragraphs + diff --git a/test/rules/comment-format/allow-trailing-lowercase/test.ts.lint b/test/rules/comment-format/allow-trailing-lowercase/test.ts.lint new file mode 100644 index 00000000000..f53db41854f --- /dev/null +++ b/test/rules/comment-format/allow-trailing-lowercase/test.ts.lint @@ -0,0 +1,20 @@ +// This is a valid +// multiline comment + +// This is an invalid +//multiline + ~~~~~~~~~[space] + +let a = 1; // Some description +let b = "foo"; // another description + ~~~~~~~~~~~~~~~~~~~~[upper] + +// Another multiline +// comment .. +// +// with multiple + ~~~~~~~~~~~~~~[upper] +// paragraphs + +[upper]: comment must start with uppercase letter +[space]: comment must start with a space diff --git a/test/rules/comment-format/allow-trailing-lowercase/tslint.json b/test/rules/comment-format/allow-trailing-lowercase/tslint.json new file mode 100644 index 00000000000..705d0c25fc8 --- /dev/null +++ b/test/rules/comment-format/allow-trailing-lowercase/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-format": [true, "check-space", "check-uppercase", "allow-trailing-lowercase"] + } +} diff --git a/test/rules/comment-format/exceptions-pattern/test.ts.fix b/test/rules/comment-format/exceptions-pattern/test.ts.fix new file mode 100644 index 00000000000..c142d9cb849 --- /dev/null +++ b/test/rules/comment-format/exceptions-pattern/test.ts.fix @@ -0,0 +1,30 @@ +/// +class Clazz { // this comment is correct + /* block comment + * adada + */ + public funcxion() { // this comment has a capital letter starting it + // this comment is on its own line, and starts with a capital _and_ no space + console.log("test"); // this comment has no space + } + /// + //// foo +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +//noinspection JSUnusedGlobalSymbols +const unusedVar = 'unneeded value'; + +// tODO: Write more tests +// hACKING is not an exception + +// STDIN for input +// STDOUT for output +// stderr for errors + + + diff --git a/test/rules/comment-format/exceptions-pattern/test.ts.lint b/test/rules/comment-format/exceptions-pattern/test.ts.lint new file mode 100644 index 00000000000..58cb88eeabd --- /dev/null +++ b/test/rules/comment-format/exceptions-pattern/test.ts.lint @@ -0,0 +1,39 @@ +/// +class Clazz { // this comment is correct + /* block comment + * adada + */ + public funcxion() { // This comment has a capital letter starting it + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] + //This comment is on its own line, and starts with a capital _and_ no space + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_lower] + console.log("test"); //this comment has no space + ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] + } + /// + ////foo + ~~~ [space] +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +//noinspection JSUnusedGlobalSymbols +const unusedVar = 'unneeded value'; + +// TODO: Write more tests + ~~~~~~~~~~~~~~~~~~~~~~~ [lower] +// HACKING is not an exception + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] + +// STDIN for input +// STDOUT for output +// stderr for errors + + + +[lower]: comment must start with lowercase letter or its start must match the regex pattern "STD\w{2,3}" +[space]: comment must start with a space +[space_lower]: comment must start with a space and lowercase letter or its start must match the regex pattern "STD\w{2,3}" diff --git a/test/rules/comment-format/exceptions-pattern/tslint.json b/test/rules/comment-format/exceptions-pattern/tslint.json new file mode 100644 index 00000000000..095aa7b0de4 --- /dev/null +++ b/test/rules/comment-format/exceptions-pattern/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-format": [true, "check-space", "check-lowercase", {"ignore-pattern": "STD\\w{2,3}"}] + } +} diff --git a/test/rules/comment-format/exceptions-words/test.ts.fix b/test/rules/comment-format/exceptions-words/test.ts.fix new file mode 100644 index 00000000000..ff593a9c2fe --- /dev/null +++ b/test/rules/comment-format/exceptions-words/test.ts.fix @@ -0,0 +1,29 @@ +class Clazz { // this comment is correct + /* block comment + * adada + */ + public funcxion() { // this comment has a capital letter starting it + // this comment is on its own line, and starts with a capital _and_ no space + console.log("test"); // this comment has no space + } + /// + //// foo +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +//noinspection JSUnusedGlobalSymbols +const unusedVar = 'unneeded value'; + +// TODO: Write more tests + +// hACKING is not an exception + +// sTDIN for input +// sTDOUT for output +// stderr for errors + + diff --git a/test/rules/comment-format/exceptions-words/test.ts.lint b/test/rules/comment-format/exceptions-words/test.ts.lint new file mode 100644 index 00000000000..4a19e036682 --- /dev/null +++ b/test/rules/comment-format/exceptions-words/test.ts.lint @@ -0,0 +1,39 @@ +class Clazz { // this comment is correct + /* block comment + * adada + */ + public funcxion() { // This comment has a capital letter starting it + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] + //This comment is on its own line, and starts with a capital _and_ no space + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_lower] + console.log("test"); //this comment has no space + ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] + } + /// + ////foo + ~~~ [space] +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +//noinspection JSUnusedGlobalSymbols +const unusedVar = 'unneeded value'; + +// TODO: Write more tests + +// HACKING is not an exception + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] + +// STDIN for input + ~~~~~~~~~~~~~~~~ [lower] +// STDOUT for output + ~~~~~~~~~~~~~~~~~~ [lower] +// stderr for errors + + +[lower]: comment must start with lowercase letter or the word(s): TODO, HACK +[space]: comment must start with a space +[space_lower]: comment must start with a space and lowercase letter or the word(s): TODO, HACK diff --git a/test/rules/comment-format/exceptions-words/tslint.json b/test/rules/comment-format/exceptions-words/tslint.json new file mode 100644 index 00000000000..812c9d96fe1 --- /dev/null +++ b/test/rules/comment-format/exceptions-words/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-format": [true, "check-space", "check-lowercase", {"ignore-words": ["TODO", "HACK"]}] + } +} diff --git a/test/rules/comment-format/lower/test.ts.fix b/test/rules/comment-format/lower/test.ts.fix new file mode 100644 index 00000000000..d71c05768db --- /dev/null +++ b/test/rules/comment-format/lower/test.ts.fix @@ -0,0 +1,20 @@ +class Clazz { // this comment is correct + /* block comment + * adada + */ + public funcxion() { // this comment has a capital letter starting it + // this comment is on its own line, and starts with a capital _and_ no space + console.log("test"); // this comment has no space + } + /// + //// foo +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +//noinspection JSUnusedGlobalSymbols +const unusedVar = 'unneeded value'; + diff --git a/test/rules/comment-format/lower/test.ts.lint b/test/rules/comment-format/lower/test.ts.lint new file mode 100644 index 00000000000..07c3390abf6 --- /dev/null +++ b/test/rules/comment-format/lower/test.ts.lint @@ -0,0 +1,27 @@ +class Clazz { // this comment is correct + /* block comment + * adada + */ + public funcxion() { // This comment has a capital letter starting it + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [lower] + //This comment is on its own line, and starts with a capital _and_ no space + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_lower] + console.log("test"); //this comment has no space + ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] + } + /// + ////foo + ~~~ [space] +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +//noinspection JSUnusedGlobalSymbols +const unusedVar = 'unneeded value'; + +[lower]: comment must start with lowercase letter +[space]: comment must start with a space +[space_lower]: comment must start with a space and lowercase letter diff --git a/test/rules/comment-format/lower/test.tsx.fix b/test/rules/comment-format/lower/test.tsx.fix new file mode 100644 index 00000000000..7c09e671f03 --- /dev/null +++ b/test/rules/comment-format/lower/test.tsx.fix @@ -0,0 +1,9 @@ +const a = ( + + https://github.com/ { + // invalid comment + content + }, text + +); + diff --git a/test/rules/comment-format/lower/test.tsx.lint b/test/rules/comment-format/lower/test.tsx.lint new file mode 100644 index 00000000000..7a7e5388409 --- /dev/null +++ b/test/rules/comment-format/lower/test.tsx.lint @@ -0,0 +1,12 @@ +const a = ( + + https://github.com/ { + //invalid comment + ~~~~~~~~~~~~~~~ [space] + content + }, text + +); + + +[space]: comment must start with a space \ No newline at end of file diff --git a/test/rules/comment-format/lower/tslint.json b/test/rules/comment-format/lower/tslint.json new file mode 100644 index 00000000000..b5c3658ef21 --- /dev/null +++ b/test/rules/comment-format/lower/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-format": [true, "check-space", "check-lowercase"] + } +} diff --git a/test/rules/comment-format/upper/test.ts.fix b/test/rules/comment-format/upper/test.ts.fix new file mode 100644 index 00000000000..562af0396fa --- /dev/null +++ b/test/rules/comment-format/upper/test.ts.fix @@ -0,0 +1,27 @@ +class Clazz { // This comment is correct + /* block comment + * adada + */ + public funcxion() { // This comment has a lowercase letter starting it + // This comment is on its own line, and starts with a lowercase _and_ no space + console.log("test"); // This comment has no space + } + /// + //// Foo +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +// Tslint should show error here + +// Tslint: not a rule flag + +// tslint:disable-next-line:no-unused-expression +class Invalid {} + +// tslint:disable-next-line:no-unused-expression +class Valid {} + diff --git a/test/rules/comment-format/upper/test.ts.lint b/test/rules/comment-format/upper/test.ts.lint new file mode 100644 index 00000000000..d9d21816446 --- /dev/null +++ b/test/rules/comment-format/upper/test.ts.lint @@ -0,0 +1,37 @@ +class Clazz { // This comment is correct + /* block comment + * adada + */ + public funcxion() { // this comment has a lowercase letter starting it + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [upper] + //this comment is on its own line, and starts with a lowercase _and_ no space + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space_upper] + console.log("test"); //This comment has no space + ~~~~~~~~~~~~~~~~~~~~~~~~~ [space] + } + /// + ////foo + ~~~ [space_upper] +} + +//#region test +//#endregion + +`${location.protocol}//${location.hostname}` + +// tslint should show error here + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [upper] + +// tslint: not a rule flag + ~~~~~~~~~~~~~~~~~~~~~~~~ [upper] + +//tslint:disable-next-line:no-unused-expression + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [space] +class Invalid {} + +// tslint:disable-next-line:no-unused-expression +class Valid {} + +[upper]: comment must start with uppercase letter +[space]: comment must start with a space +[space_upper]: comment must start with a space and uppercase letter diff --git a/test/rules/comment-format/upper/tslint.json b/test/rules/comment-format/upper/tslint.json new file mode 100644 index 00000000000..acb87406447 --- /dev/null +++ b/test/rules/comment-format/upper/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-format": [true, "check-space", "check-uppercase"] + } +} diff --git a/test/rules/comment-type/combo/test.ts.lint b/test/rules/comment-type/combo/test.ts.lint new file mode 100644 index 00000000000..965f3029509 --- /dev/null +++ b/test/rules/comment-type/combo/test.ts.lint @@ -0,0 +1,25 @@ +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] + +// single comment + +/* multiline comment */ +~~~~~~~~~~~~~~~~~~~~~~~ [multiline] + +/** doc comment */ + + /** indented doc comment */ + +const x = /** inline doc comment */ 3; + +/* +~~ +actually +~~~~~~~~ +multiline +~~~~~~~~~ +*/ +~~ [multiline] + +[multiline]: multiline comments are not allowed +[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/combo/tslint.json b/test/rules/comment-type/combo/tslint.json new file mode 100644 index 00000000000..f15923071bb --- /dev/null +++ b/test/rules/comment-type/combo/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-type": [true, "singleline", "doc"] + } +} diff --git a/test/rules/comment-type/directive/test.ts.tslint b/test/rules/comment-type/directive/test.ts.tslint new file mode 100644 index 00000000000..26aa7ce4056 --- /dev/null +++ b/test/rules/comment-type/directive/test.ts.tslint @@ -0,0 +1,29 @@ +/// + +// single comment +~~~~~~~~~~~~~~~~~ [singleline] + +/* multiline comment */ +~~~~~~~~~~~~~~~~~~~~~~~ [multiline] + +/** doc comment */ +~~~~~~~~~~~~~~~~~~ [doc] + + /** indented doc comment */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] + +const x = /** inline doc comment */ 3; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] + +/* +~~ +actually +~~~~~~~~ +multiline +~~~~~~~~~ +*/ +~~ [multiline] + +[singleline]: singleline comments are not allowed +[multiline]: multiline comments are not allowed +[doc]: doc comments are not allowed diff --git a/test/rules/comment-type/directive/tslint.json b/test/rules/comment-type/directive/tslint.json new file mode 100644 index 00000000000..80a14818b2e --- /dev/null +++ b/test/rules/comment-type/directive/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-type": [true, "directive"] + } +} diff --git a/test/rules/comment-type/doc/test.ts.lint b/test/rules/comment-type/doc/test.ts.lint new file mode 100644 index 00000000000..d065facdec9 --- /dev/null +++ b/test/rules/comment-type/doc/test.ts.lint @@ -0,0 +1,27 @@ +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] + +// single comment +~~~~~~~~~~~~~~~~~ [singleline] + +/* multiline comment */ +~~~~~~~~~~~~~~~~~~~~~~~ [multiline] + +/** doc comment */ + + /** indented doc comment */ + +const x = /** inline doc comment */ 3; + +/* +~~ +actually +~~~~~~~~ +multiline +~~~~~~~~~ +*/ +~~ [multiline] + +[singleline]: singleline comments are not allowed +[multiline]: multiline comments are not allowed +[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/doc/tslint.json b/test/rules/comment-type/doc/tslint.json new file mode 100644 index 00000000000..8cdb60d9bcd --- /dev/null +++ b/test/rules/comment-type/doc/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-type": [true, "doc"] + } +} diff --git a/test/rules/comment-type/multiline/test.ts.lint b/test/rules/comment-type/multiline/test.ts.lint new file mode 100644 index 00000000000..b2318fdd373 --- /dev/null +++ b/test/rules/comment-type/multiline/test.ts.lint @@ -0,0 +1,25 @@ +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] + +// single comment +~~~~~~~~~~~~~~~~~ [singleline] + +/* multiline comment */ + +/** doc comment */ +~~~~~~~~~~~~~~~~~~ [doc] + + /** indented doc comment */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] + +const x = /** inline doc comment */ 3; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] + +/* +actually +multiline +*/ + +[singleline]: singleline comments are not allowed +[doc]: doc comments are not allowed +[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/multiline/tslint.json b/test/rules/comment-type/multiline/tslint.json new file mode 100644 index 00000000000..82a09889d0a --- /dev/null +++ b/test/rules/comment-type/multiline/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-type": [true, "multiline"] + } +} diff --git a/test/rules/comment-type/single-line/test.ts.lint b/test/rules/comment-type/single-line/test.ts.lint new file mode 100644 index 00000000000..7386ef8760e --- /dev/null +++ b/test/rules/comment-type/single-line/test.ts.lint @@ -0,0 +1,29 @@ +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [directive] + +// single comment + +/* multiline comment */ +~~~~~~~~~~~~~~~~~~~~~~~ [multiline] + +/** doc comment */ +~~~~~~~~~~~~~~~~~~ [doc] + + /** indented doc comment */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] + +const x = /** inline doc comment */ 3; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [doc] + +/* +~~ +actually +~~~~~~~~ +multiline +~~~~~~~~~ +*/ +~~ [multiline] + +[multiline]: multiline comments are not allowed +[doc]: doc comments are not allowed +[directive]: triple-slash directives are not allowed diff --git a/test/rules/comment-type/single-line/tslint.json b/test/rules/comment-type/single-line/tslint.json new file mode 100644 index 00000000000..3814eeb0381 --- /dev/null +++ b/test/rules/comment-type/single-line/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "comment-type": [true, "singleline"] + } +} diff --git a/test/rules/curly/as-needed/test.ts.lint b/test/rules/curly/as-needed/test.ts.lint new file mode 100644 index 00000000000..448d9151fa8 --- /dev/null +++ b/test/rules/curly/as-needed/test.ts.lint @@ -0,0 +1,53 @@ +if (so) { + ~ [0] + foo(); +} else { + ~ [0] + foo(); +} + +while (true) { + ~ [0] + foo(); +} + +if (so) { + ~ [0] + if (also) + foo(); +} + +if (so) { + ~ [0] + if (also) + foo(); + else + foo(); +} else + foo(); + +if (so) + bar(); +else { + ~ [0] + if (also) + foo(); +} + +// Some blocks are necessary. + +if (so) { + if (also) + foo(); +} else + bar(); + +function f() { + foo(); +} + +() => { foo(); }; + +try { foo(); } catch (e) { foo(); } finally { foo(); } + +[0]: Block contains only one statement; remove the curly braces. diff --git a/test/rules/curly/as-needed/tslint.json b/test/rules/curly/as-needed/tslint.json new file mode 100644 index 00000000000..81fdd50f632 --- /dev/null +++ b/test/rules/curly/as-needed/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "curly": [true, "as-needed"] + } +} diff --git a/test/rules/curly/defaults/test.ts.fix b/test/rules/curly/defaults/test.ts.fix new file mode 100644 index 00000000000..93047211552 --- /dev/null +++ b/test/rules/curly/defaults/test.ts.fix @@ -0,0 +1,103 @@ + if (a == 1) { console.log("a"); } + +if (x == 3) { + console.log("x"); +} + +if (y == 4) +{ + console.log("y"); +} + + if (z == 5) { // failure + console.log("z"); + } + + for (h = 0; h < 1; ++h) { console.log("h"); } + +for (i = 0; i < 1; ++i) { + console.log("i"); +} + +for (j = 0; j < 1; ++j) +{ + console.log("j"); +} + + for (k = 0; k < 1; ++k) { // failure + console.log("k"); + } + + for (k1 in l1) { console.log("l1"); } // failure + +for (k in l) { // failure + console.log("l"); +} + + for (k3 of l3) { console.log("l3"); } // failure + +for (k4 of l4) { // failure + console.log("l4"); +} + + while (m < 0) { console.log("q"); } // Failure + +while (m < 0) { + console.log("q"); +} + +while (n < 0) +{ + console.log("r"); +} + +while (n < 0) { // failure + console.log("s"); +} + + do { console.log("m1"); } // failure + while (i == 1); + +do { console.log("m2"); } +while (i == 1); + +do { + console.log("m3"); +} while (i == 1); + +do +{ + console.log("n"); +} +while (j == 1); + +do { // failure + console.log("o"); +} +while (k == 1); + +if (true) { + console.log("x"); +} else { console.log("y"); } // failure + +if (true) { + console.log("x"); +} else if (true) {console.log("y")}; + +for (let x of [1, 2, 3]) { + console.log(x); +} + +for (let y of [1, 2, 3]) { // failure + console.log(y); +} + +if (true) { /* some + comment */ + console.log(z); +} + +if (foo === "bar") { throw new Error( + "baz" +) +} diff --git a/test/rules/curly/defaults/test.ts.lint b/test/rules/curly/defaults/test.ts.lint new file mode 100644 index 00000000000..21b07949aa3 --- /dev/null +++ b/test/rules/curly/defaults/test.ts.lint @@ -0,0 +1,123 @@ + if (a == 1) console.log("a"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [if statements must be braced] + +if (x == 3) { + console.log("x"); +} + +if (y == 4) +{ + console.log("y"); +} + + if (z == 5) // failure + ~~~~~~~~~~~~~~~~~~~~~~ + console.log("z"); +~~~~~~~~~~~~~~~~~~~~~~~~~ [if statements must be braced] + + for (h = 0; h < 1; ++h) console.log("h"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +for (i = 0; i < 1; ++i) { + console.log("i"); +} + +for (j = 0; j < 1; ++j) +{ + console.log("j"); +} + + for (k = 0; k < 1; ++k) // failure + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log("k"); +~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + + for (k1 in l1) console.log("l1"); // failure + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +for (k in l) // failure +~~~~~~~~~~~~~~~~~~~~~~~ + console.log("l"); +~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + + for (k3 of l3) console.log("l3"); // failure + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +for (k4 of l4) // failure +~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log("l4"); +~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + + while (m < 0) console.log("q"); // Failure + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [while statements must be braced] + +while (m < 0) { + console.log("q"); +} + +while (n < 0) +{ + console.log("r"); +} + +while (n < 0) // failure +~~~~~~~~~~~~~~~~~~~~~~~~ + console.log("s"); +~~~~~~~~~~~~~~~~~~~~~ [while statements must be braced] + + do console.log("m1"); // failure + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + while (i == 1); +~~~~~~~~~~~~~~~~~~~ [do statements must be braced] + +do { console.log("m2"); } +while (i == 1); + +do { + console.log("m3"); +} while (i == 1); + +do +{ + console.log("n"); +} +while (j == 1); + +do // failure +~~~~~~~~~~~~~ + console.log("o"); +~~~~~~~~~~~~~~~~~~~~~ +while (k == 1); +~~~~~~~~~~~~~~~ [do statements must be braced] + +if (true) { + console.log("x"); +} else console.log("y"); // failure + ~~~~~~~~~~~~~~~~~~~~~~ [else statements must be braced] + +if (true) { + console.log("x"); +} else if (true) {console.log("y")}; + +for (let x of [1, 2, 3]) { + console.log(x); +} + +for (let y of [1, 2, 3]) // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(y); +~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +if (true) /* some +~~~~~~~~~~~~~~~~~ + comment */ +~~~~~~~~~~~~~~~~~~~~~~~ + console.log(z); +~~~~~~~~~~~~~~~~~~~ [if statements must be braced] + +if (foo === "bar") throw new Error( +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + "baz" +~~~~~~~ +) +~ [if statements must be braced] diff --git a/test/rules/curly/defaults/tslint.json b/test/rules/curly/defaults/tslint.json new file mode 100644 index 00000000000..c0855ef9fd0 --- /dev/null +++ b/test/rules/curly/defaults/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "curly": true + } +} diff --git a/test/rules/curly/ignore-same-line/test.ts.fix b/test/rules/curly/ignore-same-line/test.ts.fix new file mode 100644 index 00000000000..8363ab364bf --- /dev/null +++ b/test/rules/curly/ignore-same-line/test.ts.fix @@ -0,0 +1,93 @@ +if (a == 1) console.log("a"); + +if (x == 3) { + console.log("x"); +} + +if (y == 4) +{ + console.log("y"); +} + + if (z == 5) { // failure + console.log("z"); + } + +for (h = 0; h < 1; ++h) console.log("h"); + +for (i = 0; i < 1; ++i) { + console.log("i"); +} + +for (j = 0; j < 1; ++j) +{ + console.log("j"); +} + + for (k = 0; k < 1; ++k) { // failure + console.log("k"); + } + +for (k1 in l1) console.log("l1"); + +for (k in l) { // failure + console.log("l"); +} + +for (k3 of l3) console.log("l3"); + +for (k4 of l4) { // failure + console.log("l4"); +} + +while (m < 0) console.log("q"); + +while (m < 0) { + console.log("q"); +} + +while (n < 0) +{ + console.log("r"); +} + +while (n < 0) { // failure + console.log("s"); +} + +do console.log("m1"); +while (i == 1); + +do { console.log("m2"); } +while (i == 1); + +do { + console.log("m3"); +} while (i == 1); + +do +{ + console.log("n"); +} +while (j == 1); + +do { // failure + console.log("o"); +} +while (k == 1); + +if (true) { + console.log("x"); +} else console.log("y"); + +if (true) { + console.log("x"); +} else if (true) {console.log("y")}; + +for (let x of [1, 2, 3]) { + console.log(x); +} + +for (let y of [1, 2, 3]) { // failure + console.log(y); +} diff --git a/test/rules/curly/ignore-same-line/test.ts.lint b/test/rules/curly/ignore-same-line/test.ts.lint new file mode 100644 index 00000000000..2d51287c5f7 --- /dev/null +++ b/test/rules/curly/ignore-same-line/test.ts.lint @@ -0,0 +1,101 @@ +if (a == 1) console.log("a"); + +if (x == 3) { + console.log("x"); +} + +if (y == 4) +{ + console.log("y"); +} + + if (z == 5) // failure + ~~~~~~~~~~~~~~~~~~~~~~ + console.log("z"); +~~~~~~~~~~~~~~~~~~~~~~~~~ [if statements must be braced] + +for (h = 0; h < 1; ++h) console.log("h"); + +for (i = 0; i < 1; ++i) { + console.log("i"); +} + +for (j = 0; j < 1; ++j) +{ + console.log("j"); +} + + for (k = 0; k < 1; ++k) // failure + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log("k"); +~~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +for (k1 in l1) console.log("l1"); + +for (k in l) // failure +~~~~~~~~~~~~~~~~~~~~~~~ + console.log("l"); +~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +for (k3 of l3) console.log("l3"); + +for (k4 of l4) // failure +~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log("l4"); +~~~~~~~~~~~~~~~~~~~~~~ [for statements must be braced] + +while (m < 0) console.log("q"); + +while (m < 0) { + console.log("q"); +} + +while (n < 0) +{ + console.log("r"); +} + +while (n < 0) // failure +~~~~~~~~~~~~~~~~~~~~~~~~ + console.log("s"); +~~~~~~~~~~~~~~~~~~~~~ [while statements must be braced] + +do console.log("m1"); +while (i == 1); + +do { console.log("m2"); } +while (i == 1); + +do { + console.log("m3"); +} while (i == 1); + +do +{ + console.log("n"); +} +while (j == 1); + +do // failure +~~~~~~~~~~~~~ + console.log("o"); +~~~~~~~~~~~~~~~~~~~~~ +while (k == 1); +~~~~~~~~~~~~~~~ [do statements must be braced] + +if (true) { + console.log("x"); +} else console.log("y"); + +if (true) { + console.log("x"); +} else if (true) {console.log("y")}; + +for (let x of [1, 2, 3]) { + console.log(x); +} + +for (let y of [1, 2, 3]) // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + console.log(y); +~~~~~~~~~~~~~~~~~~~ [for statements must be braced] diff --git a/test/rules/curly/ignore-same-line/tslint.json b/test/rules/curly/ignore-same-line/tslint.json new file mode 100644 index 00000000000..9788efabf64 --- /dev/null +++ b/test/rules/curly/ignore-same-line/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "curly": [true, "ignore-same-line"] + } +} diff --git a/test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint b/test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint new file mode 100644 index 00000000000..a55df367b3b --- /dev/null +++ b/test/rules/cyclomatic-complexity/defaultThreshold/test.ts.lint @@ -0,0 +1,68 @@ +// Check that a default threshold is used if none is specified. + +function validThresholdPass() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + const condition3 = true ? "true" : "false"; + const condition4 = true ? "true" : "false"; + const condition5 = true ? "true" : "false"; + const condition6 = true ? "true" : "false"; + const condition7 = true ? "true" : "false"; + const condition8 = true ? "true" : "false"; + const condition9 = true ? "true" : "false"; + const condition10 = true ? "true" : "false"; + const condition11 = true ? "true" : "false"; + const condition12 = true ? "true" : "false"; + const condition13 = true ? "true" : "false"; + const condition14 = true ? "true" : "false"; + const condition15 = true ? "true" : "false"; + const condition16 = true ? "true" : "false"; + const condition17 = true ? "true" : "false"; + const condition18 = true ? "true" : "false"; + const condition19 = true ? "true" : "false"; +} + +function validThresholdFail() { +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition4 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition5 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition6 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition7 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition8 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition9 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition10 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition11 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition12 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition13 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition14 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition15 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition16 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition17 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition18 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition19 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition20 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function validThresholdFail has a cyclomatic complexity of 21 which is higher than the threshold of 20] diff --git a/test/rules/cyclomatic-complexity/defaultThreshold/tslint.json b/test/rules/cyclomatic-complexity/defaultThreshold/tslint.json new file mode 100644 index 00000000000..aee113f4f0b --- /dev/null +++ b/test/rules/cyclomatic-complexity/defaultThreshold/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "cyclomatic-complexity": [true] + } +} diff --git a/test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint b/test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint new file mode 100644 index 00000000000..aa6f059cad0 --- /dev/null +++ b/test/rules/cyclomatic-complexity/invalidThreshold/test.ts.lint @@ -0,0 +1,25 @@ +// Check that rule is not applied for invalid config values by checking a +// function with complexity higher than the dafault threshold. + +function invalidThreshold() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + const condition3 = true ? "true" : "false"; + const condition4 = true ? "true" : "false"; + const condition5 = true ? "true" : "false"; + const condition6 = true ? "true" : "false"; + const condition7 = true ? "true" : "false"; + const condition8 = true ? "true" : "false"; + const condition9 = true ? "true" : "false"; + const condition10 = true ? "true" : "false"; + const condition11 = true ? "true" : "false"; + const condition12 = true ? "true" : "false"; + const condition13 = true ? "true" : "false"; + const condition14 = true ? "true" : "false"; + const condition15 = true ? "true" : "false"; + const condition16 = true ? "true" : "false"; + const condition17 = true ? "true" : "false"; + const condition18 = true ? "true" : "false"; + const condition19 = true ? "true" : "false"; + const condition20 = true ? "true" : "false"; +} diff --git a/test/rules/cyclomatic-complexity/invalidThreshold/tslint.json b/test/rules/cyclomatic-complexity/invalidThreshold/tslint.json new file mode 100644 index 00000000000..d8c5fbdd4c0 --- /dev/null +++ b/test/rules/cyclomatic-complexity/invalidThreshold/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "cyclomatic-complexity": [true, -5] + } +} diff --git a/test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint b/test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint new file mode 100644 index 00000000000..cbf59112825 --- /dev/null +++ b/test/rules/cyclomatic-complexity/specifiedThreshold/test.ts.lint @@ -0,0 +1,383 @@ +// Test each function type. +const validFunctionExpression = function() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; +} + +const invalidFunctionExpression = function() { + ~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function has a cyclomatic complexity of 4 which is higher than the threshold of 3] + + +function validFunctionDeclaration() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; +} + +function invalidFunctionDeclaration() { +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function invalidFunctionDeclaration has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +const validArrowFunction = () => { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; +} + +const invalidArrowFunction = () => { + ~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +class MyClass { + get validGet(): string { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + return "test"; + } + + get invalidGet(): string { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return "test"; +~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [The function invalidGet has a cyclomatic complexity of 4 which is higher than the threshold of 3] + + set validSet(newValue: string) { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + } + + set invalidSet(newValue: string) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [The function invalidSet has a cyclomatic complexity of 4 which is higher than the threshold of 3] + + validMethod() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + } + + invalidMethod() { + ~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [The function invalidMethod has a cyclomatic complexity of 4 which is higher than the threshold of 3] +} + +class validConstructor { + constructor() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + } +} + +class invalidConstructor { + constructor() { + ~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [The function has a cyclomatic complexity of 4 which is higher than the threshold of 3] +} + +// Test each remaining expression type. +function validBinaryExpression() { + return first || second && third +} + +function invalidBinaryExpression() { +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return first || second && third || fourth; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function invalidBinaryExpression has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validSwitch() { + switch(5) { + case 0: + case 2: + return "even"; + case 1: + case 3: + return "odd"; + default: + return -1; + } +} + +function invalidSwitch() { +~~~~~~~~~~~~~~~~~~~~~~~~~~ + switch(5) { +~~~~~~~~~~~~~~~ + case 0: +~~~~~~~~~~~~~~~ + return 0; +~~~~~~~~~~~~~~~~~~~~~ + case 1: +~~~~~~~~~~~~~~~ + return 1; +~~~~~~~~~~~~~~~~~~~~~ + case 2: +~~~~~~~~~~~~~~~ + return 2; +~~~~~~~~~~~~~~~~~~~~~ + default: +~~~~~~~~~~~~~~~~ + return -1; +~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ +} +~ [The function invalidSwitch has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validCatch() { + try { } + catch(error) { } + try { } + catch(error) { } + try { } + finally { } +} + +function invalidCatch() { +~~~~~~~~~~~~~~~~~~~~~~~~~ + try { } +~~~~~~~~~~~ + catch(error) { } +~~~~~~~~~~~~~~~~~~~~ + try { } +~~~~~~~~~~~ + catch(error) { } +~~~~~~~~~~~~~~~~~~~~ + try { } +~~~~~~~~~~~ + catch(error) { } +~~~~~~~~~~~~~~~~~~~~ + try { } +~~~~~~~~~~~ + finally { } +~~~~~~~~~~~~~~~ +} +~ [The function invalidCatch has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validDo() { + do { } + while (false) + do { } + while (false) +} + +function invalidDo() { +~~~~~~~~~~~~~~~~~~~~~~ + do { } +~~~~~~~~~~ + while (false) +~~~~~~~~~~~~~~~~~ + do { } +~~~~~~~~~~ + while (false) +~~~~~~~~~~~~~~~~~ + do { } +~~~~~~~~~~ + while (false) +~~~~~~~~~~~~~~~~~ +} +~ [The function invalidDo has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validFor() { + for(;;) { } + for(;;) { } +} + +function invalidFor() { +~~~~~~~~~~~~~~~~~~~~~~~ + for(;;) { } +~~~~~~~~~~~~~~~ + for(;;) { } +~~~~~~~~~~~~~~~ + for(;;) { } +~~~~~~~~~~~~~~~ +} +~ [The function invalidFor has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validForIn() { + for(let i in [0,1,2]) { } + for(let i in [0,1,2]) { } +} + +function invalidForIn() { +~~~~~~~~~~~~~~~~~~~~~~~~~ + for(let i in [0,1,2]) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + for(let i in [0,1,2]) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + for(let i in [0,1,2]) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function invalidForIn has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validForOf() { + for(let i of [0,1,2]) { } + for(let i of [0,1,2]) { } +} + +function invalidForOf() { +~~~~~~~~~~~~~~~~~~~~~~~~~ + for(let i of [0,1,2]) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + for(let i of [0,1,2]) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + for(let i of [0,1,2]) { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [The function invalidForOf has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +let variable = 1; + +function validIf() { + if(variable) { } + if(variable) { } else { } +} + +function invalidIf() { +~~~~~~~~~~~~~~~~~~~~~~ + if(variable) { } +~~~~~~~~~~~~~~~~~~~~ + if(variable) { } else { } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if(variable) { } +~~~~~~~~~~~~~~~~~~~~ +} +~ [The function invalidIf has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +function validWhile() { + while(false) { } + while(false) { } +} + +function invalidWhile() { +~~~~~~~~~~~~~~~~~~~~~~~~~ + while(false) { } +~~~~~~~~~~~~~~~~~~~~ + while(false) { } +~~~~~~~~~~~~~~~~~~~~ + while(false) { } +~~~~~~~~~~~~~~~~~~~~ +} +~ [The function invalidWhile has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +// Test that the rule behaves correctly for nested functions. + +// Valid outer function, invalid inner function. +function outer1() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + function inner1() { + ~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition4 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition5 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [The function inner1 has a cyclomatic complexity of 4 which is higher than the threshold of 3] +} + +// Invalid outer function, valid inner function. +function outer2() { +~~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + function inner2() { +~~~~~~~~~~~~~~~~~~~~~~~ + const condition4 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition5 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ +} +~ [The function outer2 has a cyclomatic complexity of 4 which is higher than the threshold of 3] + +// Both valid. +function outer3() { + const condition1 = true ? "true" : "false"; + const condition2 = true ? "true" : "false"; + function inner3() { + const condition3 = true ? "true" : "false"; + const condition4 = true ? "true" : "false"; + } +} + +// Both invalid. +function outer4() { +~~~~~~~~~~~~~~~~~~~ + const condition1 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition2 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition3 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + function inner4() { +~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ + const condition4 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition5 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const condition6 = true ? "true" : "false"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ +~~~~~ [The function inner4 has a cyclomatic complexity of 4 which is higher than the threshold of 3] +} +~ [The function outer4 has a cyclomatic complexity of 4 which is higher than the threshold of 3] diff --git a/test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json b/test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json new file mode 100644 index 00000000000..b16ec05ded6 --- /dev/null +++ b/test/rules/cyclomatic-complexity/specifiedThreshold/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "cyclomatic-complexity": [true, 3] + } +} diff --git a/test/rules/deprecation/other.test.ts b/test/rules/deprecation/other.test.ts new file mode 100644 index 00000000000..780c95c9c38 --- /dev/null +++ b/test/rules/deprecation/other.test.ts @@ -0,0 +1,34 @@ +/** @deprecated reason */ +export function other(): void; +/** not deprecated */ +export function other(num: number); +export function other(_num?: number) {} + +/** @deprecated */ +export let other2: Function; + +/** This one has @deprecated somewhere in it's jsdoc */ +export let notDeprecated: any; +/* @deprecated but it's no JsDoc */ +export let notDeprecated2: any; + +/** @deprecated deprecated default export */ +let def = ""; +export default def; + +/** @deprecated */ +export class DeprecatedClass { + constructor() {} +} + +export class DeprecatedConstructorClass { + /** @deprecated */ + constructor() {} +} + +export class PartiallyDeprecatedClass { + constructor(); + /** @deprecated */ + constructor(foo: number); + constructor(_foo?: number) {} +} diff --git a/test/rules/deprecation/other2.test.ts b/test/rules/deprecation/other2.test.ts new file mode 100644 index 00000000000..77d6d94afda --- /dev/null +++ b/test/rules/deprecation/other2.test.ts @@ -0,0 +1,3 @@ +/** @deprecated */ +let x = ""; +export = x; \ No newline at end of file diff --git a/test/rules/deprecation/test.ts.lint b/test/rules/deprecation/test.ts.lint new file mode 100644 index 00000000000..a2131666f4c --- /dev/null +++ b/test/rules/deprecation/test.ts.lint @@ -0,0 +1,174 @@ +// don't show an error on imports, because they don't do any harm if not used +import def, {other, other2 as foobar, notDeprecated, notDeprecated2} from './other.test'; +import * as namespaceImport from './other.test'; +import * as other2 from './other2.test'; + +other(); +~~~~~ [errmsg % ('other', 'reason')] +other(1); +foobar(); +~~~~~~ [err % ('foobar')] +other2; +~~~~~~ [err % ('other2')] + +import tmp = namespaceImport.other; + +tmp; +~~~ [errmsg % ('tmp', 'reason')] + +declare interface D { + /** @deprecated */ m: () => void; +} + + +declare let d: D; +d.m(); + ~ [err % ('m')] + +/** + * Some text + * @one-tag + * @deprecated reason is this + * @two-tag + */ +export class P { + /** @deprecated */ f: string; + g, + /** @deprecated Use g instead.*/ h: number; +} + +let p = new P(); + ~ [errmsg % ('P', 'reason is this')] +let pf = p.f; + ~ [err % ('f')] +pf; // that indirection is allowed +p.g; +p.h; + ~ [errmsg % ('h', 'Use g instead.')] + +interface I extends P {} + ~ [errmsg % ('P', 'reason is this')] +declare var i: I; +i.f; + ~ [err % ('f')] +i.g; + +/** @deprecated */ +const A = 1, B = 2; + +A + B; +~ [err % ('A')] +#if typescript < 2.6.1 + ~ [err % ('B')] +#endif + +export default A; + +declarationIsMissing(); + +function fn(): T; +/** @deprecated */ +function fn(bar: any): any; +function fn() { } + +fn(); +fn(1); +~~ [err % ('fn')] +fn; +~~ [err % ('fn')] + +class TestClass { + /** @deprecated */ + static method(): void; + static method(param): void; + static method(param?): void {} +} + +TestClass.method(); + ~~~~~~ [err % ('method')] +TestClass.method(1); + +interface TestInterface { + /** @deprecated */ + method(): void; + method(param): void; +} +declare let interfaceTest: TestInterface; +interfaceTest.method(); + ~~~~~~ [err % ('method')] +interfaceTest.method(1); + +declare let callSignatureTest: { + /** @deprecated */ + (): void; + (param): void; +} +callSignatureTest(); +~~~~~~~~~~~~~~~~~ [err % ('callSignatureTest')] +callSignatureTest(1); + +/** @deprecated */ +declare let variableWithCallSignature: { + (): void; +} +variableWithCallSignature(); +~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('variableWithCallSignature')] + +/** @deprecated */ +declare let variableWithCallSignature2: () => void; +variableWithCallSignature2(); +~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('variableWithCallSignature2')] + +function dedent(strings: TemplateStringsArray, ...values: string[]): string; +function dedent(strings: TemplateStringsArray, ...values: number[]): string; +/** @deprecated */ +function dedent(strings: TemplateStringsArray, ...values: any[]): string; +function dedent(strings: TemplateStringsArray, ...values: any[]): string { + return "foo"; +} + +dedent``; +dedent`${"foo"}`; +dedent`${1}`; +dedent`${[]}`; +~~~~~~ [err % ('dedent')] + +import {DeprecatedClass, DeprecatedConstructorClass, PartiallyDeprecatedClass} from "./other.test" +{ + const a: DeprecatedClass = new DeprecatedClass(); + ~~~~~~~~~~~~~~~ [err % ('DeprecatedClass')] + ~~~~~~~~~~~~~~~ [err % ('DeprecatedClass')] + const b: DeprecatedConstructorClass = new DeprecatedConstructorClass(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('DeprecatedConstructorClass')] + const c: PartiallyDeprecatedClass = new PartiallyDeprecatedClass(); + const d: PartiallyDeprecatedClass = new PartiallyDeprecatedClass(1); + ~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('PartiallyDeprecatedClass')] +} + +let {f, g, h} = p; + ~ [err % ('f')] + ~ [errmsg % ('h', 'Use g instead.')] +({f, g, h} = p); + ~ [err % ('f')] + ~ [errmsg % ('h', 'Use g instead.')] + +({f: g, g: h, h: f} = p); + ~ [err % ('f')] + ~ [errmsg % ('h', 'Use g instead.')] + +{ + /** @deprecated Just don't use. */ + let tmp; + ({f: tmp} = p); + ~ [err % ('f')] + ~~~ [errmsg % ('tmp', "Just don't use.")] +} + +(function ({f, g, h: tmp}: I) {}) + ~ [err % ('f')] + ~ [errmsg % ('h', 'Use g instead.')] +(function ({foo: {f, g}}: {foo: I}) {}) + ~ [err % ('f')] + +[err]: %s is deprecated. +[errmsg]: %s is deprecated: %s diff --git a/test/rules/deprecation/tsconfig.json b/test/rules/deprecation/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/deprecation/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/deprecation/tslint.json b/test/rules/deprecation/tslint.json new file mode 100644 index 00000000000..db90a0266cd --- /dev/null +++ b/test/rules/deprecation/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "deprecation": true + } +} diff --git a/test/rules/encoding/tslint.json b/test/rules/encoding/tslint.json new file mode 100644 index 00000000000..cfaabc04423 --- /dev/null +++ b/test/rules/encoding/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "encoding": true + } +} \ No newline at end of file diff --git a/test/rules/encoding/utf16be.ts.lint b/test/rules/encoding/utf16be.ts.lint new file mode 100644 index 0000000000000000000000000000000000000000..9e23e87aa89dcf5ac20167b9b0fc6d67b69f9617 GIT binary patch literal 138 zcmXwxyAD8507K90D~t>z7O`4<0h1Um*DDbQW}l9_VrqNR_PWXOIPs||nV8w-2kAmD w_vN0IjtwhjMU87!S`?Ax{p=;L)^IarhlJ*oe|UEJ>oGJWB>pF literal 0 HcmV?d00001 diff --git a/test/rules/encoding/utf16le.ts.lint b/test/rules/encoding/utf16le.ts.lint new file mode 100644 index 0000000000000000000000000000000000000000..cca0c813eb3f5bce94bd91658b40c8ed36a8a4c9 GIT binary patch literal 144 zcmXwzu?|2$5JX??E0h!`(TG;#3#ddPoVY|zLG9BqPGqy$*~!f8-d9D$NlZt>f@2q+ zHCL?Aw_7|T8=0C~95sfVLR=z;<50a$qxRA|X+3F3@^T&Ghmf)9O3a^8lF{pv E2cd5mzyJUM literal 0 HcmV?d00001 diff --git a/test/rules/encoding/utf8-bom.ts.lint b/test/rules/encoding/utf8-bom.ts.lint new file mode 100644 index 00000000000..e4366f08bd3 --- /dev/null +++ b/test/rules/encoding/utf8-bom.ts.lint @@ -0,0 +1,2 @@ +A +~ [This file is encoded as UTF-8 with byte-order marker (BOM) instead of UTF-8.] diff --git a/test/rules/encoding/utf8.ts.lint b/test/rules/encoding/utf8.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/eofline/comment.ts.lint b/test/rules/eofline/comment.ts.lint new file mode 100644 index 00000000000..ca08d31db5c --- /dev/null +++ b/test/rules/eofline/comment.ts.lint @@ -0,0 +1,3 @@ +let foo = bar; +// some comment in last line + ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/eofline/disabled.ts.lint b/test/rules/eofline/disabled.ts.lint new file mode 100644 index 00000000000..573e1afe932 --- /dev/null +++ b/test/rules/eofline/disabled.ts.lint @@ -0,0 +1,2 @@ +let bar = baz; +let foo = bar; // tslint:disable-line: eofline \ No newline at end of file diff --git a/test/rules/eofline/empty.ts.lint b/test/rules/eofline/empty.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/eofline/invalid.ts.fix b/test/rules/eofline/invalid.ts.fix new file mode 100644 index 00000000000..e5f25d98abb --- /dev/null +++ b/test/rules/eofline/invalid.ts.fix @@ -0,0 +1 @@ +let foo = bar; \ No newline at end of file diff --git a/test/rules/eofline/invalid.ts.lint b/test/rules/eofline/invalid.ts.lint new file mode 100644 index 00000000000..6ab3f3de0be --- /dev/null +++ b/test/rules/eofline/invalid.ts.lint @@ -0,0 +1,2 @@ +let foo = bar; + ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/eofline/only-whitespace.ts.fix b/test/rules/eofline/only-whitespace.ts.fix new file mode 100644 index 00000000000..5237d534ed2 --- /dev/null +++ b/test/rules/eofline/only-whitespace.ts.fix @@ -0,0 +1,2 @@ + + diff --git a/test/rules/eofline/only-whitespace.ts.lint b/test/rules/eofline/only-whitespace.ts.lint new file mode 100644 index 00000000000..e23b1c7dfef --- /dev/null +++ b/test/rules/eofline/only-whitespace.ts.lint @@ -0,0 +1,3 @@ + + + ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/eofline/tslint.json b/test/rules/eofline/tslint.json new file mode 100644 index 00000000000..030ddb8c92b --- /dev/null +++ b/test/rules/eofline/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "eofline": true + } +} diff --git a/test/rules/eofline/valid.ts.lint b/test/rules/eofline/valid.ts.lint new file mode 100644 index 00000000000..c85081ab6c4 --- /dev/null +++ b/test/rules/eofline/valid.ts.lint @@ -0,0 +1 @@ +let foo = bar; diff --git a/test/rules/eofline/whitespace.ts.lint b/test/rules/eofline/whitespace.ts.lint new file mode 100644 index 00000000000..ce57bec9c84 --- /dev/null +++ b/test/rules/eofline/whitespace.ts.lint @@ -0,0 +1,2 @@ +let foo = bar; + ~nil [file should end with a newline] \ No newline at end of file diff --git a/test/rules/file-header/bad-newline/test.ts.fix b/test/rules/file-header/bad-newline/test.ts.fix new file mode 100644 index 00000000000..c5133e19990 --- /dev/null +++ b/test/rules/file-header/bad-newline/test.ts.fix @@ -0,0 +1,11 @@ +/*! + * Good header 2 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/bad-newline/test.ts.lint b/test/rules/file-header/bad-newline/test.ts.lint new file mode 100644 index 00000000000..eb415cdf751 --- /dev/null +++ b/test/rules/file-header/bad-newline/test.ts.lint @@ -0,0 +1,11 @@ +/*! +~nil [missing new line following the file header] + * Good header 2 + */ +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/bad-newline/tslint.json b/test/rules/file-header/bad-newline/tslint.json new file mode 100644 index 00000000000..888444210f1 --- /dev/null +++ b/test/rules/file-header/bad-newline/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d", "Good header 2", "enforce-trailing-newline"] + } +} diff --git a/test/rules/file-header/bad-shebang/test.ts.fix b/test/rules/file-header/bad-shebang/test.ts.fix new file mode 100644 index 00000000000..b0ad7bf0496 --- /dev/null +++ b/test/rules/file-header/bad-shebang/test.ts.fix @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +/*! + * Good header 2 + */ + +/* + * Bad header 3 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 4 + */ diff --git a/test/rules/file-header/bad-shebang/test.ts.lint b/test/rules/file-header/bad-shebang/test.ts.lint new file mode 100644 index 00000000000..9032f789dfe --- /dev/null +++ b/test/rules/file-header/bad-shebang/test.ts.lint @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +~nil [missing file header] +/* + * Bad header 3 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 4 + */ diff --git a/test/rules/file-header/bad-shebang/tslint.json b/test/rules/file-header/bad-shebang/tslint.json new file mode 100644 index 00000000000..9203b6ffb9a --- /dev/null +++ b/test/rules/file-header/bad-shebang/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d", "Good header 2"] + } +} diff --git a/test/rules/file-header/bad-single-line/test.ts.fix b/test/rules/file-header/bad-single-line/test.ts.fix new file mode 100644 index 00000000000..47cd4177286 --- /dev/null +++ b/test/rules/file-header/bad-single-line/test.ts.fix @@ -0,0 +1,17 @@ +/*! + * Good header 2 + */ + +// Bad header 1 + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 2 + */ diff --git a/test/rules/file-header/bad-single-line/test.ts.lint b/test/rules/file-header/bad-single-line/test.ts.lint new file mode 100644 index 00000000000..9c69e523faf --- /dev/null +++ b/test/rules/file-header/bad-single-line/test.ts.lint @@ -0,0 +1,14 @@ +// Bad header 1 +~nil [missing file header] + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 2 + */ diff --git a/test/rules/file-header/bad-single-line/tslint.json b/test/rules/file-header/bad-single-line/tslint.json new file mode 100644 index 00000000000..9203b6ffb9a --- /dev/null +++ b/test/rules/file-header/bad-single-line/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d", "Good header 2"] + } +} diff --git a/test/rules/file-header/bad-single-newline/test.ts.fix b/test/rules/file-header/bad-single-newline/test.ts.fix new file mode 100644 index 00000000000..ae4d4867777 --- /dev/null +++ b/test/rules/file-header/bad-single-newline/test.ts.fix @@ -0,0 +1,12 @@ +/*! + * Good header 2 + */ + +// Bad header +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/bad-single-newline/test.ts.lint b/test/rules/file-header/bad-single-newline/test.ts.lint new file mode 100644 index 00000000000..1ededeaf0ba --- /dev/null +++ b/test/rules/file-header/bad-single-newline/test.ts.lint @@ -0,0 +1,9 @@ +// Bad header +~nil [missing file header] +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/bad-single-newline/tslint.json b/test/rules/file-header/bad-single-newline/tslint.json new file mode 100644 index 00000000000..888444210f1 --- /dev/null +++ b/test/rules/file-header/bad-single-newline/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d", "Good header 2", "enforce-trailing-newline"] + } +} diff --git a/test/rules/file-header/bad-use-strict/test.ts.fix b/test/rules/file-header/bad-use-strict/test.ts.fix new file mode 100644 index 00000000000..9ccabfa32f4 --- /dev/null +++ b/test/rules/file-header/bad-use-strict/test.ts.fix @@ -0,0 +1,21 @@ +/*! + * Good header 2 + */ + +"use strict"; + +/* + * Bad header 5 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 6 + */ diff --git a/test/rules/file-header/bad-use-strict/test.ts.lint b/test/rules/file-header/bad-use-strict/test.ts.lint new file mode 100644 index 00000000000..910a579d7a2 --- /dev/null +++ b/test/rules/file-header/bad-use-strict/test.ts.lint @@ -0,0 +1,18 @@ +"use strict"; +~nil [missing file header] + +/* + * Bad header 5 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 6 + */ diff --git a/test/rules/file-header/bad-use-strict/tslint.json b/test/rules/file-header/bad-use-strict/tslint.json new file mode 100644 index 00000000000..9203b6ffb9a --- /dev/null +++ b/test/rules/file-header/bad-use-strict/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d", "Good header 2"] + } +} diff --git a/test/rules/file-header/bad/test.ts.fix b/test/rules/file-header/bad/test.ts.fix new file mode 100644 index 00000000000..c280ae62d78 --- /dev/null +++ b/test/rules/file-header/bad/test.ts.fix @@ -0,0 +1,19 @@ +/*! + * Good header 2 + */ + +/* + * Bad header 1 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 2 + */ diff --git a/test/rules/file-header/bad/test.ts.lint b/test/rules/file-header/bad/test.ts.lint new file mode 100644 index 00000000000..f26963fcabf --- /dev/null +++ b/test/rules/file-header/bad/test.ts.lint @@ -0,0 +1,16 @@ +/* +~nil [missing file header] + * Bad header 1 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} + +/* + * Good header 2 + */ diff --git a/test/rules/file-header/bad/test2.ts.fix b/test/rules/file-header/bad/test2.ts.fix new file mode 100644 index 00000000000..29f5b546f57 --- /dev/null +++ b/test/rules/file-header/bad/test2.ts.fix @@ -0,0 +1,7 @@ +/*! + * Good header 2 + */ + +// ********************************** +// Bad header +// ********************************** diff --git a/test/rules/file-header/bad/test2.ts.lint b/test/rules/file-header/bad/test2.ts.lint new file mode 100644 index 00000000000..ef259de4caf --- /dev/null +++ b/test/rules/file-header/bad/test2.ts.lint @@ -0,0 +1,4 @@ +// ********************************** +~nil [missing file header] +// Bad header +// ********************************** diff --git a/test/rules/file-header/bad/tslint.json b/test/rules/file-header/bad/tslint.json new file mode 100644 index 00000000000..9203b6ffb9a --- /dev/null +++ b/test/rules/file-header/bad/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d", "Good header 2"] + } +} diff --git a/test/rules/file-header/empty-file/test.ts.lint b/test/rules/file-header/empty-file/test.ts.lint new file mode 100644 index 00000000000..40e2acd429d --- /dev/null +++ b/test/rules/file-header/empty-file/test.ts.lint @@ -0,0 +1,2 @@ + +~nil [missing file header] diff --git a/test/rules/file-header/empty-file/tslint.json b/test/rules/file-header/empty-file/tslint.json new file mode 100644 index 00000000000..79f26da8b41 --- /dev/null +++ b/test/rules/file-header/empty-file/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d"] + } +} diff --git a/test/rules/file-header/good-allow-single-line-comments/test.ts.lint b/test/rules/file-header/good-allow-single-line-comments/test.ts.lint new file mode 100644 index 00000000000..8aa13d57e2e --- /dev/null +++ b/test/rules/file-header/good-allow-single-line-comments/test.ts.lint @@ -0,0 +1,4 @@ +// ********************************** +// Good header +// ********************************** + diff --git a/test/rules/file-header/good-allow-single-line-comments/tslint.json b/test/rules/file-header/good-allow-single-line-comments/tslint.json new file mode 100644 index 00000000000..5f1256bb402 --- /dev/null +++ b/test/rules/file-header/good-allow-single-line-comments/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "file-header": [true, { + "match": "Good header", + "allow-single-line-comments": true + }] + } + } diff --git a/test/rules/file-header/good-newline/test.ts.lint b/test/rules/file-header/good-newline/test.ts.lint new file mode 100644 index 00000000000..f724f642455 --- /dev/null +++ b/test/rules/file-header/good-newline/test.ts.lint @@ -0,0 +1,3 @@ +/* Copyright 2019 */ + +class Foo {} diff --git a/test/rules/file-header/good-newline/tslint.json b/test/rules/file-header/good-newline/tslint.json new file mode 100644 index 00000000000..858210b6a93 --- /dev/null +++ b/test/rules/file-header/good-newline/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "file-header": [ + true, + "Copyright \\d{4}", + "Copyright 2019", + "enforce-trailing-newline" + ] + } +} diff --git a/test/rules/file-header/good-shebang/test.ts.lint b/test/rules/file-header/good-shebang/test.ts.lint new file mode 100644 index 00000000000..0c58de97be7 --- /dev/null +++ b/test/rules/file-header/good-shebang/test.ts.lint @@ -0,0 +1,14 @@ +#!/usr/bin/env node + + +/* + * Good header 2 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/good-shebang/tslint.json b/test/rules/file-header/good-shebang/tslint.json new file mode 100644 index 00000000000..79f26da8b41 --- /dev/null +++ b/test/rules/file-header/good-shebang/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d"] + } +} diff --git a/test/rules/file-header/good-single-line/test.ts.lint b/test/rules/file-header/good-single-line/test.ts.lint new file mode 100644 index 00000000000..7c9cd1e230b --- /dev/null +++ b/test/rules/file-header/good-single-line/test.ts.lint @@ -0,0 +1,9 @@ +// Good header 4 + +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/good-single-line/tslint.json b/test/rules/file-header/good-single-line/tslint.json new file mode 100644 index 00000000000..79f26da8b41 --- /dev/null +++ b/test/rules/file-header/good-single-line/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d"] + } +} diff --git a/test/rules/file-header/good-use-strict/test.ts.lint b/test/rules/file-header/good-use-strict/test.ts.lint new file mode 100644 index 00000000000..e76f84c6bd4 --- /dev/null +++ b/test/rules/file-header/good-use-strict/test.ts.lint @@ -0,0 +1,13 @@ +/* + * Good header 3 + */ + +"use strict"; + +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/good-use-strict/tslint.json b/test/rules/file-header/good-use-strict/tslint.json new file mode 100644 index 00000000000..79f26da8b41 --- /dev/null +++ b/test/rules/file-header/good-use-strict/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d"] + } +} diff --git a/test/rules/file-header/good/test.ts.fix b/test/rules/file-header/good/test.ts.fix new file mode 100644 index 00000000000..df6b2bb9a56 --- /dev/null +++ b/test/rules/file-header/good/test.ts.fix @@ -0,0 +1,12 @@ + +/* + * Good header 1 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/good/test.ts.lint b/test/rules/file-header/good/test.ts.lint new file mode 100644 index 00000000000..df6b2bb9a56 --- /dev/null +++ b/test/rules/file-header/good/test.ts.lint @@ -0,0 +1,12 @@ + +/* + * Good header 1 + */ + +export class A { + public x = 1; + + public B() { + return 2; + } +} diff --git a/test/rules/file-header/good/tslint.json b/test/rules/file-header/good/tslint.json new file mode 100644 index 00000000000..79f26da8b41 --- /dev/null +++ b/test/rules/file-header/good/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-header": [true, "Good header \\d"] + } +} diff --git a/test/rules/file-name-casing/camel-case/camelCase.ts.lint b/test/rules/file-name-casing/camel-case/camelCase.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/camel-case/no-camel-case.ts.lint b/test/rules/file-name-casing/camel-case/no-camel-case.ts.lint new file mode 100644 index 00000000000..c6a2024811e --- /dev/null +++ b/test/rules/file-name-casing/camel-case/no-camel-case.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be camelCase] diff --git a/test/rules/file-name-casing/camel-case/tslint.json b/test/rules/file-name-casing/camel-case/tslint.json new file mode 100644 index 00000000000..883029f5a95 --- /dev/null +++ b/test/rules/file-name-casing/camel-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-name-casing": [true, "camel-case"] + } +} diff --git a/test/rules/file-name-casing/complex/ComponentName.tsx.lint b/test/rules/file-name-casing/complex/ComponentName.tsx.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint b/test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint new file mode 100644 index 00000000000..c6a2024811e --- /dev/null +++ b/test/rules/file-name-casing/complex/InvalidNonComponentName.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be camelCase] diff --git a/test/rules/file-name-casing/complex/invalid-component-name.tsx.lint b/test/rules/file-name-casing/complex/invalid-component-name.tsx.lint new file mode 100644 index 00000000000..947411ef4df --- /dev/null +++ b/test/rules/file-name-casing/complex/invalid-component-name.tsx.lint @@ -0,0 +1,2 @@ + +~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/complex/my-button.component.ts.lint b/test/rules/file-name-casing/complex/my-button.component.ts.lint new file mode 100644 index 00000000000..947411ef4df --- /dev/null +++ b/test/rules/file-name-casing/complex/my-button.component.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/complex/nonComponentName.ts.lint b/test/rules/file-name-casing/complex/nonComponentName.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/complex/tslint.json b/test/rules/file-name-casing/complex/tslint.json new file mode 100644 index 00000000000..be350316521 --- /dev/null +++ b/test/rules/file-name-casing/complex/tslint.json @@ -0,0 +1,9 @@ +{ + "rules": { + "file-name-casing": [true, { + ".component.ts$": "pascal-case", + ".tsx$": "pascal-case", + ".ts$": "camel-case" + }] + } +} diff --git a/test/rules/file-name-casing/file-matcher/PascalCase.ts.lint b/test/rules/file-name-casing/file-matcher/PascalCase.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/file-matcher/camelCase.ts.lint b/test/rules/file-name-casing/file-matcher/camelCase.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint b/test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint new file mode 100644 index 00000000000..947411ef4df --- /dev/null +++ b/test/rules/file-name-casing/file-matcher/notPascalCase.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint b/test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint new file mode 100644 index 00000000000..c6a2024811e --- /dev/null +++ b/test/rules/file-name-casing/file-matcher/not_camel_case.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be camelCase] diff --git a/test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint b/test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint new file mode 100644 index 00000000000..75f1057bba6 --- /dev/null +++ b/test/rules/file-name-casing/file-matcher/not_kebab_case.tsx.lint @@ -0,0 +1,2 @@ + +~nil [File name must be kebab-case] diff --git a/test/rules/file-name-casing/file-matcher/tslint.json b/test/rules/file-name-casing/file-matcher/tslint.json new file mode 100644 index 00000000000..bc03c3b8579 --- /dev/null +++ b/test/rules/file-name-casing/file-matcher/tslint.json @@ -0,0 +1,13 @@ +{ + "rules": { + "file-name-casing": [ + true, + { + ".*)": "snake-case", // making sure invalid RegExp will be ignored + "pascal.?case": "pascal-case", + "tsx$": "kebab-case", + ".*": "camel-case" + } + ] + } +} diff --git a/test/rules/file-name-casing/ignore/complaint.tsx.lint b/test/rules/file-name-casing/ignore/complaint.tsx.lint new file mode 100644 index 00000000000..947411ef4df --- /dev/null +++ b/test/rules/file-name-casing/ignore/complaint.tsx.lint @@ -0,0 +1,2 @@ + +~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/ignore/file.ts.lint b/test/rules/file-name-casing/ignore/file.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/ignore/tslint.json b/test/rules/file-name-casing/ignore/tslint.json new file mode 100644 index 00000000000..dab56203717 --- /dev/null +++ b/test/rules/file-name-casing/ignore/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "file-name-casing": [true, { + ".ts$": "ignore", + ".tsx$": "pascal-case" + }] + } +} diff --git a/test/rules/file-name-casing/invalid-option/snake_case.ts.lint b/test/rules/file-name-casing/invalid-option/snake_case.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/invalid-option/tslint.json b/test/rules/file-name-casing/invalid-option/tslint.json new file mode 100644 index 00000000000..357701e90f4 --- /dev/null +++ b/test/rules/file-name-casing/invalid-option/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-name-casing": [true, "invalid-option"] + } +} diff --git a/test/rules/file-name-casing/kebab-case/kebab-case.ts.lint b/test/rules/file-name-casing/kebab-case/kebab-case.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint b/test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint new file mode 100644 index 00000000000..75f1057bba6 --- /dev/null +++ b/test/rules/file-name-casing/kebab-case/noKebabCase.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be kebab-case] diff --git a/test/rules/file-name-casing/kebab-case/tslint.json b/test/rules/file-name-casing/kebab-case/tslint.json new file mode 100644 index 00000000000..b600a590662 --- /dev/null +++ b/test/rules/file-name-casing/kebab-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-name-casing": [true, "kebab-case"] + } +} diff --git a/test/rules/file-name-casing/pascal-case/PascalCase.ts.lint b/test/rules/file-name-casing/pascal-case/PascalCase.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint b/test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint new file mode 100644 index 00000000000..947411ef4df --- /dev/null +++ b/test/rules/file-name-casing/pascal-case/no-pascal-case.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be PascalCase] diff --git a/test/rules/file-name-casing/pascal-case/tslint.json b/test/rules/file-name-casing/pascal-case/tslint.json new file mode 100644 index 00000000000..1036cc4572a --- /dev/null +++ b/test/rules/file-name-casing/pascal-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-name-casing": [true, "pascal-case"] + } +} diff --git a/test/rules/file-name-casing/snake-case/no-snake-case.ts.lint b/test/rules/file-name-casing/snake-case/no-snake-case.ts.lint new file mode 100644 index 00000000000..d37aa03d910 --- /dev/null +++ b/test/rules/file-name-casing/snake-case/no-snake-case.ts.lint @@ -0,0 +1,2 @@ + +~nil [File name must be snake_case] diff --git a/test/rules/file-name-casing/snake-case/snake_case.ts.lint b/test/rules/file-name-casing/snake-case/snake_case.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/file-name-casing/snake-case/tslint.json b/test/rules/file-name-casing/snake-case/tslint.json new file mode 100644 index 00000000000..a08000df93c --- /dev/null +++ b/test/rules/file-name-casing/snake-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "file-name-casing": [true, "snake-case"] + } +} diff --git a/test/rules/forin/test.ts.lint b/test/rules/forin/test.ts.lint new file mode 100644 index 00000000000..a621922b16b --- /dev/null +++ b/test/rules/forin/test.ts.lint @@ -0,0 +1,41 @@ +function a() { + for (var i in obj) { + ~~~~~~~~~~~~~~~~~~~~ + console.log("i"); +~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [0] + + for (var j in obj) { + ~~~~~~~~~~~~~~~~~~~~ + if (j === 3) { +~~~~~~~~~~~~~~~~~~~~~~ + console.log("j"); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~~~~~ + console.log("j"); +~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [0] + + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + console.log("k"); + } + } + + for (var m in obj) { + if (!obj.hasOwnProperty(m)) { + continue; + } + console.log("m"); + } + + for (var n in obj) { + if (!obj.hasOwnProperty(n)) continue; + console.log("m"); + } +} + +[0]: for (... in ...) statements must be filtered with an if statement diff --git a/test/rules/forin/tslint.json b/test/rules/forin/tslint.json new file mode 100644 index 00000000000..c7c10b4b899 --- /dev/null +++ b/test/rules/forin/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "forin": true + } +} diff --git a/test/rules/function-constructor/test.ts.lint b/test/rules/function-constructor/test.ts.lint new file mode 100644 index 00000000000..cc2f3829427 --- /dev/null +++ b/test/rules/function-constructor/test.ts.lint @@ -0,0 +1,19 @@ +function one() { } +const two = function () { }; +const three = () => {}; + +const noParametersNew = Function(); + ~~~~~~~~~~ [0] +const oneParameterNew = Function("a"); + ~~~~~~~~~~~~~ [0] +const twoParametersNew = Function("a", "b"); + ~~~~~~~~~~~~~~~~~~ [0] + +const noParametersNew = new Function(); + ~~~~~~~~~~~~~~ [0] +const oneParameterNew = new Function("a"); + ~~~~~~~~~~~~~~~~~ [0] +const twoParametersNew = new Function("a", "b"); + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: Do not use the Function constructor to create functions. diff --git a/test/rules/function-constructor/tslint.json b/test/rules/function-constructor/tslint.json new file mode 100644 index 00000000000..9f48491ff28 --- /dev/null +++ b/test/rules/function-constructor/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "function-constructor": true + } +} diff --git a/test/rules/import-blacklist/test.ts.lint b/test/rules/import-blacklist/test.ts.lint new file mode 100644 index 00000000000..0c499ed2f39 --- /dev/null +++ b/test/rules/import-blacklist/test.ts.lint @@ -0,0 +1,55 @@ +import { Observable } from 'rxjs'; + ~~~~ [0] +import { Observable } from 'rxjs/Observable'; + +import rxjs = require('rxjs'); + ~~~~ [0] +import Observable = require('rxjs/Observable'); + +import * as rxjs from "rxjs"; + ~~~~ [0] + +// non-static imports cannot be checked +import {Observable} from rxjs; +import forOwn = require(lodash); + +import * as notBlacklisted from "not-blacklisted"; + +export * from 'rxjs'; + ~~~~ [0] + +export { default } from "dummy"; + ~~~~~~~~~~~ [3] + +export * from "lodash"; + ~~~~~~ [1] + +import * as lodash from "lodash"; + ~~~~~~ [1] +import { difference } from "lodash"; + +import { pull, difference } from "lodash"; + ~~~~~~~~~~~~~~~~~~~~ [2] + +import lodash, { pull } from "lodash"; + ~~~~~~~~~~~~~~~~ [2] + +import { pull as notPull } from "lodash"; + ~~~~~~~~~~~~~~~~~~~ [2] + +import test from "dummy"; + ~~~~ [3] + +import {myFunc} from './my.temp'; + ~~~~~~~~~ [4] + +import {myFunc} from './my.tmp'; + ~~~~~~~~ [5] + + +[0]: Importing this module is blacklisted. Try importing a submodule instead. +[1]: Some named exports from this module are blacklisted for importing (or re-exporting). Import/re-export only the specific values you want, instead of the whole module. +[2]: The export "pull" is blacklisted. +[3]: Importing (or re-exporting) the default export is blacklisted. +[4]: This import is blacklisted by /.*\.temp$/ +[5]: This import is blacklisted by /.*\.tmp$/ diff --git a/test/rules/import-blacklist/tslint.json b/test/rules/import-blacklist/tslint.json new file mode 100644 index 00000000000..5ac04a3762d --- /dev/null +++ b/test/rules/import-blacklist/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "import-blacklist": [true, "rxjs", { "lodash": ["pullAll", "pull"] }, { "dummy": ["default"] }, [".*\\.temp$", ".*\\.tmp$"]] + } +} diff --git a/test/rules/import-spacing/test.ts.lint b/test/rules/import-spacing/test.ts.lint new file mode 100644 index 00000000000..daa11455ba4 --- /dev/null +++ b/test/rules/import-spacing/test.ts.lint @@ -0,0 +1,157 @@ +// --------------------------------------------------------------------------------------------------------------------- +// Module with side effect import +// --------------------------------------------------------------------------------------------------------------------- +// good +import "styles.css"; + +// bad +import"styles.css"; +~~~~~~ [Add space after 'import'] +import "styles.css"; +~~~~~~~~ [Too many spaces after 'import'] +import "styles.css"; +~~~~~~~~~ [Too many spaces after 'import'] + +import +~~~~~~ +"styles.css"; +~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] +// --------------------------------------------------------------------------------------------------------------------- +// Namespace import +// --------------------------------------------------------------------------------------------------------------------- +// good +import * as ts from "typescript"; + +// bad +import*as ts from "typescript"; +~~~~~~ [Add space after 'import'] + ~~~~~~ [Add space after '*'] +import *as ts from "typescript"; + ~~~~~~ [Add space after '*'] +import * as ts from "typescript"; + ~~~~~~~~ [Too many spaces after '*'] +import * as ts from "typescript"; + ~~~~~~~~~ [Too many spaces after '*'] +import* as ts from "typescript"; +~~~~~~ [Add space after 'import'] +import * as ts from"typescript"; + ~~~~~ [Add space after 'from'] +import * as ts from "typescript"; +~~~~~~~~ [Too many spaces after 'import'] +import * as ts from "typescript"; +~~~~~~~~~~ [Too many spaces after 'import'] +import * as ts from "typescript"; + ~~~~~~~ [Too many spaces after 'from'] +import +~~~~~~ [Line breaks are not allowed in import declaration] +* as ts from "typescript"; + +import * + ~ +as ts from "typescript"; +~~~~~ [Line breaks are not allowed in import declaration] + +import * as + ~~~~ +ts from "typescript"; +~~ [Line breaks are not allowed in import declaration] + +import * as ts + ~nil +from "typescript"; +~~~~~~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] + + +// --------------------------------------------------------------------------------------------------------------------- +// Single-line import +// --------------------------------------------------------------------------------------------------------------------- +// good +import {Expression} from "typescript"; + +// bad +import{Expression}from"typescript"; +~~~~~~ [Add space after 'import'] + ~~~~ [Add space after 'from'] + ~~~~ [Add space before 'from'] +import {Expression}from"typescript"; + ~~~~ [Add space after 'from'] + ~~~~ [Add space before 'from'] +import {Expression} from"typescript"; + ~~~~~ [Add space after 'from'] +import {Expression} from "typescript"; +~~~~~~~~ [Too many spaces after 'import'] +import {Expression} from "typescript"; + ~~~~~~~ [Too many spaces before 'from'] +import {Expression} from "typescript"; + ~~~~~~~ [Too many spaces after 'from'] +import {Expression} from "typescript"; +~~~~~~~~ [Too many spaces after 'import'] +import {Expression} from "typescript"; +~~~~~~~~~ [Too many spaces after 'import'] + +import +~~~~~~ [Line breaks are not allowed in import declaration] +{Expression} from "typescript"; + +import {Expression} + ~nil +from "typescript"; +~~~~~~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] + +import {Expression} from + ~~~~~ +"typescript"; +~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] + +// --------------------------------------------------------------------------------------------------------------------- +// Multi-line import +// --------------------------------------------------------------------------------------------------------------------- +// good +import { + Expression +} from "typescript"; + +// bad +import{ +~~~~~~ [Add space after 'import'] + Expression +} from "typescript"; + +import {Expression +}from "typescript"; + ~~~~~ [Add space before 'from'] + +import { + Expression +} from"typescript"; + ~~~~~ [Add space after 'from'] + +import { +~~~~~~~~ [Too many spaces after 'import'] + Expression +} from "typescript"; + +import { +~~~~~~~~ [Too many spaces after 'import'] + Expression +} from "typescript"; + +import { + Expression +} + ~nil +from "typescript"; +~~~~~~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] + +import { + Expression +} from + ~~~~~ +"typescript"; +~~~~~~~~~~~~~ [Line breaks are not allowed in import declaration] + +import +~~~~~~ [Line breaks are not allowed in import declaration] +{ + Expression +} from "typescript" diff --git a/test/rules/import-spacing/tslint.json b/test/rules/import-spacing/tslint.json new file mode 100644 index 00000000000..acb0f7dc507 --- /dev/null +++ b/test/rules/import-spacing/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "import-spacing": true + } +} diff --git a/test/rules/increment-decrement/allow-post/test.ts.fix b/test/rules/increment-decrement/allow-post/test.ts.fix new file mode 100644 index 00000000000..ebac59985d4 --- /dev/null +++ b/test/rules/increment-decrement/allow-post/test.ts.fix @@ -0,0 +1,20 @@ +let x = 7; + +x += 1; +x++; + +x -= 1; +x--; + ++x; +-x; +x + 1; +x - 1; +1 + x; +1 - x; + +x + (x += 1); +x + x++; + +x - (x -= 1); +x - x--; diff --git a/test/rules/increment-decrement/allow-post/test.ts.lint b/test/rules/increment-decrement/allow-post/test.ts.lint new file mode 100644 index 00000000000..c27629a2cdb --- /dev/null +++ b/test/rules/increment-decrement/allow-post/test.ts.lint @@ -0,0 +1,26 @@ +let x = 7; + +++x; +~~~ [plus] +x++; + +--x; +~~~ [minus] +x--; + ++x; +-x; +x + 1; +x - 1; +1 + x; +1 - x; + +x + ++x; + ~~~ [plus] +x + x++; + +x - --x; + ~~~ [minus] +x - x--; +[plus]: Use an explicit += 1 operator. +[minus]: Use an explicit -= 1 operator. diff --git a/test/rules/increment-decrement/allow-post/tslint.json b/test/rules/increment-decrement/allow-post/tslint.json new file mode 100644 index 00000000000..b0964670126 --- /dev/null +++ b/test/rules/increment-decrement/allow-post/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "increment-decrement": [true, "allow-post"] + } +} diff --git a/test/rules/increment-decrement/default/test.ts.fix b/test/rules/increment-decrement/default/test.ts.fix new file mode 100644 index 00000000000..245a116d30f --- /dev/null +++ b/test/rules/increment-decrement/default/test.ts.fix @@ -0,0 +1,29 @@ +let x = 7; + +x += 1; +x += 1; + +x -= 1; +x -= 1; + ++x; +-x; +x + 1; +x - 1; +1 + x; +1 - x; + +x + (x += 1); +x + x++; + +x - (x -= 1); +x - x--; + +(x += 1) + x; +x++ + x; + +(x -= 1) - x; +x-- - x; + +expect(x++) +expect(x += 1) diff --git a/test/rules/increment-decrement/default/test.ts.lint b/test/rules/increment-decrement/default/test.ts.lint new file mode 100644 index 00000000000..19f39bb99b0 --- /dev/null +++ b/test/rules/increment-decrement/default/test.ts.lint @@ -0,0 +1,45 @@ +let x = 7; + +++x; +~~~ [plus] +x++; +~~~ [plus] + +--x; +~~~ [minus] +x--; +~~~ [minus] + ++x; +-x; +x + 1; +x - 1; +1 + x; +1 - x; + +x + ++x; + ~~~ [plus] +x + x++; + ~~~ [plus] + +x - --x; + ~~~ [minus] +x - x--; + ~~~ [minus] + +++x + x; +~~~ [plus] +x++ + x; +~~~ [plus] + +--x - x; +~~~ [minus] +x-- - x; +~~~ [minus] +[plus]: Use an explicit += 1 operator. +[minus]: Use an explicit -= 1 operator. + +expect(x++) + ~~~ [plus] +expect(++x) + ~~~ [plus] diff --git a/test/rules/increment-decrement/default/tslint.json b/test/rules/increment-decrement/default/tslint.json new file mode 100644 index 00000000000..42c70f0b7ab --- /dev/null +++ b/test/rules/increment-decrement/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "increment-decrement": true + } +} diff --git a/test/rules/indent/spaces-2/test.ts.fix b/test/rules/indent/spaces-2/test.ts.fix new file mode 100644 index 00000000000..02ee82b0503 --- /dev/null +++ b/test/rules/indent/spaces-2/test.ts.fix @@ -0,0 +1,139 @@ +// valid code +module TestModule { + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading tabs inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +// we get a weird scenario here where our ~~ underlines don't quite line up with the line above +// this is because tabs are only one character and thus only one ~ goes beneath them. +module TestModule { + var testVariable = 123; +} + +function() { + var test = 123; +} + +class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } +} + +var obj = { + a: 1, + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, + VALUE2 +} + +switch (integerValue) { + case 0: + console.warn("1"); + break; + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +} + +while (i < 1) { + console.warn("123"); +} + +do { + console.warn("123"); +} while (i < 1); + +if (i < 1) { + console.warn("123"); +} + +var arr = [ + 1, + 2 +]; + +var arr2 = [ + { + a: 1, + b: 2 + }, + { + a: 3, + b: 4 + } +]; + diff --git a/test/rules/indent/spaces-2/test.ts.lint b/test/rules/indent/spaces-2/test.ts.lint new file mode 100644 index 00000000000..fabe1580c83 --- /dev/null +++ b/test/rules/indent/spaces-2/test.ts.lint @@ -0,0 +1,162 @@ +// valid code +module TestModule { + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading tabs inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } +~~ [0] + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +// we get a weird scenario here where our ~~ underlines don't quite line up with the line above +// this is because tabs are only one character and thus only one ~ goes beneath them. +module TestModule { + var testVariable = 123; +~ [0] +} + +function() { + var test = 123; +~~ [0] +} + +class TestClass { + private variable; +~ [0] + + testFunction() { +~ [0] + this.variable = 3; +~~ [0] + } +~ [0] +} + +var obj = { + a: 1, +~ [0] + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, +~ [0] + VALUE2 +} + +switch (integerValue) { + case 0: +~ [0] + console.warn("1"); +~~ [0] + break; +~~ [0] + case 1: + console.warn("1"); + break; + default: +~ [0] + console.warn("default"); +~~ [0] + break; +~~ [0] +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +~ [0] +} + +while (i < 1) { + console.warn("123"); +~ [0] +} + +do { + console.warn("123"); +~ [0] +} while (i < 1); + +if (i < 1) { + console.warn("123"); +~ [0] +} + +var arr = [ + 1, +~ [0] + 2 +]; + +var arr2 = [ + { + a: 1, +~~ [0] + b: 2 + }, +~ [0] + { + a: 3, + b: 4 + } +]; + +[0]: 2 space indentation expected diff --git a/test/rules/indent/spaces-2/test.tsx.lint b/test/rules/indent/spaces-2/test.tsx.lint new file mode 100644 index 00000000000..07f54d1fc56 --- /dev/null +++ b/test/rules/indent/spaces-2/test.tsx.lint @@ -0,0 +1,17 @@ + + +~ [0] + baz +~~ [0] + +~ [0] + + { +~ [0] + +~~ [0] + } +~ [0] + + +[0]: 2 space indentation expected \ No newline at end of file diff --git a/test/rules/indent/spaces-2/tslint.json b/test/rules/indent/spaces-2/tslint.json new file mode 100644 index 00000000000..1845d7c8884 --- /dev/null +++ b/test/rules/indent/spaces-2/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "indent": [true, "spaces", 2] + } +} diff --git a/test/rules/indent/spaces-4/test.ts.fix b/test/rules/indent/spaces-4/test.ts.fix new file mode 100644 index 00000000000..bc01c41e902 --- /dev/null +++ b/test/rules/indent/spaces-4/test.ts.fix @@ -0,0 +1,139 @@ +// valid code +module TestModule { + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading tabs inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +// we get a weird scenario here where our ~~ underlines don't quite line up with the line above +// this is because tabs are only one character and thus only one ~ goes beneath them. +module TestModule { + var testVariable = 123; +} + +function() { + var test = 123; +} + +class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } +} + +var obj = { + a: 1, + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, + VALUE2 +} + +switch (integerValue) { + case 0: + console.warn("1"); + break; + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +} + +while (i < 1) { + console.warn("123"); +} + +do { + console.warn("123"); +} while (i < 1); + +if (i < 1) { + console.warn("123"); +} + +var arr = [ + 1, + 2 +]; + +var arr2 = [ + { + a: 1, + b: 2 + }, + { + a: 3, + b: 4 + } +]; + diff --git a/test/rules/indent/spaces-4/test.ts.lint b/test/rules/indent/spaces-4/test.ts.lint new file mode 100644 index 00000000000..0c173f913a5 --- /dev/null +++ b/test/rules/indent/spaces-4/test.ts.lint @@ -0,0 +1,162 @@ +// valid code +module TestModule { + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading tabs inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } +~~ [0] + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +// we get a weird scenario here where our ~~ underlines don't quite line up with the line above +// this is because tabs are only one character and thus only one ~ goes beneath them. +module TestModule { + var testVariable = 123; +~ [0] +} + +function() { + var test = 123; +~~ [0] +} + +class TestClass { + private variable; +~ [0] + + testFunction() { +~ [0] + this.variable = 3; +~~ [0] + } +~ [0] +} + +var obj = { + a: 1, +~ [0] + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, +~ [0] + VALUE2 +} + +switch (integerValue) { + case 0: +~ [0] + console.warn("1"); +~~ [0] + break; +~~ [0] + case 1: + console.warn("1"); + break; + default: +~ [0] + console.warn("default"); +~~ [0] + break; +~~ [0] +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +~ [0] +} + +while (i < 1) { + console.warn("123"); +~ [0] +} + +do { + console.warn("123"); +~ [0] +} while (i < 1); + +if (i < 1) { + console.warn("123"); +~ [0] +} + +var arr = [ + 1, +~ [0] + 2 +]; + +var arr2 = [ + { + a: 1, +~~ [0] + b: 2 + }, +~ [0] + { + a: 3, + b: 4 + } +]; + +[0]: 4 space indentation expected diff --git a/test/rules/indent/spaces-4/tslint.json b/test/rules/indent/spaces-4/tslint.json new file mode 100644 index 00000000000..9a84296b21d --- /dev/null +++ b/test/rules/indent/spaces-4/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "indent": [true, "spaces", 4] + } +} diff --git a/test/rules/indent/tabs-2/test.ts.fix b/test/rules/indent/tabs-2/test.ts.fix new file mode 100644 index 00000000000..709a381974e --- /dev/null +++ b/test/rules/indent/tabs-2/test.ts.fix @@ -0,0 +1,141 @@ +// valid code +module TestModule { + /** + * Some documentation + */ + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 1; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading spaces inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +module TestModule { + var testVariable = 123; +} + +function() { + var test = 123; +} + +class TestClass { + private variable; + + testFunction() { + // fix incomplete space groups + this.variable = 1; + } +} + +var obj = { + a: 1, + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, + VALUE2 +} + +switch (integerValue) { + case 0: + console.warn("1"); + break; + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +} + +while (i < 1) { + console.warn("123"); +} + +do { + console.warn("123"); +} while (i < 1); + +if (i < 1) { + console.warn("123"); +} + +var arr = [ + 1, + 2 +]; + +var arr2 = [ + { + a: 1, + b: 2 + }, + { + a: 3, + b: 4 + } +]; + diff --git a/test/rules/indent/tabs-2/test.ts.lint b/test/rules/indent/tabs-2/test.ts.lint new file mode 100644 index 00000000000..fcc0344f5c8 --- /dev/null +++ b/test/rules/indent/tabs-2/test.ts.lint @@ -0,0 +1,164 @@ +// valid code +module TestModule { + /** + * Some documentation + */ + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 1; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading spaces inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } +~~~~~ [0] + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +module TestModule { + var testVariable = 123; +~~ [0] +} + +function() { + var test = 123; +~~~~ [0] +} + +class TestClass { + private variable; +~~ [0] + + testFunction() { +~~ [0] + // fix incomplete space groups + this.variable = 1; +~~~ [0] + } +~~ [0] +} + +var obj = { + a: 1, +~~ [0] + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, +~~ [0] + VALUE2 +} + +switch (integerValue) { + case 0: + console.warn("1"); + break; + case 1: +~~ [0] + console.warn("1"); +~~~~ [0] + break; +~~~~ [0] + default: +~~ [0] + console.warn("default"); +~~~~ [0] + break; +~~~~ [0] +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +~~ [0] +} + +while (i < 1) { + console.warn("123"); +~~ [0] +} + +do { + console.warn("123"); +~~ [0] +} while (i < 1); + +if (i < 1) { + console.warn("123"); +~~ [0] +} + +var arr = [ + 1, +~~ [0] + 2 +]; + +var arr2 = [ + { + a: 1, +~~~~ [0] + b: 2 + }, +~~ [0] + { + a: 3, + b: 4 + } +]; + +[0]: tab indentation expected diff --git a/test/rules/indent/tabs-2/tslint.json b/test/rules/indent/tabs-2/tslint.json new file mode 100644 index 00000000000..4d52a9464e0 --- /dev/null +++ b/test/rules/indent/tabs-2/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "indent": [true, "tabs", 2] + } +} diff --git a/test/rules/indent/tabs-4/test.ts.fix b/test/rules/indent/tabs-4/test.ts.fix new file mode 100644 index 00000000000..a41a63e5d3c --- /dev/null +++ b/test/rules/indent/tabs-4/test.ts.fix @@ -0,0 +1,141 @@ +// valid code +module TestModule { + /** + * Some documentation + */ + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading spaces inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +module TestModule { + var testVariable = 123; +} + +function() { + var test = 123; +} + +class TestClass { + private variable; + + testFunction() { + // fix incomplete space groups + this.variable = 3; + } +} + +var obj = { + a: 1, + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, + VALUE2 +} + +switch (integerValue) { + case 0: + console.warn("1"); + break; + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +} + +while (i < 1) { + console.warn("123"); +} + +do { + console.warn("123"); +} while (i < 1); + +if (i < 1) { + console.warn("123"); +} + +var arr = [ + 1, + 2 +]; + +var arr2 = [ + { + a: 1, + b: 2 + }, + { + a: 3, + b: 4 + } +]; + diff --git a/test/rules/indent/tabs-4/test.ts.lint b/test/rules/indent/tabs-4/test.ts.lint new file mode 100644 index 00000000000..c867527b411 --- /dev/null +++ b/test/rules/indent/tabs-4/test.ts.lint @@ -0,0 +1,164 @@ +// valid code +module TestModule { + /** + * Some documentation + */ + var func = () => { + console.warn("hi"); + }; + + class TestClass { + private variable; + + testFunction() { + this.variable = 3; + } + } + + var obj = { + a: 1, + b: 2, + c: 3 + }; + + // ignore leading spaces inside template strings + var s1 = ` + multiline` + ` template + string`; + var s2 = ` + multiline ${ "A" } + template ${ "B" + + "C" } +~~~~~ [0] + string`; + + export enum TestEnum { + VALUE1, + VALUE2 + } + + switch (integerValue) { + case 1: + console.warn("1"); + break; + default: + console.warn("default"); + break; + } + + function loops() { + for (var i = 0; i < 1; ++i) { + console.warn(i); + } + + while (i < 1) { + console.warn(i); + } + + do { + console.warn(i); + } while (i < 1); + + if (i < 1) { + console.warn(i); + } else { + console.warn(i + 1); + } + } +} + +// invalid code +module TestModule { + var testVariable = 123; +~~~~ [0] +} + +function() { + var test = 123; +~~~~~~~~ [0] +} + +class TestClass { + private variable; +~~~~ [0] + + testFunction() { +~~~~ [0] + // fix incomplete space groups + this.variable = 3; +~~~~~~~ [0] + } +~~~~ [0] +} + +var obj = { + a: 1, +~~~~ [0] + b: 2, + c: 3 +}; + +enum TestEnum { + VALUE1, +~~~~ [0] + VALUE2 +} + +switch (integerValue) { + case 0: + console.warn("1"); + break; + case 1: +~~~~ [0] + console.warn("1"); +~~~~~~~~ [0] + break; +~~~~~~~~ [0] + default: +~~~~ [0] + console.warn("default"); +~~~~~~~~ [0] + break; +~~~~~~~~ [0] +} + +for (var i = 0; i < 1; ++i) { + console.warn("123"); +~~~~ [0] +} + +while (i < 1) { + console.warn("123"); +~~~~ [0] +} + +do { + console.warn("123"); +~~~~ [0] +} while (i < 1); + +if (i < 1) { + console.warn("123"); +~~~~ [0] +} + +var arr = [ + 1, +~~~~ [0] + 2 +]; + +var arr2 = [ + { + a: 1, +~~~~~~~~ [0] + b: 2 + }, +~~~~ [0] + { + a: 3, + b: 4 + } +]; + +[0]: tab indentation expected diff --git a/test/rules/indent/tabs-4/tslint.json b/test/rules/indent/tabs-4/tslint.json new file mode 100644 index 00000000000..a2677945fc2 --- /dev/null +++ b/test/rules/indent/tabs-4/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "indent": [true, "tabs", 4] + } +} diff --git a/test/rules/interface-name/always-prefix/test.ts.lint b/test/rules/interface-name/always-prefix/test.ts.lint new file mode 100644 index 00000000000..a196ab0fb7e --- /dev/null +++ b/test/rules/interface-name/always-prefix/test.ts.lint @@ -0,0 +1,34 @@ +// valid code +interface IOptions { +} + +interface ID { +} + +interface IABC { +} + +interface IDBFactory { +} + +interface II18nService { +} + +interface IIS3Foobar { +} + +interface IS3Foobar { +} + +// invalid code +interface Options { + ~~~~~~~ [interface name must start with a capitalized I] +} + +interface Incomplete { + ~~~~~~~~~~ [interface name must start with a capitalized I] +} + +interface I18nService { + ~~~~~~~~~~~ [interface name must start with a capitalized I] +} diff --git a/test/rules/interface-name/always-prefix/tslint.json b/test/rules/interface-name/always-prefix/tslint.json new file mode 100644 index 00000000000..be1e1405023 --- /dev/null +++ b/test/rules/interface-name/always-prefix/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "interface-name": [true, "always-prefix"] + } +} diff --git a/test/rules/interface-name/default/test.ts.lint b/test/rules/interface-name/default/test.ts.lint new file mode 100644 index 00000000000..5904c7e823d --- /dev/null +++ b/test/rules/interface-name/default/test.ts.lint @@ -0,0 +1,7 @@ +interface IValidInterfaceName { + +} + +interface NotValidInterfaceName { + ~~~~~~~~~~~~~~~~~~~~~ [interface name must start with a capitalized I] +} diff --git a/test/rules/interface-name/default/tslint.json b/test/rules/interface-name/default/tslint.json new file mode 100644 index 00000000000..a474c87992a --- /dev/null +++ b/test/rules/interface-name/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "interface-name": true + } +} diff --git a/test/rules/interface-name/never-prefix/test.ts.lint b/test/rules/interface-name/never-prefix/test.ts.lint new file mode 100644 index 00000000000..1dd62de83ba --- /dev/null +++ b/test/rules/interface-name/never-prefix/test.ts.lint @@ -0,0 +1,35 @@ +// valid code +interface Index { +} + +interface I { +} + +interface ID { +} + +interface IABC { +} + +interface IDBFactory { +} + +interface I18nFactory { +} + +interface II18nFactory { +} + +interface IS3Foobar { +} + +interface IIS3Foobar { +} + +interface ABC { +} + +// invalid code +interface IOptions { + ~~~~~~~~ [interface name must not have an "I" prefix] +} diff --git a/test/rules/interface-name/never-prefix/tslint.json b/test/rules/interface-name/never-prefix/tslint.json new file mode 100644 index 00000000000..bd0d2d24374 --- /dev/null +++ b/test/rules/interface-name/never-prefix/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "interface-name": [true, "never-prefix"] + } +} diff --git a/test/rules/interface-over-type-literal/test.ts.fix b/test/rules/interface-over-type-literal/test.ts.fix new file mode 100644 index 00000000000..69ff2367698 --- /dev/null +++ b/test/rules/interface-over-type-literal/test.ts.fix @@ -0,0 +1,10 @@ +interface T { x: number; } + +type U = string; +type V = { x: number; } | { y: string; }; +export interface W { + x: T, +} +type Record = { + [K in T]: U; +} diff --git a/test/rules/interface-over-type-literal/test.ts.lint b/test/rules/interface-over-type-literal/test.ts.lint new file mode 100644 index 00000000000..de37151b029 --- /dev/null +++ b/test/rules/interface-over-type-literal/test.ts.lint @@ -0,0 +1,14 @@ +type T = { x: number; } + ~ [0] + +type U = string; +type V = { x: number; } | { y: string; }; +export type W = { + ~ [0] + x: T, +}; +type Record = { + [K in T]: U; +} + +[0]: Use an interface instead of a type literal. \ No newline at end of file diff --git a/test/rules/interface-over-type-literal/tslint.json b/test/rules/interface-over-type-literal/tslint.json new file mode 100644 index 00000000000..dfcff017ebf --- /dev/null +++ b/test/rules/interface-over-type-literal/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "interface-over-type-literal": true + } +} \ No newline at end of file diff --git a/test/rules/invalid-void/allow-generics/false/test.ts.lint b/test/rules/invalid-void/allow-generics/false/test.ts.lint new file mode 100644 index 00000000000..2ad5f1ef10f --- /dev/null +++ b/test/rules/invalid-void/allow-generics/false/test.ts.lint @@ -0,0 +1,16 @@ +type Generic = [T]; +type GenericVoid = Generic; + ~~~~ [0] + +function takeVoid(thing: void) { } + ~~~~ [0] + +let voidPromise: Promise = new Promise(() => {}); + ~~~~ [0] + ~~~~ [0] + +let voidMap: Map = new Map(); + ~~~~ [0] + ~~~~ [0] + +[0]: void is only valid as a return type diff --git a/test/rules/invalid-void/allow-generics/false/tslint.json b/test/rules/invalid-void/allow-generics/false/tslint.json new file mode 100644 index 00000000000..baddd96c2b4 --- /dev/null +++ b/test/rules/invalid-void/allow-generics/false/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "invalid-void": [true, { + "allow-generics": false + }] + } +} diff --git a/test/rules/invalid-void/allow-generics/true/test.ts.lint b/test/rules/invalid-void/allow-generics/true/test.ts.lint new file mode 100644 index 00000000000..900c5f54946 --- /dev/null +++ b/test/rules/invalid-void/allow-generics/true/test.ts.lint @@ -0,0 +1,11 @@ +type Generic = [T]; +type GenericVoid = Generic; + +function takeVoid(thing: void) { } + ~~~~ [0] + +let voidPromise: Promise = new Promise(() => {}); + +let voidMap: Map = new Map(); + +[0]: void is only valid as a return type or generic type variable diff --git a/test/rules/invalid-void/allow-generics/true/tslint.json b/test/rules/invalid-void/allow-generics/true/tslint.json new file mode 100644 index 00000000000..d7dec9afca2 --- /dev/null +++ b/test/rules/invalid-void/allow-generics/true/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "invalid-void": [true, { + "allow-generics": true + }] + } +} diff --git a/test/rules/invalid-void/allow-generics/whitelist/test.ts.lint b/test/rules/invalid-void/allow-generics/whitelist/test.ts.lint new file mode 100644 index 00000000000..3734b406e2b --- /dev/null +++ b/test/rules/invalid-void/allow-generics/whitelist/test.ts.lint @@ -0,0 +1,12 @@ +type Allowed = [T]; +type AllowedVoid = Allowed; + +type Banned = [T]; +type BannedVoid = Banned; + ~~~~ [Generic % ('Banned')] + +function takeVoid(thing: void) { } + ~~~~ [0] + +[0]: void is only valid as a return type or generic type variable +[Generic]: %s may not have void as a type variable diff --git a/test/rules/invalid-void/allow-generics/whitelist/tslint.json b/test/rules/invalid-void/allow-generics/whitelist/tslint.json new file mode 100644 index 00000000000..44c4d38f9ef --- /dev/null +++ b/test/rules/invalid-void/allow-generics/whitelist/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "invalid-void": [true, { + "allow-generics": ["Allowed"] + }] + } +} diff --git a/test/rules/invalid-void/default/test.ts.lint b/test/rules/invalid-void/default/test.ts.lint new file mode 100644 index 00000000000..1f1fef5fc85 --- /dev/null +++ b/test/rules/invalid-void/default/test.ts.lint @@ -0,0 +1,127 @@ +function func(): void {} + +type NormalType = () => void; + +let normalArrow = (): void => { } + +let ughThisThing = void 0; + +function takeThing(thing: undefined) { } +takeThing(void 0); + +function takeVoid(thing: void) { } + ~~~~ [0] + + +const arrowGeneric = (arg: T) => { } + ~~~~ [0] +#if typescript >= 2.3.0 +const arrowGeneric1 = (arg: T) => { } + ~~~~ [0] +const arrowGeneric2 = (arg: T) => { } + ~~~~ [0] + ~~~~ [0] +#endif + +#if typescript >= 2.3.0 +function functionGeneric(arg: T) {} + ~~~~ [0] + +function functionGeneric1(arg: T) {} + ~~~~ [0] +function functionGeneric2(arg: T) {} + ~~~~ [0] + ~~~~ [0] +#endif + +declare function functionDeclaration(arg: T): void; + ~~~~ [0] +#if typescript >= 2.3.0 +declare function functionDeclaration1(arg: T): void; + ~~~~ [0] +declare function functionDeclaration2(arg: T): void; + ~~~~ [0] + ~~~~ [0] +#endif + + +functionGeneric(undefined); + ~~~~ [0] + +declare function voidArray(args: void[]): void[]; + ~~~~ [0] + ~~~~ [0] + +let value = undefined as void; + ~~~~ [0] + +let value = undefined; + ~~~~ [0] + +function takesThings(...things: void[]): void { } + ~~~~ [0] + +type KeyofVoid = keyof void; + ~~~~[0] + +interface Interface { + lambda: () => void; + voidProp: void; + ~~~~ [0] +} + +class ClassName { + private readonly propName: void; + ~~~~ [0] +} + +let voidPromise: Promise = new Promise(() => {}); + +let voidMap: Map = new Map(); + +let letVoid: void; + ~~~~ [0] + +type VoidType = void; + ~~~~ [0] + +class OtherClassName { + private propName: VoidType; +} + +type UnionType = string | number; +type UnionType2 = string | number | void; + ~~~~ [0] + +type UnionType3 = string | (number & any | (string | void)); + ~~~~ [0] + +type IntersectionType = string & number & void; + ~~~~ [0] + +function returnsVoidPromiseDirectly(): Promise { + return Promise.resolve(); +} + +async function returnsVoidPromiseAsync(): Promise {} + +#if typescript >= 2.8.0 +type MappedType = { + [K in keyof T]: void; + ~~~~ [0] +} +type ConditionalType = { + [K in keyof T]: T[K] extends string ? void : string; + ~~~~ [0] +} +#endif + +#if typescript >= 3.4.0 +type ManyVoid = readonly void[]; + ~~~~ [0] + +function foo(arr: readonly void[]) { } + ~~~~ [0] +#endif + +[0]: void is only valid as a return type or generic type variable diff --git a/test/rules/invalid-void/default/tslint.json b/test/rules/invalid-void/default/tslint.json new file mode 100644 index 00000000000..79da7276673 --- /dev/null +++ b/test/rules/invalid-void/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "invalid-void": true + } +} diff --git a/test/rules/jsdoc-format/check-multiline-start/test.ts.lint b/test/rules/jsdoc-format/check-multiline-start/test.ts.lint new file mode 100644 index 00000000000..1e78b77b079 --- /dev/null +++ b/test/rules/jsdoc-format/check-multiline-start/test.ts.lint @@ -0,0 +1,10 @@ + /** First line of multiline jsdoc + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [jsdoc is not formatted correctly on this line] + * should be empty. + */ + + /** + * Good multiline. + */ + + /** Good singleline */ diff --git a/test/rules/jsdoc-format/check-multiline-start/tslint.json b/test/rules/jsdoc-format/check-multiline-start/tslint.json new file mode 100644 index 00000000000..40faa974a27 --- /dev/null +++ b/test/rules/jsdoc-format/check-multiline-start/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "jsdoc-format": [true, "check-multiline-start"] + } +} diff --git a/test/rules/jsdoc-format/default/jsdoc-bom.ts.lint b/test/rules/jsdoc-format/default/jsdoc-bom.ts.lint new file mode 100644 index 00000000000..7cbf9e07419 --- /dev/null +++ b/test/rules/jsdoc-format/default/jsdoc-bom.ts.lint @@ -0,0 +1,3 @@ +/** + * This is a valid jsdoc comment and should show no warning even though there is a BOM in the first line + */ diff --git a/test/rules/jsdoc-format/default/jsdoc-windows.ts.lint b/test/rules/jsdoc-format/default/jsdoc-windows.ts.lint new file mode 100644 index 00000000000..5d6090b9b0a --- /dev/null +++ b/test/rules/jsdoc-format/default/jsdoc-windows.ts.lint @@ -0,0 +1,24 @@ +/** + * MyClass + * + * Does classy things and impresses everyone. Quite a debonair class indeed. + * + * This file has all windows line endings "\r\n" and valid jsdoc. + */ +class MyClass { + +} + +/** + *here comes some invalid jsdoc +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] + to ensure that the error is shown in the right place +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [asterisks] + * +*/ +~~ [asterisks] +function foo() {} + +[format]: jsdoc is not formatted correctly on this line +[asterisks]: asterisks in jsdoc must be aligned \ No newline at end of file diff --git a/test/rules/jsdoc-format/default/jsdoc.ts.lint b/test/rules/jsdoc-format/default/jsdoc.ts.lint new file mode 100644 index 00000000000..8a66c75a6be --- /dev/null +++ b/test/rules/jsdoc-format/default/jsdoc.ts.lint @@ -0,0 +1,88 @@ +function makeHeader(pkg: Package) { + return [ + `\t/**`, + `\t * ${pkg.name} v${pkg.version}`, + `\t */` + ].join("\r\n"); +} + +class Clazz { //this is not a block comment + /* block comment + *Not a jsdoc and not subject to the rules lalala + * oh look I'm over here and you can't do anything about me + *and now I'm here, wheeee +I've even got characters where I shouldn't. How fun! * + You can't stop me! */ + public funcxion() { + /** + * This is jsdoc + * and it is correct + * so should be no errors here + * + * not on the above line either + */ + } + + /**********************************************************/ + /* this is just an arbitrary separator, not a jsdoc block */ + /**********************************************************/ + + /** + * this is also jsdoc + *and it has a problem on this line +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] + */ + + /** + * this jsoc is fine + * up until the last line when it isn't + */ +~~~~~ [asterisks] + + /** + * this jsdoc has characters where it really should +not */ +~~~~~~~ [format] + + /** + * same thing with this +one * +~~~~~~ [format] + */ + + /** + * what else can go wrong? + * oh right this +~~~~~~~~~~~~~~~~~~ [asterisks] + */ + + /**a bad one liner */ + ~~~~~~~~~~~~~~~~~~~~~ [format] + + /** another bad one liner*/ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [format] + + /** */ + + /** */ + + /** a good one */ + + /**/ // no jsdoc + + /** First line of multiline jsdoc + * should be empty. + */ +} + +// Regression test: jsdoc rule shouldn't look inside template strings (https://github.com/palantir/tslint/issues/332) +function makeHeader(pkg: Package) { + return [ + `\t/**`, + `\t * ${pkg.name} v${pkg.version}`, + `\t */` + ].join("\r\n"); +} + +[format]: jsdoc is not formatted correctly on this line +[asterisks]: asterisks in jsdoc must be aligned diff --git a/test/rules/jsdoc-format/default/tslint.json b/test/rules/jsdoc-format/default/tslint.json new file mode 100644 index 00000000000..02b95774ec7 --- /dev/null +++ b/test/rules/jsdoc-format/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "jsdoc-format": true + } +} diff --git a/test/rules/label-position/test.ts.lint b/test/rules/label-position/test.ts.lint new file mode 100644 index 00000000000..cd7c95afd2d --- /dev/null +++ b/test/rules/label-position/test.ts.lint @@ -0,0 +1,38 @@ +var t = function() { + lab1: + ~~~~ [unexpected label on statement] + var x = 123; + + lab2: + ~~~~ [unexpected label on statement] + console.log("123"); + + lab3: + for (var i = 0; i < 5; ++i) { + break lab3; + } + + lab4: + do { + break lab4; + } while (i < 10); + + lab5: + while (i < 10) { + lab6: + while (j < 20) { + break lab5; + } + } + + lab7: + switch (i) { + case 0: + break lab7; + } + + lab8: + for (let value of [1]) { + break lab8; + } +}; diff --git a/test/rules/label-position/tslint.json b/test/rules/label-position/tslint.json new file mode 100644 index 00000000000..82a6a0582e6 --- /dev/null +++ b/test/rules/label-position/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "label-position": true + } +} diff --git a/test/rules/linebreak-style/emptyFile/test.ts.lint b/test/rules/linebreak-style/emptyFile/test.ts.lint new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/linebreak-style/emptyFile/tslint.json b/test/rules/linebreak-style/emptyFile/tslint.json new file mode 100644 index 00000000000..f82a6f4d1df --- /dev/null +++ b/test/rules/linebreak-style/emptyFile/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "linebreak-style": [true, "LF"] + } +} diff --git a/test/rules/linebreak-style/failure/CRLF/test.ts.fix b/test/rules/linebreak-style/failure/CRLF/test.ts.fix new file mode 100644 index 00000000000..4a60171c332 --- /dev/null +++ b/test/rules/linebreak-style/failure/CRLF/test.ts.fix @@ -0,0 +1,4 @@ +// this line uses CRLF +// this line uses CRLF +// this line uses CRLF +// this line uses CRLF diff --git a/test/rules/linebreak-style/failure/CRLF/test.ts.lint b/test/rules/linebreak-style/failure/CRLF/test.ts.lint new file mode 100644 index 00000000000..7d55d0fe1f9 --- /dev/null +++ b/test/rules/linebreak-style/failure/CRLF/test.ts.lint @@ -0,0 +1,8 @@ +// this line uses CRLF +~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] +// this line uses CRLF +~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] +// this line uses CRLF +~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] +// this line uses CRLF +~~~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'LF'] diff --git a/test/rules/linebreak-style/failure/CRLF/tslint.json b/test/rules/linebreak-style/failure/CRLF/tslint.json new file mode 100644 index 00000000000..f82a6f4d1df --- /dev/null +++ b/test/rules/linebreak-style/failure/CRLF/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "linebreak-style": [true, "LF"] + } +} diff --git a/test/rules/linebreak-style/failure/LF/test.ts.fix b/test/rules/linebreak-style/failure/LF/test.ts.fix new file mode 100644 index 00000000000..1f88a5a75a2 --- /dev/null +++ b/test/rules/linebreak-style/failure/LF/test.ts.fix @@ -0,0 +1,4 @@ +// this line uses LF +// this line uses LF +// this line uses LF +// this line uses LF diff --git a/test/rules/linebreak-style/failure/LF/test.ts.lint b/test/rules/linebreak-style/failure/LF/test.ts.lint new file mode 100644 index 00000000000..fa51e943c77 --- /dev/null +++ b/test/rules/linebreak-style/failure/LF/test.ts.lint @@ -0,0 +1,8 @@ +// this line uses LF +~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] +// this line uses LF +~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] +// this line uses LF +~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] +// this line uses LF +~~~~~~~~~~~~~~~~~~~~ [Expected linebreak to be 'CRLF'] diff --git a/test/rules/linebreak-style/failure/LF/tslint.json b/test/rules/linebreak-style/failure/LF/tslint.json new file mode 100644 index 00000000000..d959e7a49e4 --- /dev/null +++ b/test/rules/linebreak-style/failure/LF/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "linebreak-style": [true, "CRLF"] + } +} diff --git a/test/rules/linebreak-style/success/CRLF/test.ts.lint b/test/rules/linebreak-style/success/CRLF/test.ts.lint new file mode 100644 index 00000000000..4a60171c332 --- /dev/null +++ b/test/rules/linebreak-style/success/CRLF/test.ts.lint @@ -0,0 +1,4 @@ +// this line uses CRLF +// this line uses CRLF +// this line uses CRLF +// this line uses CRLF diff --git a/test/rules/linebreak-style/success/CRLF/tslint.json b/test/rules/linebreak-style/success/CRLF/tslint.json new file mode 100644 index 00000000000..d959e7a49e4 --- /dev/null +++ b/test/rules/linebreak-style/success/CRLF/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "linebreak-style": [true, "CRLF"] + } +} diff --git a/test/rules/linebreak-style/success/LF/test.ts.lint b/test/rules/linebreak-style/success/LF/test.ts.lint new file mode 100644 index 00000000000..1f88a5a75a2 --- /dev/null +++ b/test/rules/linebreak-style/success/LF/test.ts.lint @@ -0,0 +1,4 @@ +// this line uses LF +// this line uses LF +// this line uses LF +// this line uses LF diff --git a/test/rules/linebreak-style/success/LF/tslint.json b/test/rules/linebreak-style/success/LF/tslint.json new file mode 100644 index 00000000000..f82a6f4d1df --- /dev/null +++ b/test/rules/linebreak-style/success/LF/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "linebreak-style": [true, "LF"] + } +} diff --git a/test/rules/match-default-export-name/anonymous.test.ts b/test/rules/match-default-export-name/anonymous.test.ts new file mode 100644 index 00000000000..7f810d3f328 --- /dev/null +++ b/test/rules/match-default-export-name/anonymous.test.ts @@ -0,0 +1 @@ +export default 0; diff --git a/test/rules/match-default-export-name/named.test.ts b/test/rules/match-default-export-name/named.test.ts new file mode 100644 index 00000000000..c33f5633d79 --- /dev/null +++ b/test/rules/match-default-export-name/named.test.ts @@ -0,0 +1 @@ +export default function a() {} diff --git a/test/rules/match-default-export-name/test.ts.lint b/test/rules/match-default-export-name/test.ts.lint new file mode 100644 index 00000000000..5fdb33083bd --- /dev/null +++ b/test/rules/match-default-export-name/test.ts.lint @@ -0,0 +1,3 @@ +import b from "./named.test"; + ~ [Expected import 'b' to match the default export 'a'.] +import anyName from "./anonymous.test"; diff --git a/test/rules/match-default-export-name/tsconfig.json b/test/rules/match-default-export-name/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/match-default-export-name/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/match-default-export-name/tslint.json b/test/rules/match-default-export-name/tslint.json new file mode 100644 index 00000000000..be090e5892d --- /dev/null +++ b/test/rules/match-default-export-name/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "match-default-export-name": true + } +} diff --git a/test/rules/max-classes-per-file/one/test.ts.lint b/test/rules/max-classes-per-file/one/test.ts.lint new file mode 100644 index 00000000000..a2910cb15f6 --- /dev/null +++ b/test/rules/max-classes-per-file/one/test.ts.lint @@ -0,0 +1,35 @@ +export abstract class UnsupportedVisitor extends NodeVisitor { + public static withDescriptor(descriptor: string): typeof UnsupportedVisitor { + return class extends UnsupportedVisitor { + protected descriptor = descriptor; + }; + } + + protected abstract descriptor: string; + + public visit(node: Node): undefined { + return `${this.descriptor} is not supported.`; + } +} + +class one { +~~~~~~~~~~~ + public foo = "bar"; +~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [0] + +class two { +~~~~~~~~~~~ + public banana = "apple"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + public theAbovePropertyMakesSense = false; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [0] + +let three = class { + public foo = "bar"; +} + +[0]: A maximum of 1 class per file is allowed. diff --git a/test/rules/max-classes-per-file/one/tslint.json b/test/rules/max-classes-per-file/one/tslint.json new file mode 100644 index 00000000000..62170ab7c05 --- /dev/null +++ b/test/rules/max-classes-per-file/one/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "max-classes-per-file": [true, 1, "exclude-class-expressions"] + } +} diff --git a/test/rules/max-classes-per-file/two/test.ts.lint b/test/rules/max-classes-per-file/two/test.ts.lint new file mode 100644 index 00000000000..38e499b87e5 --- /dev/null +++ b/test/rules/max-classes-per-file/two/test.ts.lint @@ -0,0 +1,23 @@ +class one { + public foo = "bar"; +} + +class two { + public foo = "bar"; +} + +let three = class { + ~~~~~~~ + public foo = "bar"; +~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [0] + +class four { +~~~~~~~~~~~~ + public foo = "bar"; +~~~~~~~~~~~~~~~~~~~~~~~ +} +~ [0] + +[0]: A maximum of 2 classes per file are allowed. diff --git a/test/rules/max-classes-per-file/two/tslint.json b/test/rules/max-classes-per-file/two/tslint.json new file mode 100644 index 00000000000..2064f81ad82 --- /dev/null +++ b/test/rules/max-classes-per-file/two/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "max-classes-per-file": [true, 2] + } +} diff --git a/test/rules/max-file-line-count/default/test.ts.lint b/test/rules/max-file-line-count/default/test.ts.lint new file mode 100644 index 00000000000..d6425abcfce --- /dev/null +++ b/test/rules/max-file-line-count/default/test.ts.lint @@ -0,0 +1,23 @@ +namespace App { + class GiveMeANumber { + + /* tslint:disable:no-any */ + private num:any = 10; + /* tslint:enable:no-any */ + + //This is some kind of comment + constructor(){ + this.giveNumber(); + } + + /* + Here is another comment + It's very helpful. + */ + + public giveNumber = () =>{ + alert(this.num); + }; + } +} +~ [This file has 22 lines, which exceeds the maximum of 10 lines allowed. Consider breaking this file up into smaller parts] \ No newline at end of file diff --git a/test/rules/max-file-line-count/default/tslint.json b/test/rules/max-file-line-count/default/tslint.json new file mode 100644 index 00000000000..0a612cdcda6 --- /dev/null +++ b/test/rules/max-file-line-count/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "max-file-line-count": [true, 10] + } +} diff --git a/test/rules/max-file-line-count/disabled/test.ts.lint b/test/rules/max-file-line-count/disabled/test.ts.lint new file mode 100644 index 00000000000..b648ec13e27 --- /dev/null +++ b/test/rules/max-file-line-count/disabled/test.ts.lint @@ -0,0 +1,24 @@ +//This file NEEDS to be very long, so we've disabled this rule here + +/* tslint:disable:max-file-line-count */ + +namespace App { + class GiveMeANumber { + + //THis is a comment about something + private num = 10; + + constructor(){ + this.giveNumber(); + } + + /* + Here is another comment + It's very helpful. + */ + + public giveNumber = () =>{ + alert(this.num); + }; + } +} diff --git a/test/rules/max-file-line-count/disabled/tslint.json b/test/rules/max-file-line-count/disabled/tslint.json new file mode 100644 index 00000000000..0a612cdcda6 --- /dev/null +++ b/test/rules/max-file-line-count/disabled/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "max-file-line-count": [true, 10] + } +} diff --git a/test/rules/max-line-length/check-strings-and-regex/test.ts.lint b/test/rules/max-line-length/check-strings-and-regex/test.ts.lint new file mode 100644 index 00000000000..438b13a6f8e --- /dev/null +++ b/test/rules/max-line-length/check-strings-and-regex/test.ts.lint @@ -0,0 +1,33 @@ +import { KindOfOneVerySpecificComponentOrSomethingLikeThis } from '../../../../very/very/very/very/very/long/and/complicated/and/nested/directory/structure/target'; + +var simpleName = 1; +var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedName; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicat; + +const extremelyLongSingleQuoteString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const extremelyLongDoubleQuoteString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const extremelyLongTemplateString = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu`; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const extremelyLongTemplateStringWithVariableAtLimit = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod ${simpleName} ut labore et dolore magna aliquyam `; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const multiLineTemplateString = ` +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +`; + +const veryLongRegularExpression = /\s*********************************************************************************************************************/; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: Exceeds maximum line length of 140 \ No newline at end of file diff --git a/test/rules/max-line-length/check-strings-and-regex/tslint.json b/test/rules/max-line-length/check-strings-and-regex/tslint.json new file mode 100644 index 00000000000..fd6631ccaae --- /dev/null +++ b/test/rules/max-line-length/check-strings-and-regex/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "max-line-length": [true, { + "limit": "140", + "ignore-pattern": "^import ", + "check-strings": true, + "check-regex": true + }] + } +} diff --git a/test/rules/max-line-length/default/test.ts.lint b/test/rules/max-line-length/default/test.ts.lint new file mode 100644 index 00000000000..eb9b6dc1172 --- /dev/null +++ b/test/rules/max-line-length/default/test.ts.lint @@ -0,0 +1,25 @@ +import { KindOfOneVerySpecificComponentOrSomethingLikeThis } from '../../../../very/very/very/very/very/long/and/complicated/and/nested/directory/structure/target'; + +var simpleName = 1; +var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedName; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +var complicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicatedNameIsAcomplicat; + +const extremelyLongSingleQuoteString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu'; + +const extremelyLongDoubleQuoteString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu"; + +const extremelyLongTemplateString = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu`; + +const extremelyLongTemplateStringWithVariableAtLimit = `Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod ${someVariable} ut labore et dolore magna aliquyam `; + +const multiLineTemplateString = ` +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu +`; + +const veryLongRegularExpression = /\s*********************************************************************************************************************/; + +[0]: Exceeds maximum line length of 140 \ No newline at end of file diff --git a/test/rules/max-line-length/default/tslint.json b/test/rules/max-line-length/default/tslint.json new file mode 100644 index 00000000000..5937f62d6a7 --- /dev/null +++ b/test/rules/max-line-length/default/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "max-line-length": [true, { + "limit": 140 + }] + } +} diff --git a/test/rules/member-access/accessor/test.ts.fix b/test/rules/member-access/accessor/test.ts.fix new file mode 100644 index 00000000000..5a91a06fc98 --- /dev/null +++ b/test/rules/member-access/accessor/test.ts.fix @@ -0,0 +1,17 @@ +class Members { + public get g() { + return 1; + } + public set s(o: any) {} + + public get publicG() { + return 1; + } + public set publicS(o: any) {} +} + +const obj = { + get g() { + return 1; + } +}; diff --git a/test/rules/member-access/accessor/test.ts.lint b/test/rules/member-access/accessor/test.ts.lint new file mode 100644 index 00000000000..4541a8fbb78 --- /dev/null +++ b/test/rules/member-access/accessor/test.ts.lint @@ -0,0 +1,19 @@ +class Members { + get g() { + ~ [The get property accessor 'g' must be marked either 'private', 'public', or 'protected'] + return 1; + } + set s(o: any) {} + ~ [The set property accessor 's' must be marked either 'private', 'public', or 'protected'] + + public get publicG() { + return 1; + } + public set publicS(o: any) {} +} + +const obj = { + get g() { + return 1; + } +}; diff --git a/test/rules/member-access/accessor/tslint.json b/test/rules/member-access/accessor/tslint.json new file mode 100644 index 00000000000..165c6526ab4 --- /dev/null +++ b/test/rules/member-access/accessor/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-access": [true, "check-accessor"] + } +} diff --git a/test/rules/member-access/constructor/test.ts.fix b/test/rules/member-access/constructor/test.ts.fix new file mode 100644 index 00000000000..d4b9899da44 --- /dev/null +++ b/test/rules/member-access/constructor/test.ts.fix @@ -0,0 +1,10 @@ +class ContructorsNoAccess { + public constructor(i: number); + public constructor(o: any) {} +} + +class ContructorsAccess { + public constructor(i: number); + public constructor(o: any) {} +} + diff --git a/test/rules/member-access/constructor/test.ts.lint b/test/rules/member-access/constructor/test.ts.lint new file mode 100644 index 00000000000..7c140b2da27 --- /dev/null +++ b/test/rules/member-access/constructor/test.ts.lint @@ -0,0 +1,13 @@ +class ContructorsNoAccess { + constructor(i: number); + ~~~~~~~~~~~ [0] + constructor(o: any) {} + ~~~~~~~~~~~ [0] +} + +class ContructorsAccess { + public constructor(i: number); + public constructor(o: any) {} +} + +[0]: The class constructor must be marked either 'private', 'public', or 'protected' diff --git a/test/rules/member-access/constructor/tslint.json b/test/rules/member-access/constructor/tslint.json new file mode 100644 index 00000000000..2166eb52f4f --- /dev/null +++ b/test/rules/member-access/constructor/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-access": [true, "check-constructor"] + } +} diff --git a/test/rules/member-access/default/test.ts.fix b/test/rules/member-access/default/test.ts.fix new file mode 100644 index 00000000000..640a45fc5e9 --- /dev/null +++ b/test/rules/member-access/default/test.ts.fix @@ -0,0 +1,54 @@ +declare class AmbientNoAccess { + public a(): number; + + public static b(): number; +} + +declare class AmbientAccess { + public a(): number; + public static b(): number; +} + +class Members { + [x: string]: number; + public i: number; + public static j: number; + + public nPublic: number; + protected nProtected: number; + private nPrivate: number; + + public static nsPublic: number; + protected static nsProtected: number; + private static nsPrivate: number; + + public noAccess(x: number): number; + public noAccess(o: any): any {} + + public static noAccess(x: number): number; + public static noAccess(o: any): any {} + + public access(x: number): number; + public access(o: any): any {} + + public static access(x: number): number; + public static access(o: any): any {} +} + +const obj = { + func() {} +}; + +function main() { + class A { + public i: number; + public static j: number; + public n: number; + } +} + +abstract class Decorated { + @decorator public prop; + @decorator public abstract method() {} + @decorator @moreDecorator({}) public readonly static PROP = 'FOO'; +} diff --git a/test/rules/member-access/default/test.ts.lint b/test/rules/member-access/default/test.ts.lint new file mode 100644 index 00000000000..3f67fc4fa21 --- /dev/null +++ b/test/rules/member-access/default/test.ts.lint @@ -0,0 +1,67 @@ +declare class AmbientNoAccess { + a(): number; + ~ [The class method 'a' must be marked either 'private', 'public', or 'protected'] + + static b(): number; + ~ [The class method 'b' must be marked either 'private', 'public', or 'protected'] +} + +declare class AmbientAccess { + public a(): number; + public static b(): number; +} + +class Members { + [x: string]: number; + i: number; + ~ [The class property 'i' must be marked either 'private', 'public', or 'protected'] + static j: number; + ~ [The class property 'j' must be marked either 'private', 'public', or 'protected'] + + public nPublic: number; + protected nProtected: number; + private nPrivate: number; + + public static nsPublic: number; + protected static nsProtected: number; + private static nsPrivate: number; + + noAccess(x: number): number; + ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] + noAccess(o: any): any {} + ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] + + static noAccess(x: number): number; + ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] + static noAccess(o: any): any {} + ~~~~~~~~ [The class method 'noAccess' must be marked either 'private', 'public', or 'protected'] + + public access(x: number): number; + public access(o: any): any {} + + public static access(x: number): number; + public static access(o: any): any {} +} + +const obj = { + func() {} +}; + +function main() { + class A { + i: number; + ~ [The class property 'i' must be marked either 'private', 'public', or 'protected'] + static j: number; + ~ [The class property 'j' must be marked either 'private', 'public', or 'protected'] + public n: number; + } +} + +abstract class Decorated { + @decorator prop; + ~~~~ [The class property 'prop' must be marked either 'private', 'public', or 'protected'] + @decorator abstract method() {} + ~~~~~~ [The class method 'method' must be marked either 'private', 'public', or 'protected'] + @decorator @moreDecorator({}) readonly static PROP = 'FOO'; + ~~~~ [The class property 'PROP' must be marked either 'private', 'public', or 'protected'] +} diff --git a/test/rules/member-access/default/tslint.json b/test/rules/member-access/default/tslint.json new file mode 100644 index 00000000000..f9c417e0902 --- /dev/null +++ b/test/rules/member-access/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-access": true + } +} diff --git a/test/rules/member-access/no-public/test.ts.fix b/test/rules/member-access/no-public/test.ts.fix new file mode 100644 index 00000000000..25f61ce9e3a --- /dev/null +++ b/test/rules/member-access/no-public/test.ts.fix @@ -0,0 +1,12 @@ +class { + x() {} + constructor() {} + get y() {} + public() {} + constructor(readonly param : number) {} + constructor(readonly param : number) {} + constructor(private readonly paramPrivate : number, protected readonly paramProtected : number, readonly paramReadonly : number) {} + + constructor(public necessaryPublic : number) {} +} + diff --git a/test/rules/member-access/no-public/test.ts.lint b/test/rules/member-access/no-public/test.ts.lint new file mode 100644 index 00000000000..138f6d73841 --- /dev/null +++ b/test/rules/member-access/no-public/test.ts.lint @@ -0,0 +1,19 @@ +class { + public x() {} + ~~~~~~ [0] + public constructor() {} + ~~~~~~ [0] + public/*some comment*/ get y() {} + ~~~~~~ [0] + public() {} + constructor(public readonly param : number) {} + ~~~~~~ [0] + public constructor(public readonly param : number) {} + ~~~~~~ [0] + ~~~~~~ [0] + constructor(private readonly paramPrivate : number, protected readonly paramProtected : number, readonly paramReadonly : number) {} + + constructor(public necessaryPublic : number) {} +} + +[0]: 'public' is implicit. diff --git a/test/rules/member-access/no-public/tslint.json b/test/rules/member-access/no-public/tslint.json new file mode 100644 index 00000000000..bb4607c80fd --- /dev/null +++ b/test/rules/member-access/no-public/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-access": [true, "no-public"] + } +} diff --git a/test/rules/member-access/parameter-property/test.ts.fix b/test/rules/member-access/parameter-property/test.ts.fix new file mode 100644 index 00000000000..889981a518c --- /dev/null +++ b/test/rules/member-access/parameter-property/test.ts.fix @@ -0,0 +1,17 @@ +class Members { + constructor( + public readonly paramReadonly : number, + public paramPublic : number, + protected paramProtected : number, + private paramPrivate : number, + public readonly paramPublicReadonly : number, + protected readonly paramProtectedReadonly : number, + private readonly paramPrivateReadonly : number + ){ + + } + + constructor(public readonly a : number, @decorated public readonly b : number) { + + } +} diff --git a/test/rules/member-access/parameter-property/test.ts.lint b/test/rules/member-access/parameter-property/test.ts.lint new file mode 100644 index 00000000000..2c110ca7a31 --- /dev/null +++ b/test/rules/member-access/parameter-property/test.ts.lint @@ -0,0 +1,20 @@ +class Members { + constructor( + readonly paramReadonly : number, + ~~~~~~~~~~~~~ [The parameter property 'paramReadonly' must be marked either 'private', 'public', or 'protected'] + public paramPublic : number, + protected paramProtected : number, + private paramPrivate : number, + public readonly paramPublicReadonly : number, + protected readonly paramProtectedReadonly : number, + private readonly paramPrivateReadonly : number + ){ + + } + + constructor(readonly a : number, @decorated readonly b : number) { + ~ [The parameter property 'a' must be marked either 'private', 'public', or 'protected'] + ~ [The parameter property 'b' must be marked either 'private', 'public', or 'protected'] + + } +} diff --git a/test/rules/member-access/parameter-property/tslint.json b/test/rules/member-access/parameter-property/tslint.json new file mode 100644 index 00000000000..d4c6243e573 --- /dev/null +++ b/test/rules/member-access/parameter-property/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-access": [true, "check-parameter-property"] + } +} diff --git a/test/rules/member-ordering/alphabetize-nested/test.ts.fix b/test/rules/member-ordering/alphabetize-nested/test.ts.fix new file mode 100644 index 00000000000..7463bdea548 --- /dev/null +++ b/test/rules/member-ordering/alphabetize-nested/test.ts.fix @@ -0,0 +1,14 @@ +class X { + a() { + class A { + e() {} + f() {} + } + } + b() { + class B { + c() {} + d() {} + } + } +} diff --git a/test/rules/member-ordering/alphabetize-nested/test.ts.lint b/test/rules/member-ordering/alphabetize-nested/test.ts.lint new file mode 100644 index 00000000000..59d0e971cb9 --- /dev/null +++ b/test/rules/member-ordering/alphabetize-nested/test.ts.lint @@ -0,0 +1,17 @@ +class X { + b() { + class B { + d() {} + c() {} + ~ ['c' should come alphabetically before 'd'] + } + } + a() { + ~ ['a' should come alphabetically before 'b'] + class A { + f() {} + e() {} + ~ ['e' should come alphabetically before 'f'] + } + } +} diff --git a/test/rules/member-ordering/alphabetize-nested/tslint.json b/test/rules/member-ordering/alphabetize-nested/tslint.json new file mode 100644 index 00000000000..d63ae1f4057 --- /dev/null +++ b/test/rules/member-ordering/alphabetize-nested/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "member-ordering": [true, { + "order": "fields-first", + "alphabetize": true + }] + } +} diff --git a/test/rules/member-ordering/alphabetize/test.ts.fix b/test/rules/member-ordering/alphabetize/test.ts.fix new file mode 100644 index 00000000000..bc854ab87a3 --- /dev/null +++ b/test/rules/member-ordering/alphabetize/test.ts.fix @@ -0,0 +1,32 @@ +class X { + // Different categories have alphabetization together. + bar: number; + foo: string; + + get y() { + return 0; + } + set y(x: number) {} + get z() { + return 0; + } + + set z(x: number) {} + + [Symbol.iterator]() {} + // No ordering among computed properties + [Symbol.alpherator]() {} + + // Computed properties must go at the beginning. + [Symbol.zeterator]() {} + + 0() {} + 1() {} + 2() {} + bar() {} + + foo() {} + "goo"() {} + Hoo() {} + ioo() {} +} diff --git a/test/rules/member-ordering/alphabetize/test.ts.lint b/test/rules/member-ordering/alphabetize/test.ts.lint new file mode 100644 index 00000000000..6ae168f0267 --- /dev/null +++ b/test/rules/member-ordering/alphabetize/test.ts.lint @@ -0,0 +1,38 @@ +class X { + // Different categories have alphabetization together. + bar: number; + foo: string; + + set z(x: number) {} + get z() { + ~ [Getter for 'z' should appear before setter.] + return 0; + } + + get y() { + ~ ['y' should come alphabetically before 'z'] + return 0; + } + set y(x: number) {} + ~ ['y' should come alphabetically before 'z'] + + [Symbol.iterator]() {} + // No ordering among computed properties + [Symbol.alpherator]() {} + + 0() {} + 2() {} + 1() {} + ~ ['1' should come alphabetically before '2'] + + foo() {} + "goo"() {} + Hoo() {} + ioo() {} + bar() {} + ~~~ ['bar' should come alphabetically before 'foo'] + + // Computed properties must go at the beginning. + [Symbol.zeterator]() {} + ~~~~~~~~~~~~~~~~~~ [Computed property should come alphabetically before '0'] +} diff --git a/test/rules/member-ordering/alphabetize/tslint.json b/test/rules/member-ordering/alphabetize/tslint.json new file mode 100644 index 00000000000..d63ae1f4057 --- /dev/null +++ b/test/rules/member-ordering/alphabetize/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "member-ordering": [true, { + "order": "fields-first", + "alphabetize": true + }] + } +} diff --git a/test/rules/member-ordering/custom-categories/test.ts.fix b/test/rules/member-ordering/custom-categories/test.ts.fix new file mode 100644 index 00000000000..ad7d44f2f54 --- /dev/null +++ b/test/rules/member-ordering/custom-categories/test.ts.fix @@ -0,0 +1,9 @@ +class C { + static foo() {} + protected static bar = 0; + static baz(); + + static bang(); + + constructor(); +} diff --git a/test/rules/member-ordering/custom-categories/test.ts.lint b/test/rules/member-ordering/custom-categories/test.ts.lint new file mode 100644 index 00000000000..6df80c3273e --- /dev/null +++ b/test/rules/member-ordering/custom-categories/test.ts.lint @@ -0,0 +1,10 @@ +class C { + static foo() {} + protected static bar = 0; + static baz(); + + constructor(); + + static bang(); + ~~~~~~~~~~~~~~ [Declaration of static non-private not allowed after declaration of constructor. Instead, this should come at the beginning of the class/interface.] +} diff --git a/test/rules/member-ordering/custom-categories/tslint.json b/test/rules/member-ordering/custom-categories/tslint.json new file mode 100644 index 00000000000..ddacc962238 --- /dev/null +++ b/test/rules/member-ordering/custom-categories/tslint.json @@ -0,0 +1,18 @@ +{ + "rules": { + "member-ordering": [true, { + "order": [ + { + "name": "static non-private", + "kinds": [ + "public-static-field", + "protected-static-field", + "public-static-method", + "protected-static-method" + ] + }, + "constructor" + ] + }] + } +} diff --git a/test/rules/member-ordering/custom/test.ts.fix b/test/rules/member-ordering/custom/test.ts.fix new file mode 100644 index 00000000000..51d32ec08dd --- /dev/null +++ b/test/rules/member-ordering/custom/test.ts.fix @@ -0,0 +1,35 @@ +class Good { + constructor() {} + bar = 5; + static foo() {} + private z = 12; + private static zz = 10; +} + +class Bad { + constructor() {} + private static a() {} + static b() {} + private c = 2; +} + +class AlsoOkay { + constructor() { + const bar = { + someMethod() {} + }; + } + + private z = 10; +} + +const foo = { + // TS treats this as a method, but we should be careful not to + someMethod() {} +}; + +function makeAClass() { + const myClass = class { + method(){} + }; +} diff --git a/test/rules/member-ordering/custom/test.ts.lint b/test/rules/member-ordering/custom/test.ts.lint new file mode 100644 index 00000000000..6a4f8d749e2 --- /dev/null +++ b/test/rules/member-ordering/custom/test.ts.lint @@ -0,0 +1,36 @@ +class Good { + constructor() {} + bar = 5; + static foo() {} + private z = 12; + private static zz = 10; +} + +class Bad { + constructor() {} + private static a() {} + private c = 2; + static b() {} + ~~~~~~~~~~~~~ [Declaration of public static method not allowed after declaration of private instance field. Instead, this should come at the beginning of the class/interface.] +} + +class AlsoOkay { + constructor() { + const bar = { + someMethod() {} + }; + } + + private z = 10; +} + +const foo = { + // TS treats this as a method, but we should be careful not to + someMethod() {} +}; + +function makeAClass() { + const myClass = class { + method(){} + }; +} diff --git a/test/rules/member-ordering/custom/tslint.json b/test/rules/member-ordering/custom/tslint.json new file mode 100644 index 00000000000..5b8c7471e59 --- /dev/null +++ b/test/rules/member-ordering/custom/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "member-ordering": [true, { "order": [ + "public-static-method", + "private-instance-field" + ]}] + } +} diff --git a/test/rules/member-ordering/fields-first/test.ts.fix b/test/rules/member-ordering/fields-first/test.ts.fix new file mode 100644 index 00000000000..7c3057e9753 --- /dev/null +++ b/test/rules/member-ordering/fields-first/test.ts.fix @@ -0,0 +1,37 @@ +class Good { + public static a = 1; + protected static b = 2; + private static c = 3; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + public static g() {} + protected static h() {} + private static i = () => {}; + j = () => {}; + protected k() {}; + private l = () => {}; +} + +interface IGood { + foo: number; + arrowsAreFields: () => void; + nonArrowsAreMethods(): void; +} + +class Bad { + public static a = 1; + protected static b = 2; + private static c = 3; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + public static g() {} + protected static h() {} + private static i = () => {}; + j = () => {}; + protected k() {} + private l = () => {}; +} diff --git a/test/rules/member-ordering/fields-first/test.ts.lint b/test/rules/member-ordering/fields-first/test.ts.lint new file mode 100644 index 00000000000..4769de116d0 --- /dev/null +++ b/test/rules/member-ordering/fields-first/test.ts.lint @@ -0,0 +1,39 @@ +class Good { + public static a = 1; + protected static b = 2; + private static c = 3; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + public static g() {} + protected static h() {} + private static i = () => {}; + j = () => {}; + protected k() {}; + private l = () => {}; +} + +interface IGood { + foo: number; + arrowsAreFields: () => void; + nonArrowsAreMethods(): void; +} + +class Bad { + public static a = 1; + protected static b = 2; + public d = 4; + protected e: number = 5; + private static c = 3; + ~~~~~~~~~~~~~~~~~~~~~ [Declaration of private static field not allowed after declaration of protected instance field. Instead, this should come after protected static fields.] + private f = foo(); + public static g() {} + protected static h() {} + private static i = () => {}; + j = () => {}; + protected k() {} + constructor() {} + ~~~~~~~~~~~~~~~~ [Declaration of constructor not allowed after declaration of protected instance method. Instead, this should come after private instance fields.] + private l = () => {}; +} diff --git a/test/rules/member-ordering/fields-first/tslint.json b/test/rules/member-ordering/fields-first/tslint.json new file mode 100644 index 00000000000..5c797489522 --- /dev/null +++ b/test/rules/member-ordering/fields-first/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-ordering": [true, { "order": "fields-first" }] + } +} diff --git a/test/rules/member-ordering/fix-trivia/test.ts.fix b/test/rules/member-ordering/fix-trivia/test.ts.fix new file mode 100644 index 00000000000..e76c436a61e --- /dev/null +++ b/test/rules/member-ordering/fix-trivia/test.ts.fix @@ -0,0 +1,23 @@ +class A { + + /** + * bar() JSDoc. + */ + bar() { + return 2; + } // bar trailing comment + + /** + * foo() JSDoc. + */ + foo(x: string): number + // an overload taking a string + foo(x: number): number // comment after foo(x: number) + foo(x: string | number): number { + return 1; + } // foo trailing comment +} + +class B { +declaration() {} // 4 +line() {} /* 3 */ /* 1 */ single() {} /* 2 */ } diff --git a/test/rules/member-ordering/fix-trivia/test.ts.lint b/test/rules/member-ordering/fix-trivia/test.ts.lint new file mode 100644 index 00000000000..2f6e456bbdb --- /dev/null +++ b/test/rules/member-ordering/fix-trivia/test.ts.lint @@ -0,0 +1,26 @@ +class A { + + /** + * foo() JSDoc. + */ + foo(x: string): number + // an overload taking a string + foo(x: number): number // comment after foo(x: number) + foo(x: string | number): number { + return 1; + } // foo trailing comment + + /** + * bar() JSDoc. + */ + bar() { + ~~~ ['bar' should come alphabetically before 'foo'] + return 2; + } // bar trailing comment +} + +class B { + /* 1 */ single() {} /* 2 */ line() {} /* 3 */ declaration() {} // 4 + ~~~~ ['line' should come alphabetically before 'single'] + ~~~~~~~~~~~ ['declaration' should come alphabetically before 'single'] +} diff --git a/test/rules/member-ordering/fix-trivia/tslint.json b/test/rules/member-ordering/fix-trivia/tslint.json new file mode 100644 index 00000000000..d63ae1f4057 --- /dev/null +++ b/test/rules/member-ordering/fix-trivia/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "member-ordering": [true, { + "order": "fields-first", + "alphabetize": true + }] + } +} diff --git a/test/rules/member-ordering/instance-sandwich/test.ts.fix b/test/rules/member-ordering/instance-sandwich/test.ts.fix new file mode 100644 index 00000000000..5043f06924e --- /dev/null +++ b/test/rules/member-ordering/instance-sandwich/test.ts.fix @@ -0,0 +1,37 @@ +class Good { + public static a = 1; + protected static b = 2; + private static c = 3; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + j = () => {}; + protected k() {} + private l = () => {}; + public static g() {} + protected static h() {} + private static i = () => {}; +} + +interface IGood { + foo: number; + arrowsAreFields: () => void; + nonArrowsAreMethods(): void; +} + +class Bad { + public static a = 1; + protected static b = 2; + private static c = 3; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + j = () => {}; + protected k() {} + private l = () => {}; + public static g() {} + protected static h() {} + private static i = () => {}; +} diff --git a/test/rules/member-ordering/instance-sandwich/test.ts.lint b/test/rules/member-ordering/instance-sandwich/test.ts.lint new file mode 100644 index 00000000000..537ce64d9af --- /dev/null +++ b/test/rules/member-ordering/instance-sandwich/test.ts.lint @@ -0,0 +1,40 @@ +class Good { + public static a = 1; + protected static b = 2; + private static c = 3; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + j = () => {}; + protected k() {} + private l = () => {}; + public static g() {} + protected static h() {} + private static i = () => {}; +} + +interface IGood { + foo: number; + arrowsAreFields: () => void; + nonArrowsAreMethods(): void; +} + +class Bad { + public static a = 1; + public d = 4; + protected static b = 2; + ~~~~~~~~~~~~~~~~~~~~~~~ [Declaration of protected static field not allowed after declaration of public instance field. Instead, this should come after public static fields.] + private static c = 3; + ~~~~~~~~~~~~~~~~~~~~~ [Declaration of private static field not allowed after declaration of public instance field. Instead, this should come after protected static fields.] + protected e: number = 5; + private f = foo(); + j = () => {}; + protected k() {} + private l = () => {}; + public static g() {} + protected static h() {} + private static i = () => {}; + constructor() {} + ~~~~~~~~~~~~~~~~ [Declaration of constructor not allowed after declaration of private static method. Instead, this should come after private instance fields.] +} diff --git a/test/rules/member-ordering/instance-sandwich/tslint.json b/test/rules/member-ordering/instance-sandwich/tslint.json new file mode 100644 index 00000000000..db381ec0429 --- /dev/null +++ b/test/rules/member-ordering/instance-sandwich/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-ordering": [true, { "order": "instance-sandwich" }] + } +} diff --git a/test/rules/member-ordering/mix-old-options/test.ts.fix b/test/rules/member-ordering/mix-old-options/test.ts.fix new file mode 100644 index 00000000000..677ce8b2228 --- /dev/null +++ b/test/rules/member-ordering/mix-old-options/test.ts.fix @@ -0,0 +1,15 @@ +class Foo { + public static x: number; + private static y: number; + public x: number; + + z: number; + private y: number; + + public static m() {} + private static n() {} + + constructor() {} + public m() {} + private n() {} +} diff --git a/test/rules/member-ordering/mix-old-options/test.ts.lint b/test/rules/member-ordering/mix-old-options/test.ts.lint new file mode 100644 index 00000000000..109ef9699e3 --- /dev/null +++ b/test/rules/member-ordering/mix-old-options/test.ts.lint @@ -0,0 +1,16 @@ +class Foo { + public static x: number; + private static y: number; + public x: number; + private y: number; + + public static m() {} + private static n() {} + + constructor() {} + public m() {} + private n() {} + + z: number; + ~~~~~~~~~~ [Declaration of public instance field not allowed after declaration of private instance method. Instead, this should come after private static fields.] +} diff --git a/test/rules/member-ordering/mix-old-options/tslint.json b/test/rules/member-ordering/mix-old-options/tslint.json new file mode 100644 index 00000000000..659333c1fbe --- /dev/null +++ b/test/rules/member-ordering/mix-old-options/tslint.json @@ -0,0 +1,9 @@ +{ + "rules": { + "member-ordering": [true, + "public-before-private", + "static-before-instance", + "variables-before-functions" + ] + } +} diff --git a/test/rules/member-ordering/omit-access-modifier/test.ts.fix b/test/rules/member-ordering/omit-access-modifier/test.ts.fix new file mode 100644 index 00000000000..adc639d8934 --- /dev/null +++ b/test/rules/member-ordering/omit-access-modifier/test.ts.fix @@ -0,0 +1,11 @@ +class C { + private static x = 0; + static y = 1; + + static z = 2; + + x = 0; + private y = 1; + + constructor() {} +} diff --git a/test/rules/member-ordering/omit-access-modifier/test.ts.lint b/test/rules/member-ordering/omit-access-modifier/test.ts.lint new file mode 100644 index 00000000000..fdfbf683047 --- /dev/null +++ b/test/rules/member-ordering/omit-access-modifier/test.ts.lint @@ -0,0 +1,12 @@ +class C { + private static x = 0; + static y = 1; + + x = 0; + private y = 1; + + constructor() {} + + static z = 2; + ~~~~~~~~~~~~~ [Declaration of static field not allowed after declaration of constructor. Instead, this should come at the beginning of the class/interface.] +} diff --git a/test/rules/member-ordering/omit-access-modifier/tslint.json b/test/rules/member-ordering/omit-access-modifier/tslint.json new file mode 100644 index 00000000000..c88314eb612 --- /dev/null +++ b/test/rules/member-ordering/omit-access-modifier/tslint.json @@ -0,0 +1,9 @@ +{ + "rules": { + "member-ordering": [true, { "order": [ + "static-field", + "instance-field", + "constructor" + ]}] + } +} diff --git a/test/rules/member-ordering/public-before-private/test.ts.fix b/test/rules/member-ordering/public-before-private/test.ts.fix new file mode 100644 index 00000000000..f714c2a6e33 --- /dev/null +++ b/test/rules/member-ordering/public-before-private/test.ts.fix @@ -0,0 +1,8 @@ +class Foo { + y: number; + private x: number; + private bar(): any { + var bla: { a: string } = {a: '1'}; + } +} + diff --git a/test/rules/member-ordering/public-before-private/test.ts.lint b/test/rules/member-ordering/public-before-private/test.ts.lint new file mode 100644 index 00000000000..c26be55d8ac --- /dev/null +++ b/test/rules/member-ordering/public-before-private/test.ts.lint @@ -0,0 +1,10 @@ +class Foo { + private x: number; + private bar(): any { + var bla: { a: string } = {a: '1'}; + } + y: number; + ~~~~~~~~~~ [0] +} + +[0]: Declaration of public member not allowed after declaration of private member. Instead, this should come at the beginning of the class/interface. diff --git a/test/rules/member-ordering/public-before-private/tslint.json b/test/rules/member-ordering/public-before-private/tslint.json new file mode 100644 index 00000000000..9b2be79af85 --- /dev/null +++ b/test/rules/member-ordering/public-before-private/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-ordering": [true, "public-before-private"] + } +} diff --git a/test/rules/member-ordering/static-before-instance/test.ts.fix b/test/rules/member-ordering/static-before-instance/test.ts.fix new file mode 100644 index 00000000000..05a93c60f2a --- /dev/null +++ b/test/rules/member-ordering/static-before-instance/test.ts.fix @@ -0,0 +1,8 @@ +class Foo { + static y: number; + x: number; + constructor() { + // nothing to do + } +} + diff --git a/test/rules/member-ordering/static-before-instance/test.ts.lint b/test/rules/member-ordering/static-before-instance/test.ts.lint new file mode 100644 index 00000000000..532440d9837 --- /dev/null +++ b/test/rules/member-ordering/static-before-instance/test.ts.lint @@ -0,0 +1,10 @@ +class Foo { + x: number; + static y: number; + ~~~~~~~~~~~~~~~~~ [0] + constructor() { + // nothing to do + } +} + +[0]: Declaration of static member not allowed after declaration of instance member. Instead, this should come at the beginning of the class/interface. diff --git a/test/rules/member-ordering/static-before-instance/tslint.json b/test/rules/member-ordering/static-before-instance/tslint.json new file mode 100644 index 00000000000..01c8d924d1e --- /dev/null +++ b/test/rules/member-ordering/static-before-instance/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-ordering": [true, "static-before-instance"] + } +} diff --git a/test/rules/member-ordering/statics-first/test.ts.fix b/test/rules/member-ordering/statics-first/test.ts.fix new file mode 100644 index 00000000000..36999db9354 --- /dev/null +++ b/test/rules/member-ordering/statics-first/test.ts.fix @@ -0,0 +1,37 @@ +class Good { + public static a = 1; + public static g() {} + protected static b = 2; + protected static h() {} + private static c = 3; + private static i = () => {}; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + j = () => {}; + protected k() {} + private l = () => {}; +} + +interface IGood { + foo: number; + arrowsAreFields: () => void; + nonArrowsAreMethods(): void; +} + +class Bad { + public static a = 1; + public static g() {} + protected static b = 2; + protected static h() {} + private static c = 3; + private static i = () => {}; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + j = () => {}; + protected k() {} + private l = () => {}; +} diff --git a/test/rules/member-ordering/statics-first/test.ts.lint b/test/rules/member-ordering/statics-first/test.ts.lint new file mode 100644 index 00000000000..a4d4ed2e1f5 --- /dev/null +++ b/test/rules/member-ordering/statics-first/test.ts.lint @@ -0,0 +1,41 @@ +class Good { + public static a = 1; + public static g() {} + protected static b = 2; + protected static h() {} + private static c = 3; + private static i = () => {}; + public d = 4; + protected e: number = 5; + private f = foo(); + constructor() {} + j = () => {}; + protected k() {} + private l = () => {}; +} + +interface IGood { + foo: number; + arrowsAreFields: () => void; + nonArrowsAreMethods(): void; +} + +class Bad { + public static a = 1; + private static c = 3; + public static g() {} + ~~~~~~~~~~~~~~~~~~~~ [Declaration of public static method not allowed after declaration of private static field. Instead, this should come after public static fields.] + protected static h() {} + ~~~~~~~~~~~~~~~~~~~~~~~ [Declaration of protected static method not allowed after declaration of private static field. Instead, this should come after protected static fields.] + private static i = () => {}; + public d = 4; + protected static b = 2; + ~~~~~~~~~~~~~~~~~~~~~~~ [Declaration of protected static field not allowed after declaration of public instance field. Instead, this should come after public static methods.] + protected e: number = 5; + constructor() {} + j = () => {}; + protected k() {} + private f = foo(); + ~~~~~~~~~~~~~~~~~~ [Declaration of private instance field not allowed after declaration of protected instance method. Instead, this should come after protected instance fields.] + private l = () => {}; +} diff --git a/test/rules/member-ordering/statics-first/tslint.json b/test/rules/member-ordering/statics-first/tslint.json new file mode 100644 index 00000000000..bf764615abc --- /dev/null +++ b/test/rules/member-ordering/statics-first/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-ordering": [true, { "order": "statics-first" }] + } +} diff --git a/test/rules/member-ordering/variables-before-functions/test.ts.fix b/test/rules/member-ordering/variables-before-functions/test.ts.fix new file mode 100644 index 00000000000..b1d89382406 --- /dev/null +++ b/test/rules/member-ordering/variables-before-functions/test.ts.fix @@ -0,0 +1,63 @@ +// ensure that Bar and Baz do not get conflated +interface Bar { + x(): void; +} + +interface Baz { + y: number; +} + +interface BarBaz { + y: number; + x(): void; +} + +class Foo { + y: number; + x(): void {} +} + +interface IArrowMethods { + a: number; + d: () => void; + b(): void; +} + +class ArrowMethods { + public a = 5; + private callback: () => void + public b = "foo"; + public c() {} + public d = () => {}; + public e = function() {}; +} + +class OutOfOrder { + b = 5; + a = () => {}; +} + +class Constructor1 { + blah: number = 0; + constructor() {} +} + +class Constructor2 { + blah: number = 0; + constructor() {} +} + +// Works for type literal, just like interface +type T = { + y: number; + x(): void; +} + +// Works for class inside object literal +const o = { + foo: class C { + y: number; + x(): void; + } +} + diff --git a/test/rules/member-ordering/variables-before-functions/test.ts.lint b/test/rules/member-ordering/variables-before-functions/test.ts.lint new file mode 100644 index 00000000000..e657b567d72 --- /dev/null +++ b/test/rules/member-ordering/variables-before-functions/test.ts.lint @@ -0,0 +1,71 @@ +// ensure that Bar and Baz do not get conflated +interface Bar { + x(): void; +} + +interface Baz { + y: number; +} + +interface BarBaz { + x(): void; + y: number; + ~~~~~~~~~~ [0] +} + +class Foo { + x(): void {} + y: number; + ~~~~~~~~~~ [0] +} + +interface IArrowMethods { + a: number; + b(): void; + d: () => void; + ~~~~~~~~~~~~~~ [0] +} + +class ArrowMethods { + public a = 5; + private callback: () => void + public b = "foo"; + public c() {} + public d = () => {}; + public e = function() {}; +} + +class OutOfOrder { + a = () => {}; + b = 5; + ~~~~~~ [0] +} + +class Constructor1 { + blah: number = 0; + constructor() {} +} + +class Constructor2 { + constructor() {} + blah: number = 0; + ~~~~~~~~~~~~~~~~~ [0] +} + +// Works for type literal, just like interface +type T = { + x(): void; + y: number; + ~~~~~~~~~~ [0] +} + +// Works for class inside object literal +const o = { + foo: class C { + x(): void; + y: number; + ~~~~~~~~~~ [0] + } +} + +[0]: Declaration of field not allowed after declaration of method. Instead, this should come at the beginning of the class/interface. diff --git a/test/rules/member-ordering/variables-before-functions/tslint.json b/test/rules/member-ordering/variables-before-functions/tslint.json new file mode 100644 index 00000000000..9be59dcd531 --- /dev/null +++ b/test/rules/member-ordering/variables-before-functions/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "member-ordering": [true, "variables-before-functions"] + } +} diff --git a/test/rules/new-parens/test.ts.lint b/test/rules/new-parens/test.ts.lint new file mode 100644 index 00000000000..733f48ed974 --- /dev/null +++ b/test/rules/new-parens/test.ts.lint @@ -0,0 +1,14 @@ +// correct case +var foo = new Date(); + +// incorrect case +var foge = new Date; + ~~~~~~~~ [0] +class Bar {} +var bar = new Bar; + ~~~~~~~ [0] +var fogefoge = new Bar(new Foo); + ~~~~~~~ [0] + +[0]: Parentheses are required when invoking a constructor + diff --git a/test/rules/new-parens/tslint.json b/test/rules/new-parens/tslint.json new file mode 100644 index 00000000000..7cd049d2253 --- /dev/null +++ b/test/rules/new-parens/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "new-parens": true + } +} diff --git a/test/rules/newline-before-return/default/test.ts.fix b/test/rules/newline-before-return/default/test.ts.fix new file mode 100644 index 00000000000..bfde13a5783 --- /dev/null +++ b/test/rules/newline-before-return/default/test.ts.fix @@ -0,0 +1,126 @@ +function foo(bar) { + if (!bar) { + return; + } + + return bar; +} + +function foo(bar) { + if (!bar) { + var statement = ''; + + return statement; + } + + return bar; +} + +function foo(bar) { + if (!bar) { + return; + } + + /* multi-line + comment */ + return bar; +} + +var fn = () => null; +function foo() { + fn(); + + return; +} + +function foo(fn) { + fn(); + + return; +} + +function foo(fn) { + fn(); + + return; +} + +function foo(fn) { + fn(); + + return; +} + +function foo() { + return; +} + +function foo() { + + return; +} + +function foo(bar) { + if (!bar) return; +} + +function foo(bar) { + let someCall; + if (!bar) return; +} + +function foo(bar) { + if (!bar) { return }; +} + +function foo(bar) { + if (!bar) { + return; + } +} + +function foo(bar) { + if (!bar) { + return; + } + + return bar; +} + +function foo(bar) { + if (!bar) { + + return; + } +} + +function foo() { + + // comment + return; +} + +function test() { + console.log("Any statement"); + // Any comment + + return; +} + +function foo() { + fn(); + // comment + + // comment + return; +} + +function bar() { + "some statement"; + + //comment + //comment + //comment + return; +} + diff --git a/test/rules/newline-before-return/default/test.ts.lint b/test/rules/newline-before-return/default/test.ts.lint new file mode 100644 index 00000000000..1ed6848f696 --- /dev/null +++ b/test/rules/newline-before-return/default/test.ts.lint @@ -0,0 +1,124 @@ +function foo(bar) { + if (!bar) { + return; + } + return bar; + ~nil [0] +} + +function foo(bar) { + if (!bar) { + var statement = ''; + return statement; + ~nil [0] + } + + return bar; +} + +function foo(bar) { + if (!bar) { + return; + } + /* multi-line + ~nil [0] + comment */ + return bar; +} + +var fn = () => null; +function foo() { + fn(); + return; + ~nil [0] +} + +function foo(fn) { + fn(); return; + ~nil [0] +} + +function foo(fn) { + fn(); return; + ~nil [0] +} + +function foo(fn) { + fn(); return; + ~nil [0] +} + +function foo() { + return; +} + +function foo() { + + return; +} + +function foo(bar) { + if (!bar) return; +} + +function foo(bar) { + let someCall; + if (!bar) return; +} + +function foo(bar) { + if (!bar) { return }; +} + +function foo(bar) { + if (!bar) { + return; + } +} + +function foo(bar) { + if (!bar) { + return; + } + + return bar; +} + +function foo(bar) { + if (!bar) { + + return; + } +} + +function foo() { + + // comment + return; +} + +function test() { + console.log("Any statement"); + // Any comment + + return; +} + +function foo() { + fn(); + // comment + + // comment + return; +} + +function bar() { + "some statement"; + //comment + ~nil [0] + //comment + //comment + return; +} + +[0]: Missing blank line before return diff --git a/test/rules/newline-before-return/default/test.tsx.fix b/test/rules/newline-before-return/default/test.tsx.fix new file mode 100644 index 00000000000..e6b34d9b171 --- /dev/null +++ b/test/rules/newline-before-return/default/test.tsx.fix @@ -0,0 +1,17 @@ +import * as React from 'react'; + +
{ [].map((child: any) => { + let i = 0; + + return ; +}) }
+ +
{ [].map((child: any) => { + return ; +}) }
+ +
{ [].map((child: any) => + ; +) }
+ + diff --git a/test/rules/newline-before-return/default/test.tsx.lint b/test/rules/newline-before-return/default/test.tsx.lint new file mode 100644 index 00000000000..ae18dcfb7d0 --- /dev/null +++ b/test/rules/newline-before-return/default/test.tsx.lint @@ -0,0 +1,18 @@ +import * as React from 'react'; + +
{ [].map((child: any) => { + let i = 0; + return ; + ~nil [0] +}) }
+ +
{ [].map((child: any) => { + return ; +}) }
+ +
{ [].map((child: any) => + ; +) }
+ + +[0]: Missing blank line before return diff --git a/test/rules/newline-before-return/default/tslint.json b/test/rules/newline-before-return/default/tslint.json new file mode 100644 index 00000000000..fdefd1ad13b --- /dev/null +++ b/test/rules/newline-before-return/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "newline-before-return": true + } +} diff --git a/test/rules/newline-per-chained-call/default/test.ts.lint b/test/rules/newline-per-chained-call/default/test.ts.lint new file mode 100644 index 00000000000..a00c7e99ea7 --- /dev/null +++ b/test/rules/newline-per-chained-call/default/test.ts.lint @@ -0,0 +1,120 @@ +this.getFoo()[0].toString(); + ~~~~~~~~~ [ERROR] + +this.foo()["bar"]().buzz(); + ~~~~~ [ERROR] + +this.foo()["bar"](); + +foo().bar(); + ~~~~ [ERROR] + +const y: string[] = _observable + .map(function(item) { return item.helloYay().another() } + ~~~~~~~~ [ERROR] + .operator() + .another(function(result) { return result.hello.Yay! }).wrong(); + ~~~~~~ [ERROR] + +SomeClass.propA.helloYay((a: number) => { + return a + 1; +}); + +this.some.nested(); + +const y: string[] = _observable + .map(function(item) { return item.helloYay! }) + .operator() + .another(function(result) { return result.hello.Yay! }); + + +const y: string[] = _observable.map(item => item.helloYay).operator().another(function(result) { return result.helloYay! }); + ~~~~~~~~ [ERROR] + ~~~~~~~~~ [ERROR] + +const x: string[] = _observable.map(item => item.helloYay); + +SomeClass.propA.propB.helloYay(); + +SomeClass + .propA + .propB + .helloYay(); + +SomeClass + .propA + .propB.helloYay(); + +SomeClass + .propA + .propB + .helloYay(function() { + return 1; + }).test(); + ~~~~~ [ERROR] + +SomeClass + .propA + .propB + .helloYay(function() { + return 1; + }). test(); + ~~~~~~~ [ERROR] + +SomeClass + .propA + .propB + .helloYay(function() { + return 1; + }). + ~ + test(); +~~~~~~~~ [ERROR] + +SomeClass.propA.propB.methodB(() => { + return "hello Yay!"; +}).helloYay((a: number) => { + ~~~~~~~~~ [ERROR] + return a + 1; +}); + +SomeClass.propA.propB.methodB(() => { + return "hello Yay!"; +}) +.helloYay((a: number) => { + return a + 1; +}); + +SomeClass.propA.propB.methodB(() => { + return "hello Yay!"; +}) +.helloYay((a: number) => { + return obj.method() + .chainedButOkay( + objB.nested().superNestedCall() + ~~~~~~~~~~~~~~~~ [ERROR] + ) +}); + +SomeClass.propA.propB.methodB(() => { + return "hello Yay!"; +}) +.helloYay((a: number) => { + return obj.method() + .chainedButOkay( + objB.nested() + .superNestedCall() + ) +}); + +SomeClass + .propA + .propB + .methodC(() => { + return "hello Yay!"; + }) + .helloYay(() => { + return 1; + }); + +[ERROR]: When chaining calls, put method calls on new lines. \ No newline at end of file diff --git a/test/rules/newline-per-chained-call/default/tslint.json b/test/rules/newline-per-chained-call/default/tslint.json new file mode 100644 index 00000000000..5501b8f65cf --- /dev/null +++ b/test/rules/newline-per-chained-call/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "newline-per-chained-call": true + } +} diff --git a/test/rules/no-angle-bracket-type-assertion/test.ts.fix b/test/rules/no-angle-bracket-type-assertion/test.ts.fix new file mode 100644 index 00000000000..292b90da4fa --- /dev/null +++ b/test/rules/no-angle-bracket-type-assertion/test.ts.fix @@ -0,0 +1,52 @@ +var a = 5 as any; + +var b = 5 as any as number; + +var c = (5 as any) as number; + +var d = 5 as any as number; + +var e = 5 as any as number; + +let f = (flag as any as number) & value; +f = (flag as any as number) | value; + +let g = a as any as A; + +let h = a as any as AsyncIterableIterator; + +interface Action { + payload: number | false; +} + +const action: Action = { + payload: 5, +} + +const booleanAction: Action = { + payload: false, +} + +const a = 5 + (action.payload as number); + +const a = 5 - (action.payload as number); + +const a = 5 * (action.payload as number); + +const a = 5 / (action.payload as number); + +const a = 5 % (action.payload as number); + +const a = 5 && (action.payload as number); + +const a = 5 || (action.payload as number); + +const a = 5 % (action.payload as any as number); + +const a = 5 && (action.payload as any as number); + +const a = 5 || (action.payload as any as number); + +const a = true || (booleanAction.payload as boolean); + +const a = false && (booleanAction.payload as boolean); diff --git a/test/rules/no-angle-bracket-type-assertion/test.ts.lint b/test/rules/no-angle-bracket-type-assertion/test.ts.lint new file mode 100644 index 00000000000..b45672e67e5 --- /dev/null +++ b/test/rules/no-angle-bracket-type-assertion/test.ts.lint @@ -0,0 +1,73 @@ +var a = 5; + ~~~~~~ [0] + +var b = 5; + ~~~~~~~~~~~~~~ [0] + +var c = (5 as any); + ~~~~~~~~~~~~~~~~~~ [0] + +var d = 5 as number; + ~~~~~~~ [0] + +var e = 5 as any as number; + +let f = flag & value; + ~~~~~~~~~~~~~~~~~ [0] +f = flag | value; + ~~~~~~~~~~~~~~~~~ [0] + +let g = a; + ~~~~~~~~~ [0] + +let h = a; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +interface Action { + payload: number | false; +} + +const action: Action = { + payload: 5, +} + +const booleanAction: Action = { + payload: false, +} + +const a = 5 + action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 - action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 * action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 / action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 % action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 && action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 || action.payload; + ~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 % action.payload; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 && action.payload; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = 5 || action.payload; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = true || booleanAction.payload; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const a = false && booleanAction.payload; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +[0]: Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead. diff --git a/test/rules/no-angle-bracket-type-assertion/tslint.json b/test/rules/no-angle-bracket-type-assertion/tslint.json new file mode 100644 index 00000000000..a067500fe8b --- /dev/null +++ b/test/rules/no-angle-bracket-type-assertion/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-angle-bracket-type-assertion": true + } +} diff --git a/test/rules/no-any/default/test.ts.lint b/test/rules/no-any/default/test.ts.lint new file mode 100644 index 00000000000..66200e514a1 --- /dev/null +++ b/test/rules/no-any/default/test.ts.lint @@ -0,0 +1,34 @@ +var x: any; // error + ~~~ [0] + +function foo(a: any) : any { // 2 errors + ~~~ [0] + ~~~ [0] + return; +} + +const fooArrow(a: any[]) => { + ~~~ [0] + return; +} + +function bar(...a: any[]) { + ~~~ [0] + return; +} + +const barArrow = (...a: any[]): any => { + ~~~ [0] + ~~~ [0] + return; +} + +let a: any = 2, // error + ~~~ [0] + b: any[] = 4; // error + ~~~ [0] + +let {a: c, b: d}: {c: any, d: number} = {c: 99, d: 100}; // error + ~~~ [0] + +[0]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type. diff --git a/test/rules/no-any/default/tslint.json b/test/rules/no-any/default/tslint.json new file mode 100644 index 00000000000..2876d288c08 --- /dev/null +++ b/test/rules/no-any/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-any": true + } +} diff --git a/test/rules/no-any/ignore-rest-args/test.ts.lint b/test/rules/no-any/ignore-rest-args/test.ts.lint new file mode 100644 index 00000000000..9cf2ae897f1 --- /dev/null +++ b/test/rules/no-any/ignore-rest-args/test.ts.lint @@ -0,0 +1,38 @@ +var x: any; // error + ~~~ [0] + +function foo(a: any) : any { // 2 errors + ~~~ [0] + ~~~ [0] + return; +} + +const fooArrow(a: any[]) => { + ~~~ [0] + return; +} + +function bar(...a: any[]) { + return; +} + +const barArrow = (...a: any[]): any => { + ~~~ [0] + return; +} + +const function(...a: { [key: any]: any }[]) { + ~~~ [0] + ~~~ [0] + return; +} + +let a: any = 2, // error + ~~~ [0] + b: any[] = 4; // error + ~~~ [0] + +let {a: c, b: d}: {c: any, d: number} = {c: 99, d: 100}; // error + ~~~ [0] + +[0]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type. diff --git a/test/rules/no-any/ignore-rest-args/tslint.json b/test/rules/no-any/ignore-rest-args/tslint.json new file mode 100644 index 00000000000..8ec5fb037c2 --- /dev/null +++ b/test/rules/no-any/ignore-rest-args/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-any": [true, { "ignore-rest-args": true }] + } +} diff --git a/test/rules/no-arg/test.ts.lint b/test/rules/no-arg/test.ts.lint new file mode 100644 index 00000000000..d8e2193dcde --- /dev/null +++ b/test/rules/no-arg/test.ts.lint @@ -0,0 +1,12 @@ +var testVariable = 123; + +function testFunction(): number { + if(arguments.callee.caller === testFunction) { + ~~~~~~~~~~~~~~~~ [Access to arguments.callee is forbidden] + console.log("called"); + } + + argument.callee = testFunction; + + return testVariable; +} diff --git a/test/rules/no-arg/tslint.json b/test/rules/no-arg/tslint.json new file mode 100644 index 00000000000..139d0955e11 --- /dev/null +++ b/test/rules/no-arg/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-arg": true + } +} diff --git a/test/rules/no-async-without-await/test.ts.lint b/test/rules/no-async-without-await/test.ts.lint new file mode 100644 index 00000000000..cda2178d5f5 --- /dev/null +++ b/test/rules/no-async-without-await/test.ts.lint @@ -0,0 +1,165 @@ +async function a(){ +~~~~~ [FAILURE_STRING] + let b = 1; + console.log(b); +} + +async function a(){ + let b = 1; + await console.log(b); +} + +async function a(){ + let b = 1; + console.log(await b()); +} + +async function a(){ +~~~~~ [FAILURE_STRING] + let b = 1; + let c = async () => { + await fetch(); + }; +} + +async function a(){ +~~~~~ [FAILURE_STRING] + let b = 1; + async function f() { + await fetch(); + }; +} + +function a(){ + let b = 1; + async function f() { + ~~~~~ [FAILURE_STRING] + fetch(); + }; +} + +const a = async () => { + ~~~~~ [FAILURE_STRING] + let b = 1; + console.log(b); +} + +class A { + async b() { + ~~~~~ [FAILURE_STRING] + console.log(1); + } +} + +class A { + async b() { + await b(); + } +} + +class A { + public a = async function b() { + await b(); + } + } + +class A { + public a = async function b() { + ~~~~~ [FAILURE_STRING] + b(); + } + } + +class A { + public a = async () => { + await b(); + } + } + +class A { + public a = async () => { + ~~~~~ [FAILURE_STRING] + b(); + } + } + +class A { + public a = async () => 1; + } + +async () => { + await a(); + class A { + async b() { + ~~~~~ [FAILURE_STRING] + console.log(1); + } + } +}; + +async function a() { + let b = 1; + return b; +} + +let a = async () => 1; + +async function a() { +~~~~~ [FAILURE_STRING] + let b = 1; + let a = () => { + return 1; + } +} + +async function foo; +~~~~~ [FAILURE_STRING] + +function * foo() { + return 1; +} + +abstract class A { + public async func() { + ~~~~~ [FAILURE_STRING] + b(); + } +} + +abstract class A { + public abstract func(): void; +} + +abstract class A { + public async func() { /* */ } + ~~~~~ [FAILURE_STRING] +} + +abstract class A { + public async func(): Promise { /* */ } + ~~~~~ [FAILURE_STRING] +} + +abstract class A { + public const test: Promise +} + +abstract class A { + public abstract async func(param: T): Promise; +} + +export async function f(i: number): Promise; +export async function f(s1: string, s2: string): Promise; +export async function f(...args: unknown[]): Promise { + return Promise.resolve(); +} + +export class A { + public async f(i: number): Promise; + public async f(s1: string, s2: string): Promise; + public async f(..._args: unknown[]): Promise { + return Promise.resolve(); + } +} + +[FAILURE_STRING]: Functions marked async must contain an await or return statement. diff --git a/test/rules/no-async-without-await/tslint.json b/test/rules/no-async-without-await/tslint.json new file mode 100644 index 00000000000..140ce628454 --- /dev/null +++ b/test/rules/no-async-without-await/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-async-without-await": true + } +} diff --git a/test/rules/no-bitwise/test.ts.lint b/test/rules/no-bitwise/test.ts.lint new file mode 100644 index 00000000000..f16f3bcc8b2 --- /dev/null +++ b/test/rules/no-bitwise/test.ts.lint @@ -0,0 +1,6 @@ +var z = (x || 3) && (y || 4); +var yy = x | 3; + ~~~~~ [Forbidden bitwise operation] +var zz = (z || y) & (x | y); + ~~~~~~~~~~~~~~~~~~ [Forbidden bitwise operation] + ~~~~~ [Forbidden bitwise operation] diff --git a/test/rules/no-bitwise/tslint.json b/test/rules/no-bitwise/tslint.json new file mode 100644 index 00000000000..9dfce74f345 --- /dev/null +++ b/test/rules/no-bitwise/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-bitwise": true + } +} diff --git a/test/rules/no-boolean-literal-compare/test.ts.fix b/test/rules/no-boolean-literal-compare/test.ts.fix new file mode 100644 index 00000000000..30bb48dc97e --- /dev/null +++ b/test/rules/no-boolean-literal-compare/test.ts.fix @@ -0,0 +1,30 @@ +declare const x: boolean; + +x; +x; + +!x; +!x; + +!x; +!x; + +x; +x; + +x; + +declare const y: boolean | undefined; +y === true; + +declare function f(): boolean; +!f(); + +declare const a: number, b: number; + +!(a as any as boolean); + +!(a < b); + +!!x; + diff --git a/test/rules/no-boolean-literal-compare/test.ts.lint b/test/rules/no-boolean-literal-compare/test.ts.lint new file mode 100644 index 00000000000..9e54c2c6e92 --- /dev/null +++ b/test/rules/no-boolean-literal-compare/test.ts.lint @@ -0,0 +1,45 @@ +declare const x: boolean; + +x === true; +~ [T] +true === x; + ~ [T] + +x === false; +~ [F] +false === x; + ~ [F] + +x !== true; +~ [F] +true !== x; + ~ [F] + +x !== false; +~ [T] +false !== x; + ~ [T] + +x == true; +~ [T] + +declare const y: boolean | undefined; +y === true; + +declare function f(): boolean; +f() === false; +~~~ [F] + +declare const a: number, b: number; + +a as any as boolean === false; +~~~~~~~~~~~~~~~~~~~ [F] + +a < b === false; +~~~~~ [F] + +!x === false; +~~ [F] + +[T]: This expression is unnecessarily compared to a boolean. Just use it directly. +[F]: This expression is unnecessarily compared to a boolean. Just negate it. diff --git a/test/rules/no-boolean-literal-compare/tsconfig.json b/test/rules/no-boolean-literal-compare/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/no-boolean-literal-compare/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/no-boolean-literal-compare/tslint.json b/test/rules/no-boolean-literal-compare/tslint.json new file mode 100644 index 00000000000..ad257794e15 --- /dev/null +++ b/test/rules/no-boolean-literal-compare/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-boolean-literal-compare": true + } +} \ No newline at end of file diff --git a/test/rules/no-conditional-assignment/test.ts.lint b/test/rules/no-conditional-assignment/test.ts.lint new file mode 100644 index 00000000000..e43cb87702e --- /dev/null +++ b/test/rules/no-conditional-assignment/test.ts.lint @@ -0,0 +1,79 @@ +// valid cases +if (x == 5) { } +if (x === 5) { } +else if (y <= 23) { } +else if ((z && a) == 7) { } +else { } + +do { } while (x == 2); +do { } while (x !== 2); + +while (x == 2) { } +while (x !== 2) { } + +for (var x = 8; x == 8; ++x) { } +for (var x = 8; x == 8; x = 12) { } +for (;;) { } + +while (a ? b : c) {} +while (--i) {} +while ((a = b)++) {} // don't bother, it's a compile error anyway + +while ((a || (a = b)).foo) {} +while (a[b = c]) {} +while ((() => a = b)()) {} +while (fn(a = b)) {} +a ? b = a : a = b; + +// invalid cases +if (x = 5) { } + ~~~~~ [0] +if (a && (b = 5)) { } + ~~~~~ [0] +else if (x = 2) { } + ~~~~~ [0] + +do { } while (x = 4); + ~~~~~ [0] + +while (x = 4); + ~~~~~ [0] +while ((x = y - 12)); + ~~~~~~~~~~ [0] + +for (var x = 4; x = 8; x++) { } + ~~~~~ [0] +for (; (y == 2) && (x = 3); ) { } + ~~~~~ [0] + +if (x += 2) { } + ~~~~~~ [0] +else if (h || (x <<= 4)) { } + ~~~~~~~ [0] + +do { } while (x ^= 4) { } + ~~~~~~ [0] +while ((a = 5) && ((b == 4) || (c = 3))) {} + ~~~~~ [0] + ~~~~~ [0] +while (+(a = b) || -(b = c)) {} + ~~~~~ [0] + ~~~~~ [0] +while (foo() || (a = (b = c)!)) {} + ~~~~~~~~~~~~ [0] + ~~~~~ [0] +while (a == (b = fn()) as any) {} + ~~~~~~~~ [0] +while (a ? b = a : a = b) {} + ~~~~~ [0] + ~~~~~ [0] +while (!((a = b) ? c : d) || (x = y)) {} + ~~~~~ [0] + ~~~~~ [0] +(a = b) ? c : d; + ~~~~~ [0] +(foo ? a = b : b = a) ? c : d; + ~~~~~ [0] + ~~~~~ [0] + +[0]: Assignments in conditional expressions are forbidden diff --git a/test/rules/no-conditional-assignment/tslint.json b/test/rules/no-conditional-assignment/tslint.json new file mode 100644 index 00000000000..014f7127c44 --- /dev/null +++ b/test/rules/no-conditional-assignment/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-conditional-assignment": true + } +} diff --git a/test/rules/no-consecutive-blank-lines/default/test.ts.fix b/test/rules/no-consecutive-blank-lines/default/test.ts.fix new file mode 100644 index 00000000000..119e8e98967 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/default/test.ts.fix @@ -0,0 +1,27 @@ +// the markup for this test is a little bit weird +// tslint, for the first error below, says it goes from +// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) + +class Clazz { // comment + + public funcxion() { + + // also comment + + console.log("test"); + + } + +} + +//Begin whitespace +// The next two lines of "code" contain only tabs or spaces, they are also considered "blank" lines + +let foo = ` + + +`; + +let bar = `${bar + +}`; diff --git a/test/rules/no-consecutive-blank-lines/default/test.ts.lint b/test/rules/no-consecutive-blank-lines/default/test.ts.lint new file mode 100644 index 00000000000..9577de1bef6 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/default/test.ts.lint @@ -0,0 +1,42 @@ +// the markup for this test is a little bit weird +// tslint, for the first error below, says it goes from +// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) + + +~nil +class Clazz { // comment +~nil [Consecutive blank lines are forbidden] + + public funcxion() { + + // also comment + + +~nil + console.log("test"); +~nil [Consecutive blank lines are forbidden] + + } + + +~nil +} +~nil [Consecutive blank lines are forbidden] + +//Begin whitespace +// The next two lines of "code" contain only tabs or spaces, they are also considered "blank" lines + + +~ [Consecutive blank lines are forbidden] + + +let foo = ` + + +`; + +let bar = `${bar + + +~ [Consecutive blank lines are forbidden] +}`; diff --git a/test/rules/no-consecutive-blank-lines/default/tslint.json b/test/rules/no-consecutive-blank-lines/default/tslint.json new file mode 100644 index 00000000000..3aa56ee6643 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-consecutive-blank-lines": true + } +} diff --git a/test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint b/test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint new file mode 100644 index 00000000000..6bc6eb7fc90 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/invalid-option/test.ts.lint @@ -0,0 +1,30 @@ +// This rule will always pass since the arguments value in tslint.json is a string, +// while it should be a valid integer and > 1. +// In such a case, the rule is not enabled. + +class Clazz { // comment + + public funcxion() { + + + // also comment + + + + // still allowed since 2 lines only + + + + + + // this one won't be allowed anymore + + console.log("test"); + + } + + +} + + + diff --git a/test/rules/no-consecutive-blank-lines/invalid-option/tslint.json b/test/rules/no-consecutive-blank-lines/invalid-option/tslint.json new file mode 100644 index 00000000000..11f06b692b3 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/invalid-option/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-consecutive-blank-lines": [true, "three"] + } +} diff --git a/test/rules/no-consecutive-blank-lines/multiple/test.ts.fix b/test/rules/no-consecutive-blank-lines/multiple/test.ts.fix new file mode 100644 index 00000000000..c1ba96dee2e --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/multiple/test.ts.fix @@ -0,0 +1,28 @@ +// the markup for this test is a little bit weird +// tslint, for the first error below, says it goes from +// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) + +class Clazz { // comment + + + public funcxion() { + + // also comment + + + // still allowed since 2 lines only + + + // this one won't be allowed anymore + + console.log("test"); + + } + + +} + +//Begin whitespace +// The next lines contain only tabs or spaces, they are also considered "blank" lines + + \ No newline at end of file diff --git a/test/rules/no-consecutive-blank-lines/multiple/test.ts.lint b/test/rules/no-consecutive-blank-lines/multiple/test.ts.lint new file mode 100644 index 00000000000..5f05126c895 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/multiple/test.ts.lint @@ -0,0 +1,40 @@ +// the markup for this test is a little bit weird +// tslint, for the first error below, says it goes from +// [5, 1] to [6, 1], and thus the markup appears to be off (but it's not) + +class Clazz { // comment + + + +~nil + +~nil [Exceeds the 2 allowed consecutive blank lines] + public funcxion() { + + // also comment + + + // still allowed since 2 lines only + + + +~nil + +~nil [Exceeds the 2 allowed consecutive blank lines] + + // this one won't be allowed anymore + + console.log("test"); + + } + + +} + +//Begin whitespace +// The next lines contain only tabs or spaces, they are also considered "blank" lines + + + +~ [Exceeds the 2 allowed consecutive blank lines] + diff --git a/test/rules/no-consecutive-blank-lines/multiple/tslint.json b/test/rules/no-consecutive-blank-lines/multiple/tslint.json new file mode 100644 index 00000000000..b9a168a7960 --- /dev/null +++ b/test/rules/no-consecutive-blank-lines/multiple/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-consecutive-blank-lines": [true, 2] + } +} diff --git a/test/rules/no-console/all/test.ts.lint b/test/rules/no-console/all/test.ts.lint new file mode 100644 index 00000000000..45cd25785a6 --- /dev/null +++ b/test/rules/no-console/all/test.ts.lint @@ -0,0 +1,22 @@ +console.time(); +~~~~~~~~~~~~ [err % ('time')] +console.log("log"); +~~~~~~~~~~~ [err % ('log')] +console.dir(object); +~~~~~~~~~~~ [err % ('dir')] +console.info("info"); +~~~~~~~~~~~~ [err % ('info')] +console.trace("trace"); +~~~~~~~~~~~~~ [err % ('trace')] +console.warn("warn"); +~~~~~~~~~~~~ [err % ('warn')] +console.error("error"); +~~~~~~~~~~~~~ [err % ('error')] +console.something(); +~~~~~~~~~~~~~~~~~ [err % ('something')] +console.timeEnd(); +~~~~~~~~~~~~~~~ [err % ('timeEnd')] +[].forEach(console.log); + ~~~~~~~~~~~ [err % ('log')] + +[err]: Calls to 'console.%s' are not allowed. diff --git a/test/rules/no-console/all/tslint.json b/test/rules/no-console/all/tslint.json new file mode 100644 index 00000000000..a4bede1138e --- /dev/null +++ b/test/rules/no-console/all/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-console": true + } +} diff --git a/test/rules/no-console/list/test.ts.lint b/test/rules/no-console/list/test.ts.lint new file mode 100644 index 00000000000..2ee294b7d6b --- /dev/null +++ b/test/rules/no-console/list/test.ts.lint @@ -0,0 +1,13 @@ +console.time(); +console.log("log"); +~~~~~~~~~~~ [Calls to 'console.log' are not allowed.] +console.dir(object); +~~~~~~~~~~~ [Calls to 'console.dir' are not allowed.] +console.info("info"); +console.trace("trace"); +console.warn("warn"); +~~~~~~~~~~~~ [Calls to 'console.warn' are not allowed.] +console.error("error"); +~~~~~~~~~~~~~ [Calls to 'console.error' are not allowed.] +console.something(); +console.timeEnd(); diff --git a/test/rules/no-console/list/tslint.json b/test/rules/no-console/list/tslint.json new file mode 100644 index 00000000000..08a0d1815f8 --- /dev/null +++ b/test/rules/no-console/list/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-console": [true, "dir", "error", "log", "warn"] + } +} diff --git a/test/rules/no-construct/test.ts.lint b/test/rules/no-construct/test.ts.lint new file mode 100644 index 00000000000..b11a12570b8 --- /dev/null +++ b/test/rules/no-construct/test.ts.lint @@ -0,0 +1,13 @@ +var s1 = "s"; +var s2 = new String("s"); + ~~~~~~~~~~ [0] + +var n1 = 1; +var n2 = new Number(1); + ~~~~~~~~~~~~~ [0] + +var b1 = true; +var b2 = new Boolean (true); + ~~~~~~~~~~~ [0] + +[0]: Forbidden constructor, use a literal or simple function call instead diff --git a/test/rules/no-construct/tslint.json b/test/rules/no-construct/tslint.json new file mode 100644 index 00000000000..9d1db2e04c1 --- /dev/null +++ b/test/rules/no-construct/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-construct": true + } +} diff --git a/test/rules/no-debugger/test.ts.lint b/test/rules/no-debugger/test.ts.lint new file mode 100644 index 00000000000..de25e88e833 --- /dev/null +++ b/test/rules/no-debugger/test.ts.lint @@ -0,0 +1,8 @@ +var testVariable = "debugger"; + +function testFunction(): number { + if (testVariable === "debugger") { + debugger; + ~~~~~~~~~ [Use of debugger statements is forbidden] + } +} diff --git a/test/rules/no-debugger/tslint.json b/test/rules/no-debugger/tslint.json new file mode 100644 index 00000000000..53e3193c563 --- /dev/null +++ b/test/rules/no-debugger/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-debugger": true + } +} diff --git a/test/rules/no-default-export/test.ts.lint b/test/rules/no-default-export/test.ts.lint new file mode 100644 index 00000000000..e50cfe2816d --- /dev/null +++ b/test/rules/no-default-export/test.ts.lint @@ -0,0 +1,46 @@ +switch (value) { + case 1: break; + default: break; +} + +export { SingleItem }; + +export { FirstItem, SecondItem }; + +export { Item as aliasForItem }; + +export { ItemFromImport } from 'module'; + +export * from './relativeModule'; + +export namespace SomeNamespace { } + +export import ItemAlias = someNamespace.Item; + +export const default = 'VALID'; + +export = 'VALID'; + +export default 'INVALID'; + ~~~~~~~ [0] + +export default { } + ~~~~~~~ [0] + +export default class { } + ~~~~~~~ [0] + +export default class Test { } + ~~~~~~~ [0] + +export default abstract class { } + ~~~~~~~ [0] + +export default function() { } + ~~~~~~~ [0] + +export default function Test() { } + ~~~~~~~ [0] + +[0]: Use of default exports is forbidden + diff --git a/test/rules/no-default-export/tslint.json b/test/rules/no-default-export/tslint.json new file mode 100644 index 00000000000..ebed5e9e331 --- /dev/null +++ b/test/rules/no-default-export/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-default-export": true + } +} diff --git a/test/rules/no-default-import/default/test.ts.lint b/test/rules/no-default-import/default/test.ts.lint new file mode 100644 index 00000000000..399593ed9f6 --- /dev/null +++ b/test/rules/no-default-import/default/test.ts.lint @@ -0,0 +1,36 @@ +import * as Utils from "tslint-utils" + +import TslintUtils from "tslint-utils" + +import Bar, { Foo } from "tslint-misc" + +import Bar, * as Foo from "tslint-misc" + +import { default as Foo } from "tslint-misc" + +import { default as foo, bar } from "tslint-misc" + +import { bar, default as foo } from "tslint-misc" + +import TslintUtils from "../tslint-utils" + ~~~~~~~~~~~ [0] + +import TslintUtils from "./tslint-utils" + ~~~~~~~~~~~ [0] + +import Bar, { Foo } from "../tslint-misc" + ~~~ [0] + +import Bar, * as Foo from "./tslint-misc" + ~~~ [0] + +import { default as Foo } from "../tslint-misc" + ~~~~~~~ [0] + +import { default as foo, bar } from "./tslint-misc" + ~~~~~~~ [0] + +import { bar, default as foo } from "../tslint-misc" + ~~~~~~~ [0] + +[0]: Import of default members from this module is forbidden. Import named member instead diff --git a/test/rules/no-default-import/default/tslint.json b/test/rules/no-default-import/default/tslint.json new file mode 100644 index 00000000000..63855417715 --- /dev/null +++ b/test/rules/no-default-import/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-default-import": true + } +} diff --git a/test/rules/no-default-import/fromModules/test.ts.lint b/test/rules/no-default-import/fromModules/test.ts.lint new file mode 100644 index 00000000000..2b789830c6e --- /dev/null +++ b/test/rules/no-default-import/fromModules/test.ts.lint @@ -0,0 +1,24 @@ +import * as Utils from "tslint-utils" + +import TslintUtils from "../tslint-utils" + ~~~~~~~~~~~ [0] + +import TslintUtils from "tslint-utils" + ~~~~~~~~~~~ [0] + +import Bar, { Foo } from "tslint-misc" + ~~~ [0] + +import Bar, * as Foo from "tslint-misc" + ~~~ [0] + +import { default as Foo } from "tslint-misc" + ~~~~~~~ [0] + +import { default as foo, bar } from "tslint-misc" + ~~~~~~~ [0] + +import { bar, default as foo } from "tslint-misc" + ~~~~~~~ [0] + +[0]: Import of default members from this module is forbidden. Import named member instead diff --git a/test/rules/no-default-import/fromModules/tslint.json b/test/rules/no-default-import/fromModules/tslint.json new file mode 100644 index 00000000000..1d9bf38d79d --- /dev/null +++ b/test/rules/no-default-import/fromModules/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "no-default-import": [ + true, + { + "fromModules": "^tslint-|^\\./|^\\.\\./" + } + ] + } +} diff --git a/test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint b/test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint new file mode 100644 index 00000000000..89d54bb9eb8 --- /dev/null +++ b/test/rules/no-duplicate-imports/allow-namespace-imports/test.d.ts.lint @@ -0,0 +1,6 @@ +import * as fs from 'fs'; +declare module "foo" { + import {readFile} from 'fs'; +} + +declare module "*"; diff --git a/test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint b/test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint new file mode 100644 index 00000000000..7bf56979661 --- /dev/null +++ b/test/rules/no-duplicate-imports/allow-namespace-imports/test.ts.lint @@ -0,0 +1,14 @@ +import * as fs from 'fs'; +import {readFile} from 'fs'; +import {readFileSync} from 'fs'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'fs' can be combined into one.] + +import * as fs from 'fs'; +~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple wildcard imports from the same module, 'fs', are prohibited.] + +import * as path from 'path'; +import {resolve} from 'path'; + +import {Socket} from 'net' +import {Server} from 'net'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'net' can be combined into one.] diff --git a/test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json b/test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json new file mode 100644 index 00000000000..ca35db49814 --- /dev/null +++ b/test/rules/no-duplicate-imports/allow-namespace-imports/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "no-duplicate-imports": { + "severity": "error", + "options": { + "allow-namespace-imports": true + } + } + } +} diff --git a/test/rules/no-duplicate-imports/default/test.d.ts.lint b/test/rules/no-duplicate-imports/default/test.d.ts.lint new file mode 100644 index 00000000000..5c5b614baa9 --- /dev/null +++ b/test/rules/no-duplicate-imports/default/test.d.ts.lint @@ -0,0 +1,7 @@ +import * as fs from 'fs'; +declare module "foo" { + import {readFile} from 'fs'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'fs' can be combined into one.] +} + +declare module "*"; diff --git a/test/rules/no-duplicate-imports/default/test.ts.lint b/test/rules/no-duplicate-imports/default/test.ts.lint new file mode 100644 index 00000000000..7a5c5def8de --- /dev/null +++ b/test/rules/no-duplicate-imports/default/test.ts.lint @@ -0,0 +1,20 @@ +import * as fs from 'fs'; +import {readFile} from 'fs'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('fs')] + +import * as path from 'path'; + +import {writeFileSync as wfs} from 'fs'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('fs')] + +import {parse} from 'url'; +import {format} from 'url'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('url')] + +import foo from './foo'; +import {bar} from './foo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('./foo')] + +import {writeFile} from './fs'; + +[err]: Multiple imports from '%s' can be combined into one. diff --git a/test/rules/no-duplicate-imports/default/test2.d.ts.lint b/test/rules/no-duplicate-imports/default/test2.d.ts.lint new file mode 100644 index 00000000000..00ce946e7d1 --- /dev/null +++ b/test/rules/no-duplicate-imports/default/test2.d.ts.lint @@ -0,0 +1,8 @@ +declare module 'a' { + import foo from 'foo'; +} + +declare module 'b' { + // No error -- this is a separate ambient module declaration. + import foo from 'foo'; +} diff --git a/test/rules/no-duplicate-imports/default/test3.d.ts.lint b/test/rules/no-duplicate-imports/default/test3.d.ts.lint new file mode 100644 index 00000000000..bd64667a22f --- /dev/null +++ b/test/rules/no-duplicate-imports/default/test3.d.ts.lint @@ -0,0 +1,11 @@ +export {}; + +declare module 'a' { + import foo from 'foo'; +} + +declare module 'b' { + // Error because these imports could be combined in an outer scope. + import foo from 'foo'; + ~~~~~~~~~~~~~~~~~~~~~~ [Multiple imports from 'foo' can be combined into one.] +} diff --git a/test/rules/no-duplicate-imports/default/tslint.json b/test/rules/no-duplicate-imports/default/tslint.json new file mode 100644 index 00000000000..27886316114 --- /dev/null +++ b/test/rules/no-duplicate-imports/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-duplicate-imports": true + } +} diff --git a/test/rules/no-duplicate-super/test.ts.lint b/test/rules/no-duplicate-super/test.ts.lint new file mode 100644 index 00000000000..052d90c45eb --- /dev/null +++ b/test/rules/no-duplicate-super/test.ts.lint @@ -0,0 +1,280 @@ +declare const b: boolean; +declare const b2: boolean; +declare const n: number; + +// Simple +{ + class A { + constructor() { + super(); + ~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~ [0] + } + } + + class B { + constructor() { + super(); + super.foo(); + } + } + + class C1 { + constructor() { + super(); + + class C2 { + constructor() { + super(); + } + } + } + } + + class D { + constructor() { + super(super()); + ~~~~~~~~~~~~~ [0] + } + } +} + +// If/else +{ + class A { + constructor() { + if (b) { + super(); + return; + } + super(); + } + } + + class B { + constructor() { + if (b) { + super(); + } else { + super(); + } + } + } + + class C { + constructor() { + if (b) { + super(); + return; + } else if (b2) { + super(); + ~~~~~~~~ + } +~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~ [0] + } + } + + class D { + constructor() { + if (b) { + super(); + return; + } else if (b) { + super(); + return; + } + super(); + } + } +} + +// Loop +{ + class A { + constructor() { + while (b) { + if (b) { + super(); + break; + } + } + } + } + + class B { + constructor() { + while (b) { + if (b) { + super(); + break; + } + if (b2) { + super(); + break; + } + super(); + break; + } + } + } + + class C { + constructor() { + while (b) { + if (b) { + super(); + return; + } else { + super(); + return; + } + } + super(); + } + } + + class D { + constructor() { + while (b) { + if (b) { + super(); + return; + } else { + super(); + ~~~~~~~ + break; +~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~~~~~~~~~~~~~ + } +~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~ [0] + } + } + + class E { + constructor() { + while (b) { + if (b) { + super(); + ~~~~~~~ + break; +~~~~~~~~~~~~~~~~~~~~~~~~~~ + } else { +~~~~~~~~~~~~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return; +~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~~~~~~~~~~~~~ + } +~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~ [0] + } + } +} + +// Switch +{ + class A { + constructor() { + switch (n) { + case 0: + super(); + ~~~~~~~~ + case 1: +~~~~~~~~~~~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + } + } + } + + class B { + constructor() { + switch (n) { + case 0: + super(); + break; + case 1: + super(); + break; + } + } + } + + class C { + constructor() { + switch (n) { + case 0: + super(); + break; + case 1: + super(); + ~~~~~~~~ + break; +~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~~~~ [0] + } + } +} + +// Wierd +{ + class A { + constructor() { + if (b) { + super(); + { + return; + } + } + super(); + } + } + + class B { + constructor() { + switch (n) { + case 0: + if (b) { + super(); + return; + } else { + super(); + if (b2) return; else return; + } + } + super(); + } + } +} + +// With ternary operator +{ + class A { + constructor(props?: any) { + props ? super(props) : super(); + } + } + + class B { + constructor(props?: any) { + props ? super(props) : super() ? super() : super(); + ~~~~~~~~~~~~~~~~~ [0] + } + } +} + + +[0]: Multiple calls to 'super()' found. It must be called only once. +[1]: 'super()' called in a loop. It must be called only once. diff --git a/test/rules/no-duplicate-super/tslint.json b/test/rules/no-duplicate-super/tslint.json new file mode 100644 index 00000000000..715471b08e5 --- /dev/null +++ b/test/rules/no-duplicate-super/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-duplicate-super": true + } +} diff --git a/test/rules/no-duplicate-switch-case/test.ts.lint b/test/rules/no-duplicate-switch-case/test.ts.lint new file mode 100644 index 00000000000..ecfd4a1914d --- /dev/null +++ b/test/rules/no-duplicate-switch-case/test.ts.lint @@ -0,0 +1,82 @@ +const withNumber = (value: number) => { + switch (value): + case 0: + break; + + case 1: + break; + + case 0: + ~ [error % ("0")] + case 1: { + ~ [error % ("1")] + break; + } +}; + +class WithString { + constructor(param: string) { + switch (param) { + case "aaa": + break; + + case "bbb": + case "ccc": + break; + + case "bbb": + ~~~~~ [error % ('"bbb"')] + case "ddd": + switch (param.length) { + case 0: + break; + + case 0: + ~ [error % ("0")] + case 1: + break; + + default: + break; + } + + case "eee": + case "eee": + ~~~~~ [error % ('"eee"')] + break; + + case "default": + break; + + case 0: + break; + + case "1": + break; + + default: + break; + } + } + + test(obj: object) { + switch (obj) { + case undefined: + break; + + case null: + case Infinity: + break; + + case this: + case null: + ~~~~ [error % ("null")] + break; + + default: + break; + } + } +} + +[error]: Duplicate switch case: '%s'. diff --git a/test/rules/no-duplicate-switch-case/tslint.json b/test/rules/no-duplicate-switch-case/tslint.json new file mode 100644 index 00000000000..27ad3e6211d --- /dev/null +++ b/test/rules/no-duplicate-switch-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-duplicate-switch-case": [true] + } +} diff --git a/test/rules/no-duplicate-variable/check-parameters/test.ts.lint b/test/rules/no-duplicate-variable/check-parameters/test.ts.lint new file mode 100644 index 00000000000..76fe1d878a0 --- /dev/null +++ b/test/rules/no-duplicate-variable/check-parameters/test.ts.lint @@ -0,0 +1,180 @@ +var duplicated = 1; + +function f(x) { + var x; + ~ [err % ('x')] +} + +class Test { + private myFunc() { + var notDuplicated = 123, + duplicated = 234, + someFunc = () => { + var notDuplicated = 345; + }; + + var duplicated = null; + ~~~~~~~~~~ [err % ('duplicated')] + } +} + +function test() { + var notDuplicated = 123, + duplicated = 234, + someFunc = () => { + var notDuplicated = 345; + }; + + var duplicated = null; + ~~~~~~~~~~ [err % ('duplicated')] +} + +duplicated = 2; +var duplicated = 3; + ~~~~~~~~~~ [err % ('duplicated')] + +// valid code +module tmp { + var path = require("path"); + export class MyType { + path: string; + } +} + +module MyModule { + export class ClassA { + id: string; + } + + export class ClassB { + id: string; + } +} + +var a = { + foo(): void { + var bar = 1; + }, + baz(): void { + var bar = 1; + } +}; + +class AccessorTest { + get accesor1(): number { + var x = 0; + return x; + } + + get accesor2(): number { + var x = 0; + return x; + } + +} + +class NoDupConstructor { + private test: string; + constructor() { + var test = "test"; + this.test = test; + } +} + +// valid/invalid code +function letTesting() { + var a = 1; + let b = 1; + let d = 1; + if (true) { + let a = 2; + let b = 2; + let c = 2; + var d = 2; + var e = 2; + } + else { + let b = 3; + let c = 3; + let e = 3; + let f = 3; + } + var f = 4; +} + +// failure: two arguments have the same name. +function testArguments1(arg: number, arg: number): void { +} + +// failure: local var/let declarations shadow arguments. +function testArguments2(x: number, y: number): void { + var x = 1; + ~ [err % ('x')] + let y = 2; +} + +var references: {[vertex: string]: any}; +var dependents: {[vertex: string]: any}; + +function blah(arg1: {[key: string]: any}, arg2: {[key:string]: any}) { +} + +interface IClipboard { + copy(key: string, state: any): void; + paste(key: string): any; + findMaxOrMin(values: any[], defaultValue: number, operation: (...values: any[]) => number); + functionA: (value: string) => void; + functionB: (value: string) => void; +} + +try { + // +} catch (e) { + e.blah(); + // +} + +try { + // +} catch (e) { + e.blah(); + // +} + +function testDestructuring() { + function myFunc() { + return [1, 2]; + } + + var [x, y] = myFunc(); + var [z, z] = myFunc(); // failure + ~ [err % ('z')] + + let [x1, y1] = myFunc(); + let [z1, z1] = myFunc(); // tsc error + + const [x2, y2] = myFunc(); + const [z2, z2] = myFunc(); // tsc error + + let [a1, [b1, c1]] = [1, [2, 3]]; + let [{a1, d1}] = [{a1: 1, d1: 4}]; // tsc error + + var [a2, [b2, c2]] = [1, [2, 3]]; + var [{a2, d2}] = [{a2: 1, d2: 4}]; // failure + ~~ [err % ('a2')] + + function myFunc2([a, b]) { + var a; + ~ [err % ('a')] + return b; + } + + var [x, y3] = myFunc(); // failure + ~ [err % ('x')] + var [x3, ...y] = [1, 2, 3, 4]; // failure + ~ [err % ('y')] +} + +function compileErrors(foo, {bar}, bar, foo, {baz}, [baz]) {} + +[err]: Duplicate variable: '%s' \ No newline at end of file diff --git a/test/rules/no-duplicate-variable/check-parameters/tslint.json b/test/rules/no-duplicate-variable/check-parameters/tslint.json new file mode 100644 index 00000000000..3c4e30e3d0b --- /dev/null +++ b/test/rules/no-duplicate-variable/check-parameters/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-duplicate-variable": [true, "check-parameters"] + } +} diff --git a/test/rules/no-duplicate-variable/default/test.ts.lint b/test/rules/no-duplicate-variable/default/test.ts.lint new file mode 100644 index 00000000000..9676f576c3d --- /dev/null +++ b/test/rules/no-duplicate-variable/default/test.ts.lint @@ -0,0 +1,177 @@ +var duplicated = 1; + +function f(x) { + var x; +} + +class Test { + private myFunc() { + var notDuplicated = 123, + duplicated = 234, + someFunc = () => { + var notDuplicated = 345; + }; + + var duplicated = null; + ~~~~~~~~~~ [err % ('duplicated')] + } +} + +function test() { + var notDuplicated = 123, + duplicated = 234, + someFunc = () => { + var notDuplicated = 345; + }; + + var duplicated = null; + ~~~~~~~~~~ [err % ('duplicated')] +} + +duplicated = 2; +var duplicated = 3; + ~~~~~~~~~~ [err % ('duplicated')] + +// valid code +module tmp { + var path = require("path"); + export class MyType { + path: string; + } +} + +module MyModule { + export class ClassA { + id: string; + } + + export class ClassB { + id: string; + } +} + +var a = { + foo(): void { + var bar = 1; + }, + baz(): void { + var bar = 1; + } +}; + +class AccessorTest { + get accesor1(): number { + var x = 0; + return x; + } + + get accesor2(): number { + var x = 0; + return x; + } + +} + +class NoDupConstructor { + private test: string; + constructor() { + var test = "test"; + this.test = test; + } +} + +// valid/invalid code +function letTesting() { + var a = 1; + let b = 1; + let d = 1; + if (true) { + let a = 2; + let b = 2; + let c = 2; + var d = 2; + var e = 2; + } + else { + let b = 3; + let c = 3; + let e = 3; + let f = 3; + } + var f = 4; +} + +// failure: two arguments have the same name. +function testArguments1(arg: number, arg: number): void { +} + +// local var/let declarations shadow arguments. Use options "check-parameters" to catch this +function testArguments2(x: number, y: number): void { + var x = 1; + let y = 2; +} + +var references: {[vertex: string]: any}; +var dependents: {[vertex: string]: any}; + +function blah(arg1: {[key: string]: any}, arg2: {[key:string]: any}) { +} + +interface IClipboard { + copy(key: string, state: any): void; + paste(key: string): any; + findMaxOrMin(values: any[], defaultValue: number, operation: (...values: any[]) => number); + functionA: (value: string) => void; + functionB: (value: string) => void; +} + +try { + // +} catch (e) { + e.blah(); + // +} + +try { + // +} catch (e) { + e.blah(); + // +} + +function testDestructuring() { + function myFunc() { + return [1, 2]; + } + + var [x, y] = myFunc(); + var [z, z] = myFunc(); // failure + ~ [err % ('z')] + + let [x1, y1] = myFunc(); + let [z1, z1] = myFunc(); // tsc error + + const [x2, y2] = myFunc(); + const [z2, z2] = myFunc(); // tsc error + + let [a1, [b1, c1]] = [1, [2, 3]]; + let [{a1, d1}] = [{a1: 1, d1: 4}]; // tsc error + + var [a2, [b2, c2]] = [1, [2, 3]]; + var [{a2, d2}] = [{a2: 1, d2: 4}]; // failure + ~~ [err % ('a2')] + + function myFunc2([a, b]) { + var a; + return b; + } + + var [x, y3] = myFunc(); // failure + ~ [err % ('x')] + var [x3, ...y] = [1, 2, 3, 4]; // failure + ~ [err % ('y')] +} + +function compileErrors(foo, {bar}, bar, foo, {baz}, [baz]) {} + +[err]: Duplicate variable: '%s' \ No newline at end of file diff --git a/test/rules/no-duplicate-variable/default/tslint.json b/test/rules/no-duplicate-variable/default/tslint.json new file mode 100644 index 00000000000..9d9b7a7156a --- /dev/null +++ b/test/rules/no-duplicate-variable/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-duplicate-variable": true + } +} diff --git a/test/rules/no-dynamic-delete/test.ts.fix b/test/rules/no-dynamic-delete/test.ts.fix new file mode 100644 index 00000000000..0cefd09ec54 --- /dev/null +++ b/test/rules/no-dynamic-delete/test.ts.fix @@ -0,0 +1,19 @@ +const container: { [i: string]: 0 } = {}; + +const getName = () => ""; + +delete container.aaa; +delete container["bb" + "b"]; +delete container.ccc; +delete container.delete; +delete container.delete; +delete container[7]; +delete container[-7]; +delete container[7]; +delete container[-Infinity]; +delete container["-Infinity"]; +delete container[+Infinity]; +delete container["+Infinity"]; +delete container[NaN]; +delete container.NaN; +delete container[getName()]; diff --git a/test/rules/no-dynamic-delete/test.ts.lint b/test/rules/no-dynamic-delete/test.ts.lint new file mode 100644 index 00000000000..51dbc6295d2 --- /dev/null +++ b/test/rules/no-dynamic-delete/test.ts.lint @@ -0,0 +1,29 @@ +const container: { [i: string]: 0 } = {}; + +const getName = () => ""; + +delete container.aaa; +delete container["bb" + "b"]; + ~~~~~~~~~~~~ [0] +delete container["ccc"]; + ~~~~~~~ [0] +delete container.delete; +delete container["delete"]; + ~~~~~~~~~~ [0] +delete container[7]; +delete container[-7]; +delete container[+7]; + ~~~~ [0] +delete container[-Infinity]; + ~~~~~~~~~~~ [0] +delete container["-Infinity"]; +delete container[+Infinity]; + ~~~~~~~~~~~ [0] +delete container["+Infinity"]; +delete container[NaN]; + ~~~~~ [0] +delete container["NaN"]; + ~~~~~~~ [0] +delete container[getName()]; + ~~~~~~~~~~~ [0] +[0]: Do not delete dynamically computed property keys. diff --git a/test/rules/no-dynamic-delete/tslint.json b/test/rules/no-dynamic-delete/tslint.json new file mode 100644 index 00000000000..f0c7404cfbf --- /dev/null +++ b/test/rules/no-dynamic-delete/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-dynamic-delete": true + } +} diff --git a/test/rules/no-empty-interface/test.ts.lint b/test/rules/no-empty-interface/test.ts.lint new file mode 100644 index 00000000000..b740fc1d6cd --- /dev/null +++ b/test/rules/no-empty-interface/test.ts.lint @@ -0,0 +1,14 @@ +interface I { } + ~ [An empty interface is equivalent to `{}`.] + +interface J extends I { } + ~ [An interface declaring no members is equivalent to its supertype.] + +interface K { x: number; } + +interface L extends J, K {} // extending more than one interface is ok, as it can be used instead of intersection types + +interface M extends {} // don't crash on empty extends list + ~ [An interface declaring no members is equivalent to its supertype.] + +interface N extends Promise {} diff --git a/test/rules/no-empty-interface/tslint.json b/test/rules/no-empty-interface/tslint.json new file mode 100644 index 00000000000..366f38b35e9 --- /dev/null +++ b/test/rules/no-empty-interface/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-empty-interface": true + } +} diff --git a/test/rules/no-empty/allow-empty-catch/test.ts.lint b/test/rules/no-empty/allow-empty-catch/test.ts.lint new file mode 100644 index 00000000000..b93d14c4cf5 --- /dev/null +++ b/test/rules/no-empty/allow-empty-catch/test.ts.lint @@ -0,0 +1,86 @@ +if (x === 1) {} + ~~ [block is empty] +if (x === 2) { + ~ + +~nil + +~nil +} +~ [block is empty] + +function testFunction1() { + ~ + +~nil +} +~ [block is empty] + +const testFunction2 = () => { }; + ~~~ [block is empty] + +const testFunction3 = function() {} + ~~ [block is empty] + +const testFunction4 = function(): void {} + ~~ [block is empty] + +for (var x = 0; x < 1; ++x) { } + ~~~ [block is empty] + +// empty blocks with comments should be legal +for (var y = 0; y < 1; ++y) { + // empty here +} +{ // empty block allowed +} +{ + /* this block is also empty, but allowed to be */ +} + +class testClass { + constructor(private allowed: any, private alsoAllowed: any) { + } +} + +class testClass2 { + constructor(protected allowed: any) { + } +} + +class testClass3 { + constructor(notAllowed: any) { + ~ + } +~~~~~ [block is empty] +} + +class testClass4 { + constructor(readonly allowed: any) { + } +} + +class PrivateClassConstructor { + private constructor() {} +} + +class ProtectedClassConstructor { + protected constructor() {} +} + +class PublicClassConstructor { + public constructor() {} + ~~ [block is empty] +} + +class ClassMethod { + public methodWithoutResultTypehinting() {} + ~~ [block is empty] + + public methodWithResultTypehinting(): void {} + ~~ [block is empty] +} + +try { + throw new Error(); +} catch (error) {} diff --git a/test/rules/no-empty/allow-empty-catch/tslint.json b/test/rules/no-empty/allow-empty-catch/tslint.json new file mode 100644 index 00000000000..02e43ab164d --- /dev/null +++ b/test/rules/no-empty/allow-empty-catch/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-empty": [true, "allow-empty-catch"] + } +} diff --git a/test/rules/no-empty/allow-empty-functions/test.ts.lint b/test/rules/no-empty/allow-empty-functions/test.ts.lint new file mode 100644 index 00000000000..daeb737873a --- /dev/null +++ b/test/rules/no-empty/allow-empty-functions/test.ts.lint @@ -0,0 +1,81 @@ +if (x === 1) {} + ~~ [block is empty] +if (x === 2) { + ~ + +~nil + +~nil +} +~ [block is empty] + +function testFunction1() { + + + +} + +const testFunction2 = () => { }; + +const testFunction3 = function() {} + +const testFunction4 = function(): void {} + +for (var x = 0; x < 1; ++x) { } + ~~~ [block is empty] + +// empty blocks with comments should be legal +for (var y = 0; y < 1; ++y) { + // empty here +} +{ // empty block allowed +} +{ + /* this block is also empty, but allowed to be */ +} + +class testClass { + constructor(private allowed: any, private alsoAllowed: any) { + } +} + +class testClass2 { + constructor(protected allowed: any) { + } +} + +class testClass3 { + constructor(notAllowed: any) { + ~ + } +~~~~~ [block is empty] +} + +class testClass4 { + constructor(readonly allowed: any) { + } +} + +class PrivateClassConstructor { + private constructor() {} +} + +class ProtectedClassConstructor { + protected constructor() {} +} + +class PublicClassConstructor { + public constructor() {} + ~~ [block is empty] +} + +class ClassMethod { + public methodWithoutResultTypehinting() {} + + public methodWithResultTypehinting(): void {} +} + +try { + throw new Error(); +} catch (error) {} + ~~ [block is empty] diff --git a/test/rules/no-empty/allow-empty-functions/tslint.json b/test/rules/no-empty/allow-empty-functions/tslint.json new file mode 100644 index 00000000000..56754e50512 --- /dev/null +++ b/test/rules/no-empty/allow-empty-functions/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-empty": [true, "allow-empty-functions"] + } +} diff --git a/test/rules/no-empty/default/test.ts.lint b/test/rules/no-empty/default/test.ts.lint new file mode 100644 index 00000000000..111c4986bbf --- /dev/null +++ b/test/rules/no-empty/default/test.ts.lint @@ -0,0 +1,87 @@ +if (x === 1) {} + ~~ [block is empty] +if (x === 2) { + ~ + +~nil + +~nil +} +~ [block is empty] + +function testFunction1() { + ~ + +~nil +} +~ [block is empty] + +const testFunction2 = () => { }; + ~~~ [block is empty] + +const testFunction3 = function() {} + ~~ [block is empty] + +const testFunction4 = function(): void {} + ~~ [block is empty] + +for (var x = 0; x < 1; ++x) { } + ~~~ [block is empty] + +// empty blocks with comments should be legal +for (var y = 0; y < 1; ++y) { + // empty here +} +{ // empty block allowed +} +{ + /* this block is also empty, but allowed to be */ +} + +class testClass { + constructor(private allowed: any, private alsoAllowed: any) { + } +} + +class testClass2 { + constructor(protected allowed: any) { + } +} + +class testClass3 { + constructor(notAllowed: any) { + ~ + } +~~~~~ [block is empty] +} + +class testClass4 { + constructor(readonly allowed: any) { + } +} + +class PrivateClassConstructor { + private constructor() {} +} + +class ProtectedClassConstructor { + protected constructor() {} +} + +class PublicClassConstructor { + public constructor() {} + ~~ [block is empty] +} + +class ClassMethod { + public methodWithoutResultTypehinting() {} + ~~ [block is empty] + + public methodWithResultTypehinting(): void {} + ~~ [block is empty] +} + +try { + throw new Error(); +} catch (error) {} + ~~ [block is empty] diff --git a/test/rules/no-empty/default/tslint.json b/test/rules/no-empty/default/tslint.json new file mode 100644 index 00000000000..282eaa1ffa3 --- /dev/null +++ b/test/rules/no-empty/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-empty": true + } +} diff --git a/test/rules/no-eval/test.ts.lint b/test/rules/no-eval/test.ts.lint new file mode 100644 index 00000000000..d7ffe5c856c --- /dev/null +++ b/test/rules/no-eval/test.ts.lint @@ -0,0 +1,10 @@ +var testVariable = "eval"; + +function a() { + function b() { + function c() { + eval("console.log('hi');"); + ~~~~ [forbidden eval] + } + } +} diff --git a/test/rules/no-eval/tslint.json b/test/rules/no-eval/tslint.json new file mode 100644 index 00000000000..1f0ba96f559 --- /dev/null +++ b/test/rules/no-eval/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-eval": true + } +} diff --git a/test/rules/no-floating-promises/jquerypromise/test.ts.lint b/test/rules/no-floating-promises/jquerypromise/test.ts.lint new file mode 100644 index 00000000000..4d6096e18c1 --- /dev/null +++ b/test/rules/no-floating-promises/jquerypromise/test.ts.lint @@ -0,0 +1,17 @@ +class Promise { } +class JQueryPromise { } +class NotAPromise { } + +const returnsPromise = () => new Promise(); +const returnsJQueryPromise = () => new JQueryPromise(); +const returnsNotAPromise = () => new NotAPromise(); + +returnsPromise(); +~~~~~~~~~~~~~~~~ [0] + +returnsJQueryPromise(); +~~~~~~~~~~~~~~~~~~~~~~ [0] + +returnsNotAPromise(); + +[0]: Promises must be handled appropriately diff --git a/test/rules/no-floating-promises/jquerypromise/tsconfig.json b/test/rules/no-floating-promises/jquerypromise/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-floating-promises/jquerypromise/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-floating-promises/jquerypromise/tslint.json b/test/rules/no-floating-promises/jquerypromise/tslint.json new file mode 100644 index 00000000000..1aa03fb4f2f --- /dev/null +++ b/test/rules/no-floating-promises/jquerypromise/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-floating-promises": [true, "JQueryPromise"] + } +} diff --git a/test/rules/no-floating-promises/promises/test.ts.lint b/test/rules/no-floating-promises/promises/test.ts.lint new file mode 100644 index 00000000000..145062f8c24 --- /dev/null +++ b/test/rules/no-floating-promises/promises/test.ts.lint @@ -0,0 +1,161 @@ +class Promise { + then(): Promise; +} + +function returnsPromiseFunction() { + return new Promise(); +} + +const returnsPromiseVariable = () => new Promise(); + +class ReturnsPromiseClass { + returnsPromiseMemberFunction() { + return new Promise(); + } + + returnsPromiseMemberVariable = () => new Promise(); + + static returnsPromiseStaticFunction = () => new Promise(); +} + +let a = returnsPromiseFunction(); +let b = returnsPromiseVariable(); +let c = new ReturnsPromiseClass().returnsPromiseMemberFunction(); +let d = new ReturnsPromiseClass().returnsPromiseMemberVariable(); +let e = ReturnsPromiseClass.returnsPromiseStaticFunction(); + +returnsPromiseFunction(); +~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +returnsPromiseFunction().then(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +returnsPromiseVariable(); +~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +returnsPromiseVariable().then(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +new ReturnsPromiseClass().returnsPromiseMemberFunction(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +new ReturnsPromiseClass().returnsPromiseMemberFunction().then(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +new ReturnsPromiseClass().returnsPromiseMemberVariable(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +new ReturnsPromiseClass().returnsPromiseMemberVariable().then(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +ReturnsPromiseClass.returnsPromiseStaticFunction(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +ReturnsPromiseClass.returnsPromiseStaticFunction().then(); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +(function () { + let a = returnsPromiseFunction(); + + returnsPromiseFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + returnsPromiseFunction().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberFunction().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberVariable(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberVariable().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + ReturnsPromiseClass.returnsPromiseStaticFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + ReturnsPromiseClass.returnsPromiseStaticFunction().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +})(); + +(() => { + let a = returnsPromiseFunction(); + + returnsPromiseFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + returnsPromiseFunction().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberFunction().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberVariable(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + new ReturnsPromiseClass().returnsPromiseMemberVariable().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + ReturnsPromiseClass.returnsPromiseStaticFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + ReturnsPromiseClass.returnsPromiseStaticFunction().then(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +})(); + +[].push(returnsPromiseFunction()); + +[].push(returnsPromiseFunction().then()); + +[].push(ReturnsPromiseClass.returnsPromiseStaticFunction()); + +[].push(ReturnsPromiseClass.returnsPromiseStaticFunction().then()); + +while (returnsPromiseFunction()); + +while (returnsPromiseFunction().then()); + +for (let i = 0; i < returnsPromiseFunction(); i += 1); + +for (let i = 0; i < returnsPromiseFunction().then(); i += 1); + +for (let i in returnsPromiseFunction()); + +for (let i in returnsPromiseFunction().then()); + +for (const promise of returnsPromiseFunction()); + +for (const promise of returnsPromiseFunction().then()); + +let promise = Math.random() > .5 + ? returnsPromiseFunction() + : returnsPromiseFunction().then(); + +declare var foo: boolean; +if (foo) + returnsPromiseFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] +switch(foo) { + case true: + returnsPromiseFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] + break; + case false: { + returnsPromiseFunction(); + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] + break; + } +} + +returnsPromiseFunction().catch(e => { console.error(e.stack); }); + +returnsPromiseFunction().then(() => {}, e => { console.error(e.stack); }); + +[0]: Promises must be handled appropriately diff --git a/test/rules/no-floating-promises/promises/tsconfig.json b/test/rules/no-floating-promises/promises/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-floating-promises/promises/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-floating-promises/promises/tslint.json b/test/rules/no-floating-promises/promises/tslint.json new file mode 100644 index 00000000000..9ed3c104284 --- /dev/null +++ b/test/rules/no-floating-promises/promises/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-floating-promises": true + } +} \ No newline at end of file diff --git a/test/rules/no-for-in-array/test.ts.lint b/test/rules/no-for-in-array/test.ts.lint new file mode 100644 index 00000000000..4024527653e --- /dev/null +++ b/test/rules/no-for-in-array/test.ts.lint @@ -0,0 +1,45 @@ +const array = [1, 2, 3, 4]; +const strArray = ['a', 'b', 'c']; +const objArray = [{a: 1}, {a: 2, b: 10}, {a: 3}]; +const o = {}; +const numArray = { + 1: "a", + 2: "b" +}; +const d = new Date(); +const str = "abc"; +const objectMap = {} as {[key: string]: number}; +const map = new Map([['a', 1], ['b', 2]]); +const set = new Set([1, 2, 3]); + +class C { + a: number; + f() {} + g() {} +} +c = new C(); + +class A { } +let refType: A; + +// valid cases +for (var k in o); +for (var k in d); +for (var k in map); +for (var k in numArray); +for (var k in c); +for (var k in refType); + +// invalid cases +for (var k in array); +~~~~~~~~~~~~~~~~~~~~~ [0] +for (var k in str); +~~~~~~~~~~~~~~~~~~~ [0] +for (var k in objArray); +~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +// Ideally these would also be forbidden: +for (var k in map); +for (var k in set); + +[0]: for-in loops over arrays are forbidden. Use for-of or array.forEach instead. diff --git a/test/rules/no-for-in-array/tsconfig.json b/test/rules/no-for-in-array/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-for-in-array/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-for-in-array/tslint.json b/test/rules/no-for-in-array/tslint.json new file mode 100644 index 00000000000..57f80691b45 --- /dev/null +++ b/test/rules/no-for-in-array/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-for-in-array": true + } +} diff --git a/test/rules/no-for-in/test.ts.lint b/test/rules/no-for-in/test.ts.lint new file mode 100644 index 00000000000..a3dd806a466 --- /dev/null +++ b/test/rules/no-for-in/test.ts.lint @@ -0,0 +1,20 @@ +const columns = [{ data: [1] }]; +for (let i = 0; i < columns[0].data.length; i++) { + columns.map((x) => x.data[i]); +} + +const object = { test: 1, test2: 1, test3: 1 }; +for (const key in object) { +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if (object.hasOwnProperty(key)) { +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const element = object[key]; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~ +} +~ [Use a for...of statement instead of for...in. If iterating over an object, use Object.keys() to access its enumerable keys.] + +for (const key of Object.keys(object)) { + const value = object[key]; +} diff --git a/test/rules/no-for-in/tslint.json b/test/rules/no-for-in/tslint.json new file mode 100644 index 00000000000..2a62503d3e3 --- /dev/null +++ b/test/rules/no-for-in/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-for-in": true + } +} diff --git a/test/rules/no-implicit-dependencies/default/bom/package.json b/test/rules/no-implicit-dependencies/default/bom/package.json new file mode 100644 index 00000000000..9c78824fcec --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/bom/package.json @@ -0,0 +1,5 @@ +{ + "name": "bom", + "version": "1.0.0", + "dependencies": {} +} diff --git a/test/rules/no-implicit-dependencies/default/bom/test.ts.lint b/test/rules/no-implicit-dependencies/default/bom/test.ts.lint new file mode 100644 index 00000000000..3531bc9edbc --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/bom/test.ts.lint @@ -0,0 +1,2 @@ +import * as ts from "typescript"; + ~~~~~~~~~~~~ [Module 'typescript' is not listed as dependency in package.json] diff --git a/test/rules/no-implicit-dependencies/default/builtin-only.ts.lint b/test/rules/no-implicit-dependencies/default/builtin-only.ts.lint new file mode 100644 index 00000000000..1223a2e0983 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/builtin-only.ts.lint @@ -0,0 +1,4 @@ +import * as fs from 'fs'; +import path = require('path'); +import('child_process').then(cp => cp.exec('foo')); +const http = require('http'); diff --git a/test/rules/no-implicit-dependencies/default/malformed/package.json b/test/rules/no-implicit-dependencies/default/malformed/package.json new file mode 100644 index 00000000000..8c94190c464 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/malformed/package.json @@ -0,0 +1,3 @@ +{ + , +} diff --git a/test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint b/test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint new file mode 100644 index 00000000000..217310ee713 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/malformed/tets.ts.lint @@ -0,0 +1,2 @@ +import foo from 'foo'; + ~~~~~ [Module 'foo' is not listed as dependency in package.json] diff --git a/test/rules/no-implicit-dependencies/default/nested-package/package.json b/test/rules/no-implicit-dependencies/default/nested-package/package.json new file mode 100644 index 00000000000..0b574aa2cf6 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/nested-package/package.json @@ -0,0 +1,7 @@ +{ + "name": "nested", + "version": "0.0.1", + "dependencies": { + "baz": "next" + } +} diff --git a/test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint b/test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint new file mode 100644 index 00000000000..02f84aefcd8 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/nested-package/test.ts.lint @@ -0,0 +1,24 @@ +import {assert} from 'chai'; + ~~~~~~ [err % ('chai')] +import foo from 'foo'; + ~~~~~ [err % ('foo')] + +if (foo) { + const common = require('common'); + ~~~~~~~~ [err % ('common')] +} + +export * from "@angular/core"; + ~~~~~~~~~~~~~~~ [err % ('@angular/core')] + +export * from "@angular/common/http"; + ~~~~~~~~~~~~~~~~~~~~~~ [err % ('@angular/common')] + +import * as ts from "typescript"; + ~~~~~~~~~~~~ [err % ('typescript')] + +import "baz"; + +const http = require('http'); + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/subdir/test.ts.lint b/test/rules/no-implicit-dependencies/default/subdir/test.ts.lint new file mode 100644 index 00000000000..927a875463c --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/subdir/test.ts.lint @@ -0,0 +1,26 @@ +import {assert} from 'chai'; + ~~~~~~ [err % ('chai')] +import foo from 'foo'; + +import Foo from 'Foo'; + ~~~~~ [err % ('Foo')] + +if (foo) { + const common = require('common'); + ~~~~~~~~ [err % ('common')] +} + +export * from "@angular/core"; + +export * from "@angular/common/http"; + +import * as ts from "typescript"; + +import "baz/foo"; + ~~~~~~~~~ [err % ('baz')] + +const http = require('http'); + +import test from '../test.ts'; + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/test.js.lint b/test/rules/no-implicit-dependencies/default/test.js.lint new file mode 100644 index 00000000000..ba3366f2051 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/test.js.lint @@ -0,0 +1,10 @@ +const foo = require('foo'); +const bar = require('bar'); +const baz = require('baz'); + ~~~~~ [err % ('baz')] + +import storageHelper from 'storage-helper'; + ~~~~~~~~~~~~~~~~ [err % ('storage-helper')] +const myModule = require('./myModule'); + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/test.ts.lint b/test/rules/no-implicit-dependencies/default/test.ts.lint new file mode 100644 index 00000000000..3ad34b19414 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/test.ts.lint @@ -0,0 +1,24 @@ +import {assert} from 'chai'; + ~~~~~~ [err % ('chai')] +import foo from 'foo'; + +if (foo) { + const common = require('common'); + ~~~~~~~~ [err % ('common')] +} + +export * from "@angular/core"; + +export * from "@angular/common/http"; + +import * as ts from "typescript"; + +import "baz"; + ~~~~~ [err % ('baz')] + +const http = require('http'); + +import * as fsevents from "fsevents"; + ~~~~~~~~~~ [err % ('fsevents')] + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/default/tslint.json b/test/rules/no-implicit-dependencies/default/tslint.json new file mode 100644 index 00000000000..9ad9a030528 --- /dev/null +++ b/test/rules/no-implicit-dependencies/default/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "no-implicit-dependencies": true + }, + "jsRules": { + "no-implicit-dependencies": true + } +} diff --git a/test/rules/no-implicit-dependencies/dev/test.ts.lint b/test/rules/no-implicit-dependencies/dev/test.ts.lint new file mode 100644 index 00000000000..9d4bbf3f269 --- /dev/null +++ b/test/rules/no-implicit-dependencies/dev/test.ts.lint @@ -0,0 +1,14 @@ +import * as ts from 'typescript'; + +import {assert} from 'chai'; + +import foo from 'foo'; + +import {baz} from 'baz'; + ~~~~~ [err % ('baz')] + + +import * as fsevents from "fsevents"; + ~~~~~~~~~~ [err % ('fsevents')] + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/dev/tslint.json b/test/rules/no-implicit-dependencies/dev/tslint.json new file mode 100644 index 00000000000..63472f0676a --- /dev/null +++ b/test/rules/no-implicit-dependencies/dev/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-implicit-dependencies": [true, "dev"] + } +} diff --git a/test/rules/no-implicit-dependencies/optional/test.ts.lint b/test/rules/no-implicit-dependencies/optional/test.ts.lint new file mode 100644 index 00000000000..6c361996c20 --- /dev/null +++ b/test/rules/no-implicit-dependencies/optional/test.ts.lint @@ -0,0 +1,13 @@ +import * as ts from 'typescript'; + +import {assert} from 'chai'; + ~~~~~~ [err % ('chai')] + +import foo from 'foo'; + +import {baz} from 'baz'; + ~~~~~ [err % ('baz')] + +import * as fsevents from "fsevents"; + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/optional/tslint.json b/test/rules/no-implicit-dependencies/optional/tslint.json new file mode 100644 index 00000000000..451b4ce11e2 --- /dev/null +++ b/test/rules/no-implicit-dependencies/optional/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-implicit-dependencies": [true, "optional"] + } +} diff --git a/test/rules/no-implicit-dependencies/package.json b/test/rules/no-implicit-dependencies/package.json new file mode 100644 index 00000000000..9ff1fed0ee3 --- /dev/null +++ b/test/rules/no-implicit-dependencies/package.json @@ -0,0 +1,19 @@ +{ + "name": "test", + "version": "1.0.0", + "dependencies": { + "foo": "latest", + "bar": "latest", + "@angular/core": "4.4.5", + "@angular/common": "4.4.4" + }, + "devDependencies": { + "chai": "latest" + }, + "peerDependencies": { + "typescript": "2.5.3" + }, + "optionalDependencies": { + "fsevents": "latest" + } +} diff --git a/test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint b/test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint new file mode 100644 index 00000000000..64c8000afb0 --- /dev/null +++ b/test/rules/no-implicit-dependencies/whitelist-with-dev/test.ts.lint @@ -0,0 +1,10 @@ +import * as ts from 'typescript'; + +import * from 'src/a'; + +import * from 'app/b'; + +import * from 'notapp/c'; + ~~~~~~~~~~ [err % ('notapp')] + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json b/test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json new file mode 100644 index 00000000000..4e1437158ad --- /dev/null +++ b/test/rules/no-implicit-dependencies/whitelist-with-dev/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-implicit-dependencies": [true, "dev", ["src", "app"]] + } +} diff --git a/test/rules/no-implicit-dependencies/whitelist/test.ts.lint b/test/rules/no-implicit-dependencies/whitelist/test.ts.lint new file mode 100644 index 00000000000..efc3c279f19 --- /dev/null +++ b/test/rules/no-implicit-dependencies/whitelist/test.ts.lint @@ -0,0 +1,20 @@ +import * as ts from 'typescript'; + +import * from 'src/a'; + +import * from '@components/a'; + +import * from '@com/fixer'; + +import * from 'app/b'; + +import * from 'notapp/c'; + ~~~~~~~~~~ [err % ('notapp')] + +import * from '@notapp/c'; + ~~~~~~~~~~~ [err % ('@notapp/c')] + +import * from '@com/c'; + ~~~~~~~~ [err % ('@com/c')] + +[err]: Module '%s' is not listed as dependency in package.json diff --git a/test/rules/no-implicit-dependencies/whitelist/tslint.json b/test/rules/no-implicit-dependencies/whitelist/tslint.json new file mode 100644 index 00000000000..98121cf053c --- /dev/null +++ b/test/rules/no-implicit-dependencies/whitelist/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-implicit-dependencies": [true, ["src", "app", "@components", "@com/fixer"]] + } +} diff --git a/test/rules/no-import-side-effect/default/test.ts.lint b/test/rules/no-import-side-effect/default/test.ts.lint new file mode 100644 index 00000000000..0f5151a0b4e --- /dev/null +++ b/test/rules/no-import-side-effect/default/test.ts.lint @@ -0,0 +1,22 @@ + +// valid cases +import {Injectable, Component, Directive} from '@angular/core'; +import {Inject} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Observable as Obs} from 'rxjs/Observable'; +import * as _ from 'underscore'; +import DefaultExport from 'module-with-default'; + +// invalid cases +import './allow-side-effect'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +import './styles.css'; +~~~~~~~~~~~~~~~~~~~~~~ [0] +import 'rxjs/add/observable/of'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +import 'rxjs/add/operator/mapTo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +import 'random-side-effect'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: import with explicit side-effect diff --git a/test/rules/no-import-side-effect/default/tslint.json b/test/rules/no-import-side-effect/default/tslint.json new file mode 100644 index 00000000000..220182feece --- /dev/null +++ b/test/rules/no-import-side-effect/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-import-side-effect": [true] + } +} diff --git a/test/rules/no-import-side-effect/ignore-module/test.ts.lint b/test/rules/no-import-side-effect/ignore-module/test.ts.lint new file mode 100644 index 00000000000..971b14817a2 --- /dev/null +++ b/test/rules/no-import-side-effect/ignore-module/test.ts.lint @@ -0,0 +1,18 @@ +// valid cases +import {Injectable, Component, Directive} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Observable as Obs} from 'rxjs/Observable'; +import * as _ from 'underscore'; +import DefaultExport from 'module-with-default'; +import './allow-side-effect'; +import './styles.css'; + +// invalid cases +import 'rxjs/add/observable/of'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +import 'rxjs/add/operator/mapTo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +import 'random-side-effect'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: import with explicit side-effect diff --git a/test/rules/no-import-side-effect/ignore-module/tslint.json b/test/rules/no-import-side-effect/ignore-module/tslint.json new file mode 100644 index 00000000000..72647987f09 --- /dev/null +++ b/test/rules/no-import-side-effect/ignore-module/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "no-import-side-effect": [ + true, + { + "ignore-module": "(allow-side-effect|\\.css)$" + } + ] + } +} diff --git a/test/rules/no-inferrable-types/default/test.ts.fix b/test/rules/no-inferrable-types/default/test.ts.fix new file mode 100644 index 00000000000..51255e20557 --- /dev/null +++ b/test/rules/no-inferrable-types/default/test.ts.fix @@ -0,0 +1,35 @@ +// errors, inferrable type is declared +let a = 7; +let b = false; +let c = "foo"; +let d = Infinity; +let e = -Infinity; +class C { + x = 1; +} + +// errors, types are inferrable +function foo (a = 5, b = true, c = "bah") { } + +class Foo { + bar = 0; + baz = true, + bas = "moar"; + readonly foo: boolean = false; + constructor(readonly foobar: string = "test", public barfoo = 1) {} +} + +// not errors, inferrable type is not declared +let _x = 7; +let _y = false; +let _z = "foo"; + +// not error, type is not inferrable +let weird: any = 123; + +// not errors, inferrable type is not declared +function bar(a = 5, b = true, c = "bah") { } + +// not errors, types are not inferrable +function baz(a: any = 5, b: any = true, c: any = "bah") { } + diff --git a/test/rules/no-inferrable-types/default/test.ts.lint b/test/rules/no-inferrable-types/default/test.ts.lint new file mode 100644 index 00000000000..02282636387 --- /dev/null +++ b/test/rules/no-inferrable-types/default/test.ts.lint @@ -0,0 +1,51 @@ +// errors, inferrable type is declared +let a: number = 7; + ~~~~~~ [number] +let b: boolean = false; + ~~~~~~~ [boolean] +let c: string = "foo"; + ~~~~~~ [string] +let d: number = Infinity; + ~~~~~~ [number] +let e: number = -Infinity; + ~~~~~~ [number] +class C { + x: number = 1; + ~~~~~~ [number] +} + +// errors, types are inferrable +function foo (a: number = 5, b: boolean = true, c: string = "bah") { } + ~~~~~~ [number] + ~~~~~~~ [boolean] + ~~~~~~ [string] + +class Foo { + bar: number = 0; + ~~~~~~ [number] + baz: boolean = true, + ~~~~~~~ [boolean] + bas: string = "moar"; + ~~~~~~ [string] + readonly foo: boolean = false; + constructor(readonly foobar: string = "test", public barfoo: number = 1) {} + ~~~~~~ [number] +} + +// not errors, inferrable type is not declared +let _x = 7; +let _y = false; +let _z = "foo"; + +// not error, type is not inferrable +let weird: any = 123; + +// not errors, inferrable type is not declared +function bar(a = 5, b = true, c = "bah") { } + +// not errors, types are not inferrable +function baz(a: any = 5, b: any = true, c: any = "bah") { } + +[number]: Type number trivially inferred from a number literal, remove type annotation +[boolean]: Type boolean trivially inferred from a boolean literal, remove type annotation +[string]: Type string trivially inferred from a string literal, remove type annotation diff --git a/test/rules/no-inferrable-types/default/tslint.json b/test/rules/no-inferrable-types/default/tslint.json new file mode 100644 index 00000000000..e753f48f599 --- /dev/null +++ b/test/rules/no-inferrable-types/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-inferrable-types": true + } +} diff --git a/test/rules/no-inferrable-types/ignore-params/test.ts.fix b/test/rules/no-inferrable-types/ignore-params/test.ts.fix new file mode 100644 index 00000000000..2adaaff65c3 --- /dev/null +++ b/test/rules/no-inferrable-types/ignore-params/test.ts.fix @@ -0,0 +1,34 @@ +// errors, inferrable type is declared +let x = 7; +let y = false; +let z = "foo"; + +// not errors, we are skipping params +function foo (a: number = 5, b: boolean = true, c: string = "bah") { } + +class TestClass { + doSomething(a: number = 5, b: boolean = true, c: string = "bah") {} +} + +class Foo { + bar = 0; + baz = true, + bas = "moar"; + readonly foo: boolean = false; + constructor(readonly foobar: string = "test", public barfoo: number = 1) {} +} + +// not errors, inferrable type is not declared +let _x = 7; +let _y = false; +let _z = "foo"; + +// not error, type is not inferrable +let weird: any = 123; + +// not errors, inferrable type is not declared +function bar(a = 5, b = true, c = "bah") { } + +// not errors, types are not inferrable +function baz(a: any = 5, b: any = true, c: any = "bah") { } + diff --git a/test/rules/no-inferrable-types/ignore-params/test.ts.lint b/test/rules/no-inferrable-types/ignore-params/test.ts.lint new file mode 100644 index 00000000000..f5fbee1fc09 --- /dev/null +++ b/test/rules/no-inferrable-types/ignore-params/test.ts.lint @@ -0,0 +1,43 @@ +// errors, inferrable type is declared +let x: number = 7; + ~~~~~~ [number] +let y: boolean = false; + ~~~~~~~ [boolean] +let z: string = "foo"; + ~~~~~~ [string] + +// not errors, we are skipping params +function foo (a: number = 5, b: boolean = true, c: string = "bah") { } + +class TestClass { + doSomething(a: number = 5, b: boolean = true, c: string = "bah") {} +} + +class Foo { + bar: number = 0; + ~~~~~~ [number] + baz: boolean = true, + ~~~~~~~ [boolean] + bas: string = "moar"; + ~~~~~~ [string] + readonly foo: boolean = false; + constructor(readonly foobar: string = "test", public barfoo: number = 1) {} +} + +// not errors, inferrable type is not declared +let _x = 7; +let _y = false; +let _z = "foo"; + +// not error, type is not inferrable +let weird: any = 123; + +// not errors, inferrable type is not declared +function bar(a = 5, b = true, c = "bah") { } + +// not errors, types are not inferrable +function baz(a: any = 5, b: any = true, c: any = "bah") { } + +[number]: Type number trivially inferred from a number literal, remove type annotation +[boolean]: Type boolean trivially inferred from a boolean literal, remove type annotation +[string]: Type string trivially inferred from a string literal, remove type annotation diff --git a/test/rules/no-inferrable-types/ignore-params/tslint.json b/test/rules/no-inferrable-types/ignore-params/tslint.json new file mode 100644 index 00000000000..bad8056f990 --- /dev/null +++ b/test/rules/no-inferrable-types/ignore-params/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "no-inferrable-types": [ + true, + "ignore-params" + ] + } +} diff --git a/test/rules/no-inferrable-types/ignore-properties/test.ts.fix b/test/rules/no-inferrable-types/ignore-properties/test.ts.fix new file mode 100644 index 00000000000..5f9c54304c6 --- /dev/null +++ b/test/rules/no-inferrable-types/ignore-properties/test.ts.fix @@ -0,0 +1,33 @@ +// errors, inferrable type is declared +let x = 7; +let y = false; +let z = "foo"; +class C { + x: number = 1; +} + +// errors, types are inferrable +function foo (a = 5, b = true, c = "bah") { } + +class Foo { + bar: number = 0; + baz: boolean = true, + bas: string = "moar"; + readonly foo: boolean = false; + constructor(readonly foobar: string = "test", public barfoo: number = 1) {} +} + +// not errors, inferrable type is not declared +let _x = 7; +let _y = false; +let _z = "foo"; + +// not error, type is not inferrable +let weird: any = 123; + +// not errors, inferrable type is not declared +function bar(a = 5, b = true, c = "bah") { } + +// not errors, types are not inferrable +function baz(a: any = 5, b: any = true, c: any = "bah") { } + diff --git a/test/rules/no-inferrable-types/ignore-properties/test.ts.lint b/test/rules/no-inferrable-types/ignore-properties/test.ts.lint new file mode 100644 index 00000000000..b9147ddd705 --- /dev/null +++ b/test/rules/no-inferrable-types/ignore-properties/test.ts.lint @@ -0,0 +1,42 @@ +// errors, inferrable type is declared +let x: number = 7; + ~~~~~~ [number] +let y: boolean = false; + ~~~~~~~ [boolean] +let z: string = "foo"; + ~~~~~~ [string] +class C { + x: number = 1; +} + +// errors, types are inferrable +function foo (a: number = 5, b: boolean = true, c: string = "bah") { } + ~~~~~~ [number] + ~~~~~~~ [boolean] + ~~~~~~ [string] + +class Foo { + bar: number = 0; + baz: boolean = true, + bas: string = "moar"; + readonly foo: boolean = false; + constructor(readonly foobar: string = "test", public barfoo: number = 1) {} +} + +// not errors, inferrable type is not declared +let _x = 7; +let _y = false; +let _z = "foo"; + +// not error, type is not inferrable +let weird: any = 123; + +// not errors, inferrable type is not declared +function bar(a = 5, b = true, c = "bah") { } + +// not errors, types are not inferrable +function baz(a: any = 5, b: any = true, c: any = "bah") { } + +[number]: Type number trivially inferred from a number literal, remove type annotation +[boolean]: Type boolean trivially inferred from a boolean literal, remove type annotation +[string]: Type string trivially inferred from a string literal, remove type annotation diff --git a/test/rules/no-inferrable-types/ignore-properties/tslint.json b/test/rules/no-inferrable-types/ignore-properties/tslint.json new file mode 100644 index 00000000000..2d9fd532f2c --- /dev/null +++ b/test/rules/no-inferrable-types/ignore-properties/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-inferrable-types": [true, "ignore-properties"] + } +} diff --git a/test/rules/no-inferred-empty-object-type/test.ts.lint b/test/rules/no-inferred-empty-object-type/test.ts.lint new file mode 100644 index 00000000000..9026cc355d4 --- /dev/null +++ b/test/rules/no-inferred-empty-object-type/test.ts.lint @@ -0,0 +1,92 @@ +[typescript]: <=3.4.5 + +let s: string; +let n: number; +let o: Object; +let l: { a: number, b: string }; +let t: [number, string]; +let p: Wrapper; +let f: () => void; +type EmptyFunc = () => void; +let voidFunc: () => void; +let stringFunc: () => string; +function WrapperFunc(x?: T): T { + return x; +} +function CurriedFunc(h?: () => T): () => T { + return h; +} +function MultiParamFunction(x?: T, y?: U): T { + return x; +} +class Wrapper { + val: T; +} +class MultiParamsClass { + val1: T; + val2: U; +} + +/* Bad */ +WrapperFunc(); +~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the function call] +CurriedFunc(); +~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the function call] +MultiParamFunction(); +~~~~~~~~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the function call] +new Wrapper(); +~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the constructor] +new MultiParamsClass(); +~~~~~~~~~~~~~~~~~~~~~~ [Explicit type parameter needs to be provided to the constructor] + +/* Good */ +WrapperFunc(); +WrapperFunc(); +WrapperFunc(); +WrapperFunc(s); +WrapperFunc(n); +WrapperFunc(o); +WrapperFunc(l); +WrapperFunc(t); +WrapperFunc(p); +WrapperFunc(f); +WrapperFunc<() => {}>(); + +WrapperFunc<() => void>(); +WrapperFunc<{ a: number }>(); +WrapperFunc<{ [x: number]: string }>(); +WrapperFunc<{ [x: string]: string }>(); + +CurriedFunc(voidFunc); +CurriedFunc(stringFunc); + +MultiParamFunction(); +MultiParamFunction<{}, number>(); +MultiParamFunction(); +MultiParamFunction<{ a: number }, string>(); +MultiParamFunction<() => {}, () => void>(); +MultiParamFunction<() => void, () => {}>(); +MultiParamFunction<() => void, () => void>(); +MultiParamFunction<{ [x: number]: string }, () => void>(); +MultiParamFunction<{ [x: string]: string }, number>(); + +new Wrapper(); +new Wrapper<() => void>(); +new Wrapper<() => {}>(); +new Wrapper<{ a: number }>(); +new Wrapper<{ [x: number]: string }>(); +new Wrapper<{ [x: string]: string }>(); + +new MultiParamsClass(); +new MultiParamsClass<{}, number>(); +new MultiParamsClass(); +new MultiParamsClass<{ a: number }, string>(); +new MultiParamsClass<() => {}, () => void>(); +new MultiParamsClass<() => void, () => {}>(); +new MultiParamsClass<() => void, () => void>(); +new MultiParamsClass<{ [x: number]: string }, () => void>(); +new MultiParamsClass<{ [x: string]: string }, number>(); + +// don't crash with stack overflow +import {expect} from "chai"; +expect(1).to.eq(1); diff --git a/test/rules/no-inferred-empty-object-type/tsconfig.json b/test/rules/no-inferred-empty-object-type/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-inferred-empty-object-type/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-inferred-empty-object-type/tslint.json b/test/rules/no-inferred-empty-object-type/tslint.json new file mode 100644 index 00000000000..81b900beb64 --- /dev/null +++ b/test/rules/no-inferred-empty-object-type/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-inferred-empty-object-type": true + } +} diff --git a/test/rules/no-internal-module/test.ts.fix b/test/rules/no-internal-module/test.ts.fix new file mode 100644 index 00000000000..89359233193 --- /dev/null +++ b/test/rules/no-internal-module/test.ts.fix @@ -0,0 +1,62 @@ +namespace foo { +} + +// valid, special syntax for augmenting global +declare global { } + +namespace bar { +} + +declare namespace buzz { +} + +declare module "hoge" { +} +declare module 'fuga' { +} + +namespace foo.bar { +} +namespace foo.bar.baz { +} +namespace foo { + namespace bar.baz { + } +} + +namespace foo.bar { + namespace baz { + namespace buzz { + } + } +} + +namespace foo.bar { + namespace baz { + namespace buzz { + } + } +} + +namespace name.namespace { +} +namespace namespace.name { +} + +// intentionally malformed for test cases, do not format +declare namespace declare +.dec{} +declare namespace dec . declare { +} + +namespace mod.module{} +namespace module.mod +{ +} + +namespace global {} +namespace foo.global {} +namespace foo { + export namespace global {} +} + diff --git a/test/rules/no-internal-module/test.ts.lint b/test/rules/no-internal-module/test.ts.lint new file mode 100644 index 00000000000..64cf478d2db --- /dev/null +++ b/test/rules/no-internal-module/test.ts.lint @@ -0,0 +1,76 @@ +namespace foo { +} + +// valid, special syntax for augmenting global +declare global { } + +module bar { +~~~~~~ [0] +} + +declare module buzz { + ~~~~~~ [0] +} + +declare module "hoge" { +} +declare module 'fuga' { +} + +namespace foo.bar { +} +namespace foo.bar.baz { +} +namespace foo { + namespace bar.baz { + } +} + +namespace foo.bar { + module baz { + ~~~~~~ [0] + namespace buzz { + } + } +} + +module foo.bar { +~~~~~~ [0] + namespace baz { + module buzz { + ~~~~~~ [0] + } + } +} + +namespace name.namespace { +} +namespace namespace.name { +} + +// intentionally malformed for test cases, do not format +declare module declare + ~~~~~~ [0] +.dec{} +declare module dec . declare { + ~~~~~~ [0] +} + +module mod.module{} +~~~~~~ [0] +module module.mod +~~~~~~ [0] +{ +} + +module global {} +~~~~~~ [0] +module foo.global {} +~~~~~~ [0] +module foo { +~~~~~~ [0] + export module global {} + ~~~~~~ [0] +} + +[0]: The internal 'module' syntax is deprecated, use the 'namespace' keyword instead. diff --git a/test/rules/no-internal-module/tslint.json b/test/rules/no-internal-module/tslint.json new file mode 100644 index 00000000000..ac4edc57f5f --- /dev/null +++ b/test/rules/no-internal-module/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-internal-module": true + } +} diff --git a/test/rules/no-invalid-template-strings/test.ts.lint b/test/rules/no-invalid-template-strings/test.ts.lint new file mode 100644 index 00000000000..ac4fd54f7d2 --- /dev/null +++ b/test/rules/no-invalid-template-strings/test.ts.lint @@ -0,0 +1,41 @@ +new (Tab.mixins.Controlled('MemberComments',Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData()))) + +new (Tab.mixins.Controlled('MemberComments',Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('\${c}')))) + +Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('\\${d}')) + ~~~~ [0] + +Tab.mixins.Templated(`
`,Tab.mixins.AlwaysHasData('${f}')) + ~~~~ [0] + +Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('${h}'), Tab.mixin.SomeMethod('${i}')) + ~~~~ [0] + ~~~~ [0] + ~~~~ [0] + +new (Tab.mixins.Controlled('MemberComments',Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData()))) + ~~~~ [0] + +new (Tab.mixins.Templated('
',Tab.mixins.AlwaysHasData('\\\\${c}')))) + ~~~~ [0] + +"\${a} = ${a}"; + ~~~~ [0] + +"One plus one is ${1 + 1}."; + ~~~~~~~~ [0] + +'One plus one is ${1 + 1}.'; + ~~~~~~~~ [0] + +`One plus one is ${1 + 1}.`; + +"${"; + +"${" + '}'; + +"${() => {}} ${abc}" + ~~~~~~~~~~ [0] + ~~~~~~ [0] + +[0]: Interpolation will only work for template strings. diff --git a/test/rules/no-invalid-template-strings/tslint.json b/test/rules/no-invalid-template-strings/tslint.json new file mode 100644 index 00000000000..f495c57db7e --- /dev/null +++ b/test/rules/no-invalid-template-strings/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-invalid-template-strings": true + } +} diff --git a/test/rules/no-invalid-this/enabled/test.ts.lint b/test/rules/no-invalid-this/enabled/test.ts.lint new file mode 100644 index 00000000000..47f50f57aa2 --- /dev/null +++ b/test/rules/no-invalid-this/enabled/test.ts.lint @@ -0,0 +1,118 @@ +function setSomeProperty(this: { someProperty: number }) { + this.someProperty = 7; +} + +function bindProperty(this: { someProperty: number }, fn: Function) { + return fn.bind(this); +} + +const objectLiteralStyle = { + bindProperty: function(this: { someProperty: number }, fn: Function) { + return fn.bind(this); + }, +}; + +const objectMethodStyle = { + bindProperty(this: { someProperty: number }, fn: Function) { + return fn.bind(this); + }, +}; + +export function f(this: Observable): Observable { + const nestedFunction = function(this) => { + console.log(this) + } + return this.map(i=>i); +} + +class ContextualThisClass { + private someMethod(): void { + let nestedFunction: (this: number[]) => number[] = function(this) { + [3,4].forEach(function(nr){ + console.log(this); + ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] + }); + return this.map(i=>i); + }; + } +} + +function foo(x: number) { + console.log(this.x); + ~~~~ [the "this" keyword is disallowed outside of a class body] + + this.evilMethod(); + ~~~~ [the "this" keyword is disallowed outside of a class body] +} + +class AClass { + private x: number; + + constructor() { + this.x = 2; + } + + public aMethod() { + this.x = 5; + } + + public bMethod() { + [3,4].forEach(function(nr){ + console.log(this.x === nr); + ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] + }); + } + + public bMethod() { + [3,4].forEach((nr) => { + console.log(this.x === nr); + }); + } + + public cMethod = () => { + [3,4].forEach(function(nr){ + console.log(this.x === nr); + ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] + }); + } + + public dMethod() { + [3,4].forEach(badFunction); + function badFunction(nr) { + console.log(this.x === nr); + ~~~~ [the "this" keyword is disallowed in function bodies inside class methods, use arrow functions instead] + } + } + + public eMethod() { + [3,4].forEach(badFunction); + let badFunction = nr => console.log(this.x === nr); + } + + public fMethod() { + const objectLiteralStyle = { + bindProperty: function(this: { someProperty: number }, fn: Function) { + return fn.bind(this); + }, + }; + + const objectMethodStyle = { + bindProperty(this: { someProperty: number }, fn: Function) { + return fn.bind(this); + }, + }; + + return { + objectLiteralStyle, + objectMethodStyle, + }; + } +} + +const AClassExpression = class { + private x: number; + + public aMethod() { + this.x = 5; + } +} diff --git a/test/rules/no-invalid-this/enabled/tslint.json b/test/rules/no-invalid-this/enabled/tslint.json new file mode 100644 index 00000000000..55c5eee2986 --- /dev/null +++ b/test/rules/no-invalid-this/enabled/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "no-invalid-this": [ + true, + "check-function-in-method" + ] + } +} diff --git a/test/rules/no-irregular-whitespace/test.builder.ts b/test/rules/no-irregular-whitespace/test.builder.ts new file mode 100644 index 00000000000..4d540345060 --- /dev/null +++ b/test/rules/no-irregular-whitespace/test.builder.ts @@ -0,0 +1,41 @@ +/** + * @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. + */ + +/** + * This script auto-generate test files for the `no-irregular-whitespace` rule + */ + +import * as fs from 'fs'; +import * as path from 'path'; + +import { IRREGULAR_WHITESPACE_REGEX } from '../../../src/rules/noIrregularWhitespaceRule'; + +const matches = IRREGULAR_WHITESPACE_REGEX.source + .substring(1, IRREGULAR_WHITESPACE_REGEX.source.length - 2) + .match(/\\\w+/g) + .filter(match => ['\\u2029', '\\u2028'].indexOf(match) === -1) // those seems to break the parser + .map(match => JSON.parse(`"${match}"`) as string); + +const lintFilePath = path.join(__dirname, "test.ts.lint"); +const lintFileContent = matches.reduce((acc: string, match) => { + return acc += `let ${match} foo;\n ~ [Irregular whitespace not allowed]\n`; +}, ''); +fs.writeFileSync(lintFilePath, lintFileContent); + +const fixFilePath = path.join(__dirname, "test.ts.fix"); +const fixFileContent = 'let foo;\n'.repeat(matches.length) +fs.writeFileSync(fixFilePath, fixFileContent); diff --git a/test/rules/no-irregular-whitespace/test.ts.fix b/test/rules/no-irregular-whitespace/test.ts.fix new file mode 100644 index 00000000000..608ce2c0cf4 --- /dev/null +++ b/test/rules/no-irregular-whitespace/test.ts.fix @@ -0,0 +1,22 @@ +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; +let foo; diff --git a/test/rules/no-irregular-whitespace/test.ts.lint b/test/rules/no-irregular-whitespace/test.ts.lint new file mode 100644 index 00000000000..d18c7f261e2 --- /dev/null +++ b/test/rules/no-irregular-whitespace/test.ts.lint @@ -0,0 +1,44 @@ +let foo; + ~ [Irregular whitespace not allowed] +let foo; + ~ [Irregular whitespace not allowed] +let … foo; + ~ [Irregular whitespace not allowed] +let  foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let ᠎ foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let ​ foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] +let   foo; + ~ [Irregular whitespace not allowed] diff --git a/test/rules/no-irregular-whitespace/tslint.json b/test/rules/no-irregular-whitespace/tslint.json new file mode 100644 index 00000000000..5d70362a4a2 --- /dev/null +++ b/test/rules/no-irregular-whitespace/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-irregular-whitespace": true + } +} diff --git a/test/rules/no-magic-numbers/allowed-numbers/test.ts.lint b/test/rules/no-magic-numbers/allowed-numbers/test.ts.lint new file mode 100644 index 00000000000..35a47e2bb56 --- /dev/null +++ b/test/rules/no-magic-numbers/allowed-numbers/test.ts.lint @@ -0,0 +1,23 @@ +parseInt(); +parseInt('123', 2); +parseInt('123', 8); +parseInt('123', 10); +parseInt('123', 16); +console.log(-0); +console.log(1337); +console.log(-1337); +console.log(- 1337); +console.log(1337.7); +console.log(1338); + ~~~~ ['magic numbers' are not allowed: 1338] +console.log(-1338) + ~~~~~ ['magic numbers' are not allowed: -1338] +parseInt(foo === 4711 ? bar : baz, 10); + ~~~~ ['magic numbers' are not allowed: 4711] +parseInt(foo === -0 ? bar : baz, 10); +export let x = 1337; +export let x = -1337; +export let x = 1337.7; +export let x = 1338; +export let x = -1338; +export let x = -0; diff --git a/test/rules/no-magic-numbers/allowed-numbers/tslint.json b/test/rules/no-magic-numbers/allowed-numbers/tslint.json new file mode 100644 index 00000000000..6cbe7e8b5a8 --- /dev/null +++ b/test/rules/no-magic-numbers/allowed-numbers/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-magic-numbers": [true, { + "allowed-numbers": [1337, 1337.7, -1337, -0] + }] + } +} diff --git a/test/rules/no-magic-numbers/custom/test.ts.lint b/test/rules/no-magic-numbers/custom/test.ts.lint new file mode 100644 index 00000000000..35a47e2bb56 --- /dev/null +++ b/test/rules/no-magic-numbers/custom/test.ts.lint @@ -0,0 +1,23 @@ +parseInt(); +parseInt('123', 2); +parseInt('123', 8); +parseInt('123', 10); +parseInt('123', 16); +console.log(-0); +console.log(1337); +console.log(-1337); +console.log(- 1337); +console.log(1337.7); +console.log(1338); + ~~~~ ['magic numbers' are not allowed: 1338] +console.log(-1338) + ~~~~~ ['magic numbers' are not allowed: -1338] +parseInt(foo === 4711 ? bar : baz, 10); + ~~~~ ['magic numbers' are not allowed: 4711] +parseInt(foo === -0 ? bar : baz, 10); +export let x = 1337; +export let x = -1337; +export let x = 1337.7; +export let x = 1338; +export let x = -1338; +export let x = -0; diff --git a/test/rules/no-magic-numbers/custom/tslint.json b/test/rules/no-magic-numbers/custom/tslint.json new file mode 100644 index 00000000000..7b109490b00 --- /dev/null +++ b/test/rules/no-magic-numbers/custom/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-magic-numbers": [true, 1337, 1337.7, -1337, -0] + } +} diff --git a/test/rules/no-magic-numbers/default-jsx/test.tsx.lint b/test/rules/no-magic-numbers/default-jsx/test.tsx.lint new file mode 100644 index 00000000000..27ae8e598f8 --- /dev/null +++ b/test/rules/no-magic-numbers/default-jsx/test.tsx.lint @@ -0,0 +1,8 @@ +import * as React from "react"; +class App extends React.Component { + render() { + return ; + ~~~ ['magic numbers' are not allowed: 200] + ~~~ ['magic numbers' are not allowed: 200] + } +} diff --git a/test/rules/no-magic-numbers/default-jsx/tslint.json b/test/rules/no-magic-numbers/default-jsx/tslint.json new file mode 100644 index 00000000000..13ce3e0dab0 --- /dev/null +++ b/test/rules/no-magic-numbers/default-jsx/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-magic-numbers": true + } +} diff --git a/test/rules/no-magic-numbers/default/test.ts.lint b/test/rules/no-magic-numbers/default/test.ts.lint new file mode 100644 index 00000000000..8cd050f2c5e --- /dev/null +++ b/test/rules/no-magic-numbers/default/test.ts.lint @@ -0,0 +1,48 @@ +console.log(-1, 0, 1); +console.log(42.42); + ~~~~~ ['magic numbers' are not allowed: 42.42] +console.log(-0); + ~~ ['magic numbers' are not allowed: -0] +const a = 1337; +const b = { + a: 1338, + b: 0, +} +b.b = 1339; + ~~~~ ['magic numbers' are not allowed: 1339] + +console.log(1340); + ~~~~ ['magic numbers' are not allowed: 1340] +for(let i = 0;i>1341;++i) { + ~~~~ ['magic numbers' are not allowed: 1341] +} + +throw 1342; + ~~~~ ['magic numbers' are not allowed: 1342] + +class A { + static test = 1337; + + constructor (private a = 1337) { + } +} + +enum Test { + key = 1337, +} + +const a = 0.1234567801234567890; +a.toFixed(2); +a.toFixed(5); +a.toFixed(10); + +a.toString(10); +a.toString(36); + +a.toPrecision(3) +a.toPrecision(10) +a.toPrecision(20) + +const b = 77.1234; +b.toExponential(4); +b.toExponential(2); diff --git a/test/rules/no-magic-numbers/default/tslint.json b/test/rules/no-magic-numbers/default/tslint.json new file mode 100644 index 00000000000..13ce3e0dab0 --- /dev/null +++ b/test/rules/no-magic-numbers/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-magic-numbers": true + } +} diff --git a/test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint b/test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint new file mode 100644 index 00000000000..77e9a1bf651 --- /dev/null +++ b/test/rules/no-magic-numbers/ignore-jsx/test.tsx.lint @@ -0,0 +1,10 @@ +import * as React from "react"; +class App extends React.Component { + render() { + return ; + } +} + +function something(num) {} +something(100) + ~~~ ['magic numbers' are not allowed: 100] diff --git a/test/rules/no-magic-numbers/ignore-jsx/tslint.json b/test/rules/no-magic-numbers/ignore-jsx/tslint.json new file mode 100644 index 00000000000..d0d81589636 --- /dev/null +++ b/test/rules/no-magic-numbers/ignore-jsx/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-magic-numbers": [true, { + "ignore-jsx": true + }] + } +} diff --git a/test/rules/no-mergeable-namespace/test.ts.lint b/test/rules/no-mergeable-namespace/test.ts.lint new file mode 100644 index 00000000000..9e884966eee --- /dev/null +++ b/test/rules/no-mergeable-namespace/test.ts.lint @@ -0,0 +1,41 @@ +// valid case +var foo; +namespace foo{ + namespace foo {} +} +declare module buzz {} +module bar {} + +// invalid case +namespace a {} +namespace a {} + ~ [err % ('a', '10')] + +namespace b { + namespace b {} + namespace b {} + ~ [err % ('b', '14')] + namespace b {} + ~ [err % ('b', '15')] +} + +namespace x.y {} +namespace x { namespace y{} } + ~ [err % ('x', '19')] + +namespace m.n { + namespace l {} + namespace l {} + ~ [err % ('l', '23')] +} + +module "foo" { + // Different than outer 'a' + namespace a {} + + namespace q {} + namespace q {} + ~ [err % ('q', '31')] +} + +[err]: Mergeable namespace '%s' found. Merge its contents with the namespace on line %s. diff --git a/test/rules/no-mergeable-namespace/tslint.json b/test/rules/no-mergeable-namespace/tslint.json new file mode 100644 index 00000000000..74cde33b4d0 --- /dev/null +++ b/test/rules/no-mergeable-namespace/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-mergeable-namespace": true + } +} diff --git a/test/rules/no-misused-new/test.ts.lint b/test/rules/no-misused-new/test.ts.lint new file mode 100644 index 00000000000..f1ed5ca1120 --- /dev/null +++ b/test/rules/no-misused-new/test.ts.lint @@ -0,0 +1,32 @@ +interface I { + new(): I; + ~~~~~~~~~ [0] + // OK if return type is not the interface. + new(): {}; + constructor(): void; + ~~~~~~~~~~~~~~~~~~~~ [0] +} + +// Works for generic type. +interface G { + new(): G; + ~~~~~~~~~~~~~~~ [0] +} + +type T = { + // `new` OK in type literal (we don't know the type name) + new(): T; + // `constructor` still flagged. + constructor(): void; + ~~~~~~~~~~~~~~~~~~~~ [0] +} + +class C { + new(): C; + ~~~~~~~~~ [1] + // OK if there's a body + new() {} +} + +[0]: Interfaces cannot be constructed, only classes. Did you mean `declare class`? +[1]: `new` in a class is a method named "new". Did you mean `constructor`? diff --git a/test/rules/no-misused-new/tslint.json b/test/rules/no-misused-new/tslint.json new file mode 100644 index 00000000000..87f36324069 --- /dev/null +++ b/test/rules/no-misused-new/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-misused-new": true + } +} diff --git a/test/rules/no-namespace/allow-declarations/test.d.ts.lint b/test/rules/no-namespace/allow-declarations/test.d.ts.lint new file mode 100644 index 00000000000..28cba058e92 --- /dev/null +++ b/test/rules/no-namespace/allow-declarations/test.d.ts.lint @@ -0,0 +1 @@ +namespace N { } diff --git a/test/rules/no-namespace/allow-declarations/test.ts.lint b/test/rules/no-namespace/allow-declarations/test.ts.lint new file mode 100644 index 00000000000..d60730eae44 --- /dev/null +++ b/test/rules/no-namespace/allow-declarations/test.ts.lint @@ -0,0 +1,8 @@ +declare global {} + +declare namespace Foo { + // Allowed because namespaces nested in ambients are implicitly ambient. + namespace Foo { + + } +} diff --git a/test/rules/no-namespace/allow-declarations/tslint.json b/test/rules/no-namespace/allow-declarations/tslint.json new file mode 100644 index 00000000000..b90b9030e34 --- /dev/null +++ b/test/rules/no-namespace/allow-declarations/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-namespace": [true, "allow-declarations"] + } +} diff --git a/test/rules/no-namespace/default/test.d.ts.lint b/test/rules/no-namespace/default/test.d.ts.lint new file mode 100644 index 00000000000..eb104f9c9e7 --- /dev/null +++ b/test/rules/no-namespace/default/test.d.ts.lint @@ -0,0 +1,2 @@ +namespace N { } +~~~~~~~~~~~~~~~ ['namespace' and 'module' are disallowed] diff --git a/test/rules/no-namespace/default/test.ts.lint b/test/rules/no-namespace/default/test.ts.lint new file mode 100644 index 00000000000..7bce2405982 --- /dev/null +++ b/test/rules/no-namespace/default/test.ts.lint @@ -0,0 +1,25 @@ +namespace Foo { +~~~~~~~~~~~~~~~ +} +~ ['namespace' and 'module' are disallowed] +namespace Foo.Bar { +~~~~~~~~~~~~~~~~~~~ +} +~ ['namespace' and 'module' are disallowed] + +module Foo { +~~~~~~~~~~~~ +} +~ ['namespace' and 'module' are disallowed] + +declare namespace Foo { +~~~~~~~~~~~~~~~~~~~~~~~ +} +~ ['namespace' and 'module' are disallowed] + +declare module 'foo' { +} + +declare global { + interface Foo {} +} diff --git a/test/rules/no-namespace/default/tslint.json b/test/rules/no-namespace/default/tslint.json new file mode 100644 index 00000000000..6958cd0e9b5 --- /dev/null +++ b/test/rules/no-namespace/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-namespace": [true] + } +} diff --git a/test/rules/no-non-null-assertion/test.ts.lint b/test/rules/no-non-null-assertion/test.ts.lint new file mode 100644 index 00000000000..12bb8af725d --- /dev/null +++ b/test/rules/no-non-null-assertion/test.ts.lint @@ -0,0 +1,4 @@ +var x = null + +x!.y = null +~~ [Forbidden non null assertion] diff --git a/test/rules/no-non-null-assertion/tslint.json b/test/rules/no-non-null-assertion/tslint.json new file mode 100644 index 00000000000..6359b34ac55 --- /dev/null +++ b/test/rules/no-non-null-assertion/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-non-null-assertion": true + } +} diff --git a/test/rules/no-null-keyword/test.ts.fix b/test/rules/no-null-keyword/test.ts.fix new file mode 100644 index 00000000000..5a43ae107d8 --- /dev/null +++ b/test/rules/no-null-keyword/test.ts.fix @@ -0,0 +1,12 @@ +var x = null; // error +console.log(null, x); // error + +let match: string | null; +interface foo { + bar: [number, null, string]; +} + +if (document.querySelector('.foo') === null) {} +if (document.querySelector('.foo') == undefined) {} +if (null !== document.querySelector('.foo')) {} +if (undefined != document.querySelector('.foo')) {} diff --git a/test/rules/no-null-keyword/test.ts.lint b/test/rules/no-null-keyword/test.ts.lint new file mode 100644 index 00000000000..92248e37a1f --- /dev/null +++ b/test/rules/no-null-keyword/test.ts.lint @@ -0,0 +1,18 @@ +var x = null; // error + ~~~~ [0] +console.log(null, x); // error + ~~~~ [0] + +let match: string | null; +interface foo { + bar: [number, null, string]; +} + +if (document.querySelector('.foo') === null) {} +if (document.querySelector('.foo') == null) {} + ~~~~ [0] +if (null !== document.querySelector('.foo')) {} +if (null != document.querySelector('.foo')) {} + ~~~~ [0] + +[0]: Use 'undefined' instead of 'null' \ No newline at end of file diff --git a/test/rules/no-null-keyword/tslint.json b/test/rules/no-null-keyword/tslint.json new file mode 100644 index 00000000000..1e4bf06a307 --- /dev/null +++ b/test/rules/no-null-keyword/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-null-keyword": true + } +} diff --git a/test/rules/no-null-undefined-union/test.ts.lint b/test/rules/no-null-undefined-union/test.ts.lint new file mode 100644 index 00000000000..5b7df70469b --- /dev/null +++ b/test/rules/no-null-undefined-union/test.ts.lint @@ -0,0 +1,85 @@ +[typescript]: >= 2.4.0 < 3.5.0 + +// Catches explicit union types. + +type SomeType = + + | null + ~~~~ + | undefined +~~~~~~~~~~~~~~~ + | boolean; +~~~~~~~~~~~~~ [0] + +const c: string | null | undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const someFunc = (): string | undefined | null => {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const someFunc = (foo: null | string | undefined, bar: boolean) => {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +interface SomeInterface { + foo: number | null | undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + bar: boolean; +} + +function someFunc(): Promise {} // error + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +function someFunc(bar: boolean, foo: undefined | number | null) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +// Catches implicit return types. + +function testFunc() { +~~~~~~~~~~~~~~~~~~~~~ + const somePredicate = (): boolean => true; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const someFunc = (): string | null => null; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + let foo; +~~~~~~~~~~~~ + if (somePredicate()) { +~~~~~~~~~~~~~~~~~~~~~~~~~~ + foo = someFunc(); +~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ + return foo; +~~~~~~~~~~~~~~~ +} +~ [0] + +// Does not consider ? as shorthand for undefined. + +type Text = string | null + +interface TextInterface { + foo?: Text +} + +interface SuperTextInterface { + bar?: Text | number +} + +function someFunc(foo?: Text, bar?: Text | number) {} + +// Ignores implicit union types. + +const x: SomeType; + +const someFunc = (): SomeType => {} + +function(foo: SomeInterface) {} + +const y = testFunc(); + +// Unless they are explicitly unioned. + +const z: Text | undefined; + ~~~~~~~~~~~~~~~~ [0] + +[0]: Union type cannot include both 'null' and 'undefined'. diff --git a/test/rules/no-null-undefined-union/ts350.ts.lint b/test/rules/no-null-undefined-union/ts350.ts.lint new file mode 100644 index 00000000000..a6a907edcd5 --- /dev/null +++ b/test/rules/no-null-undefined-union/ts350.ts.lint @@ -0,0 +1,12 @@ +[typescript]: >= 3.5.0 + +type SomeType = + + | null + ~~~~~~ + | undefined +~~~~~~~~~~~~~~~ + | boolean; +~~~~~~~~~~~~~ [0] + +[0]: Union type cannot include both 'null' and 'undefined'. diff --git a/test/rules/no-null-undefined-union/tsconfig.json b/test/rules/no-null-undefined-union/tsconfig.json new file mode 100644 index 00000000000..d81c1202adb --- /dev/null +++ b/test/rules/no-null-undefined-union/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "downlevelIteration": true, + "experimentalDecorators": true, + "importHelpers": true, + "jsx": "react", + "lib": [ + "es5", + "es2015", + "es2016", + "es2017" + ], + "module": "commonjs", + "moduleResolution": "node", + "strict": true, + "stripInternal": true, + "target": "es5" + } +} diff --git a/test/rules/no-null-undefined-union/tslint.json b/test/rules/no-null-undefined-union/tslint.json new file mode 100644 index 00000000000..f41c08c7b72 --- /dev/null +++ b/test/rules/no-null-undefined-union/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-null-undefined-union": true + } +} diff --git a/test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint b/test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint new file mode 100644 index 00000000000..ba5f37ee442 --- /dev/null +++ b/test/rules/no-object-literal-type-assertion/allow-arguments/test.ts.lint @@ -0,0 +1,23 @@ + ({}); +~~~~~~~~ [0] + +({}) as T; +~~~~~~~~~ [0] + + x; + +x as T; + +// Allow cast to 'any' +{} as any; + {}; + +// Allow cast to 'unknown' +{} as unknown; + {}; + +// Allow object literals to be asserted when used as arguments. +foo({} as T); +foo({}); + +[0]: Type assertion on object literals is forbidden, use a type annotation instead. diff --git a/test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json b/test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json new file mode 100644 index 00000000000..6dad916f47d --- /dev/null +++ b/test/rules/no-object-literal-type-assertion/allow-arguments/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-object-literal-type-assertion": [true, { "allow-arguments": true }] + } +} diff --git a/test/rules/no-object-literal-type-assertion/default/test.ts.lint b/test/rules/no-object-literal-type-assertion/default/test.ts.lint new file mode 100644 index 00000000000..53a555a4710 --- /dev/null +++ b/test/rules/no-object-literal-type-assertion/default/test.ts.lint @@ -0,0 +1,31 @@ + ({}); +~~~~~~~~ [0] + +({}) as T; +~~~~~~~~~ [0] + + x; + +x as T; + +// Allow cast to 'any' +{} as any; + {}; + +// Allow cast to 'unknown' +{} as unknown; + {}; + +#if typescript >= 3.4.0 +// Allow const assertion +({}) as const; + ({}); +#endif + +foo({} as T); + ~~~~~~~ [0] + +foo({}); + ~~~~~ [0] + +[0]: Type assertion on object literals is forbidden, use a type annotation instead. diff --git a/test/rules/no-object-literal-type-assertion/default/tslint.json b/test/rules/no-object-literal-type-assertion/default/tslint.json new file mode 100644 index 00000000000..98063421083 --- /dev/null +++ b/test/rules/no-object-literal-type-assertion/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-object-literal-type-assertion": true + } +} diff --git a/test/rules/no-parameter-properties/test.ts.lint b/test/rules/no-parameter-properties/test.ts.lint new file mode 100644 index 00000000000..49f957f1cad --- /dev/null +++ b/test/rules/no-parameter-properties/test.ts.lint @@ -0,0 +1,24 @@ +class Class1 { + // one error + constructor(private foo: string) { + ~~~~~~~ [err % ('foo')] + } +} + +class Class2 { + // three errors, last one is correct + // don't crash if name is not an identifier + constructor(private foo: string, public bar: string, qux: any, readonly {baz}: any) { + ~~~~~~~ [err % ('foo')] + ~~~~~~ [err % ('bar')] + ~~~~~~~~ [err % ('{baz}')] + } +} + +class Class3 { + // no errors + constructor() { + } +} + +[err]: Property '%s' cannot be declared in the constructor \ No newline at end of file diff --git a/test/rules/no-parameter-properties/tslint.json b/test/rules/no-parameter-properties/tslint.json new file mode 100644 index 00000000000..c65a294034b --- /dev/null +++ b/test/rules/no-parameter-properties/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-parameter-properties": true + } +} diff --git a/test/rules/no-parameter-reassignment/test.ts.lint b/test/rules/no-parameter-reassignment/test.ts.lint new file mode 100644 index 00000000000..550ba46a186 --- /dev/null +++ b/test/rules/no-parameter-reassignment/test.ts.lint @@ -0,0 +1,34 @@ +function f1(foo = "") {} + +function f2([foo = 0]: number[]) {} + +function f3(foo: number) { + foo; +} + +let noParam: number = 0; +noParam++; +noParam = 0; +let [alsoNoParam] = [0]; +--alsoNoParam; + +function f4(foo: number, {bar}: {bar: number}, baz: string) { + --noParam; + alsoNoParam += alsoNoParam; + foo += 1; + ~~~ [err % ('foo')] + foo++; + ~~~ [err % ('foo')] + --foo; + ~~~ [err % ('foo')] + foo += foo; + ~~~ [err % ('foo')] + ({foo} = {foo: 1}); + ~~~ [err % ('foo')] + for (bar of arr) {} + ~~~ [err % ('bar')] + for (baz in obj) {} + ~~~ [err % ('baz')] +} + +[err]: Reassigning parameter '%s' is forbidden. diff --git a/test/rules/no-parameter-reassignment/tslint.json b/test/rules/no-parameter-reassignment/tslint.json new file mode 100644 index 00000000000..f5b8846ea7d --- /dev/null +++ b/test/rules/no-parameter-reassignment/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-parameter-reassignment": true + } +} diff --git a/test/rules/no-promise-as-boolean/custom-promise/test.ts.lint b/test/rules/no-promise-as-boolean/custom-promise/test.ts.lint new file mode 100644 index 00000000000..57a4b051488 --- /dev/null +++ b/test/rules/no-promise-as-boolean/custom-promise/test.ts.lint @@ -0,0 +1,37 @@ +[typescript]: >= 2.4.0 + +async function promiseFunc() { + return false; +} + +class CustomPromise {} +const customPromise = new CustomPromise(); + +// Custom promise +if (customPromise) {} + ~~~~~~~~~~~~~ [0] + +normalExpression = customPromise; +const stringLiteral = "text" + customPromise; + +const globalUnaryExpression = !!customPromise; + ~~~~~~~~~~~~~ [0] + +const globalBinaryExpression = "text" && customPromise; + ~~~~~~~~~~~~~ [0] + +customPromise && console.log("topLevelBinaryExpression"); +~~~~~~~~~~~~~ [0] + +function union(promiseOrUndefined: CustomPromise | undefined, promiseOrFalse: CustomPromise | false, promiseOrNull: CustomPromise | null) { + if (promiseOrUndefined || promiseOrFalse || promiseOrNull) { + return; + } +} + +function normalUrCustomPromise(onlyPromise: CustomPromise | Promise, promiseOrNull: CustomPromise | Promise | null) { + if (onlyPromise && promiseOrNull) { } + ~~~~~~~~~~~ [0] +} + +[0]: Promises are not allowed as boolean. diff --git a/test/rules/no-promise-as-boolean/custom-promise/tsconfig.json b/test/rules/no-promise-as-boolean/custom-promise/tsconfig.json new file mode 100644 index 00000000000..f8f3eb52d44 --- /dev/null +++ b/test/rules/no-promise-as-boolean/custom-promise/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es6" + } +} diff --git a/test/rules/no-promise-as-boolean/custom-promise/tslint.json b/test/rules/no-promise-as-boolean/custom-promise/tslint.json new file mode 100644 index 00000000000..654b35ecb70 --- /dev/null +++ b/test/rules/no-promise-as-boolean/custom-promise/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-promise-as-boolean": [true, { "promise-classes": ["CustomPromise"] }] + } +} diff --git a/test/rules/no-promise-as-boolean/es6-promise/test.ts.lint b/test/rules/no-promise-as-boolean/es6-promise/test.ts.lint new file mode 100644 index 00000000000..ba86acaed03 --- /dev/null +++ b/test/rules/no-promise-as-boolean/es6-promise/test.ts.lint @@ -0,0 +1,66 @@ +[typescript]: >= 2.4.0 + +async function promiseFunc() { + return false; +} + +normalExpression = promiseFunc(); +const stringLiteral = "text" + promiseFunc(); + +const globalUnaryExpression = !!promiseFunc(); + ~~~~~~~~~~~~~ [0] + +const globalBinaryExpression = "text" && promiseFunc(); + ~~~~~~~~~~~~~ [0] + +promiseFunc() && console.log("topLevelBinaryExpression"); +~~~~~~~~~~~~~ [0] + +function union(promiseOrUndefined: Promise | undefined, promiseOrFalse: Promise | false, promiseOrNull: Promise | null) { + if (promiseOrUndefined || promiseOrFalse || promiseOrNull) { + return; + } +}; + +function funky(maybePromise?: Promise) { + while (promiseFunc() && maybePromise) { + ~~~~~~~~~~~~~ [0] + + const binaryExpression = (promiseFunc() && "1") || ("1" && !promiseFunc()) ? ("1" && promiseFunc() ? "1" : "1") : maybePromise; + ~~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~~ [0] + + // For-loop + for (let index = 0; promiseFunc(); index++) { + ~~~~~~~~~~~~~ [0] + + // a non-promise + if ("just some text" + promiseFunc()) { + + // Promise literal + } else if (new Promise(() => { })) { + ~~~~~~~~~~~~~~~~~~~~~~ [0] + + // Nested Promise + if (promiseFunc()) { + ~~~~~~~~~~~~~ [0] + } + + // Parenthesized Expression + Exclamation Tokens + } else if (promiseFunc() && !!promiseFunc()) { + ~~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~~ [0] + } + } + } +} + +async function waiter(custumerDecisionPromise: Promise) { + if (await custumerDecisionPromise) { + console.log("Customer ready to take an order.") + } +} + +[0]: Promises are not allowed as boolean. diff --git a/test/rules/no-promise-as-boolean/es6-promise/tsconfig.json b/test/rules/no-promise-as-boolean/es6-promise/tsconfig.json new file mode 100644 index 00000000000..f8f3eb52d44 --- /dev/null +++ b/test/rules/no-promise-as-boolean/es6-promise/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es6" + } +} diff --git a/test/rules/no-promise-as-boolean/es6-promise/tslint.json b/test/rules/no-promise-as-boolean/es6-promise/tslint.json new file mode 100644 index 00000000000..88591c2c285 --- /dev/null +++ b/test/rules/no-promise-as-boolean/es6-promise/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-promise-as-boolean": true + } +} diff --git a/test/rules/no-redundant-jsdoc/test.ts.lint b/test/rules/no-redundant-jsdoc/test.ts.lint new file mode 100644 index 00000000000..6711a859702 --- /dev/null +++ b/test/rules/no-redundant-jsdoc/test.ts.lint @@ -0,0 +1,59 @@ +/** @typedef {number} T */ + ~~~~~~~ [tag % ('typedef')] + +/** @function + ~~~~~~~~ [tag % ('function')] + * @this + ~~~~ [tag % ('this')] + */ +function f() {} + +/** @type number */ + ~~~~ [tag % ('type')] +const x = 0; + +/** + * @class + ~~~~~ [tag % ('class')] + * @this {} + ~~~~ [tag % ('this')] + * @param {number} x Is a number + ~~~~~~~~ [type] + * @param y + ~~~~~ [param] + * @param {number} z + ~~~~~ [param] + ~~~~~~~~ [type] + * @returns {number} + ~~~~~~~ [returns] + ~~~~~~~~ [type] + */ +declare function g(x: number, y: number, z: number): number; + +/** + * @this {SomeClass} + ~~~~ [tag % ('this')] + */ +declare function h(); + +/** + * @author John Doe + * @param x Useful comment + * @returns Useful comment + */ +declare function i(x: number): number; + +/** + * @template T, U +#if typescript < 2.2.0 || >= 2.3.0 + ~~~~~~~~ [description % ('template')] +#endif + * @template V Some additional information + */ +declare function j(x: T, y: V): U; + +[tag]: JSDoc tag '@%s' is redundant in TypeScript code. +[type]: Type annotation in JSDoc is redundant in TypeScript code. +[description]: '@%s' is redundant in TypeScript code if it has no description. +[param]: description % ('param') +[returns]: description % ('returns') diff --git a/test/rules/no-redundant-jsdoc/tslint.json b/test/rules/no-redundant-jsdoc/tslint.json new file mode 100644 index 00000000000..b7cc878baac --- /dev/null +++ b/test/rules/no-redundant-jsdoc/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-redundant-jsdoc": true + } +} diff --git a/test/rules/no-reference-import/test.d.ts.lint b/test/rules/no-reference-import/test.d.ts.lint new file mode 100644 index 00000000000..ba9a8709347 --- /dev/null +++ b/test/rules/no-reference-import/test.d.ts.lint @@ -0,0 +1,12 @@ +[typescript]: <2.4.0 +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [No need to reference "foo", since it is imported.] +/// +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [No need to reference "baz", since it is imported.] + +import * as foo from "foo"; + +declare module "quux" { + import * as baz from "baz"; +} diff --git a/test/rules/no-reference-import/ts240.d.ts.lint b/test/rules/no-reference-import/ts240.d.ts.lint new file mode 100644 index 00000000000..56d2baf3e41 --- /dev/null +++ b/test/rules/no-reference-import/ts240.d.ts.lint @@ -0,0 +1,12 @@ +[typescript]: >=2.4.0 +/// + ~~~ [No need to reference "foo", since it is imported.] +/// +/// + ~~~ [No need to reference "baz", since it is imported.] + +import * as foo from "foo"; + +declare module "quux" { + import * as baz from "baz"; +} diff --git a/test/rules/no-reference-import/tslint.json b/test/rules/no-reference-import/tslint.json new file mode 100644 index 00000000000..4809ce73100 --- /dev/null +++ b/test/rules/no-reference-import/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-reference-import": true + } +} diff --git a/test/rules/no-reference/test.ts.lint b/test/rules/no-reference/test.ts.lint new file mode 100644 index 00000000000..cb833f0f9be --- /dev/null +++ b/test/rules/no-reference/test.ts.lint @@ -0,0 +1,3 @@ +[typescript]: <2.4.0 +/// +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ is not allowed, use imports] diff --git a/test/rules/no-reference/ts240.ts.lint b/test/rules/no-reference/ts240.ts.lint new file mode 100644 index 00000000000..4806cef6f23 --- /dev/null +++ b/test/rules/no-reference/ts240.ts.lint @@ -0,0 +1,3 @@ +[typescript]: >=2.4.0 +/// + ~~~~~~~~~~~~ [ is not allowed, use imports] diff --git a/test/rules/no-reference/tslint.json b/test/rules/no-reference/tslint.json new file mode 100644 index 00000000000..6a925a49578 --- /dev/null +++ b/test/rules/no-reference/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-reference": true + } +} diff --git a/test/rules/no-require-imports/test.ts.lint b/test/rules/no-require-imports/test.ts.lint new file mode 100644 index 00000000000..b54741ed2b8 --- /dev/null +++ b/test/rules/no-require-imports/test.ts.lint @@ -0,0 +1,24 @@ +var lib = require('lib'); // failure + ~~~~~~~~~~~~~~ [no-require] + +let lib2 = require('lib2'); // failure + ~~~~~~~~~~~~~~~ [no-require] + +import {l} from 'lib'; + +var lib3 = load('not_an_import'); + +var lib4 = lib2.subImport; + +var lib5 = require('lib5'), // failure + ~~~~~~~~~~~~~~~ [no-require] + lib6 = require('lib6'), // failure + ~~~~~~~~~~~~~~~ [no-require] + lib7 = 700; + +import lib8 = require('lib8'); // failure + ~~~~~~~~~~~~~~~ [no-require] + +import lib9 = lib2.anotherSubImport; + +[no-require]: require() style import is forbidden diff --git a/test/rules/no-require-imports/tslint.json b/test/rules/no-require-imports/tslint.json new file mode 100644 index 00000000000..39bc26f8312 --- /dev/null +++ b/test/rules/no-require-imports/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-require-imports": true + } +} diff --git a/test/rules/no-restricted-globals/custom-global.d.ts b/test/rules/no-restricted-globals/custom-global.d.ts new file mode 100644 index 00000000000..e981c8a88cf --- /dev/null +++ b/test/rules/no-restricted-globals/custom-global.d.ts @@ -0,0 +1,2 @@ +declare var badGlobal: any; +declare var goodGlobal: any; \ No newline at end of file diff --git a/test/rules/no-restricted-globals/foo.d.ts b/test/rules/no-restricted-globals/foo.d.ts new file mode 100644 index 00000000000..30f811d837f --- /dev/null +++ b/test/rules/no-restricted-globals/foo.d.ts @@ -0,0 +1 @@ +export var name: string; \ No newline at end of file diff --git a/test/rules/no-restricted-globals/namespace.ts.lint b/test/rules/no-restricted-globals/namespace.ts.lint new file mode 100644 index 00000000000..5fe8939d5c6 --- /dev/null +++ b/test/rules/no-restricted-globals/namespace.ts.lint @@ -0,0 +1,10 @@ +console.log(name); + ~~~~ [Unexpected global variable 'name'. Use a local parameter or variable instead.] + +namespace A { + const foo = name; +} + +namespace A { + export var name = 23; +} \ No newline at end of file diff --git a/test/rules/no-restricted-globals/test.ts.lint b/test/rules/no-restricted-globals/test.ts.lint new file mode 100644 index 00000000000..2fb6b4c5521 --- /dev/null +++ b/test/rules/no-restricted-globals/test.ts.lint @@ -0,0 +1,75 @@ +function foo(evt: Event) { + let length: number = 1; + console.log(length); + + Event.target; + + event.target; + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] +} + +console.log(length); + ~~~~~~ [Unexpected global variable 'length'. Use a local parameter or variable instead.] + +import { name } from "./foo"; +import "./custom-global" +console.log(name); + +console.log(badGlobal); + ~~~~~~~~~ [Unexpected global variable 'badGlobal'. Use a local parameter or variable instead.] + +console.log(goodGlobal); + +let { foo = event } = bar + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] + +let { foo = (() => event)() } = bar; + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] + +let foo: typeof event; + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] + +function rest() { + const { bar, ...event } = foo; +} + +function nested() { + const { bar, event: { x: y } } = foo; +} + +function initializer() { + const { bar, length = () => event } = foo; + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] +} + +function nestedInitializer() { + const { bar, length: { x: y = () => event } } = foo; + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] +} + +function computedProperty() { + const { [event.type]: x } = foo; + ~~~~~ [Unexpected global variable 'event'. Use a local parameter or variable instead.] +} + +function typeTest() { + type name = any; +} + +function functionTest () { + const foo = name; + + function name () { + + } +} + +function interfaceTest() { + var foo: name; + interface name {} +} + +function classTest() { + const foo = new name(); + class name {} +} \ No newline at end of file diff --git a/test/rules/no-restricted-globals/tsconfig.json b/test/rules/no-restricted-globals/tsconfig.json new file mode 100644 index 00000000000..3039d056863 --- /dev/null +++ b/test/rules/no-restricted-globals/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom" + ] + } +} diff --git a/test/rules/no-restricted-globals/tslint.json b/test/rules/no-restricted-globals/tslint.json new file mode 100644 index 00000000000..4c2950318f4 --- /dev/null +++ b/test/rules/no-restricted-globals/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "no-restricted-globals": [ + true, + "name", + "length", + "event", + "badGlobal" + ] + } +} diff --git a/test/rules/no-return-await/test.ts.fix b/test/rules/no-return-await/test.ts.fix new file mode 100644 index 00000000000..23b56babfaa --- /dev/null +++ b/test/rules/no-return-await/test.ts.fix @@ -0,0 +1,80 @@ +async function foo() { + return x; +} +(async () => x); + +async function allowTypeAssertion() { + return (await x)!; + return (await x as number); + return await x; +} +async function allowedInsideTryCatch() { + try { + return await x; + } catch (e) { + // handle error + return x; // not allowed in catch when there is no finally + } +} +async function allowedInsideTryFinally() { + try { + return await x; + } finally { + // do cleanup, close connection for example + return x; // not allowed in finally at all + } +} +async function allowedInsideCatchFinally() { + try { + return await x; + } catch (e) { + return await x; + } finally { + return x; + } +} +async function nestedTryStatements() { + try { + try { + return await x; + } catch (e) { + return await x; + } finally { + return await foobar; + } + } catch(e) { + try { + return await x; + } catch (e) { + return await x; + } finally { + return await foobar; + } + } finally { + try { + return await x; + } catch (e) { + return await x; + } finally { + return x; + } + } +} + +async function handleParens() { + return (x); +} +async function handleBinaryExpression() { + return await foo || x; + return await foo && x; + return await foo, x; + return await foo + await bar; +} +async function handleConditionalExpression() { + return await foo ? bar : baz; +} + +throw await x; +await x; +return x; + diff --git a/test/rules/no-return-await/test.ts.lint b/test/rules/no-return-await/test.ts.lint new file mode 100644 index 00000000000..57fac556b11 --- /dev/null +++ b/test/rules/no-return-await/test.ts.lint @@ -0,0 +1,94 @@ +async function foo() { + return await x; + ~~~~~ [0] +} +(async () => await x); + ~~~~~ [0] + +async function allowTypeAssertion() { + return (await x)!; + return (await x as number); + return await x; +} +async function allowedInsideTryCatch() { + try { + return await x; + } catch (e) { + // handle error + return await x; // not allowed in catch when there is no finally + ~~~~~ [0] + } +} +async function allowedInsideTryFinally() { + try { + return await x; + } finally { + // do cleanup, close connection for example + return await x; // not allowed in finally at all + ~~~~~ [0] + } +} +async function allowedInsideCatchFinally() { + try { + return await x; + } catch (e) { + return await x; + } finally { + return await x; + ~~~~~ [0] + } +} +async function nestedTryStatements() { + try { + try { + return await x; + } catch (e) { + return await x; + } finally { + return await foobar; + } + } catch(e) { + try { + return await x; + } catch (e) { + return await x; + } finally { + return await foobar; + } + } finally { + try { + return await x; + } catch (e) { + return await x; + } finally { + return await x; + ~~~~~ [0] + } + } +} + +async function handleParens() { + return (await x); + ~~~~~ [0] +} +async function handleBinaryExpression() { + return await foo || await x; + ~~~~~ [0] + return await foo && await x; + ~~~~~ [0] + return await foo, await x; + ~~~~~ [0] + return await foo + await bar; +} +async function handleConditionalExpression() { + return await foo ? await bar : await baz; + ~~~~~ [0] + ~~~~~ [0] +} + +throw await x; +await x; +return await x; + ~~~~~ [0] + +[0]: Unnecessary 'await'. diff --git a/test/rules/no-return-await/tslint.json b/test/rules/no-return-await/tslint.json new file mode 100644 index 00000000000..56764d25ff0 --- /dev/null +++ b/test/rules/no-return-await/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-return-await": true + } +} diff --git a/test/rules/no-shadowed-variable/default/ambient.d.ts.lint b/test/rules/no-shadowed-variable/default/ambient.d.ts.lint new file mode 100644 index 00000000000..a629aba6c7e --- /dev/null +++ b/test/rules/no-shadowed-variable/default/ambient.d.ts.lint @@ -0,0 +1,7 @@ +// no errors in declaration files +declare type T = any; +declare class C {} +declare namespace ns { + type T = C; + class C {} +} diff --git a/test/rules/no-shadowed-variable/default/test.ts.lint b/test/rules/no-shadowed-variable/default/test.ts.lint new file mode 100644 index 00000000000..b7d372cd6d8 --- /dev/null +++ b/test/rules/no-shadowed-variable/default/test.ts.lint @@ -0,0 +1,384 @@ +import { Foo } from './foo'; +import * as Bar from '.bar'; +import Baz from './baz'; +import Bas = require('./bas'); +import _ = require('lodash'); +{ + const Foo = 'bar'; + ~~~ [err % ('Foo')] + const Bar = Foo; + ~~~ [err % ('Bar')] + const Baz = Bar; + ~~~ [err % ('Baz')] + const Bas = Baz; + ~~~ [err % ('Bas')] + const _ = _; + ~ [err % ('_')] +} +function letTesting() { + var a = 1; + ~ [err % ('a')] + let b = 1; + + if (true) { + let a = 2; // failure + ~ [err % ('a')] + let b = 2; // failure + ~ [err % ('b')] + let c = 2; + var e = 2; + } else { + let b = 3; // failure + ~ [err % ('b')] + let c = 3; + let e = 3; // failure + ~ [err % ('e')] + let f = 3; + ~ [err % ('f')] + } + + var f = 4; + ~ [err % ('f')] +} + +let a = 1; +if (true) { + let a = 2; // failure + ~ [err % ('a')] +} + +var g = 1; +for (var index in [0, 1, 2]) { + let g = 2; // failure + ~ [err % ('g')] +} + +function constTesting() { + var h = 1; + const i = 1; + + if (true) { + const h = 2; // failure + ~ [err % ('h')] + const i = 2; // failure + ~ [err % ('i')] + } +} + +function testArguments(x: number, y: number): void { + var x = 1; // failure + let y = 2; // tsc error +} + +let j = 1; +for (var index in [0, 1, 2]) { + let j = 2; // failure + ~ [err % ('j')] +} + +function testTryStatement() { + try { + let foo = 1; + throw new Error(); + } catch (e) { + let foo = 2; + var bar = 2; + } finally { + let foo = 3; + let bar = 3; // failure + ~~~ [err % ('bar')] + } +} + +function testWhileStatement() { + let foo = 1; + + while (true) { + let foo = 2; // failure + ~~~ [err % ('foo')] + } +} + +function testDoStatement() { + let foo = 1; + + do { + let foo = 2; // failure + ~~~ [err % ('foo')] + } while (true); +} + +function testDestructuring(x: number) { + var {y, z} = {y: 2, z: 3}; + + function myFunc() { + return [1]; + } + + function innerFunc() { + var [foo] = myFunc(); + var [x] = myFunc(); // failure + ~ [err % ('x')] + let [y] = myFunc(); // failure + ~ [err % ('y')] + const [z] = myFunc(); // failure + ~ [err % ('z')] + } + + function anotherInnerFunc() { + var [{x}] = [{x: 1}]; // failure + ~ [err % ('x')] + let [[y]] = [[2]]; // failure + ~ [err % ('y')] + var [foo, ...bar] = [1, 2, 3, 4]; + var [...z] = [1, 2, 3, 4]; // failure + ~ [err % ('z')] + } +} + +function falsePositive1(bar: (okay1: any) => void) { + let okay1 = 1; +} + +function falsePositive2(okay2: any, done: (okay2: any) => void) { } + +interface FalsePositive3 { + diffuse: (pos: number) => number; + specular: (pos: number) => number; + pos: number; +} + +interface FalsePositive4 { + (parameters: T, runSynchonous: boolean): TResult; + (parameters: T, callback: (error: Error, result: TResult) => void): void; +} + +let p = 1; +function testParameterDestructuring( + { pos: p }: FalsePositive3, // failure + ~ [err % ('p')] + { pos: q, specular: r }: FalsePositive3, + { pos }: FalsePositive3 +) { + p = 2; + var q = 1; // merges with parameter, should use no-duplicate-variable to catch this + + function someInnerFunc() { + let pos = 3; // failure + ~~~ [err % ('pos')] + } +} + + +{ + const simpleBlockVar = 3 +} + +function testSimpleBlockVar() { + const simpleBlockVar = 4 +} + +interface SeparateIndexeSighatures1 { + [separate: string]: any; +} +interface SeparateIndexeSighatures2 { + [separate: number]: any; +} + +const external = 1; +interface ExternalIndexSignature1 { + [external: string]: any; +} +interface ExternalIndexSignature2 { + [external: number]: any; +} + +interface CombinedIndexeSighatures { + [i: string]: any; + [i: number]: any; +} + +function constructorsWithArgs( + derivedCtor: new (...args: any[]) => any, + baseCtors: Array any>): void { + // ... +} + +function constructorsWithArgsConst( + derivedCtor: new (...args: any[]) => any, + baseCtors: Array any>): void { + const args = []; +} + +function constructorsWithArgsParamConst( + derivedCtor: new (...args: any[]) => any, + baseCtors: Array any>, + args: any[]): void { + { + const args = []; + ~~~~ [err % ('args')] + } +} + +class MyClass { }; + +declare type MyConstructor = new (myVariable: any) => MyClass; +declare type MyFunction = (myParameter: any) => boolean; + +function creatorFunction(constructor: MyConstructor, filter: MyFunction): void { + const myVariable = 1; + const myParameter = 1; + console.log(myVariable); +} + +for (let i = 0; i < 3; i++) { + let i = 34; + ~ [err % ('i')] +} + +(function f1() { + let f1; + ~~ [err % ('f1')] +})(); +function f2() { + const f2 = 0; + ~~ [err % ('f2')] +} +(function f3() { + var f3; + ~~ [err % ('f3')] +})(); +(function f4(f4) { + ~~ [err % ('f4')] +})(); +let f5; +(function f5(){})() + ~~ [err % ('f5')] + +class C { + ~ [err % ('C')] + C(C: C): C { + ~ [err % ('C')] + ~ [err % ('C')] + type C = C; + ~ [err % ('C')] + namespace C { + ~ [err % ('C')] + interface C {} + ~ [err % ('C')] + ~ [err % ('C')] + } + } +} + +// allow nested namespaces +namespace ns.C {} +namespace ns { + export namespace C {} + ~ [err % ('C')] +} +namespace ns { + namespace C {} + ~ [err % ('C')] +} + +type Mapped = { + [K in T]: K + ~ [err % ('K')] +} + +// Allow parameters in signatures +{ + let param; + class TestClass { + myMethod(param): void; + myMethod(): void; + myMethod(param): void {} + ~~~~~ [err % ('param')] + } + interface TestInterface { + (param): void; + myMethod(param): void + myMethod(): void; + ~~~~~ [err % ('param')] + } +} + +// Handle variables in multiple child scopes +{ + { + { + let test; + ~~~~ [err % ('test')] + } + let test; + ~~~~ [err % ('test')] + { + let test; + ~~~~ [err % ('test')] + } + } + { + let test; + ~~~~ [err % ('test')] + } + let test; +} + +// Allow mergeable declarations. +interface I {} +interface I {} + +// Exempt 'this' +function f(this): void { + function inner(this): void {} +} + +@decorator((param) => param) +function funxion(param) {} + +class Clazz { + static method() {} + static prop = () => {} + method() {} + ~ [err % ('T')] + prop = () => {} + ~ [err % ('T')] + constructor() { + class Inner { + ~ [err % ('T')] + static method() {} + ~ [err % ('T')] + static prop = () => {} + ~ [err % ('T')] + } + } +} + +export default function ( + paramA = function() {let paramB}, + ~~~~~~ [err % ('paramB')] + paramB, +) {} + +// allow IndexSignature names +function baz(param: {[baz: string]: string}) {} + +// no error INSIDE ambient namespaces and module +declare global { + function baz(): void; +} +declare module "foo" { + class Clazz {} +} +declare namespace MyNamespaceName { + interface I {} +} + +{ + let MyNamespaceName; // still check names of declare namespace + ~~~~~~~~~~~~~~~ [err % ('MyNamespaceName')] + let global; // don't treat `declare global` as variable +} + +[err]: Shadowed name: '%s' diff --git a/test/rules/no-shadowed-variable/default/tslint.json b/test/rules/no-shadowed-variable/default/tslint.json new file mode 100644 index 00000000000..f9d0b34237a --- /dev/null +++ b/test/rules/no-shadowed-variable/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-shadowed-variable": true + } +} diff --git a/test/rules/no-shadowed-variable/ignore-class/test.ts.lint b/test/rules/no-shadowed-variable/ignore-class/test.ts.lint new file mode 100644 index 00000000000..7fa3dadeb35 --- /dev/null +++ b/test/rules/no-shadowed-variable/ignore-class/test.ts.lint @@ -0,0 +1,16 @@ +class C { + constructor() { + var C; + var D; + ~ [Shadowed name: 'D'] + { + class C { + constructor() { + var C; + ~ [Shadowed name: 'C'] + } + } + } + } +} +interface D {} diff --git a/test/rules/no-shadowed-variable/ignore-class/tslint.json b/test/rules/no-shadowed-variable/ignore-class/tslint.json new file mode 100644 index 00000000000..8e16e7b3ca6 --- /dev/null +++ b/test/rules/no-shadowed-variable/ignore-class/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-shadowed-variable": [true, {"class": false}] + } +} diff --git a/test/rules/no-shadowed-variable/ignore-import/test.ts.lint b/test/rules/no-shadowed-variable/ignore-import/test.ts.lint new file mode 100644 index 00000000000..c2f713c6fa5 --- /dev/null +++ b/test/rules/no-shadowed-variable/ignore-import/test.ts.lint @@ -0,0 +1,13 @@ +import {diff} from "diff"; +import clear from "storage-helper"; + +diff(original, current).forEach((diff) => { + console.log(diff); +}); + +{ + (function clear() { + let clear = true; + ~~~~~ [Shadowed name: 'clear'] + })(); +} diff --git a/test/rules/no-shadowed-variable/ignore-import/tslint.json b/test/rules/no-shadowed-variable/ignore-import/tslint.json new file mode 100644 index 00000000000..2fac839865b --- /dev/null +++ b/test/rules/no-shadowed-variable/ignore-import/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-shadowed-variable": [true, {"import": false}] + } +} diff --git a/test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint b/test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint new file mode 100644 index 00000000000..4e1fa88763d --- /dev/null +++ b/test/rules/no-shadowed-variable/ignore-underscore/test.ts.lint @@ -0,0 +1,10 @@ +import _ = require('lodash'); + +function foo(_) { + console.log(_); +} + +function foo(_1, _2) { + // Allow shadowing of multiple unused parameters + [].map((_1, _2) => undefined); +} diff --git a/test/rules/no-shadowed-variable/ignore-underscore/tslint.json b/test/rules/no-shadowed-variable/ignore-underscore/tslint.json new file mode 100644 index 00000000000..ed40897ba47 --- /dev/null +++ b/test/rules/no-shadowed-variable/ignore-underscore/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-shadowed-variable": [true, {"underscore": false}] + } + } diff --git a/test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint b/test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint new file mode 100644 index 00000000000..06798ae55fe --- /dev/null +++ b/test/rules/no-shadowed-variable/temporal-dead-zone/test.ts.lint @@ -0,0 +1,89 @@ +['a', 'b', 'c'].map((path) => path.resolve(path)) + ~~~~ [err % ('path')] + +import * as path from 'path' + +export function foo(wam: boolean) { + if (wam) { + const now = new Date(); // no error because it's in the temporal dead zone of the outer `now` + return now.getTime(); + } + + const now = new Date(); + return now.getTime() + 1000; +} + +function foo(v) { + if (v) { + const Foo = null; // classes are block scoped, therefore no error in the temporal dead zone + return Foo; + } + class Foo {} + return new Foo(); +} + +function foo(v) { + if (v) { + const Foo = null; // interfaces are block scoped, but hoisted -> error in temporal dead zone + ~~~ [err % ('Foo')] + return Foo; + } + interface Foo {} + class Foo {} + return new Foo(); +} + +function foo() { + { + let tmp = 1; // error because `var` is hoisted + ~~~ [err % ('tmp')] + return tmp; + } + var tmp = undefined; + return tmp; +} + +function foo(v) { + let tmp = 1; + if (v) { + const tmp = v; + ~~~ [err % ('tmp')] + return v; + } else { + const v = tmp; + ~ [err % ('v')] + return v; + } +} + +// parameters also have a temporal dead zone +function foo( + a = function() {let b}, + b, +) {} + +{ + { + class Foo {} // tdz + } + enum Foo {} // tdz + { + class Foo {} // shadowing enum Foo + ~~~ [err % ('Foo')] + } +} +class Foo {} +{ + { + class Foo {} + ~~~ [err % ('Foo')] + } + enum Foo {} + ~~~ [err % ('Foo')] + { + class Foo {} + ~~~ [err % ('Foo')] + } +} + +[err]: Shadowed name: '%s' diff --git a/test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json b/test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json new file mode 100644 index 00000000000..a5685425fc5 --- /dev/null +++ b/test/rules/no-shadowed-variable/temporal-dead-zone/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "no-shadowed-variable": [ + true, + { + "temporalDeadZone": false + } + ] + } +} diff --git a/test/rules/no-sparse-arrays/test.ts.lint b/test/rules/no-sparse-arrays/test.ts.lint new file mode 100644 index 00000000000..3a777dbd0a6 --- /dev/null +++ b/test/rules/no-sparse-arrays/test.ts.lint @@ -0,0 +1,24 @@ +[1, , 3]; + ~ [0] + +// Destructuring allowed. +const [foo, , bar] = []; +const [{foo: [, bar]}] = []; +const [foo = [, 1]] = []; + ~ [0] + +[foo, , (bar)] = []; +[{foo: [, bar]}] = []; +[foo = [, 1]] = []; + ~ [0] +[foo = bar([,])] = []; + ~ [0] + +[1,,]; + ~ [0] + +[1,,,]; + ~ [0] + ~ [0] + +[0]: Array has a missing element. diff --git a/test/rules/no-sparse-arrays/tslint.json b/test/rules/no-sparse-arrays/tslint.json new file mode 100644 index 00000000000..e3be109d241 --- /dev/null +++ b/test/rules/no-sparse-arrays/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-sparse-arrays": true + } +} diff --git a/test/rules/no-string-literal/test.ts.fix b/test/rules/no-string-literal/test.ts.fix new file mode 100644 index 00000000000..ad0703fba31 --- /dev/null +++ b/test/rules/no-string-literal/test.ts.fix @@ -0,0 +1,29 @@ +var obj = { + a: 1, + b: 2, + c: 3, + d: 4 +}; + +function test() { + var a = obj.a; + var b = obj.bcd; + var c = obj.c; + var d = obj[b]; +} + +obj.invalid_accessor; +obj._AnotherInvalidAccessor; +obj.a; // unicode value "a" + +// valid accessors +obj["a-2"]; +obj["2a"]; +obj["?a#$!$^&%&"]; + +// invalid accessor - no crash +obj[] + +// that underscrore escaping thing typescript does +obj.__foo__; + diff --git a/test/rules/no-string-literal/test.ts.lint b/test/rules/no-string-literal/test.ts.lint new file mode 100644 index 00000000000..00c61285f4c --- /dev/null +++ b/test/rules/no-string-literal/test.ts.lint @@ -0,0 +1,36 @@ +var obj = { + a: 1, + b: 2, + c: 3, + d: 4 +}; + +function test() { + var a = obj.a; + var b = obj[ 'bcd' ]; + ~~~~~ [0] + var c = obj["c"]; + ~~~ [0] + var d = obj[b]; +} + +obj["invalid_accessor"]; + ~~~~~~~~~~~~~~~~~~ [0] +obj["_AnotherInvalidAccessor"]; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +obj["\u0061"]; // unicode value "a" + ~~~~~~~~ [0] + +// valid accessors +obj["a-2"]; +obj["2a"]; +obj["?a#$!$^&%&"]; + +// invalid accessor - no crash +obj[] + +// that underscrore escaping thing typescript does +obj['__foo__']; + ~~~~~~~~~ [0] + +[0]: object access via string literals is disallowed diff --git a/test/rules/no-string-literal/tslint.json b/test/rules/no-string-literal/tslint.json new file mode 100644 index 00000000000..ade4197c3d3 --- /dev/null +++ b/test/rules/no-string-literal/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-string-literal": true + } +} diff --git a/test/rules/no-string-throw/test.ts.fix b/test/rules/no-string-throw/test.ts.fix new file mode 100644 index 00000000000..92fc925fa7b --- /dev/null +++ b/test/rules/no-string-throw/test.ts.fix @@ -0,0 +1,30 @@ +let a: never = () => throw new Error('bla'); + +let b: never = () => throw new Error('bla'); + +let c: never = () => throw new Error('string1' + 'string2' + 'string3'); + +let d: never = () => throw new Error('string' + 1); + +let e: never = () => throw new Error('string1' + 1 + {}); + +let f: never = () => throw new Error(('string')); + +let g: never = () => throw new Error(1 + 2 + ('string')); + +// no warning because rule does not check for toString() +const one = 1; +let h: never = () => throw one.toString(); + +let i: never = () => throw new Error(`some template string`); + +const someVariable = 123; +let j: never = () => throw new Error(`template with ${someVariable} string`); + +throw new Error(('component requires CSS height property')); + +throw new Error('component...') + +throw new Error((('component...'))) + +throw/**/new Error('component') diff --git a/test/rules/no-string-throw/test.ts.lint b/test/rules/no-string-throw/test.ts.lint new file mode 100644 index 00000000000..788fb9af842 --- /dev/null +++ b/test/rules/no-string-throw/test.ts.lint @@ -0,0 +1,42 @@ +let a: never = () => throw 'bla'; + ~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +let b: never = () => throw new Error('bla'); + +let c: never = () => throw 'string1' + 'string2' + 'string3'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +let d: never = () => throw 'string' + 1; + ~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +let e: never = () => throw 'string1' + 1 + {}; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +let f: never = () => throw ('string'); + ~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +let g: never = () => throw 1 + 2 + ('string'); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +// no warning because rule does not check for toString() +const one = 1; +let h: never = () => throw one.toString(); + +let i: never = () => throw `some template string`; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +const someVariable = 123; +let j: never = () => throw `template with ${someVariable} string`; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +throw('component requires CSS height property'); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +throw'component...' +~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +throw(('component...')) +~~~~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] + +throw/**/'component' +~~~~~~~~~~~~~~~~~~~~ [Throwing plain strings (not instances of Error) gives no stack traces] diff --git a/test/rules/no-string-throw/tslint.json b/test/rules/no-string-throw/tslint.json new file mode 100644 index 00000000000..dc5dabddab0 --- /dev/null +++ b/test/rules/no-string-throw/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-string-throw": true + } +} \ No newline at end of file diff --git a/test/rules/no-submodule-imports/dynamic-imports/test.ts.lint b/test/rules/no-submodule-imports/dynamic-imports/test.ts.lint new file mode 100644 index 00000000000..46a66fd6e5a --- /dev/null +++ b/test/rules/no-submodule-imports/dynamic-imports/test.ts.lint @@ -0,0 +1,28 @@ +[typescript]: >=2.4.0 + +const dynamicImport = import("lodash"); + +const dynamicImport = import("lodash/sub-module"); + ~~~~~~~~~~~~~~~~~~~ [0] + +const dynamicImport = import("lodash/a/b/c/sub-module"); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + +const dynamicImport = import("@blueprintjs/core"); + +const dynamicImport = import("@blueprintjs/core/sub-module"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const dynamicImport = import("@blueprintjs/core/a/b/c/sub-module"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const dynamicImport = import("rxjs"); +const dynamicImport = import("rxjs/sub-module"); +const dynamicImport = import("@angular/core"); +const dynamicImport = import("@angular/core/forms/directives"); + +const dynamicImport = import("./myModule"); +const dynamicImport = import("./myModule/a/b/c/sub-module"); + +[0]: Submodule import paths from this package are disallowed; import from the root instead \ No newline at end of file diff --git a/test/rules/no-submodule-imports/dynamic-imports/tslint.json b/test/rules/no-submodule-imports/dynamic-imports/tslint.json new file mode 100644 index 00000000000..61983d2a471 --- /dev/null +++ b/test/rules/no-submodule-imports/dynamic-imports/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-submodule-imports": [true, "@angular/core", "rxjs"] + } +} \ No newline at end of file diff --git a/test/rules/no-submodule-imports/static-imports/test.ts.lint b/test/rules/no-submodule-imports/static-imports/test.ts.lint new file mode 100644 index 00000000000..75ddc078a89 --- /dev/null +++ b/test/rules/no-submodule-imports/static-imports/test.ts.lint @@ -0,0 +1,73 @@ +import { submodule } from "@blueprintjs/core"; + +import { submodule } from "@blueprintjs/core/sub-module"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import submodule = require("@blueprintjs/core"); + +import submodule = require("@blueprintjs/core/sub-module"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import { submodule } from "@blueprintjs/core"; + +import { submodule } from "@blueprintjs/core/a/b/c/sub-module"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import submodule = require("@blueprintjs/core"); + +import submodule = require("@blueprintjs/core/a/b/c/sub-module"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import { submodule } from "@angular/core"; +import { submodule } from "@angular/core/sub-module"; +import submodule = require("@angular/core"); +import submodule = require("@angular/core/sub-module"); +import { submodule } from "@angular/core"; +import { submodule } from "@angular/core/a/b/c/sub-module"; +import submodule = require("@angular/core"); +import submodule = require("@angular/core/a/b/c/sub-module"); + +import { submodule } from "@angular/platform-browser"; +import { submodule } from "@angular/platform-browser/animations"; +import { submodule } from "@angular/platform-browser/animations/foo"; +import { submodule } from "@angular/platform-browser/bar"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import { submodule } from "lodash"; + +import { submodule } from "lodash/sub-module"; + ~~~~~~~~~~~~~~~~~~~ [0] + +import submodule = require("lodash"); + +import submodule = require("lodash/sub-module"); + ~~~~~~~~~~~~~~~~~~~ [0] + +import { submodule } from "lodash"; + +import { submodule } from "lodash/a/b/c/sub-module"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import submodule = require("lodash"); + +import submodule = require("lodash/a/b/c/sub-module"); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +import { submodule } from "rxjs"; +import { submodule } from "rxjs/sub-module"; +import submodule = require("rxjs"); +import submodule = require("rxjs/sub-module"); +import { submodule } from "rxjs"; +import { submodule } from "rxjs/a/b/c/sub-module"; +import submodule = require("rxjs"); +import submodule = require("rxjs/a/b/c/sub-module"); + +import { submodule } from "./../node_modules/package"; +import { submodule } from "../myModule/a/package"; +import submodule = require("./../node_modules/package"); +import submodule = require("../myModule/a/package"); + +export * from "@angular/http/testing"; + ~~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: Submodule import paths from this package are disallowed; import from the root instead diff --git a/test/rules/no-submodule-imports/static-imports/tslint.json b/test/rules/no-submodule-imports/static-imports/tslint.json new file mode 100644 index 00000000000..5a36dc800f1 --- /dev/null +++ b/test/rules/no-submodule-imports/static-imports/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-submodule-imports": [true, "@angular/core", "rxjs", "@angular/platform-browser/animations"] + } +} diff --git a/test/rules/no-switch-case-fall-through/test.ts.lint b/test/rules/no-switch-case-fall-through/test.ts.lint new file mode 100644 index 00000000000..1b0a1511e2a --- /dev/null +++ b/test/rules/no-switch-case-fall-through/test.ts.lint @@ -0,0 +1,144 @@ +switch (foo) { + case 1: + bar(); + case 2: + ~~~~ [expected a 'break' before 'case'] + bar(); + bar(); + case 3: + ~~~~ [expected a 'break' before 'case'] + case 4: + default: + break; +} + + +switch (foo) { + case 1: + bar(); + case 2: + ~~~~ [expected a 'break' before 'case'] + bar(); +} + + +switch (foo) { + case 1: + case 2: + default: + bar(); +} + +switch (foo) { + case 1: + switch (bar) { + case "": + default: + break; + } + case 2: + ~~~~ [expected a 'break' before 'case'] +} + +switch (foo) { + case 1: + case 2: + + case 3: + + case 4: + break; + default: + bar(); +} + + +switch (foo) { + case 1: + return; // handle return the same as break + case 2: + case 3: + throw "error"; +} + +switch (foo) { + case 1: + bar(); + /* falls through */ + case 2: + bar(); + /* Testing */ + /* falls through */ + default: + bar(); + // falls through + case 3: + break; +} + +// valid +switch (foo) { + case 1: + break; + case 2: + case 3: + break; + default: +} + +// recognise blocks +switch (foo) { + case 1: { + break; + } + case 2: +} + +// recognise if-else +switch (foo) { + case 1: + if (bar) { + break; + } else { + return; + } + case 2: + if (bar) { + break; + } + case 3: + ~~~~ [expected a 'break' before 'case'] +} + +// allow throw +switch (foo) { + case 1: + throw bar; + case 2: +} + +// handle nested switch statements +switch (foo) { + case 1: + switch (bar) { + case 1: + foobar(); // this case clause falls through and returns in the default clause + default: + ~~~~~~~ [expected a 'break' before 'default'] + return; + } + case 2: +} + +switch (foo) { + case 1: + foo; + // Falls through + case 2: + foo; + // Falls through. + case 3: + foo; + // Falls through -- for reasons + default: +} diff --git a/test/rules/no-switch-case-fall-through/tslint.json b/test/rules/no-switch-case-fall-through/tslint.json new file mode 100644 index 00000000000..31c7fba4e6e --- /dev/null +++ b/test/rules/no-switch-case-fall-through/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-switch-case-fall-through": true + } +} diff --git a/test/rules/no-tautology-expression/test.ts.lint b/test/rules/no-tautology-expression/test.ts.lint new file mode 100644 index 00000000000..09a5057a7cf --- /dev/null +++ b/test/rules/no-tautology-expression/test.ts.lint @@ -0,0 +1,159 @@ + +const expr = "someStr" === "someStr"; + ~~~~~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] +const expr = 123 === 123; + ~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] +const someVar = 100; +const expr = someVar === someVar; + ~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + +const someFunc = () => { + if ("SomeStr" === "SomeStr") { + ~~~~~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (100 === 100) { + ~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + let someVar = 100; + if (someVar === someVar) { + ~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (1 !== 1) { + ~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (1 > 1) { + ~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + const someVar = 123; + if (someVar < someVar) { + ~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if ("str" == "str") { + ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (123 != 123) { + ~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if ("str" <= "str") { + ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if ("str" >= "str") { + ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + const someVar = true; + if (someVar || someVar) { + ~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + const someVar = true; + if (someVar && someVar) { + ~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + const someObj = { "name" : "moses the great" }; + if (someObj.name === someObj.name) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + const someObj = { "name" : "moses the great", "address" : "king's road 10" }; + if (someObj.name === someObj.address) { + return true; + } +} + +const someFunc = () => { + const objOne = { "name" : "moses the great" }; + const objTwo = { "name" : "moses the great" }; + if (objOne.name === objTwo.name) { + return true; + } +} + +const someFunc = () => { + if (true === true) { + ~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (false === false) { + ~~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (true === false) { + ~~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (null === null) { + ~~~~~~~~~~~~~ [Both sides of this equality comparison are the same, so the expression is either a tautology or a contradiction.] + return true; + } +} + +const someFunc = () => { + if (null === false) { + return true; + } +} + +const someVar1 = 3 + 3; +const someVar2 = 3 - 3; +const someVar3 = 3 * 3; +const someVar4 = 3 % 3; +const someVar5 = 3 / 3; diff --git a/test/rules/no-tautology-expression/tslint.json b/test/rules/no-tautology-expression/tslint.json new file mode 100644 index 00000000000..82111395df2 --- /dev/null +++ b/test/rules/no-tautology-expression/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-tautology-expression": true + } +} diff --git a/test/rules/no-this-assignment/allow-destructuring/test.ts.lint b/test/rules/no-this-assignment/allow-destructuring/test.ts.lint new file mode 100644 index 00000000000..3be40991478 --- /dev/null +++ b/test/rules/no-this-assignment/allow-destructuring/test.ts.lint @@ -0,0 +1,13 @@ +const { length } = this; + +const { length, toString } = this; + +const [foo] = this; + +const [foo, bar] = this; + +const self = this; + ~~~~~~~~~~~ [name % ('self')] + +[name]: Assigning `this` reference to local variable not allowed: %s. + diff --git a/test/rules/no-this-assignment/allow-destructuring/tslint.json b/test/rules/no-this-assignment/allow-destructuring/tslint.json new file mode 100644 index 00000000000..ba6ce5a4fd2 --- /dev/null +++ b/test/rules/no-this-assignment/allow-destructuring/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-this-assignment": [true, { + "allow-destructuring": true + }] + } +} diff --git a/test/rules/no-this-assignment/allowed-names/test.ts.lint b/test/rules/no-this-assignment/allowed-names/test.ts.lint new file mode 100644 index 00000000000..7411f550af8 --- /dev/null +++ b/test/rules/no-this-assignment/allowed-names/test.ts.lint @@ -0,0 +1,8 @@ +const start = this; + +const startEnd = this; + +const endStart = this; + ~~~~~~~~~~~~~~~ [name % ('endStart')] + +[name]: Assigning `this` reference to local variable not allowed: %s. diff --git a/test/rules/no-this-assignment/allowed-names/tslint.json b/test/rules/no-this-assignment/allowed-names/tslint.json new file mode 100644 index 00000000000..8435d774dc5 --- /dev/null +++ b/test/rules/no-this-assignment/allowed-names/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-this-assignment": [true, { + "allowed-names": ["^start"] + }] + } +} diff --git a/test/rules/no-this-assignment/default/test.ts.lint b/test/rules/no-this-assignment/default/test.ts.lint new file mode 100644 index 00000000000..94a9141c709 --- /dev/null +++ b/test/rules/no-this-assignment/default/test.ts.lint @@ -0,0 +1,46 @@ +var unscoped = this; + ~~~~~~~~~~~~~~~ [identifier % ('unscoped')] + +function testFunction() { + let inFunction = this; + ~~~~~~~~~~~~~~~~~ [identifier % ('inFunction')] +} + +const testLambda = () => { + const inLambda = this; + ~~~~~~~~~~~~~~~ [identifier % ('inLambda')] +}; + +class TestClass { + constructor() { + const inConstructor = this; + ~~~~~~~~~~~~~~~~~~~~ [identifier % ('inConstructor')] + + const asThis: this = this; + ~~~~~~~~~~~~~~~~~~~ [identifier % ('asThis')] + + const asString = "this"; + const asArray = [this]; + const asArrayString = ["this"]; + } + + public act(scope: this = this) { + const inMemberFunction = this; + ~~~~~~~~~~~~~~~~~~~~~~~ [identifier % ('inMemberFunction')] + + const { act } = this; + ~~~~~~~~~~~~~~ [binding] + + const { act, constructor } = this; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [binding] + + const [foo] = this; + ~~~~~~~~~~~~ [binding] + + const [foo, bar] = this; + ~~~~~~~~~~~~~~~~~ [binding] + } +} + +[binding]: Don't assign members of `this` to local variables. +[identifier]: Assigning `this` reference to local variable not allowed: %s. diff --git a/test/rules/no-this-assignment/default/tslint.json b/test/rules/no-this-assignment/default/tslint.json new file mode 100644 index 00000000000..3fb515282cd --- /dev/null +++ b/test/rules/no-this-assignment/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-this-assignment": true + } +} diff --git a/test/rules/no-trailing-whitespace/default/test.ts.fix b/test/rules/no-trailing-whitespace/default/test.ts.fix new file mode 100644 index 00000000000..4383de12e33 --- /dev/null +++ b/test/rules/no-trailing-whitespace/default/test.ts.fix @@ -0,0 +1,33 @@ +class Clazz { + public funcxion() { + console.log("test") ; + } + + + private foobar() { + } +} +const template = ` +I have trailing whitespace +`; +// single line comment without trailing whitespace +// single line comment with trailing whitespace + /* single line multiline comment */ +/* whitespace after comment */ +/* first line has trailing whitespace + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + * + */ + +// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/default/test.ts.lint b/test/rules/no-trailing-whitespace/default/test.ts.lint new file mode 100644 index 00000000000..a6a9bca652e --- /dev/null +++ b/test/rules/no-trailing-whitespace/default/test.ts.lint @@ -0,0 +1,49 @@ +class Clazz { + public funcxion() { + ~~~~ [trailing whitespace] + console.log("test") ; + ~~~~ [trailing whitespace] + } + +~~~~ [trailing whitespace] + +~~~~ [trailing whitespace] + private foobar() { + } +} + ~~~~ [trailing whitespace] +const template = ` + ~ [trailing whitespace] +I have trailing whitespace + ~~ [trailing whitespace] +`; +// single line comment without trailing whitespace +// single line comment with trailing whitespace + ~~~ [trailing whitespace] + /* single line multiline comment */ +/* whitespace after comment */ + ~ [trailing whitespace] +/* first line has trailing whitespace + ~~ [trailing whitespace] + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +/*** + * not a JSDoc comment + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +// following line checks for trailing whitespace before EOF + +~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/default/tslint.json b/test/rules/no-trailing-whitespace/default/tslint.json new file mode 100644 index 00000000000..f81bfe73957 --- /dev/null +++ b/test/rules/no-trailing-whitespace/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-trailing-whitespace": true + } +} diff --git a/test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix b/test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix new file mode 100644 index 00000000000..18bfde2eeb4 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-comments/test.ts.fix @@ -0,0 +1,30 @@ +class Clazz { + public funcxion() { + console.log("test") ; + } + + + private foobar() { + } +} +// single line comment without trailing whitespace +// single line comment with trailing whitespace + /* single line multiline comment */ +/* whitespace after comment */ +/* first line has trailing whitespace + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + * + */ + +// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint b/test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint new file mode 100644 index 00000000000..db700e685d1 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-comments/test.ts.lint @@ -0,0 +1,38 @@ +class Clazz { + public funcxion() { + ~~~~ [trailing whitespace] + console.log("test") ; + ~~~~ [trailing whitespace] + } + +~~~~ [trailing whitespace] + +~~~~ [trailing whitespace] + private foobar() { + } +} + ~~~~ [trailing whitespace] +// single line comment without trailing whitespace +// single line comment with trailing whitespace + /* single line multiline comment */ +/* whitespace after comment */ + ~ [trailing whitespace] +/* first line has trailing whitespace + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + * + */ + +// following line checks for trailing whitespace before EOF + +~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/ignore-comments/tslint.json b/test/rules/no-trailing-whitespace/ignore-comments/tslint.json new file mode 100644 index 00000000000..862e2496a87 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-comments/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-trailing-whitespace": [true, "ignore-comments"] + } +} diff --git a/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix b/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix new file mode 100644 index 00000000000..dfd0fadad70 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.fix @@ -0,0 +1,30 @@ +class Clazz { + public funcxion() { + console.log("test") ; + } + + + private foobar() { + } +} +// single line comment without trailing whitespace +// single line comment with trailing whitespace + /* single line multiline comment */ +/* whitespace after comment */ +/* first line has trailing whitespace + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + * + */ + +// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint b/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint new file mode 100644 index 00000000000..0bf15bf9b69 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-jsdoc/test.ts.lint @@ -0,0 +1,42 @@ +class Clazz { + public funcxion() { + ~~~~ [trailing whitespace] + console.log("test") ; + ~~~~ [trailing whitespace] + } + +~~~~ [trailing whitespace] + +~~~~ [trailing whitespace] + private foobar() { + } +} + ~~~~ [trailing whitespace] +// single line comment without trailing whitespace +// single line comment with trailing whitespace + ~~~ [trailing whitespace] + /* single line multiline comment */ +/* whitespace after comment */ + ~ [trailing whitespace] +/* first line has trailing whitespace + ~~ [trailing whitespace] + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +// following line checks for trailing whitespace before EOF + +~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json b/test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json new file mode 100644 index 00000000000..fc15bef2af0 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-jsdoc/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-trailing-whitespace": [true, "ignore-jsdoc"] + } +} diff --git a/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix b/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix new file mode 100644 index 00000000000..201e1a6ef36 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.fix @@ -0,0 +1,33 @@ +class Clazz { + public funcxion() { + console.log("test") ; + } + + + private foobar() { + } +} +const template = ` +I have trailing whitespace +`; +// single line comment without trailing whitespace +// single line comment with trailing whitespace + /* single line multiline comment */ +/* whitespace after comment */ +/* first line has trailing whitespace + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + * + */ + +// following line checks for trailing whitespace before EOF diff --git a/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint b/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint new file mode 100644 index 00000000000..b0de5d3f721 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-template-strings/test.ts.lint @@ -0,0 +1,47 @@ +class Clazz { + public funcxion() { + ~~~~ [trailing whitespace] + console.log("test") ; + ~~~~ [trailing whitespace] + } + +~~~~ [trailing whitespace] + +~~~~ [trailing whitespace] + private foobar() { + } +} + ~~~~ [trailing whitespace] +const template = ` +I have trailing whitespace +`; +// single line comment without trailing whitespace +// single line comment with trailing whitespace + ~~~ [trailing whitespace] + /* single line multiline comment */ +/* whitespace after comment */ + ~ [trailing whitespace] +/* first line has trailing whitespace + ~~ [trailing whitespace] + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +/*** + * not a JSDoc comment + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +// following line checks for trailing whitespace before EOF + +~~~ [trailing whitespace] \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json b/test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json new file mode 100644 index 00000000000..0cffd8366f0 --- /dev/null +++ b/test/rules/no-trailing-whitespace/ignore-template-strings/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "no-trailing-whitespace": [ + true, + "ignore-template-strings" + ] + } +} diff --git a/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix b/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix new file mode 100644 index 00000000000..e5d0cb0d678 --- /dev/null +++ b/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.fix @@ -0,0 +1,34 @@ +class Clazz { + public funcxion() { + console.log("test") ; + } + + + private foobar() { + } +} +const template = ` +I have trailing whitespace +`; +// single line comment without trailing whitespace +// single line comment with trailing whitespace + /* single line multiline comment */ +/* whitespace after comment */ +/* first line has trailing whitespace + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + * + */ + +/*** + * not a JSDoc comment + * + */ + +// following line checks for trailing whitespace before EOF + \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint b/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint new file mode 100644 index 00000000000..bd036eba86f --- /dev/null +++ b/test/rules/no-trailing-whitespace/skip-blank-lines/test.ts.lint @@ -0,0 +1,46 @@ +class Clazz { + public funcxion() { + ~~~~ [trailing whitespace] + console.log("test") ; + ~~~~ [trailing whitespace] + } + + + private foobar() { + } +} + ~~~~ [trailing whitespace] +const template = ` + ~ [trailing whitespace] +I have trailing whitespace + ~~ [trailing whitespace] +`; +// single line comment without trailing whitespace +// single line comment with trailing whitespace + ~~~ [trailing whitespace] + /* single line multiline comment */ +/* whitespace after comment */ + ~ [trailing whitespace] +/* first line has trailing whitespace + ~~ [trailing whitespace] + second line is ok + last line is not checked */ +/* + */ + +/** + * JSDoc comment with trailing whitespace + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +/*** + * not a JSDoc comment + ~ [trailing whitespace] + * + ~ [trailing whitespace] + */ + +// following line checks for trailing whitespace before EOF + \ No newline at end of file diff --git a/test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json b/test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json new file mode 100644 index 00000000000..8c800146f7d --- /dev/null +++ b/test/rules/no-trailing-whitespace/skip-blank-lines/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-trailing-whitespace": [true, "ignore-blank-lines"] + } +} diff --git a/test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint b/test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint new file mode 100644 index 00000000000..c873c6af5a2 --- /dev/null +++ b/test/rules/no-trailing-whitespace/zero-width-no-break-space/test.ts.lint @@ -0,0 +1,4 @@ + +// This file starts with a zero width no-break-space. +// See http://www.fileformat.info/info/unicode/char/feff/index.htm +const a = 3; diff --git a/test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint b/test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint new file mode 100644 index 00000000000..96c770979e8 --- /dev/null +++ b/test/rules/no-trailing-whitespace/zero-width-no-break-space/test2.ts.lint @@ -0,0 +1,5 @@ + +~~ [trailing whitespace] +// This file starts with a zero width no-break-space followed by a trailing space. +// See http://www.fileformat.info/info/unicode/char/feff/index.htm +const a = 3; diff --git a/test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json b/test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json new file mode 100644 index 00000000000..f81bfe73957 --- /dev/null +++ b/test/rules/no-trailing-whitespace/zero-width-no-break-space/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-trailing-whitespace": true + } +} diff --git a/test/rules/no-unbound-method/default/test.ts.lint b/test/rules/no-unbound-method/default/test.ts.lint new file mode 100644 index 00000000000..53d3ba61f8f --- /dev/null +++ b/test/rules/no-unbound-method/default/test.ts.lint @@ -0,0 +1,14 @@ +interface I { m?(): void; } +function f(i: I) { + i.m!(); + (i.m as any)(1); + ( i.m)(1); + i.m ? 1 : 2; + if (i.m) {} + !i.m; + i.m["length"]; + return i.m!; + ~~~ [0] +} + +[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/default/test.tsx.lint b/test/rules/no-unbound-method/default/test.tsx.lint new file mode 100644 index 00000000000..b6e86b3405d --- /dev/null +++ b/test/rules/no-unbound-method/default/test.tsx.lint @@ -0,0 +1,68 @@ +class C { + method(x: number) {} + property: () => void; + template(strs: TemplateStringsArray, x: any) {} +} + +const c = new C(); +[0].forEach(c.method); + ~~~~~~~~ [0] +[0].forEach(x => c.method(x)); +[0].forEach(c.property); + +c.template; +~~~~~~~~~~ [0] +c.template`foo${0}`; +String.raw`${c.template}`; + ~~~~~~~~~~ [0] + +interface I { + foo(): void; + bar: () => void; +} +declare var i: I; +i.foo; +~~~~~ [0] +i.bar; + +c.method === i.foo; + +// OK in condition +c.method ? 1 : 2; +1 ? c.method : c.method; + ~~~~~~~~ [0] + ~~~~~~~~ [0] +if (c.method) {} +while (c.method) {} +do {} while (c.method); +for (c.method; c.method; c.method) {} + + +[0].forEach(c.method || i.foo); + ~~~~~~~~ [0] + ~~~~~ [0] +[0].forEach(c.method.bind(c)); + +; + ~~~~~~~~ [0] + +class Validators { + static required() { + return null; + } + static compose(...args: Function[]) {} +} + +Validators.compose(Validators.required); + ~~~~~~~~~~~~~~~~~~~ [0] + +const a = { + getText() { + return 'text'; + } +}; + +delete a.getText; + ~~~~~~~~~ [0] + +[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/default/tsconfig.json b/test/rules/no-unbound-method/default/tsconfig.json new file mode 100644 index 00000000000..f7855d670cb --- /dev/null +++ b/test/rules/no-unbound-method/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} \ No newline at end of file diff --git a/test/rules/no-unbound-method/default/tslint.json b/test/rules/no-unbound-method/default/tslint.json new file mode 100644 index 00000000000..908c6e2ad9e --- /dev/null +++ b/test/rules/no-unbound-method/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unbound-method": true + } +} diff --git a/test/rules/no-unbound-method/ignore-static/test.tsx.lint b/test/rules/no-unbound-method/ignore-static/test.tsx.lint new file mode 100644 index 00000000000..e1775b891dc --- /dev/null +++ b/test/rules/no-unbound-method/ignore-static/test.tsx.lint @@ -0,0 +1,46 @@ +class C { + method(x: number) {} + property: () => void; + template(strs: TemplateStringsArray, x: any) {} +} + +const c = new C(); +[0].forEach(c.method); + ~~~~~~~~ [0] +[0].forEach(x => c.method(x)); +[0].forEach(c.property); + +c.template; +~~~~~~~~~~ [0] +c.template`foo${0}`; +String.raw`${c.template}`; + ~~~~~~~~~~ [0] + +interface I { + foo(): void; + bar: () => void; +} +declare var i: I; +i.foo; +~~~~~ [0] +i.bar; + +c.method === i.foo; +[0].forEach(c.method || i.foo); + ~~~~~~~~ [0] + ~~~~~ [0] +[0].forEach(c.method.bind(c)); + +; + ~~~~~~~~ [0] + +class Validators { + static required() { + return null; + } + static compose(...args: Function[]) {} +} + +Validators.compose(Validators.required); + +[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/ignore-static/tsconfig.json b/test/rules/no-unbound-method/ignore-static/tsconfig.json new file mode 100644 index 00000000000..f7855d670cb --- /dev/null +++ b/test/rules/no-unbound-method/ignore-static/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} \ No newline at end of file diff --git a/test/rules/no-unbound-method/ignore-static/tslint.json b/test/rules/no-unbound-method/ignore-static/tslint.json new file mode 100644 index 00000000000..d0674c20abf --- /dev/null +++ b/test/rules/no-unbound-method/ignore-static/tslint.json @@ -0,0 +1,8 @@ +{ + "linterOptions": { + "typeCheck": true + }, + "rules": { + "no-unbound-method": [true, "ignore-static"] + } +} diff --git a/test/rules/no-unbound-method/whitelist/test.tsx.lint b/test/rules/no-unbound-method/whitelist/test.tsx.lint new file mode 100644 index 00000000000..fbb98f7d95c --- /dev/null +++ b/test/rules/no-unbound-method/whitelist/test.tsx.lint @@ -0,0 +1,80 @@ +class C { + method(x: number) {} + property: () => void; + template(strs: TemplateStringsArray, x: any) {} +} + +const c = new C(); +[0].forEach(c.method); + ~~~~~~~~ [0] +[0].forEach(x => c.method(x)); +[0].forEach(c.property); + +c.template; +~~~~~~~~~~ [0] +c.template`foo${0}`; +String.raw`${c.template}`; + ~~~~~~~~~~ [0] + +expect(c.method).toHaveBeenCalled(); +typeof c.method; + +test(c.method); + ~~~~~~~~ [0] + +interface I { + foo(): void; + bar: () => void; +} +declare var i: I; +i.foo; +~~~~~ [0] +i.bar; + +c.method === i.foo; + +// OK in condition +c.method ? 1 : 2; +1 ? c.method : c.method; + ~~~~~~~~ [0] + ~~~~~~~~ [0] +if (c.method) {} +while (c.method) {} +do {} while (c.method); +for (c.method; c.method; c.method) {} + + +[0].forEach(c.method || i.foo); + ~~~~~~~~ [0] + ~~~~~ [0] +[0].forEach(c.method.bind(c)); + +; + ~~~~~~~~ [0] + +class Validators { + static required() { + return null; + } + static compose(...args: Function[]) {} +} + +Validators.compose(Validators.required); + ~~~~~~~~~~~~~~~~~~~ [0] + +(condition ? expectA : expectB)(c.method); + ~~~~~~~~ [0] +(await someObject)(c.method); + ~~~~~~~~ [0] +(await someMethod())(c.method); + ~~~~~~~~ [0] + +const a = { + getText() { + return 'text'; + } +}; + +delete a.getText; + +[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'. diff --git a/test/rules/no-unbound-method/whitelist/tsconfig.json b/test/rules/no-unbound-method/whitelist/tsconfig.json new file mode 100644 index 00000000000..f7855d670cb --- /dev/null +++ b/test/rules/no-unbound-method/whitelist/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} \ No newline at end of file diff --git a/test/rules/no-unbound-method/whitelist/tslint.json b/test/rules/no-unbound-method/whitelist/tslint.json new file mode 100644 index 00000000000..96ff8334aa8 --- /dev/null +++ b/test/rules/no-unbound-method/whitelist/tslint.json @@ -0,0 +1,8 @@ +{ + "linterOptions": { + "typeCheck": true + }, + "rules": { + "no-unbound-method": [true, { "whitelist": ["expect"], "allow-typeof": true, "allow-delete": true }] + } +} diff --git a/test/rules/no-unnecessary-callback-wrapper/test.ts.fix b/test/rules/no-unnecessary-callback-wrapper/test.ts.fix new file mode 100644 index 00000000000..6a81f365c99 --- /dev/null +++ b/test/rules/no-unnecessary-callback-wrapper/test.ts.fix @@ -0,0 +1,27 @@ +f; + +f; + +(x, y) => f(x, y, 0); +(x, y) => f(y, x); + +f; + +(x, ...y) => f(x, y); + +f; + +// Ignore if function is not an identifier +(x) => obj.f(x); +(x) => obj["f"](x); +x => foo()(x); +// x is not only used as argument +(x) => obj[x](x); +x => x(x); + +// allow async arrows +async (x) => f(x); + +// Not bothering to catch this case. +({ x, y }) => f({ x, y }); + diff --git a/test/rules/no-unnecessary-callback-wrapper/test.ts.lint b/test/rules/no-unnecessary-callback-wrapper/test.ts.lint new file mode 100644 index 00000000000..c51c4067a7a --- /dev/null +++ b/test/rules/no-unnecessary-callback-wrapper/test.ts.lint @@ -0,0 +1,32 @@ +x => f(x); +~~~~~~~~~ [0] + +(x, y) => f(x, y); +~~~~~~~~~~~~~~~~~ [0] + +(x, y) => f(x, y, 0); +(x, y) => f(y, x); + +(x, y) => f(x, y); +~~~~~~~~~~~~~~~~~~~~ [0] + +(x, ...y) => f(x, y); + +(...args) => f(...args); +~~~~~~~~~~~~~~~~~~~~~~~ [0] + +// Ignore if function is not an identifier +(x) => obj.f(x); +(x) => obj["f"](x); +x => foo()(x); +// x is not only used as argument +(x) => obj[x](x); +x => x(x); + +// allow async arrows +async (x) => f(x); + +// Not bothering to catch this case. +({ x, y }) => f({ x, y }); + +[0]: No need to wrap 'f' in another function. Just use it directly. diff --git a/test/rules/no-unnecessary-callback-wrapper/tslint.json b/test/rules/no-unnecessary-callback-wrapper/tslint.json new file mode 100644 index 00000000000..44e0d7a2d07 --- /dev/null +++ b/test/rules/no-unnecessary-callback-wrapper/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-callback-wrapper": true + } +} diff --git a/test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint b/test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint new file mode 100644 index 00000000000..ca5c10c9c05 --- /dev/null +++ b/test/rules/no-unnecessary-class/allow-constructor-only/test.ts.lint @@ -0,0 +1,156 @@ +class Foo { + public prop = 1; + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { + constructor() { + class Bar { + constructor() { + class FizzBuzz { + ~~~~~ [STATIC_ONLY] + public static a = 'hello mom!'; + } + } + } + } +} + +class Foo { + constructor() { + class Bar { + public static helper(): void {} + private Helper(): boolean { + return true; + } + constructor() {} + } + } +} + +class Foo { + constructor() { + class Bar { + constructor() { + class FizzBuzz { + public static helper(): void {} + private privateHelper(): boolean { + return true; + } + constructor() {} + } + } + } + } +} + +class Foo { + constructor() { + class Bar { + private a: SomeType; + static PROP = 2; + } + } +} + +class Foo { + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class EmptyClassA {} +~~~~~ [EMPTY_CLASS] + +class EmptyClassB { constructor() {} } + +export class AClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class BClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + + constructor() { + class nestedClass {} + ~~~~~ [EMPTY_CLASS] + } +} + +export class DoubleClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + + constructor() { + class NestedClass {} + ~~~~~ [EMPTY_CLASS] + + class SecondNestedClass { + ~~~~~ [STATIC_ONLY] + static myNum: number = 0; + } + } +} + +export class CClass extends BaseClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class ShorthandPropsClass { + public static helper(): void {} + constructor(private a: string) {} +} + +export class DClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + public index = 0; + constructor() {} +} + +export class EClass { + public static helper(): void {} + private Helper(): boolean { + return true; + } + constructor() {} +} + +[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. +[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. +[EMPTY_CLASS]: This class has no members. diff --git a/test/rules/no-unnecessary-class/allow-constructor-only/tslint.json b/test/rules/no-unnecessary-class/allow-constructor-only/tslint.json new file mode 100644 index 00000000000..f3f43df47fd --- /dev/null +++ b/test/rules/no-unnecessary-class/allow-constructor-only/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-class": [true, "allow-constructor-only"] + } +} diff --git a/test/rules/no-unnecessary-class/allow-empty/test.ts.lint b/test/rules/no-unnecessary-class/allow-empty/test.ts.lint new file mode 100644 index 00000000000..a26534a409c --- /dev/null +++ b/test/rules/no-unnecessary-class/allow-empty/test.ts.lint @@ -0,0 +1,151 @@ +class Foo { + public prop = 1; + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { + private number hello = 0; + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class FizzBuzz { + ~~~~~ [STATIC_ONLY] + public static a = 'hello mom!'; + } + } + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + public static helper(): void {} + private private Helper(): boolean { + return true; + } + constructor() {} + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class FizzBuzz { + public static helper(): void {} + private privateHelper(): boolean { + return true; + } + constructor() {} + } + } + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + private a: SomeType; + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class EmptyClassA {} + +class EmptyClassB { constructor() {} } +~~~~~ [CONSTRUCTOR_ONLY] + +export class AClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class BClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } +} + +export class CClass extends BaseClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class ShorthandPropsClass { + public static helper(): void {} + constructor(private a: string) {} +} + +export class DClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + public index = 0; + constructor() {} +} + +export class EClass { + public static helper(): void {} + private Helper(): boolean { + return true; + } + constructor() {} +} + +[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. +[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. +[EMPTY_CLASS]: This class has no members. \ No newline at end of file diff --git a/test/rules/no-unnecessary-class/allow-empty/tslint.json b/test/rules/no-unnecessary-class/allow-empty/tslint.json new file mode 100644 index 00000000000..02f4ec676fa --- /dev/null +++ b/test/rules/no-unnecessary-class/allow-empty/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-class": [true, "allow-empty-class"] + } +} diff --git a/test/rules/no-unnecessary-class/allow-static-only/test.ts.lint b/test/rules/no-unnecessary-class/allow-static-only/test.ts.lint new file mode 100644 index 00000000000..7813da0f876 --- /dev/null +++ b/test/rules/no-unnecessary-class/allow-static-only/test.ts.lint @@ -0,0 +1,136 @@ +class Foo { + public prop = 1; + constructor() { + class Bar { + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class FizzBuzz { + public static a = 'hello mom!'; + } + } + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + public static helper(): void {} + private private Helper(): boolean { + return true; + } + constructor() {} + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class FizzBuzz { + public static helper(): void {} + private privateHelper(): boolean { + return true; + } + constructor() {} + } + } + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + private a: SomeType; + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + static PROP = 2; + } + } +} + +class EmptyClassA {} +~~~~~ [EMPTY_CLASS] + +class EmptyClassB { constructor() {} } +~~~~~ [CONSTRUCTOR_ONLY] + +export class AClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class BClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } +} + +export class CClass extends BaseClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class ShorthandPropsClass { + public static helper(): void {} + constructor(private a: string) {} +} + +export class DClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + public index = 0; + constructor() {} +} + +export class EClass { + public static helper(): void {} + private Helper(): boolean { + return true; + } + constructor() {} +} + +[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. +[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. +[EMPTY_CLASS]: This class has no members. \ No newline at end of file diff --git a/test/rules/no-unnecessary-class/allow-static-only/tslint.json b/test/rules/no-unnecessary-class/allow-static-only/tslint.json new file mode 100644 index 00000000000..37ecb72cc17 --- /dev/null +++ b/test/rules/no-unnecessary-class/allow-static-only/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-class": [true, "allow-static-only"] + } +} diff --git a/test/rules/no-unnecessary-class/default/test.ts.lint b/test/rules/no-unnecessary-class/default/test.ts.lint new file mode 100644 index 00000000000..eeda30340f3 --- /dev/null +++ b/test/rules/no-unnecessary-class/default/test.ts.lint @@ -0,0 +1,146 @@ +class Foo { + public prop = 1; + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class FizzBuzz { + ~~~~~ [STATIC_ONLY] + public static a = 'hello mom!'; + } + } + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + public static helper(): void {} + private private Helper(): boolean { + return true; + } + constructor() {} + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class FizzBuzz { + public static helper(): void {} + private privateHelper(): boolean { + return true; + } + constructor() {} + } + } + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + private a: SomeType; + static PROP = 2; + } + } +} + +class Foo { +~~~~~ [CONSTRUCTOR_ONLY] + constructor() { + class Bar { + ~~~~~ [STATIC_ONLY] + static PROP = 2; + } + } +} + +class EmptyClassA {} +~~~~~ [EMPTY_CLASS] + +class EmptyClassB { constructor() {} } +~~~~~ [CONSTRUCTOR_ONLY] + +export class AClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() { + class nestedClass { + ~~~~~ [EMPTY_CLASS] + } + } +} + +export class BClass { + ~~~~~ [STATIC_ONLY] + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } +} + +export class CClass extends BaseClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + constructor() {} +} + +export class ShorthandPropsClass { + public static helper(): void {} + constructor(private a: string) {} +} + +export class DClass { + public static helper(): void {} + private static privateHelper(): boolean { + return true; + } + public index = 0; + constructor() {} +} + +export class EClass { + public static helper(): void {} + private Helper(): boolean { + return true; + } + constructor() {} +} + +[CONSTRUCTOR_ONLY]: Every member of this class is a constructor. Use functions instead. +[STATIC_ONLY]: Every member of this class is static. Use namespaces or plain objects instead. +[EMPTY_CLASS]: This class has no members. \ No newline at end of file diff --git a/test/rules/no-unnecessary-class/default/tslint.json b/test/rules/no-unnecessary-class/default/tslint.json new file mode 100644 index 00000000000..58f7ae0f0ba --- /dev/null +++ b/test/rules/no-unnecessary-class/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-class": [true] + } +} diff --git a/test/rules/no-unnecessary-initializer/test.ts.fix b/test/rules/no-unnecessary-initializer/test.ts.fix new file mode 100644 index 00000000000..0d832bda1cf --- /dev/null +++ b/test/rules/no-unnecessary-initializer/test.ts.fix @@ -0,0 +1,18 @@ +let a: string | undefined; +var b: string | undefined; + +for (let c: number | undefined; c < 2; c++) {} + +let d; + +const e = undefined; + +function f(x: string | undefined, bar: number) {} +function f2(x: string | undefined = undefined, bar: number = 1) {} + +declare function get(): T +const { g } = get<{ g?: number }>(); +const [h] = get(); + +function f({ x }: { x?: number }) {} + diff --git a/test/rules/no-unnecessary-initializer/test.ts.lint b/test/rules/no-unnecessary-initializer/test.ts.lint new file mode 100644 index 00000000000..1de4897d422 --- /dev/null +++ b/test/rules/no-unnecessary-initializer/test.ts.lint @@ -0,0 +1,28 @@ +let a: string | undefined = undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +var b: string | undefined = undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +for (let c: number | undefined = undefined; c < 2; c++) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +let d; + +const e = undefined; + +function f(x: string | undefined = undefined, bar: number) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +function f2(x: string | undefined = undefined, bar: number = 1) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] + +declare function get(): T +const { g = undefined } = get<{ g?: number }>(); + ~~~~~~~~~~~~~ [0] +const [h = undefined] = get(); + ~~~~~~~~~~~~~ [0] + +function f({ x = undefined }: { x?: number }) {} + ~~~~~~~~~~~~~ [0] + +[0]: Unnecessary initialization to 'undefined'. +[1]: Use an optional parameter instead of initializing to 'undefined'. Also, the type declaration does not need to include '| undefined'. diff --git a/test/rules/no-unnecessary-initializer/tslint.json b/test/rules/no-unnecessary-initializer/tslint.json new file mode 100644 index 00000000000..2fbb39a5e80 --- /dev/null +++ b/test/rules/no-unnecessary-initializer/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-initializer": [true] + } +} diff --git a/test/rules/no-unnecessary-qualifier/arguments.ts.lint b/test/rules/no-unnecessary-qualifier/arguments.ts.lint new file mode 100644 index 00000000000..04dd3ffb80d --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/arguments.ts.lint @@ -0,0 +1,12 @@ +namespace N { + export type T = number; + export const x: N.T = 0; + ~ [N] + export function f() { + if (arguments.length > 0) { + console.log('arguments should not break this rule'); + } + } +} + +[N]: Qualifier is unnecessary since 'N' is in scope. diff --git a/test/rules/no-unnecessary-qualifier/b.test.ts b/test/rules/no-unnecessary-qualifier/b.test.ts new file mode 100644 index 00000000000..a87fbc00e59 --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/b.test.ts @@ -0,0 +1 @@ +export type T = number; \ No newline at end of file diff --git a/test/rules/no-unnecessary-qualifier/test-global-2.ts.lint b/test/rules/no-unnecessary-qualifier/test-global-2.ts.lint new file mode 100644 index 00000000000..2365cfd2eb0 --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/test-global-2.ts.lint @@ -0,0 +1,4 @@ +namespace M { + // Used in test-global.ts + export type T = number; +} diff --git a/test/rules/no-unnecessary-qualifier/test-global.ts.fix b/test/rules/no-unnecessary-qualifier/test-global.ts.fix new file mode 100644 index 00000000000..b82929776f6 --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/test-global.ts.fix @@ -0,0 +1,5 @@ +namespace N { + export type T = number; + export const x: T = 0; + export const x: M.T = 0; +} diff --git a/test/rules/no-unnecessary-qualifier/test-global.ts.lint b/test/rules/no-unnecessary-qualifier/test-global.ts.lint new file mode 100644 index 00000000000..67436ffccfe --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/test-global.ts.lint @@ -0,0 +1,6 @@ +namespace N { + export type T = number; + export const x: N.T = 0; + ~ [Qualifier is unnecessary since 'N' is in scope.] + export const x: M.T = 0; +} diff --git a/test/rules/no-unnecessary-qualifier/test.ts.fix b/test/rules/no-unnecessary-qualifier/test.ts.fix new file mode 100644 index 00000000000..0775562d407 --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/test.ts.fix @@ -0,0 +1,41 @@ +namespace N { + export type T = number; + export const x: T = 0; + + export namespace M { + export type U = T; + export const y: U = 0; + export const z: U = 0; + export const a = x; + export const b = y; + export const c = z; + } +} + +namespace A.B.C1 { + export const D = 7; +} + +namespace A.B.C2 { + const copy = C1.D; +} + +import * as B from "./b.test"; +declare module "./b.test" { + const x: T; +} + +namespace X { + export type T = number; + namespace Y { + type T = string; + // This qualifier *is* necessary since 'X.T' is shadowed. + const x: X.T = 0; + } +} + +enum E { + A, + B = A +} + diff --git a/test/rules/no-unnecessary-qualifier/test.ts.lint b/test/rules/no-unnecessary-qualifier/test.ts.lint new file mode 100644 index 00000000000..ee09132ffd4 --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/test.ts.lint @@ -0,0 +1,54 @@ +namespace N { + export type T = number; + export const x: N.T = 0; + ~ [N] + + export namespace M { + export type U = N.T; + ~ [N] + export const y: M.U = 0; + ~ [M] + export const z: N.M.U = 0; + ~~~ [NM] + export const a = N.x; + ~ [N] + export const b = M.y; + ~ [M] + export const c = N.M.z; + ~~~ [NM] + } +} + +namespace A.B.C1 { + export const D = 7; +} + +namespace A.B.C2 { + const copy = A.B.C1.D; + ~~~ [Qualifier is unnecessary since 'A.B' is in scope.] +} + +import * as B from "./b.test"; +declare module "./b.test" { + const x: B.T; + ~ [Qualifier is unnecessary since 'B' is in scope.] +} + +namespace X { + export type T = number; + namespace Y { + type T = string; + // This qualifier *is* necessary since 'X.T' is shadowed. + const x: X.T = 0; + } +} + +enum E { + A, + B = E.A + ~ [Qualifier is unnecessary since 'E' is in scope.] +} + +[N]: Qualifier is unnecessary since 'N' is in scope. +[M]: Qualifier is unnecessary since 'M' is in scope. +[NM]: Qualifier is unnecessary since 'N.M' is in scope. diff --git a/test/rules/no-unnecessary-qualifier/tsconfig.json b/test/rules/no-unnecessary-qualifier/tsconfig.json new file mode 100644 index 00000000000..db953a729b9 --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "declaration": true + } +} \ No newline at end of file diff --git a/test/rules/no-unnecessary-qualifier/tslint.json b/test/rules/no-unnecessary-qualifier/tslint.json new file mode 100644 index 00000000000..53feac1c8ab --- /dev/null +++ b/test/rules/no-unnecessary-qualifier/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-qualifier": true + } +} \ No newline at end of file diff --git a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint new file mode 100644 index 00000000000..baa6c0a6dfd --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/test.ts.lint @@ -0,0 +1,6 @@ +declare const x: string | undefined; +x!; + +declare const y: string; +y as string; +~~~~~~~~~~~ [This assertion is unnecessary since it does not change the type of the expression.] diff --git a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tsconfig.json @@ -0,0 +1 @@ +{} diff --git a/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json new file mode 100644 index 00000000000..2acf91b7b08 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/noStrictNullChecks/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-type-assertion": true + } +} diff --git a/test/rules/no-unnecessary-type-assertion/strict/test.ts.fix b/test/rules/no-unnecessary-type-assertion/strict/test.ts.fix new file mode 100644 index 00000000000..17726c9bc0c --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strict/test.ts.fix @@ -0,0 +1,104 @@ +const nonNullStringLiteral: 'test'; +const nonNullString: string; +const nullableString: string|undefined; +let anyType: any; +type AnyDuringMigration = any; +let tuple: [number, number] = [1, 2]; + +// non-null +let a = nonNullStringLiteral; +let b = nonNullString; +let c = nullableString!; +tuple; + +// as +let d = nonNullStringLiteral as string; +let e = nonNullString; +let f = nullableString as string; + +// type assertion +let g = nonNullStringLiteral; +let h = nonNullString; +let i = nullableString; + +// complex inner expression +let j = (nonNullString + nonNullStringLiteral); +let k = (nonNullString + nonNullStringLiteral); +let l = (nonNullString + nonNullStringLiteral); +let m = nonNullString.trim(); +let n = nonNullString.trim(); +let o = nonNullString.trim(); +let p = nonNullString.trim(); + +// custom types +interface Iface1 { + prop: string; +} +interface Iface2 { + prop: string; +} + +const value1: Iface1 = {prop: 'test'}; +const value2: Iface2 = {prop: 'test'}; + +let q = value1; +let r = value1; +let s = value2; +let t = value2 as Iface1; +let aa = anyType as AnyDuringMigration; + +interface TypeA { + kind: 'a'; +} +interface TypeB { + kind: 'b'; +} + +function isB(x: TypeA|TypeB): x is TypeB { + return true; +} + +function func(aOrB: TypeA|TypeB) { + let u = aOrB as TypeA; + let v = aOrB; + + if (aOrB.kind === 'a') { + let w = aOrB; + } else { + let x = aOrB; + } + + if (isB(aOrB)) { + let y = aOrB; + } else { + let z = aOrB; + } +} + +// Expecting no warning for these assertions as they are not unnecessary. + +type Bar = 'bar'; +const data = { + x: 'foo' as 'foo', + y: 'bar' as Bar, +} + +[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); +let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); + +interface NotATuple { + 0: number, + 0.5: number, + 2: number, +} + +declare const notATuple: NotATuple; +notATuple; + +function foo() { + let xx: 1 | 2 = 1; + const f = () => xx = 2; + f(); + xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error +} + diff --git a/test/rules/no-unnecessary-type-assertion/strict/test.ts.lint b/test/rules/no-unnecessary-type-assertion/strict/test.ts.lint new file mode 100644 index 00000000000..42ae2598262 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strict/test.ts.lint @@ -0,0 +1,125 @@ +[typescript]: >= 2.4.0 +const nonNullStringLiteral: 'test'; +const nonNullString: string; +const nullableString: string|undefined; +let anyType: any; +type AnyDuringMigration = any; +let tuple: [number, number] = [1, 2]; + +// non-null +let a = nonNullStringLiteral!; + ~~~~~~~~~~~~~~~~~~~~~ [0] +let b = nonNullString!; + ~~~~~~~~~~~~~~ [0] +let c = nullableString!; +tuple!; +~~~~~~ [0] + +// as +let d = nonNullStringLiteral as string; +let e = nonNullString as string; + ~~~~~~~~~~~~~~~~~~~~~~~ [0] +let f = nullableString as string; + +// type assertion +let g = nonNullStringLiteral; +let h = nonNullString; + ~~~~~~~~~~~~~~~~~~~~~ [0] +let i = nullableString; + +// complex inner expression +let j = (nonNullString + nonNullStringLiteral)!; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let k = (nonNullString + nonNullStringLiteral) as string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let l = (nonNullString + nonNullStringLiteral); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let m = nonNullString.trim()!; + ~~~~~~~~~~~~~~~~~~~~~ [0] +let n = nonNullString.trim() as string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let o = nonNullString.trim(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let p = nonNullString!.trim(); + ~~~~~~~~~~~~~~ [0] + +// custom types +interface Iface1 { + prop: string; +} +interface Iface2 { + prop: string; +} + +const value1: Iface1 = {prop: 'test'}; +const value2: Iface2 = {prop: 'test'}; + +let q = value1; + ~~~~~~~~~~~~~~ [0] +let r = value1; +let s = value2 as Iface2; + ~~~~~~~~~~~~~~~~ [0] +let t = value2 as Iface1; +let aa = anyType as AnyDuringMigration; + +interface TypeA { + kind: 'a'; +} +interface TypeB { + kind: 'b'; +} + +function isB(x: TypeA|TypeB): x is TypeB { + return true; +} + +function func(aOrB: TypeA|TypeB) { + let u = aOrB as TypeA; + let v = aOrB; + + if (aOrB.kind === 'a') { + let w = aOrB as TypeA; + ~~~~~~~~~~~~~ [0] + } else { + let x = aOrB; + ~~~~~~~~~~~ [0] + } + + if (isB(aOrB)) { + let y = aOrB as TypeB; + ~~~~~~~~~~~~~ [0] + } else { + let z = aOrB; + ~~~~~~~~~~~ [0] + } +} + +// Expecting no warning for these assertions as they are not unnecessary. + +type Bar = 'bar'; +const data = { + x: 'foo' as 'foo', + y: 'bar' as Bar, +} + +[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); +let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); + +interface NotATuple { + 0: number, + 0.5: number, + 2: number, +} + +declare const notATuple: NotATuple; +notATuple; +~~~~~~~~~~~~~~~~~~~~ [0] + +function foo() { + let xx: 1 | 2 = 1; + const f = () => xx = 2; + f(); + xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error +} + +[0]: This assertion is unnecessary since it does not change the type of the expression. diff --git a/test/rules/no-unnecessary-type-assertion/strict/tsconfig.json b/test/rules/no-unnecessary-type-assertion/strict/tsconfig.json new file mode 100644 index 00000000000..71e2b87a156 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strict/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "es2015", + "strict": true + } +} diff --git a/test/rules/no-unnecessary-type-assertion/strict/tslint.json b/test/rules/no-unnecessary-type-assertion/strict/tslint.json new file mode 100644 index 00000000000..6c6fdcf5f38 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strict/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-type-assertion": [true, "AnyDuringMigration"] + } +} diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix b/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix new file mode 100644 index 00000000000..17726c9bc0c --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.fix @@ -0,0 +1,104 @@ +const nonNullStringLiteral: 'test'; +const nonNullString: string; +const nullableString: string|undefined; +let anyType: any; +type AnyDuringMigration = any; +let tuple: [number, number] = [1, 2]; + +// non-null +let a = nonNullStringLiteral; +let b = nonNullString; +let c = nullableString!; +tuple; + +// as +let d = nonNullStringLiteral as string; +let e = nonNullString; +let f = nullableString as string; + +// type assertion +let g = nonNullStringLiteral; +let h = nonNullString; +let i = nullableString; + +// complex inner expression +let j = (nonNullString + nonNullStringLiteral); +let k = (nonNullString + nonNullStringLiteral); +let l = (nonNullString + nonNullStringLiteral); +let m = nonNullString.trim(); +let n = nonNullString.trim(); +let o = nonNullString.trim(); +let p = nonNullString.trim(); + +// custom types +interface Iface1 { + prop: string; +} +interface Iface2 { + prop: string; +} + +const value1: Iface1 = {prop: 'test'}; +const value2: Iface2 = {prop: 'test'}; + +let q = value1; +let r = value1; +let s = value2; +let t = value2 as Iface1; +let aa = anyType as AnyDuringMigration; + +interface TypeA { + kind: 'a'; +} +interface TypeB { + kind: 'b'; +} + +function isB(x: TypeA|TypeB): x is TypeB { + return true; +} + +function func(aOrB: TypeA|TypeB) { + let u = aOrB as TypeA; + let v = aOrB; + + if (aOrB.kind === 'a') { + let w = aOrB; + } else { + let x = aOrB; + } + + if (isB(aOrB)) { + let y = aOrB; + } else { + let z = aOrB; + } +} + +// Expecting no warning for these assertions as they are not unnecessary. + +type Bar = 'bar'; +const data = { + x: 'foo' as 'foo', + y: 'bar' as Bar, +} + +[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); +let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); + +interface NotATuple { + 0: number, + 0.5: number, + 2: number, +} + +declare const notATuple: NotATuple; +notATuple; + +function foo() { + let xx: 1 | 2 = 1; + const f = () => xx = 2; + f(); + xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error +} + diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint b/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint new file mode 100644 index 00000000000..0bac9d59232 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strictNullChecks/test.ts.lint @@ -0,0 +1,124 @@ +const nonNullStringLiteral: 'test'; +const nonNullString: string; +const nullableString: string|undefined; +let anyType: any; +type AnyDuringMigration = any; +let tuple: [number, number] = [1, 2]; + +// non-null +let a = nonNullStringLiteral!; + ~~~~~~~~~~~~~~~~~~~~~ [0] +let b = nonNullString!; + ~~~~~~~~~~~~~~ [0] +let c = nullableString!; +tuple!; +~~~~~~ [0] + +// as +let d = nonNullStringLiteral as string; +let e = nonNullString as string; + ~~~~~~~~~~~~~~~~~~~~~~~ [0] +let f = nullableString as string; + +// type assertion +let g = nonNullStringLiteral; +let h = nonNullString; + ~~~~~~~~~~~~~~~~~~~~~ [0] +let i = nullableString; + +// complex inner expression +let j = (nonNullString + nonNullStringLiteral)!; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let k = (nonNullString + nonNullStringLiteral) as string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let l = (nonNullString + nonNullStringLiteral); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let m = nonNullString.trim()!; + ~~~~~~~~~~~~~~~~~~~~~ [0] +let n = nonNullString.trim() as string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let o = nonNullString.trim(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let p = nonNullString!.trim(); + ~~~~~~~~~~~~~~ [0] + +// custom types +interface Iface1 { + prop: string; +} +interface Iface2 { + prop: string; +} + +const value1: Iface1 = {prop: 'test'}; +const value2: Iface2 = {prop: 'test'}; + +let q = value1; + ~~~~~~~~~~~~~~ [0] +let r = value1; +let s = value2 as Iface2; + ~~~~~~~~~~~~~~~~ [0] +let t = value2 as Iface1; +let aa = anyType as AnyDuringMigration; + +interface TypeA { + kind: 'a'; +} +interface TypeB { + kind: 'b'; +} + +function isB(x: TypeA|TypeB): x is TypeB { + return true; +} + +function func(aOrB: TypeA|TypeB) { + let u = aOrB as TypeA; + let v = aOrB; + + if (aOrB.kind === 'a') { + let w = aOrB as TypeA; + ~~~~~~~~~~~~~ [0] + } else { + let x = aOrB; + ~~~~~~~~~~~ [0] + } + + if (isB(aOrB)) { + let y = aOrB as TypeB; + ~~~~~~~~~~~~~ [0] + } else { + let z = aOrB; + ~~~~~~~~~~~ [0] + } +} + +// Expecting no warning for these assertions as they are not unnecessary. + +type Bar = 'bar'; +const data = { + x: 'foo' as 'foo', + y: 'bar' as Bar, +} + +[1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); +let x: Array<[number, string]> = [1, 2, 3, 4, 5].map(x => [x, 'A' + x] as [number, string]); + +interface NotATuple { + 0: number, + 0.5: number, + 2: number, +} + +declare const notATuple: NotATuple; +notATuple; +~~~~~~~~~~~~~~~~~~~~ [0] + +function foo() { + let xx: 1 | 2 = 1; + const f = () => xx = 2; + f(); + xx as 1 | 2 === 2; // xx is inferred as 1, assertion is necessary to avoid compile error +} + +[0]: This assertion is unnecessary since it does not change the type of the expression. diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json b/test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json new file mode 100644 index 00000000000..52e6c965a46 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strictNullChecks/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "es2015", + "strictNullChecks": true + } +} diff --git a/test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json b/test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json new file mode 100644 index 00000000000..6c6fdcf5f38 --- /dev/null +++ b/test/rules/no-unnecessary-type-assertion/strictNullChecks/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unnecessary-type-assertion": [true, "AnyDuringMigration"] + } +} diff --git a/test/rules/no-unsafe-any/default/commonjsModule.ts b/test/rules/no-unsafe-any/default/commonjsModule.ts new file mode 100644 index 00000000000..d38fad21b9c --- /dev/null +++ b/test/rules/no-unsafe-any/default/commonjsModule.ts @@ -0,0 +1,3 @@ +const x: any = 0; +namespace x {} +export = x; diff --git a/test/rules/no-unsafe-any/default/es6Module.ts b/test/rules/no-unsafe-any/default/es6Module.ts new file mode 100644 index 00000000000..26ffb150702 --- /dev/null +++ b/test/rules/no-unsafe-any/default/es6Module.ts @@ -0,0 +1,8 @@ +const defaultExport: any = 0; +export default defaultExport; +export const namedExport: any = 0; +export type T = number; + +export namespace NS { + export interface ITest {} +} diff --git a/test/rules/no-unsafe-any/default/test.ts.lint b/test/rules/no-unsafe-any/default/test.ts.lint new file mode 100644 index 00000000000..3746de2495c --- /dev/null +++ b/test/rules/no-unsafe-any/default/test.ts.lint @@ -0,0 +1,348 @@ +import importEquals = require("./commonjsModule"); +import importAlias = importEquals; +namespace N { export const x: any = 0; } +import importQualifiedName = N.x; +import * as namespaceImport from "./es6Module"; +import defaultExport, { namedExport, NS } from "./es6Module"; +import namedExportAlias = namespaceImport.namedExport; + +const num: namespaceImport.T = 0; + +{ + const { x: { y, z } } = { x: { y: 1, z: 2 } }; + function f(a: any, b: { x: any }) { + const { g } = a; + ~~~~~ [0] + ~ [0] + const { x } = b; + } +} + +// Ignore number/string literal in type +function returnsA(): 0 | "a" | null | undefined { + return null; +} + +label: for (const x of [1]) { + continue label; +} +label: while(true) { + break label; +} + +importAlias.property; + +namespaceImport.namedExport; + +namedExport.foo; +~~~~~~~~~~~ [0] +namedExportAlias.foo; +~~~~~~~~~~~~~~~~ [0] +namedExport, namedExportAlias; + + +declare const x: any; +declare const hasProp: { x: any }; + +hasProp.x(1); +~~~~~~~~~ [0] + +declare function takesAny(a: any, ...bs: any[]): void; +declare function takesNumber(a: number, ...bs: number[]): void; + +takesAny(x, x); +takesNumber(x, x); + ~ [0] + ~ [0] + +declare function templateTakesAny(arr: TemplateStringsArray, a: any, ...bs: any[]): any; +declare function templateTakesNumber(arr: TemplateStringsArray, a: number, ...bs: number[]): any; + +templateTakesAny`${x}${x}`; +templateTakesNumber`${x}${x}`; + ~ [0] + ~ [0] +templateTakesAny`${x}`.prop; +~~~~~~~~~~~~~~~~~~~~~~ [0] + +declare function decoratorTakesAny(value: any): Function; +declare function decoratorTakesNumber(value: number): Function; +declare const decoratorIsAny: any; + +class C { + @decoratorTakesAny(x) f() {} + @decoratorTakesNumber(x) g() {} + ~ [0] + @decoratorIsAny h() {} + ~~~~~~~~~~~~~~ [0] +} + +x instanceof Date; +Date instanceof x; + ~ [0] + +const retBool: () => boolean = x; + ~ [0] + +function params(a: any = x, b: boolean = x) {} + ~ [0] + +function f(x: any, retAny: () => any): any { + x; + (x); + + x.foo; + ~ [0] + x(0); + ~ [0] + x``; + ~ [0] + x + 3; + ~ [0] + new x(); + ~ [0] + + retAny(); + retAny()[0]; + ~~~~~~~~ [0] + + // Same for constructors + new X(x); + new Y(x); + ~ [0] + + // Assignment: assign to 'any' OK, assign to other not OK. + const v0: any = x; + const v1: boolean = x; + ~ [0] + let v2: any, v3: boolean; + v2 = x; + v3 = x; + ~ [0] + + // Return OK if return type is 'any' + return x; +} + +function f2(x: any): boolean { + return x; + ~ [0] +} + +class X { + constructor(y: any) {} + + prop0: any = x; + prop1: number = x; + ~ [0] + +} +class Y { + constructor(x: number) {} +} + +function g(x: any): string { + if (x === undefined) { + return "undefined"; + } + if (typeof x === "string") { + return `string: ${x}`; + } + if (x instanceof Array) { + // Once it's been tested, OK to use it as an array. + return `Array, length ${x.length}`; + } + if (Math.random() > 0.5) { + // Allow explicit cast to 'any' + (x as any).whatchamacallit; + // Allow explicit cast + return ( x).toLowerCase() + (x as string).toUpperCase(); + } + + "" + x; + x + ""; + let s = ""; + s += x; + x += s; + ~ [0] + + return `other: ${x}`; +} + +function deleteOk(obj: { x: any }) { + delete obj.x; +} + +const obj: { x: number, y: number } = { + x: "number" as any, // Cast OK, and doesn't warn for LHS either. + [x]: 1, +}; + +switch (x) {} +switch (x.y) { + ~ [0] + case x: + x.y; + ~ [0] + break; + case x.y: + ~ [0] + break; +} + +declare global {} + +if (x) {} +if (!x) {} +if (!x || x) {} +for (;x;) {} +while (x) {} +do {} while (x); + +takesNumber(x ? x : x); + ~ [0] + ~ [0] +typeof x.prop; + ~ [0] + +function *gen1(): any { + yield x; + (yield).foo; + ~~~~~ [0] +} + +function *gen2() { + yield x; +} + +function *gen3(): IterableIterator { + yield x; + ~ [0] +} + +function *gen4(): IterableIterator { + yield x; +} + +void x; + +{ + let { a = x, b = x, c: d = x }: { a: number, b: any, c: string } = { a: 1, b: true, c: '' }; + ~ [0] + ~ [0] +} +{ + let {a, b} = x; + ~~~~~~ [0] + ~ [0] + let {c, d}: any = x; + ~~~~~~ [0] + let {x: {e, f}} = {x}; + ~~~~~~ [0] + ~ [0] + let {x: {g, h}}: {x: any} = {x}; + ~~~~~~ [0] + ({a, b} = x); + ~ [0] + ({x: {a, b}} = {x}); + ~ [0] +} +{ + let obj = {x}; + let {x: {a, b}} = obj; + ~~~~~~ [0] + ({x: {a, b}} = obj); // TODO show error on the inner destructuring +} +{ + let { a = x, b = x, c: d = x } = { a: 1, b: true, c: '' }; + ~ [0] + ~ [0] + ~ [0] +} +{ + let obj: {a: any, b: any} = null!; + let {a = x, b = x}: {a: number, b: any} = obj; + ~ [0] +} +{ + let a: number; + let b: any; + let c: string; + ({a = x, b: b = x, d: c = x} = {a: 1, b: x, d: ''}); + ~ [0] + ~ [0] +} +{ + class C { + prop: number = x; + ~ [0] + prop2 = x; + prop3: any = x; + } + class D extends C { + prop = x; + ~ [0] + prop2 = x; + prop3 = x; + } +} +{ + let obj = {x}; + let arr = [x]; +} +for (const {prop} of [x]) {} + ~~~~~~ [0] + +function predicate(x: any): x is number { + return typeof x === 'number'; +} + +function hasThisParameter(this: any) { + const v: number = this; + ~~~~ [0] +} + +(async function() { + return x; +}); +(async function(): Promise { + return x; +}); +(async function(): Promise { + return x; + ~ [0] +}) + +{ + let obj = {...x}; + ({...obj} = x); + ~~~ [0] + let arr = [...x]; + ~ [0] + predicate(...x); + ~ [0] +} + +namespace TestNS { + export interface ITest {} +} +namespace TestNS2 { + ""; + export interface ITest {} +} +{ + class Test implements TestNS.ITest {} + type T = any; + class Test2 implements T {} + ~ [0] + let C = null as any; + class Test3 extends C {} + ~ [0] + + interface I {} + class Test4 implements I {} + class Test5 implements TestNS2.ITest {} + class Test6 implements NS.ITest {} +} + +[0]: Unsafe use of expression of type 'any'. diff --git a/test/rules/no-unsafe-any/default/tsconfig.json b/test/rules/no-unsafe-any/default/tsconfig.json new file mode 100644 index 00000000000..2ea9f28254e --- /dev/null +++ b/test/rules/no-unsafe-any/default/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "experimentalDecorators": true + } +} diff --git a/test/rules/no-unsafe-any/default/tslint.json b/test/rules/no-unsafe-any/default/tslint.json new file mode 100644 index 00000000000..b44ff572bc8 --- /dev/null +++ b/test/rules/no-unsafe-any/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unsafe-any": true + } +} diff --git a/test/rules/no-unsafe-any/jsx/test.tsx.lint b/test/rules/no-unsafe-any/jsx/test.tsx.lint new file mode 100644 index 00000000000..edd49f1002c --- /dev/null +++ b/test/rules/no-unsafe-any/jsx/test.tsx.lint @@ -0,0 +1,15 @@ +declare const AnyComponent: any; + +const nativeJsxFull = ; +const nativeJsxShort = ; + +const nativeFragmentEmpty = <>; +const nativeFragmentFull = <>; + +const componentJsxFull = ; + ~~~~~~~~~~~~ [0] + ~~~~~~~~~~~~ [0] +const componentJsxShort = ; + ~~~~~~~~~~~~ [0] + +[0]: Unsafe use of expression of type 'any'. diff --git a/test/rules/no-unsafe-any/jsx/tsconfig.json b/test/rules/no-unsafe-any/jsx/tsconfig.json new file mode 100644 index 00000000000..0b75885e6e8 --- /dev/null +++ b/test/rules/no-unsafe-any/jsx/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "jsx": "react", + "module": "commonjs", + "target": "es6", + "experimentalDecorators": true + } +} diff --git a/test/rules/no-unsafe-any/jsx/tslint.json b/test/rules/no-unsafe-any/jsx/tslint.json new file mode 100644 index 00000000000..b44ff572bc8 --- /dev/null +++ b/test/rules/no-unsafe-any/jsx/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unsafe-any": true + } +} diff --git a/test/rules/no-unsafe-any/unknown/test.ts.lint b/test/rules/no-unsafe-any/unknown/test.ts.lint new file mode 100644 index 00000000000..1f955c599cb --- /dev/null +++ b/test/rules/no-unsafe-any/unknown/test.ts.lint @@ -0,0 +1,83 @@ +[typescript]: >= 3.0.0 + +/* + * It is not unsafe to pass any where unknown is allowed. This file checks + * these uses. + */ + +declare const x: any; + +declare function takesUnknown(a: unknown, ...bs: unknown[]): void; +takesUnknown(x, x); + +declare function templateTakesUnknown(arr: TemplateStringsArray, a: unknown, ...bs: unknown[]): any; +templateTakesUnknown`${x}${x}`; + +declare function decoratorTakesUnknown(value: unknown): Function; + +class C { + @decoratorTakesUnknown(x) f() {} +} + +function f(x: any, retAny: () => any): unknown { + const v2: unknown = x; + let v5: unknown; + v5 = x; + + // Return OK if return type is 'any' + return x; +} + +class X { + constructor(y: any) {} + prop: unknown = x; +} + +takesUnknown(x ? x : x); + +function *gen(): IterableIterator { + yield x; +} + +void x; + +{ + class C { + prop: unknown = x; + } + class D extends C { + prop = x; + } +} + +function hasThisParameter(this: any) { + const u: unknown = this; +} + +(async function(): Promise { + return x; +}); + +const obj = { property: "value" } as any; +const result: unknown = JSON.parse("{}"); + +const hasUnknownProp: { prop: unknown, obj: unknown } = { prop: obj, obj }; +hasUnknownProp.prop = obj; + +function acceptsUnknown(a: unknown, b: unknown = x) { } + +acceptsUnknown(obj); + +interface ContainsUnknownProperty { + e: unknown; +} + +const p: ContainsUnknownProperty = { e: (123 as any) }; + +function g() { + try { + + } catch (e) { + acceptsUnknown(e); + } +} diff --git a/test/rules/no-unsafe-any/unknown/tsconfig.json b/test/rules/no-unsafe-any/unknown/tsconfig.json new file mode 100644 index 00000000000..2ea9f28254e --- /dev/null +++ b/test/rules/no-unsafe-any/unknown/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "experimentalDecorators": true + } +} diff --git a/test/rules/no-unsafe-any/unknown/tslint.json b/test/rules/no-unsafe-any/unknown/tslint.json new file mode 100644 index 00000000000..b44ff572bc8 --- /dev/null +++ b/test/rules/no-unsafe-any/unknown/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unsafe-any": true + } +} diff --git a/test/rules/no-unsafe-finally/test.ts.lint b/test/rules/no-unsafe-finally/test.ts.lint new file mode 100644 index 00000000000..b64d8f7408c --- /dev/null +++ b/test/rules/no-unsafe-finally/test.ts.lint @@ -0,0 +1,376 @@ +function() { + try { + } finally { + return; + ~~~~~~~ [return] + } +} + +function() { + try { + } catch { + } finally { + return 1; + ~~~~~~~~~ [return] + } +} + +function() { + try { + } catch { + } finally { + { + return 1; + ~~~~~~~~~ [return] + } + } +} + +function() { + try { + } catch { + } finally { + for (let i = 0; i < 5; ++i) { + if (i % 2 === 0) { + return 1; + ~~~~~~~~~ [return] + } + } + } +} + +function() { + try { + } catch { + } finally { + let i = 1; + while (i < 5) { + if (i % 2 === 0) { + return i; + ~~~~~~~~~ [return] + } + + ++i; + } + } +} + +function() { + try { + } catch { + } finally { + let i = 1; + do { + if (i % 2 === 0) { + return i; + ~~~~~~~~~ [return] + } + + ++i; + } while (i < 5); + } +} + +function() { + try { + if (foo()) { + try { + bar(); + } catch { + } finally { + return 2; + ~~~~~~~~~ [return] + } + } + } catch { + } finally { + for (const i of [1, 2, 3, 4, 5]) { + if (i % 2 === 0) { + return 1; + ~~~~~~~~~ [return] + } + } + } +} + +function foo() { + try { + try { + } finally { + return 1; + ~~~~~~~~~ [return] + } + } catch { + } +} + +function foo() { + try { + } finally { + throw "error"; + ~~~~~~~~~~~~~~ [throw] + } +} + +function foo() { + for (const i of [1, 2, 3, 4, 5]) { + try { + } finally { + continue; + ~~~~~~~~~ [continue] + } + } +} + +function foo() { + for (const i of [1, 2, 3, 4, 5]) { + try { + } finally { + break; + ~~~~~~ [break] + } + } +} + +function foo() { + for (let i = 0; i < 5; ++i) { + try { + } finally { + continue; + ~~~~~~~~~ [continue] + } + } +} + +function foo() { + do { + try { + } finally { + continue; + ~~~~~~~~~ [continue] + } + } while (i > 0); +} + +function foo() { + while (i > 0) { + try { + } finally { + continue; + ~~~~~~~~~ [continue] + } + } +} + +function foo() { + do { + try { + } finally { + break; + ~~~~~~ [break] + } + } while (i > 0); +} + +function foo() { + while (i > 0) { + try { + } finally { + break; + ~~~~~~ [break] + } + } +} + +function foo() { + switch (a) { + case 1: + try { + return; + } finally { + break; + ~~~~~~ [break] + } + break; + default: + try { + } finally { + break; + ~~~~~~ [break] + } + break; + } +} + +function foo() { + label: + try { + } finally { + break label; + ~~~~~~~~~~~~ [break] + } +} + +function foo() { + label: + for (let i = 0; i < 4; ++i) { + try { + } finally { + break label; + ~~~~~~~~~~~~ [break] + } + } +} + +function foo() { + outer: + for (let i = 0; i < 4; ++i) { + try { + } finally { + inner: + for (let j = 0; j < 2; ++j) { + break outer; + ~~~~~~~~~~~~ [break] + } + } + } +} + +function foo() { + label: + for (let i = 0; i < 4; ++i) { + try { + } finally { + continue label; + ~~~~~~~~~~~~~~~ [continue] + } + } +} + +function foo() { + outer: + for (let i = 0; i < 4; ++i) { + try { + } finally { + inner: + for (let j = 0; j < 2; ++j) { + continue outer; + ~~~~~~~~~~~~~~~ [continue] + } + } + } +} + +// valid +function() { + try { + } finally { + (function() { + return 1; + })(); + } +} + +// valid +function() { + try { + foo(); + } finally { + class C { + bar() { + return 1; + } + } + } + + return 1; +} + +// valid +function() { + try { + } catch { + } finally { + for (let i = 0; i < 5; ++i) { + if (i % 2 === 0) { + continue; + } + } + } +} + +// valid +function() { + try { + } catch { + } finally { + for (let i = 0; i < 5; ++i) { + if (i % 2 === 0) { + break; + } + } + } +} + +// valid +function() { + try { + } catch { + } finally { + switch (a) { + case 1: + break; + default: + break; + } + } +} + +//valid +function() { + try { + } finally { + label: + break label; + } +} + +//valid +function() { + try { + } finally { + outer: + for (let i = 0; i < 2; ++i) { + if (i % 2 === 0) { + continue outer; + } + + inner: + for (let j = 0; j < 2; ++j) { + if (j % 2 === 0) { + continue outer; + } + } + } + } +} + +function() { + try { + } finally { + function f() { + return; + } + } +} + +try { +} finally { + break; + ~~~~~~ [break] +} + +[return]: 'return' statements in finally blocks are forbidden. +[throw]: 'throw' statements in finally blocks are forbidden. +[break]: 'break' statements in finally blocks are forbidden. +[continue]: 'continue' statements in finally blocks are forbidden. diff --git a/test/rules/no-unsafe-finally/tslint.json b/test/rules/no-unsafe-finally/tslint.json new file mode 100644 index 00000000000..0b957d11b67 --- /dev/null +++ b/test/rules/no-unsafe-finally/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unsafe-finally": true + } +} \ No newline at end of file diff --git a/test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint b/test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint new file mode 100644 index 00000000000..ca6bef0e813 --- /dev/null +++ b/test/rules/no-unused-expression/allow-fast-null-checks/test.ts.lint @@ -0,0 +1,143 @@ +"use strict"; +'use asm'; +"ngInject"; +''; + +function fun1() { + "use strict"; + 'someOtherDirective'; + return 0; +} + +(function() { "directive"; +'foo' +'directive2' +console.log('foo'); +'notdirective'; +~~~~~~~~~~~~~~~ [0] +})(); + +const a = () => { +'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } + ~~~~~~~~~~~~~~~ [0] + +function fun2(a: number) { + return 0; +} + +function fun3(a: number, b: number) { + return 0; +} + +namespace Fam { 'use strict'; 'use cool'; } +module Bam { 'use strict'; 'use cool'; } +namespace Az.Bz.Cz.Dz { + 'ngInject'; +} + +class Foo { + constructor() { + "ngInject"; + var a = 1; + 'notdirective'; + ~~~~~~~~~~~~~~~ [0] + } + + bar() { + 'use strict'; + } + + get baz() { + 'use asm'; + } + + set baz(newValue) { + "use asm"; + } +} + +// valid code: + +var i: number; +var j = 3; +i = 1 + 2; +j = fun1(); +fun1(); +fun2(2); +fun3(2, fun1()); +i++; +i += 2; +--i; +i <<= 2; +i = fun1() + fun1(); +j = (j === 0 ? 5 : 6); +(j === 0 ? fun1() : fun2(j)); +(a => 5)(4); +var obj = {}; +delete obj.key; +function* g(): Iterable { + for (let i = 0; i < 100; i++) { + yield i; + } +} + +async function f(foo: Promise): Promise { + await foo; + return 0; +} + +new Foo(); +~~~~~~~~~~ [0] + +// invalid code: + +5; +~~ [0] +i; +~~ [0] +3 + 5; +~~~~~~ [0] +fun1() + fun1(); +~~~~~~~~~~~~~~~~ [0] +fun2(i) + fun3(4,7); +~~~~~~~~~~~~~~~~~~~~ [0] +fun1() + 4; +~~~~~~~~~~~ [0] +4 + fun2(j); +~~~~~~~~~~~~ [0] +(j === 0 ? fun1() : 5); + ~ [0] +(j === 0 ? i : fun2(j)); + ~ [0] +a => fun2(a); +~~~~~~~~~~~~~ [0] +() => {return fun1();}; +~~~~~~~~~~~~~~~~~~~~~~~ [0] +"use strct"; +~~~~~~~~~~~~ [0] + +afterEach((el) => { + el && el.remove(); +}); + +checkParams((a, b) => { + (a || required('a')) && (b || required('b')); +}); + +checkParams((a, b) => { + ((a && b) || required('a, b')); +}); + +function interactionHandler(e) { + // fails in all cases since logical NOT operator is redundant + e && !e.preventDefault(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +a && b; +~~~~~~~ [0] +a() && b; +~~~~~~~~~ [0] +a() && b(); + +[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/allow-fast-null-checks/tslint.json b/test/rules/no-unused-expression/allow-fast-null-checks/tslint.json new file mode 100644 index 00000000000..a0cf399bd23 --- /dev/null +++ b/test/rules/no-unused-expression/allow-fast-null-checks/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-expression": [true, "allow-fast-null-checks"] + } +} diff --git a/test/rules/no-unused-expression/allow-new/test.ts.lint b/test/rules/no-unused-expression/allow-new/test.ts.lint new file mode 100644 index 00000000000..bb5542b6642 --- /dev/null +++ b/test/rules/no-unused-expression/allow-new/test.ts.lint @@ -0,0 +1,145 @@ +"use strict"; +'use asm'; +"ngInject"; +''; + +function fun1() { + "use strict"; + 'someOtherDirective'; + return 0; +} + +(function() { "directive"; +'foo' +'directive2' +console.log('foo'); +'notdirective'; +~~~~~~~~~~~~~~~ [0] +})(); + +const a = () => { +'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } + ~~~~~~~~~~~~~~~ [0] + +function fun2(a: number) { + return 0; +} + +function fun3(a: number, b: number) { + return 0; +} + +namespace Fam { 'use strict'; 'use cool'; } +module Bam { 'use strict'; 'use cool'; } +namespace Az.Bz.Cz.Dz { + 'ngInject'; +} + +class Foo { + constructor() { + "ngInject"; + var a = 1; + 'notdirective'; + ~~~~~~~~~~~~~~~ [0] + } + + bar() { + 'use strict'; + } + + get baz() { + 'use asm'; + } + + set baz(newValue) { + "use asm"; + } +} + +// valid code: + +var i: number; +var j = 3; +i = 1 + 2; +j = fun1(); +fun1(); +fun2(2); +fun3(2, fun1()); +i++; +i += 2; +--i; +i <<= 2; +i = fun1() + fun1(); +j = (j === 0 ? 5 : 6); +(j === 0 ? fun1() : fun2(j)); +(a => 5)(4); +var obj = {}; +delete obj.key; +function* g(): Iterable { + for (let i = 0; i < 100; i++) { + yield i; + } +} + +async function f(foo: Promise): Promise { + await foo; + return 0; +} + +new Foo(); + +bar.foo || (bar.foo = new Foo()); + +// invalid code: + +5; +~~ [0] +i; +~~ [0] +3 + 5; +~~~~~~ [0] +fun1() + fun1(); +~~~~~~~~~~~~~~~~ [0] +fun2(i) + fun3(4,7); +~~~~~~~~~~~~~~~~~~~~ [0] +fun1() + 4; +~~~~~~~~~~~ [0] +4 + fun2(j); +~~~~~~~~~~~~ [0] +(j === 0 ? fun1() : 5); + ~ [0] +(j === 0 ? i : fun2(j)); + ~ [0] +a => fun2(a); +~~~~~~~~~~~~~ [0] +() => {return fun1();}; +~~~~~~~~~~~~~~~~~~~~~~~ [0] +"use strct"; +~~~~~~~~~~~~ [0] + +afterEach((el) => { + el && el.remove(); +}); + +checkParams((a, b) => { + (a || required('a')) && (b || required('b')); +}); + +checkParams((a, b) => { + ((a && b) || required('a, b')); +}); + +function interactionHandler(e) { + // fails in all cases since logical NOT operator is redundant + e && !e.preventDefault(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +let var1, var2; +if (foo) + var1 = 1, var2 = 1; +else + var1 = 2, var2; + ~~~~ [0] + +[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/allow-new/tslint.json b/test/rules/no-unused-expression/allow-new/tslint.json new file mode 100644 index 00000000000..f340315a6d7 --- /dev/null +++ b/test/rules/no-unused-expression/allow-new/tslint.json @@ -0,0 +1,9 @@ +{ + "rules": { + "no-unused-expression": [ + true, + "allow-new", + "allow-fast-null-checks" + ] + } +} diff --git a/test/rules/no-unused-expression/allow-tagged-template/test.ts.lint b/test/rules/no-unused-expression/allow-tagged-template/test.ts.lint new file mode 100644 index 00000000000..2c69f6790ae --- /dev/null +++ b/test/rules/no-unused-expression/allow-tagged-template/test.ts.lint @@ -0,0 +1,194 @@ +"use strict"; +'use asm'; +"ngInject"; +''; + +function fun1() { + "use strict"; + 'someOtherDirective'; + return 0; +} + +(function() { "directive"; +'foo' +'directive2' +console.log('foo'); +'notdirective'; +~~~~~~~~~~~~~~~ [0] +})(); + +const a = () => { +'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } + ~~~~~~~~~~~~~~~ [0] + +function fun2(a: number) { + return 0; +} + +function fun3(a: number, b: number) { + return 0; +} + +namespace Fam { 'use strict'; 'use cool'; } +module Bam { 'use strict'; 'use cool'; } +namespace Az.Bz.Cz.Dz { + 'ngInject'; +} + +class Foo { + constructor() { + "ngInject"; + var a = 1; + 'notdirective'; + ~~~~~~~~~~~~~~~ [0] + } + + bar() { + 'use strict'; + } + + get baz() { + 'use asm'; + } + + set baz(newValue) { + "use asm"; + } +} + +// valid code: + +var i: number; +var j = 3; +i = 1 + 2; +j = fun1(); +fun1(); +fun2(2); +fun3(2, fun1()); +i++; +i += 2; +--i; +i <<= 2; +i = fun1() + fun1(); +j = (j === 0 ? 5 : 6); +(j === 0 ? fun1() : fun2(j)); +(a => 5)(4); +var obj = {}; +delete obj.key; +function* g(): Iterable { + for (let i = 0; i < 100; i++) { + yield i; + } +} + +async function f(foo: Promise): Promise { + await foo; + return 0; +} + +new Foo(); +~~~~~~~~~~ [0] + +// invalid code: + +5; +~~ [0] +i; +~~ [0] +3 + 5; +~~~~~~ [0] +fun1() + fun1(); +~~~~~~~~~~~~~~~~ [0] +fun2(i) + fun3(4,7); +~~~~~~~~~~~~~~~~~~~~ [0] +fun1() + 4; +~~~~~~~~~~~ [0] +4 + fun2(j); +~~~~~~~~~~~~ [0] +(j === 0 ? fun1() : 5); + ~ [0] +(j === 0 ? i : fun2(j)); + ~ [0] +a => fun2(a); +~~~~~~~~~~~~~ [0] +() => {return fun1();}; +~~~~~~~~~~~~~~~~~~~~~~~ [0] +"use strct"; +~~~~~~~~~~~~ [0] + +afterEach((el) => { + el && el.remove(); + ~~~~~~~~~~~~~~~~~~ [0] +}); + +checkParams((a, b) => { + (a || required('a')) && (b || required('b')); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +}); + +checkParams((a, b) => { + ((a && b) || required('a, b')); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +}); + +function interactionHandler(e) { + // fails in all cases since logical NOT operator is redundant + e && !e.preventDefault(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +let var1, var2; +if (foo) + var1 = 1, var2 = 1; +else + var1 = 2, var2; + ~~~~ [0] + +(0,eval)('"foobar";'); +(foo,eval)('"foobar";'); + ~~~ [0] +(foo(),eval)('"foobar";'); +(0, 1, eval)('"foobar";'); + ~~~~ [0] +(1, eval)('"foobar";'); + ~ [0] +(0, foo)('"foobar":'); + ~ [0] +var2 = (0, 1, 2); + ~~~~ [0] +(0, 1, 2); +~~~~~~~~~~ [0] + +var1 = void 0; +var1 = void 1; + ~ [0] +var1 = void foo; + ~~~ [0] +var1 = void foo === bar; + ~~~ [0] + +var1 = void (foo === bar); + ~~~~~~~~~~~~~ [0] +var1 = void (foo = bar); +var1 = void foo.bar; + ~~~~~~~ [0] +var1 = void foo(); + +switch(l) { + case 0, 1: + ~ [0] + return 'zero or one'; + default: + return 'more than one'; +} + +let x = Math.pow((3, 5)); + ~ [0] +let a = [(3 + 4), ((1 + 1, 8) * 4)]; + ~~~~~ [0] + +`foo`; +~~~~~~ [0] +foo`bar`; + +[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/allow-tagged-template/tslint.json b/test/rules/no-unused-expression/allow-tagged-template/tslint.json new file mode 100644 index 00000000000..0c85e06a62c --- /dev/null +++ b/test/rules/no-unused-expression/allow-tagged-template/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "no-unused-expression": [ + true, + "allow-tagged-template" + ] + } +} diff --git a/test/rules/no-unused-expression/default/test.ts.lint b/test/rules/no-unused-expression/default/test.ts.lint new file mode 100644 index 00000000000..88bf876a3fb --- /dev/null +++ b/test/rules/no-unused-expression/default/test.ts.lint @@ -0,0 +1,226 @@ +"use strict"; +'use asm'; +"ngInject"; +''; + +function fun1() { + "use strict"; + 'someOtherDirective'; + return 0; +} + +(function() { "directive"; +'foo' +'directive2' +console.log('foo'); +'notdirective'; +~~~~~~~~~~~~~~~ [0] +})(); + +const a = () => { +'use strict'; "use cool"; "use lint"; var a = 1; "notdirective"; } + ~~~~~~~~~~~~~~~ [0] + +function fun2(a: number) { + return 0; +} + +function fun3(a: number, b: number) { + return 0; +} + +namespace Fam { 'use strict'; 'use cool'; } +module Bam { 'use strict'; 'use cool'; } +namespace Az.Bz.Cz.Dz { + 'ngInject'; +} + +class Foo { + constructor() { + "ngInject"; + var a = 1; + 'notdirective'; + ~~~~~~~~~~~~~~~ [0] + } + + bar() { + 'use strict'; + } + + get baz() { + 'use asm'; + } + + set baz(newValue) { + "use asm"; + } +} + +// valid code: + +var i: number; +var j = 3; +i = 1 + 2; +j = fun1(); +fun1(); +fun2(2); +fun3(2, fun1()); +i++; +i += 2; +--i; +i <<= 2; +i = fun1() + fun1(); +j = (j === 0 ? 5 : 6); +(j === 0 ? fun1() : fun2(j)); +(a => 5)(4); +var obj = {}; +delete obj.key; +function* g(): Iterable { + for (let i = 0; i < 100; i++) { + yield i; + } +} + +async function f(foo: Promise): Promise { + await foo; + return 0; +} + +new Foo(); +~~~~~~~~~~ [0] + +// invalid code: + +5; +~~ [0] +i; +~~ [0] +3 + 5; +~~~~~~ [0] +fun1() + fun1(); +~~~~~~~~~~~~~~~~ [0] +fun2(i) + fun3(4,7); +~~~~~~~~~~~~~~~~~~~~ [0] +fun1() + 4; +~~~~~~~~~~~ [0] +4 + fun2(j); +~~~~~~~~~~~~ [0] +(j === 0 ? fun1() : 5); + ~ [0] +(j === 0 ? i : fun2(j)); + ~ [0] +a => fun2(a); +~~~~~~~~~~~~~ [0] +() => {return fun1();}; +~~~~~~~~~~~~~~~~~~~~~~~ [0] +"use strct"; +~~~~~~~~~~~~ [0] + +afterEach((el) => { + el && el.remove(); + ~~~~~~~~~~~~~~~~~~ [0] +}); + +checkParams((a, b) => { + (a || required('a')) && (b || required('b')); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +}); + +checkParams((a, b) => { + ((a && b) || required('a, b')); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +}); + +function interactionHandler(e) { + // fails in all cases since logical NOT operator is redundant + e && !e.preventDefault(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +a && b ? a : b; +~~~~~~~~~~~~~~~ [0] + +a && b; +~~~~~~~ [0] +a() && b; +~~~~~~~~~ [0] +a() && b(); +~~~~~~~~~~~ [0] + +let var1, var2; +if (foo) + var1 = 1, var2 = 1; +else + var1 = 2, var2; + ~~~~ [0] +var1, var2; +~~~~~~~~~~~ [0] + +(0,eval)('"foobar";'); +(foo,eval)('"foobar";'); + ~~~ [0] +(foo(),eval)('"foobar";'); +(foo(), 0, eval)('"foobar";'); + ~ [0] +(0, 1, eval)('"foobar";'); + ~~~~ [0] +(1, eval)('"foobar";'); + ~ [0] +(0, foo)('"foobar";'); + ~ [0] +var2 = (0, 1, 2); + ~~~~ [0] +(0, 1, 2); +~~~~~~~~~~ [0] +(0, 1, foo()); + ~~~~ [0] + +var1 = void 0; +var1 = void(0); +var1 = void 1; + ~ [0] +var1 = void(1); + ~~~ [0] +var1 = void foo; + ~~~ [0] +var1 = void foo === bar; + ~~~ [0] + +var1 = void (foo === bar); + ~~~~~~~~~~~~~ [0] +var1 = void (foo = bar); +var1 = void foo.bar; + ~~~~~~~ [0] +var1 = void foo(); + +void foo(); +void (foo && foo()); +~~~~~~~~~~~~~~~~~~~~ [0] +void 0; +~~~~~~~ [0] +void (foo = bar); +void 1; +~~~~~~~ [0] +foo ? bar = foo : void 0; + ~~~~~~ [0] +var1 = foo ? void (foo && foo()) : void 0; + +switch(l) { + case 0, 1: + ~ [0] + return 'zero or one'; + default: + return 'more than one'; +} + +let x = Math.pow((3, 5)); + ~ [0] +let a = [(3 + 4), ((1 + 1, 8) * 4)]; + ~~~~~ [0] + +`foo`; +~~~~~~ [0] +foo`bar`; +~~~~~~~~~ [0] + +[0]: unused expression, expected an assignment or function call diff --git a/test/rules/no-unused-expression/default/tslint.json b/test/rules/no-unused-expression/default/tslint.json new file mode 100644 index 00000000000..042bc2f9ac4 --- /dev/null +++ b/test/rules/no-unused-expression/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-expression": true + } +} diff --git a/test/rules/no-unused-variable/check-parameters/test.ts.lint b/test/rules/no-unused-variable/check-parameters/test.ts.lint new file mode 100644 index 00000000000..95aa5f377a9 --- /dev/null +++ b/test/rules/no-unused-variable/check-parameters/test.ts.lint @@ -0,0 +1,88 @@ +[typescript]: < 2.9.0 +export function func1(x: number, y: number, ...args: number[]) { + ~~~~ [err % ('args')] + return x + y; +} + +export function func2(x: number, y: number, ...args: number[]) { + ~ [err % ('y')] + return x + args[0]; +} + +export function func3(x?: number, y?: number) { + ~ [err % ('y')] + return x; +} + +export interface ITestInterface { + func4(x: number, y: number): number; +} + +export class ABCD { + constructor(private x: number, public y: number, private z: number) { + ~ [prop % ('x')] + } + + func5() { + return this.z; + } +} + +export interface ITestMapInterface { + [key: string]: string; +} + +export function func6(...args: number[]) { + return args; +} + +export function func7(f: (x: number) => number) { + return f; +} + +export function func8([x, y]: [number, number]) { + ~ [err % ('y')] + return x; +} + +export class DestructuringTests { + constructor(public x: number, public [y, z]) { // tsc error on binding pattern + } + + public func9({a, b}) { + ~ [err % ('b')] + return a; + } + + public func10([a, b]) { + ~ [err % ('b')] + return [a]; + } + + // destructuring with default value + public func11([x = 0]) { + ~ [err % ('x')] + return; + } +} + +abstract class AbstractTest { +#if typescript >= 2.9.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~ ['AbstractTest' is declared but never used.] +#endif +#if typescript >= 2.8.0 < 2.9.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ('AbstractTest')] +#endif +#if typescript < 2.8.0 + ~~~~~~~~~~~~ [err % ('AbstractTest')] +#endif + abstract foo(x); +} + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +[prop]: Property '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +[prop]: Property '%s' is declared but never used. +#endif diff --git a/test/rules/no-unused-variable/check-parameters/tsconfig.json b/test/rules/no-unused-variable/check-parameters/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-unused-variable/check-parameters/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-unused-variable/check-parameters/tslint.json b/test/rules/no-unused-variable/check-parameters/tslint.json new file mode 100644 index 00000000000..ab3b45be1f5 --- /dev/null +++ b/test/rules/no-unused-variable/check-parameters/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-variable": [true, "check-parameters"] + } +} diff --git a/test/rules/no-unused-variable/default/class.ts.lint b/test/rules/no-unused-variable/default/class.ts.lint new file mode 100644 index 00000000000..54e168a045f --- /dev/null +++ b/test/rules/no-unused-variable/default/class.ts.lint @@ -0,0 +1,31 @@ +[typescript]: < 2.9.0 +class ABCD { + private z2: number; + ~~ [err % ('z2')] + constructor() { + } + + mfunc1() { + // + } + + public mfunc2() { + this.mfunc3(); + } + + private mfunc3() { + // + } + + private mfunc4() { + ~~~~~~ [err % ('mfunc4')] + // + } + static stillPublic: number; +} + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +#endif diff --git a/test/rules/no-unused-variable/default/false-positives.ts.lint b/test/rules/no-unused-variable/default/false-positives.ts.lint new file mode 100644 index 00000000000..61ed54826de --- /dev/null +++ b/test/rules/no-unused-variable/default/false-positives.ts.lint @@ -0,0 +1,69 @@ +[typescript]: < 2.9.0 +// case 1 +const fs = require("fs"); + +module Foo { +#if typescript >= 2.8.0 +~~~~~~~~~~ [err % ('Foo')] +#else + ~~~ [err % ('Foo')] +#endif + const path = require("path"); + + console.log(fs); + console.log(path); +} + +// case 2 +class HelloWorld { + constructor(public name: string) { } + sayHello() { + return `Hello, ${this.name}!`; + } +}; + +let hello = new HelloWorld("TSLint"); +hello.sayHello(); + +// case 3 +import Bar = whatever.that.Foo; + +module some.module.blah { +#if typescript >= 2.8.0 +~~~~~~~~~~~ [err % ('some')] +#else + ~~~~ [err % ('some')] +#endif + export class bar { + private bar: Bar; + constructor() { + console.log(this.bar); + } + } +} + +// case 4 +import DateTimeOpts = Intl.DateTimeFormatOptions; + +interface MyDateTimeOpts extends DateTimeOpts { + timezoneOffset: number; +} + +let opts: MyDateTimeOpts; +console.log(opts.timezoneOffset - 1); + +import * as myLib from 'a'; +export { myLib }; + +import foo from 'a'; +const bar = {foo}; +myFunc(bar); + +import a from "a"; +export { a }; + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +#endif diff --git a/test/rules/no-unused-variable/default/function.ts.lint b/test/rules/no-unused-variable/default/function.ts.lint new file mode 100644 index 00000000000..a844cfbcf70 --- /dev/null +++ b/test/rules/no-unused-variable/default/function.ts.lint @@ -0,0 +1,39 @@ +[typescript]: < 2.9.0 +function func1(x: number, y: number) { + return x + y; +} + +var func2 = () => { + ~~~~~ [err % ('func2')] + // +}; + +function func3() { +#if typescript >= 2.8.0 +~~~~~~~~~~~~~~ [err % ('func3')] +#else + ~~~~~ [err % ('func3')] +#endif + return func1(1, 2); +} + +export function func4() { + return func1(2, 3); +} + +declare function func5(): any; +#if typescript >= 2.8.0 +~~~~~~~~~~~~~~~~~~~~~~ [err % ('func5')] +#else + ~~~~~ [err % ('func5')] +#endif + +export default function () { + return 0; +} + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +#endif diff --git a/test/rules/no-unused-variable/default/import.ts.fix b/test/rules/no-unused-variable/default/import.ts.fix new file mode 100644 index 00000000000..961e3f72bad --- /dev/null +++ b/test/rules/no-unused-variable/default/import.ts.fix @@ -0,0 +1,53 @@ +/** + * Some license that appears in the leading trivia of a statement that will be deleted. + * This text will not be deleted. + */ +import $ = require("a"); +import _ = require("a"); +import {a2 as aa2} from "a"; +aa2; +import {a3 as aa3} from "a"; +aa3; +// This import statement is unused and will be deleted along with this comment. +import {a8} from "a"; +a8; +import {a13} from "a"; +a13; +import {a14, a16} from "a"; +a14; +a16; + +// Leading comment will not be deleted +// Next comment will not be deleted + +export import a = require("a"); + +$(_.xyz()); + +/// + +module S { + var template = ""; +} + +import * as bar from "a"; +import baz from "a"; +import { namedExport } from "a"; +import d3 from "a"; +d3; + +d3; +d3; +d3;d3; + +bar.someFunc(); +baz(); +namedExport(); + +import "a"; + +import abc = require('a'); +import def = abc.someVar; +console.log(def); + + diff --git a/test/rules/no-unused-variable/default/import.ts.lint b/test/rules/no-unused-variable/default/import.ts.lint new file mode 100644 index 00000000000..45fb1651d6a --- /dev/null +++ b/test/rules/no-unused-variable/default/import.ts.lint @@ -0,0 +1,91 @@ +[typescript]: < 2.9.0 +/** + * Some license that appears in the leading trivia of a statement that will be deleted. + * This text will not be deleted. + */ +import xyz = require("a"); + ~~~ [err % ('xyz')] +import $ = require("a"); +import _ = require("a"); +import {a1 as aa1, a2 as aa2} from "a"; + ~~~ [err % ('aa1')] +aa2; +import {a3 as aa3, a4 as aa4} from "a"; + ~~~ [err % ('aa4')] +aa3; +// This import statement is unused and will be deleted along with this comment. +import {a5, a6} from "a"; +~~~~~~~~~~~~~~~~~~~~~~~~~ [allErr] +import {a7} from "a"; +~~~~~~~~~~~~~~~~~~~~~ [allErr] +import {a8, a9, a10} from "a"; + ~~ [err % ('a9')] + ~~~ [err % ('a10')] +a8; +import {a11, a12, a13} from "a"; + ~~~ [err % ('a11')] + ~~~ [err % ('a12')] +a13; +import {a14, a15, a16} from "a"; + ~~~ [err % ('a15')] +a14; +a16; + +// Leading comment will not be deleted +import {unusedFunction} from "legacyDependency"; // Import unusedFunction because .... +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [allErr] +// Next comment will not be deleted + +export import a = require("a"); + +$(_.xyz()); + +/// + +module S { +#if typescript >= 2.8.0 +~~~~~~~~ [err % ('S')] +#else + ~ [err % ('S')] +#endif + var template = ""; + ~~~~~~~~ [err % ('template')] +} + +import * as foo from "a"; + ~~~ [err % ('foo')] +import * as bar from "a"; +import baz from "a"; +import defaultExport, { namedExport } from "a"; + ~~~~~~~~~~~~~ [err % ('defaultExport')] +import d1, { d2 } from "a"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [allErr] +import d3, { d4 } from "a"; + ~~~~~~ [All named bindings are unused.] +d3; + +d3;import d5 from "a"; + ~~~~~~~~~~~~~~~~~~~ [allErr] +import d6 from "a";d3; +~~~~~~~~~~~~~~~~~~~ [allErr] +d3;import d7 from "a";d3; + ~~~~~~~~~~~~~~~~~~~ [allErr] + +bar.someFunc(); +baz(); +namedExport(); + +import "a"; + +import abc = require('a'); +import def = abc.someVar; +console.log(def); + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +#endif + +[allErr]: All imports on this line are unused. +[allErrDecl]: All imports in import declaration are unused. diff --git a/test/rules/no-unused-variable/default/node_modules/a.ts b/test/rules/no-unused-variable/default/node_modules/a.ts new file mode 100644 index 00000000000..85e5dcf1ed9 --- /dev/null +++ b/test/rules/no-unused-variable/default/node_modules/a.ts @@ -0,0 +1,2 @@ +declare var x: any; +export = x; diff --git a/test/rules/no-unused-variable/default/node_modules/react.ts b/test/rules/no-unused-variable/default/node_modules/react.ts new file mode 100644 index 00000000000..6c1838c3425 --- /dev/null +++ b/test/rules/no-unused-variable/default/node_modules/react.ts @@ -0,0 +1 @@ +export default x = 0; \ No newline at end of file diff --git a/test/rules/no-unused-variable/default/node_modules/react/addons.ts b/test/rules/no-unused-variable/default/node_modules/react/addons.ts new file mode 100644 index 00000000000..d6d31ab1196 --- /dev/null +++ b/test/rules/no-unused-variable/default/node_modules/react/addons.ts @@ -0,0 +1 @@ +export const x = 0; \ No newline at end of file diff --git a/test/rules/no-unused-variable/default/react-addons1.tsx.lint b/test/rules/no-unused-variable/default/react-addons1.tsx.lint new file mode 100644 index 00000000000..e416a7fd69b --- /dev/null +++ b/test/rules/no-unused-variable/default/react-addons1.tsx.lint @@ -0,0 +1,5 @@ +[typescript]: >= 2.1.0 < 2.9.0 + +import * as React from "react/addons"; + +console.log(
); diff --git a/test/rules/no-unused-variable/default/react-addons2.tsx.lint b/test/rules/no-unused-variable/default/react-addons2.tsx.lint new file mode 100644 index 00000000000..1fbc8455304 --- /dev/null +++ b/test/rules/no-unused-variable/default/react-addons2.tsx.lint @@ -0,0 +1,4 @@ +[typescript]: < 2.9.0 +import * as React from "react/addons"; + +export class MyComponent extends React.Component<{}, {}> {} diff --git a/test/rules/no-unused-variable/default/react-addons3.tsx.lint b/test/rules/no-unused-variable/default/react-addons3.tsx.lint new file mode 100644 index 00000000000..65b914d5bf3 --- /dev/null +++ b/test/rules/no-unused-variable/default/react-addons3.tsx.lint @@ -0,0 +1,7 @@ +[typescript]: < 2.9.0 +import * as React from "react/addons"; +#if typescript >= 2.6.0 + ~~~~~ ['React' is declared but its value is never read.] +#else + ~~~~~ ['React' is declared but never used.] +#endif diff --git a/test/rules/no-unused-variable/default/react1.tsx.lint b/test/rules/no-unused-variable/default/react1.tsx.lint new file mode 100644 index 00000000000..7ba79ea6418 --- /dev/null +++ b/test/rules/no-unused-variable/default/react1.tsx.lint @@ -0,0 +1,5 @@ +[typescript]: >= 2.1.0 < 2.9.0 + +import * as React from "react"; + +console.log(
); diff --git a/test/rules/no-unused-variable/default/react2.tsx.lint b/test/rules/no-unused-variable/default/react2.tsx.lint new file mode 100644 index 00000000000..e3be995c34d --- /dev/null +++ b/test/rules/no-unused-variable/default/react2.tsx.lint @@ -0,0 +1,4 @@ +[typescript]: < 2.9.0 +import * as React from "react"; + +export class MyComponent extends React.Component<{}, {}> {} diff --git a/test/rules/no-unused-variable/default/react3.tsx.lint b/test/rules/no-unused-variable/default/react3.tsx.lint new file mode 100644 index 00000000000..c509ec72b6a --- /dev/null +++ b/test/rules/no-unused-variable/default/react3.tsx.lint @@ -0,0 +1,7 @@ +[typescript]: < 2.9.0 +import * as React from "react"; +#if typescript >= 2.6.0 + ~~~~~ ['React' is declared but its value is never read.] +#else + ~~~~~ ['React' is declared but never used.] +#endif diff --git a/test/rules/no-unused-variable/default/react4.tsx.lint b/test/rules/no-unused-variable/default/react4.tsx.lint new file mode 100644 index 00000000000..c509ec72b6a --- /dev/null +++ b/test/rules/no-unused-variable/default/react4.tsx.lint @@ -0,0 +1,7 @@ +[typescript]: < 2.9.0 +import * as React from "react"; +#if typescript >= 2.6.0 + ~~~~~ ['React' is declared but its value is never read.] +#else + ~~~~~ ['React' is declared but never used.] +#endif diff --git a/test/rules/no-unused-variable/default/tsconfig.json b/test/rules/no-unused-variable/default/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-unused-variable/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-unused-variable/default/tslint.json b/test/rules/no-unused-variable/default/tslint.json new file mode 100644 index 00000000000..b1d833a0963 --- /dev/null +++ b/test/rules/no-unused-variable/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-variable": true + } +} diff --git a/test/rules/no-unused-variable/default/var.ts.lint b/test/rules/no-unused-variable/default/var.ts.lint new file mode 100644 index 00000000000..5cff354df76 --- /dev/null +++ b/test/rules/no-unused-variable/default/var.ts.lint @@ -0,0 +1,92 @@ +[typescript]: < 2.9.0 +var x = 3; + +var y = x; + ~ [err % ('y')] +var z; +#if typescript >= 2.6.0 + ~ [err % ('z')] +#endif + +export var abcd = 3; + +class ABCD { +#if typescript >= 2.9.0 +~~~~~~~~~~ ['ABCD' is declared but never used.] +#endif +#if typescript >= 2.8.0 < 2.9.0 +~~~~~~~~~~ [err % ('ABCD')] +#endif +#if typescript < 2.8.0 + ~~~~ [err % ('ABCD')] +#endif + constructor() { + z = 3; + } +} + +try { + // code here +} catch (e) { + // e is unused but that's still ok +} + +declare var tmp: any; + ~~~ [err % ('tmp')] + +export function testDestructuring() { + var [a, b] = [1, 2]; + ~ [err % ('a')] + ~ [err % ('b')] + var [c] = [3]; + + var {d, e} = { d: 1, e: 2 }; +#if typescript >= 2.9.0 + ~~~~~~ [All destructured elements are unused.] +#else + ~ [err % ('d')] + ~ [err % ('e')] +#endif + var {f} = { f: 3 }; + + return c * f; +} + +export var [foo, bar] = [1, 2]; + +export function testUnusedSpread() { + var a = [1, 2]; + ~ [err % ('a')] + var b = [3, 4]; + var c = [...b, 5]; // make sure we see that b is being used + + return c; + +} + +for(let e of [1,2,3]) { + ~ [err % ('e')] + +} + +export function testRenamingDestructure() { + var a = 2; + let {a: b} = {a: 4}; +#if typescript >= 2.9.0 + ~~~~~~ [err % ('b')] +#endif +#if typescript >= 2.8.0 < 2.9.0 + ~~~~ [err % ('b')] +#endif +#if typescript < 2.8.0 + ~ [err % ('b')] +#endif + let {x: y} = {x: 7}; // false positive + return a + y; +} + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +#endif diff --git a/test/rules/no-unused-variable/ignore-pattern/a.test.ts b/test/rules/no-unused-variable/ignore-pattern/a.test.ts new file mode 100644 index 00000000000..3f0fe05dfe0 --- /dev/null +++ b/test/rules/no-unused-variable/ignore-pattern/a.test.ts @@ -0,0 +1 @@ +export class _A {} diff --git a/test/rules/no-unused-variable/ignore-pattern/tsconfig.json b/test/rules/no-unused-variable/ignore-pattern/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-unused-variable/ignore-pattern/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-unused-variable/ignore-pattern/tslint.json b/test/rules/no-unused-variable/ignore-pattern/tslint.json new file mode 100644 index 00000000000..6e81221de24 --- /dev/null +++ b/test/rules/no-unused-variable/ignore-pattern/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-variable": [true, {"ignore-pattern": "^[_R]"}] + } +} diff --git a/test/rules/no-unused-variable/ignore-pattern/var.ts.lint b/test/rules/no-unused-variable/ignore-pattern/var.ts.lint new file mode 100644 index 00000000000..4c067d4d355 --- /dev/null +++ b/test/rules/no-unused-variable/ignore-pattern/var.ts.lint @@ -0,0 +1,107 @@ +[typescript]: < 2.9.0 +import { _A } from './a.test'; + +var x = 3; + +var y = x; + ~ [err % ('y')] +var _y = x; +var z; +#if typescript >= 2.6.0 + ~ [err % ('z')] +#endif + +export var abcd = 3; + +class ABCD { +#if typescript >= 2.9.0 +~~~~~~~~~~ ['ABCD' is declared but never used.] +#endif +#if typescript >= 2.8.0 < 2.9.0 +~~~~~~~~~~ [err % ('ABCD')] +#endif +#if typescript < 2.8.0 + ~~~~ [err % ('ABCD')] +#endif + constructor() { + z = 3; + } +} + +try { + // code here +} catch (e) { + // e is Unused but that's still ok +} + +declare var tmp: any; + ~~~ [err % ('tmp')] + +export function testDestructuring() { + var [a, b] = [1, 2]; + ~ [err % ('a')] + ~ [err % ('b')] + var [_a, _b] = [1, 2]; + var [c] = [3]; + + var {d, e} = { d: 1, e: 2 }; +#if typescript >= 2.9.0 + ~~~~~~ [All destructured elements are unused.] +#else + ~ [err % ('d')] + ~ [err % ('e')] +#endif + var {d: _d, e: _e} = { d: 1, e: 2 }; +#if typescript >= 2.9.0 + ~~~~~~~~~~~~~~ [All destructured elements are unused.] +#endif + // this above is incorrect, unfortunately w/ TS 2.9+, ignore pattern doesn't work for this sort of error + var {f} = { f: 3 }; + + return c * f; +} + +export var [foo, bar] = [1, 2]; + +export function testUnusedSpread() { + var a = [1, 2]; + ~ [err % ('a')] + var _a = [1, 2]; + var b = [3, 4]; + var c = [...b, 5]; // make sure we see that b is being used + + return c; + +} + +for(let e of [1,2,3]) { + ~ [err % ('e')] + +} + +for(let _e of [1,2,3]) { + +} + +export function testRenamingDestructure() { + var a = 2; + let {a: b} = {a: 4}; +#if typescript >= 2.9.0 + ~~~~~~ [err % ('b')] +#endif +#if typescript >= 2.8.0 < 2.9.0 + ~~~~ [err % ('b')] +#endif +#if typescript < 2.8.0 + ~ [err % ('b')] +#endif + let {a: _b} = {a: 4}; + let {x: y} = {x: 7}; // false positive + return a + y; +} + +#if typescript >= 2.6.0 +[err]: '%s' is declared but its value is never read. +#else +[err]: '%s' is declared but never used. +#endif diff --git a/test/rules/no-unused-variable/type-checked/a.test.ts b/test/rules/no-unused-variable/type-checked/a.test.ts new file mode 100644 index 00000000000..abfc7078006 --- /dev/null +++ b/test/rules/no-unused-variable/type-checked/a.test.ts @@ -0,0 +1,2 @@ +export class A {} +export var a: A; diff --git a/test/rules/no-unused-variable/type-checked/destructuring.ts.lint b/test/rules/no-unused-variable/type-checked/destructuring.ts.lint new file mode 100644 index 00000000000..b83d808dd8a --- /dev/null +++ b/test/rules/no-unused-variable/type-checked/destructuring.ts.lint @@ -0,0 +1,15 @@ +[typescript]: < 2.9.0 +import { SomeClass, someVar } from "./some.test"; +const person = { name: "alice" }; +const { name } = person; +#if typescript >= 2.9.0 + ~~~~~~~~ ['name' is declared but its value is never read.] +#endif +#if typescript >= 2.6.0 < 2.9.0 + ~~~~ ['name' is declared but its value is never read.] +#endif +#if typescript < 2.6.0 + ~~~~ ['name' is declared but never used.] +#endif + +export const {prop} = someVar; diff --git a/test/rules/no-unused-variable/type-checked/some.test.ts b/test/rules/no-unused-variable/type-checked/some.test.ts new file mode 100644 index 00000000000..334bcaebd46 --- /dev/null +++ b/test/rules/no-unused-variable/type-checked/some.test.ts @@ -0,0 +1,3 @@ +export class SomeClass {} + +export const someVar = {prop: new SomeClass()}; diff --git a/test/rules/no-unused-variable/type-checked/test.ts.lint b/test/rules/no-unused-variable/type-checked/test.ts.lint new file mode 100644 index 00000000000..aa2ee88fa30 --- /dev/null +++ b/test/rules/no-unused-variable/type-checked/test.ts.lint @@ -0,0 +1,6 @@ +[typescript]: < 2.9.0 +import {a, A} from './a.test'; + +export class B { + static thing = a; +} diff --git a/test/rules/no-unused-variable/type-checked/tsconfig.json b/test/rules/no-unused-variable/type-checked/tsconfig.json new file mode 100644 index 00000000000..db953a729b9 --- /dev/null +++ b/test/rules/no-unused-variable/type-checked/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "declaration": true + } +} \ No newline at end of file diff --git a/test/rules/no-unused-variable/type-checked/tslint.json b/test/rules/no-unused-variable/type-checked/tslint.json new file mode 100644 index 00000000000..b1d833a0963 --- /dev/null +++ b/test/rules/no-unused-variable/type-checked/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-variable": true + } +} diff --git a/test/rules/no-use-before-declare/$.ts b/test/rules/no-use-before-declare/$.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/ImportAliasSecond.ts b/test/rules/no-use-before-declare/ImportAliasSecond.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/ImportAliasWithComment.ts b/test/rules/no-use-before-declare/ImportAliasWithComment.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/ImportRegularAlias.ts b/test/rules/no-use-before-declare/ImportRegularAlias.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/ImportWithLineBreaks.ts b/test/rules/no-use-before-declare/ImportWithLineBreaks.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/InterfaceFile.ts b/test/rules/no-use-before-declare/InterfaceFile.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/lib.ts b/test/rules/no-use-before-declare/lib.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-use-before-declare/test.ts.lint b/test/rules/no-use-before-declare/test.ts.lint new file mode 100644 index 00000000000..d8cf57c1805 --- /dev/null +++ b/test/rules/no-use-before-declare/test.ts.lint @@ -0,0 +1,105 @@ +subscribe(({ meta: newMeta }: {meta: SessionMeta}) => { + this.setCount(newMeta.match_count); +}); + +subscribe(({ meta: newMeta }) => this.setCount(meta.match_count)); + +$.x = 3; +~ [variable '$' used before declaration] +import $ = require("./$"); +var vara = varb, varb; + ~~~~ [variable 'varb' used before declaration] + +class Test { + constructor() { + this.a = 3; + } + + private a: number; +} + +var i = j; + ~ [variable 'j' used before declaration] + +class ClassA { + prop: number; + constructor(object: ClassB) { + this.prop = object.prop; + } +} + +class ClassB { + prop: number; +} + +var j: number; + +if (something) { + var defined = 1; +} else { + var defined; +} + +testUndeclaredImports(); // Function early reference OK + +function testUndeclaredImports() { + console.log(foo1); + ~~~~ [variable 'foo1' used before declaration] + console.log(foo2); + ~~~~ [variable 'foo2' used before declaration] + console.log(foo3); + ~~~~ [variable 'foo3' used before declaration] + map([], (x) => x); + ~~~ [variable 'map' used before declaration] +} + +import { default as foo1 } from "./lib"; +import foo2 from "./lib"; +import _, { map, foldl } from "./underscore"; +import * as foo3 from "./lib"; +import "./lib"; + +export default function () { + // +}; + +export { + undeclaredA, + ~~~~~~~~~~~ [variable 'undeclaredA' used before declaration] + undeclaredB, + ~~~~~~~~~~~ [variable 'undeclaredB' used before declaration] + undeclaredC, + ~~~~~~~~~~~ [variable 'undeclaredC' used before declaration] + testUndeclaredImports +}; + +var undeclaredA = 42; +var { undeclaredB } = { undeclaredB: 43 }; +var { undeclaredB: undeclaredA } = { undeclaredB: 43 }; +var { undeclaredB: undeclaredA, undeclaredC } = { undeclaredB: 43, undeclaredC: 'hello' }; +var { undeclaredB: undeclaredA, undeclaredC: undeclaredD } = { undeclaredB: 43, undeclaredC: 'hello' }; +const [ undeclaredC, [undeclaredD] ] = [ 1, [2] ]; + +// shouldn't crash tslint +function a() { + var b = ({c: dog}) => { dog++; }; + b({ c: 5 }); +} + +import { ITest as ITest0 } from './ImportRegularAlias'; +import {/*ensure comments works*/ ITest as ITest1 } from './ImportAliasWithComment'; +import { + ITest as ITest2 +} from './ImportWithLineBreaks'; +import {First, ITest as ITest3 } from './ImportAliasSecond'; + +import ITest from './InterfaceFile'; + +class Greeter { + greet(options: { str: string }) { + var {str} = options; + return str; + } +} + +undefined; diff --git a/test/rules/no-use-before-declare/tsconfig.json b/test/rules/no-use-before-declare/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-use-before-declare/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-use-before-declare/tslint.json b/test/rules/no-use-before-declare/tslint.json new file mode 100644 index 00000000000..744ae40f6ff --- /dev/null +++ b/test/rules/no-use-before-declare/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-use-before-declare": true + } +} diff --git a/test/rules/no-use-before-declare/underscore.ts b/test/rules/no-use-before-declare/underscore.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/rules/no-var-keyword/global.d.ts.lint b/test/rules/no-var-keyword/global.d.ts.lint new file mode 100644 index 00000000000..76f30701892 --- /dev/null +++ b/test/rules/no-var-keyword/global.d.ts.lint @@ -0,0 +1,8 @@ +declare var x: number; + +declare namespace N { + var y: number; + ~~~ [0] +} + +[0]: Forbidden 'var' keyword, use 'let' or 'const' instead diff --git a/test/rules/no-var-keyword/module.d.ts.lint b/test/rules/no-var-keyword/module.d.ts.lint new file mode 100644 index 00000000000..50210412d76 --- /dev/null +++ b/test/rules/no-var-keyword/module.d.ts.lint @@ -0,0 +1,17 @@ +export var x: number; + ~~~ [0] + +declare global { + var x: number; +} + +declare namespace foo.global { + var x: number; + ~~~ [0] + export namespace global { + var x: number; + ~~~ [0] + } +} + +[0]: Forbidden 'var' keyword, use 'let' or 'const' instead diff --git a/test/rules/no-var-keyword/test.ts.fix b/test/rules/no-var-keyword/test.ts.fix new file mode 100644 index 00000000000..a01748fb9da --- /dev/null +++ b/test/rules/no-var-keyword/test.ts.fix @@ -0,0 +1,44 @@ +let foo; + +function tmp(t: any) { + let x = 3; +} + +let i, + j; + +let [a, b] = [1, 2]; + +for (let n; false;); +for (let n1 in foo); +for (let n2 of foo); + +export let exportVar0 = 0; +export let exportVar1 = 1; +export let exportVar2 = 2, + exportVar21 = 21; +export /* var tst */ let exportVar3 = 3; + +module quz { + export let i; +} + +declare var tmp2: any; + +let bar; +const qux; + +let k, + l; + +let [x, y] = [1, 2]; + +for (n; false;); +for (let n; false;); +for (let name in foo); +for (let name of foo); +for (const name in foo); +for (const name of foo); + +export let exportLet = 1; +export const exportConst = 1; diff --git a/test/rules/no-var-keyword/test.ts.lint b/test/rules/no-var-keyword/test.ts.lint new file mode 100644 index 00000000000..0579e31d389 --- /dev/null +++ b/test/rules/no-var-keyword/test.ts.lint @@ -0,0 +1,56 @@ +var foo; +~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] + +function tmp(t: any) { + var x = 3; + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] +} + +var i, +~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] + j; + +var [a, b] = [1, 2]; +~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] + +for (var n; false;); + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] +for (var n1 in foo); + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] +for (var n2 of foo); + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] + +export var exportVar0 = 0; + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] +export var exportVar1 = 1; + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] +export var exportVar2 = 2, + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] + exportVar21 = 21; +export /* var tst */ var exportVar3 = 3; + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] + +module quz { + export var i; + ~~~ [Forbidden 'var' keyword, use 'let' or 'const' instead] +} + +declare var tmp2: any; + +let bar; +const qux; + +let k, + l; + +let [x, y] = [1, 2]; + +for (n; false;); +for (let n; false;); +for (let name in foo); +for (let name of foo); +for (const name in foo); +for (const name of foo); + +export let exportLet = 1; +export const exportConst = 1; diff --git a/test/rules/no-var-keyword/tslint.json b/test/rules/no-var-keyword/tslint.json new file mode 100644 index 00000000000..1de4119c014 --- /dev/null +++ b/test/rules/no-var-keyword/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-var-keyword": true + } +} diff --git a/test/rules/no-var-requires/test.ts.lint b/test/rules/no-var-requires/test.ts.lint new file mode 100644 index 00000000000..de02a16a8ad --- /dev/null +++ b/test/rules/no-var-requires/test.ts.lint @@ -0,0 +1,3 @@ +import a = require("a"); +var b = require("b"); + ~~~~~~~~~~~~ [require statement not part of an import statement] diff --git a/test/rules/no-var-requires/tslint.json b/test/rules/no-var-requires/tslint.json new file mode 100644 index 00000000000..665051136ed --- /dev/null +++ b/test/rules/no-var-requires/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-var-requires": true + } +} diff --git a/test/rules/no-void-expression/default/test.ts.lint b/test/rules/no-void-expression/default/test.ts.lint new file mode 100644 index 00000000000..1322aff7aee --- /dev/null +++ b/test/rules/no-void-expression/default/test.ts.lint @@ -0,0 +1,29 @@ +function doIt() {} +async function doAsync() {} +function print(strs) {} + +[].forEach(x => console.log(x)); + ~~~~~~~~~~~~~~ [0] + +[].forEach(x => x && console.log(x)); + ~~~~~~~~~~~~~~ [0] + +async function f(): Promise { + const x = doIt(); + ~~~~~~ [0] + console.log(await doAsync()); + ~~~~~~~~~~~~~~~ [0] + return print``; + ~~~~~~~ [0] +} + +true && console.log(0); +false || console.log(0); + +declare function doIt(): void; +declare function doAsync(): Promise; +declare function print(strs: TemplateStringsArray): void; + +!!data ? console.info(message, data) : console.info(message); + +[0]: Expression has type `void`. Put it on its own line as a statement. diff --git a/test/rules/no-void-expression/default/tsconfig.json b/test/rules/no-void-expression/default/tsconfig.json new file mode 100644 index 00000000000..981cde20346 --- /dev/null +++ b/test/rules/no-void-expression/default/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "es6", + "allowJs": true + } +} \ No newline at end of file diff --git a/test/rules/no-void-expression/default/tslint.json b/test/rules/no-void-expression/default/tslint.json new file mode 100644 index 00000000000..d8073cc8eda --- /dev/null +++ b/test/rules/no-void-expression/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-void-expression": true + } +} diff --git a/test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint b/test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint new file mode 100644 index 00000000000..023f1861947 --- /dev/null +++ b/test/rules/no-void-expression/ignore-arrow-function-shorthand/test.ts.lint @@ -0,0 +1,10 @@ +[].forEach(x => console.log(x)); +[].forEach(x => x && console.log(x)); +[].forEach(x => !x || console.log(x)); + +[].forEach(x => { + return console.log(x); + ~~~~~~~~~~~~~~ [0] +}); + +[0]: Expression has type `void`. Put it on its own line as a statement. diff --git a/test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json b/test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/no-void-expression/ignore-arrow-function-shorthand/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json b/test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json new file mode 100644 index 00000000000..edb823990d3 --- /dev/null +++ b/test/rules/no-void-expression/ignore-arrow-function-shorthand/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-void-expression": [true, "ignore-arrow-function-shorthand"] + } +} diff --git a/test/rules/number-literal-format/test.ts.fix b/test/rules/number-literal-format/test.ts.fix new file mode 100644 index 00000000000..8e9e5fcd6eb --- /dev/null +++ b/test/rules/number-literal-format/test.ts.fix @@ -0,0 +1,47 @@ +0; +0.5; +10; +1.1e10; + +-6000; + +-777; + +-0; + +-0.9; + +-0.2; + +-0.5; + +-123e3; + +-145E4; + +-1467e-8; + +-189e10; + +-0xDEADBEEF; + +1; + +1 + +0; +0.5; + +0.5; + +0.5; + +1e1; +1E1; +1e-1; +1e10; + +0xDEADBEEF; + +0.0102; + diff --git a/test/rules/number-literal-format/test.ts.lint b/test/rules/number-literal-format/test.ts.lint new file mode 100644 index 00000000000..e9c9d9d0d00 --- /dev/null +++ b/test/rules/number-literal-format/test.ts.lint @@ -0,0 +1,77 @@ +0; +0.5; +10; +1.1e10; + +-0000006000; + ~~~~~~~~~~ [leading-0] + +-777.; + ~~~~ [trailing-decimal] + +-0.000; + ~~~~~ [trailing-0] + +-0.90000; + ~~~~~~~ [trailing-0] + +-.2; + ~~ [leading-decimal] + +-.50000; + ~~~~~~ [trailing-0] + ~~~~~~ [leading-decimal] + +-123e0003; + ~~~~ [leading-0] + +-145E0004; + ~~~~ [leading-0] + +-1467e-0008; + ~~~~~ [leading-0] + +-189.000e10; + ~~~~~~~ [trailing-0] + +-0xDEAdBEEF; + ~~~~~~~~~~ [uppercase] + +01; +~~ [leading-0] + +1. +~~ [trailing-decimal] + +0.0; +~~~ [trailing-0] +0.50; +~~~~ [trailing-0] + +.5; +~~ [leading-decimal] + +.50; +~~~ [trailing-0] +~~~ [leading-decimal] + +1e01; + ~~ [leading-0] +1E01; + ~~ [leading-0] +1e-01; + ~~~ [leading-0] +1.0e10; +~~~ [trailing-0] + +0xDEAdBEEF; +~~~~~~~~~~ [uppercase] + +0.010200; +~~~~~~~~ [trailing-0] + +[leading-0]: Number literal should not have a leading '0'. +[trailing-0]: Number literal should not have a trailing '0'. +[trailing-decimal]: Number literal should not end in '.'. +[leading-decimal]: Number literal should begin with '0.' and not just '.'. +[uppercase]: Hexadecimal number literal should be uppercase. diff --git a/test/rules/number-literal-format/tslint.json b/test/rules/number-literal-format/tslint.json new file mode 100644 index 00000000000..ec0d152e9f2 --- /dev/null +++ b/test/rules/number-literal-format/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "number-literal-format": true + } +} diff --git a/test/rules/object-literal-key-quotes/always/test.ts.fix b/test/rules/object-literal-key-quotes/always/test.ts.fix new file mode 100644 index 00000000000..b5d13dd2b1f --- /dev/null +++ b/test/rules/object-literal-key-quotes/always/test.ts.fix @@ -0,0 +1,20 @@ +const o = { + 'hello': 123, + "goodbye": 234, // failure + "quote": 345, + "needs quote": 789, + "hyphens-need-quotes": null, + [computed]: 456, + "123": "hello", // failure + "10000": "something", // failure + "0.123": "float", // failure + '123': 'numbers do not need quotes', + '010': 'but this one does.', + '.123': 'as does this one', + "fn"() { return }, + "true": 0, // failure + "0x0": 0, + "true": 0, + x, + ...y, +}; diff --git a/test/rules/object-literal-key-quotes/always/test.ts.lint b/test/rules/object-literal-key-quotes/always/test.ts.lint new file mode 100644 index 00000000000..9ccb80df382 --- /dev/null +++ b/test/rules/object-literal-key-quotes/always/test.ts.lint @@ -0,0 +1,26 @@ +const o = { + 'hello': 123, + goodbye: 234, // failure + ~~~~~~~ [Unquoted property 'goodbye' found.] + "quote": 345, + "needs quote": 789, + "hyphens-need-quotes": null, + [computed]: 456, + 123: "hello", // failure + ~~~ [Unquoted property '123' found.] + 1e4: "something", // failure + ~~~ [Unquoted property '10000' found.] + .123: "float", // failure + ~~~~ [Unquoted property '0.123' found.] + '123': 'numbers do not need quotes', + '010': 'but this one does.', + '.123': 'as does this one', + fn() { return }, + ~~ [Unquoted property 'fn' found.] + true: 0, // failure + ~~~~ [Unquoted property 'true' found.] + "0x0": 0, + "true": 0, + x, + ...y, +}; diff --git a/test/rules/object-literal-key-quotes/always/tslint.json b/test/rules/object-literal-key-quotes/always/tslint.json new file mode 100644 index 00000000000..a7927997726 --- /dev/null +++ b/test/rules/object-literal-key-quotes/always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-key-quotes": [true, "always"] + } +} diff --git a/test/rules/object-literal-key-quotes/as-needed/test.ts.fix b/test/rules/object-literal-key-quotes/as-needed/test.ts.fix new file mode 100644 index 00000000000..d4e6146b179 --- /dev/null +++ b/test/rules/object-literal-key-quotes/as-needed/test.ts.fix @@ -0,0 +1,23 @@ +const o = { + hello: 123, // failure + goodbye: 234, + quote: 345, // failure + "needs quote": 789, + "hyphens-need-quotes": null, + [computed]: 456, + 123: "hello", + 1e4: "something", + .123: "float", + 123: 'numbers do not need quotes', // failure + 1.23: null, + '010': 'but this one does.', + '.123': 'as does this one', + '-1': 'and this one', + fn() { return }, + true: 0, + "0x0": 0, + true: 0, // failure + '': 'always quote the empty string', + x, + ...y, +}; diff --git a/test/rules/object-literal-key-quotes/as-needed/test.ts.lint b/test/rules/object-literal-key-quotes/as-needed/test.ts.lint new file mode 100644 index 00000000000..3e4e2cefd43 --- /dev/null +++ b/test/rules/object-literal-key-quotes/as-needed/test.ts.lint @@ -0,0 +1,27 @@ +const o = { + 'hello': 123, // failure + ~~~~~~~ [Unnecessarily quoted property 'hello' found.] + goodbye: 234, + "quote": 345, // failure + ~~~~~~~ [Unnecessarily quoted property 'quote' found.] + "needs quote": 789, + "hyphens-need-quotes": null, + [computed]: 456, + 123: "hello", + 1e4: "something", + .123: "float", + '123': 'numbers do not need quotes', // failure + ~~~~~ [Unnecessarily quoted property '123' found.] + 1.23: null, + '010': 'but this one does.', + '.123': 'as does this one', + '-1': 'and this one', + fn() { return }, + true: 0, + "0x0": 0, + "true": 0, // failure + ~~~~~~ [Unnecessarily quoted property 'true' found.] + '': 'always quote the empty string', + x, + ...y, +}; diff --git a/test/rules/object-literal-key-quotes/as-needed/tslint.json b/test/rules/object-literal-key-quotes/as-needed/tslint.json new file mode 100644 index 00000000000..a366a23efb2 --- /dev/null +++ b/test/rules/object-literal-key-quotes/as-needed/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-key-quotes": [true, "as-needed"] + } +} diff --git a/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix b/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix new file mode 100644 index 00000000000..b15e40fea09 --- /dev/null +++ b/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.fix @@ -0,0 +1,43 @@ + +const o = { + hello: 123, + bye: 45, +}; +const v = { + hello: 123, + bye: 45, +}; +const s = { + hello: 123, + bye: 45, +}; +const r = { + "hello": 123, + "bye-bye": 45, +}; +const p = { + hello: 123, + bye: 45, +}; +const q = { + "hello": 123, + "bye-bye": 45, +}; +const t = { + hello: 123, + nested: { + bird: 2, + egg: 3, + } +}; +const u = { + hello: 123, + bye: 45, + nested: { + bird: 1, + egg: 2, + } +}; +const v = { + ...o, +}; diff --git a/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint b/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint new file mode 100644 index 00000000000..f05f6777157 --- /dev/null +++ b/test/rules/object-literal-key-quotes/consistent-as-needed/test.ts.lint @@ -0,0 +1,52 @@ + +const o = { + 'hello': 123, + ~~~~~~~ [Unnecessarily quoted property 'hello' found.] + "bye": 45, + ~~~~~ [Unnecessarily quoted property 'bye' found.] +}; +const v = { + "hello": 123, + ~~~~~~~ [Unnecessarily quoted property 'hello' found.] + "bye": 45, + ~~~~~ [Unnecessarily quoted property 'bye' found.] +}; +const s = { + hello: 123, + bye: 45, +}; +const r = { + "hello": 123, + "bye-bye": 45, +}; +const p = { + hello: 123, + "bye": 45, + ~~~~~ [Unnecessarily quoted property 'bye' found.] +}; +const q = { + hello: 123, + ~~~~~ [Unquoted property 'hello' found.] + "bye-bye": 45, +}; +const t = { + hello: 123, + nested: { + "bird": 2, + ~~~~~~ [Unnecessarily quoted property 'bird' found.] + egg: 3, + } +}; +const u = { + hello: 123, + bye: 45, + nested: { + "bird": 1, + ~~~~~~ [Unnecessarily quoted property 'bird' found.] + "egg": 2, + ~~~~~ [Unnecessarily quoted property 'egg' found.] + } +}; +const v = { + ...o, +}; diff --git a/test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json b/test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json new file mode 100644 index 00000000000..f125186828a --- /dev/null +++ b/test/rules/object-literal-key-quotes/consistent-as-needed/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-key-quotes": [true, "consistent-as-needed"] + } +} diff --git a/test/rules/object-literal-key-quotes/consistent/test.ts.lint b/test/rules/object-literal-key-quotes/consistent/test.ts.lint new file mode 100644 index 00000000000..d6404cc432e --- /dev/null +++ b/test/rules/object-literal-key-quotes/consistent/test.ts.lint @@ -0,0 +1,43 @@ + +const o = { + 'hello': 123, + "bye": 45, +}; +const v = { + "hello": 123, + "bye": 45, +}; +const s = { + hello: 123, + bye: 45, +}; +const r = { + "hello": 123, + "bye-bye": 45, +}; +const p = { + ~ [All property names in this object literal must be consistently quoted or unquoted.] + hello: 123, + "bye": 45, +}; +const q = { + ~ [All property names in this object literal must be consistently quoted or unquoted.] + hello: 123, + "bye-bye": 45, +}; +const t = { + hello: 123, + nested: { + ~ [All property names in this object literal must be consistently quoted or unquoted.] + "bird": 2, + egg: 3, + } +}; +const u = { + hello: 123, + bye: 45, + nested: { + "bird": 1, + "egg": 2, + } +}; \ No newline at end of file diff --git a/test/rules/object-literal-key-quotes/consistent/tslint.json b/test/rules/object-literal-key-quotes/consistent/tslint.json new file mode 100644 index 00000000000..e8d308b9b78 --- /dev/null +++ b/test/rules/object-literal-key-quotes/consistent/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-key-quotes": [true, "consistent"] + } +} diff --git a/test/rules/object-literal-shorthand/always/test.ts.fix b/test/rules/object-literal-shorthand/always/test.ts.fix new file mode 100644 index 00000000000..edf1133d480 --- /dev/null +++ b/test/rules/object-literal-shorthand/always/test.ts.fix @@ -0,0 +1,43 @@ +const bad = { + w() {}, + *x() {}, + [y]() {}, + z +}; + +const good = { + w() {}, + *x() {}, + [y]() {}, + z +}; + +const arrows = { + x: (y) => y // this is OK. +}; + +const namedFunctions = { + x: function y() {} // named function expressions are also OK. +}; + +const quotes = { + "foo-bar"() {}, + "foo-bar"() {} +}; + +const extraCases = { + x, + a: 123, + b: "hello", + c: 'c', + ["a" + "nested"]: { + x + } +}; + +const asyncFn = { + async foo() {}, + async *bar() {} +} + +({foo} = {foo}); diff --git a/test/rules/object-literal-shorthand/always/test.ts.lint b/test/rules/object-literal-shorthand/always/test.ts.lint new file mode 100644 index 00000000000..8e887237eca --- /dev/null +++ b/test/rules/object-literal-shorthand/always/test.ts.lint @@ -0,0 +1,55 @@ +const bad = { + w: function() {}, + ~~~~~~~~~~~ [LONGHAND_METHOD % ("('{w() {...}}')")] + x: function *() {}, + ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{*x() {...}}')")] + [y]: function() {}, + ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{[y]() {...}}')")] + z: z + ~~~~ [Expected property shorthand in object literal ('{z}').] +}; + +const good = { + w() {}, + *x() {}, + [y]() {}, + z +}; + +const arrows = { + x: (y) => y // this is OK. +}; + +const namedFunctions = { + x: function y() {} // named function expressions are also OK. +}; + +const quotes = { + "foo-bar": function() {}, + ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{\"foo-bar\"() {...}}')")] + "foo-bar"() {} +}; + +const extraCases = { + x, + a: 123, + b: "hello", + c: 'c', + ["a" + "nested"]: { + x: x + ~~~~ [Expected property shorthand in object literal ('{x}').] + } +}; + +const asyncFn = { + foo: async function() {}, + ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async foo() {...}}')")] + bar: async function*() {} + ~~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async *bar() {...}}')")] +} + +({foo: foo} = {foo: foo}); + ~~~~~~~~ [LONGHAND_PROPERTY % ("('{foo}')")] + ~~~~~~~~ [LONGHAND_PROPERTY % ("('{foo}')")] +[LONGHAND_METHOD]: Expected method shorthand in object literal %s. +[LONGHAND_PROPERTY]: Expected property shorthand in object literal %s. diff --git a/test/rules/object-literal-shorthand/always/tslint.json b/test/rules/object-literal-shorthand/always/tslint.json new file mode 100644 index 00000000000..3979c6d1466 --- /dev/null +++ b/test/rules/object-literal-shorthand/always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-shorthand": [true, "always"] + } +} diff --git a/test/rules/object-literal-shorthand/never/test.ts.fix b/test/rules/object-literal-shorthand/never/test.ts.fix new file mode 100644 index 00000000000..25576bcb9b1 --- /dev/null +++ b/test/rules/object-literal-shorthand/never/test.ts.fix @@ -0,0 +1,59 @@ +const asyncFn = { + f: async function() { + await some_promise; + }, + fa: async function*() { + await some_promise; + } +}; + +const bad = { + w: function() { + const alsoBad = { + bad: bad, + }; + }, + x: function*() {}, + [y]: function() {}, + z: z, + nest: { + nestBad: function() {}, + nextGood: function(prop: string): void {} + } +}; + +const good = { + w: function() {}, + x: function *() {}, + [y]: function() {} +}; + +const arrows = { + x: (y) => y // this is OK. +}; + +const namedFunctions = { + x: function y() {} // named function expressions are also OK. +}; + +const quotes = { + "foo-bar": function() {}, + "foo-bar": function() {} +}; + +const extraCases = { + x: x, + a: 123, + b: "hello", + c: 'c', + ["a" + "nested"]: { + x: x + } +}; + +export class ClassA extends ClassZ { + testMethod() {} +} + +({foo: foo} = {foo: foo}); + diff --git a/test/rules/object-literal-shorthand/never/test.ts.lint b/test/rules/object-literal-shorthand/never/test.ts.lint new file mode 100644 index 00000000000..b6ea615c327 --- /dev/null +++ b/test/rules/object-literal-shorthand/never/test.ts.lint @@ -0,0 +1,72 @@ +const asyncFn = { + async f() { + ~ [SHORTHAND_ASSIGNMENT] + await some_promise; + }, + async* fa() { + ~~ [SHORTHAND_ASSIGNMENT] + await some_promise; + } +}; + +const bad = { + w() { + ~ [SHORTHAND_ASSIGNMENT] + const alsoBad = { + bad, + ~~~ [SHORTHAND_ASSIGNMENT] + }; + }, + *x() {}, + ~ [SHORTHAND_ASSIGNMENT] + [y]() {}, + ~~~ [SHORTHAND_ASSIGNMENT] + z, + ~ [SHORTHAND_ASSIGNMENT] + nest: { + nestBad() {}, + ~~~~~~~ [SHORTHAND_ASSIGNMENT] + nextGood: function(prop: string): void {} + } +}; + +const good = { + w: function() {}, + x: function *() {}, + [y]: function() {} +}; + +const arrows = { + x: (y) => y // this is OK. +}; + +const namedFunctions = { + x: function y() {} // named function expressions are also OK. +}; + +const quotes = { + "foo-bar": function() {}, + "foo-bar"() {} + ~~~~~~~~~ [SHORTHAND_ASSIGNMENT] +}; + +const extraCases = { + x, + ~ [SHORTHAND_ASSIGNMENT] + a: 123, + b: "hello", + c: 'c', + ["a" + "nested"]: { + x: x + } +}; + +export class ClassA extends ClassZ { + testMethod() {} +} + +({foo} = {foo}); + ~~~ [SHORTHAND_ASSIGNMENT] + ~~~ [SHORTHAND_ASSIGNMENT] + +[SHORTHAND_ASSIGNMENT]: Shorthand property and method assignments have been disallowed. diff --git a/test/rules/object-literal-shorthand/never/tslint.json b/test/rules/object-literal-shorthand/never/tslint.json new file mode 100644 index 00000000000..407e9d245b9 --- /dev/null +++ b/test/rules/object-literal-shorthand/never/tslint.json @@ -0,0 +1,6 @@ +{ + "rules": { + "object-literal-shorthand": [true, "never"] + } + } + \ No newline at end of file diff --git a/test/rules/object-literal-shorthand/onlyMethods/test.ts.fix b/test/rules/object-literal-shorthand/onlyMethods/test.ts.fix new file mode 100644 index 00000000000..47e0f714cf4 --- /dev/null +++ b/test/rules/object-literal-shorthand/onlyMethods/test.ts.fix @@ -0,0 +1,45 @@ +const badMethodsGoodProps = { + w() {}, + *x() {}, + [y]() {}, + z: z +}; + +const goodMethodsBadProps = { + w() {}, + *x() {}, + [y]() {}, + z: z +}; + +const arrows = { + x: (y) => y // this is OK. +}; + +const namedFunctions = { + x: function y() {} // named function expressions are also OK. +}; + +const quotes = { + "foo-bar"() {}, + "foo-bar"() {} +}; + +const extraCases = { + x: x, + a: 123, + b: "hello", + c: 'c', + ["a" + "nested"]: { + x: x + } +}; + +const asyncFn = { + async foo() {}, + async *bar() {} +} + +({foo: foo} = {foo: foo}); +({foo: foo} = {foo: foo}); + diff --git a/test/rules/object-literal-shorthand/onlyMethods/test.ts.lint b/test/rules/object-literal-shorthand/onlyMethods/test.ts.lint new file mode 100644 index 00000000000..ffc9981c5d1 --- /dev/null +++ b/test/rules/object-literal-shorthand/onlyMethods/test.ts.lint @@ -0,0 +1,58 @@ +const badMethodsGoodProps = { + w: function() {}, + ~~~~~~~~~~~ [LONGHAND_METHOD % ("('{w() {...}}')")] + x: function *() {}, + ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{*x() {...}}')")] + [y]: function() {}, + ~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{[y]() {...}}')")] + z: z +}; + +const goodMethodsBadProps = { + w() {}, + *x() {}, + [y]() {}, + z + ~ [OBJECT_LITERAL_DISALLOWED] +}; + +const arrows = { + x: (y) => y // this is OK. +}; + +const namedFunctions = { + x: function y() {} // named function expressions are also OK. +}; + +const quotes = { + "foo-bar": function() {}, + ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{\"foo-bar\"() {...}}')")] + "foo-bar"() {} +}; + +const extraCases = { + x, + ~ [OBJECT_LITERAL_DISALLOWED] + a: 123, + b: "hello", + c: 'c', + ["a" + "nested"]: { + x: x + } +}; + +const asyncFn = { + foo: async function() {}, + ~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async foo() {...}}')")] + bar: async function*() {} + ~~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async *bar() {...}}')")] +} + +({foo: foo} = {foo: foo}); +({foo} = {foo}); + ~~~ [OBJECT_LITERAL_DISALLOWED] + ~~~ [OBJECT_LITERAL_DISALLOWED] + +[OBJECT_LITERAL_DISALLOWED]: Shorthand property assignments have been disallowed. +[LONGHAND_METHOD]: Expected method shorthand in object literal %s. +[LONGHAND_PROPERTY]: Expected property shorthand in object literal %s. diff --git a/test/rules/object-literal-shorthand/onlyMethods/tslint.json b/test/rules/object-literal-shorthand/onlyMethods/tslint.json new file mode 100644 index 00000000000..fc32bc1d466 --- /dev/null +++ b/test/rules/object-literal-shorthand/onlyMethods/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "object-literal-shorthand": [ + true, + { + "property": "never", + "method": "always" + } + ] + } +} diff --git a/test/rules/object-literal-sort-keys/default/crlf.ts.lint b/test/rules/object-literal-sort-keys/default/crlf.ts.lint new file mode 100644 index 00000000000..1aea24abe6f --- /dev/null +++ b/test/rules/object-literal-sort-keys/default/crlf.ts.lint @@ -0,0 +1,6 @@ +// ensure that we don't treat \r\n as two line breaks +let obj = { + foo: 1, + bar: 2, + ~~~ [The key 'bar' is not sorted alphabetically] +} diff --git a/test/rules/object-literal-sort-keys/default/test.ts.lint b/test/rules/object-literal-sort-keys/default/test.ts.lint new file mode 100644 index 00000000000..491a05b083b --- /dev/null +++ b/test/rules/object-literal-sort-keys/default/test.ts.lint @@ -0,0 +1,319 @@ +var passA = { + a: 1, + b: 2 +}; + +var failA = { + b: 1, + a: 2 + ~ [err % ('a')] +}; + +var passB = { + a: 1, + b: 2, + c: 3, + d: 4 +}; + +var failB = { + c: 3, + a: 1, + ~ [err % ('a')] + b: 2, + d: 4 +}; + +var passC = { + a: 1, + b: { + aa: 1, + bb: 2 + } +}; + +var failC = { + a: 1, + b: { + bb: 2, + aa: 1 + ~~ [err % ('aa')] + } +}; + +var passD = { + a: 1, + b: { + aa: 1, + bb: 2 + }, + c: 3 +}; + +var failD = { + a: 1, + c: { + aa: 1, + bb: 2 + }, + b: 3 + ~ [err % ('b')] +}; + +var passE = {}; + +var passF = { + asdf: [1, 2, 3], + sdfa: {} +}; + +var failF = { + sdfa: {}, + asdf: [1, 2, 3] + ~~~~ [err % ('asdf')] +}; + +var passG = { + asdfn: function () {}, + sdafn: function () {} +}; + +var failG = { + sdafn: function () {}, + asdfn: function () {} + ~~~~~ [err % ('asdfn')] +}; + +var passH = { + a: 1, + 'b': 2, + c: 3 +} + +var failH = { + 'b': 2, + a: 1, + ~ [err % ('a')] + c: 3 +} + +var passI = { + 'Z': 1, + À: 2, + è: 3 +} + +var failI = { + À: 2, + 'Z': 1, + ~~~ [err % ('Z')] + è: 3, +} + +var passJ = { + 1: 1, + '11': 2 + 2: 4, + A: 3, +} + +var failJ = { + 1: 1, + 2: 4, + A: 3, + '11': 2 + ~~~~ [err % ('11')] +} + +var passK = { + a: 1, + 'b': { + 'd': 4, + e: 5 + }, + c: 3 +} + +var failK = { + 'b': { + e: 5, + 'd': 4 + ~~~ [err % ('d')] + }, + a: 1, + ~ [err % ('a')] + c: 3 +} + +var passL = {z: 1, y: '1', x: [1, 2]}; + +var failL = {x: 1, y: { + b: 1, + a: 2 + ~ [err % ('a')] +}, z: [1, 2]}; + +var passM = { + x: 1, + y: { + a: 1, + b: 2 + }, + z: {z: 1, y: '1', x: [1, 2]} +}; + +const spread = { + c, + ...x, + b: b, + a, + ~ [err % ('a')] +}; + +const numbers = { + 1: true, + 2: true, + 100: true, + 1e4: true, + 2e-1: true, +} + +const a = { + array: [], + objList: [{}, {}], + object: {}, +} + +const b = { + array: [], + object: {}, + objList: [{}, {}], + ~~~~~~~ [err % ('objList')] +} + +var blankLineGroupingPassA = { + a: 1, + b: 2, + d: 4, + + c: 3, + e: 5, +}; + +var blankLineGroupingFailA = { + a: 1, + b: 2, + d: 4, + // non-empty line not counted as a new line + c: 3, + ~ [err % ('c')] + e: 5, +}; + +var blankLineGroupingPassB = { + a: 1, + b: 2, + d: 4, + // a comment + + c: 3, + e: 5, +}; + +var blankLineGroupingFailB = { + a: 1, + b: 2, + c: 3, + + f: 6, + e: 5, + ~ [err % ('e')] + d: 4 +}; + +var blankLineGroupingPassC = { + b: 1, + + // a single line comment before the group + a: 2, + c: 3, +}; + +var blankLineGroupingFailC = { + b: 1, + /* a multiline comment with + + an extra new line in the middle */ + a: 2, + ~ [err % ('a')] + c: 3, +}; + +var blankLineGroupingPassD = { + b: 1, + + /* a multiline comment with a new line before and + + an extra new line in the middle, before a group */ + a: 2, + c: 3, +}; + +var blankLineGroupingFailD = { + b: 1, + // a single-line comments + /* a multiline comment with + + an extra new line in the middle */ + a: 2, + ~ [err % ('a')] + c: 3, +}; + +var blankLineGroupingPassE = { + b: 1, + /* a multiline comment with a new line after and + + an extra new line in the middle */ + + a: 2, + c: 3, +}; + +var blankLineGroupingFailE = { + a: 1, + c: `3 is a + + multiline string`, + b: 2, + ~ [err % ('b')] + d: 4 +} + +var blankLineGroupingPassF = { + b: 1, + /* double multiline comments + + and a space between */ + + /* more talking + + here */ + a: 2, + c: 3, +}; + +var blankLineGroupingFailF = { + b: 1, + /* double multiline comments + + with no space between */ + /* more talking + + here */ + a: 2, + ~ [err % ('a')] + c: 3, +}; + +[err]: The key '%s' is not sorted alphabetically diff --git a/test/rules/object-literal-sort-keys/default/tslint.json b/test/rules/object-literal-sort-keys/default/tslint.json new file mode 100644 index 00000000000..280382fe390 --- /dev/null +++ b/test/rules/object-literal-sort-keys/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": true + } +} diff --git a/test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint b/test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint new file mode 100644 index 00000000000..328b2911a5d --- /dev/null +++ b/test/rules/object-literal-sort-keys/ignore-blank-lines/test.ts.lint @@ -0,0 +1,26 @@ +var testPassA = { + a: 'a', + + b: 'b', + + c: 'c', +}; + +var testFailA = { + b: 'b', + + a: 'a', + ~ [err % ('a')] + c: 'c', +}; + +var testFailB = { + a: 'a', + + c: 'c', + + b: 'b', + ~ [err % ('b')] +}; + +[err]: The key '%s' is not sorted alphabetically \ No newline at end of file diff --git a/test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json b/test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json new file mode 100644 index 00000000000..fd1360f919a --- /dev/null +++ b/test/rules/object-literal-sort-keys/ignore-blank-lines/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": [true, "ignore-blank-lines"] + } +} diff --git a/test/rules/object-literal-sort-keys/ignore-case/test.ts.lint b/test/rules/object-literal-sort-keys/ignore-case/test.ts.lint new file mode 100644 index 00000000000..b706a1a6145 --- /dev/null +++ b/test/rules/object-literal-sort-keys/ignore-case/test.ts.lint @@ -0,0 +1,12 @@ +const a = { + array: [], + objList: [{}, {}], + object: {}, + ~~~~~~ [The key 'object' is not sorted alphabetically] +} + +const b = { + array: [], + object: {}, + objList: [{}, {}], +} diff --git a/test/rules/object-literal-sort-keys/ignore-case/tslint.json b/test/rules/object-literal-sort-keys/ignore-case/tslint.json new file mode 100644 index 00000000000..0e35ccdd33c --- /dev/null +++ b/test/rules/object-literal-sort-keys/ignore-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": [true, "ignore-case"] + } +} diff --git a/test/rules/object-literal-sort-keys/locale-compare/test.ts.lint b/test/rules/object-literal-sort-keys/locale-compare/test.ts.lint new file mode 100644 index 00000000000..df4899f4926 --- /dev/null +++ b/test/rules/object-literal-sort-keys/locale-compare/test.ts.lint @@ -0,0 +1,12 @@ +const a = { + autor: 1, + título: 2, + type: 3 +} + +const b = { + autor: 1, + type: 3, + título: 2 + ~~~~~~ [The key 'título' is not sorted alphabetically] +} diff --git a/test/rules/object-literal-sort-keys/locale-compare/tslint.json b/test/rules/object-literal-sort-keys/locale-compare/tslint.json new file mode 100644 index 00000000000..43f902bfea3 --- /dev/null +++ b/test/rules/object-literal-sort-keys/locale-compare/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": [true, "locale-compare"] + } +} diff --git a/test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint b/test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint new file mode 100644 index 00000000000..7064efedcfc --- /dev/null +++ b/test/rules/object-literal-sort-keys/match-declaration-order-only/test.ts.lint @@ -0,0 +1,71 @@ +interface I { + b; + a; +} + +declare function f(i: I): void; + +const a = 0, b = 0; + +f({ b, a }); + +f({ a, b }); + ~ [0 % ('b', 'I')] + +// Resets ordering after spread operator. + +f({ a, ...x, b }); + +f({ a, ...x, a, b }); + ~ [0 % ('b', 'I')] + + +// Methods and getters/setters work like any other key. + +f({ b() {}, a() {} }); + +f({ a() {}, b() {} }); + ~ [0 % ('b', 'I')] + +f({ + get b() {}, + a, + set b(v) {}, + ~ [0 % ('b', 'I')] +}); + +f({ + get b() {}, + set b() {}, + a, +}); + +// Ignores computed properties. Does not ignore string / number keys. + +interface J { + "foo"; + 2; + [Symol.iterator]; +} +declare function j(j: J): void; +j({ [Symbol.iterator]: 1, "foo": 1, 2: 1 }); +j({ [Symbol.iterator]: 1, 2: 1, "foo": 1 }); + ~~~~~ [0 % ('foo', 'J')] + +// Works with anonymous type too. +type T = { b, a }; +const o: T = { a, b }; + ~ [0 % ('b', 'T')] + +const o: { b, a } = { a, b }; + ~ [1 % ('b')] + +// Non-alphabetical ordering is fine, even if it can't find a type. + +const o = { + b, + a, +}; + +[0]: The key '%s' is not in the same order as it is in '%s'. +[1]: The key '%s' is not in the same order as it is in its type declaration. diff --git a/test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json b/test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json new file mode 100644 index 00000000000..9e26dfeeb6e --- /dev/null +++ b/test/rules/object-literal-sort-keys/match-declaration-order-only/tsconfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json b/test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json new file mode 100644 index 00000000000..c4100bcda48 --- /dev/null +++ b/test/rules/object-literal-sort-keys/match-declaration-order-only/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": [true, "ignore-case", "match-declaration-order-only"] + } +} diff --git a/test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint b/test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint new file mode 100644 index 00000000000..3d2079221d1 --- /dev/null +++ b/test/rules/object-literal-sort-keys/match-declaration-order/test.ts.lint @@ -0,0 +1,72 @@ +interface I { + b; + a; +} + +declare function f(i: I): void; + +const a = 0, b = 0; + +f({ b, a }); + +f({ a, b }); + ~ [0 % ('b', 'I')] + +// Resets ordering after spread operator. + +f({ a, ...x, b }); + +f({ a, ...x, a, b }); + ~ [0 % ('b', 'I')] + + +// Methods and getters/setters work like any other key. + +f({ b() {}, a() {} }); + +f({ a() {}, b() {} }); + ~ [0 % ('b', 'I')] + +f({ + get b() {}, + a, + set b(v) {}, + ~ [0 % ('b', 'I')] +}); + +f({ + get b() {}, + set b() {}, + a, +}); + +// Ignores computed properties. Does not ignore string / number keys. + +interface J { + "foo"; + 2; + [Symol.iterator]; +} +declare function j(j: J): void; +j({ [Symbol.iterator]: 1, "foo": 1, 2: 1 }); +j({ [Symbol.iterator]: 1, 2: 1, "foo": 1 }); + ~~~~~ [0 % ('foo', 'J')] + +// Works with anonymous type too. +type T = { b, a }; +const o: T = { a, b }; + ~ [0 % ('b', 'T')] + +const o: { b, a } = { a, b }; + ~ [1 % ('b')] + +// Goes with alphabetical ordering if it can't find a type. + +const o = { + b, + a, + ~ [The key 'a' is not sorted alphabetically] +}; + +[0]: The key '%s' is not in the same order as it is in '%s'. +[1]: The key '%s' is not in the same order as it is in its type declaration. diff --git a/test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json b/test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json new file mode 100644 index 00000000000..9e26dfeeb6e --- /dev/null +++ b/test/rules/object-literal-sort-keys/match-declaration-order/tsconfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/rules/object-literal-sort-keys/match-declaration-order/tslint.json b/test/rules/object-literal-sort-keys/match-declaration-order/tslint.json new file mode 100644 index 00000000000..c4d505791fe --- /dev/null +++ b/test/rules/object-literal-sort-keys/match-declaration-order/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": [true, "ignore-case", "match-declaration-order"] + } +} diff --git a/test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint b/test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint new file mode 100644 index 00000000000..7dea783d978 --- /dev/null +++ b/test/rules/object-literal-sort-keys/shorthand-first/test.ts.lint @@ -0,0 +1,79 @@ +const a = 'a' +const c = 'c' +const x = {} + +const fail1 = { + a, + b: 'b', + c, + ~ [shorthandErr % ('c')] + d: 'd', +} + +const fail2 = { + c, + a, + ~ [alphaErr % ('a')] + b: 'b', + d: 'd', +} + +const fail3 = { + a, + c, + d: 'd', + b: 'b', + ~ [alphaErr % ('b')] +} + +const fail4 = { + c, + ...x, + a, + d: 'd', + b: 'b', + ~ [alphaErr % ('b')] +} + +const pass1 = { + a, + c, + b: 'b', + d: 'd', +} + +const pass2 = { + ...x, + a, + c, + b: 'b', + d: 'd', +} + +const pass3 = { + a, + c, + ...x, + b: 'b', + d: 'd', +} + +const pass4 = { + c, + ...x, + a, + b: 'b', + d: 'd', +} + +const pass5 = { + d: 'd', + ...x, + c, + ...x, + a, + b: 'b', +} + +[alphaErr]: The key '%s' is not sorted alphabetically +[shorthandErr]: The shorthand property '%s' should appear before normal properties diff --git a/test/rules/object-literal-sort-keys/shorthand-first/tslint.json b/test/rules/object-literal-sort-keys/shorthand-first/tslint.json new file mode 100644 index 00000000000..9ba03e3c2c9 --- /dev/null +++ b/test/rules/object-literal-sort-keys/shorthand-first/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "object-literal-sort-keys": [true, "shorthand-first"] + } +} diff --git a/test/rules/one-line/all/test.ts.fix b/test/rules/one-line/all/test.ts.fix new file mode 100644 index 00000000000..ccd729f9841 --- /dev/null +++ b/test/rules/one-line/all/test.ts.fix @@ -0,0 +1,152 @@ +module Module { + export enum Enumeration { + A, + B, + C, + D + } + + export function Call() { + if (x == 3) { + x = 4; + } else { + x = 5; + } + return "called"; + } +} + +interface Class { + variable: string; +} + +var object = { + a: 1, + b: 2 +}; + +for(var x= 0; x < 1; ++x) { + ++i; +} + +switch(y) { + case 0: { + x--; + break; + } + default: + x++; + break; +} + +try { + throw new Error("hi"); +} catch (e) { + throw(e); +} finally { + // do something +} + +try { + foo(); +} finally { + bar(); +} + +try { + foo(); +} catch(e) { + bar(); +} finally { + baz(); +} + +while(x < 10) { + x++; +} + +function f(): + number { + + return 5; +} + +class BarBooBaz { + +} + +class FooBarBaz { +} + +// Valid multiline declarations +export class LongDescriptiveClassName, S> + extends SomeAbstractBaseClass implements IImportantInterface { +} + +export interface LongDescriptiveInterfaceName + extends AThirdInterface { +} + +function longFunctionNameWithLotsOfParams( + x: number, + y: number, + z: number, + a: T) { +} + +let geoConfig: { + maximumAge?: number; + timeout?: number; + enableHighAccuracy?: boolean; +} = { + maximumAge: 3000, + timeout: 5000, + enableHighAccuracy: false +}; + +declare module "*"; +declare module "someLibrary/*"; + +// No error if there are no braces +if (true) + true; +else + false; + +class Foo< + Bar, + Baz, + Bas +> { + // works for multiline type parameters +} + +type Foo = { + bar, +}; +type Bar = { bar }; +type Baz = { [K in T]: T }; +type Bas = "a"; + +{ + {}{}{} // just some random blocks +} + +if (true) { + true; +} else { + false; +} + +// don't crash on parse error +interface InvalidInterface = { + foo: string, +} + +class InvalidClass = { + foo: string, +} + +foo = class InvalidClassExpression = { + foo: string, +} diff --git a/test/rules/one-line/all/test.ts.lint b/test/rules/one-line/all/test.ts.lint new file mode 100644 index 00000000000..15ec7d1ccf0 --- /dev/null +++ b/test/rules/one-line/all/test.ts.lint @@ -0,0 +1,197 @@ +module Module +{ +~ [misplaced opening brace] + export enum Enumeration + { + ~ [misplaced opening brace] + A, + B, + C, + D + } + + export function Call() + { + ~ [misplaced opening brace] + if (x == 3) + { + ~ [misplaced opening brace] + x = 4; + } + else { + ~~~~ [misplaced 'else'] + x = 5; + } + return "called"; + } +} + +interface Class +{ +~ [misplaced opening brace] + variable: string; +} + +var object = +{ +~ [misplaced opening brace] + a: 1, + b: 2 +}; + +for(var x= 0; x < 1; ++x) +{ +~ [misplaced opening brace] + ++i; +} + +switch(y) +{ +~ [misplaced opening brace] + case 0: + { + ~ [misplaced opening brace] + x--; + break; + } + default: + x++; + break; +} + +try +{ +~ [misplaced opening brace] + throw new Error("hi"); +} +catch (e) +~~~~~ [misplaced 'catch'] +{ +~ [misplaced opening brace] + throw(e); +} +finally +~~~~~~~ [misplaced 'finally'] +{ +~ [misplaced opening brace] + // do something +} + +try { + foo(); +} +finally +~~~~~~~ [misplaced 'finally'] +{ +~ [misplaced opening brace] + bar(); +} + +try{ + ~ [missing whitespace] + foo(); +} catch(e){ + ~ [missing whitespace] + bar(); +} finally{ + ~ [missing whitespace] + baz(); +} + +while(x < 10){ + ~ [missing whitespace] + x++; +} + +function f(): + number { + + return 5; +} + +class BarBooBaz +{ +~ [misplaced opening brace] + +} + +class FooBarBaz { +} + +// Valid multiline declarations +export class LongDescriptiveClassName, S> + extends SomeAbstractBaseClass implements IImportantInterface { +} + +export interface LongDescriptiveInterfaceName + extends AThirdInterface { +} + +function longFunctionNameWithLotsOfParams( + x: number, + y: number, + z: number, + a: T) { +} + +let geoConfig: { + maximumAge?: number; + timeout?: number; + enableHighAccuracy?: boolean; +} = { + maximumAge: 3000, + timeout: 5000, + enableHighAccuracy: false +}; + +declare module "*"; +declare module "someLibrary/*"; + +// No error if there are no braces +if (true) + true; +else + false; + +class Foo< + Bar, + Baz, + Bas +> { + // works for multiline type parameters +} + +type Foo = { + bar, +}; +type Bar = +{ bar }; +~ [misplaced opening brace] +type Baz = +{ [K in T]: T }; +~ [misplaced opening brace] +type Bas = "a"; + +{ + {}{}{} // just some random blocks +} + +if (true) { + true; +}else { + ~~~~ [missing whitespace] + false; +} + +// don't crash on parse error +interface InvalidInterface = { + foo: string, +} + +class InvalidClass = { + foo: string, +} + +foo = class InvalidClassExpression = { + foo: string, +} diff --git a/test/rules/one-line/all/tslint.json b/test/rules/one-line/all/tslint.json new file mode 100644 index 00000000000..d8a064cc2e5 --- /dev/null +++ b/test/rules/one-line/all/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-finally", "check-whitespace"] + } +} diff --git a/test/rules/one-line/no-whitespace/test.ts.fix b/test/rules/one-line/no-whitespace/test.ts.fix new file mode 100644 index 00000000000..e4e1ceb0770 --- /dev/null +++ b/test/rules/one-line/no-whitespace/test.ts.fix @@ -0,0 +1,132 @@ +module Module{ + export enum Enumeration{ + A, + B, + C, + D + } + + export function Call(){ + if (x == 3){ + x = 4; + }else { + x = 5; + } + return "called"; + } +} + +interface Class{ + variable: string; +} + +var object ={ + a: 1, + b: 2 +}; + +for(var x= 0; x < 1; ++x){ + ++i; +} + +switch(y){ + case 0: + x--; + break; + default: + x++; + break; +} + +try{ + throw new Error("hi"); +}catch (e){ + throw(e); +}finally{ + // do something +} + +try { + foo(); +}finally{ + bar(); +} + +try{ + foo(); +} catch(e){ + bar(); +} finally{ + baz(); +} + +while(x < 10){ + x++; +} + +function f(): + number { + + return 5; +} + +class BarBooBaz{ + +} + +class FooBarBaz { +} + +// Valid multiline declarations +export class LongDescriptiveClassName, S> + extends SomeAbstractBaseClass implements IImportantInterface { +} + +export interface LongDescriptiveInterfaceName + extends AThirdInterface { +} + +function longFunctionNameWithLotsOfParams( + x: number, + y: number, + z: number, + a: T) { +} + +let geoConfig: { + maximumAge?: number; + timeout?: number; + enableHighAccuracy?: boolean; +} = { + maximumAge: 3000, + timeout: 5000, + enableHighAccuracy: false +}; + +declare module "*"; +declare module "someLibrary/*"; + +// No error if there are no braces +if (true) + true; +else + false; + +class Foo< + Bar, + Baz, + Bas +> { + // works for multiline type parameters +} + +type Foo = { + bar, +}; +type Bar ={ bar }; +type Baz ={ [K in T]: T }; +type Bas = "a"; + +{ + {}{}{} // just some random blocks +} diff --git a/test/rules/one-line/no-whitespace/test.ts.lint b/test/rules/one-line/no-whitespace/test.ts.lint new file mode 100644 index 00000000000..6ed6e4de9a2 --- /dev/null +++ b/test/rules/one-line/no-whitespace/test.ts.lint @@ -0,0 +1,170 @@ +module Module +{ +~ [misplaced opening brace] + export enum Enumeration + { + ~ [misplaced opening brace] + A, + B, + C, + D + } + + export function Call() + { + ~ [misplaced opening brace] + if (x == 3) + { + ~ [misplaced opening brace] + x = 4; + } + else { + ~~~~ [misplaced 'else'] + x = 5; + } + return "called"; + } +} + +interface Class +{ +~ [misplaced opening brace] + variable: string; +} + +var object = +{ +~ [misplaced opening brace] + a: 1, + b: 2 +}; + +for(var x= 0; x < 1; ++x) +{ +~ [misplaced opening brace] + ++i; +} + +switch(y) +{ +~ [misplaced opening brace] + case 0: + x--; + break; + default: + x++; + break; +} + +try +{ +~ [misplaced opening brace] + throw new Error("hi"); +} +catch (e) +~~~~~ [misplaced 'catch'] +{ +~ [misplaced opening brace] + throw(e); +} +finally +~~~~~~~ [misplaced 'finally'] +{ +~ [misplaced opening brace] + // do something +} + +try { + foo(); +} +finally +~~~~~~~ [misplaced 'finally'] +{ +~ [misplaced opening brace] + bar(); +} + +try{ + foo(); +} catch(e){ + bar(); +} finally{ + baz(); +} + +while(x < 10){ + x++; +} + +function f(): + number { + + return 5; +} + +class BarBooBaz +{ +~ [misplaced opening brace] + +} + +class FooBarBaz { +} + +// Valid multiline declarations +export class LongDescriptiveClassName, S> + extends SomeAbstractBaseClass implements IImportantInterface { +} + +export interface LongDescriptiveInterfaceName + extends AThirdInterface { +} + +function longFunctionNameWithLotsOfParams( + x: number, + y: number, + z: number, + a: T) { +} + +let geoConfig: { + maximumAge?: number; + timeout?: number; + enableHighAccuracy?: boolean; +} = { + maximumAge: 3000, + timeout: 5000, + enableHighAccuracy: false +}; + +declare module "*"; +declare module "someLibrary/*"; + +// No error if there are no braces +if (true) + true; +else + false; + +class Foo< + Bar, + Baz, + Bas +> { + // works for multiline type parameters +} + +type Foo = { + bar, +}; +type Bar = +{ bar }; +~ [misplaced opening brace] +type Baz = +{ [K in T]: T }; +~ [misplaced opening brace] +type Bas = "a"; + +{ + {}{}{} // just some random blocks +} diff --git a/test/rules/one-line/no-whitespace/tslint.json b/test/rules/one-line/no-whitespace/tslint.json new file mode 100644 index 00000000000..80fd92e4cd0 --- /dev/null +++ b/test/rules/one-line/no-whitespace/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-finally"] + } +} diff --git a/test/rules/one-line/none/test.ts.lint b/test/rules/one-line/none/test.ts.lint new file mode 100644 index 00000000000..1e974841c1f --- /dev/null +++ b/test/rules/one-line/none/test.ts.lint @@ -0,0 +1,130 @@ +module Module +{ + export enum Enumeration + { + A, + B, + C, + D + } + + export function Call() + { + if (x == 3) + { + x = 4; + } + else { + x = 5; + } + return "called"; + } +} + +interface Class +{ + variable: string; +} + +var object = +{ + a: 1, + b: 2 +}; + +for(var x= 0; x < 1; ++x) +{ + ++i; +} + +switch(y) +{ + case 0: + x--; + break; + default: + x++; + break; +} + +try +{ + throw new Error("hi"); +} +catch (e) +{ + throw(e); +} +finally +{ + // do something +} + +try { + foo(); +} +finally +{ + bar(); +} + +try{ + foo(); +} catch(e){ + bar(); +} finally{ + baz(); +} + +while(x < 10){ + x++; +} + +function f(): + number { + + return 5; +} + +class BarBooBaz +{ + +} + +class FooBarBaz { +} + +// Valid multiline declarations +export class LongDescriptiveClassName, S> + extends SomeAbstractBaseClass implements IImportantInterface { +} + +export interface LongDescriptiveInterfaceName + extends AThirdInterface { +} + +function longFunctionNameWithLotsOfParams( + x: number, + y: number, + z: number, + a: T) { +} + +let geoConfig: { + maximumAge?: number; + timeout?: number; + enableHighAccuracy?: boolean; +} = { + maximumAge: 3000, + timeout: 5000, + enableHighAccuracy: false +}; + +declare module "*"; +declare module "someLibrary/*"; + +// No error if there are no braces +if (true) + true; +else + false; diff --git a/test/rules/one-line/none/tslint.json b/test/rules/one-line/none/tslint.json new file mode 100644 index 00000000000..ea05ac32938 --- /dev/null +++ b/test/rules/one-line/none/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "one-line": true + } +} diff --git a/test/rules/one-variable-per-declaration/default/test.ts.lint b/test/rules/one-variable-per-declaration/default/test.ts.lint new file mode 100644 index 00000000000..8869d8a119a --- /dev/null +++ b/test/rules/one-variable-per-declaration/default/test.ts.lint @@ -0,0 +1,45 @@ +// valid cases +var foo1; +var foo2: number; +var foo3 = 1; + +let foo4; +let foo5: number; +let foo6 = 1; + +const foo7: number = 1; +const foo8 = 1; + +for (var i = 0; i > 1; i++) {} +for (let i = 0; i > 1; i++) {} +for (const i = 0; i > 1;) {} + +// invalid cases +var foo9, foo10; +~~~~~~~~~~~~~~~~ [0] +var foo11: number, foo12: number; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +var foo13 = 1, foo14 = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +let foo15, foo16; +~~~~~~~~~~~~~~~~~ [0] +let foo17: number, foo18: number; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let foo19 = 1, foo20 = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const foo21: number = 1, foo22: number = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +const foo23 = 1, foo24 = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +for (var i = 0, j = 0; i > 1; i++) {} + ~~~~~~~~~~~~~~~~ [0] +for (let i = 0, j = 0; i > 1; i++) {} + ~~~~~~~~~~~~~~~~ [0] +for (const i = 0, j = 0; i > 1;) {} + ~~~~~~~~~~~~~~~~~~ [0] + +[0]: Multiple variable declarations in the same statement are forbidden + diff --git a/test/rules/one-variable-per-declaration/default/tslint.json b/test/rules/one-variable-per-declaration/default/tslint.json new file mode 100644 index 00000000000..3d64c8fa578 --- /dev/null +++ b/test/rules/one-variable-per-declaration/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "one-variable-per-declaration": true + } +} diff --git a/test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint b/test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint new file mode 100644 index 00000000000..44d835fef07 --- /dev/null +++ b/test/rules/one-variable-per-declaration/ignore-for-loop/test.ts.lint @@ -0,0 +1,30 @@ +// valid cases +for (var i = 0; i > 1; i++) {} +for (let i = 0; i > 1; i++) {} +for (const i = 0; i > 1;) {} +for (var i = 0, j = 0; i > 1; i++) {} +for (let i = 0, j = 0; i > 1; i++) {} +for (const i = 0, j = 0; i > 1;) {} + +// invalid cases +var foo1, foo2; +~~~~~~~~~~~~~~~ [0] +var foo3: number, foo4: number; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +var foo5 = 1, foo6 = 1; +~~~~~~~~~~~~~~~~~~~~~~~ [0] + +let foo7, foo8; +~~~~~~~~~~~~~~~ [0] +let foo9: number, foo10: number; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +let foo11 = 1, foo12 = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const foo13: number = 1, foo14: number = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +const foo15 = 1, foo16 = 1; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: Multiple variable declarations in the same statement are forbidden + diff --git a/test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json b/test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json new file mode 100644 index 00000000000..657afeded5d --- /dev/null +++ b/test/rules/one-variable-per-declaration/ignore-for-loop/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "one-variable-per-declaration": [true, + "ignore-for-loop" + ] + } +} diff --git a/test/rules/only-arrow-functions/allow-declarations/test.ts.lint b/test/rules/only-arrow-functions/allow-declarations/test.ts.lint new file mode 100644 index 00000000000..6b0ce7a08a8 --- /dev/null +++ b/test/rules/only-arrow-functions/allow-declarations/test.ts.lint @@ -0,0 +1,26 @@ +function foo(a: any) : any { + return; +} + +let a = () => {}; +let b = function () {}; + ~~~~~~~~ [0] + +function c() {} + +function () { + // ... +} + +((func) => func())(function e(): void {}); + ~~~~~~~~ [0] + +((func) => func())(() => {}); + +function* generator() {} +let generator = function*() {} + +function hasThisParameter(this) {} +let hasThisParameter = function(this) {} + +[0]: non-arrow functions are forbidden diff --git a/test/rules/only-arrow-functions/allow-declarations/tslint.json b/test/rules/only-arrow-functions/allow-declarations/tslint.json new file mode 100644 index 00000000000..89262ad4c12 --- /dev/null +++ b/test/rules/only-arrow-functions/allow-declarations/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "only-arrow-functions": [true, "allow-declarations"] + } +} diff --git a/test/rules/only-arrow-functions/allow-named-functions/test.ts.lint b/test/rules/only-arrow-functions/allow-named-functions/test.ts.lint new file mode 100644 index 00000000000..6563488db2b --- /dev/null +++ b/test/rules/only-arrow-functions/allow-named-functions/test.ts.lint @@ -0,0 +1,7 @@ +const x = function() {} + ~~~~~~~~ [0] +const y = function y() {} + +function z() {} + +[0]: non-arrow functions are forbidden diff --git a/test/rules/only-arrow-functions/allow-named-functions/tslint.json b/test/rules/only-arrow-functions/allow-named-functions/tslint.json new file mode 100644 index 00000000000..f63eab14bd9 --- /dev/null +++ b/test/rules/only-arrow-functions/allow-named-functions/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "only-arrow-functions": [true, "allow-named-functions"] + } +} diff --git a/test/rules/only-arrow-functions/default/test.ts.lint b/test/rules/only-arrow-functions/default/test.ts.lint new file mode 100644 index 00000000000..19bc9c36cb7 --- /dev/null +++ b/test/rules/only-arrow-functions/default/test.ts.lint @@ -0,0 +1,47 @@ +function foo(a: any) : any { +~~~~~~~~ [0] + return; +} + +let a = () => {}; +let b = function () {}; + ~~~~~~~~ [0] + +function c() {} +~~~~~~~~ [0] + +function () { +~~~~~~~~ [0] + // ... +} + +((func) => func())(function e(): void {}); + ~~~~~~~~ [0] + +((func) => func())(() => {}); + +function* generator() {} +let generator = function*() {} + +function hasThisParameter(this) {} +let hasThisParameter = function(this) {} + +let usesThis = function() { this; } +let usesThis2 = function(foo = this) {} + +let notUsesThis = function() { + ~~~~~~~~ [0] + function f() { this; } +} +let notUsesThis2 = function() { + ~~~~~~~~ [0] + return class { method() { this; } } +} + +export function exported() {} + ~~~~~~~~ [0] + +async function asyncFunction() {} + ~~~~~~~~ [0] + +[0]: non-arrow functions are forbidden diff --git a/test/rules/only-arrow-functions/default/tslint.json b/test/rules/only-arrow-functions/default/tslint.json new file mode 100644 index 00000000000..2e69b360a49 --- /dev/null +++ b/test/rules/only-arrow-functions/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "only-arrow-functions": true + } +} diff --git a/test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix b/test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix new file mode 100644 index 00000000000..31b9a3fddf0 --- /dev/null +++ b/test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix @@ -0,0 +1,48 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {A, B} from 'foo'; // failure + +// Case is irrelevant for named import ordering. +import {A, bz, C} from 'foo'; // failure +import {A, b, C} from 'zfoo'; + +// Underscores come first. +import {_b, A, C, d} from 'zfoo'; // failure +import {_b, A, C, d} from 'zfoo'; + +import {g} from "y"; // failure +import { + a as d, + b as c, +} from "z"; + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as bar from 'bar'; // failure +import * as foo from 'foo'; + +// ignore quotes +import * as bar from 'bar'; +import * as foo from "foo"; + +import * as bar from "bar"; +import * as foo from 'foo'; + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault from "module"; +import "something"; +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; + +// do not fix cases where a newline is missing +import * as foo from 'foo'; import * as bar from 'bar'; + +import * as bar from 'bar'; +import * as foo from 'foo'; diff --git a/test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint b/test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint new file mode 100644 index 00000000000..1ab7bbe5114 --- /dev/null +++ b/test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint @@ -0,0 +1,61 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {B, A} from 'foo'; // failure + ~~~~ [ordered-imports] + +// Case is irrelevant for named import ordering. +import {A, b, C} from 'zfoo'; +import {bz, A, C} from 'foo'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + ~~~~~ [Named imports must be alphabetized.] + +// Underscores come first. +import {A, _b, C, d} from 'zfoo'; // failure + ~~~~~ [Named imports must be alphabetized.] +import {_b, A, C, d} from 'zfoo'; + +import { + b as c, + ~~~~~~~ + a as d, +~~~~~~~~~~ [Named imports must be alphabetized.] +} from "z"; +import {g} from "y"; // failure +~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as foo from 'foo'; +import * as bar from 'bar'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +// ignore quotes +import * as bar from 'bar'; +import * as foo from "foo"; + +import * as bar from "bar"; +import * as foo from 'foo'; + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import "something"; + +// do not fix cases where a newline is missing +import * as foo from 'foo'; import * as bar from 'bar'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +import * as foo from 'foo'; +import * as bar from 'bar'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +[ordered-imports]: Named imports must be alphabetized. +[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/case-insensitive-legacy/tslint.json b/test/rules/ordered-imports/case-insensitive-legacy/tslint.json new file mode 100644 index 00000000000..611601029ac --- /dev/null +++ b/test/rules/ordered-imports/case-insensitive-legacy/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "ordered-imports": [ + true, + { + "import-sources-order": "case-insensitive-legacy", + "named-imports-order": "case-insensitive-legacy" + } + ] + } +} diff --git a/test/rules/ordered-imports/case-insensitive/test.ts.fix b/test/rules/ordered-imports/case-insensitive/test.ts.fix new file mode 100644 index 00000000000..11a5c889203 --- /dev/null +++ b/test/rules/ordered-imports/case-insensitive/test.ts.fix @@ -0,0 +1,48 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {A, B} from 'foo'; // failure + +// Case is irrelevant for named import ordering. +import {A, bz, C} from 'foo'; // failure +import {A, b, C} from 'zfoo'; + +// Underscores come last. +import {A, C, d, _b} from 'zfoo'; // failure +import {A, C, d, _b} from 'zfoo'; + +import {g} from "y"; // failure +import { + a as d, + b as c, +} from "z"; + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as bar from 'bar'; // failure +import * as foo from 'foo'; + +// ignore quotes +import * as bar from 'bar'; +import * as foo from "foo"; + +import * as bar from "bar"; +import * as foo from 'foo'; + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault from "module"; +import "something"; +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; + +// do not fix cases where a newline is missing +import * as foo from 'foo'; import * as bar from 'bar'; + +import * as bar from 'bar'; +import * as foo from 'foo'; diff --git a/test/rules/ordered-imports/case-insensitive/test.ts.lint b/test/rules/ordered-imports/case-insensitive/test.ts.lint new file mode 100644 index 00000000000..ee69fe602f0 --- /dev/null +++ b/test/rules/ordered-imports/case-insensitive/test.ts.lint @@ -0,0 +1,61 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {B, A} from 'foo'; // failure + ~~~~ [ordered-imports] + +// Case is irrelevant for named import ordering. +import {A, b, C} from 'zfoo'; +import {bz, A, C} from 'foo'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + ~~~~~ [Named imports must be alphabetized.] + +// Underscores come last. +import {A, _b, C, d} from 'zfoo'; // failure + ~~~~~ [Named imports must be alphabetized.] +import {A, C, d, _b} from 'zfoo'; + +import { + b as c, + ~~~~~~~ + a as d, +~~~~~~~~~~ [Named imports must be alphabetized.] +} from "z"; +import {g} from "y"; // failure +~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as foo from 'foo'; +import * as bar from 'bar'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +// ignore quotes +import * as bar from 'bar'; +import * as foo from "foo"; + +import * as bar from "bar"; +import * as foo from 'foo'; + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import "something"; + +// do not fix cases where a newline is missing +import * as foo from 'foo'; import * as bar from 'bar'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +import * as foo from 'foo'; +import * as bar from 'bar'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +[ordered-imports]: Named imports must be alphabetized. +[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/case-insensitive/tslint.json b/test/rules/ordered-imports/case-insensitive/tslint.json new file mode 100644 index 00000000000..714e6c81bc9 --- /dev/null +++ b/test/rules/ordered-imports/case-insensitive/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": true + } +} diff --git a/test/rules/ordered-imports/grouped-imports/test.ts.fix b/test/rules/ordered-imports/grouped-imports/test.ts.fix new file mode 100644 index 00000000000..13a8cc71812 --- /dev/null +++ b/test/rules/ordered-imports/grouped-imports/test.ts.fix @@ -0,0 +1,13 @@ +#!/usr/bin/env node +/* Test the case where import should be grouped using default grouping. */ + +import {afoo, foo} from 'foo'; +import x = require('y'); + +import {bar} from '../bar'; + +import './baa'; +import './baz'; // required +import './caa'; + +export class Test {} diff --git a/test/rules/ordered-imports/grouped-imports/test.ts.lint b/test/rules/ordered-imports/grouped-imports/test.ts.lint new file mode 100644 index 00000000000..321bbc51bde --- /dev/null +++ b/test/rules/ordered-imports/grouped-imports/test.ts.lint @@ -0,0 +1,18 @@ +#!/usr/bin/env node +/* Test the case where import should be grouped using default grouping. */ + +import {bar} from '../bar'; + +import {foo, afoo} from 'foo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: libraries, parent directories, current directory.] + ~~~~~~~~~ [Named imports must be alphabetized.] + +import './baz'; // required +import './baa'; +~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +import './caa'; + +import x = require('y'); + +export class Test {} diff --git a/test/rules/ordered-imports/grouped-imports/tslint.json b/test/rules/ordered-imports/grouped-imports/tslint.json new file mode 100644 index 00000000000..307aed99054 --- /dev/null +++ b/test/rules/ordered-imports/grouped-imports/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "ordered-imports": [ + true, { + "import-sources-order": "case-insensitive", + "named-imports-order": "case-insensitive", + "grouped-imports": true + }] + } +} diff --git a/test/rules/ordered-imports/groups-complex/test.ts.fix b/test/rules/ordered-imports/groups-complex/test.ts.fix new file mode 100644 index 00000000000..f9ee5865e32 --- /dev/null +++ b/test/rules/ordered-imports/groups-complex/test.ts.fix @@ -0,0 +1,24 @@ +#!/usr/bin/env node +/* Test a more complex set of split up groups. */ + +// comment outside of imports +import {afoo, foo} from 'foo'; +import x = require('y'); + +import {app_b} from 'app/bar'; +import {app_f} from 'app/foo'; + +// comment pkg/bar +import {a} from '@pkg/bar'; +import {x} from '@pkg/foo'; + +import './baa'; +import './baz'; // required + +import {bar} from '../bar'; +import {xbar} from '../xbar'; +x.fnCall(); + + + +export class Test {} diff --git a/test/rules/ordered-imports/groups-complex/test.ts.lint b/test/rules/ordered-imports/groups-complex/test.ts.lint new file mode 100644 index 00000000000..36772342a19 --- /dev/null +++ b/test/rules/ordered-imports/groups-complex/test.ts.lint @@ -0,0 +1,30 @@ +#!/usr/bin/env node +/* Test a more complex set of split up groups. */ + +// comment outside of imports +import {app_f} from 'app/foo'; +import {x} from '@pkg/foo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: extra, /^app/, /^@pkg/, current dir, parent_dir.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +import {app_b} from 'app/bar'; +// comment pkg/bar +import {a} from '@pkg/bar'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +import {xbar} from '../xbar'; + +import {bar} from '../bar'; + +import {foo, afoo} from 'foo'; + ~~~~~~~~~ [Named imports must be alphabetized.] + +import x = require('y'); +x.fnCall(); + +import './baz'; // required +import './baa'; +~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + + +export class Test {} diff --git a/test/rules/ordered-imports/groups-complex/tslint.json b/test/rules/ordered-imports/groups-complex/tslint.json new file mode 100644 index 00000000000..dd444e141fc --- /dev/null +++ b/test/rules/ordered-imports/groups-complex/tslint.json @@ -0,0 +1,19 @@ +{ + "rules": { + "ordered-imports": [ + true, + { + "import-sources-order": "case-insensitive", + "named-imports-order": "case-insensitive", + "grouped-imports": true, + "groups": [ + { "match": "^app", "order": 20 }, + { "match": "^@pkg", "order": 30 }, + { "name": "parent_dir", "match": "^\\.\\.", "order": 50 }, + { "name": "current dir", "match": "^\\.", "order": 40 }, + { "name": "extra", "match": ".*", "order": 5 } + ] + } + ] + } +} diff --git a/test/rules/ordered-imports/groups-shared-order/test.ts.fix b/test/rules/ordered-imports/groups-shared-order/test.ts.fix new file mode 100644 index 00000000000..7a50b6b2858 --- /dev/null +++ b/test/rules/ordered-imports/groups-shared-order/test.ts.fix @@ -0,0 +1,13 @@ +#!/usr/bin/env node +/* Test the case where multiple matches have the same order value. */ + +import {y} from 'app_a/bar'; +import {x} from 'app_a/foo'; +import {f} from 'app_b/foo'; + +import {b} from '@pkg/bar'; +import {a} from '@pkg/foo'; + +import {o} from 'other/bar'; + +export class Test {} diff --git a/test/rules/ordered-imports/groups-shared-order/test.ts.lint b/test/rules/ordered-imports/groups-shared-order/test.ts.lint new file mode 100644 index 00000000000..1d518fd824f --- /dev/null +++ b/test/rules/ordered-imports/groups-shared-order/test.ts.lint @@ -0,0 +1,18 @@ +#!/usr/bin/env node +/* Test the case where multiple matches have the same order value. */ + +import {f} from 'app_b/foo'; +import {x} from 'app_a/foo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import {y} from 'app_a/bar'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + + +import {a} from '@pkg/foo'; + +import {b} from '@pkg/bar'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: /^app_b/, /^app_a/, /^@pkg/.] + +import {o} from 'other/bar'; + +export class Test {} diff --git a/test/rules/ordered-imports/groups-shared-order/tslint.json b/test/rules/ordered-imports/groups-shared-order/tslint.json new file mode 100644 index 00000000000..f74cab4f9ca --- /dev/null +++ b/test/rules/ordered-imports/groups-shared-order/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "ordered-imports": [ + true, + { + "import-sources-order": "case-insensitive", + "named-imports-order": "case-insensitive", + "grouped-imports": true, + "groups": [ + { "match": "^app_b", "order": 10 }, + { "match": "^app_a", "order": 10 }, + { "match": "^@pkg", "order": 20 } + ] + } + ] + } +} diff --git a/test/rules/ordered-imports/groups-string-list/test.ts.fix b/test/rules/ordered-imports/groups-string-list/test.ts.fix new file mode 100644 index 00000000000..c8a7d7bca4a --- /dev/null +++ b/test/rules/ordered-imports/groups-string-list/test.ts.fix @@ -0,0 +1,18 @@ +#!/usr/bin/env node +/* Test import grouping where only a list or regex strings is passed to config. */ + +import { app_b } from "app/bar"; +import { app_f } from "app/foo"; + +import { a } from "@pkg/bar"; +import { x } from "@pkg/foo"; + +import { bar } from "../bar"; +import { xbar } from "../xbar"; + +import "./baa"; +import "./baz"; + +import { foo } from "foo"; + +export class Test {} diff --git a/test/rules/ordered-imports/groups-string-list/test.ts.lint b/test/rules/ordered-imports/groups-string-list/test.ts.lint new file mode 100644 index 00000000000..28d518d3cb6 --- /dev/null +++ b/test/rules/ordered-imports/groups-string-list/test.ts.lint @@ -0,0 +1,20 @@ +#!/usr/bin/env node +/* Test import grouping where only a list or regex strings is passed to config. */ + +import { x } from "@pkg/foo"; +import { app_f } from "app/foo"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: /^app/, /^@pkg/, /^\.\./, /^\./.] + +import { a } from "@pkg/bar"; +import { app_b } from "app/bar"; + +import { xbar } from "../xbar"; + +import { bar } from "../bar"; + +import { foo } from "foo"; + +import "./baa"; +import "./baz"; + +export class Test {} diff --git a/test/rules/ordered-imports/groups-string-list/tslint.json b/test/rules/ordered-imports/groups-string-list/tslint.json new file mode 100644 index 00000000000..cf049d8e990 --- /dev/null +++ b/test/rules/ordered-imports/groups-string-list/tslint.json @@ -0,0 +1,13 @@ +{ + "rules": { + "ordered-imports": [ + true, + { + "import-sources-order": "case-insensitive", + "named-imports-order": "case-insensitive", + "grouped-imports": true, + "groups": ["^app", "^@pkg", "^\\.\\.", "^\\."] + } + ] + } +} diff --git a/test/rules/ordered-imports/groups-unmatched/test.ts.fix b/test/rules/ordered-imports/groups-unmatched/test.ts.fix new file mode 100644 index 00000000000..5cd8ca747ea --- /dev/null +++ b/test/rules/ordered-imports/groups-unmatched/test.ts.fix @@ -0,0 +1,14 @@ +#!/usr/bin/env node +/* Test to check that all unmatched imports end up in unmatched group at end.*/ + +import {app_b} from 'app/bar'; +import {app_f} from 'app/foo'; + +import {a} from '@pkg/bar'; +import {x} from '@pkg/foo'; + +import {foo} from 'foo'; +import {xbar} from '../xbar'; +import {b} from './ybar'; + +export class Test {} diff --git a/test/rules/ordered-imports/groups-unmatched/test.ts.lint b/test/rules/ordered-imports/groups-unmatched/test.ts.lint new file mode 100644 index 00000000000..bc1dd250ff1 --- /dev/null +++ b/test/rules/ordered-imports/groups-unmatched/test.ts.lint @@ -0,0 +1,18 @@ +#!/usr/bin/env node +/* Test to check that all unmatched imports end up in unmatched group at end.*/ + +import {app_f} from 'app/foo'; + +import {x} from '@pkg/foo'; + +import {app_b} from 'app/bar'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: /^app/, /^@pkg/.] + +import {a} from '@pkg/bar'; + +import {xbar} from '../xbar'; + +import {foo} from 'foo'; +import {b} from './ybar'; + +export class Test {} diff --git a/test/rules/ordered-imports/groups-unmatched/tslint.json b/test/rules/ordered-imports/groups-unmatched/tslint.json new file mode 100644 index 00000000000..7b810a8f933 --- /dev/null +++ b/test/rules/ordered-imports/groups-unmatched/tslint.json @@ -0,0 +1,13 @@ +{ + "rules": { + "ordered-imports": [ + true, + { + "import-sources-order": "case-insensitive", + "named-imports-order": "case-insensitive", + "grouped-imports": true, + "groups": [{ "match": "^app", "order": 20 }, { "match": "^@pkg", "order": 30 }] + } + ] + } +} diff --git a/test/rules/ordered-imports/import-sources-any/default/test.ts.fix b/test/rules/ordered-imports/import-sources-any/default/test.ts.fix new file mode 100644 index 00000000000..36552bd9588 --- /dev/null +++ b/test/rules/ordered-imports/import-sources-any/default/test.ts.fix @@ -0,0 +1,31 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {A, B} from 'foo'; // failure + +// Case is irrelevant for named import ordering. +import {A, b, C} from 'zfoo'; +import {A, bz, C} from 'foo'; // failure + +// Import sources don't need to be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as foo from 'foo'; +import * as bar from 'bar'; // should not fail + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +import "something"; + +// contains ImportEqualsDeclaration +import c = require('./c'); +import * as a from './a'; +import b from './b'; + diff --git a/test/rules/ordered-imports/import-sources-any/default/test.ts.lint b/test/rules/ordered-imports/import-sources-any/default/test.ts.lint new file mode 100644 index 00000000000..2404b2e0f6f --- /dev/null +++ b/test/rules/ordered-imports/import-sources-any/default/test.ts.lint @@ -0,0 +1,35 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {B, A} from 'foo'; // failure + ~~~~ [ordered-imports] + +// Case is irrelevant for named import ordering. +import {A, b, C} from 'zfoo'; +import {bz, A, C} from 'foo'; // failure + ~~~~~ [ordered-imports] + +// Import sources don't need to be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as foo from 'foo'; +import * as bar from 'bar'; // should not fail + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +import "something"; + +// contains ImportEqualsDeclaration +import c = require('./c'); +import * as a from './a'; +import b from './b'; + +[ordered-imports]: Named imports must be alphabetized. +[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/import-sources-any/default/tslint.json b/test/rules/ordered-imports/import-sources-any/default/tslint.json new file mode 100644 index 00000000000..a88bcb08b5d --- /dev/null +++ b/test/rules/ordered-imports/import-sources-any/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": [true, {"import-sources-order": "any"}] + } +} diff --git a/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix b/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix new file mode 100644 index 00000000000..f620876650b --- /dev/null +++ b/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.fix @@ -0,0 +1,4 @@ +import { getOr } from 'lodash/fp' +import { Request } from 'express' + +import { getStatusCode } from './errors' diff --git a/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint b/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint new file mode 100644 index 00000000000..cef72a1ee8b --- /dev/null +++ b/test/rules/ordered-imports/import-sources-any/grouped-imports/test.ts.lint @@ -0,0 +1,5 @@ +import { getOr } from 'lodash/fp' + +import { Request } from 'express' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: libraries, parent directories, current directory.] +import { getStatusCode } from './errors' diff --git a/test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json b/test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json new file mode 100644 index 00000000000..c49cdb90188 --- /dev/null +++ b/test/rules/ordered-imports/import-sources-any/grouped-imports/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": [true, {"import-sources-order": "any", "grouped-imports": true}] + } + } diff --git a/test/rules/ordered-imports/inside-module-declaration/test.ts.lint b/test/rules/ordered-imports/inside-module-declaration/test.ts.lint new file mode 100644 index 00000000000..59f908d8334 --- /dev/null +++ b/test/rules/ordered-imports/inside-module-declaration/test.ts.lint @@ -0,0 +1,7 @@ +declare module "foo" { + import y from "y"; + import x from "x"; + ~~~~~~~~~~~~~~~~~~ [0] +} + +[0]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/inside-module-declaration/tslint.json b/test/rules/ordered-imports/inside-module-declaration/tslint.json new file mode 100644 index 00000000000..9f79dbd1712 --- /dev/null +++ b/test/rules/ordered-imports/inside-module-declaration/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": [true] + } +} diff --git a/test/rules/ordered-imports/lowercase-first/test.ts.fix b/test/rules/ordered-imports/lowercase-first/test.ts.fix new file mode 100644 index 00000000000..c1a1e3682f8 --- /dev/null +++ b/test/rules/ordered-imports/lowercase-first/test.ts.fix @@ -0,0 +1,31 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {A, B} from 'foo'; // failure + +// Lowercase comes before uppercase. +import {bz, A, C} from 'foo'; // failure +import {b, A, C} from 'zfoo'; + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as bar from 'bar'; // failure +import * as foo from 'foo'; + +// Lowercase comes before uppercase +import {A, B} from 'baz'; +import {A, B} from 'Bar'; +import {A, B} from 'Foo'; + +// Other styles of import statements. +import someDefault from "module"; +import "something"; +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; + +// contains ImportEqualsDeclaration +import * as a from './a'; +import b from './b'; +import c = require('./c'); + diff --git a/test/rules/ordered-imports/lowercase-first/test.ts.lint b/test/rules/ordered-imports/lowercase-first/test.ts.lint new file mode 100644 index 00000000000..bac65e93568 --- /dev/null +++ b/test/rules/ordered-imports/lowercase-first/test.ts.lint @@ -0,0 +1,40 @@ +// Named imports should be alphabetized. +import {A, B} from 'foo'; +import {B, A} from 'foo'; // failure + ~~~~ [ordered-imports] + +// Lowercase comes before uppercase. +import {A, b, C} from 'zfoo'; + ~~~~ [Named imports must be alphabetized.] +import {bz, A, C} from 'foo'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as foo from 'foo'; +import * as bar from 'bar'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +// Lowercase comes before uppercase +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] +import {A, B} from 'Foo'; + +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import "something"; + +// contains ImportEqualsDeclaration +import c = require('./c'); +import * as a from './a'; +~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] +import b from './b'; + +[ordered-imports]: Named imports must be alphabetized. +[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/lowercase-first/tslint.json b/test/rules/ordered-imports/lowercase-first/tslint.json new file mode 100644 index 00000000000..62b8787a617 --- /dev/null +++ b/test/rules/ordered-imports/lowercase-first/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": [true, {"import-sources-order": "lowercase-first", "named-imports-order": "lowercase-first"}] + } +} diff --git a/test/rules/ordered-imports/module-source-path/test.ts.fix b/test/rules/ordered-imports/module-source-path/test.ts.fix new file mode 100644 index 00000000000..11b341b29ef --- /dev/null +++ b/test/rules/ordered-imports/module-source-path/test.ts.fix @@ -0,0 +1,19 @@ +// Other styles of import statements. +import someDefault from "module"; +import "something"; +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; + +// contains relative path & ImportEqualsDeclaration +import a from './foo/a'; +import b from './bar/b'; +import c = require('./baz/c'); + +// contains relative path & ImportEqualsDeclaration +import a from '../../foo/a'; +import b from './bar/b'; +import c = require('./baz/c'); + +// contains scoped import +import a from 'foo/a'; +import b = require('foo/b'); +import c from 'foo/c'; diff --git a/test/rules/ordered-imports/module-source-path/test.ts.lint b/test/rules/ordered-imports/module-source-path/test.ts.lint new file mode 100644 index 00000000000..3ced77fc1c5 --- /dev/null +++ b/test/rules/ordered-imports/module-source-path/test.ts.lint @@ -0,0 +1,23 @@ +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import "something"; + +// contains relative path & ImportEqualsDeclaration +import c = require('./baz/c'); +import a from './foo/a'; +~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import b from './bar/b'; + +// contains relative path & ImportEqualsDeclaration +import c = require('./baz/c'); +import a from '../../foo/a'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import b from './bar/b'; + +// contains scoped import +import b = require('foo/b'); +import a from 'foo/a'; +~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import c from 'foo/c'; diff --git a/test/rules/ordered-imports/module-source-path/tslint.json b/test/rules/ordered-imports/module-source-path/tslint.json new file mode 100644 index 00000000000..93b97002867 --- /dev/null +++ b/test/rules/ordered-imports/module-source-path/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": [true, {"module-source-path": "basename"}] + } +} diff --git a/test/rules/ordered-imports/named-imports-any/test.ts.fix b/test/rules/ordered-imports/named-imports-any/test.ts.fix new file mode 100644 index 00000000000..d43cf75eb33 --- /dev/null +++ b/test/rules/ordered-imports/named-imports-any/test.ts.fix @@ -0,0 +1,42 @@ +// Named imports do not need to be alphabetized. +import {A, B} from 'foo'; +import {B, A} from 'foo'; // should not fail + +// Case is irrelevant for named import ordering. +import {bz, A, C} from 'foo'; // should not fail +import {A, b, C} from 'zfoo'; + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as bar from 'bar'; // failure +import * as foo from 'foo'; + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault from "module"; +import "something"; +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; + +// contains ImportEqualsDeclaration +import * as a from './a'; +import b from './b'; +import c = require('./c'); + +import * as a from './a'; +import b from './b'; +import c = require('./c'); + +import * as a from './a'; +import b from './b'; +import c = require('./c'); + +import c = require('./c'); +import d = require('./d'); + diff --git a/test/rules/ordered-imports/named-imports-any/test.ts.lint b/test/rules/ordered-imports/named-imports-any/test.ts.lint new file mode 100644 index 00000000000..400879083c5 --- /dev/null +++ b/test/rules/ordered-imports/named-imports-any/test.ts.lint @@ -0,0 +1,52 @@ +// Named imports do not need to be alphabetized. +import {A, B} from 'foo'; +import {B, A} from 'foo'; // should not fail + +// Case is irrelevant for named import ordering. +import {A, b, C} from 'zfoo'; +import {bz, A, C} from 'foo'; // should not fail +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] + +// Import sources should be alphabetized. +import * as bar from 'bar'; +import * as foo from 'foo'; + +import * as abc from 'abc'; +import * as foo from 'foo'; +import * as bar from 'bar'; // failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +// Case is irrelevant for source import ordering. +import {A, B} from 'Bar'; +import {A, B} from 'baz'; +import {A, B} from 'Foo'; // should not fail + +// Other styles of import statements. +import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; +import someDefault from "module"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] +import "something"; + +// contains ImportEqualsDeclaration +import c = require('./c'); +import * as a from './a'; +~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] +import b from './b'; + +import * as a from './a'; +import c = require('./c'); +import b from './b'; +~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +import c = require('./c'); +import b from './b'; +~~~~~~~~~~~~~~~~~~~~ [ordered-sources] +import * as a from './a'; +~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +import d = require('./d'); +import c = require('./c'); +~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] + +[ordered-imports]: Named imports must be alphabetized. +[ordered-sources]: Import sources within a group must be alphabetized. diff --git a/test/rules/ordered-imports/named-imports-any/tslint.json b/test/rules/ordered-imports/named-imports-any/tslint.json new file mode 100644 index 00000000000..89be91b2528 --- /dev/null +++ b/test/rules/ordered-imports/named-imports-any/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "ordered-imports": [true, {"named-imports-order": "any"}] + } +} diff --git a/test/rules/ordered-imports/standalone-grouped-import/test.ts.fix b/test/rules/ordered-imports/standalone-grouped-import/test.ts.fix new file mode 100644 index 00000000000..b1ac69a33bd --- /dev/null +++ b/test/rules/ordered-imports/standalone-grouped-import/test.ts.fix @@ -0,0 +1,10 @@ +#!/usr/bin/env node + +import {a} from 'foo'; +import x = require('y'); + +import './baa'; +import './baz'; +import './caa'; + +export class Test {} diff --git a/test/rules/ordered-imports/standalone-grouped-import/test.ts.lint b/test/rules/ordered-imports/standalone-grouped-import/test.ts.lint new file mode 100644 index 00000000000..9ce6cefb980 --- /dev/null +++ b/test/rules/ordered-imports/standalone-grouped-import/test.ts.lint @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +import {a} from 'foo'; + +import './baa'; +import './baz'; + +import './caa'; +~~~~~~~~~~~~~~~ [Imports from this module are not allowed in this group. The expected groups (in order) are: libraries, parent directories, current directory.] + +import x = require('y'); + +export class Test {} diff --git a/test/rules/ordered-imports/standalone-grouped-import/tslint.json b/test/rules/ordered-imports/standalone-grouped-import/tslint.json new file mode 100644 index 00000000000..307aed99054 --- /dev/null +++ b/test/rules/ordered-imports/standalone-grouped-import/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "ordered-imports": [ + true, { + "import-sources-order": "case-insensitive", + "named-imports-order": "case-insensitive", + "grouped-imports": true + }] + } +} diff --git a/test/rules/prefer-conditional-expression/check-else-if/test.ts.lint b/test/rules/prefer-conditional-expression/check-else-if/test.ts.lint new file mode 100644 index 00000000000..0424780d9f4 --- /dev/null +++ b/test/rules/prefer-conditional-expression/check-else-if/test.ts.lint @@ -0,0 +1,106 @@ +let x; +if (true) { +~~ [err % ('x')] + x = 1; +} else { + x = 2; +} + +if (true) +~~ [err % ('x')] + x = "TRUE"; +else if (false) + x = "FALSE"; +else + x = "FILE_NOT_FOUND"; + +// Must assign same variable +if (true) { + x = 1; +} else { + y = 2; +} + +// All branches must be present +if (true) { + x = 1; +} + +// Must not be a multi-statement block. +if (true) { + x = 1; +} else { + x = 2; + y = 3; +} + +// Or even multi-line. +if (true) + x = [ + 1, + 2 + ]; +else + x = 3; + +// Works for complex left hand side. +if (true) { +~~ [err % ('foo(bar).baz')] + foo(bar).baz = 0; +} else { + foo(bar).baz = 1; +} + +if (length === 0) { +~~ [err % ('x')] + x = "foo"; +} else if (length === 1) { + x = "bar"; +} else if (length === 2) { + x = "something else"; +} else { + x = "unknown"; +} + +if (length === 0) { +~~ [err % ('x')] + x = "foo"; +} else { + if (length === 1) { + x = "bar"; + } else { + if (length === 2) { + x = "something else"; + } else { + x = "unknown"; + } + } +} + +if (length === 0) { + y = "foo"; +} else if (length === 1) { + ~~ [err % ('x')] + x = "bar"; +} else if (length === 2) { + x = "something else"; +} else { + x = "unknown"; +} + +if (length === 0) { + y = "foo"; +} else { + if (length === 1) { + ~~ [err % ('x')] + x = "bar"; + } else { + if (length === 2) { + x = "something else"; + } else { + x = "unknown"; + } + } +} + +[err]: Use a conditional expression instead of assigning to '%s' in multiple places. diff --git a/test/rules/prefer-conditional-expression/check-else-if/tslint.json b/test/rules/prefer-conditional-expression/check-else-if/tslint.json new file mode 100644 index 00000000000..07c97a9338a --- /dev/null +++ b/test/rules/prefer-conditional-expression/check-else-if/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-conditional-expression": [true, "check-else-if"] + } +} diff --git a/test/rules/prefer-conditional-expression/default/test.ts.lint b/test/rules/prefer-conditional-expression/default/test.ts.lint new file mode 100644 index 00000000000..ead36e4f3dd --- /dev/null +++ b/test/rules/prefer-conditional-expression/default/test.ts.lint @@ -0,0 +1,95 @@ +let x; +if (true) { +~~ [err % ('x')] + x = 1; +} else { + x = 2; +} + +if (true) + x = "TRUE"; +else if (false) + x = "FALSE"; +else + x = "FILE_NOT_FOUND"; + +// Must assign same variable +if (true) { + x = 1; +} else { + y = 2; +} + +// All branches must be present +if (true) { + x = 1; +} + +// Must not be a multi-statement block. +if (true) { + x = 1; +} else { + x = 2; + y = 3; +} + +// Or even multi-line. +if (true) + x = [ + 1, + 2 + ]; +else + x = 3; + +// Works for complex left hand side. +if (true) { +~~ [err % ('foo(bar).baz')] + foo(bar).baz = 0; +} else { + foo(bar).baz = 1; +} + +// leave nested if statements alone +if (length === 0) { + x = "foo"; +} else if (length === 1) { + x = "bar"; +} else if (length === 2) { + x = "something else"; +} else { + x = "unknown"; +} + +if (length === 0) { + x = "foo"; +} else { + if (length === 1) { + x = "bar"; + } else { + if (length === 2) { + x = "something else"; + } else { + x = "unknown"; + } + } +} + +if (length === 0) { + x = "foo"; +} else if (length === 1) { + x = "bar"; +} else if (length === 2) { + x = "something else"; +} else { + foo(); + // detects nested if statements when not direct child of else + if (bar) { + ~~ [err % ('x')] + x = 1; + } else { + x = 2; + } +} + +[err]: Use a conditional expression instead of assigning to '%s' in multiple places. diff --git a/test/rules/prefer-conditional-expression/default/tslint.json b/test/rules/prefer-conditional-expression/default/tslint.json new file mode 100644 index 00000000000..8f68fd2c6a0 --- /dev/null +++ b/test/rules/prefer-conditional-expression/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-conditional-expression": true + } +} diff --git a/test/rules/prefer-const/default/ambient.d.ts.lint b/test/rules/prefer-const/default/ambient.d.ts.lint new file mode 100644 index 00000000000..5a9f881717c --- /dev/null +++ b/test/rules/prefer-const/default/ambient.d.ts.lint @@ -0,0 +1,5 @@ +// no errors in declaration files +let foo = 0; +namespace bar { + let foo = 0; +} \ No newline at end of file diff --git a/test/rules/prefer-const/default/global.ts.lint b/test/rules/prefer-const/default/global.ts.lint new file mode 100644 index 00000000000..a941fd89b18 --- /dev/null +++ b/test/rules/prefer-const/default/global.ts.lint @@ -0,0 +1,17 @@ +// this is not an external module +// variables in the global scope are ignored by prefer-const +let var1 = 0; +let var2 = 0; +{ + let var2 = 1; + { + var2 = 2; + } + var var3 = 0; + { + let var3 = 1; + var3 = 2; + let var4 = 0; + ~~~~ [Identifier 'var4' is never reassigned; use 'const' instead of 'let'.] + } +} \ No newline at end of file diff --git a/test/rules/prefer-const/default/spread.ts.lint b/test/rules/prefer-const/default/spread.ts.lint new file mode 100644 index 00000000000..7847c8db97a --- /dev/null +++ b/test/rules/prefer-const/default/spread.ts.lint @@ -0,0 +1,24 @@ +{ + let d1 = 0; + let d2 = 0; + let d3 = 0; + let d4 = 0; + [(d1), ([d2]), ...[d3 = 1, ...(d4)]] = []; +} + +{ + let d1 = 0; + let d2 = 0; + let d3 = 0; + let d4 = 0; + let d5 = 0; + ({ + d1 = 2, + foo: d2, + bar: { + ...d3 + }, + baz: {d4} = {}, + ...(d5), + } = {}); +} \ No newline at end of file diff --git a/test/rules/prefer-const/default/test.ts.fix b/test/rules/prefer-const/default/test.ts.fix new file mode 100644 index 00000000000..987b880694e --- /dev/null +++ b/test/rules/prefer-const/default/test.ts.fix @@ -0,0 +1,228 @@ +const a = 1; + +// different reassignments +let b = 1; +b = 2; +let b1 = 1; +b1++; +let b2 = 1; +b2--; +let b3 = 1; +b3 /= 2; +let b4 = 1; +--b4; + +// basic failure +const c = 1; // failure + +// multiple declarations +const c5 = 5, c6 = 6; +const c1 = 1, c2 = 2; // 2 failures +let c3 = 1, c4 = 2; // 1 failure +c3 = 4; + +// destructuring +{ + let destructLater = 4; + [destructLater] = 5; + let a: number; + let b: number; + let c: any; + ({ eh: a, b, ...c } = { eh: 0, b: 1 }); +} + +let {h, i} = {h: 1, i: 1}; // failure for 'h' +let [j, k] = [1, 1]; // failure for 'j' +let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 +let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // failure for 'r' +i = 2; +k = 2; +q = 4; +x2 = 5; + +// functions +function myFunc(d: number, e: number) { + const f = 1; // failure + const g = 1; + d = 2; +} +function myFunc2() { + let [l, m] = [1, 1]; // failure for 'l' + m = 2; + return l; +} + +// for-of +for (const n of [1, 1]) { // failure for 'n' + console.log(n); +} +for (let {o, p} of [{1, 1}, {1, 1}]) { + console.log(o); + p = 2; +} + +// for loop +for (let i1 = 0; i1 < 4; i1++) { +} +for (const i2 = 0;;) { // failure +} +for (const i2 = 0;;) { +} + +// scope +let sc = 0; +const sc1 = 0; +let sc2 = 0; +let sc3 = 0; +{ + sc = 1; +} +for(;;) { + sc2 = 3; +} +class MyClass { + private classVar = 5; + public Increment() { + let sc4 = 0; + const sc5 = 0; // error + this.classVar++; + sc3++; + sc4++; + } +} + +// separate declaration and assignment (no error) +let x: number; +x = 5; + +// ignores RHS of declaration +const usedAsRHS = 3; +const LHS: number | string = usedAsRHS; + +// handle nested declaration +const nest = () => { + const a = 4; + let b = 0; + const c = 1; + b = 2; + return a + b + c; +}; + +const nest2 = () => { + const error = false; + try { + } catch(error) { + // variable error is block scoped + error = true; + } +} + +// export +export let x = 4; + +// array +const arr = []; +arr.push(0); +arr[1] = 1; +arr.length = 1; + +// reassignment of the forward declaration +function useOfForwardDecl() { + forwardDecl = 1; +} + +let forwardDecl: number; + +module E { + const x = 1; +} + +switch (1) { + case 1: + const x = 1; + break; + case 2: + const y = 1; + break; +} + +var someVariable = 0; +function funcxion(someVariable, someParameter) { + someVariable = 1; + { + var var1 = 0; + var var2 = 0; + } + { + var1 = 1; + } + { + let var2 = 1; + var2 = 2; + } +} + +const shadowed1 = 0; +const shadowed2 = 0; +const shadowed3 = 0; +function shadowVariables({shadowed1, ...shadowed2}, shadowed3) { + shadowed1 = 1; + shadowed2 = 1; + shadowed3 = 1; +} + +// no error in for loop initializer +for (let i = 1, l = arr.length; i < l; ++i) { +} + +{ + const var1 = 0; + let var2 = 0; + function foo(var1 = var2 = 1, var2 = var1 = 1) {} + function foo2(p1 = var2 = 1) { + const var2 = 0; + } +} + +// cannot fix, because of uninitialized variables +let uninitialized; +let initialized1 = 0, uninitialized2; + +// ambient declarations are not checked +declare let ambient = 0; + +declare namespace ambient { + let foo = 0; +} + +{ + let someVar: string; + for (someVar in someObj) {} +} +{ + let someVar: string; + for (someVar of someArr) {} +} +{ + let someVar: string, someVar2: string; + for ({someVar, foo: someVar2} of someArr) {} +} +{ + let someVar: string, someObj: any; + for ({someVar: someObj.val} of someArr) {} +} +for (let [var1, var2] of someArr) { + var1 = null; +} +for (const [var1, var2] of someArr) {} +for (let {var1, var2} of someArr) { + var2 = null; +} + +{ + let k: any = 0; + function foo(param: {[k: string]: string}) { + k = param; + } +} + diff --git a/test/rules/prefer-const/default/test.ts.lint b/test/rules/prefer-const/default/test.ts.lint new file mode 100644 index 00000000000..5b379fce273 --- /dev/null +++ b/test/rules/prefer-const/default/test.ts.lint @@ -0,0 +1,270 @@ +const a = 1; + +// different reassignments +let b = 1; +b = 2; +let b1 = 1; +b1++; +let b2 = 1; +b2--; +let b3 = 1; +b3 /= 2; +let b4 = 1; +--b4; + +// basic failure +let c = 1; // failure + ~ [let % ('c')] + +// multiple declarations +const c5 = 5, c6 = 6; +let c1 = 1, c2 = 2; // 2 failures + ~~ [let % ('c1')] + ~~ [let % ('c2')] +let c3 = 1, c4 = 2; // 1 failure + ~~ [let % ('c4')] +c3 = 4; + +// destructuring +{ + let destructLater = 4; + [destructLater] = 5; + let a: number; + let b: number; + let c: any; + ({ eh: a, b, ...c } = { eh: 0, b: 1 }); +} + +let {h, i} = {h: 1, i: 1}; // failure for 'h' + ~ [let % ('h')] +let [j, k] = [1, 1]; // failure for 'j' + ~ [let % ('j')] +let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 + ~~ [let % ('x1')] + ~~ [let % ('x3')] +let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // failure for 'r' + ~ [let % ('r')] +i = 2; +k = 2; +q = 4; +x2 = 5; + +// functions +function myFunc(d: number, e: number) { + let f = 1; // failure + ~ [let % ('f')] + const g = 1; + d = 2; +} +function myFunc2() { + let [l, m] = [1, 1]; // failure for 'l' + ~ [let % ('l')] + m = 2; + return l; +} + +// for-of +for (let n of [1, 1]) { // failure for 'n' + ~ [let % ('n')] + console.log(n); +} +for (let {o, p} of [{1, 1}, {1, 1}]) { + console.log(o); + p = 2; +} + +// for loop +for (let i1 = 0; i1 < 4; i1++) { +} +for (let i2 = 0;;) { // failure + ~~ [let % ('i2')] +} +for (const i2 = 0;;) { +} + +// scope +let sc = 0; +let sc1 = 0; + ~~~ [let % ('sc1')] +let sc2 = 0; +let sc3 = 0; +{ + sc = 1; +} +for(;;) { + sc2 = 3; +} +class MyClass { + private classVar = 5; + public Increment() { + let sc4 = 0; + let sc5 = 0; // error + ~~~ [let % ('sc5')] + this.classVar++; + sc3++; + sc4++; + } +} + +// separate declaration and assignment (no error) +let x: number; +x = 5; + +// ignores RHS of declaration +let usedAsRHS = 3; + ~~~~~~~~~ [let % ('usedAsRHS')] +let LHS: number | string = usedAsRHS; + ~~~ [let % ('LHS')] + +// handle nested declaration +let nest = () => { + ~~~~ [let % ('nest')] + const a = 4; + let b = 0; + let c = 1; + ~ [let % ('c')] + b = 2; + return a + b + c; +}; + +let nest2 = () => { + ~~~~~ [let % ('nest2')] + let error = false; + ~~~~~ [let % ('error')] + try { + } catch(error) { + // variable error is block scoped + error = true; + } +} + +// export +export let x = 4; + +// array +let arr = []; + ~~~ [let % ('arr')] +arr.push(0); +arr[1] = 1; +arr.length = 1; + +// reassignment of the forward declaration +function useOfForwardDecl() { + forwardDecl = 1; +} + +let forwardDecl: number; + +module E { + let x = 1; + ~ [let % ('x')] +} + +switch (1) { + case 1: + let x = 1; + ~ [let % ('x')] + break; + case 2: + let y = 1; + ~ [let % ('y')] + break; +} + +var someVariable = 0; + ~~~~~~~~~~~~ [var % ('someVariable')] +function funcxion(someVariable, someParameter) { + someVariable = 1; + { + var var1 = 0; + var var2 = 0; + ~~~~ [var % ('var2')] + } + { + var1 = 1; + } + { + let var2 = 1; + var2 = 2; + } +} + +let shadowed1 = 0; + ~~~~~~~~~ [let % ('shadowed1')] +let shadowed2 = 0; + ~~~~~~~~~ [let % ('shadowed2')] +let shadowed3 = 0; + ~~~~~~~~~ [let % ('shadowed3')] +function shadowVariables({shadowed1, ...shadowed2}, shadowed3) { + shadowed1 = 1; + shadowed2 = 1; + shadowed3 = 1; +} + +// no error in for loop initializer +for (let i = 1, l = arr.length; i < l; ++i) { +} + +{ + let var1 = 0; + ~~~~ [let % ('var1')] + let var2 = 0; + function foo(var1 = var2 = 1, var2 = var1 = 1) {} + function foo2(p1 = var2 = 1) { + let var2 = 0; + ~~~~ [let % ('var2')] + } +} + +// cannot fix, because of uninitialized variables +let uninitialized; + ~~~~~~~~~~~~~ [let % ('uninitialized')] +let initialized1 = 0, uninitialized2; + ~~~~~~~~~~~~ [let % ('initialized1')] + ~~~~~~~~~~~~~~ [let % ('uninitialized2')] + +// ambient declarations are not checked +declare let ambient = 0; + +declare namespace ambient { + let foo = 0; +} + +{ + let someVar: string; + for (someVar in someObj) {} +} +{ + let someVar: string; + for (someVar of someArr) {} +} +{ + let someVar: string, someVar2: string; + for ({someVar, foo: someVar2} of someArr) {} +} +{ + let someVar: string, someObj: any; + ~~~~~~~ [let % ('someVar')] + ~~~~~~~ [let % ('someObj')] + for ({someVar: someObj.val} of someArr) {} +} +for (let [var1, var2] of someArr) { + var1 = null; +} +for (let [var1, var2] of someArr) {} + ~~~~ [let % ('var1')] + ~~~~ [let % ('var2')] +for (let {var1, var2} of someArr) { + var2 = null; +} + +{ + let k: any = 0; + function foo(param: {[k: string]: string}) { + k = param; + } +} + +[_base]: Identifier '%%s' is never reassigned; use 'const' instead of '%s'. +[let]: _base % ('let') +[var]: _base % ('var') diff --git a/test/rules/prefer-const/default/tslint.json b/test/rules/prefer-const/default/tslint.json new file mode 100644 index 00000000000..369865b3ae9 --- /dev/null +++ b/test/rules/prefer-const/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-const": true + } +} diff --git a/test/rules/prefer-const/destructuring-all/test.ts.fix b/test/rules/prefer-const/destructuring-all/test.ts.fix new file mode 100644 index 00000000000..f89ce0a5ba3 --- /dev/null +++ b/test/rules/prefer-const/destructuring-all/test.ts.fix @@ -0,0 +1,28 @@ +export let foo = 1; +// destructuring +{ + let destructLater = 4; + [destructLater] = 5; + let a: number; + let b: number; + let c: any; + ({ eh: a, b, ...c } = { eh: 0, b: 1 }); +} + +let {h, i} = {h: 1, i: 1}; // 'h' can be const +let [j, k] = [1, 1]; // 'j' can be const +let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 +let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // 'r' can be const +i = 2; +k = 2; +q = 4; +x2 = 5; + +for (let {o, p} of [{1, 1}, {1, 1}]) { // 'o' can be const + console.log(o); + p = 2; +} + +{ + const [d1, d2] = []; +} diff --git a/test/rules/prefer-const/destructuring-all/test.ts.lint b/test/rules/prefer-const/destructuring-all/test.ts.lint new file mode 100644 index 00000000000..e0144287017 --- /dev/null +++ b/test/rules/prefer-const/destructuring-all/test.ts.lint @@ -0,0 +1,34 @@ +export let foo = 1; +// destructuring +{ + let destructLater = 4; + [destructLater] = 5; + let a: number; + let b: number; + let c: any; + ({ eh: a, b, ...c } = { eh: 0, b: 1 }); +} + +let {h, i} = {h: 1, i: 1}; // 'h' can be const +let [j, k] = [1, 1]; // 'j' can be const +let [x1, x3] = [1, 2], [x2] = [3]; // failure for x1, x3 + ~~ [let % ('x1')] + ~~ [let % ('x3')] +let {a: {b: {q}, c: {r}}} = { a: { b: { q: 3 }, c: { r: 2 } } }; // 'r' can be const +i = 2; +k = 2; +q = 4; +x2 = 5; + +for (let {o, p} of [{1, 1}, {1, 1}]) { // 'o' can be const + console.log(o); + p = 2; +} + +{ + let [d1, d2] = []; + ~~ [let % ('d1')] + ~~ [let % ('d2')] +} + +[let]: Identifier '%s' is never reassigned; use 'const' instead of 'let'. \ No newline at end of file diff --git a/test/rules/prefer-const/destructuring-all/tslint.json b/test/rules/prefer-const/destructuring-all/tslint.json new file mode 100644 index 00000000000..10b347a8c1c --- /dev/null +++ b/test/rules/prefer-const/destructuring-all/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "prefer-const": [ + true, + {"destructuring": "all"} + ] + } +} diff --git a/test/rules/prefer-for-of/test.ts.lint b/test/rules/prefer-for-of/test.ts.lint new file mode 100644 index 00000000000..8338a67fdb9 --- /dev/null +++ b/test/rules/prefer-for-of/test.ts.lint @@ -0,0 +1,197 @@ +// should not flag (#2159) +const columns = [{ data: [1] }]; +for (let i = 0; i < columns[0].data.length; i++) { + columns.map((x) => x.data[i]); +} + +function sampleFunc() { + // issue #1931, should not error + const value1 = [1]; + const value2 = [2]; + for (let i = 0; i < (value1).length; i++) { + const x = (value1)[i] === (value2)[i]; + } + + // This loop only uses the iterator to access the array item, so we can recommend a for-of loop here + for (var a = 0; a < obj.arr.length; a++) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + console.log(obj.arr[a]); + } + + // Same as above, but no curly braces + for (var b = 0; b < obj.arr.length; b++) console.log(obj.arr[b]); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + // the index is used by itself, so a normal for loop is allowed here + for (var c = 0; c < arr.length; c++) { + doMath(c); + } + + // Same as above, but no curly braces + for (var d = 0; d < arr.length; d++) doMath(d); + + // the index is used by itself, so a normal for loop is allowed here + for (var e = 0; e < arr.length; e++) { + if(e > 5) { + doMath(e); + } + console.log(arr[e]); + } + + // This iterates off of a hard-coded number and should be allowed + for (var f = 0; f <= 40; f++) { + doMath(f); + } + + // Same as above, but no curly braces + for (var g = 0; g <= 40; g++) doMath(g); + + // multiple operations in the initializer + for(var h=0, len=arr.length; h < len; h++) {} + + // Same as above, but no curly braces + for(var i=0, len=arr.length; i < len; i++) arr[i]; + + // Odd for loop setups + var m = 0; + for (;;) { + if (m > 3) break; + console.log(m); + m++; + } + + var n = 0; + for (; n < 9; n++) { + console.log(n); + } + + var o = 0; + for (; o < arr.length; o++) { + console.log(arr[o]); + } + + // Prefix incrementor + for(let p = 0; p < arr.length; ++p) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + arr[p].whatever(); + } + + // empty + for(let x = 0; x < arr.length; x++) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + // missing + for(; x < arr.length; x++) {} + for(let x = 0;; x++) {} + for(let x = 0; x < arr.length;) {} + + // mismatch + for(let x = 0; NOTX < arr.length; x++) {} + for(let x = 0; x < arr.length; NOTX++) {} + for(let NOTX = 0; x < arr.length; x++) {} + + // decrement + for(let x = 0; x < arr.length; x--) {} + + // not `<` + for(let x = 0; x <= arr.length; x++) {} + + // wrong starting point + for(let x = 1; x < arr.length; x++) {} + + // not `length` property + for(let x = 0; x < arr.length(); x++) {} + + // alternate incrementor + for(let x = 0; x < arr.length; x+=1) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + for(let x = 0; x < arr.length; x=x+1) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + for(let x = 0; x < arr.length; x=1+x) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + + // adds too much + for(let x = 0; x < arr.length; x+=11) {} + for(let x = 0; x < arr.length; x=x+11) {} + + for(let x = 0; x < arr.length; x++) { + x++; + } + + // unexpected condition + for(let x = 0; true; x++) {} + + // For-in loops ARE allowed + for (var q in obj) { + if (obj.hasOwnProperty(q)) { + console.log(q); + } + } + + // For-of loops ARE allowed + for (var r of arr) { + console.log(r); + } + + // array element is assigned a new value + for (let x = 0; x < arr.length; x++) { + arr[x] = 4; + } + + // access element other than current + for (let x = 0; x < arr.length; x++) { + let y = arr[x + 1]; + } +} + +for (let shadow = 0; shadow < arr.length; shadow++) { +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + for (let shadow = 0; shadow < arr.length; shadow++) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + } +} + +for (let i = 0; i < arr.length; i++) { + delete arr[i]; +} + +for (let i = 0; i < arr.length; ++i) { +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + { + let i = 1; + let x = i; + let obj = {i, x}; + } + i: while(true) { + let obj = {i: 1}; + break i; + } + + let node = arr[i]; +} + +function test() { + function print() { + console.log(arr[i]) + } + for (var i = 0, i < arr.length, ++i) + print(); +} + +for (let i = 0; i < arr.length; ++i) { + arr[i]++; +} + +for (let i = 0; i < arr.length; ++i) { + ({...arr[i]} = foo); +} + +for (let i = 0; i < arr.length; ++i) { + for (arr[i] of otherArr) {} +} + +for (let i = 0; i < arr.length; ++i) { + ++(arr[i]); +} + +[0]: Expected a 'for-of' loop instead of a 'for' loop with this simple iteration diff --git a/test/rules/prefer-for-of/tslint.json b/test/rules/prefer-for-of/tslint.json new file mode 100644 index 00000000000..a7d6263e98a --- /dev/null +++ b/test/rules/prefer-for-of/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-for-of": true + } +} diff --git a/test/rules/prefer-function-over-method/allow-protected/test.ts.lint b/test/rules/prefer-function-over-method/allow-protected/test.ts.lint new file mode 100644 index 00000000000..880413a27ec --- /dev/null +++ b/test/rules/prefer-function-over-method/allow-protected/test.ts.lint @@ -0,0 +1,9 @@ +class C { + a() {} + ~ [0] + protected b() {} + private c() {} + ~ [0] +} + +[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/allow-protected/tslint.json b/test/rules/prefer-function-over-method/allow-protected/tslint.json new file mode 100644 index 00000000000..c5c1ff87b7e --- /dev/null +++ b/test/rules/prefer-function-over-method/allow-protected/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-function-over-method": [true, "allow-protected"] + } +} diff --git a/test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint b/test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint new file mode 100644 index 00000000000..bef8ec11b35 --- /dev/null +++ b/test/rules/prefer-function-over-method/allow-public-and-protected/test.ts.lint @@ -0,0 +1,8 @@ +class C { + a() {} + protected b() {} + private c() {} + ~ [0] +} + +[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json b/test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json new file mode 100644 index 00000000000..c60d1b2b86e --- /dev/null +++ b/test/rules/prefer-function-over-method/allow-public-and-protected/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-function-over-method": [true, "allow-public", "allow-protected"] + } +} diff --git a/test/rules/prefer-function-over-method/allow-public/test.ts.lint b/test/rules/prefer-function-over-method/allow-public/test.ts.lint new file mode 100644 index 00000000000..9781d94bf63 --- /dev/null +++ b/test/rules/prefer-function-over-method/allow-public/test.ts.lint @@ -0,0 +1,9 @@ +class C { + a() {} + protected b() {} + ~ [0] + private c() {} + ~ [0] +} + +[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/allow-public/tslint.json b/test/rules/prefer-function-over-method/allow-public/tslint.json new file mode 100644 index 00000000000..3b9071c84a8 --- /dev/null +++ b/test/rules/prefer-function-over-method/allow-public/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-function-over-method": [true, "allow-public"] + } +} diff --git a/test/rules/prefer-function-over-method/default/test.ts.lint b/test/rules/prefer-function-over-method/default/test.ts.lint new file mode 100644 index 00000000000..3001e60be6a --- /dev/null +++ b/test/rules/prefer-function-over-method/default/test.ts.lint @@ -0,0 +1,66 @@ +class C { + static s() {} + + plain() {} + ~~~~~ [0] + + thisInFunction() { + ~~~~~~~~~~~~~~ [0] + function() { + this; + } + } + + thisInObjectMethod() { + ~~~~~~~~~~~~~~~~~~ [0] + return { x() { this; } } + } + + recur() { + ~~~~~ [0] + this.recur(); + } + + thisInParameter(this: string) {} + ~~~~~~~~~~~~~~~ [0] + + thisInParameterDefault(x = this) {} + + thisUsed() { + this; + } + + super() { + super; + } + + protected protected() {} + ~~~~~~~~~ [0] + + private private() {} + ~~~~~~~ [0] + + [Symbol.iterator]() {} + ~~~~~~~~~~~~~~~~~ [0] + + thisType(foo: this): this { + ~~~~~~~~ [0] + return foo; + } + + overload(): void; + overload(foo): void; + overload(foo?): void { + return this; + } +} + +abstract class C2 { + abstract abstract(): void; +} + +const o = { + x() {} +} + +[0]: Class method does not use 'this'. Use a function instead. diff --git a/test/rules/prefer-function-over-method/default/tslint.json b/test/rules/prefer-function-over-method/default/tslint.json new file mode 100644 index 00000000000..eabdb99d86a --- /dev/null +++ b/test/rules/prefer-function-over-method/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-function-over-method": true + } +} diff --git a/test/rules/prefer-method-signature/test.ts.fix b/test/rules/prefer-method-signature/test.ts.fix new file mode 100644 index 00000000000..ceb3f0ad236 --- /dev/null +++ b/test/rules/prefer-method-signature/test.ts.fix @@ -0,0 +1,18 @@ +interface I { + foo(): void; + bar(): T; +} + +type T = { + foo?(): void; +} + +class C { + // OK in class + foo: () => void; +} + +export interface Bar { + someMethod(someArg: Pick): string; +} + diff --git a/test/rules/prefer-method-signature/test.ts.lint b/test/rules/prefer-method-signature/test.ts.lint new file mode 100644 index 00000000000..4cea96b42b0 --- /dev/null +++ b/test/rules/prefer-method-signature/test.ts.lint @@ -0,0 +1,25 @@ +interface I { + foo: () => void; + ~~~ [0] + bar: () => T; + ~~~ [0] +} + +type T = { + foo?: () => void; + ~~~ [0] +} + +class C { + // OK in class + foo: () => void; +} + +export interface Bar { + someMethod: ( + ~~~~~~~~~~ [0] + someArg: Pick + ) => string; +} + +[0]: Use a method signature instead of a property signature of function type. diff --git a/test/rules/prefer-method-signature/tslint.json b/test/rules/prefer-method-signature/tslint.json new file mode 100644 index 00000000000..ca95816c0f3 --- /dev/null +++ b/test/rules/prefer-method-signature/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-method-signature": true + } +} diff --git a/test/rules/prefer-object-spread/test.ts.fix b/test/rules/prefer-object-spread/test.ts.fix new file mode 100644 index 00000000000..6ab5c8e3b99 --- /dev/null +++ b/test/rules/prefer-object-spread/test.ts.fix @@ -0,0 +1,30 @@ +const form = Object.assign({}, this); +const foo = Object.assign(bar, this); +const foo = Object.assign({}, bar, baz, this); +const original = {a: 1, b:2}; +{...original, c: 3}; +{a: 1, b: 2, c: 3}; +Object.assign({a:1}, ...[{b: 2}, {c: 3}]) +Object.assign(original, {c: 3}); +var result = {...original, c: 3}; +result = {...original, c: 3}; +var result = {...original, c: 3}; +foo({...original, c: 3}); +[{...original, c: 3}]; +({ + foo: {...original, c: 3} +}) + +{a: 1,}; +{a: 1, ...(foo ? {b: 2} : {c: 3})}; +{a: 1, ...{b: 2}}; +{}; +{}; + +// allowed +result = Object.assign(new Foo(), {}); +result = Object.assign(createFoo(), {}); +result = Object.assign(function() {}, {}); +result = Object.assign(() => {}, {}); + +let fn = () => ({...original}); diff --git a/test/rules/prefer-object-spread/test.ts.lint b/test/rules/prefer-object-spread/test.ts.lint new file mode 100644 index 00000000000..298394f2afa --- /dev/null +++ b/test/rules/prefer-object-spread/test.ts.lint @@ -0,0 +1,46 @@ +const form = Object.assign({}, this); +const foo = Object.assign(bar, this); +const foo = Object.assign({}, bar, baz, this); +const original = {a: 1, b:2}; +Object.assign({}, original, {c: 3}); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Object.assign({a: 1, b: 2}, {c: 3}); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Object.assign({a:1}, ...[{b: 2}, {c: 3}]) +Object.assign(original, {c: 3}); +var result = Object.assign(original, {c: 3}); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] +result = Object.assign(original, {c: 3}); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] +var result = Object.assign({}, original, {c: 3}); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +foo(Object.assign(original, {c: 3})); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] +[Object.assign(original, {c: 3})]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] +({ + foo: Object.assign(original, {c: 3}) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] +}) + +Object.assign({}, {}, {a: 1,},); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Object.assign({a: 1}, foo ? {b: 2} : {c: 3}); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Object.assign({a: 1, ...{b: 2}}); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +Object.assign({}, {}); +~~~~~~~~~~~~~~~~~~~~~ [0] +Object.assign({}, {},); +~~~~~~~~~~~~~~~~~~~~~~ [0] + +// allowed +result = Object.assign(new Foo(), {}); +result = Object.assign(createFoo(), {}); +result = Object.assign(function() {}, {}); +result = Object.assign(() => {}, {}); + +let fn = () => Object.assign({}, original); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +[0]: Use the object spread operator instead. +[1]: 'Object.assign' returns the first argument. Prefer object spread if you want a new object. diff --git a/test/rules/prefer-object-spread/tslint.json b/test/rules/prefer-object-spread/tslint.json new file mode 100644 index 00000000000..43b88cfa0d5 --- /dev/null +++ b/test/rules/prefer-object-spread/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-object-spread": true + } +} \ No newline at end of file diff --git a/test/rules/prefer-readonly/default/test.ts.fix b/test/rules/prefer-readonly/default/test.ts.fix new file mode 100644 index 00000000000..49b701351a9 --- /dev/null +++ b/test/rules/prefer-readonly/default/test.ts.fix @@ -0,0 +1,155 @@ +class SampleClass { + private static readonly correctlyReadonlyStatic = 7; + + private static readonly incorrectlyModifiableStatic = 7; + + private static readonly incorrectlyModifiableStaticArrow = () => {}; + + private static correctlyModifiableStatic = 7; + + private static correctlyModifiableByParameterProperty = 7; + + private readonly correctlyReadonlyInline = 7; + + private readonly correctlyReadonlyDelayed; + + private readonly incorrectlyModifiableInline = 7; + + private readonly incorrectlyModifiableDelayed; + + private correctlyModifiableInline = 7; + + private correctlyModifiableDelayed; + + private correctlyModifiableDeleted = 7; + + private readonly childClassExpressionModifiable = 7; + + private correctlyModifiableWithinConstructor; + + private correctlyModifiableWithinConstructorInArrowFunction; + + private correctlyModifiableWithinConstructorInFunctionExpression; + + private correctlyModifiableWithinConstructorInGetAccessor; + + private correctlyModifiableWithinConstructorInMethodDeclaration; + + private correctlyModifiableWithinConstructorInSetAccessor; + + private correctlyModifiablePostDecremented; + + private correctlyModifiablePostIncremented; + + private readonly incorrectlyModifiablePostMinus; + + private readonly incorrectlyModifiablePostPlus; + + private correctlyModifiablePreDecremented; + + private correctlyModifiablePreIncremented; + + private readonly incorrectlyModifiablePreMinus; + + private readonly incorrectlyModifiablePrePlus; + + private readonly overlappingClassVariable = 7; + + protected protectedModifiable = 7; + + protected publicModifiable = 7; + + public constructor( + private readonly correctlyReadonlyParameter: number = 7, + private readonly incorrectlyModifiableParameter: number = 7, + private correctlyModifiableParameter: number = 7, + public correctlyModifiablePublicParameter: number = (() => { + return SampleClass.correctlyModifiableByParameterProperty = 7; + })(); + ) { + this.correctlyReadonlyDelayed = 7; + this.incorrectlyModifiableDelayed = 7; + this.incorrectlyModifiableParameter = 7; + + (() => { + const self = this; + + this.correctlyModifiableWithinConstructor = 7; + + (() => { + this.correctlyModifiableWithinConstructorInArrowFunction = 7; + })(); + + (function () { + self.correctlyModifiableWithinConstructorInFunctionExpression = 7; + })(); + + const confusingObject = { + get getAccessor() { + return self.correctlyModifiableWithinConstructorInGetAccessor = 7; + } + + methodDeclaration() { + self.correctlyModifiableWithinConstructorInMethodDeclaration = 7; + } + + set setAccessor() { + self.correctlyModifiableWithinConstructorInSetAccessor = 7; + } + }; + })(); + + SampleClass.correctlyModifiableStatic += 1; + } + + public mutate() { + this.correctlyModifiableDelayed = 7; + this.correctlyModifiableInline = 7; + this.correctlyModifiableMember = () => {}; + this.correctlyModifiableParameter = 7; + + delete this.correctlyModifiableDeleted; + + this.correctlyModifiablePostDecremented--; + this.correctlyModifiablePostIncremented++; + this.incorrectlyModifiablePostMinus+; + this.incorrectlyModifiablePostPlus+; + --this.correctlyModifiablePreDecremented; + ++this.correctlyModifiablePreIncremented; + -this.incorrectlyModifiablePreMinus; + +this.incorrectlyModifiablePrePlus; + } + + public createConfusingChildClass() { + return class { + private correctlyModifiableInline = 7; + + private readonly incorrectlyModifiableInline = 7; + + private readonly incorrectlyUniqueModifiableInline = 7; + + private childClassExpressionModifiable = 7; + + mutate() { + this.correctlyModifiableInline = 7; + this.childClassExpressionModifiable = 7; + } + } + } + + public workWithSimilarClass(other: SimilarClass) { + other.overlappingClassVariable = 7; + } + + private readonly incorrectlyModifiableMember = () => { }; + + private correctlyModifiableMember = () => { }; +} + +class SimilarClass { + public overlappingClassVariable = 7; +} + +declare class DeclaredClass { + private declaredMember = 7; +} diff --git a/test/rules/prefer-readonly/default/test.ts.lint b/test/rules/prefer-readonly/default/test.ts.lint new file mode 100644 index 00000000000..dd02f62316e --- /dev/null +++ b/test/rules/prefer-readonly/default/test.ts.lint @@ -0,0 +1,169 @@ +class SampleClass { + private static readonly correctlyReadonlyStatic = 7; + + private static incorrectlyModifiableStatic = 7; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private static variable 'incorrectlyModifiableStatic' is never reassigned; mark it as 'readonly'.] + + private static incorrectlyModifiableStaticArrow = () => {}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private static variable 'incorrectlyModifiableStaticArrow' is never reassigned; mark it as 'readonly'.] + + private static correctlyModifiableStatic = 7; + + private static correctlyModifiableByParameterProperty = 7; + + private readonly correctlyReadonlyInline = 7; + + private readonly correctlyReadonlyDelayed; + + private incorrectlyModifiableInline = 7; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableInline' is never reassigned; mark it as 'readonly'.] + + private incorrectlyModifiableDelayed; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableDelayed' is never reassigned; mark it as 'readonly'.] + + private correctlyModifiableInline = 7; + + private correctlyModifiableDelayed; + + private correctlyModifiableDeleted = 7; + + private childClassExpressionModifiable = 7; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'childClassExpressionModifiable' is never reassigned; mark it as 'readonly'.] + + private correctlyModifiableWithinConstructor; + + private correctlyModifiableWithinConstructorInArrowFunction; + + private correctlyModifiableWithinConstructorInFunctionExpression; + + private correctlyModifiableWithinConstructorInGetAccessor; + + private correctlyModifiableWithinConstructorInMethodDeclaration; + + private correctlyModifiableWithinConstructorInSetAccessor; + + private correctlyModifiablePostDecremented; + + private correctlyModifiablePostIncremented; + + private incorrectlyModifiablePostMinus; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePostMinus' is never reassigned; mark it as 'readonly'.] + + private incorrectlyModifiablePostPlus; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePostPlus' is never reassigned; mark it as 'readonly'.] + + private correctlyModifiablePreDecremented; + + private correctlyModifiablePreIncremented; + + private incorrectlyModifiablePreMinus; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePreMinus' is never reassigned; mark it as 'readonly'.] + + private incorrectlyModifiablePrePlus; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiablePrePlus' is never reassigned; mark it as 'readonly'.] + + private overlappingClassVariable = 7; + ~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'overlappingClassVariable' is never reassigned; mark it as 'readonly'.] + + protected protectedModifiable = 7; + + protected publicModifiable = 7; + + public constructor( + private readonly correctlyReadonlyParameter: number = 7, + private incorrectlyModifiableParameter: number = 7, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableParameter' is never reassigned; mark it as 'readonly'.] + private correctlyModifiableParameter: number = 7, + public correctlyModifiablePublicParameter: number = (() => { + return SampleClass.correctlyModifiableByParameterProperty = 7; + })(); + ) { + this.correctlyReadonlyDelayed = 7; + this.incorrectlyModifiableDelayed = 7; + this.incorrectlyModifiableParameter = 7; + + (() => { + const self = this; + + this.correctlyModifiableWithinConstructor = 7; + + (() => { + this.correctlyModifiableWithinConstructorInArrowFunction = 7; + })(); + + (function () { + self.correctlyModifiableWithinConstructorInFunctionExpression = 7; + })(); + + const confusingObject = { + get getAccessor() { + return self.correctlyModifiableWithinConstructorInGetAccessor = 7; + } + + methodDeclaration() { + self.correctlyModifiableWithinConstructorInMethodDeclaration = 7; + } + + set setAccessor() { + self.correctlyModifiableWithinConstructorInSetAccessor = 7; + } + }; + })(); + + SampleClass.correctlyModifiableStatic += 1; + } + + public mutate() { + this.correctlyModifiableDelayed = 7; + this.correctlyModifiableInline = 7; + this.correctlyModifiableMember = () => {}; + this.correctlyModifiableParameter = 7; + + delete this.correctlyModifiableDeleted; + + this.correctlyModifiablePostDecremented--; + this.correctlyModifiablePostIncremented++; + this.incorrectlyModifiablePostMinus+; + this.incorrectlyModifiablePostPlus+; + --this.correctlyModifiablePreDecremented; + ++this.correctlyModifiablePreIncremented; + -this.incorrectlyModifiablePreMinus; + +this.incorrectlyModifiablePrePlus; + } + + public createConfusingChildClass() { + return class { + private correctlyModifiableInline = 7; + + private incorrectlyModifiableInline = 7; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableInline' is never reassigned; mark it as 'readonly'.] + + private incorrectlyUniqueModifiableInline = 7; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyUniqueModifiableInline' is never reassigned; mark it as 'readonly'.] + + private childClassExpressionModifiable = 7; + + mutate() { + this.correctlyModifiableInline = 7; + this.childClassExpressionModifiable = 7; + } + } + } + + public workWithSimilarClass(other: SimilarClass) { + other.overlappingClassVariable = 7; + } + + private incorrectlyModifiableMember = () => { }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableMember' is never reassigned; mark it as 'readonly'.] + + private correctlyModifiableMember = () => { }; +} + +class SimilarClass { + public overlappingClassVariable = 7; +} + +declare class DeclaredClass { + private declaredMember = 7; +} diff --git a/test/rules/prefer-readonly/default/tsconfig.json b/test/rules/prefer-readonly/default/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/prefer-readonly/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/prefer-readonly/default/tslint.json b/test/rules/prefer-readonly/default/tslint.json new file mode 100644 index 00000000000..4eabc221064 --- /dev/null +++ b/test/rules/prefer-readonly/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-readonly": true + } +} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix b/test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix new file mode 100644 index 00000000000..c3a23eddf40 --- /dev/null +++ b/test/rules/prefer-readonly/only-inline-lambdas/test.ts.fix @@ -0,0 +1,28 @@ +class SampleClass { + private readonly correctlyReadonlyDelayedArrow: () => void; + + private readonly correctlyReadonlyInlineArrow = () => {} + + private readonly correctlyReadonlyValue = 7; + + private correctlyModifiableDelayedArrow: () => void; + + private incorrectlyModifiableDelayedArrow: () => void; + + private readonly incorrectlyModifiableInlineArrow = () => {} + + private correctlyModifiableInlineArrow = () => {} + + private correctlyModifiableValue = 7; + + public constructor() { + this.correctlyModifiableDelayedArrow = () => {}; + this.incorrectlyModifiableDelayedArrow = () => {}; + } + + public mutate() { + this.correctlyModifiableDelayedArrow = () => {}; + this.correctlyModifiableInlineArrow = () => {}; + this.correctlyModifiableValue += 1; + } +} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint b/test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint new file mode 100644 index 00000000000..344109ae72c --- /dev/null +++ b/test/rules/prefer-readonly/only-inline-lambdas/test.ts.lint @@ -0,0 +1,29 @@ +class SampleClass { + private readonly correctlyReadonlyDelayedArrow: () => void; + + private readonly correctlyReadonlyInlineArrow = () => {} + + private readonly correctlyReadonlyValue = 7; + + private correctlyModifiableDelayedArrow: () => void; + + private incorrectlyModifiableDelayedArrow: () => void; + + private incorrectlyModifiableInlineArrow = () => {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Private member variable 'incorrectlyModifiableInlineArrow' is never reassigned; mark it as 'readonly'.] + + private correctlyModifiableInlineArrow = () => {} + + private correctlyModifiableValue = 7; + + public constructor() { + this.correctlyModifiableDelayedArrow = () => {}; + this.incorrectlyModifiableDelayedArrow = () => {}; + } + + public mutate() { + this.correctlyModifiableDelayedArrow = () => {}; + this.correctlyModifiableInlineArrow = () => {}; + this.correctlyModifiableValue += 1; + } +} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json b/test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/prefer-readonly/only-inline-lambdas/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/prefer-readonly/only-inline-lambdas/tslint.json b/test/rules/prefer-readonly/only-inline-lambdas/tslint.json new file mode 100644 index 00000000000..2ac8a95230e --- /dev/null +++ b/test/rules/prefer-readonly/only-inline-lambdas/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-readonly": [true, "only-inline-lambdas"] + } +} diff --git a/test/rules/prefer-switch/default/test.ts.lint b/test/rules/prefer-switch/default/test.ts.lint new file mode 100644 index 00000000000..b8d2bd2f44e --- /dev/null +++ b/test/rules/prefer-switch/default/test.ts.lint @@ -0,0 +1,79 @@ +if (x === 1 || x === 2) {} + +if (x === 1 || x === 2 || x === 3) {} + +if (x === 1 || x === 2 || x === 3) {} + +if (x === 1 || x === 2 || x === -3) {} + +if (x === 1 || x === 2 || x === null) {} + +if (x === 1 || x === 2 || x === true) {} + +if (x === 1 || x === 2 || x === false) {} + +if (x === 1 || x === 2 || x === `123`) {} + +if (x === 1 || x === 2 && x === `123`) {} + +if (x === 1) {} + ~~~~~~~ [0] +else if (x === 2) {} +else if (x === 3) {} + +if (x === 1) {} + ~~~~~~~ [0] +else if (x === 2) {} +else if (x === 3) {} +else {} + +if (x === 1 || x === 2) {} + ~~~~~~~~~~~~~~~~~~ [0] +else if (x === 3) {} + +if (x === 1 || x === 2) {} +else {} + +if (x === 1 || x === 2 || && x === 3) {} +else if (x === 4) {} +else if (x === 5) {} +else {} + +if (x === 1 && x === 2) {} +else if (x === 3) {} +else if (x === 4) {} + +if (x === 1 && x === 2) {} +else if (x === 3) {} +else if (x === 4) {} +else {} + + +if (x === 1 || y === 2) {} +else if (x === 3) {} +else if (x === 4) {} +else {} + + +if (x === 1 && y === 2) {} +else if (x === 3) {} +else if (x === 4 && x === 5) {} +else {} + +if (x === 1 && y === 2) {} +else if (x === 3) {} +else if (x === 4 && x === 5) {} + +export enum ItemType { + FIRST = "FIRST", + SECOND = "SECOND", + THIRD = "THIRD", +} + +if ( + item.type === ItemType.FIRST || + item.type === ItemType.SECOND || + item.type === ItemType.THIRD +) {} + +[0]: Use a switch statement instead of using multiple '===' checks. diff --git a/test/rules/prefer-switch/default/tslint.json b/test/rules/prefer-switch/default/tslint.json new file mode 100644 index 00000000000..82d257e645d --- /dev/null +++ b/test/rules/prefer-switch/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-switch": true + } +} diff --git a/test/rules/prefer-switch/min-cases-2/test.ts.lint b/test/rules/prefer-switch/min-cases-2/test.ts.lint new file mode 100644 index 00000000000..f7ae69c9967 --- /dev/null +++ b/test/rules/prefer-switch/min-cases-2/test.ts.lint @@ -0,0 +1,52 @@ +if (x === 1) {} + ~~~~~~~ [0] +else if (x === 2) {} // Notice that we don't get *another* error here. +// Dangling `else` OK (this becomes `default:`) +else if (x === 3) {} +else {} + +if (x === 1) {} else if (x === 2) {} + ~~~~~~~ [0] + +// Works with `||` +if (this === 1 || this === 2) {} + +if (this === 1 || this === 2 || this === 3) {} + + +if (x === 1) {} + ~~~~~~~ [0] +else if (x === 2) {} +else if (x === 3) {} + +if (x === 1) {} + ~~~~~~~ [0] +else if (x === 2) {} + + +// Default minumum of 2 cases. +if (x === 1) {} else {} + +// Different variables, no failure +if (x === 1) {} else if (y === 2) {} + +// Non-simple cases, no failure +if (x === f()) {} else if (x === g()) {} + +// Allow properties +if (x.y.z === a.b) else if (x.y.z === c.d) {} + ~~~~~~~~~~~~~ [0] + +export enum ItemType { + FIRST = "FIRST", + SECOND = "SECOND", + THIRD = "THIRD", +} + +if ( + item.type === ItemType.FIRST || + item.type === ItemType.SECOND || + item.type === ItemType.THIRD +) {} + +[0]: Use a switch statement instead of using multiple '===' checks. diff --git a/test/rules/prefer-switch/min-cases-2/tslint.json b/test/rules/prefer-switch/min-cases-2/tslint.json new file mode 100644 index 00000000000..e776dd404f0 --- /dev/null +++ b/test/rules/prefer-switch/min-cases-2/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "prefer-switch": [true, { + "min-cases": 2 + }] + } +} diff --git a/test/rules/prefer-template/allow-single-concat/test.ts.lint b/test/rules/prefer-template/allow-single-concat/test.ts.lint new file mode 100644 index 00000000000..205068dd80d --- /dev/null +++ b/test/rules/prefer-template/allow-single-concat/test.ts.lint @@ -0,0 +1,37 @@ +"a" + x; +x + "a"; + +"a" + x + "b"; +~~~~~~~~~~~~~ [0] + +x + "a" + y; +~~~~~~~~~~~ [0] + +"a" + x + y; +~~~~~~~~~~~ [0] + +"a" + x + "b" + y + "c"; +~~~~~~~~~~~~~~~~~~~~~~~ [0] + +`a` + x + `b${y}c`; +~~~~~~~~~~~~~~~~~~ [0] + +"a" + "b" + "c"; + +x`a` + y; // OK, can't simplify something with a tag + +"a" + "b"; // OK to concatenate regular strings. + +"a\n" + "b"; +~~~~~~~~~~~ [1] + +"a" + "\nb"; +~~~~~~~~~~~ [1] + +1 + 1; +1 + 1 + "a"; +~~~~~~~~~~~ [0] +x + y; + +[0]: Use a template literal instead of concatenating with a string literal. +[1]: Use a multiline template literal instead of concatenating string literals with newlines. diff --git a/test/rules/prefer-template/allow-single-concat/tslint.json b/test/rules/prefer-template/allow-single-concat/tslint.json new file mode 100644 index 00000000000..96d0735c320 --- /dev/null +++ b/test/rules/prefer-template/allow-single-concat/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-template": [true, "allow-single-concat"] + } +} \ No newline at end of file diff --git a/test/rules/prefer-template/default/test.ts.lint b/test/rules/prefer-template/default/test.ts.lint new file mode 100644 index 00000000000..430f5e455f2 --- /dev/null +++ b/test/rules/prefer-template/default/test.ts.lint @@ -0,0 +1,39 @@ +"a" + x; +~~~~~~~ [0] +x + "a"; +~~~~~~~ [0] + +"a" + x + "b"; +~~~~~~~~~~~~~ [0] + +x + "a" + y; +~~~~~~~~~~~ [0] + +"a" + x + y; +~~~~~~~~~~~ [0] + +"a" + x + "b" + y + "c"; +~~~~~~~~~~~~~~~~~~~~~~~ [0] + +`a` + x + `b${y}c`; +~~~~~~~~~~~~~~~~~~ [0] + +"a" + "b" + "c"; + +x`a` + y; // OK, can't simplify something with a tag + +"a" + "b"; // OK to concatenate strings without newlines. + +"a\n" + "b"; +~~~~~~~~~~~ [1] + +"a" + "\nb"; +~~~~~~~~~~~ [1] + +1 + 1; +1 + 1 + "a"; +~~~~~~~~~~~ [0] +x + y; + +[0]: Use a template literal instead of concatenating with a string literal. +[1]: Use a multiline template literal instead of concatenating string literals with newlines. diff --git a/test/rules/prefer-template/default/tslint.json b/test/rules/prefer-template/default/tslint.json new file mode 100644 index 00000000000..1b743e18ad9 --- /dev/null +++ b/test/rules/prefer-template/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-template": [true] + } +} \ No newline at end of file diff --git a/test/rules/prefer-while/test.ts.fix b/test/rules/prefer-while/test.ts.fix new file mode 100644 index 00000000000..248cc3cc822 --- /dev/null +++ b/test/rules/prefer-while/test.ts.fix @@ -0,0 +1,24 @@ +// for loops without an initializer, termination condition, and incrementor should be updated +while (true) { + console.log('Hello World'); +} + +// for loops without an initializer and incrementor should be updated +while (true===true) { + console.log('Hello World'); +} + +// for loops with an initializer, termination condition, and incrementor using '++' should remain untouched +for (let i = 1; i < 10; i++) { + console.log(i); +} + +// for loops with an initializer, termination condition, and incrementor using '+=' should remain untouched +for (let i = 0; i < 10; i+=1) { + console.log(i); +} + +// for loops with an initializer and termination condition should remain untouched +for (let i = 0; i < 10;) { + i += 1; +} diff --git a/test/rules/prefer-while/test.ts.lint b/test/rules/prefer-while/test.ts.lint new file mode 100644 index 00000000000..0b0cad78dd2 --- /dev/null +++ b/test/rules/prefer-while/test.ts.lint @@ -0,0 +1,26 @@ +// for loops without an initializer, termination condition, and incrementor should be updated +for(;;) { +~~~~~~~ [Prefer `while` loops instead of `for` loops without an initializer and incrementor.] + console.log('Hello World'); +} + +// for loops without an initializer and incrementor should be updated +for(;true===true;) { +~~~~~~~~~~~~~~~~~~ [Prefer `while` loops instead of `for` loops without an initializer and incrementor.] + console.log('Hello World'); +} + +// for loops with an initializer, termination condition, and incrementor using '++' should remain untouched +for (let i = 1; i < 10; i++) { + console.log(i); +} + +// for loops with an initializer, termination condition, and incrementor using '+=' should remain untouched +for (let i = 0; i < 10; i+=1) { + console.log(i); +} + +// for loops with an initializer and termination condition should remain untouched +for (let i = 0; i < 10;) { + i += 1; +} diff --git a/test/rules/prefer-while/tslint.json b/test/rules/prefer-while/tslint.json new file mode 100644 index 00000000000..87f765de49f --- /dev/null +++ b/test/rules/prefer-while/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "prefer-while": true + } +} diff --git a/test/rules/promise-function-async/test.ts.lint b/test/rules/promise-function-async/test.ts.lint new file mode 100644 index 00000000000..c85dc8c7139 --- /dev/null +++ b/test/rules/promise-function-async/test.ts.lint @@ -0,0 +1,74 @@ +declare class Promise{} + +const nonAsyncPromiseFunctionExpressionA = function(p: Promise) { return p; }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const nonAsyncPromiseFunctionExpressionB = function() { return new Promise(); }; + ~~~~~~~~~~ [0] + +// 'async' 'Promise'-returning function expressions are allowed +const asyncPromiseFunctionExpressionA = async function(p: Promise) { return p; }; +const asyncPromiseFunctionExpressionB = async function() { return new Promise(); }; + +// non-'async' non-'Promise'-returning function expressions are allowed +const nonAsyncNonPromiseFunctionExpression = function(n: number) { return n; }; + +function nonAsyncPromiseFunctionDeclarationA(p: Promise) { return p; } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +function nonAsyncPromiseFunctionDeclarationB() { return new Promise(); } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +// 'async' 'Promise'-returning function declarations are allowed +async function asyncPromiseFunctionDeclarationA(p: Promise) { return p; } +async function asyncPromiseFunctionDeclarationB() { return new Promise(); } + +// non-'async' non-'Promise'-returning function declarations are allowed +function nonAsyncNonPromiseFunctionDeclaration(n: number) { return n; } + +const nonAsyncPromiseArrowFunctionA = (p: Promise) => p; + ~~~~~~~~~~~~~~~~~~~~~ [0] + +const nonAsyncPromiseArrowFunctionB = () => new Promise(); + ~~~~~ [0] + +// 'async' 'Promise'-returning arrow functions are allowed +const asyncPromiseArrowFunctionA = async (p: Promise) => p; +const asyncPromiseArrowFunctionB = async () => new Promise(); + +// non-'async' non-'Promise'-returning arrow functions are allowed +const nonAsyncNonPromiseArrowFunction = (n: number) => n; +const nonAsyncNonPromiseArrowFunctionParenthesisOne = (n: number) => (n); +const nonAsyncNonPromiseArrowFunctionParenthesisTwo = (n: number) => ((n)); + +class Test { + public nonAsyncPromiseMethodA(p: Promise) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + return p; + } + + public nonAsyncPromiseMethodB() { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + return new Promise(); + } + + // 'async' 'Promise'-returning methods are allowed + public async asyncPromiseMethodA(p: Promise) { + return p; + } + public async asyncPromiseMethodB() { + return new Promise(); + } + + // non-'async' non-'Promise'-returning methods are allowed + public nonAsyncNonPromiseMethod(n: number) { + return n; + } + + // single statement lamda functions that delegate to another promise-returning function are allowed + public delegatingMethod = () => this.asyncPromiseMethodB(1); + public delegatingMethodParenthesisOne = () => (this.asyncPromiseMethodB(1)); + public delegatingMethodParenthesisTwo = () => ((this.asyncPromiseMethodB(1))); +} + +[0]: functions that return promises must be async diff --git a/test/rules/promise-function-async/tsconfig.json b/test/rules/promise-function-async/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/promise-function-async/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/promise-function-async/tslint.json b/test/rules/promise-function-async/tslint.json new file mode 100644 index 00000000000..c4546e54179 --- /dev/null +++ b/test/rules/promise-function-async/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "promise-function-async": true + } +} diff --git a/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix b/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix new file mode 100644 index 00000000000..f3e005b4d9f --- /dev/null +++ b/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.fix @@ -0,0 +1,13 @@ +if (typeof v === `string`) {} + +if (typeof `string` === `number`) {} + +const object: { + "optional-prop"?: `hello-optional` + "optional-function"?(): void + "another-kebab": `hello-value` +} = { + "optional-prop": undefined, + "optional-function"() {}, + "another-kebab": `hello-value` +}; diff --git a/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint b/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint new file mode 100644 index 00000000000..1f33caa5d7b --- /dev/null +++ b/test/rules/quotemark/backtick/test-post-2.7.1-syntax.ts.lint @@ -0,0 +1,21 @@ +[typescript]: >=2.7.1 +if (typeof v === "string") {} + ~~~~~~~~ [double] + +if (typeof "string" === 'number') {} + ~~~~~~~~ [double] + ~~~~~~~~ [single] + +const object: { + "optional-prop"?: `hello-optional` + "optional-function"?(): void + "another-kebab": "hello-value" + ~~~~~~~~~~~~~ [double] +} = { + "optional-prop": undefined, + "optional-function"() {}, + "another-kebab": "hello-value" + ~~~~~~~~~~~~~ [double] +}; +[single]: ' should be ` +[double]: " should be ` diff --git a/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix b/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix new file mode 100644 index 00000000000..30b5e84aaa9 --- /dev/null +++ b/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.fix @@ -0,0 +1,11 @@ +if (typeof v === "string") {} + +if (typeof `string` === 'number') {} + +const object: { + "optional-prop"?: "hello-optional" + "another-kebab": "hello-value" +} = { + "optional-prop": undefined, + "another-kebab": "hello-value" +}; diff --git a/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint b/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint new file mode 100644 index 00000000000..c4ee7762f0c --- /dev/null +++ b/test/rules/quotemark/backtick/test-pre-2.7.1-syntax.ts.lint @@ -0,0 +1,15 @@ +[typescript]: <2.7.1 +if (typeof v === "string") {} + +if (typeof "string" === 'number') {} + ~~~~~~~~ [double] + +const object: { + "optional-prop"?: "hello-optional" + "another-kebab": "hello-value" +} = { + "optional-prop": undefined, + "another-kebab": "hello-value" +}; +[single]: ' should be ` +[double]: " should be ` diff --git a/test/rules/quotemark/backtick/test.ts.fix b/test/rules/quotemark/backtick/test.ts.fix new file mode 100644 index 00000000000..55cf8ac4dc2 --- /dev/null +++ b/test/rules/quotemark/backtick/test.ts.fix @@ -0,0 +1,80 @@ +"use strict" + +import { Something } from "some-package" +export { SomethingElse } from "another-package" + +enum Sides { + '<- Left', + 'Right ->' +} + +const octalEscapeSequence = '\1' +const octalEscapeSequence2 = '\7' +const octalEscapeSequence3 = '\77' +const octalEscapeSequence4 = '\377' +const octalEscapeSequence5 = '\123' +// Prefix (\47) is an octal escape sequence +const octalEscapeSequence6 = '\477' +const octalEscapeSequence7 = '\\77 \77 \\37 \\77' + +const notOctalEscapeSequence = `\877` +const notOctalEscapeSequence2 = `\017` +const notOctalEscapeSequence3 = `\t` +const notOctalEscapeSequence4 = `\0` +const notOctalEscapeSequence4 = `\\77 \\37 \\\\47 \\\\\\77` + +function strictFunction() { + "use strict" + + const str = `use strict` +} + +var single = `single`; + var double = `married`; +var singleWithinDouble = `'singleWithinDouble'`; +var doubleWithinSingle = `"doubleWithinSingle"`; +var tabNewlineWithinSingle = `tab\tNewline\nWithinSingle`; + +var array: Array<"literal string"> = []; +var arrayTwo: Array<"literal string" | number> = []; +var arrayThree: Array<"literal string" | "hello world"> = []; +var arrayFour: Array<"literal string" | "hello world" | "foo bar"> = []; +var array: Array<"literal string"> = []; +var arrayTwo: Array<"literal string" & number> = []; +var arrayFour: Array<"literal string" | "hello world" & "foo bar"> = []; + +function test() { + +} + +function test() { + +} + +declare var obj: { + helloWorldString: string +} + +interface obj2 { + helloWorldString: string +} + +type objHello = typeof obj["helloWorldString"] +type objHello2 = obj2["helloWorldString"] +let helloValue = obj[`helloWorldString`] + +helloValue = obj[`helloWorldString`] + +const obj3: { + value: typeof obj["helloWorldString"] +} = { + value: obj[`helloWorldString`] +} + +const callback = () => `hi` as number | string + +var hello: `world`; +`escaped'quotemark`; + +// "avoid-template" option is not set. +`foo`; diff --git a/test/rules/quotemark/backtick/test.ts.lint b/test/rules/quotemark/backtick/test.ts.lint new file mode 100644 index 00000000000..99329be41f4 --- /dev/null +++ b/test/rules/quotemark/backtick/test.ts.lint @@ -0,0 +1,99 @@ +"use strict" + +import { Something } from "some-package" +export { SomethingElse } from "another-package" + +enum Sides { + '<- Left', + 'Right ->' +} + +const octalEscapeSequence = '\1' +const octalEscapeSequence2 = '\7' +const octalEscapeSequence3 = '\77' +const octalEscapeSequence4 = '\377' +const octalEscapeSequence5 = '\123' +// Prefix (\47) is an octal escape sequence +const octalEscapeSequence6 = '\477' +const octalEscapeSequence7 = '\\77 \77 \\37 \\77' + +const notOctalEscapeSequence = '\877' + ~~~~~~ [single] +const notOctalEscapeSequence2 = '\017' + ~~~~~~ [single] +const notOctalEscapeSequence3 = '\t' + ~~~~ [single] +const notOctalEscapeSequence4 = '\0' + ~~~~ [single] +const notOctalEscapeSequence4 = '\\77 \\37 \\\\47 \\\\\\77' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [single] + +function strictFunction() { + "use strict" + + const str = "use strict" + ~~~~~~~~~~~~ [double] +} + +var single = 'single'; + ~~~~~~~~ [single] + var double = "married"; + ~~~~~~~~~ [double] +var singleWithinDouble = "'singleWithinDouble'"; + ~~~~~~~~~~~~~~~~~~~~~~ [double] +var doubleWithinSingle = '"doubleWithinSingle"'; + ~~~~~~~~~~~~~~~~~~~~~~ [single] +var tabNewlineWithinSingle = 'tab\tNewline\nWithinSingle'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [single] + +var array: Array<"literal string"> = []; +var arrayTwo: Array<"literal string" | number> = []; +var arrayThree: Array<"literal string" | "hello world"> = []; +var arrayFour: Array<"literal string" | "hello world" | "foo bar"> = []; +var array: Array<"literal string"> = []; +var arrayTwo: Array<"literal string" & number> = []; +var arrayFour: Array<"literal string" | "hello world" & "foo bar"> = []; + +function test() { + +} + +function test() { + +} + +declare var obj: { + helloWorldString: string +} + +interface obj2 { + helloWorldString: string +} + +type objHello = typeof obj["helloWorldString"] +type objHello2 = obj2["helloWorldString"] +let helloValue = obj["helloWorldString"] + ~~~~~~~~~~~~~~~~~~ [double] + +helloValue = obj["helloWorldString"] + ~~~~~~~~~~~~~~~~~~ [double] + +const obj3: { + value: typeof obj["helloWorldString"] +} = { + value: obj["helloWorldString"] + ~~~~~~~~~~~~~~~~~~ [double] +} + +const callback = () => "hi" as number | string + ~~~~ [double] + +var hello: "world"; + ~~~~~~~ [double] +'escaped\'quotemark'; +~~~~~~~~~~~~~~~~~~~~ [single] + +// "avoid-template" option is not set. +`foo`; +[single]: ' should be ` +[double]: " should be ` diff --git a/test/rules/quotemark/backtick/tslint.json b/test/rules/quotemark/backtick/tslint.json new file mode 100644 index 00000000000..f10ebc2f972 --- /dev/null +++ b/test/rules/quotemark/backtick/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "backtick"] + } +} diff --git a/test/rules/quotemark/double-avoid-escape/test.ts.fix b/test/rules/quotemark/double-avoid-escape/test.ts.fix new file mode 100644 index 00000000000..249ce46b38e --- /dev/null +++ b/test/rules/quotemark/double-avoid-escape/test.ts.fix @@ -0,0 +1,5 @@ +var single = "single"; + var double = "married"; +var singleWithinDouble = "'singleWithinDouble'"; +var doubleWithinSingle = '"doubleWithinSingle"'; +var tabNewlineWithinSingle = "tab\tNewline\nWithinSingle"; diff --git a/test/rules/quotemark/double-avoid-escape/test.ts.lint b/test/rules/quotemark/double-avoid-escape/test.ts.lint new file mode 100644 index 00000000000..720edf1cd5d --- /dev/null +++ b/test/rules/quotemark/double-avoid-escape/test.ts.lint @@ -0,0 +1,7 @@ +var single = 'single'; + ~~~~~~~~ [' should be "] + var double = "married"; +var singleWithinDouble = "'singleWithinDouble'"; +var doubleWithinSingle = '"doubleWithinSingle"'; +var tabNewlineWithinSingle = 'tab\tNewline\nWithinSingle'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] diff --git a/test/rules/quotemark/double-avoid-escape/tslint.json b/test/rules/quotemark/double-avoid-escape/tslint.json new file mode 100644 index 00000000000..6c0f14e3051 --- /dev/null +++ b/test/rules/quotemark/double-avoid-escape/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "double", "avoid-escape"] + } +} diff --git a/test/rules/quotemark/double-avoid-template/test.ts.fix b/test/rules/quotemark/double-avoid-template/test.ts.fix new file mode 100644 index 00000000000..df3dfeacb23 --- /dev/null +++ b/test/rules/quotemark/double-avoid-template/test.ts.fix @@ -0,0 +1,20 @@ +"fo`o"; + +"a 'quote'"; + +'a "quote"'; + +`a "quote" 'quote'`; + +// Allow multi-line templates +` +foo +bar +`; + +// Allow tagged templates and templates with substitutions +foo``; +`${foo}`; + +this.toastCtrl.present('Please tick "Yes" to confirm'); + diff --git a/test/rules/quotemark/double-avoid-template/test.ts.lint b/test/rules/quotemark/double-avoid-template/test.ts.lint new file mode 100644 index 00000000000..eb0d6f9481f --- /dev/null +++ b/test/rules/quotemark/double-avoid-template/test.ts.lint @@ -0,0 +1,26 @@ +`fo\`o`; +~~~~~~~ [0] + +`a 'quote'`; +~~~~~~~~~~~ [0] + +`a "quote"`; +~~~~~~~~~~~ [1] + +`a "quote" 'quote'`; + +// Allow multi-line templates +` +foo +bar +`; + +// Allow tagged templates and templates with substitutions +foo``; +`${foo}`; + +this.toastCtrl.present(`Please tick "Yes" to confirm`); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1] + +[0]: ` should be " +[1]: ` should be ' diff --git a/test/rules/quotemark/double-avoid-template/tslint.json b/test/rules/quotemark/double-avoid-template/tslint.json new file mode 100644 index 00000000000..dbeffb1d574 --- /dev/null +++ b/test/rules/quotemark/double-avoid-template/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "double", "avoid-escape", "avoid-template"] + } +} diff --git a/test/rules/quotemark/double/test.ts.fix b/test/rules/quotemark/double/test.ts.fix new file mode 100644 index 00000000000..77531382b02 --- /dev/null +++ b/test/rules/quotemark/double/test.ts.fix @@ -0,0 +1,9 @@ +var single = "single"; + var double = "married"; +var singleWithinDouble = "'singleWithinDouble'"; +var doubleWithinSingle = "\"doubleWithinSingle\""; +var tabNewlineWithinSingle = "tab\tNewline\nWithinSingle"; +"escaped'quotemark"; + +// "avoid-template" option is not set. +`foo`; diff --git a/test/rules/quotemark/double/test.ts.lint b/test/rules/quotemark/double/test.ts.lint new file mode 100644 index 00000000000..32fc8dd6f34 --- /dev/null +++ b/test/rules/quotemark/double/test.ts.lint @@ -0,0 +1,13 @@ +var single = 'single'; + ~~~~~~~~ [' should be "] + var double = "married"; +var singleWithinDouble = "'singleWithinDouble'"; +var doubleWithinSingle = '"doubleWithinSingle"'; + ~~~~~~~~~~~~~~~~~~~~~~ [' should be "] +var tabNewlineWithinSingle = 'tab\tNewline\nWithinSingle'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [' should be "] +'escaped\'quotemark'; +~~~~~~~~~~~~~~~~~~~~ [' should be "] + +// "avoid-template" option is not set. +`foo`; diff --git a/test/rules/quotemark/double/tslint.json b/test/rules/quotemark/double/tslint.json new file mode 100644 index 00000000000..9318e0d53e4 --- /dev/null +++ b/test/rules/quotemark/double/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "double"] + } +} diff --git a/test/rules/quotemark/invalid-double/test.ts.fix b/test/rules/quotemark/invalid-double/test.ts.fix new file mode 100644 index 00000000000..1e5ab6769e1 --- /dev/null +++ b/test/rules/quotemark/invalid-double/test.ts.fix @@ -0,0 +1,2 @@ +var single = "single"; +var unbalancedSingleAfter = ('a) diff --git a/test/rules/quotemark/invalid-double/test.ts.lint b/test/rules/quotemark/invalid-double/test.ts.lint new file mode 100644 index 00000000000..8bf8e15d4f9 --- /dev/null +++ b/test/rules/quotemark/invalid-double/test.ts.lint @@ -0,0 +1,3 @@ +var single = 'single'; + ~~~~~~~~ [' should be "] +var unbalancedSingleAfter = ('a) diff --git a/test/rules/quotemark/invalid-double/tslint.json b/test/rules/quotemark/invalid-double/tslint.json new file mode 100644 index 00000000000..9318e0d53e4 --- /dev/null +++ b/test/rules/quotemark/invalid-double/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "double"] + } +} diff --git a/test/rules/quotemark/invalid-single/test.ts.fix b/test/rules/quotemark/invalid-single/test.ts.fix new file mode 100644 index 00000000000..16e11a81288 --- /dev/null +++ b/test/rules/quotemark/invalid-single/test.ts.fix @@ -0,0 +1,2 @@ +var single = 'single'; +var unbalancedSingleAfter = ("a) diff --git a/test/rules/quotemark/invalid-single/test.ts.lint b/test/rules/quotemark/invalid-single/test.ts.lint new file mode 100644 index 00000000000..e5525bef1ce --- /dev/null +++ b/test/rules/quotemark/invalid-single/test.ts.lint @@ -0,0 +1,3 @@ +var single = "single"; + ~~~~~~~~ [" should be '] +var unbalancedSingleAfter = ("a) diff --git a/test/rules/quotemark/invalid-single/tslint.json b/test/rules/quotemark/invalid-single/tslint.json new file mode 100644 index 00000000000..4a5f880d8ab --- /dev/null +++ b/test/rules/quotemark/invalid-single/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "single"] + } +} diff --git a/test/rules/quotemark/jsx-double/test.tsx.fix b/test/rules/quotemark/jsx-double/test.tsx.fix new file mode 100644 index 00000000000..52aee4810f8 --- /dev/null +++ b/test/rules/quotemark/jsx-double/test.tsx.fix @@ -0,0 +1,4 @@ +import * as React from 'react'; + +export const a = ( +
diff --git a/test/rules/quotemark/jsx-double/test.tsx.lint b/test/rules/quotemark/jsx-double/test.tsx.lint new file mode 100644 index 00000000000..ef33be82556 --- /dev/null +++ b/test/rules/quotemark/jsx-double/test.tsx.lint @@ -0,0 +1,8 @@ +import * as React from "react"; + ~~~~~~~ [" should be '] + +export const a = ( +
+ ~~~~ [' should be "] + ~~~ [" should be '] + ~~~~~~~~~ [" should be '] diff --git a/test/rules/quotemark/jsx-double/tslint.json b/test/rules/quotemark/jsx-double/tslint.json new file mode 100644 index 00000000000..2cd40c48b47 --- /dev/null +++ b/test/rules/quotemark/jsx-double/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true,"jsx-double", "single"] + } +} diff --git a/test/rules/quotemark/jsx-single/test.tsx.fix b/test/rules/quotemark/jsx-single/test.tsx.fix new file mode 100644 index 00000000000..4e9df3a01ce --- /dev/null +++ b/test/rules/quotemark/jsx-single/test.tsx.fix @@ -0,0 +1,4 @@ +import * as React from "react"; + +export const a = ( +
diff --git a/test/rules/quotemark/jsx-single/test.tsx.lint b/test/rules/quotemark/jsx-single/test.tsx.lint new file mode 100644 index 00000000000..9dbc3f68f05 --- /dev/null +++ b/test/rules/quotemark/jsx-single/test.tsx.lint @@ -0,0 +1,7 @@ +import * as React from "react"; + +export const a = ( +
+ ~~~~~~~ [" should be '] + ~~~ [' should be "] + ~~~~~~~~~ [' should be "] diff --git a/test/rules/quotemark/jsx-single/tslint.json b/test/rules/quotemark/jsx-single/tslint.json new file mode 100644 index 00000000000..587153999f1 --- /dev/null +++ b/test/rules/quotemark/jsx-single/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "double", "jsx-single"] + } +} diff --git a/test/rules/quotemark/single-avoid-escape/test.ts.fix b/test/rules/quotemark/single-avoid-escape/test.ts.fix new file mode 100644 index 00000000000..2b3ee390fe7 --- /dev/null +++ b/test/rules/quotemark/single-avoid-escape/test.ts.fix @@ -0,0 +1,5 @@ +var single = 'single'; + var double = 'married'; +var singleWithinDouble = "'singleWithinDouble'"; +var doubleWithinSingle = '"doubleWithinSingle"'; +var tabNewlineWithinDouble = 'tab\tNewline\nWithinDouble'; diff --git a/test/rules/quotemark/single-avoid-escape/test.ts.lint b/test/rules/quotemark/single-avoid-escape/test.ts.lint new file mode 100644 index 00000000000..2084df32b57 --- /dev/null +++ b/test/rules/quotemark/single-avoid-escape/test.ts.lint @@ -0,0 +1,7 @@ +var single = 'single'; + var double = "married"; + ~~~~~~~~~ [" should be '] +var singleWithinDouble = "'singleWithinDouble'"; +var doubleWithinSingle = '"doubleWithinSingle"'; +var tabNewlineWithinDouble = "tab\tNewline\nWithinDouble"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [" should be '] diff --git a/test/rules/quotemark/single-avoid-escape/tslint.json b/test/rules/quotemark/single-avoid-escape/tslint.json new file mode 100644 index 00000000000..c360887f9d7 --- /dev/null +++ b/test/rules/quotemark/single-avoid-escape/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "single", "avoid-escape"] + } +} diff --git a/test/rules/quotemark/single-avoid-template/test.ts.fix b/test/rules/quotemark/single-avoid-template/test.ts.fix new file mode 100644 index 00000000000..5f26f410553 --- /dev/null +++ b/test/rules/quotemark/single-avoid-template/test.ts.fix @@ -0,0 +1,20 @@ +'fo`o'; + +"a 'quote'"; + +'a "quote"'; + +`a "quote" 'quote'`; + +// Allow multi-line templates +` +foo +bar +`; + +// Allow tagged templates and templates with substitutions +foo``; +`${foo}`; + +this.toastCtrl.present('Please tick "Yes" to confirm'); + diff --git a/test/rules/quotemark/single-avoid-template/test.ts.lint b/test/rules/quotemark/single-avoid-template/test.ts.lint new file mode 100644 index 00000000000..8bf33978e84 --- /dev/null +++ b/test/rules/quotemark/single-avoid-template/test.ts.lint @@ -0,0 +1,26 @@ +`fo\`o`; +~~~~~~~ [0] + +`a 'quote'`; +~~~~~~~~~~~ [1] + +`a "quote"`; +~~~~~~~~~~~ [0] + +`a "quote" 'quote'`; + +// Allow multi-line templates +` +foo +bar +`; + +// Allow tagged templates and templates with substitutions +foo``; +`${foo}`; + +this.toastCtrl.present(`Please tick "Yes" to confirm`); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: ` should be ' +[1]: ` should be " diff --git a/test/rules/quotemark/single-avoid-template/tslint.json b/test/rules/quotemark/single-avoid-template/tslint.json new file mode 100644 index 00000000000..f5eb55e4f0c --- /dev/null +++ b/test/rules/quotemark/single-avoid-template/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "single", "avoid-escape", "avoid-template"] + } +} diff --git a/test/rules/quotemark/single/test.ts.fix b/test/rules/quotemark/single/test.ts.fix new file mode 100644 index 00000000000..2ed41df170d --- /dev/null +++ b/test/rules/quotemark/single/test.ts.fix @@ -0,0 +1,6 @@ +var single = 'single'; + var double = 'married'; +var singleWithinDouble = '\'singleWithinDouble\''; +var doubleWithinSingle = '"doubleWithinSingle"'; +var tabNewlineWithinDouble = 'tab\tNewline\nWithinDouble'; +'escaped"quotemark'; diff --git a/test/rules/quotemark/single/test.ts.lint b/test/rules/quotemark/single/test.ts.lint new file mode 100644 index 00000000000..292791dcceb --- /dev/null +++ b/test/rules/quotemark/single/test.ts.lint @@ -0,0 +1,10 @@ +var single = 'single'; + var double = "married"; + ~~~~~~~~~ [" should be '] +var singleWithinDouble = "'singleWithinDouble'"; + ~~~~~~~~~~~~~~~~~~~~~~ [" should be '] +var doubleWithinSingle = '"doubleWithinSingle"'; +var tabNewlineWithinDouble = "tab\tNewline\nWithinDouble"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [" should be '] +"escaped\"quotemark"; +~~~~~~~~~~~~~~~~~~~~ [" should be '] diff --git a/test/rules/quotemark/single/test.tsx.lint b/test/rules/quotemark/single/test.tsx.lint new file mode 100644 index 00000000000..08e15a52b36 --- /dev/null +++ b/test/rules/quotemark/single/test.tsx.lint @@ -0,0 +1,2 @@ +let foo = + ~~~~~ [" should be '] diff --git a/test/rules/quotemark/single/tslint.json b/test/rules/quotemark/single/tslint.json new file mode 100644 index 00000000000..4a5f880d8ab --- /dev/null +++ b/test/rules/quotemark/single/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotemark": [true, "single"] + } +} diff --git a/test/rules/radix/test.ts.lint b/test/rules/radix/test.ts.lint new file mode 100644 index 00000000000..fc1c61e898d --- /dev/null +++ b/test/rules/radix/test.ts.lint @@ -0,0 +1,28 @@ +var x = parseInt(3, 10) + + parseInt(4); + ~~~~~~~~~~~ [Missing radix parameter] +var y = parseFloat("2.5"); + +parser.parseInt("123"); +obj.parser.parseInt("123"); + +global.parseInt("123"); +~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] +global.global.parseInt("123"); +window.parseInt("123"); +~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] + +Number.parseInt("123", 10); +Number.parseInt("123"); +~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] +other.Number.parseInt("123"); + +global.Number.parseInt("123", 10); +global.Number.parseInt("123"); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] +other.global.Number.parseInt("123"); + +window.Number.parseInt("123", 10); +window.Number.parseInt("123"); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Missing radix parameter] +other.window.Number.parseInt("123"); diff --git a/test/rules/radix/tslint.json b/test/rules/radix/tslint.json new file mode 100644 index 00000000000..38441411292 --- /dev/null +++ b/test/rules/radix/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "radix": true + } +} diff --git a/test/rules/restrict-plus-operands/default/test.ts.lint b/test/rules/restrict-plus-operands/default/test.ts.lint new file mode 100644 index 00000000000..f1c604d3efe --- /dev/null +++ b/test/rules/restrict-plus-operands/default/test.ts.lint @@ -0,0 +1,68 @@ +// aliases for number +type MyNumber = number; +type MyString = string; +interface NumberStringPair { + first: MyNumber, + second: MyString +} + +var x = 5; +var y = "10"; +var z = 8.2; +var w = "6.5"; +var pair: NumberStringPair = { + first: 5, + second: "10" +}; + +// bad +var bad1 = 5 + "10"; + ~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5 + "10". Consider using template literals.] +var bad2 = [] + 5; + ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + 5] +var bad3 = [] + {}; + ~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + {}] +var bad4 = [] + []; + ~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + []] +var bad4 = 5 + []; + ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5 + []] +var bad5 = "5" + {}; + ~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found "5" + {}. Consider using template literals.] +var bad6 = 5.5 + "5"; + ~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5.5 + "5". Consider using template literals.] +var bad7 = "5.5" + 5; + ~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found "5.5" + 5. Consider using template literals.] +var bad8 = x + y; + ~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + string. Consider using template literals.] +var bad9 = y + x; + ~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found string + number. Consider using template literals.] +var bad10 = x + {}; + ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + {}] +var bad11 = [] + y; + ~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found [] + string. Consider using template literals.] +var bad12 = pair.first + "10"; + ~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + "10". Consider using template literals.] +var bad13 = 5 + pair.second; + ~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found 5 + string. Consider using template literals.] +var bad14 = pair + pair; + ~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found NumberStringPair + NumberStringPair] +var anyTyped: any = 5; +var bad15 = anyTyped + 12; + ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found any + 12] + +// good +var good1 = 5 + 10; +var good2 = "5.5" + "10"; +var good3 = parseFloat("5.5", 10), + 10; +var good4 = x + z; +var good5 = y + w; + +var good6 = pair.first + 10; +var good7 = pair.first + (10 as MyNumber); +var good8 = "5.5" + pair.second; +var good9 = ("5.5" as MyString) + pair.second; +const good10 = 'hello' + (someBoolean ? 'a' : 'b') + (() => someBoolean ? 'c' : 'd')() + 'e'; + +// don't check other binary expressions +const balls = true; +balls === true; diff --git a/test/rules/restrict-plus-operands/default/tsconfig.json b/test/rules/restrict-plus-operands/default/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/restrict-plus-operands/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/restrict-plus-operands/default/tslint.json b/test/rules/restrict-plus-operands/default/tslint.json new file mode 100644 index 00000000000..8389b1de47a --- /dev/null +++ b/test/rules/restrict-plus-operands/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "restrict-plus-operands": true + } +} diff --git a/test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint b/test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint new file mode 100644 index 00000000000..b8ddc80558c --- /dev/null +++ b/test/rules/restrict-plus-operands/esnext-bigint/test.ts.lint @@ -0,0 +1,42 @@ +[typescript]: >= 3.2.0 +type MyNumber = number; +type MyString = string; +type MyBigInt = bigint; +interface NumberStringBigint { + first: MyNumber, + second: MyString, + third: MyBigInt +} + +var x = 5; +var y = "10"; +var bigintVar = BigInt(200); +var anyVar: any = 200; +var pair: NumberStringBigint = { + first: 5, first: 5, + second: "10" second: "10", + third: BigInt(100), +}; + +const bigIntPassA = BigInt(1) + BigInt(2); +const bigIntPassB = BigInt(1) + 100n; +const bigIntFailA = BigInt(1) + 2; + ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + 2] +const bigIntFailB = BigInt(1) + "failureString"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + "failureString". Consider using template literals.] + +const bigIntFailC = bigintVar + x; + ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + number] +const bigIntFailD = y + bigintVar; + ~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found string + bigint. Consider using template literals.] +const bigIntFailE = bigintVar + anyVar; + ~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + any] + +const bigIntFailF = pair.first + pair.third; + ~~~~~~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found number + bigint] +const bigIntFailG = pair.third + pair.second; + ~~~~~~~~~~~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + string. Consider using template literals.] +const bigIntFailH = bigintVar + []; + ~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + []] +const bigIntFailI = bigintVar + {}; + ~~~~~~~~~~~~~~ [Operands of '+' operation must either be both strings or both numbers or both bigints, but found bigint + {}] diff --git a/test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json b/test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json new file mode 100644 index 00000000000..0d58d115f70 --- /dev/null +++ b/test/rules/restrict-plus-operands/esnext-bigint/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "target": "esnext" + } +} diff --git a/test/rules/restrict-plus-operands/esnext-bigint/tslint.json b/test/rules/restrict-plus-operands/esnext-bigint/tslint.json new file mode 100644 index 00000000000..e5801e9ba40 --- /dev/null +++ b/test/rules/restrict-plus-operands/esnext-bigint/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "restrict-plus-operands": true + } +} diff --git a/test/rules/return-undefined/default/test.ts.lint b/test/rules/return-undefined/default/test.ts.lint new file mode 100644 index 00000000000..e672954f38d --- /dev/null +++ b/test/rules/return-undefined/default/test.ts.lint @@ -0,0 +1,92 @@ +class Promise { + then(): Promise; +} +function valueWrong(): number | undefined { + return; + ~~~~~~~ [UNDEFINED] +} +function valueRight(): number | undefined { + return undefined; +} + +function voidWrong(): void { + return undefined; + ~~~~~~~~~~~~~~~~~ [VOID] +} +function voidRight(): void { + return; +} + +// Infers type from context. +[].forEach(() => { + return undefined; + ~~~~~~~~~~~~~~~~~ [VOID] +}); +[].map(() => { + return; + ~~~~~~~ [UNDEFINED] +}); + +type Cb = () => void; +declare function badContextualType(cb: Cb | Cb[]): void; +// Uses typeAtLocation instead of contextual type. +badContextualType(() => { + if (1 === 2) return 1; + else return; + ~~~~~~~ [UNDEFINED] +}); + +// Allow anything in callback taking 'any'. +function takesAnyCb(cb: () => any): void; +takesAnyCb(() => { return; }); +takesAnyCb(() => { return undefined; }); +takesAnyCb(() => { + if (1 === 2) return; + else return 1; +}); +takesAnyCb(() => { + if (1 === 2) return; + else return undefined; +}); +takesAnyCb((): void => { + if (1 === 2) return; + else return undefined; + ~~~~~~~~~~~~~~~~~ [VOID] +}); + +async function promiseVoid(): Promise { + if (1 === 2) return; + else return undefined; + ~~~~~~~~~~~~~~~~~ [VOID] +} + +async function promiseValue(): Promise { + if (1 === 2) return 1; + else return; + ~~~~~~~ [UNDEFINED] +} + +declare function test(cb: () => Promise | void): void; + +test(async () => { + if (1 === 2) return; + else return undefined; + ~~~~~~~~~~~~~~~~~ [VOID] +}); + + +function * generator(returnNothing: boolean) { + if (returnNothing) return; + yield 1; + return yield * [2, 3]; +} + +class ClassWithGeneratorMethod { + * generatorMethod(returnNothing: boolean) { + if (returnNothing) return; + yield 1; + } +} + +[VOID]: `void` function should use `return;`, not `return undefined;`. +[UNDEFINED]: Value-returning function should use `return undefined;`, not just `return;`. diff --git a/test/rules/return-undefined/default/tsconfig.json b/test/rules/return-undefined/default/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/return-undefined/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/return-undefined/default/tslint.json b/test/rules/return-undefined/default/tslint.json new file mode 100644 index 00000000000..475b28dc589 --- /dev/null +++ b/test/rules/return-undefined/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "return-undefined": true + } +} diff --git a/test/rules/return-undefined/pre-ts-3.6/test.ts.lint b/test/rules/return-undefined/pre-ts-3.6/test.ts.lint new file mode 100644 index 00000000000..b58b43f5719 --- /dev/null +++ b/test/rules/return-undefined/pre-ts-3.6/test.ts.lint @@ -0,0 +1,9 @@ +[typescript]: <= 3.6.0 + +// in TS 3.6 and later, the type checker infers this anonymous function as returning 'unknown' +declare function f(action: () => T | undefined): void; +f(() => { return undefined; }); + ~~~~~~~~~~~~~~~~~ [VOID] + +[VOID]: `void` function should use `return;`, not `return undefined;`. +[UNDEFINED]: Value-returning function should use `return undefined;`, not just `return;`. diff --git a/test/rules/return-undefined/pre-ts-3.6/tsconfig.json b/test/rules/return-undefined/pre-ts-3.6/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/return-undefined/pre-ts-3.6/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/return-undefined/pre-ts-3.6/tslint.json b/test/rules/return-undefined/pre-ts-3.6/tslint.json new file mode 100644 index 00000000000..475b28dc589 --- /dev/null +++ b/test/rules/return-undefined/pre-ts-3.6/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "return-undefined": true + } +} diff --git a/test/rules/semicolon/always/test.ts.fix b/test/rules/semicolon/always/test.ts.fix new file mode 100644 index 00000000000..3d15200c279 --- /dev/null +++ b/test/rules/semicolon/always/test.ts.fix @@ -0,0 +1,96 @@ +declare module "*"; +declare module "foo" {} +var x = 3; +a += b; + +c = () => { +}; + +d = function() { }; + +console.log("i am adam, am i?"); + +function xyz() { + return; +} + +switch(xyz) { + case 1: + break; + case 2: + continue; +} + +throw new Error("some error"); + +do { + var a = 4; +} while(x == 3); + +debugger; + +import v = require("i"); +module M { + export var x; + export function f(s: string): string; + export function f(n: number): number; + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number; +} + +function useStrictMissingSemicolon() { + "use strict"; + return null; +} + +class MyClass { + public name : string; + private index : number; + private email : string; + + public initializedProperty = 6; + public initializedMethodProperty = () => { + return "hi"; + } + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; + public someMethod(): void; + public someMethod(param): void; + public someMethod(param?) { + return; + } +} + +interface ITest { + foo?: string; + bar: number; // handles comment + qux: string; // handles comment + baz: boolean; + readonly raz: number; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib'; + +export default LoginPage; +export default LoginPage; +export = Date; +export = Date; +type t = number; +type t = number; + +if (true); +for(;;); + + diff --git a/test/rules/semicolon/always/test.ts.lint b/test/rules/semicolon/always/test.ts.lint new file mode 100644 index 00000000000..494175afbf4 --- /dev/null +++ b/test/rules/semicolon/always/test.ts.lint @@ -0,0 +1,131 @@ +declare module "*" + ~nil [Missing semicolon] +declare module "foo" {} +var x = 3 + ~nil [Missing semicolon] +a += b + ~nil [Missing semicolon] + +c = () => { +} + ~nil [Missing semicolon] + +d = function() { } + ~nil [Missing semicolon] + +console.log("i am adam, am i?") + ~nil [Missing semicolon] + +function xyz() { + return + ~nil [Missing semicolon] +} + +switch(xyz) { + case 1: + break + ~nil [Missing semicolon] + case 2: + continue + ~nil [Missing semicolon] +} + +throw new Error("some error") + ~nil [Missing semicolon] + +do { + var a = 4 + ~nil [Missing semicolon] +} while(x == 3) + ~nil [Missing semicolon] + +debugger + ~nil [Missing semicolon] + +import v = require("i") + ~nil [Missing semicolon] +module M { + export var x + ~nil [Missing semicolon] + export function f(s: string): string; + export function f(n: number): number + ~nil [Missing semicolon] + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number + ~nil [Missing semicolon] +} + +function useStrictMissingSemicolon() { + "use strict" + ~nil [Missing semicolon] + return null; +} + +class MyClass { + public name : string + ~nil [Missing semicolon] + private index : number + ~nil [Missing semicolon] + private email : string; + + public initializedProperty = 6 + ~nil [Missing semicolon] + public initializedMethodProperty = () => { + return "hi"; + }; + ~ [Unnecessary semicolon] + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } + ~nil [Missing semicolon] + public someMethod(): void; + public someMethod(param): void + ~nil [Missing semicolon] + public someMethod(param?) { + return; + }; + ~ [Unnecessary semicolon] +}; + ~ [Unnecessary semicolon] + +interface ITest { + foo?: string + ~nil [Missing semicolon] + bar: number // handles comment + ~nil [Missing semicolon] + qux: string, // handles comment + ~ [Properties should be separated by semicolons] + baz: boolean; + readonly raz: number; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib' + ~nil [Missing semicolon] + +export default LoginPage; +export default LoginPage + ~nil [Missing semicolon] +export = Date; +export = Date + ~nil [Missing semicolon] +type t = number; +type t = number + ~nil [Missing semicolon] + +if (true); + ~ [Unnecessary semicolon] +for(;;); + +; +~ [Unnecessary semicolon] diff --git a/test/rules/semicolon/always/tslint.json b/test/rules/semicolon/always/tslint.json new file mode 100644 index 00000000000..3df79679a99 --- /dev/null +++ b/test/rules/semicolon/always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": [true, "always"] + } +} diff --git a/test/rules/semicolon/enabled/test.ts.fix b/test/rules/semicolon/enabled/test.ts.fix new file mode 100644 index 00000000000..b25bb6b528e --- /dev/null +++ b/test/rules/semicolon/enabled/test.ts.fix @@ -0,0 +1,87 @@ +var x = 3; +a += b; + +c = () => { +}; + +f(() => { + return 1; +}); + +d = function() { }; + +console.log("i am adam, am i?"); + +function xyz() { + return; +} + +switch(xyz) { + case 1: + break; + case 2: + continue; +} + +throw new Error("some error"); + +do { + var a = 4; +} while(x == 3); + +debugger; + +import v = require("i"); +module M { + export var x; + export function f(s: string): string; + export function f(n: number): number; + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number; +} + +function useStrictMissingSemicolon() { + "use strict"; + return null; +} + +class MyClass { + public name : string; + private index : number; + private email : string; + + public initializedProperty = 6; + public initializedMethodProperty: mytype = () => { + return "hi"; + } + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; +} + +interface ITest { + foo?: string; + bar: number; + qux: string; + baz: boolean; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib'; + +export default LoginPage; +export default LoginPage; +export = Date; +export = Date; +type t = number; +type t = number; diff --git a/test/rules/semicolon/enabled/test.ts.lint b/test/rules/semicolon/enabled/test.ts.lint new file mode 100644 index 00000000000..9e4f9553030 --- /dev/null +++ b/test/rules/semicolon/enabled/test.ts.lint @@ -0,0 +1,116 @@ +var x = 3 + ~nil [Missing semicolon] +a += b + ~nil [Missing semicolon] + +c = () => { +} + ~nil [Missing semicolon] + +f(() => { + return 1; +}); + +d = function() { } + ~nil [Missing semicolon] + +console.log("i am adam, am i?") + ~nil [Missing semicolon] + +function xyz() { + return + ~nil [Missing semicolon] +} + +switch(xyz) { + case 1: + break + ~nil [Missing semicolon] + case 2: + continue + ~nil [Missing semicolon] +} + +throw new Error("some error") + ~nil [Missing semicolon] + +do { + var a = 4 + ~nil [Missing semicolon] +} while(x == 3) + ~nil [Missing semicolon] + +debugger + ~nil [Missing semicolon] + +import v = require("i") + ~nil [Missing semicolon] +module M { + export var x + ~nil [Missing semicolon] + export function f(s: string): string; + export function f(n: number): number + ~nil [Missing semicolon] + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number + ~nil [Missing semicolon] +} + +function useStrictMissingSemicolon() { + "use strict" + ~nil [Missing semicolon] + return null; +} + +class MyClass { + public name : string + ~nil [Missing semicolon] + private index : number + ~nil [Missing semicolon] + private email : string; + + public initializedProperty = 6 + ~nil [Missing semicolon] + public initializedMethodProperty: mytype = () => { + return "hi"; + }; + ~ [Unnecessary semicolon] + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } + ~nil [Missing semicolon] +} + +interface ITest { + foo?: string + ~nil [Missing semicolon] + bar: number + ~nil [Missing semicolon] + qux: string, + ~ [Properties should be separated by semicolons] + baz: boolean; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib' + ~nil [Missing semicolon] + +export default LoginPage; +export default LoginPage + ~nil [Missing semicolon] +export = Date; +export = Date + ~nil [Missing semicolon] +type t = number; +type t = number + ~nil [Missing semicolon] diff --git a/test/rules/semicolon/enabled/tslint.json b/test/rules/semicolon/enabled/tslint.json new file mode 100644 index 00000000000..7a7a8e7d42a --- /dev/null +++ b/test/rules/semicolon/enabled/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": true + } +} diff --git a/test/rules/semicolon/ignore-bound-class-methods/test.ts.fix b/test/rules/semicolon/ignore-bound-class-methods/test.ts.fix new file mode 100644 index 00000000000..e31a7abf17b --- /dev/null +++ b/test/rules/semicolon/ignore-bound-class-methods/test.ts.fix @@ -0,0 +1,83 @@ +var x = 3; +a += b; + +c = () => { +}; + +d = function() { }; + +console.log("i am adam, am i?"); + +function xyz() { + return; +} + +switch(xyz) { + case 1: + break; + case 2: + continue; +} + +throw new Error("some error"); + +do { + var a = 4; +} while(x == 3); + +debugger; + +import v = require("i"); +module M { + export var x; + export function f(s: string): string; + export function f(n: number): number; + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number; +} + +function useStrictMissingSemicolon() { + "use strict"; + return null; +} + +class MyClass { + public name : string; + private index : number; + private email : string; + + public initializedProperty = 6; + public initializedMethodProperty = () => { + return "hi"; + }; + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; +} + +interface ITest { + foo?: string; + bar: number; + qux: string; + baz: boolean; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib'; + +export default LoginPage; +export default LoginPage; +export = Date; +export = Date; +type t = number; +type t = number; diff --git a/test/rules/semicolon/ignore-bound-class-methods/test.ts.lint b/test/rules/semicolon/ignore-bound-class-methods/test.ts.lint new file mode 100644 index 00000000000..34f605eb816 --- /dev/null +++ b/test/rules/semicolon/ignore-bound-class-methods/test.ts.lint @@ -0,0 +1,111 @@ +var x = 3 + ~nil [Missing semicolon] +a += b + ~nil [Missing semicolon] + +c = () => { +} + ~nil [Missing semicolon] + +d = function() { } + ~nil [Missing semicolon] + +console.log("i am adam, am i?") + ~nil [Missing semicolon] + +function xyz() { + return + ~nil [Missing semicolon] +} + +switch(xyz) { + case 1: + break + ~nil [Missing semicolon] + case 2: + continue + ~nil [Missing semicolon] +} + +throw new Error("some error") + ~nil [Missing semicolon] + +do { + var a = 4 + ~nil [Missing semicolon] +} while(x == 3) + ~nil [Missing semicolon] + +debugger + ~nil [Missing semicolon] + +import v = require("i") + ~nil [Missing semicolon] +module M { + export var x + ~nil [Missing semicolon] + export function f(s: string): string; + export function f(n: number): number + ~nil [Missing semicolon] + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number + ~nil [Missing semicolon] +} + +function useStrictMissingSemicolon() { + "use strict" + ~nil [Missing semicolon] + return null; +} + +class MyClass { + public name : string + ~nil [Missing semicolon] + private index : number + ~nil [Missing semicolon] + private email : string; + + public initializedProperty = 6 + ~nil [Missing semicolon] + public initializedMethodProperty = () => { + return "hi"; + }; + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } + ~nil [Missing semicolon] +} + +interface ITest { + foo?: string + ~nil [Missing semicolon] + bar: number + ~nil [Missing semicolon] + qux: string, + ~ [Properties should be separated by semicolons] + baz: boolean; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib' + ~nil [Missing semicolon] + +export default LoginPage; +export default LoginPage + ~nil [Missing semicolon] +export = Date; +export = Date + ~nil [Missing semicolon] +type t = number; +type t = number + ~nil [Missing semicolon] diff --git a/test/rules/semicolon/ignore-bound-class-methods/tslint.json b/test/rules/semicolon/ignore-bound-class-methods/tslint.json new file mode 100644 index 00000000000..52bef362d4b --- /dev/null +++ b/test/rules/semicolon/ignore-bound-class-methods/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": [true, "always", "ignore-bound-class-methods"] + } +} diff --git a/test/rules/semicolon/ignore-interfaces/test.ts.fix b/test/rules/semicolon/ignore-interfaces/test.ts.fix new file mode 100644 index 00000000000..f0fce8929a3 --- /dev/null +++ b/test/rules/semicolon/ignore-interfaces/test.ts.fix @@ -0,0 +1,83 @@ +var x = 3; +a += b; + +c = () => { +}; + +d = function() { }; + +console.log("i am adam, am i?"); + +function xyz() { + return; +} + +switch(xyz) { + case 1: + break; + case 2: + continue; +} + +throw new Error("some error"); + +do { + var a = 4; +} while(x == 3); + +debugger; + +import v = require("i"); +module M { + export var x; + export function f(s: string): string; + export function f(n: number): number; + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number; +} + +function useStrictMissingSemicolon() { + "use strict"; + return null; +} + +class MyClass { + public name : string; + private index : number; + private email : string; + + public initializedProperty = 6; + public initializedMethodProperty = () => { + return "hi"; + } + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; +} + +interface ITest { + foo?: string + bar: number + qux: string, + baz: boolean; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib'; + +export default LoginPage; +export default LoginPage; +export = Date; +export = Date; +type t = number; +type t = number; diff --git a/test/rules/semicolon/ignore-interfaces/test.ts.lint b/test/rules/semicolon/ignore-interfaces/test.ts.lint new file mode 100644 index 00000000000..3cad904d7ec --- /dev/null +++ b/test/rules/semicolon/ignore-interfaces/test.ts.lint @@ -0,0 +1,109 @@ +var x = 3 + ~nil [Missing semicolon] +a += b + ~nil [Missing semicolon] + +c = () => { +} + ~nil [Missing semicolon] + +d = function() { } + ~nil [Missing semicolon] + +console.log("i am adam, am i?") + ~nil [Missing semicolon] + +function xyz() { + return + ~nil [Missing semicolon] +} + +switch(xyz) { + case 1: + break + ~nil [Missing semicolon] + case 2: + continue + ~nil [Missing semicolon] +} + +throw new Error("some error") + ~nil [Missing semicolon] + +do { + var a = 4 + ~nil [Missing semicolon] +} while(x == 3) + ~nil [Missing semicolon] + +debugger + ~nil [Missing semicolon] + +import v = require("i") + ~nil [Missing semicolon] +module M { + export var x + ~nil [Missing semicolon] + export function f(s: string): string; + export function f(n: number): number + ~nil [Missing semicolon] + export function f(x: any) { return x; } +} + +declare module "M" { + function f(): number; + function g(): number + ~nil [Missing semicolon] +} + +function useStrictMissingSemicolon() { + "use strict" + ~nil [Missing semicolon] + return null; +} + +class MyClass { + public name : string + ~nil [Missing semicolon] + private index : number + ~nil [Missing semicolon] + private email : string; + + public initializedProperty = 6 + ~nil [Missing semicolon] + public initializedMethodProperty = () => { + return "hi"; + }; + ~ [Unnecessary semicolon] + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } + ~nil [Missing semicolon] +} + +interface ITest { + foo?: string + bar: number + qux: string, + baz: boolean; +} + +import {Router} from 'aurelia-router'; + +import {Controller} from 'my-lib' + ~nil [Missing semicolon] + +export default LoginPage; +export default LoginPage + ~nil [Missing semicolon] +export = Date; +export = Date + ~nil [Missing semicolon] +type t = number; +type t = number + ~nil [Missing semicolon] diff --git a/test/rules/semicolon/ignore-interfaces/tslint.json b/test/rules/semicolon/ignore-interfaces/tslint.json new file mode 100644 index 00000000000..a81b2d1b4a4 --- /dev/null +++ b/test/rules/semicolon/ignore-interfaces/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": [true, "always", "ignore-interfaces"] + } +} diff --git a/test/rules/semicolon/never/eof1.ts.lint b/test/rules/semicolon/never/eof1.ts.lint new file mode 100644 index 00000000000..1e1cb6b6940 --- /dev/null +++ b/test/rules/semicolon/never/eof1.ts.lint @@ -0,0 +1,2 @@ +var foo = bar; + ~ [Unnecessary semicolon] \ No newline at end of file diff --git a/test/rules/semicolon/never/eof2.ts.lint b/test/rules/semicolon/never/eof2.ts.lint new file mode 100644 index 00000000000..518b947922c --- /dev/null +++ b/test/rules/semicolon/never/eof2.ts.lint @@ -0,0 +1,2 @@ +return; + ~ [Unnecessary semicolon] \ No newline at end of file diff --git a/test/rules/semicolon/never/test.ts.fix b/test/rules/semicolon/never/test.ts.fix new file mode 100644 index 00000000000..f79d5be4a4e --- /dev/null +++ b/test/rules/semicolon/never/test.ts.fix @@ -0,0 +1,227 @@ +declare module "*" +declare module "foo" {} +var x = 3 +a += b + +c = () => { +} + +d = function() { } + +console.log("i am adam, am i?") + +function xyz() { + return +} + +switch(xyz) { + case 1: + break + case 2: + continue +} + +throw new Error("some error") + +do { + var a = 4 +} while(x == 3) + +debugger + +import v = require("i") +module M { + export var x + [] + export var y = x; + [] + export function f(s: string): string + export function f(n: number): number + export function f(x: any) { return x } +} + +declare module "M" { + function f(): number + function g(): number +} + +function useStrictUnnecessarySemicolon() { + "use strict" + return null +} + +class MyClass { + public name : string + private index : number + private email : string + public initializedProperty = 6 + public initializedMethodProperty = () => { + return "hi" + } + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again" + } + + public initializedMethodProperty1Line = () => { return "hi" } + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again" } + public someMethod(): void + public someMethod(param): void + public someMethod(param?) { + return + } +} + +interface ITest { + foo?: string + bar: number + qux: string, + baz: boolean + bas: never} + +import {Router} from 'aurelia-router' + +import {Controller} from 'my-lib' + +// Edge cases when not omitting semicolon needs to be supported + +var a = 1; +("1" + "2").length + +var a = 1; +[].length + +var a = 1; ++"a" + +var a = 1; +-1 + +var a = 1 +;("1" + "2").length + +var a = 1 +;[].length + +var a = 1 +;+"a" + +var a = 1 +;-1 + +// For loops uses semicolons as well so make sure we aren't breaking those + +for (var i = 0; i < 10; ++i) { + // do something +} + +export default LoginPage +export default LoginPage + +export = Date +export = Date + +type t = number +type t = number + +if (true); +for(;;); + + + +switch(foo.bar) { + case 'header': header = foo; break + case 'sidebar': sidebar = foo; break + case 'track': track = foo; /* some comment */ break +} + +switch(foo.bar) { + case 'header': header = foo + break + case 'sidebar': sidebar = foo /* some comment + */ break + case 'track': track = foo // some comment + break +} + +const x = f(() => + 0); const y = 2 + +a = b +++c + +foo(); +(bar).foo() + +foo(); +(bar as Bar).foo() + +foo(); +bar.foo() + +foo(); +() => {} + +foo(); +`bar` + +foo(); +`bar${baz}` + +a; +/b/g + +a; +/=b/i + +function bar(foo) { if (foo) return true; return false } +function bar(foo) { if (foo) {return true} return false} + +class Foo { + public [foo] + ['moo'] + public bar = foo; + ['foo'] + public baz = () => true; + ['foobar'] + public baz2 = () => () => {return true} + ['foobarbaz'] + public bas = () => {return true} + ['barfoo'] + public moar = () => + true; + ['barbaz'] +} + +declare module "foo"; +{ /* don't remove semicolon, otherwise the shorthand module get's a body */ } + +function *gen() { + yield + [] + yield 1; + [] + if (foo) + return yield + [] + if (!foo) + return yield 1 || yield + [] + return yield 1; + [] +} + +var foo = () => {} +[] +var bar; var foo = function() {}; +[] + +var +[] + +const +[] + +let +[] diff --git a/test/rules/semicolon/never/test.ts.lint b/test/rules/semicolon/never/test.ts.lint new file mode 100644 index 00000000000..f99acd149a6 --- /dev/null +++ b/test/rules/semicolon/never/test.ts.lint @@ -0,0 +1,281 @@ +declare module "*"; + ~ [0] +declare module "foo" {} +var x = 3; + ~ [0] +a += b; + ~ [0] + +c = () => { +}; + ~ [0] + +d = function() { }; + ~ [0] + +console.log("i am adam, am i?"); + ~ [0] + +function xyz() { + return; + ~ [0] +} + +switch(xyz) { + case 1: + break; + ~ [0] + case 2: + continue; + ~ [0] +} + +throw new Error("some error"); + ~ [0] + +do { + var a = 4; + ~ [0] +} while(x == 3); + ~ [0] + +debugger; + ~ [0] + +import v = require("i"); + ~ [0] +module M { + export var x; + ~ [0] + [] + export var y = x; + [] + export function f(s: string): string; + ~ [0] + export function f(n: number): number + export function f(x: any) { return x; } + ~ [0] +} + +declare module "M" { + function f(): number; + ~ [0] + function g(): number +} + +function useStrictUnnecessarySemicolon() { + "use strict"; + ~ [0] + return null +} + +class MyClass { + public name : string; + ~ [0] + private index : number; + ~ [0] + private email : string + public initializedProperty = 6 + public initializedMethodProperty = () => { + return "hi"; + ~ [0] + }; + ~ [0] + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + ~ [0] + } + + public initializedMethodProperty1Line = () => { return "hi"; }; + ~ [0] + ~ [0] + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } + ~ [0] + public someMethod(): void; + ~ [0] + public someMethod(param): void + public someMethod(param?) { + return + }; + ~ [0] +}; + ~ [0] + +interface ITest { + foo?: string; + ~ [0] + bar: number; + ~ [0] + qux: string, + baz: boolean + bas: never;} + ~ [0] + +import {Router} from 'aurelia-router' + +import {Controller} from 'my-lib'; + ~ [0] + +// Edge cases when not omitting semicolon needs to be supported + +var a = 1; +("1" + "2").length + +var a = 1; +[].length + +var a = 1; ++"a" + +var a = 1; +-1 + +var a = 1 +;("1" + "2").length + +var a = 1 +;[].length + +var a = 1 +;+"a" + +var a = 1 +;-1 + +// For loops uses semicolons as well so make sure we aren't breaking those + +for (var i = 0; i < 10; ++i) { + // do something +} + +export default LoginPage; + ~ [0] +export default LoginPage + +export = Date; + ~ [0] +export = Date + +type t = number; + ~ [0] +type t = number + +if (true); + ~ [0] +for(;;); + +; +~ [0] + +switch(foo.bar) { + case 'header': header = foo; break + case 'sidebar': sidebar = foo; break + case 'track': track = foo; /* some comment */ break +} + +switch(foo.bar) { + case 'header': header = foo; + ~ [0] + break + case 'sidebar': sidebar = foo; /* some comment + ~ [0] + */ break + case 'track': track = foo; // some comment + ~ [0] + break +} + +const x = f(() => + 0); const y = 2 + +a = b; + ~ [0] +++c + +foo(); +(bar).foo() + +foo(); +(bar as Bar).foo() + +foo(); +bar.foo() + +foo(); +() => {} + +foo(); +`bar` + +foo(); +`bar${baz}` + +a; +/b/g + +a; +/=b/i + +function bar(foo) { if (foo) return true; return false } +function bar(foo) { if (foo) {return true;} return false;} + ~ [0] + ~ [0] + +class Foo { + public [foo]; + ~ [0] + ['moo'] + public bar = foo; + ['foo'] + public baz = () => true; + ['foobar'] + public baz2 = () => () => {return true}; + ~ [0] + ['foobarbaz'] + public bas = () => {return true}; + ~ [0] + ['barfoo'] + public moar = () => + true; + ['barbaz'] +} + +declare module "foo"; +{ /* don't remove semicolon, otherwise the shorthand module get's a body */ } + +function *gen() { + yield; + ~ [0] + [] + yield 1; + [] + if (foo) + return yield; + ~ [0] + [] + if (!foo) + return yield 1 || yield; + ~ [0] + [] + return yield 1; + [] +} + +var foo = () => {}; + ~ [0] +[] +var bar; var foo = function() {}; +[] + +var +[] + +const +[] + +let +[] + +[0]: Unnecessary semicolon \ No newline at end of file diff --git a/test/rules/semicolon/never/tslint.json b/test/rules/semicolon/never/tslint.json new file mode 100644 index 00000000000..94dc12a5077 --- /dev/null +++ b/test/rules/semicolon/never/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": [true, "never"] + } +} diff --git a/test/rules/semicolon/strict-bound-class-methods/test.ts.fix b/test/rules/semicolon/strict-bound-class-methods/test.ts.fix new file mode 100644 index 00000000000..faeb16b4135 --- /dev/null +++ b/test/rules/semicolon/strict-bound-class-methods/test.ts.fix @@ -0,0 +1,22 @@ +class MyClass { + public name : string; + private index : number; + private email : string; + + public initializedProperty = 6; + public initializedMethodProperty = () => { + return "hi"; + }; + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + }; + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; }; + public realMethod() {} + public multilineRealMethod() { + return "foo"; + } +} diff --git a/test/rules/semicolon/strict-bound-class-methods/test.ts.lint b/test/rules/semicolon/strict-bound-class-methods/test.ts.lint new file mode 100644 index 00000000000..2cc42b71ad6 --- /dev/null +++ b/test/rules/semicolon/strict-bound-class-methods/test.ts.lint @@ -0,0 +1,27 @@ +class MyClass { + public name : string + ~nil [Missing semicolon] + private index : number + ~nil [Missing semicolon] + private email : string; + + public initializedProperty = 6 + ~nil [Missing semicolon] + public initializedMethodProperty = () => { + return "hi"; + }; + + public initializedMethodPropertyWithoutSemicolon = () => { + return "hi again"; + } + ~nil [Missing semicolon] + + public initializedMethodProperty1Line = () => { return "hi"; }; + + public initializedMethodPropertyWithoutSemicolon1Line = () => { return "hi again"; } + ~nil [Missing semicolon] + public realMethod() {} + public multilineRealMethod() { + return "foo"; + } +} diff --git a/test/rules/semicolon/strict-bound-class-methods/tslint.json b/test/rules/semicolon/strict-bound-class-methods/tslint.json new file mode 100644 index 00000000000..f29bda5b7c7 --- /dev/null +++ b/test/rules/semicolon/strict-bound-class-methods/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": [true, "always", "strict-bound-class-methods"] + } +} diff --git a/test/rules/space-before-function-paren/always/test.ts.fix b/test/rules/space-before-function-paren/always/test.ts.fix new file mode 100644 index 00000000000..4322ebd07f9 --- /dev/null +++ b/test/rules/space-before-function-paren/always/test.ts.fix @@ -0,0 +1,75 @@ +// Anonymous +function () {} +function (): void { +} +function (a: string, cb: ()=>{}): void {} + +var f = function () {}; +var f = function (): void { +}; +var f = function (a: string, cb: ()=>{}): void {}; + +function () {} +var f = function () {}; + +// Named +function foobar (){} +function foobar (): void{ +} +function foobar (a: string, cb: ()=>{}): void{} + +var f = function foobar (){}; +var f = function foobar (): void{ +}; +var f = function foobar (a: string, cb: ()=>{}): void{}; + +function foobar () {} +var f = function foobar () {} + +// Default export (name ommited) +export default function () {} + +// Async Arrow +// ignore +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +async x => x; + +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +// Method +interface IMyInterface { + one (); + two (): void; + three (a: string, cb: ()=>{}): void; + four (); +} +class MyClass { + one () {} + two (): void { + } + three (a: string, cb: ()=>{}): void {} + four () {} +} + + +// Constructor +class MyClass { + constructor () {} +} +class MyClass { + constructor (): void { + } +} +class MyClass { + constructor (a: string, cb: ()=>{}): void {} +} + diff --git a/test/rules/space-before-function-paren/always/test.ts.lint b/test/rules/space-before-function-paren/always/test.ts.lint new file mode 100644 index 00000000000..5698a0baab7 --- /dev/null +++ b/test/rules/space-before-function-paren/always/test.ts.lint @@ -0,0 +1,104 @@ +// Anonymous +function() {} + ~ [space-before-function-paren] +function(): void { + ~ [space-before-function-paren] +} +function(a: string, cb: ()=>{}): void {} + ~ [space-before-function-paren] + +var f = function() {}; + ~ [space-before-function-paren] +var f = function(): void { + ~ [space-before-function-paren] +}; +var f = function(a: string, cb: ()=>{}): void {}; + ~ [space-before-function-paren] + +function () {} +var f = function () {}; + +// Named +function foobar(){} + ~ [space-before-function-paren] +function foobar(): void{ + ~ [space-before-function-paren] +} +function foobar(a: string, cb: ()=>{}): void{} + ~ [space-before-function-paren] + +var f = function foobar(){}; + ~ [space-before-function-paren] +var f = function foobar(): void{ + ~ [space-before-function-paren] +}; +var f = function foobar(a: string, cb: ()=>{}): void{}; + ~ [space-before-function-paren] + +function foobar() {} + ~ [space-before-function-paren] +var f = function foobar() {} + ~ [space-before-function-paren] + +// Default export (name ommited) +export default function() {} + ~ [space-before-function-paren] + +// Async Arrow +// ignore +() => {}; +var arrow = () => {}; + +async() => {}; + ~ [space-before-function-paren] +var arrow = async() => {}; + ~ [space-before-function-paren] + +async x => x; + +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +// Method +interface IMyInterface { + one(); + ~ [space-before-function-paren] + two(): void; + ~ [space-before-function-paren] + three(a: string, cb: ()=>{}): void; + ~ [space-before-function-paren] + four(); + ~ [space-before-function-paren] +} +class MyClass { + one() {} + ~ [space-before-function-paren] + two(): void { + ~ [space-before-function-paren] + } + three(a: string, cb: ()=>{}): void {} + ~ [space-before-function-paren] + four() {} + ~ [space-before-function-paren] +} + + +// Constructor +class MyClass { + constructor() {} + ~ [space-before-function-paren] +} +class MyClass { + constructor(): void { + ~ [space-before-function-paren] + } +} +class MyClass { + constructor(a: string, cb: ()=>{}): void {} + ~ [space-before-function-paren] +} + +[space-before-function-paren]: Missing whitespace before function parens diff --git a/test/rules/space-before-function-paren/always/tslint.json b/test/rules/space-before-function-paren/always/tslint.json new file mode 100644 index 00000000000..57c0714d282 --- /dev/null +++ b/test/rules/space-before-function-paren/always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "space-before-function-paren": true + } +} diff --git a/test/rules/space-before-function-paren/mixed/test.ts.fix b/test/rules/space-before-function-paren/mixed/test.ts.fix new file mode 100644 index 00000000000..d087d46fe17 --- /dev/null +++ b/test/rules/space-before-function-paren/mixed/test.ts.fix @@ -0,0 +1,65 @@ +// Anonymous +var f = function () {}; +var f = function (): void { +}; +var f = function (a: string, cb: ()=>{}): void {}; + +function () {} +var f = function () {}; + +// Named +function foobar(){} +function foobar(): void{ +} +function foobar(a: string, cb: ()=>{}): void{} + +var f = function foobar(){}; +var f = function foobar(): void{ +}; +var f = function foobar(a: string, cb: ()=>{}): void{}; + +function foobar() {} +var f = function foobar() {} + +// Default export (name ommited) +export default function () {} + +// Async Arrow +// ignore +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +// Method +interface IMyInterface { + one(); + two(): void; + three(a: string, cb: ()=>{}): void; + four(); +} +class MyClass { + one() {} + two(): void { + } + three(a: string, cb: ()=>{}): void {} + four() {} +} + + +// Constructor ignored +class MyClass { + constructor () {} +} +class MyClass { + constructor(): void { + } +} + diff --git a/test/rules/space-before-function-paren/mixed/test.ts.lint b/test/rules/space-before-function-paren/mixed/test.ts.lint new file mode 100644 index 00000000000..e7e4379d5f6 --- /dev/null +++ b/test/rules/space-before-function-paren/mixed/test.ts.lint @@ -0,0 +1,89 @@ +// Anonymous +var f = function() {}; + ~ [missing-space] +var f = function(): void { + ~ [missing-space] +}; +var f = function(a: string, cb: ()=>{}): void {}; + ~ [missing-space] + +function () {} +var f = function () {}; + +// Named +function foobar (){} + ~ [invalid-space] +function foobar (): void{ + ~ [invalid-space] +} +function foobar (a: string, cb: ()=>{}): void{} + ~ [invalid-space] + +var f = function foobar (){}; + ~ [invalid-space] +var f = function foobar (): void{ + ~ [invalid-space] +}; +var f = function foobar (a: string, cb: ()=>{}): void{}; + ~ [invalid-space] + +function foobar () {} + ~ [invalid-space] +var f = function foobar () {} + ~ [invalid-space] + +// Default export (name ommited) +export default function() {} + ~ [missing-space] + +// Async Arrow +// ignore +() => {}; +var arrow = () => {}; + +async() => {}; + ~ [missing-space] +var arrow = async() => {}; + ~ [missing-space] + +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +// Method +interface IMyInterface { + one (); + ~ [invalid-space] + two (): void; + ~ [invalid-space] + three (a: string, cb: ()=>{}): void; + ~ [invalid-space] + four (); + ~ [invalid-space] +} +class MyClass { + one () {} + ~ [invalid-space] + two (): void { + ~ [invalid-space] + } + three (a: string, cb: ()=>{}): void {} + ~ [invalid-space] + four () {} + ~ [invalid-space] +} + + +// Constructor ignored +class MyClass { + constructor () {} +} +class MyClass { + constructor(): void { + } +} + +[missing-space]: Missing whitespace before function parens +[invalid-space]: Spaces before function parens are disallowed diff --git a/test/rules/space-before-function-paren/mixed/tslint.json b/test/rules/space-before-function-paren/mixed/tslint.json new file mode 100644 index 00000000000..f7402bba11a --- /dev/null +++ b/test/rules/space-before-function-paren/mixed/tslint.json @@ -0,0 +1,14 @@ +{ + "rules": { + "space-before-function-paren": [ + true, + { + "anonymous": "always", + "asyncArrow": "always", + "constructor": "ignore", + "method": "never", + "named": "never" + } + ] + } +} diff --git a/test/rules/space-before-function-paren/never/test.ts.fix b/test/rules/space-before-function-paren/never/test.ts.fix new file mode 100644 index 00000000000..13090928064 --- /dev/null +++ b/test/rules/space-before-function-paren/never/test.ts.fix @@ -0,0 +1,76 @@ +// Anonymous +function() {} +function(): void { +} +function(a: string, cb: ()=>{}): void {} + +var f = function() {}; +var f = function(): void { +}; +var f = function(a: string, cb: ()=>{}): void {}; + +function () {} +var f = function () {}; + +// Named +function foobar(){} +function foobar(): void{ +} +function foobar(a: string, cb: ()=>{}): void{} + +var f = function foobar(){}; +var f = function foobar(): void{ +}; +var f = function foobar(a: string, cb: ()=>{}): void{}; + +function foobar() {} +var f = function foobar() {} + +// Default export (name ommited) +export default function() {} + +// Async Arrow +// ignore +() => {}; +var arrow = () => {}; + +async() => {}; +var arrow = async() => {}; + +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +// Method +interface IMyInterface { + one(); + two(): void; + three(a: string, cb: ()=>{}): void; + four(); +} +class MyClass { + one() {} + two(): void { + } + three(a: string, cb: ()=>{}): void {} + four() {} + + get a() {} + set a() {} +} + + +// Constructor +class MyClass { + constructor() {} +} +class MyClass { + constructor(): void { + } +} +class MyClass { + constructor(a: string, cb: ()=>{}): void {} +} + diff --git a/test/rules/space-before-function-paren/never/test.ts.lint b/test/rules/space-before-function-paren/never/test.ts.lint new file mode 100644 index 00000000000..58aae5922ef --- /dev/null +++ b/test/rules/space-before-function-paren/never/test.ts.lint @@ -0,0 +1,107 @@ +// Anonymous +function () {} + ~ [0] +function (): void { + ~ [0] +} +function (a: string, cb: ()=>{}): void {} + ~ [0] + +var f = function () {}; + ~ [0] +var f = function (): void { + ~ [0] +}; +var f = function (a: string, cb: ()=>{}): void {}; + ~ [0] + +function () {} +var f = function () {}; + +// Named +function foobar (){} + ~ [0] +function foobar (): void{ + ~ [0] +} +function foobar (a: string, cb: ()=>{}): void{} + ~ [0] + +var f = function foobar (){}; + ~ [0] +var f = function foobar (): void{ + ~ [0] +}; +var f = function foobar (a: string, cb: ()=>{}): void{}; + ~ [0] + +function foobar () {} + ~ [0] +var f = function foobar () {} + ~ [0] + +// Default export (name ommited) +export default function () {} + ~ [0] + +// Async Arrow +// ignore +() => {}; +var arrow = () => {}; + +async () => {}; + ~ [0] +var arrow = async () => {}; + ~ [0] + +() => {}; +var arrow = () => {}; + +async () => {}; +var arrow = async () => {}; + +// Method +interface IMyInterface { + one (); + ~ [0] + two (): void; + ~ [0] + three (a: string, cb: ()=>{}): void; + ~ [0] + four (); + ~ [0] +} +class MyClass { + one () {} + ~ [0] + two (): void { + ~ [0] + } + three (a: string, cb: ()=>{}): void {} + ~ [0] + four () {} + ~ [0] + + get a () {} + ~ [0] + set a () {} + ~ [0] +} + + +// Constructor +class MyClass { + constructor () {} + ~ [0] +} +class MyClass { + constructor (): void { + ~ [0] + } +} +class MyClass { + constructor (a: string, cb: ()=>{}): void {} + ~ [0] +} + +[0]: Spaces before function parens are disallowed diff --git a/test/rules/space-before-function-paren/never/tslint.json b/test/rules/space-before-function-paren/never/tslint.json new file mode 100644 index 00000000000..7c3e5f86d59 --- /dev/null +++ b/test/rules/space-before-function-paren/never/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "space-before-function-paren": [true, "never"] + } +} diff --git a/test/rules/space-within-parens/force-one-space/test.ts.fix b/test/rules/space-within-parens/force-one-space/test.ts.fix new file mode 100644 index 00000000000..542a92bfd4a --- /dev/null +++ b/test/rules/space-within-parens/force-one-space/test.ts.fix @@ -0,0 +1,11 @@ +// export statement +export function rgb2lab( r : number, g : number, b : number ) : { L : number; a : number; b: number } { + var xyz = Conversion.rgb2xyz( r, g, b ); + return Conversion.xyz2lab( xyz.x, xyz.y, xyz.z ); +} + +foo( /*no param*/ ); + +// empty parens are always allowed +foo(); + diff --git a/test/rules/space-within-parens/force-one-space/test.ts.lint b/test/rules/space-within-parens/force-one-space/test.ts.lint new file mode 100644 index 00000000000..5ec16cbe06e --- /dev/null +++ b/test/rules/space-within-parens/force-one-space/test.ts.lint @@ -0,0 +1,21 @@ +// export statement +export function rgb2lab(r : number, g : number, b : number) : { L : number; a : number; b: number } { + ~nil [0] + ~nil [0] + var xyz = Conversion.rgb2xyz(r, g, b ); + ~nil [0] + ~ [1] + return Conversion.xyz2lab( xyz.x, xyz.y, xyz.z); + ~~ [1] + ~nil [0] +} + +foo(/*no param*/); + ~nil [0] + ~nil [0] + +// empty parens are always allowed +foo(); + +[0]: Needs 1 whitespace within parentheses +[1]: No more than 1 whitespace within parentheses allowed diff --git a/test/rules/space-within-parens/force-one-space/tslint.json b/test/rules/space-within-parens/force-one-space/tslint.json new file mode 100644 index 00000000000..5727ff26f5c --- /dev/null +++ b/test/rules/space-within-parens/force-one-space/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "space-within-parens": [true, 1] + } +} diff --git a/test/rules/space-within-parens/force-two-spaces/test.ts.fix b/test/rules/space-within-parens/force-two-spaces/test.ts.fix new file mode 100644 index 00000000000..28b39ff3820 --- /dev/null +++ b/test/rules/space-within-parens/force-two-spaces/test.ts.fix @@ -0,0 +1,28 @@ +// simple expression +var x = [{ + a: 1, + b: 2, + d: 34, + c: ( a + b ), +}]; + +// simple expression on one liner +var b = [{a: 1, b: 2, d: 34, c: ( a + b )}]; + +// function parameters +function foo( bar: string, baz: string ); + +// conditional & nested expression +if ( x === y ) { + return ( {result: true, error: ( x + y )} ); +} + +// expected number of spaces provided +new Foo( ); + +// empty parens are always allowed +new Foo(); + +// Missing a space +new Foo( ); + diff --git a/test/rules/space-within-parens/force-two-spaces/test.ts.lint b/test/rules/space-within-parens/force-two-spaces/test.ts.lint new file mode 100644 index 00000000000..268505cbf01 --- /dev/null +++ b/test/rules/space-within-parens/force-two-spaces/test.ts.lint @@ -0,0 +1,42 @@ +// simple expression +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b ), + ~nil [1] + ~ [2] +}]; + +// simple expression on one liner +var b = [{a: 1, b: 2, d: 34, c: ( a + b)}]; + ~ [2] + ~nil [1] + +// function parameters +function foo( bar: string, baz: string); + ~nil [0] + ~nil [1] + +// conditional & nested expression +if (x === y) { + ~nil [1] + ~nil [1] + return ({result: true, error: ( x + y )} ); + ~nil [1] + ~ [2] +} + +// expected number of spaces provided +new Foo( ); + +// empty parens are always allowed +new Foo(); + +// Missing a space +new Foo( ); + ~nil [0] + +[0]: Needs 1 whitespace within parentheses +[1]: Needs 2 whitespaces within parentheses +[2]: No more than 2 whitespaces within parentheses allowed diff --git a/test/rules/space-within-parens/force-two-spaces/tslint.json b/test/rules/space-within-parens/force-two-spaces/tslint.json new file mode 100644 index 00000000000..d9b45796039 --- /dev/null +++ b/test/rules/space-within-parens/force-two-spaces/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "space-within-parens": [true, 2] + } +} diff --git a/test/rules/space-within-parens/no-space/test.ts.fix b/test/rules/space-within-parens/no-space/test.ts.fix new file mode 100644 index 00000000000..c00e7d19386 --- /dev/null +++ b/test/rules/space-within-parens/no-space/test.ts.fix @@ -0,0 +1,37 @@ +// simple call +console.clear(); + +// multiline call, this should be skipped +foo( + first, + second, +); + +// conditional +if (process.env === 'production') { + console.log('start'); +} + +// conditional and nested +if (x === 'string' && + y === 'object') { + + // skip this conditional + if ( + true === true && false !=== false + ) { + // load + foo(); + } + console.log('test'); +} + +// other expresions +switch (typeof x) { + default: + break; +} + +// empty parens are always allowed +foo(); + diff --git a/test/rules/space-within-parens/no-space/test.ts.lint b/test/rules/space-within-parens/no-space/test.ts.lint new file mode 100644 index 00000000000..fcb1215a5fa --- /dev/null +++ b/test/rules/space-within-parens/no-space/test.ts.lint @@ -0,0 +1,50 @@ +// simple call +console.clear( ); + ~ [0] + +// multiline call, this should be skipped +foo( + first, + second, +); + +// conditional +if ( process.env === 'production' ) { + ~ [0] + ~ [0] + console.log( 'start' ); + ~ [0] + ~ [0] +} + +// conditional and nested +if ( x === 'string' && + ~~ [0] + y === 'object' ) { + ~~ [0] + + // skip this conditional + if ( + true === true && false !=== false + ) { + // load + foo( ); + ~ [0] + } + console.log( 'test' ); + ~ [0] + ~~ [0] +} + +// other expresions +switch ( typeof x ) { + ~~ [0] + ~ [0] + default: + break; +} + +// empty parens are always allowed +foo(); + +[0]: Whitespace within parentheses is not allowed diff --git a/test/rules/space-within-parens/no-space/tslint.json b/test/rules/space-within-parens/no-space/tslint.json new file mode 100644 index 00000000000..4b2d0644357 --- /dev/null +++ b/test/rules/space-within-parens/no-space/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "space-within-parens": [true, 0] + } +} diff --git a/test/rules/static-this/test.ts.fix b/test/rules/static-this/test.ts.fix new file mode 100644 index 00000000000..5d40d646df2 --- /dev/null +++ b/test/rules/static-this/test.ts.fix @@ -0,0 +1,77 @@ +class StaticThis { + static value = 0; + static staticValue = StaticThis.value; + + static _color = undefined; + + static get color() { + return StaticThis._color; + } + + static set color(color) { + StaticThis._color = color; + } + + static getTypeOf() { + return StaticThis; + } + + private _value = 5; + + getValue() { + return this._value; + } + + get length() { + return this._value; + } + + set length(value) { + this._value = value; + } +} + +class Child extends StaticThis { + static word = 'Hello'; + static staticValue = Child.word; + + static getTypeOf() { + return Child; + } +} + +const AnonymClass = class { + static getTypeOf() { + return this; + } +} + +class AnonymClassChild extends AnonymClass { + static getTypeOf() { + return AnonymClassChild; + } +} + +const NamedClass = class Name { + static getTypeOf() { + return Name; + } +} + +class NamedClassChild extends NamedClass { + static getTypeOf() { + return NamedClassChild; + } +} + +interface Bar {} + +class Foo { + public static higherOrderComponent(): any { + return class implements Bar { + public constructor() { + console.log(this); + } + }; + } +} diff --git a/test/rules/static-this/test.ts.lint b/test/rules/static-this/test.ts.lint new file mode 100644 index 00000000000..4666f61d9a5 --- /dev/null +++ b/test/rules/static-this/test.ts.lint @@ -0,0 +1,87 @@ +class StaticThis { + static value = 0; + static staticValue = this.value; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + + static _color = undefined; + + static get color() { + return this._color; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } + + static set color(color) { + this._color = color; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } + + static getTypeOf() { + return this; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } + + private _value = 5; + + getValue() { + return this._value; + } + + get length() { + return this._value; + } + + set length(value) { + this._value = value; + } +} + +class Child extends StaticThis { + static word = 'Hello'; + static staticValue = this.word; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + + static getTypeOf() { + return this; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } +} + +const AnonymClass = class { + static getTypeOf() { + return this; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } +} + +class AnonymClassChild extends AnonymClass { + static getTypeOf() { + return this; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } +} + +const NamedClass = class Name { + static getTypeOf() { + return this; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } +} + +class NamedClassChild extends NamedClass { + static getTypeOf() { + return this; + ~~~~ [Use the parent class name instead of `this` when in a `static` context.] + } +} + +interface Bar {} + +class Foo { + public static higherOrderComponent(): any { + return class implements Bar { + public constructor() { + console.log(this); + } + }; + } +} diff --git a/test/rules/static-this/tslint.json b/test/rules/static-this/tslint.json new file mode 100644 index 00000000000..76bded512b3 --- /dev/null +++ b/test/rules/static-this/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "static-this": true + } +} diff --git a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint new file mode 100644 index 00000000000..1b97b9d01fd --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/test.ts.lint @@ -0,0 +1,36 @@ +declare function get(): T; + +declare const bu: boolean | undefined; +if (get()) {} +if (get()) {} +if (get()) {} +if (get()) {} + +if (get()) {} +if (get()) {} +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')] +if (get()) {} + ~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')] + +if (get()) {} + ~~~~~~~~~~~ [err % ("'if' condition", 'is always falsy')] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'could be undefined')] +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'could be null')] + +// Type of the condition is actually boolean | RegExp, but OK since we check each part separately. +if (get() || get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("operand for the '||' operator", 'could be undefined')] + +// This still fails of course! +if (get() || get()) {} + ~~~~~~~~~~~~~ [err % ("operand for the '||' operator", 'is always truthy')] + ~~~~~~~~~~~~~ [err % ("operand for the '||' operator", 'is always truthy')] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [err % ("'if' condition", 'could be undefined')] + +[err]: This type is not allowed in the %s because it %s. Allowed types are boolean or boolean-or-undefined. \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json new file mode 100644 index 00000000000..60445d1d0fc --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-boolean-undefined-union/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-boolean-or-undefined"] + } +} diff --git a/test/rules/strict-boolean-expressions/allow-enum/test.ts.lint b/test/rules/strict-boolean-expressions/allow-enum/test.ts.lint new file mode 100644 index 00000000000..7ff3a6f39bf --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-enum/test.ts.lint @@ -0,0 +1,6 @@ +declare function get(): T; + +if (get()) {} + +enum E {} +if (get()) {} diff --git a/test/rules/strict-boolean-expressions/allow-enum/tsconfig.json b/test/rules/strict-boolean-expressions/allow-enum/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-enum/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-enum/tslint.json b/test/rules/strict-boolean-expressions/allow-enum/tslint.json new file mode 100644 index 00000000000..e7872f36cdb --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-enum/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-enum"] + } +} diff --git a/test/rules/strict-boolean-expressions/allow-mix/test.ts.lint b/test/rules/strict-boolean-expressions/allow-mix/test.ts.lint new file mode 100644 index 00000000000..33de775911f --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-mix/test.ts.lint @@ -0,0 +1,20 @@ +declare function get(): T; + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be a number. Allowed types are boolean, undefined-union, or string.] + +if (get()) {} + +if (get()) {} + +if (get()) {} +if (get()) {} +if (get()) {} + +if (get<"" | "foo">()) {} + +// Mix of truthy values OK +if (get<"foo" | "bar" | undefined>()) {} + +// Mix of falsy values not OK +if (get<"" | boolean>()) {} diff --git a/test/rules/strict-boolean-expressions/allow-mix/tsconfig.json b/test/rules/strict-boolean-expressions/allow-mix/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-mix/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-mix/tslint.json b/test/rules/strict-boolean-expressions/allow-mix/tslint.json new file mode 100644 index 00000000000..0a36db5f45a --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-mix/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-string", "allow-undefined-union", "allow-mix"] + } +} diff --git a/test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint b/test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint new file mode 100644 index 00000000000..f74cc3614b9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-null-union/test.ts.lint @@ -0,0 +1,12 @@ +declare function get(): T; + +if (get()) {} + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or null-union.] + +if (get()) {} + ~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or null-union.] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be undefined. Allowed types are boolean or null-union.] diff --git a/test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json b/test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-null-union/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-null-union/tslint.json b/test/rules/strict-boolean-expressions/allow-null-union/tslint.json new file mode 100644 index 00000000000..68d81e95e18 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-null-union/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-null-union"] + } +} diff --git a/test/rules/strict-boolean-expressions/allow-number/test.ts.lint b/test/rules/strict-boolean-expressions/allow-number/test.ts.lint new file mode 100644 index 00000000000..4252ea97086 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-number/test.ts.lint @@ -0,0 +1,19 @@ +declare function get(): T; + +if (get()) {} + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or number.] + +enum E {} +if (get()) {} + ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Allowed types are boolean or number.] + +if (get<1 | 2>()) {} + ~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Allowed types are boolean or number.] + +if (get<0>()) {} + ~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or number.] + +if (get<0 | 1>()) {} + diff --git a/test/rules/strict-boolean-expressions/allow-number/tsconfig.json b/test/rules/strict-boolean-expressions/allow-number/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-number/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-number/tslint.json b/test/rules/strict-boolean-expressions/allow-number/tslint.json new file mode 100644 index 00000000000..e11c8f93fcc --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-number/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-number"] + } +} diff --git a/test/rules/strict-boolean-expressions/allow-string/test.ts.lint b/test/rules/strict-boolean-expressions/allow-string/test.ts.lint new file mode 100644 index 00000000000..89930bf3052 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-string/test.ts.lint @@ -0,0 +1,14 @@ +declare function get(): T; + +if (get()) {} + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or string.] + +if (get<"foo" | "bar">()) {} + ~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Allowed types are boolean or string.] + +if (get<"">()) {} + ~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or string.] + +if (get<"foo" | "">()) {} diff --git a/test/rules/strict-boolean-expressions/allow-string/tsconfig.json b/test/rules/strict-boolean-expressions/allow-string/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-string/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-string/tslint.json b/test/rules/strict-boolean-expressions/allow-string/tslint.json new file mode 100644 index 00000000000..356b40389f6 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-string/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-string"] + } +} diff --git a/test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint b/test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint new file mode 100644 index 00000000000..12ff9344f46 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-undefined-union/test.ts.lint @@ -0,0 +1,28 @@ +declare function get(): T; + +if (get()) {} + +declare const bu: boolean | undefined; +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean or undefined-union.] + +// If it's always undefined, testing for it is wrong. +if (get()) {} + ~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or undefined-union.] + +if (get()) {} + ~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always falsy. Allowed types are boolean or undefined-union.] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be null. Allowed types are boolean or undefined-union.] + +// Type of the condition is actually boolean | RegExp, but OK since we check each part separately. +if (get() || get()) {} + +// This still fails of course! +if (get() || get()) {} + ~~~~~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Allowed types are boolean or undefined-union.] + ~~~~~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Allowed types are boolean or undefined-union.] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be a number. Allowed types are boolean or undefined-union.] diff --git a/test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json b/test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-undefined-union/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json b/test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json new file mode 100644 index 00000000000..ea0d9855d30 --- /dev/null +++ b/test/rules/strict-boolean-expressions/allow-undefined-union/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-undefined-union"] + } +} diff --git a/test/rules/strict-boolean-expressions/default/test.ts.lint b/test/rules/strict-boolean-expressions/default/test.ts.lint new file mode 100644 index 00000000000..b1b1cfff6b5 --- /dev/null +++ b/test/rules/strict-boolean-expressions/default/test.ts.lint @@ -0,0 +1,235 @@ +class C { } +enum MyEnum { + A, B, C +} +let anyType: {}; +let boolType: boolean; +let boolType2: boolean; +let bwrapType: Boolean; +let numType = 9; +let strType = "string"; +let objType = new Object(); +let classType = new C(); +let enumType = MyEnum.A; +let boolFn = () => { return true; }; +let strFn = () => { return strType; }; +let numFn = () => { return numType; }; +let boolExpr = (strType !== undefined); + +/*** Binary Expressions ***/ +/*** Invalid Boolean Expressions ***/ +classType && boolType; +~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] +anyType && boolType; +~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] +numType && boolType; +~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] +boolType && strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] +boolType && objType && enumType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] + ~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is an enum. Only booleans are allowed.] +bwrapType && boolType; +~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] + +boolType || classType; + ~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] +boolType || anyType; + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] +boolType || numType; + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] +strType || boolType; +~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] +bwrapType || boolType; +~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] +objType || boolType || enumType; +~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] + ~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is an enum. Only booleans are allowed.] + +boolExpr && strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] +numType || boolExpr; +~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] +numType && boolExpr || strType; +~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] +bwrapType || boolExpr && bwrapType; +~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] + ~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] + +/*** Valid Boolean Expressions ***/ +boolType && boolType2; +boolExpr || boolType; +(numType > 0) && boolFn(); +(strType !== "bool") && boolExpr; +(numType > 0) && (strType !== "bool"); +(strType !== undefined) || (numType < 0); + +/*** ConditionalExpression ***/ +/*** Invalid ***/ +strType ? strType : numType; +~~~~~~~ [This type is not allowed in the condition because it is a string. Only booleans are allowed.] +numType ? numType : numFn(); +~~~~~~~ [This type is not allowed in the condition because it is a number. Only booleans are allowed.] +objType ? objType : boolExpr; +~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.] +classType ? strType : undefined; +~~~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.] +bwrapType ? 1 : 0; +~~~~~~~~~ [This type is not allowed in the condition because it is always truthy. Only booleans are allowed.] +enumType ? 0 : 1; +~~~~~~~~ [This type is not allowed in the condition because it is an enum. Only booleans are allowed.] + +/*** Valid ***/ +boolFn() ? numType : strType; +boolType ? strType : undefined; + +/*** PrefixUnary Expressions ***/ +/*** Invalid ***/ +!!numType; + ~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is a number. Only booleans are allowed.] +!strType; + ~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is a string. Only booleans are allowed.] +!objType; + ~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.] +!enumType; + ~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is an enum. Only booleans are allowed.] +!!classType; + ~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.] +!bwrapType; + ~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always truthy. Only booleans are allowed.] +!!undefined; + ~~~~~~~~~ [This type is not allowed in the operand for the '!' operator because it is always falsy. Only booleans are allowed.] + +/*** Valid ***/ +!!boolFn(); +!boolExpr; +!!boolType; + +/*** If Statement ***/ +/*** Invalid ***/ +if (numType) { } + ~~~~~~~ [This type is not allowed in the 'if' condition because it is a number. Only booleans are allowed.] +if (objType) { } + ~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] +if (strType) { } + ~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Only booleans are allowed.] +if (bwrapType) { } + ~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] +if (strFn()) { } + ~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Only booleans are allowed.] +if (MyEnum.A) { } + ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Only booleans are allowed.] +if (classType) { } + ~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] + +/*** Valid ***/ +if (boolFn()) { } +if (boolExpr) { } +if (boolType) { } + +/*** While Statement ***/ +/*** Invalid ***/ +while (numType) { break; } + ~~~~~~~ [This type is not allowed in the 'while' condition because it is a number. Only booleans are allowed.] +while (objType) { break; } + ~~~~~~~ [This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.] +while (strType) { break; } + ~~~~~~~ [This type is not allowed in the 'while' condition because it is a string. Only booleans are allowed.] +while (strFn()) { break; } + ~~~~~~~ [This type is not allowed in the 'while' condition because it is a string. Only booleans are allowed.] +while (bwrapType) { break; } + ~~~~~~~~~ [This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.] +while (MyEnum.A) { break; } + ~~~~~~~~ [This type is not allowed in the 'while' condition because it is an enum. Only booleans are allowed.] +while (classType) { break; } + ~~~~~~~~~ [This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.] + +/*** Valid ***/ +while (boolFn()) { break; } +while (boolExpr) { break; } +while (boolType) { break; } + +/*** Do Statement ***/ +/*** Invalid ***/ +do { break; } while (numType); + ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is a number. Only booleans are allowed.] +do { break; } while (objType); + ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is always truthy. Only booleans are allowed.] +do { break; } while (strType); + ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is a string. Only booleans are allowed.] +do { break; } while (bwrapType); + ~~~~~~~~~ [This type is not allowed in the 'do-while' condition because it is always truthy. Only booleans are allowed.] +do { break; } while (strFn()); + ~~~~~~~ [This type is not allowed in the 'do-while' condition because it is a string. Only booleans are allowed.] +do { break; } while (MyEnum.A); + ~~~~~~~~ [This type is not allowed in the 'do-while' condition because it is an enum. Only booleans are allowed.] +do { break; } while (classType); + ~~~~~~~~~ [This type is not allowed in the 'do-while' condition because it is always truthy. Only booleans are allowed.] + +/*** Valid ***/ +do { break; } while (boolFn()); +do { break; } while (boolExpr); +do { break; } while (boolType); + +/*** For Statement ***/ +/*** Invalid ***/ +for (let j = 0; j; j++) { break; } + ~ [This type is not allowed in the 'for' condition because it is a number. Only booleans are allowed.] +/*** Valid ***/ +for (let j = 0; j > numType; j++) { break; } + +// Allow always-truthy or always-falsy in the case of 'true' and 'false' +while (true) {} +if (false) {} +// Do *not* allow 'true' in a union +declare var trueOrDate: true | Date; +if (trueOrDate) {} + ~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. Only booleans are allowed.] + +declare var a: any; +// Allow 'any' +if (a) {} + +let bool1:boolean = true +let bool2:boolean = true +let obj:{}|undefined = {} + + bool1 && obj && bool2 + ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] + bool1 && bool2 && obj + ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] + boolExpr && numType || strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] + boolExpr || numType || strType; + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] + boolExpr || numType && strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] + boolExpr && numType && strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] + boolExpr || boolType && strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a string. Only booleans are allowed.] + boolExpr || boolType || strType; + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] + boolExpr && boolType || strType; + ~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] + + bool1 && obj && bool2 + ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] + + obj && bool2 && obj + ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] + ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] + + obj || bool2 || obj + ~~~ [This type is not allowed in the operand for the '||' operator because it could be undefined. Only booleans are allowed.] + ~~~ [This type is not allowed in the operand for the '||' operator because it could be undefined. Only booleans are allowed.] + + obj || bool2 && obj + ~~~ [This type is not allowed in the operand for the '||' operator because it could be undefined. Only booleans are allowed.] + ~~~ [This type is not allowed in the operand for the '&&' operator because it could be undefined. Only booleans are allowed.] + diff --git a/test/rules/strict-boolean-expressions/default/tsconfig.json b/test/rules/strict-boolean-expressions/default/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/default/tslint.json b/test/rules/strict-boolean-expressions/default/tslint.json new file mode 100644 index 00000000000..153f37560a7 --- /dev/null +++ b/test/rules/strict-boolean-expressions/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": true + } +} diff --git a/test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint b/test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint new file mode 100644 index 00000000000..e1d41ea2198 --- /dev/null +++ b/test/rules/strict-boolean-expressions/ignore-rhs/test.ts.lint @@ -0,0 +1,78 @@ +class C { } +enum MyEnum { + A, B, C +} +let anyType: {}; +let boolType: boolean; +let boolType2: boolean; +let bwrapType: Boolean; +let numType = 9; +let strType = "string"; +let objType = new Object(); +let classType = new C(); +let enumType = MyEnum.A; +let boolFn = () => { return true; }; +let strFn = () => { return strType; }; +let numFn = () => { return numType; }; +let boolExpr = (strType !== undefined); + +/*** Binary Expressions ***/ +/*** Invalid Boolean Expressions ***/ +classType && boolType; +~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] +anyType && boolType; +~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] +numType && boolType; +~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] +boolType && strType; + +boolType && objType && enumType; + +boolType && objType || enumType; + +boolType || objType && enumType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] + +boolType || objType || enumType; + +bwrapType && boolType; +~~~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is always truthy. Only booleans are allowed.] + +boolType || classType; +boolType || anyType; +boolType || numType; + +strType || boolType; +~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a string. Only booleans are allowed.] + +bwrapType || boolType; +~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] + +objType || boolType || enumType; +~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] + +boolExpr && strType; + +numType || boolExpr; +~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is a number. Only booleans are allowed.] + +numType && boolExpr || strType; +~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] + +bwrapType || boolExpr && bwrapType; +~~~~~~~~~ [This type is not allowed in the operand for the '||' operator because it is always truthy. Only booleans are allowed.] + +let bool1:boolean = true +let bool2:boolean = true +let obj:{}|undefined = {} + +bool1 && obj && bool2 +bool1 && bool2 && obj +boolExpr && numType || strType; +boolExpr || numType || strType; +boolExpr || numType && strType; + ~~~~~~~ [This type is not allowed in the operand for the '&&' operator because it is a number. Only booleans are allowed.] +boolExpr && numType && strType; +boolExpr || boolType && strType; +boolExpr || boolType || strType; +boolExpr && boolType || strType; diff --git a/test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json b/test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json new file mode 100644 index 00000000000..c4d430eb449 --- /dev/null +++ b/test/rules/strict-boolean-expressions/ignore-rhs/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} diff --git a/test/rules/strict-boolean-expressions/ignore-rhs/tslint.json b/test/rules/strict-boolean-expressions/ignore-rhs/tslint.json new file mode 100644 index 00000000000..9e38e7b80ff --- /dev/null +++ b/test/rules/strict-boolean-expressions/ignore-rhs/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "ignore-rhs"] + } +} diff --git a/test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint b/test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint new file mode 100644 index 00000000000..884aa5fcaa1 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-allow-mix/test.ts.lint @@ -0,0 +1,28 @@ +declare function get(): T; + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be a number. Allowed types are boolean, undefined-union, or string.] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [mix] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~~ [mix] + +if (get()) {} +if (get()) {} +if (get()) {} + +if (get<"" | "foo">()) {} + +// Mix of truthy values OK +if (get<"foo" | "bar" | undefined>()) {} + +// Mix of falsy values not OK +if (get<"" | boolean>()) {} + ~~~~~~~~~~~~~~~~~~~ [mix] + +// Mix of 1 falsy with any number of truthy OK +if (get()) {} + +[mix]: This type is not allowed in the 'if' condition because it unions more than one truthy/falsy type. Allowed types are boolean, undefined-union, or string. diff --git a/test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json b/test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-allow-mix/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-boolean-expressions/no-allow-mix/tslint.json b/test/rules/strict-boolean-expressions/no-allow-mix/tslint.json new file mode 100644 index 00000000000..01f7ab6fe2a --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-allow-mix/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-string", "allow-undefined-union"] + } +} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint new file mode 100644 index 00000000000..b050100493c --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/test.ts.lint @@ -0,0 +1,17 @@ +declare function get(): T; + +// Everything except string/number/enum is allowed. +if (get<{ x: number }>) {} + +if (get()) {} + ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Allowed types are boolean or null-union.] + +if (get()) {} + ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a number. Allowed types are boolean or null-union.] + +enum E {} +if (get()) {} + ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Allowed types are boolean or null-union.] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be an enum. Allowed types are boolean or null-union.] diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json new file mode 100644 index 00000000000..32e6931d462 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "strict": true, + "strictNullChecks": false + } +} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json new file mode 100644 index 00000000000..68d81e95e18 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks-allow-null-union/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-null-union"] + } +} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint new file mode 100644 index 00000000000..4b4f8876962 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/test.ts.lint @@ -0,0 +1,9 @@ +declare function get(): T; + +if (get()) {} + +if (get()) {} + +enum E {} +if (get()) {} + ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Allowed types are boolean, string, or number.] diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json new file mode 100644 index 00000000000..7cbb28510b8 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": false + } +} diff --git a/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json new file mode 100644 index 00000000000..584f5f112f6 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks-allow-number-string/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": [true, "allow-number", "allow-string"] + } +} diff --git a/test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint b/test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint new file mode 100644 index 00000000000..35c82de1b14 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks/test.ts.lint @@ -0,0 +1,17 @@ +declare function get(): T; + +if (get<{ x: number }>) {} + ~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is always truthy. It may be null/undefined, but neither 'allow-null-union' nor 'allow-undefined-union' is set. Only booleans are allowed.] + +if (get()) {} + ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a string. Only booleans are allowed.] + +if (get()) {} + ~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it is a number. Only booleans are allowed.] + +enum E {} +if (get()) {} + ~~~~~~~~ [This type is not allowed in the 'if' condition because it is an enum. Only booleans are allowed.] + +if (get()) {} + ~~~~~~~~~~~~~~~~~~~~~~~~ [This type is not allowed in the 'if' condition because it could be an enum. Only booleans are allowed.] diff --git a/test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json b/test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/strict-boolean-expressions/no-null-checks/tslint.json b/test/rules/strict-boolean-expressions/no-null-checks/tslint.json new file mode 100644 index 00000000000..153f37560a7 --- /dev/null +++ b/test/rules/strict-boolean-expressions/no-null-checks/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-boolean-expressions": true + } +} diff --git a/test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint b/test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint new file mode 100644 index 00000000000..1a939a87458 --- /dev/null +++ b/test/rules/strict-comparisons/allow-object-equal-comparison/test.ts.lint @@ -0,0 +1,182 @@ +if (2) {} +if (2 > 1) {} +if (2 < 1) {} +if (2 >= 1) {} +if (2 <= 1) {} +if (2 == 1) {} +if (2 === 1) {} +if (2 != 1) {} +if (2 !== 1) {} +if (2 > undefined) {} + ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (undefined === 1) {} +if (2 > undefined) {} + ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (true) {} +if (true > false) {} + ~~~~~~~~~~~~ [CANNOT_USE % (">", "boolean")] +if (true < false) {} + ~~~~~~~~~~~~ [CANNOT_USE % ("<", "boolean")] +if (true >= false) {} + ~~~~~~~~~~~~~ [CANNOT_USE % (">=", "boolean")] +if (true <= false) {} + ~~~~~~~~~~~~~ [CANNOT_USE % ("<=", "boolean")] +if (true == false) {} +if (true === false) {} +if (true != false) {} +if (true !== false) {} +if ('') {} +if ('' > '') {} + ~~~~~~~ [CANNOT_USE % (">", "string")] +if ('' < '') {} + ~~~~~~~ [CANNOT_USE % ("<", "string")] +if ('' >= '') {} + ~~~~~~~~ [CANNOT_USE % (">=", "string")] +if ('' <= '') {} + ~~~~~~~~ [CANNOT_USE % ("<=", "string")] +if ('' == '') {} +if ('' === '') {} +if ('' != '') {} +if ('' !== '') {} +if ({}) {} +if ({} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "object")] +if ({} < {}) {} + ~~~~~~~ [CANNOT_USE % ("<", "object")] +if ({} >= {}) {} + ~~~~~~~~ [CANNOT_USE % (">=", "object")] +if ({} <= {}) {} + ~~~~~~~~ [CANNOT_USE % ("<=", "object")] +if ({} == {}) {} +if ({} === {}) {} +if ({} != {}) {} +if ({} !== {}) {} +if ([] === []) {} + +if (3 > 2 || 2 > 1 && true === true) {} +if ('' > '' || 2 > 1 || {} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "string")] + ~~~~~~~ [CANNOT_USE % (">", "object")] +if ('' > '' && 2 > 1 && {} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "string")] + ~~~~~~~ [CANNOT_USE % (">", "object")] + +if ({} === null) {} +if (null === {}) {} +if ({} === undefined) {} +if (undefined === {}) {} + +function sameObject(a: T, b: T): boolean { + return a === b; +} + +function sameObject(a: any, b: any): boolean { + return a === b; +} + +type myNumber = number; +const a1: myNumber = 1 +const a2: myNumber = 2 + +if (a1 < a2) {} +if (a2 < a1) {} + +type myString = string; +const b1: myString = '' +const b2: myString = '' + +if (b1 === b2) {} +if (b2 === b1) {} + +type myObject = Object; +const c1: myObject = {} +const c2: myObject = {} + +if (c1 === c2) {} +if (c2 === c1) {} + +const d1: any = 'string' +const d2: any = 2 +if (d1 === d2) {} +if (d2 === d1) {} + +enum TestNumericEnum { + One = 1, + Two = 2, +} + +const e1: TestNumericEnum = TestNumericEnum.One + +#if typescript > 2.1 +if (e1 === TestNumericEnum.Two) {} +if (TestNumericEnum.Two === e1) {} +if (e1 > TestNumericEnum.Two) {} +if (TestNumericEnum.Two > e1) {} +#endif + +const f1: TestNumericEnum | undefined +const f2: TestNumericEnum | undefined + +if (f1 === f2) {} +if (f2 === f1) {} + +enum TestStringEnum { + One = 'one', + Two = 'two', +} + +const g1: TestStringEnum = TestStringEnum.One + +#if typescript > 2.1 +if (g1 === TestStringEnum.Two) {} +if (TestStringEnum.Two === g1) {} +if (g1 > TestStringEnum.Two) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] +if (TestStringEnum.Two > g1) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] +#endif + +const h1: string | number = Math.random() > 0.5 ? 'text' : 5; +const h2: string | number = Math.random() > 0.5 ? 'test' : 2; +if (h1 > h2) {} + ~~~~~~~ [Cannot use '>' comparator for type 'string'.] +if (h2 > h1) {} + ~~~~~~~ [Cannot use '>' comparator for type 'string'.] +if (h1 === h2) {} +if (h2 === h1) {} + +if (undefined === null) {} +if (null !== undefined) {} + +if (1 > null) {} + ~~~~~~~~ [CANNOT_COMPARE % ("number", "null")] +if (null > 1) {} + ~~~~~~~~ [CANNOT_COMPARE % ("null", "number")] +if (1 >= undefined) {} + ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (undefined >= 1) {} + ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "number")] +if (undefined <= null) {} + ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "null")] +if (null >= undefined) {} + ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("null", "undefined")] + +const func = (param?: boolean): boolean => { + return param === undefined ? false : param; +} +const func = (param?: boolean): boolean => { + return param === null ? false : true; +} +const func = (param: number): number => { + return param + 1; +} +const func = (arg1: number, arg2: number): boolean => { + return arg1 === arg2; +} +const func = (param: string | null = null) => { + if (param !== null) {} + if (param !== undefined) {} +} + +[CANNOT_USE]: Cannot use '%s' comparator for type '%s'. +[CANNOT_COMPARE]: Cannot compare type '%s' to type '%s'. diff --git a/test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json b/test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/strict-comparisons/allow-object-equal-comparison/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json b/test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json new file mode 100644 index 00000000000..dd0d1e1c181 --- /dev/null +++ b/test/rules/strict-comparisons/allow-object-equal-comparison/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "strict-comparisons": [ + true, + { + "allow-object-equal-comparison": true + } + ] + } +} diff --git a/test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint b/test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint new file mode 100644 index 00000000000..30c5405f0d5 --- /dev/null +++ b/test/rules/strict-comparisons/allow-string-order-comparison/test.ts.lint @@ -0,0 +1,178 @@ +if (2) {} +if (2 > 1) {} +if (2 < 1) {} +if (2 >= 1) {} +if (2 <= 1) {} +if (2 == 1) {} +if (2 === 1) {} +if (2 != 1) {} +if (2 !== 1) {} +if (2 > undefined) {} + ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (undefined === 1) {} +if (2 > undefined) {} + ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (true) {} +if (true > false) {} + ~~~~~~~~~~~~ [CANNOT_USE % (">", "boolean")] +if (true < false) {} + ~~~~~~~~~~~~ [CANNOT_USE % ("<", "boolean")] +if (true >= false) {} + ~~~~~~~~~~~~~ [CANNOT_USE % (">=", "boolean")] +if (true <= false) {} + ~~~~~~~~~~~~~ [CANNOT_USE % ("<=", "boolean")] +if (true == false) {} +if (true === false) {} +if (true != false) {} +if (true !== false) {} +if ('') {} +if ('' > '') {} +if ('' < '') {} +if ('' >= '') {} +if ('' <= '') {} +if ('' == '') {} +if ('' === '') {} +if ('' != '') {} +if ('' !== '') {} +if ({}) {} +if ({} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "object")] +if ({} < {}) {} + ~~~~~~~ [CANNOT_USE % ("<", "object")] +if ({} >= {}) {} + ~~~~~~~~ [CANNOT_USE % (">=", "object")] +if ({} <= {}) {} + ~~~~~~~~ [CANNOT_USE % ("<=", "object")] +if ({} == {}) {} + ~~~~~~~~ [CANNOT_USE % ("==", "object")] +if ({} === {}) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] +if ({} != {}) {} + ~~~~~~~~ [CANNOT_USE % ("!=", "object")] +if ({} !== {}) {} + ~~~~~~~~~ [CANNOT_USE % ("!==", "object")] +if ([] === []) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] + +if (3 > 2 || 2 > 1 && true === true) {} +if ('' > '' || 2 > 1 || {} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "object")] +if ('' > '' && 2 > 1 && {} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "object")] + +if ({} === null) {} +if (null === {}) {} +if ({} === undefined) {} +if (undefined === {}) {} + +function sameObject(a: T, b: T): boolean { + return a === b; + ~~~~~~~ [CANNOT_USE % ("===", "object")] +} + +function sameObject(a: any, b: any): boolean { + return a === b; +} + +type myNumber = number; +const a1: myNumber = 1 +const a2: myNumber = 2 + +if (a1 < a2) {} +if (a2 < a1) {} + +type myString = string; +const b1: myString = '' +const b2: myString = '' + +if (b1 === b2) {} +if (b2 === b1) {} + +type myObject = Object; +const c1: myObject = {} +const c2: myObject = {} + +if (c1 === c2) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] +if (c2 === c1) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] + +const d1: any = 'string' +const d2: any = 2 +if (d1 === d2) {} +if (d2 === d1) {} + +enum TestNumericEnum { + One = 1, + Two = 2, +} + +const e1: TestNumericEnum = TestNumericEnum.One + +#if typescript > 2.1 +if (e1 === TestNumericEnum.Two) {} +if (TestNumericEnum.Two === e1) {} +if (e1 > TestNumericEnum.Two) {} +if (TestNumericEnum.Two > e1) {} + +const f1: TestNumericEnum | undefined +const f2: TestNumericEnum | undefined + +if (f1 === f2) {} +if (f2 === f1) {} + +enum TestStringEnum { + One = 'one', + Two = 'two', +} + +const g1: TestStringEnum = TestStringEnum.One + +if (g1 === TestStringEnum.Two) {} +if (TestStringEnum.Two === g1) {} +if (g1 > TestStringEnum.Two) {} +if (TestStringEnum.Two > g1) {} +#endif + +const h1: string | number = Math.random() > 0.5 ? 'text' : 5; +const h2: string | number = Math.random() > 0.5 ? 'test' : 2; +if (h1 > h2) {} +if (h2 > h1) {} +if (h1 === h2) {} +if (h2 === h1) {} + +if (undefined === null) {} +if (null !== undefined) {} + +if (1 > null) {} + ~~~~~~~~ [CANNOT_COMPARE % ("number", "null")] +if (null > 1) {} + ~~~~~~~~ [CANNOT_COMPARE % ("null", "number")] +if (1 >= undefined) {} + ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (undefined >= 1) {} + ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "number")] +if (undefined <= null) {} + ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "null")] +if (null >= undefined) {} + ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("null", "undefined")] + +const func = (param?: boolean): boolean => { + return param === undefined ? false : param; +} +const func = (param?: boolean): boolean => { + return param === null ? false : true; +} +const func = (param: number): number => { + return param + 1; +} +const func = (arg1: number, arg2: number): boolean => { + return arg1 === arg2; +} +const func = (param: string | null = null) => { + if (param !== null) {} + if (param !== undefined) {} +} + +[CANNOT_USE]: Cannot use '%s' comparator for type '%s'. +[CANNOT_COMPARE]: Cannot compare type '%s' to type '%s'. diff --git a/test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json b/test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/strict-comparisons/allow-string-order-comparison/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/strict-comparisons/allow-string-order-comparison/tslint.json b/test/rules/strict-comparisons/allow-string-order-comparison/tslint.json new file mode 100644 index 00000000000..3e54a84a891 --- /dev/null +++ b/test/rules/strict-comparisons/allow-string-order-comparison/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "strict-comparisons": [ + true, + { + "allow-string-order-comparison": true + } + ] + } +} diff --git a/test/rules/strict-comparisons/default/test.ts.lint b/test/rules/strict-comparisons/default/test.ts.lint new file mode 100644 index 00000000000..8a1a7a83744 --- /dev/null +++ b/test/rules/strict-comparisons/default/test.ts.lint @@ -0,0 +1,190 @@ +if (2) {} +if (2 > 1) {} +if (2 < 1) {} +if (2 >= 1) {} +if (2 <= 1) {} +if (2 == 1) {} +if (2 === 1) {} +if (2 != 1) {} +if (2 !== 1) {} +if (2 > undefined) {} + ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (undefined === 1) {} +if (2 > undefined) {} + ~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (true) {} +if (true > false) {} + ~~~~~~~~~~~~ [CANNOT_USE % (">", "boolean")] +if (true < false) {} + ~~~~~~~~~~~~ [CANNOT_USE % ("<", "boolean")] +if (true >= false) {} + ~~~~~~~~~~~~~ [CANNOT_USE % (">=", "boolean")] +if (true <= false) {} + ~~~~~~~~~~~~~ [CANNOT_USE % ("<=", "boolean")] +if (true == false) {} +if (true === false) {} +if (true != false) {} +if (true !== false) {} +if ('') {} +if ('' > '') {} + ~~~~~~~ [CANNOT_USE % (">", "string")] +if ('' < '') {} + ~~~~~~~ [CANNOT_USE % ("<", "string")] +if ('' >= '') {} + ~~~~~~~~ [CANNOT_USE % (">=", "string")] +if ('' <= '') {} + ~~~~~~~~ [CANNOT_USE % ("<=", "string")] +if ('' == '') {} +if ('' === '') {} +if ('' != '') {} +if ('' !== '') {} +if ({}) {} +if ({} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "object")] +if ({} < {}) {} + ~~~~~~~ [CANNOT_USE % ("<", "object")] +if ({} >= {}) {} + ~~~~~~~~ [CANNOT_USE % (">=", "object")] +if ({} <= {}) {} + ~~~~~~~~ [CANNOT_USE % ("<=", "object")] +if ({} == {}) {} + ~~~~~~~~ [CANNOT_USE % ("==", "object")] +if ({} === {}) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] +if ({} != {}) {} + ~~~~~~~~ [CANNOT_USE % ("!=", "object")] +if ({} !== {}) {} + ~~~~~~~~~ [CANNOT_USE % ("!==", "object")] +if ([] === []) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] + +if (3 > 2 || 2 > 1 && true === true) {} +if ('' > '' || 2 > 1 || {} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "string")] + ~~~~~~~ [CANNOT_USE % (">", "object")] +if ('' > '' && 2 > 1 && {} > {}) {} + ~~~~~~~ [CANNOT_USE % (">", "string")] + ~~~~~~~ [CANNOT_USE % (">", "object")] + +if ({} === null) {} +if (null === {}) {} +if ({} === undefined) {} +if (undefined === {}) {} + +function sameObject(a: T, b: T): boolean { + return a === b; + ~~~~~~~ [CANNOT_USE % ("===", "object")] +} + +function sameObject(a: any, b: any): boolean { + return a === b; +} + +type myNumber = number; +const a1: myNumber = 1 +const a2: myNumber = 2 + +if (a1 < a2) {} +if (a2 < a1) {} + +type myString = string; +const b1: myString = '' +const b2: myString = '' + +if (b1 === b2) {} +if (b2 === b1) {} + +type myObject = Object; +const c1: myObject = {} +const c2: myObject = {} + +if (c1 === c2) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] +if (c2 === c1) {} + ~~~~~~~~~ [CANNOT_USE % ("===", "object")] + +const d1: any = 'string' +const d2: any = 2 +if (d1 === d2) {} +if (d2 === d1) {} + +enum TestNumericEnum { + One = 1, + Two = 2, +} + +const e1: TestNumericEnum = TestNumericEnum.One + +#if typescript > 2.1 +if (e1 === TestNumericEnum.Two) {} +if (TestNumericEnum.Two === e1) {} +if (e1 > TestNumericEnum.Two) {} +if (TestNumericEnum.Two > e1) {} +#endif + +const f1: TestNumericEnum | undefined +const f2: TestNumericEnum | undefined + +#if typescript > 2.1 +if (f1 === f2) {} +if (f2 === f1) {} + +enum TestStringEnum { + One = 'one', + Two = 'two', +} + +const g1: TestStringEnum = TestStringEnum.One + +if (g1 === TestStringEnum.Two) {} +if (TestStringEnum.Two === g1) {} +if (g1 > TestStringEnum.Two) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] +if (TestStringEnum.Two > g1) {} + ~~~~~~~~~~~~~~~~~~~~~~~ [CANNOT_USE % (">", "string")] +#endif + +const h1: string | number = Math.random() > 0.5 ? 'text' : 5; +const h2: string | number = Math.random() > 0.5 ? 'test' : 2; +if (h1 > h2) {} + ~~~~~~~ [CANNOT_USE % (">", "string")] +if (h2 > h1) {} + ~~~~~~~ [CANNOT_USE % (">", "string")] +if (h1 === h2) {} +if (h2 === h1) {} + +if (undefined === null) {} +if (null !== undefined) {} + +if (1 > null) {} + ~~~~~~~~ [CANNOT_COMPARE % ("number", "null")] +if (null > 1) {} + ~~~~~~~~ [CANNOT_COMPARE % ("null", "number")] +if (1 >= undefined) {} + ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("number", "undefined")] +if (undefined >= 1) {} + ~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "number")] +if (undefined <= null) {} + ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("undefined", "null")] +if (null >= undefined) {} + ~~~~~~~~~~~~~~~~~ [CANNOT_COMPARE % ("null", "undefined")] + +const func = (param?: boolean): boolean => { + return param === undefined ? false : param; +} +const func = (param?: boolean): boolean => { + return param === null ? false : true; +} +const func = (param: number): number => { + return param + 1; +} +const func = (arg1: number, arg2: number): boolean => { + return arg1 === arg2; +} +const func = (param: string | null = null) => { + if (param !== null) {} + if (param !== undefined) {} +} + +[CANNOT_USE]: Cannot use '%s' comparator for type '%s'. +[CANNOT_COMPARE]: Cannot compare type '%s' to type '%s'. diff --git a/test/rules/strict-comparisons/default/tsconfig.json b/test/rules/strict-comparisons/default/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/strict-comparisons/default/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/strict-comparisons/default/tslint.json b/test/rules/strict-comparisons/default/tslint.json new file mode 100644 index 00000000000..6c559289264 --- /dev/null +++ b/test/rules/strict-comparisons/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-comparisons": true + } +} diff --git a/test/rules/strict-string-expressions/allow-empty-types/test.ts.fix b/test/rules/strict-string-expressions/allow-empty-types/test.ts.fix new file mode 100644 index 00000000000..ed0c9eec177 --- /dev/null +++ b/test/rules/strict-string-expressions/allow-empty-types/test.ts.fix @@ -0,0 +1,133 @@ + const fooAny: any; + const fooStr: string = 'foo'; + const fooNumber = 2; + class FooClass {} + class ClassWithToString { + public static toString () { return ''; } + public toString () { return ''; } + } + const classWithToString = new ClassWithToString(); + const FooStr = new String('foo'); + const fooArr = ['foo']; + const emptyArr = []; + const stringUni = "foo" | "bar"; + const booleanVar: boolean; + + `foo` + `${'str literal'}` + `${123}` + `${booleanVar}` + `${fooAny}` + `${fooStr}` + `${stringUni}` + `${fooNumber}` + `${(typeof window)}` + `${String(FooClass)}` + `${String(ClassWithToString)}` + `${String(classWithToString)}` + `${String(FooStr)}` + `${String(fooArr)}` + `${String(emptyArr)}` + + `${String('str literal')}` + `${String(123)}` + `${String(booleanVar)}` + `${String(fooAny)}` + `${String(fooStr)}` + `${String(stringUni)}` + `${String(fooNumber)}` + `${String((typeof window))}` + `${String(FooClass)}` + `${String(ClassWithToString)}` + `${String(classWithToString)}` + `${String(FooStr)}` + `${String(fooArr)}` + `${String(emptyArr)}` + + `${'str literal'.toString()}` + `${123..toString()}` + `${booleanVar.toString()}` + `${fooAny.toString()}` + `${fooStr.toString()}` + `${stringUni.toString()}` + `${fooNumber.toString()}` + `${(typeof window).toString()}` + `${FooClass.toString()}` + `${ClassWithToString.toString()}` + `${classWithToString.toString()}` + `${FooStr.toString()}` + `${fooArr.toString()}` + `${emptyArr.toString()}` + + 'str' + 'str literal' + 'str' + 'str' + 123 + 'str' + 'str' + booleanVar + 'str' + 'str' + fooAny + 'str' + 'str' + fooStr + 'str' + 'str' + stringUni + 'str' + 'str' + fooNumber + 'str' + 'str' + (typeof window) + 'str' + 'str' + String(FooClass) + 'str' + 'str' + String(ClassWithToString) + 'str' + 'str' + String(classWithToString) + 'str' + 'str' + String(FooStr) + 'str' + 'str' + String(fooArr) + 'str' + 'str' + String(emptyArr) + 'str' + + 'str' + String('str literal') + 'str' + 'str' + String(123) + 'str' + 'str' + String(booleanVar) + 'str' + 'str' + String(fooAny) + 'str' + 'str' + String(fooStr) + 'str' + 'str' + String(stringUni) + 'str' + 'str' + String(fooNumber) + 'str' + 'str' + String((typeof window)) + 'str' + 'str' + String(FooClass) + 'str' + 'str' + String(ClassWithToString) + 'str' + 'str' + String(classWithToString) + 'str' + 'str' + String(FooStr) + 'str' + 'str' + String(fooArr) + 'str' + 'str' + String(emptyArr) + 'str' + + 'str' + 'str literal'.toString() + 'str' + 'str' + 123..toString() + 'str' + 'str' + booleanVar.toString() + 'str' + 'str' + fooAny.toString() + 'str' + 'str' + fooStr.toString() + 'str' + 'str' + stringUni.toString() + 'str' + 'str' + fooNumber.toString() + 'str' + 'str' + (typeof window).toString() + 'str' + 'str' + FooClass.toString() + 'str' + 'str' + ClassWithToString.toString() + 'str' + 'str' + classWithToString.toString() + 'str' + 'str' + FooStr.toString() + 'str' + 'str' + fooArr.toString() + 'str' + 'str' + emptyArr.toString() + 'str' + + const barFooStrOrUndef: string | undefined; + const barFooStrOrNull: string | null; + const neverType: never; + + `${barFooStrOrUndef}` + `${barFooStrOrNull}` + `${neverType}` + + `${String(barFooStrOrUndef)}` + `${String(barFooStrOrNull)}` + `${String(neverType)}` + + `${barFooStrOrUndef.toString()}` + `${barFooStrOrNull.toString()}` + `${neverType.toString()}` + + 'str' + barFooStrOrUndef + 'str' + 'str' + barFooStrOrNull + 'str' + 'str' + neverType + 'str' + + 'str' + String(barFooStrOrUndef) + 'str' + 'str' + String(barFooStrOrNull) + 'str' + 'str' + String(neverType) + 'str' + + 'str' + barFooStrOrUndef.toString() + 'str' + 'str' + barFooStrOrNull.toString() + 'str' + 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/allow-empty-types/test.ts.lint b/test/rules/strict-string-expressions/allow-empty-types/test.ts.lint new file mode 100644 index 00000000000..0660ca94379 --- /dev/null +++ b/test/rules/strict-string-expressions/allow-empty-types/test.ts.lint @@ -0,0 +1,145 @@ + const fooAny: any; + const fooStr: string = 'foo'; + const fooNumber = 2; + class FooClass {} + class ClassWithToString { + public static toString () { return ''; } + public toString () { return ''; } + } + const classWithToString = new ClassWithToString(); + const FooStr = new String('foo'); + const fooArr = ['foo']; + const emptyArr = []; + const stringUni = "foo" | "bar"; + const booleanVar: boolean; + + `foo` + `${'str literal'}` + `${123}` + `${booleanVar}` + `${fooAny}` + `${fooStr}` + `${stringUni}` + `${fooNumber}` + `${(typeof window)}` + `${FooClass}` + ~~~~~~~~~~ [Explicit conversion to string type required] + `${ClassWithToString}` + ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + `${classWithToString}` + ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + `${FooStr}` + ~~~~~~~~ [Explicit conversion to string type required] + `${fooArr}` + ~~~~~~~~ [Explicit conversion to string type required] + `${emptyArr}` + ~~~~~~~~~~ [Explicit conversion to string type required] + + `${String('str literal')}` + `${String(123)}` + `${String(booleanVar)}` + `${String(fooAny)}` + `${String(fooStr)}` + `${String(stringUni)}` + `${String(fooNumber)}` + `${String((typeof window))}` + `${String(FooClass)}` + `${String(ClassWithToString)}` + `${String(classWithToString)}` + `${String(FooStr)}` + `${String(fooArr)}` + `${String(emptyArr)}` + + `${'str literal'.toString()}` + `${123..toString()}` + `${booleanVar.toString()}` + `${fooAny.toString()}` + `${fooStr.toString()}` + `${stringUni.toString()}` + `${fooNumber.toString()}` + `${(typeof window).toString()}` + `${FooClass.toString()}` + `${ClassWithToString.toString()}` + `${classWithToString.toString()}` + `${FooStr.toString()}` + `${fooArr.toString()}` + `${emptyArr.toString()}` + + 'str' + 'str literal' + 'str' + 'str' + 123 + 'str' + 'str' + booleanVar + 'str' + 'str' + fooAny + 'str' + 'str' + fooStr + 'str' + 'str' + stringUni + 'str' + 'str' + fooNumber + 'str' + 'str' + (typeof window) + 'str' + 'str' + FooClass + 'str' + ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + ClassWithToString + 'str' + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + classWithToString + 'str' + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + FooStr + 'str' + ~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + fooArr + 'str' + ~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + emptyArr + 'str' + ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + + 'str' + String('str literal') + 'str' + 'str' + String(123) + 'str' + 'str' + String(booleanVar) + 'str' + 'str' + String(fooAny) + 'str' + 'str' + String(fooStr) + 'str' + 'str' + String(stringUni) + 'str' + 'str' + String(fooNumber) + 'str' + 'str' + String((typeof window)) + 'str' + 'str' + String(FooClass) + 'str' + 'str' + String(ClassWithToString) + 'str' + 'str' + String(classWithToString) + 'str' + 'str' + String(FooStr) + 'str' + 'str' + String(fooArr) + 'str' + 'str' + String(emptyArr) + 'str' + + 'str' + 'str literal'.toString() + 'str' + 'str' + 123..toString() + 'str' + 'str' + booleanVar.toString() + 'str' + 'str' + fooAny.toString() + 'str' + 'str' + fooStr.toString() + 'str' + 'str' + stringUni.toString() + 'str' + 'str' + fooNumber.toString() + 'str' + 'str' + (typeof window).toString() + 'str' + 'str' + FooClass.toString() + 'str' + 'str' + ClassWithToString.toString() + 'str' + 'str' + classWithToString.toString() + 'str' + 'str' + FooStr.toString() + 'str' + 'str' + fooArr.toString() + 'str' + 'str' + emptyArr.toString() + 'str' + + const barFooStrOrUndef: string | undefined; + const barFooStrOrNull: string | null; + const neverType: never; + + `${barFooStrOrUndef}` + `${barFooStrOrNull}` + `${neverType}` + + `${String(barFooStrOrUndef)}` + `${String(barFooStrOrNull)}` + `${String(neverType)}` + + `${barFooStrOrUndef.toString()}` + `${barFooStrOrNull.toString()}` + `${neverType.toString()}` + + 'str' + barFooStrOrUndef + 'str' + 'str' + barFooStrOrNull + 'str' + 'str' + neverType + 'str' + + 'str' + String(barFooStrOrUndef) + 'str' + 'str' + String(barFooStrOrNull) + 'str' + 'str' + String(neverType) + 'str' + + 'str' + barFooStrOrUndef.toString() + 'str' + 'str' + barFooStrOrNull.toString() + 'str' + 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/allow-empty-types/tsconfig.json b/test/rules/strict-string-expressions/allow-empty-types/tsconfig.json new file mode 100644 index 00000000000..aa5798f3ce6 --- /dev/null +++ b/test/rules/strict-string-expressions/allow-empty-types/tsconfig.json @@ -0,0 +1,4 @@ +{ + "compilerOptions": { + } +} diff --git a/test/rules/strict-string-expressions/allow-empty-types/tslint.json b/test/rules/strict-string-expressions/allow-empty-types/tslint.json new file mode 100644 index 00000000000..270026fc7f4 --- /dev/null +++ b/test/rules/strict-string-expressions/allow-empty-types/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "strict-string-expressions": [ + true, + { + "allow-empty-types": true + } + ] + } +} diff --git a/test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix b/test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix new file mode 100644 index 00000000000..dd4b6ee8d2c --- /dev/null +++ b/test/rules/strict-string-expressions/disallow-empty-types/test.ts.fix @@ -0,0 +1,133 @@ + const fooAny: any; + const fooStr: string = 'foo'; + const fooNumber = 2; + class FooClass {} + class ClassWithToString { + public static toString () { return ''; } + public toString () { return ''; } + } + const classWithToString = new ClassWithToString(); + const FooStr = new String('foo'); + const fooArr = ['foo']; + const emptyArr = []; + const stringUni = "foo" | "bar"; + const booleanVar: boolean; + + `foo` + `${'str literal'}` + `${123}` + `${fooAny}` + `${fooStr}` + `${stringUni}` + `${fooNumber}` + `${(typeof window)}` + `${String(FooClass)}` + `${String(ClassWithToString)}` + `${String(classWithToString)}` + `${String(FooStr)}` + `${String(fooArr)}` + `${String(emptyArr)}` + `${booleanVar}` + + `${String('str literal')}` + `${String(123)}` + `${String(fooAny)}` + `${String(fooStr)}` + `${String(stringUni)}` + `${String(fooNumber)}` + `${String((typeof window))}` + `${String(FooClass)}` + `${String(ClassWithToString)}` + `${String(classWithToString)}` + `${String(FooStr)}` + `${String(fooArr)}` + `${String(emptyArr)}` + `${String(booleanVar)}` + + `${'str literal'.toString()}` + `${123..toString()}` + `${fooAny.toString()}` + `${fooStr.toString()}` + `${stringUni.toString()}` + `${fooNumber.toString()}` + `${(typeof window).toString()}` + `${FooClass.toString()}` + `${ClassWithToString.toString()}` + `${classWithToString.toString()}` + `${FooStr.toString()}` + `${fooArr.toString()}` + `${emptyArr.toString()}` + `${booleanVar.toString()}` + + 'str' + 'str literal' + 'str' + 'str' + 123 + 'str' + 'str' + fooAny + 'str' + 'str' + fooStr + 'str' + 'str' + stringUni + 'str' + 'str' + fooNumber + 'str' + 'str' + (typeof window) + 'str' + 'str' + String(FooClass) + 'str' + 'str' + String(ClassWithToString) + 'str' + 'str' + String(classWithToString) + 'str' + 'str' + String(FooStr) + 'str' + 'str' + String(fooArr) + 'str' + 'str' + String(emptyArr) + 'str' + 'str' + booleanVar + 'str' + + 'str' + String('str literal') + 'str' + 'str' + String(123) + 'str' + 'str' + String(fooAny) + 'str' + 'str' + String(fooStr) + 'str' + 'str' + String(stringUni) + 'str' + 'str' + String(fooNumber) + 'str' + 'str' + String((typeof window)) + 'str' + 'str' + String(FooClass) + 'str' + 'str' + String(ClassWithToString) + 'str' + 'str' + String(classWithToString) + 'str' + 'str' + String(FooStr) + 'str' + 'str' + String(fooArr) + 'str' + 'str' + String(emptyArr) + 'str' + 'str' + String(booleanVar) + 'str' + + 'str' + 'str literal'.toString() + 'str' + 'str' + 123..toString() + 'str' + 'str' + fooAny.toString() + 'str' + 'str' + fooStr.toString() + 'str' + 'str' + stringUni.toString() + 'str' + 'str' + fooNumber.toString() + 'str' + 'str' + (typeof window).toString() + 'str' + 'str' + FooClass.toString() + 'str' + 'str' + ClassWithToString.toString() + 'str' + 'str' + classWithToString.toString() + 'str' + 'str' + FooStr.toString() + 'str' + 'str' + fooArr.toString() + 'str' + 'str' + emptyArr.toString() + 'str' + 'str' + booleanVar.toString() + 'str' + + const barFooStrOrUndef: string | undefined; + const barFooStrOrNull: string | null; + const neverType: never; + + `${String(barFooStrOrUndef)}` + `${String(barFooStrOrNull)}` + `${String(neverType)}` + + `${String(barFooStrOrUndef)}` + `${String(barFooStrOrNull)}` + `${String(neverType)}` + + `${barFooStrOrUndef.toString()}` + `${barFooStrOrNull.toString()}` + `${neverType.toString()}` + + 'str' + String(barFooStrOrUndef) + 'str' + 'str' + String(barFooStrOrNull) + 'str' + 'str' + String(neverType) + 'str' + + 'str' + String(barFooStrOrUndef) + 'str' + 'str' + String(barFooStrOrNull) + 'str' + 'str' + String(neverType) + 'str' + + 'str' + barFooStrOrUndef.toString() + 'str' + 'str' + barFooStrOrNull.toString() + 'str' + 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint b/test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint new file mode 100644 index 00000000000..b7f29b9ed0c --- /dev/null +++ b/test/rules/strict-string-expressions/disallow-empty-types/test.ts.lint @@ -0,0 +1,151 @@ + const fooAny: any; + const fooStr: string = 'foo'; + const fooNumber = 2; + class FooClass {} + class ClassWithToString { + public static toString () { return ''; } + public toString () { return ''; } + } + const classWithToString = new ClassWithToString(); + const FooStr = new String('foo'); + const fooArr = ['foo']; + const emptyArr = []; + const stringUni = "foo" | "bar"; + const booleanVar: boolean; + + `foo` + `${'str literal'}` + `${123}` + `${fooAny}` + `${fooStr}` + `${stringUni}` + `${fooNumber}` + `${(typeof window)}` + `${FooClass}` + ~~~~~~~~~~ [Explicit conversion to string type required] + `${ClassWithToString}` + ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + `${classWithToString}` + ~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + `${FooStr}` + ~~~~~~~~ [Explicit conversion to string type required] + `${fooArr}` + ~~~~~~~~ [Explicit conversion to string type required] + `${emptyArr}` + ~~~~~~~~~~ [Explicit conversion to string type required] + `${booleanVar}` + + `${String('str literal')}` + `${String(123)}` + `${String(fooAny)}` + `${String(fooStr)}` + `${String(stringUni)}` + `${String(fooNumber)}` + `${String((typeof window))}` + `${String(FooClass)}` + `${String(ClassWithToString)}` + `${String(classWithToString)}` + `${String(FooStr)}` + `${String(fooArr)}` + `${String(emptyArr)}` + `${String(booleanVar)}` + + `${'str literal'.toString()}` + `${123..toString()}` + `${fooAny.toString()}` + `${fooStr.toString()}` + `${stringUni.toString()}` + `${fooNumber.toString()}` + `${(typeof window).toString()}` + `${FooClass.toString()}` + `${ClassWithToString.toString()}` + `${classWithToString.toString()}` + `${FooStr.toString()}` + `${fooArr.toString()}` + `${emptyArr.toString()}` + `${booleanVar.toString()}` + + 'str' + 'str literal' + 'str' + 'str' + 123 + 'str' + 'str' + fooAny + 'str' + 'str' + fooStr + 'str' + 'str' + stringUni + 'str' + 'str' + fooNumber + 'str' + 'str' + (typeof window) + 'str' + 'str' + FooClass + 'str' + ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + ClassWithToString + 'str' + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + classWithToString + 'str' + ~~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + FooStr + 'str' + ~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + fooArr + 'str' + ~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + emptyArr + 'str' + ~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + booleanVar + 'str' + + 'str' + String('str literal') + 'str' + 'str' + String(123) + 'str' + 'str' + String(fooAny) + 'str' + 'str' + String(fooStr) + 'str' + 'str' + String(stringUni) + 'str' + 'str' + String(fooNumber) + 'str' + 'str' + String((typeof window)) + 'str' + 'str' + String(FooClass) + 'str' + 'str' + String(ClassWithToString) + 'str' + 'str' + String(classWithToString) + 'str' + 'str' + String(FooStr) + 'str' + 'str' + String(fooArr) + 'str' + 'str' + String(emptyArr) + 'str' + 'str' + String(booleanVar) + 'str' + + 'str' + 'str literal'.toString() + 'str' + 'str' + 123..toString() + 'str' + 'str' + fooAny.toString() + 'str' + 'str' + fooStr.toString() + 'str' + 'str' + stringUni.toString() + 'str' + 'str' + fooNumber.toString() + 'str' + 'str' + (typeof window).toString() + 'str' + 'str' + FooClass.toString() + 'str' + 'str' + ClassWithToString.toString() + 'str' + 'str' + classWithToString.toString() + 'str' + 'str' + FooStr.toString() + 'str' + 'str' + fooArr.toString() + 'str' + 'str' + emptyArr.toString() + 'str' + 'str' + booleanVar.toString() + 'str' + + const barFooStrOrUndef: string | undefined; + const barFooStrOrNull: string | null; + const neverType: never; + + `${barFooStrOrUndef}` + ~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + `${barFooStrOrNull}` + ~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + `${neverType}` + ~~~~~~~~~~~ [Explicit conversion to string type required] + + `${String(barFooStrOrUndef)}` + `${String(barFooStrOrNull)}` + `${String(neverType)}` + + `${barFooStrOrUndef.toString()}` + `${barFooStrOrNull.toString()}` + `${neverType.toString()}` + + 'str' + barFooStrOrUndef + 'str' + ~~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + barFooStrOrNull + 'str' + ~~~~~~~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + 'str' + neverType + 'str' + ~~~~~~~~~~~~~~~~~ [Explicit conversion to string type required] + + 'str' + String(barFooStrOrUndef) + 'str' + 'str' + String(barFooStrOrNull) + 'str' + 'str' + String(neverType) + 'str' + + 'str' + barFooStrOrUndef.toString() + 'str' + 'str' + barFooStrOrNull.toString() + 'str' + 'str' + neverType.toString() + 'str' diff --git a/test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json b/test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json new file mode 100644 index 00000000000..c4d430eb449 --- /dev/null +++ b/test/rules/strict-string-expressions/disallow-empty-types/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} diff --git a/test/rules/strict-string-expressions/disallow-empty-types/tslint.json b/test/rules/strict-string-expressions/disallow-empty-types/tslint.json new file mode 100644 index 00000000000..265d57b2aaf --- /dev/null +++ b/test/rules/strict-string-expressions/disallow-empty-types/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "strict-string-expressions": [ + true, + { + "allow-empty-types": false + } + ] + } +} diff --git a/test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint b/test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint new file mode 100644 index 00000000000..bfa10b37067 --- /dev/null +++ b/test/rules/strict-type-predicates/no-strict-null-checks/test.ts.lint @@ -0,0 +1,156 @@ +declare function get(): T; + +// typeof undefined +{ + typeof get() === "undefined"; + + typeof get() === "undefined"; + + typeof get() === "undefined"; + + declare const c: any; + typeof get() === "undefined"; + + // 'undefined' is not assignable to '{}' + typeof get<{}>() === "undefined"; +} + +// typeof boolean +{ + declare const a: boolean; + typeof get() === "boolean"; + + typeof get() === "boolean"; + + typeof get() === "boolean"; + + typeof get<{}>() === "boolean"; +} + +// typeof number +{ + enum E {} + + typeof get() === "number"; + + typeof get() === "number"; +} + +// typeof string +{ + typeof get<"abc" | "def">() === "string"; + + typeof get() === "string"; + + typeof get<"abc" | undefined>() === "string"; +} + +// typeof symbol +{ + typeof get() === "symbol"; + + typeof get() === "symbol"; + + typeof get() === "symbol"; +} + +// typeof function +{ + typeof get<() => void>() === "function"; + + typeof get() === "function"; + + + typeof get() === "function"; + + typeof get void)>() === "function"; + + class X {} + typeof X === "function"; + typeof X === "object"; + + // Works with union + class Foo { } + typeof get === "function"; +} + +// typeof object +{ + typeof get void) | Function>() === "object"; + + typeof get<{}> === "object"; +} + +// === null / undefined +{ + get() === null; + + get() === null; + + get() === undefined; + + get() === undefined; + + // 'null' and 'undefined' are not assignable to '{}' + + get<{}>() === null; + + get<{}>() === undefined; + + get() == null; + + get() == undefined; + + get() == null; + + get() == undefined; + + get() != null; + + get<{}>() == null; + + get() == null; + get() != undefined; + + get() == null; + get() != undefined; +} + +// negation +{ + get() !== null; + + get() !== null; + + get() !== undefined; + + get() !== undefined; + + typeof get() !== "string"; +} + +// reverse left/right +{ + "string" === typeof get(); + + undefined === get(); +} + +// type parameters +{ + function f(t: T) { + typeof t === "boolean"; + } + + // TODO: Would be nice to catch this. + function g(t: T) { + typeof t === "boolean"; + } +} + +// Detects bad typeof +{ + typeof get() === true; + + typeof get() === "orbject"; +} diff --git a/test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json b/test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json new file mode 100644 index 00000000000..67394b4f5a1 --- /dev/null +++ b/test/rules/strict-type-predicates/no-strict-null-checks/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + // strictNullChecks not enabled + } +} \ No newline at end of file diff --git a/test/rules/strict-type-predicates/no-strict-null-checks/tslint.json b/test/rules/strict-type-predicates/no-strict-null-checks/tslint.json new file mode 100644 index 00000000000..bb5f9231e91 --- /dev/null +++ b/test/rules/strict-type-predicates/no-strict-null-checks/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-type-predicates": true + } +} diff --git a/test/rules/strict-type-predicates/strict-null-checks/test.ts.lint b/test/rules/strict-type-predicates/strict-null-checks/test.ts.lint new file mode 100644 index 00000000000..2f45d333a2f --- /dev/null +++ b/test/rules/strict-type-predicates/strict-null-checks/test.ts.lint @@ -0,0 +1,215 @@ +declare function get(): T; + +// typeof undefined +{ + typeof get() === "undefined"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + typeof get() === "undefined"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + typeof get() === "undefined"; + + declare const c: any; + typeof get() === "undefined"; + + // 'undefined' is not assignable to '{}' + typeof get<{}>() === "undefined"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] +} + +// typeof boolean +{ + declare const a: boolean; + typeof get() === "boolean"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + typeof get() === "boolean"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + typeof get() === "boolean"; + + typeof get<{}>() === "boolean"; +} + +// typeof number +{ + enum E {} + + typeof get() === "number"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + typeof get() === "number"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] +} + +// typeof string +{ + typeof get<"abc" | "def">() === "string"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + typeof get() === "string"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + typeof get<"abc" | undefined>() === "string"; +} + +// typeof symbol +{ + typeof get() === "symbol"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + typeof get() === "symbol"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + typeof get() === "symbol"; +} + +// typeof function +{ + typeof get<() => void>() === "function"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + typeof get() === "function"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + + typeof get() === "function"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + typeof get void)>() === "function"; + + class X {} + typeof X === "function"; + ~~~~~~~~~~~~~~~~~~~~~~~ [T] + typeof X === "object"; + ~~~~~~~~~~~~~~~~~~~~~ [F] + + // Works with union + class Foo { } + typeof get === "function"; +} + +// typeof object +{ + typeof get void) | Function>() === "object"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + typeof get<{}> === "object"; +} + +// === null / undefined +{ + get() === null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + get() === null; + + get() === undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + get() === undefined; + + // 'null' and 'undefined' are not assignable to '{}' + + get<{}>() === null; + ~~~~~~~~~~~~~~~~~~ [F] + + get<{}>() === undefined; + ~~~~~~~~~~~~~~~~~~~~~~~ [F] + + get() == null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== undefined' instead.] + + get() == undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== null' instead.] + + get() == null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== null' instead.] + + get() == undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '=== undefined' instead.] + + get() != null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Use '!== undefined' instead.] + + get<{}>() == null; + ~~~~~~~~~~~~~~~~~ [F] + + get() == null; + get() != undefined; + + get() == null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + get() != undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] +} + +// negation +{ + get() !== null; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + get() !== null; + + get() !== undefined; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [T] + + get() !== undefined; + + typeof get() !== "string"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] +} + +// reverse left/right +{ + "string" === typeof get(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [F] + + undefined === get(); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [T] +} + +// type parameters +{ + function f(t: T) { + typeof t === "boolean"; + } + + // TODO: Would be nice to catch this. + function g(t: T) { + typeof t === "boolean"; + } +} + +// Detects bad typeof +{ + typeof get() === true; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] + + typeof get() === "orbject"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] + + typeof get() === `string`; + typeof get() === `stirng`; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] + + typeof get() === "unknown"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [typeof] + + let a: string, b: string; + typeof a === typeof b; + typeof a === b; + a === typeof b; + typeof a === undefined; + ~~~~~~~~~~~~~~~~~~~~~~ [F] + + undefined === typeof a; + ~~~~~~~~~~~~~~~~~~~~~~ [typeof] + null === typeof b; + ~~~~~~~~~~~~~~~~~ [typeof] +} + +[T]: Expression is always true. +[F]: Expression is always false. +[typeof]: Bad comparison for 'typeof'. diff --git a/test/rules/strict-type-predicates/strict-null-checks/tsconfig.json b/test/rules/strict-type-predicates/strict-null-checks/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-type-predicates/strict-null-checks/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-type-predicates/strict-null-checks/tslint.json b/test/rules/strict-type-predicates/strict-null-checks/tslint.json new file mode 100644 index 00000000000..bb5f9231e91 --- /dev/null +++ b/test/rules/strict-type-predicates/strict-null-checks/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-type-predicates": true + } +} diff --git a/test/rules/strict-type-predicates/unknown/test.ts.lint b/test/rules/strict-type-predicates/unknown/test.ts.lint new file mode 100644 index 00000000000..40dd5d0da99 --- /dev/null +++ b/test/rules/strict-type-predicates/unknown/test.ts.lint @@ -0,0 +1,42 @@ +[typescript]: >= 3.0.0 + +declare function get(): T; + +// typeof +{ + typeof get() === "undefined"; + typeof get() === "boolean"; + typeof get() === "number"; + typeof get() === "string"; + typeof get() === "symbol"; + typeof get() === "function"; + typeof get() === "object"; +} + +// negation +{ + get() !== null; + get() !== undefined; +} + +// reverse left/right +{ + "string" === typeof get(); + + undefined === get(); +} + +// type parameters +{ + function f(t: T) { + typeof t === "boolean"; + } +} + +const body: unknown = 'test'; +if (typeof body === 'object') + console.log('a'); + +let test: unknown = undefined; +if (test !== undefined) + console.log('b'); diff --git a/test/rules/strict-type-predicates/unknown/tsconfig.json b/test/rules/strict-type-predicates/unknown/tsconfig.json new file mode 100644 index 00000000000..1cc3bc85ee9 --- /dev/null +++ b/test/rules/strict-type-predicates/unknown/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictNullChecks": true + } +} \ No newline at end of file diff --git a/test/rules/strict-type-predicates/unknown/tslint.json b/test/rules/strict-type-predicates/unknown/tslint.json new file mode 100644 index 00000000000..bb5f9231e91 --- /dev/null +++ b/test/rules/strict-type-predicates/unknown/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "strict-type-predicates": true + } +} diff --git a/test/rules/switch-default/test.ts.lint b/test/rules/switch-default/test.ts.lint new file mode 100644 index 00000000000..2f33aba2eb5 --- /dev/null +++ b/test/rules/switch-default/test.ts.lint @@ -0,0 +1,74 @@ +switch (foo) { +~~~~~~~~~~~~~~ +case 1: +~~~~~~~ + bar(); +~~~~~~~~~~ + break; +~~~~~~~~~~ +} +~ [Switch statement should include a 'default' case] + +switch (foo) { +~~~~~~~~~~~~~~ +case 1: +~~~~~~~ + bar(); +~~~~~~~~~~ + break; +~~~~~~~~~~ +case 2: +~~~~~~~ + bar(); +~~~~~~~~~~ + break; +~~~~~~~~~~ +case 3: +~~~~~~~ + bar(); +~~~~~~~~~~ + break; +~~~~~~~~~~ +} +~ [Switch statement should include a 'default' case] + +// valid +switch (foo) { +case 1: + bar(); + break; +default: + break; +} + +// valid +switch (foo) { +default: + bar(); + break; +case 1: + bar(); + break; +} + +// valid +switch (foo) { +case 1: + bar(); + break; +default: + break; +case 2: + break; +} + +// valid +baz: +while (true){ + switch(foo) { + case 1: + bar(); + continue baz; + default: + } +} diff --git a/test/rules/switch-default/tslint.json b/test/rules/switch-default/tslint.json new file mode 100644 index 00000000000..05e34955935 --- /dev/null +++ b/test/rules/switch-default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "switch-default": true + } +} diff --git a/test/rules/switch-final-break/always/test.ts.fix b/test/rules/switch-final-break/always/test.ts.fix new file mode 100644 index 00000000000..f0ee2fa6552 --- /dev/null +++ b/test/rules/switch-final-break/always/test.ts.fix @@ -0,0 +1,49 @@ +switch (x) { + case 0: + foo(); + break; +} + +switch (x) { + case 0: { + foo(); + break; + } +} + +switch (x) { + case 0: + foo(); + break; +} + +switch (x) { + case 0: { + foo(); + break; + } +} + +switch (x) { + default: + foo(); + break; +} + +switch (x) { + default: + foo(); + break; +} + +switch (x) { + default: { + foo(); + break; + } +} + +switch (x) { + case 0: break; +} + diff --git a/test/rules/switch-final-break/always/test.ts.lint b/test/rules/switch-final-break/always/test.ts.lint new file mode 100644 index 00000000000..10bab6aa4ea --- /dev/null +++ b/test/rules/switch-final-break/always/test.ts.lint @@ -0,0 +1,51 @@ +switch (x) { + case 0: + ~~~~ [0] + foo(); +} + +switch (x) { + case 0: { + ~~~~ [0] + foo(); + } +} + +switch (x) { + case 0: + foo(); + break; +} + +switch (x) { + case 0: { + foo(); + break; + } +} + +switch (x) { + default: + foo(); + break; +} + +switch (x) { + default: + ~~~~~~~ [0] + foo(); +} + +switch (x) { + default: { + ~~~~~~~ [0] + foo(); + } +} + +switch (x) { + case 0: + ~~~~ [0] +} + +[0]: Final clause in 'switch' statement should end with 'break;'. diff --git a/test/rules/switch-final-break/always/tslint.json b/test/rules/switch-final-break/always/tslint.json new file mode 100644 index 00000000000..977f95f8ad0 --- /dev/null +++ b/test/rules/switch-final-break/always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "switch-final-break": [true, "always"] + } +} diff --git a/test/rules/switch-final-break/default/test.ts.fix b/test/rules/switch-final-break/default/test.ts.fix new file mode 100644 index 00000000000..638af1e03ae --- /dev/null +++ b/test/rules/switch-final-break/default/test.ts.fix @@ -0,0 +1,61 @@ +switch (x) { + case 0: + foo(); +} + +switch (x) { + case 0: { + foo(); + } +} + +switch (x) { + case 0: + foo(); +} + +switch (x) { + case 0: { + foo(); + } +} + +switch (x) { + default: + foo(); +} + +switch (x) { + default: + foo(); +} + +switch (x) { + default: { + foo(); + } +} + +switch (x) { + case 0: +} + +outer: while (true) { + switch (x) { + case 0: + x++; + break; + default: + break outer; + } +} + +outer2: while (true) { + inner: switch (x) { + case 0: + ++x; + break; + default: + } +} + diff --git a/test/rules/switch-final-break/default/test.ts.lint b/test/rules/switch-final-break/default/test.ts.lint new file mode 100644 index 00000000000..67b87b7fe64 --- /dev/null +++ b/test/rules/switch-final-break/default/test.ts.lint @@ -0,0 +1,70 @@ +switch (x) { + case 0: + foo(); +} + +switch (x) { + case 0: { + foo(); + } +} + +switch (x) { + case 0: + foo(); + break; + ~~~~~~ [0] +} + +switch (x) { + case 0: { + foo(); + break; + ~~~~~~ [0] + } +} + +switch (x) { + default: + foo(); + break; + ~~~~~~ [0] +} + +switch (x) { + default: + foo(); +} + +switch (x) { + default: { + foo(); + } +} + +switch (x) { + case 0: +} + +outer: while (true) { + switch (x) { + case 0: + x++; + break; + default: + break outer; + } +} + +outer2: while (true) { + inner: switch (x) { + case 0: + ++x; + break; + default: + break inner; + ~~~~~~~~~~~~ [0] + } +} + +[0]: Final clause in 'switch' statement should not end with 'break;'. diff --git a/test/rules/switch-final-break/default/tslint.json b/test/rules/switch-final-break/default/tslint.json new file mode 100644 index 00000000000..5fe1dee0d65 --- /dev/null +++ b/test/rules/switch-final-break/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "switch-final-break": true + } +} diff --git a/test/rules/trailing-comma/multiline-always/test.ts.fix b/test/rules/trailing-comma/multiline-always/test.ts.fix new file mode 100644 index 00000000000..f392b5179d4 --- /dev/null +++ b/test/rules/trailing-comma/multiline-always/test.ts.fix @@ -0,0 +1,602 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7, +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1, +}; + +var ss = [ + 6, +]; + +var tt = [ + 7, +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1, +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA, +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo, +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA, +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo, +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT, +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ, +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string, +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43, +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo", +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string, +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string, + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string, + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + } + >() { return 42; } + + set bar(foo: string) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string, + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + + new (bar: U): ITest; + + new (bar: U, baz: V,): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string, + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz, +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2, +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +export { + foo, + bar, +}; + +// don't crash +new Foo + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + +let foo = (bar): + | 1 + | 2 + | 3 => 1; diff --git a/test/rules/trailing-comma/multiline-always/test.ts.lint b/test/rules/trailing-comma/multiline-always/test.ts.lint new file mode 100644 index 00000000000..a12c0d9b4ed --- /dev/null +++ b/test/rules/trailing-comma/multiline-always/test.ts.lint @@ -0,0 +1,636 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) + ~nil [Missing trailing comma] +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 + ~nil [Missing trailing comma] +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 + ~nil [Missing trailing comma] +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 + ~nil [Missing trailing comma] +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 + ~nil [Missing trailing comma] +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA + ~nil [Missing trailing comma] +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo + ~nil [Missing trailing comma] +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA + ~nil [Missing trailing comma] +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo + ~nil [Missing trailing comma] +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT + ~nil [Missing trailing comma] +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ + ~nil [Missing trailing comma] +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string + ~nil [Missing trailing comma] +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string + ~nil [Missing trailing comma] +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string + ~nil [Missing trailing comma] +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string + ~nil [Missing trailing comma] +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 + ~nil [Missing trailing comma] +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" + ~nil [Missing trailing comma] +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string + ~nil [Missing trailing comma] +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ~nil [Missing trailing comma] + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ~nil [Missing trailing comma] + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + } + >() { return 42; } + + set bar(foo: string) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string + ~nil [Missing trailing comma] + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + + new (bar: U): ITest; + + new (bar: U, baz: V,): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ~nil [Missing trailing comma] + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz + ~nil [Missing trailing comma] +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 + ~nil [Missing trailing comma] +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +export { + foo, + bar + ~nil [Missing trailing comma] +}; + +// don't crash +new Foo + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let { + ...x + ~nil [Missing trailing comma] +} = {}; +let [ + ...y + ~nil [Missing trailing comma] +] = []; + +[ + ...y + ~nil [Missing trailing comma] +] = []; +({ + ...y + ~nil [Missing trailing comma] +} = {}) +function foo( + ...z + ~nil [Missing trailing comma] +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + +let foo = (bar): + | 1 + | 2 + | 3 => 1; diff --git a/test/rules/trailing-comma/multiline-always/tslint.json b/test/rules/trailing-comma/multiline-always/tslint.json new file mode 100644 index 00000000000..b9d77c2ab7c --- /dev/null +++ b/test/rules/trailing-comma/multiline-always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "trailing-comma": [true, {"multiline": "always"}] + } +} diff --git a/test/rules/trailing-comma/multiline-custom/always/test.ts.lint b/test/rules/trailing-comma/multiline-custom/always/test.ts.lint new file mode 100644 index 00000000000..77d4f47fee5 --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/always/test.ts.lint @@ -0,0 +1,578 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) + ~nil [Missing trailing comma] +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 + ~nil [Missing trailing comma] +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 + ~nil [Missing trailing comma] +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 + ~nil [Missing trailing comma] +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 + ~nil [Missing trailing comma] +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA + ~nil [Missing trailing comma] +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo + ~nil [Missing trailing comma] +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA + ~nil [Missing trailing comma] +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo + ~nil [Missing trailing comma] +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT + ~nil [Missing trailing comma] +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ + ~nil [Missing trailing comma] +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string + ~nil [Missing trailing comma] +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string + ~nil [Missing trailing comma] +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string + ~nil [Missing trailing comma] +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string + ~nil [Missing trailing comma] +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string + ~nil [Missing trailing comma] +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 + ~nil [Missing trailing comma] +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" + ~nil [Missing trailing comma] +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string + ~nil [Missing trailing comma] +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ~nil [Missing trailing comma] + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ~nil [Missing trailing comma] + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + } + >() { return 42; } + + set bar(foo: string) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string + ~nil [Missing trailing comma] + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + + new (bar: U): ITest; + + new (bar: U, baz: V,): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ~nil [Missing trailing comma] + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz + ~nil [Missing trailing comma] +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 + ~nil [Missing trailing comma] +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +export { + foo, + bar + ~nil [Missing trailing comma] +}; + +// don't crash +new Foo diff --git a/test/rules/trailing-comma/multiline-custom/always/tslint.json b/test/rules/trailing-comma/multiline-custom/always/tslint.json new file mode 100644 index 00000000000..d793508231c --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/always/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "multiline": { + "arrays": "always", + "exports": "always", + "functions": "always", + "imports": "always", + "objects": "always", + "typeLiterals": "always" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint b/test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint new file mode 100644 index 00000000000..b5f96410fb2 --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/ignore/test.ts.lint @@ -0,0 +1,549 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + } + >() { return 42; } + + set bar(foo: string) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + + new (bar: U): ITest; + + new (bar: U, baz: V,): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +export { + foo, + bar +}; + +// don't crash +new Foo diff --git a/test/rules/trailing-comma/multiline-custom/ignore/tslint.json b/test/rules/trailing-comma/multiline-custom/ignore/tslint.json new file mode 100644 index 00000000000..4ae13a80c11 --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/ignore/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "multiline": { + "arrays": "ignore", + "exports": "ignore", + "functions": "ignore", + "imports": "ignore", + "objects": "ignore", + "typeLiteral": "ignore" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint b/test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint new file mode 100644 index 00000000000..11a4550a30f --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/mixed/test.ts.lint @@ -0,0 +1,78 @@ +var a = [ + 'foo', + 'bar', + ~ [Unnecessary trailing comma] +] + +var a = [ + 'foo', + 'bar' +] + +export { + foo, + bar + ~nil [Missing trailing comma] +} + +export { + foo, + bar, +} + +function foo( + bar, + baz, +) + +function bar( + foo, + bar +) + +foo( + bar, + baz, +) + +foo( + bar, + baz +) + +import { + foo, + bar, + ~ [Unnecessary trailing comma] +} from 'foo' + +import { + foo, + bar +} from 'foo' + +var o = { + foo: 'foo', + bar: 'bar' + ~nil [Missing trailing comma] +} + +var o = { + foo: 'foo', + bar: 'bar', +} + +interface Foo { + foo: string, + bar: string +} + +interface Foo { + foo: string, + bar: string, +} + +interface Foo { + foo: string; + bar: string; +} diff --git a/test/rules/trailing-comma/multiline-custom/mixed/tslint.json b/test/rules/trailing-comma/multiline-custom/mixed/tslint.json new file mode 100644 index 00000000000..b888c1a0cf6 --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/mixed/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "multiline": { + "arrays": "never", + "exports": "always", + "functions": "ignore", + "imports": "never", + "objects": "always", + "typeLiterals": "ignore" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/multiline-custom/never/test.ts.fix b/test/rules/trailing-comma/multiline-custom/never/test.ts.fix new file mode 100644 index 00000000000..bd92433c252 --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/never/test.ts.fix @@ -0,0 +1,498 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6 +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24 +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6 +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24 +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA +} = s; + +var { + tA +} = t; + +var { + yA, + yB +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number +] = null; + +import { + ClassS +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43 +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo" +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >() { return 42; } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2 +} + diff --git a/test/rules/trailing-comma/multiline-custom/never/test.ts.lint b/test/rules/trailing-comma/multiline-custom/never/test.ts.lint new file mode 100644 index 00000000000..910d09ebe9d --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/never/test.ts.lint @@ -0,0 +1,527 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), + ~ [Unnecessary trailing comma] +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, + ~ [Unnecessary trailing comma] +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, + ~ [Unnecessary trailing comma] +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, + ~ [Unnecessary trailing comma] +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, + ~ [Unnecessary trailing comma] +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, + ~ [Unnecessary trailing comma] +} = s; + +var { + tA +} = t; + +var { + yA, + yB, + ~ [Unnecessary trailing comma] +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, + ~ [Unnecessary trailing comma] +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, + ~ [Unnecessary trailing comma] +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number +] = null; + +import { + ClassS, + ~ [Unnecessary trailing comma] +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, + ~ [Unnecessary trailing comma] +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, + ~ [Unnecessary trailing comma] +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, + ~ [Unnecessary trailing comma] +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", + ~ [Unnecessary trailing comma] +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, + ~ [Unnecessary trailing comma] +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ~ [Unnecessary trailing comma] + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ~ [Unnecessary trailing comma] + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >() { return 42; } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ~ [Unnecessary trailing comma] + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, + ~ [Unnecessary trailing comma] +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, + ~ [Unnecessary trailing comma] +} + diff --git a/test/rules/trailing-comma/multiline-custom/never/tslint.json b/test/rules/trailing-comma/multiline-custom/never/tslint.json new file mode 100644 index 00000000000..5509ed2ea5b --- /dev/null +++ b/test/rules/trailing-comma/multiline-custom/never/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "multiline": { + "arrays": "never", + "exports": "never", + "functions": "never", + "imports": "never", + "objects": "never", + "typeLiterals": "never" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/multiline-never/test.ts.fix b/test/rules/trailing-comma/multiline-never/test.ts.fix new file mode 100644 index 00000000000..9847bac3e8d --- /dev/null +++ b/test/rules/trailing-comma/multiline-never/test.ts.fix @@ -0,0 +1,545 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6 +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24 +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6 +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24 +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA +} = s; + +var { + tA +} = t; + +var { + yA, + yB +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number +] = null; + +import { + ClassS +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43 +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo" +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >() { return 42; } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2 +} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} diff --git a/test/rules/trailing-comma/multiline-never/test.ts.lint b/test/rules/trailing-comma/multiline-never/test.ts.lint new file mode 100644 index 00000000000..f3e0937fa2f --- /dev/null +++ b/test/rules/trailing-comma/multiline-never/test.ts.lint @@ -0,0 +1,579 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), + ~ [Unnecessary trailing comma] +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, + ~ [Unnecessary trailing comma] +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, + ~ [Unnecessary trailing comma] +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, + ~ [Unnecessary trailing comma] +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, + ~ [Unnecessary trailing comma] +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, + ~ [Unnecessary trailing comma] +} = s; + +var { + tA +} = t; + +var { + yA, + yB, + ~ [Unnecessary trailing comma] +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, + ~ [Unnecessary trailing comma] +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, + ~ [Unnecessary trailing comma] +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number +] = null; + +import { + ClassS, + ~ [Unnecessary trailing comma] +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, + ~ [Unnecessary trailing comma] +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, + ~ [Unnecessary trailing comma] +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, + ~ [Unnecessary trailing comma] +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", + ~ [Unnecessary trailing comma] +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, + ~ [Unnecessary trailing comma] +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ~ [Unnecessary trailing comma] + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ~ [Unnecessary trailing comma] + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >() { return 42; } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ~ [Unnecessary trailing comma] + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ~ [Unnecessary trailing comma] + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, + ~ [Unnecessary trailing comma] +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, + ~ [Unnecessary trailing comma] +} + +let { + ...x, + ~ [Unnecessary trailing comma] +} = {}; +let [ + ...y, + ~ [Unnecessary trailing comma] +] = []; + +[ + ...y, + ~ [Unnecessary trailing comma] +] = []; +({ + ...y, + ~ [Unnecessary trailing comma] +} = {}) +function foo( + ...z, + ~ [Unnecessary trailing comma] +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} diff --git a/test/rules/trailing-comma/multiline-never/tslint.json b/test/rules/trailing-comma/multiline-never/tslint.json new file mode 100644 index 00000000000..4ad240b0790 --- /dev/null +++ b/test/rules/trailing-comma/multiline-never/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "trailing-comma": [true, {"multiline": "never"}] + } +} diff --git a/test/rules/trailing-comma/singleline-always/test.ts.fix b/test/rules/trailing-comma/singleline-always/test.ts.fix new file mode 100644 index 00000000000..9f84332cca8 --- /dev/null +++ b/test/rules/trailing-comma/singleline-always/test.ts.fix @@ -0,0 +1,597 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +},]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1,}; + +var cc = [42, 24,]; + +var dd = [2, 1,]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo,} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo,] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD,} from "module"; + +function foo(bar: string, baz: string,); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string,) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string,) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string,) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43,); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo",); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string, }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string,) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string,) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } + + set bar(foo: string,) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + + new (bar: U,): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string,); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ, } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let foo = bar => bar; +let foo = (bar => bar); +let foo = async (bar,) => bar; +let foo = (async bar => bar); + +let foo = (bar,): + | 1 + | 2 + | 3 => 1; diff --git a/test/rules/trailing-comma/singleline-always/test.ts.lint b/test/rules/trailing-comma/singleline-always/test.ts.lint new file mode 100644 index 00000000000..5284963dfe4 --- /dev/null +++ b/test/rules/trailing-comma/singleline-always/test.ts.lint @@ -0,0 +1,629 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + ~nil [Missing trailing comma] + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + ~nil [Missing trailing comma] + ~nil [Missing trailing comma] + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + ~nil [Missing trailing comma] + +var cc = [42, 24,]; + +var dd = [2, 1]; + ~nil [Missing trailing comma] + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + ~nil [Missing trailing comma] + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + ~nil [Missing trailing comma] + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + ~nil [Missing trailing comma] + +function foo(bar: string, baz: string); + ~nil [Missing trailing comma] + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + ~nil [Missing trailing comma] + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + ~nil [Missing trailing comma] + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + ~nil [Missing trailing comma] + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + ~nil [Missing trailing comma] + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + ~nil [Missing trailing comma] + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + ~nil [Missing trailing comma] + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + ~nil [Missing trailing comma] + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + ~nil [Missing trailing comma] + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + ~nil [Missing trailing comma] + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + ~nil [Missing trailing comma] + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + ~nil [Missing trailing comma] + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } + + set bar(foo: string) { } + ~nil [Missing trailing comma] + + set bar2(foo: string,) { } + + set bar3( + foo: string + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + + new (bar: U): ITest; + ~nil [Missing trailing comma] + + new < + U, + V + >( + bar: U, + baz: U, + ack: V + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + ~nil [Missing trailing comma] + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + ~nil [Missing trailing comma] + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + ~nil [Missing trailing comma] + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x,} = {}; +let [...y,] = []; +[...y,] = []; +({...y,} = {}) +function foo(...z,) {} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; + ~nil [Missing trailing comma] +let [...y] = []; + ~nil [Missing trailing comma] +[...y] = []; + ~nil [Missing trailing comma] +({...y} = {}) + ~nil [Missing trailing comma] +function foo(...z) {} + ~nil [Missing trailing comma] + +let foo = bar => bar; +let foo = (bar => bar); +let foo = async (bar) => bar; + ~nil [Missing trailing comma] +let foo = (async bar => bar); + +let foo = (bar): + ~nil [Missing trailing comma] + | 1 + | 2 + | 3 => 1; diff --git a/test/rules/trailing-comma/singleline-always/tslint.json b/test/rules/trailing-comma/singleline-always/tslint.json new file mode 100644 index 00000000000..05767a6a9fc --- /dev/null +++ b/test/rules/trailing-comma/singleline-always/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "trailing-comma": [true, {"singleline": "always"}] + } +} diff --git a/test/rules/trailing-comma/singleline-custom/always/test.ts.fix b/test/rules/trailing-comma/singleline-custom/always/test.ts.fix new file mode 100644 index 00000000000..2aa1e2ec29b --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/always/test.ts.fix @@ -0,0 +1,540 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +},]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1,}; + +var cc = [42, 24,]; + +var dd = [2, 1,]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo,} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo,] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD,} from "module"; + +function foo(bar: string, baz: string,); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string,) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string,) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string,) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43,); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo",); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string, }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string,) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string,) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } + + set bar(foo: string,) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + + new (bar: U,): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string,); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ, } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + diff --git a/test/rules/trailing-comma/singleline-custom/always/test.ts.lint b/test/rules/trailing-comma/singleline-custom/always/test.ts.lint new file mode 100644 index 00000000000..e2fb321bdda --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/always/test.ts.lint @@ -0,0 +1,565 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + ~nil [Missing trailing comma] + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + ~nil [Missing trailing comma] + ~nil [Missing trailing comma] + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + ~nil [Missing trailing comma] + +var cc = [42, 24,]; + +var dd = [2, 1]; + ~nil [Missing trailing comma] + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + ~nil [Missing trailing comma] + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + ~nil [Missing trailing comma] + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + ~nil [Missing trailing comma] + +function foo(bar: string, baz: string); + ~nil [Missing trailing comma] + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + ~nil [Missing trailing comma] + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + ~nil [Missing trailing comma] + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + ~nil [Missing trailing comma] + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + ~nil [Missing trailing comma] + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + ~nil [Missing trailing comma] + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + ~nil [Missing trailing comma] + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + ~nil [Missing trailing comma] + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + ~nil [Missing trailing comma] + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + ~nil [Missing trailing comma] + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + ~nil [Missing trailing comma] + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + ~nil [Missing trailing comma] + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } + + set bar(foo: string) { } + ~nil [Missing trailing comma] + + set bar2(foo: string,) { } + + set bar3( + foo: string + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + + new (bar: U): ITest; + ~nil [Missing trailing comma] + + new < + U, + V + >( + bar: U, + baz: U, + ack: V + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + ~nil [Missing trailing comma] + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + ~nil [Missing trailing comma] + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + ~nil [Missing trailing comma] + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + diff --git a/test/rules/trailing-comma/singleline-custom/always/tslint.json b/test/rules/trailing-comma/singleline-custom/always/tslint.json new file mode 100644 index 00000000000..12cabc47ee2 --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/always/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "singleline": { + "arrays": "always", + "exports": "always", + "functions": "always", + "imports": "always", + "objects": "always", + "typeLiterals": "always" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint b/test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint new file mode 100644 index 00000000000..2204c42ff1a --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/ignore/test.ts.lint @@ -0,0 +1,540 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } + + set bar(foo: string) { } + + set bar2(foo: string,) { } + + set bar3( + foo: string + ) { } + + set bar4( + foo: string, + ) { } +} + +class Test2 { } + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + + new (bar: U): ITest; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V + ): ITest< + U, + U, + V + >; + + new < + U, + V + >( + bar: U, + baz: U, + ack: V, + foo: V, + ): ITest< + U, + U, + V + >; + + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A; bar: B; }, + U extends { foo: A; bar: B; }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + diff --git a/test/rules/trailing-comma/singleline-custom/ignore/tslint.json b/test/rules/trailing-comma/singleline-custom/ignore/tslint.json new file mode 100644 index 00000000000..0e6bca24404 --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/ignore/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "singleline": { + "arrays": "ignore", + "exports": "ignore", + "functions": "ignore", + "imports": "ignore", + "objects": "ignore", + "typeLiterals": "ignore" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint b/test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint new file mode 100644 index 00000000000..e2c80e4a8b1 --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/mixed/test.ts.lint @@ -0,0 +1,28 @@ +var a = ['foo', 'bar',] + ~ [Unnecessary trailing comma] + +var a = ['foo', 'bar'] + +export { foo, bar } + ~nil [Missing trailing comma] + +export { foo, bar, } + +function foo(bar, baz,) + +function bar(foo, bar) + +foo(bar, baz,) + +foo(bar, baz) + +import { foo, bar, } from 'foo' + ~ [Unnecessary trailing comma] + +import { foo, bar } from 'foo' + +interface Foo { foo: string, bar: string } + +interface Foo { foo: string, bar: string, } + +interface Foo { foo: string; bar: string; } diff --git a/test/rules/trailing-comma/singleline-custom/mixed/tslint.json b/test/rules/trailing-comma/singleline-custom/mixed/tslint.json new file mode 100644 index 00000000000..0afeee9475b --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/mixed/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "singleline": { + "arrays": "never", + "exports": "always", + "functions": "ignore", + "imports": "never", + "objects": "always", + "typeLiterals": "ignore" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/singleline-custom/never/test.ts.fix b/test/rules/trailing-comma/singleline-custom/never/test.ts.fix new file mode 100644 index 00000000000..5198ed5e6d3 --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/never/test.ts.fix @@ -0,0 +1,500 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +}]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo"); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } +} + +class Test2 { } + + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + diff --git a/test/rules/trailing-comma/singleline-custom/never/test.ts.lint b/test/rules/trailing-comma/singleline-custom/never/test.ts.lint new file mode 100644 index 00000000000..e1d597707fb --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/never/test.ts.lint @@ -0,0 +1,523 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + ~ [Unnecessary trailing comma] + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + ~ [Unnecessary trailing comma] + ~ [Unnecessary trailing comma] + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + ~ [Unnecessary trailing comma] + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + ~ [Unnecessary trailing comma] + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + ~ [Unnecessary trailing comma] + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + ~ [Unnecessary trailing comma] + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + ~ [Unnecessary trailing comma] + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + ~ [Unnecessary trailing comma] + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + ~ [Unnecessary trailing comma] + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + ~ [Unnecessary trailing comma] + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + ~ [Unnecessary trailing comma] + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + ~ [Unnecessary trailing comma] + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + ~ [Unnecessary trailing comma] + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + ~ [Unnecessary trailing comma] + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + ~ [Unnecessary trailing comma] + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + ~ [Unnecessary trailing comma] + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + ~ [Unnecessary trailing comma] + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + ~ [Unnecessary trailing comma] + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + ~ [Unnecessary trailing comma] + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } +} + +class Test2 { } + + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + ~ [Unnecessary trailing comma] + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + ~ [Unnecessary trailing comma] + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + ~ [Unnecessary trailing comma] + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + diff --git a/test/rules/trailing-comma/singleline-custom/never/tslint.json b/test/rules/trailing-comma/singleline-custom/never/tslint.json new file mode 100644 index 00000000000..375e4b0d1f5 --- /dev/null +++ b/test/rules/trailing-comma/singleline-custom/never/tslint.json @@ -0,0 +1,17 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "singleline": { + "arrays": "never", + "exports": "never", + "functions": "never", + "imports": "never", + "objects": "never", + "typeLiterals": "never" + } + } + ] + } +} diff --git a/test/rules/trailing-comma/singleline-never/test.ts.fix b/test/rules/trailing-comma/singleline-never/test.ts.fix new file mode 100644 index 00000000000..b01f2ab7b6d --- /dev/null +++ b/test/rules/trailing-comma/singleline-never/test.ts.fix @@ -0,0 +1,550 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +}]; + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24}; + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24]; + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB} = c; + +var {dOne, dTwo} = d; + +var [ccA, ccB] = cc; + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB} from "module"; + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string); + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string) { return 42; } + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string) => 42; + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string) => number = null; + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string) => number; + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43); + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo"); + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string }; + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string) { } + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string) { + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } +} + +class Test2 { } + + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string); + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ } + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + +let foo = bar => bar; +let foo = (bar => bar); diff --git a/test/rules/trailing-comma/singleline-never/test.ts.lint b/test/rules/trailing-comma/singleline-never/test.ts.lint new file mode 100644 index 00000000000..3d033030a6d --- /dev/null +++ b/test/rules/trailing-comma/singleline-never/test.ts.lint @@ -0,0 +1,578 @@ +var v = [{ + a: 1, + b: 2, + d: 34, + c: (a + b), +},]; + ~ [Unnecessary trailing comma] + +var x = [{ + a: 1, + b: 2, + d: 34, + c: (a + b) +}]; + +var s = { + sA: 6, +}; + +var t = { + tA: 7 +} + +var y = { + yA: 42, + yB: 24, +}; + +var z = { + zOne: 2, + zTwo: 1 +}; + +var ss = [ + 6, +]; + +var tt = [ + 7 +]; + +var yy = [ + 42, + 24, +]; + +var zz = [ + 2, + 1 +]; + +var a = [{a: 1, b: 2, d: 34, c: (a + b),},]; + ~ [Unnecessary trailing comma] + ~ [Unnecessary trailing comma] + +var b = [{a: 1, b: 2, d: 34, c: (a + b)}]; + +var c = {cA: 42, cB: 24,}; + ~ [Unnecessary trailing comma] + +var d = {dOne: 2, dTwo: 1}; + +var cc = [42, 24,]; + ~ [Unnecessary trailing comma] + +var dd = [2, 1]; + +var { + sA, +} = s; + +var { + tA +} = t; + +var { + yA, + yB, +} = y; + +var { + zOne, + zTwo +} = z; + +var [ + ssA, +] = ss; + +var [ + ttA +] = tt; + +var [ + yyA, + yyB, +] = yy; + +var [ + zzOne, + zzTwo +] = zz; + +var {cA, cB,} = c; + ~ [Unnecessary trailing comma] + +var {dOne, dTwo} = d; + +var [ccA, ccB,] = cc; + ~ [Unnecessary trailing comma] + +var [ddOne, ddTwo] = dd; + +var a: [string, number] = null; + +var a: [string, number,] = null; + +var a: [ + string, + number +] = null; + +var a: [ + string, + number, +] = null; + + +import { + ClassS, +} from "module"; + +import { + ClassT +} from "module"; + +import { + ClassV, + ClassX, +} from "module"; + +import { + ClassY, + ClassZ +} from "module"; + +import {ClassA, ClassB,} from "module"; + ~ [Unnecessary trailing comma] + +import {ClassC, ClassD} from "module"; + +function foo(bar: string, baz: string); + +function foo(bar: string, baz: string,); + ~ [Unnecessary trailing comma] + +function foo( + bar: string, + baz: string +); + +function foo( + bar: string, + baz: string, +); + +var foo = function(bar: string, baz: string) { return 42; }; + +var foo = function(bar: string, baz: string,) { return 42; }; + ~ [Unnecessary trailing comma] + +var foo = function( + bar: string, + baz: string +) { + return 42; +}; + +var foo = function( + bar: string, + baz: string, +) { + return 42; +}; + +function foo(bar: string, baz: string) { return 42; } + +function foo(bar: string, baz: string,) { return 42; } + ~ [Unnecessary trailing comma] + +function foo( + bar: string, + baz: string +) { + return 42; +} + +function foo( + bar: string, + baz: string, +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string +) { + return 42; +} + +function foo(bar: string, baz: string, + ack: string, +) { + return 42; +} + +var foo = (bar: string, baz: string) => 42; + +var foo = (bar: string, baz: string,) => 42; + ~ [Unnecessary trailing comma] + +var foo = ( + bar: string, + baz: string +) => 42; + +var foo = ( + bar: string, + baz: string, +) => 42; + +var foo: (bar: string, baz: string) => number = null; + +var foo: (bar: string, baz: string,) => number = null; + ~ [Unnecessary trailing comma] + +var foo: ( + bar: string, + baz: string +) => number = null; + +var foo: ( + bar: string, + baz: string, +) => number = null; + +var foo: (bar: string, baz: string) => number; + +var foo: (bar: string, baz: string,) => number; + ~ [Unnecessary trailing comma] + +var foo: ( + bar: string, + baz: string +) => number; + +var foo: ( + bar: string, + baz: string, +) => number; + +var foo: new (bar: string, baz: string) => Test; + +var foo: new (bar: string, baz: string,) => Test; + ~ [Unnecessary trailing comma] + +var foo: new ( + bar: string, + baz: string +) => Test; + +var foo: new ( + bar: string, + baz: string, +) => Test; + +var x = foo(42, 43); + +var x = foo(42, 43,); + ~ [Unnecessary trailing comma] + +var x = foo( + 42, + 43 +); + +var x = foo( + 42, + 43, +); + +var x = new Test("foo"); + +var x = new Test("foo",); + ~ [Unnecessary trailing comma] + +var x = new Test( + "foo" +); + +var x = new Test( + "foo", +); + +var x: { foo: string; bar: string }; + +var x: { foo: string; bar: string; }; + +var x: { + foo: string; + bar: string +}; + +var x: { + foo: string; + bar: string; +}; + +var x: { foo: string, bar: string }; + +var x: { foo: string, bar: string, }; + ~ [Unnecessary trailing comma] + +var x: { + foo: string, + bar: string +}; + +var x: { + foo: string, + bar: string, +}; + +class Test { + + constructor(bar: string) { } + + constructor(bar: string, baz: string,) { } + ~ [Unnecessary trailing comma] + + constructor( + bar: string, + baz: string, + ack: string + ) { } + + constructor( + bar: string, + baz: string, + ack: string, + foo: string, + ) { } + + public foo(bar: string, baz: string) { + return 42; + } + + private foo2(bar: string, baz: string,) { + ~ [Unnecessary trailing comma] + return 42; + } + + public static foo3( + bar: string, + baz: string + ) { + return 42; + } + + private static foo4( + bar: string, + baz: string, + ) { + return 42; + } + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ) { + return 42; + } + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string, + ]; + }, + >() { return 42; } +} + +class Test2 { } + + +class Test3< + A, + B, + C +> { } + +class Test4< + A, + B, + C, +> { } + +interface ITest { + foo(bar: string, baz: string); + + foo2(bar: string, baz: string,); + ~ [Unnecessary trailing comma] + + foo3( + bar: string, + baz: string + ); + + foo4( + bar: string, + baz: string, + ); + + foo5< + T extends Test<[A, A], [A, A], A>, + U extends Test, + V extends Test< + [ + C, + C + ], + [ + C, + C, + ], + C + > + >( + bar: A, + baz: T, + ); + + foo6< + T extends { foo: A, bar: B }, + U extends { foo: A, bar: B }, + V extends { + foo: A; + bar: B; + }, + W extends { + foo: [ + string, + string + ]; + } + >(); +} + +interface ITest2 { } + +interface ITest3< + A, + B, + C +> { } + +interface ITest4< + A, + B, + C, +> { } + +enum Foo { BAR, BAZ } + +enum Foo { BAR, BAZ, } + ~ [Unnecessary trailing comma] + +enum Foo { + Bar, + Baz +} + +enum Foo { + Bar, + Baz, +} + +const enum Foo { BAR = 1, BAZ = 2 } + +const enum Foo { BAR = 1, BAZ = 2, } + ~ [Unnecessary trailing comma] + +const enum Foo { + Bar = 1, + Baz = 2 +} + +const enum Foo { + Bar = 1, + Baz = 2, +} + +let { + ...x, +} = {}; +let [ + ...y, +] = []; + +[ + ...y, +] = []; +({ + ...y, +} = {}) +function foo( + ...z, +) {} + + +let {...x,} = {}; + ~ [Unnecessary trailing comma] +let [...y,] = []; + ~ [Unnecessary trailing comma] +[...y,] = []; + ~ [Unnecessary trailing comma] +({...y,} = {}) + ~ [Unnecessary trailing comma] +function foo(...z,) {} + ~ [Unnecessary trailing comma] + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + +let foo = bar => bar; +let foo = (bar => bar); diff --git a/test/rules/trailing-comma/singleline-never/tslint.json b/test/rules/trailing-comma/singleline-never/tslint.json new file mode 100644 index 00000000000..9cf46fd84b6 --- /dev/null +++ b/test/rules/trailing-comma/singleline-never/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "trailing-comma": [true, {"singleline": "never"}] + } +} diff --git a/test/rules/trailing-comma/spec-compliant/test.ts.fix b/test/rules/trailing-comma/spec-compliant/test.ts.fix new file mode 100644 index 00000000000..73c83825bb4 --- /dev/null +++ b/test/rules/trailing-comma/spec-compliant/test.ts.fix @@ -0,0 +1,66 @@ +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + + +[...y] = [...y,]; +({ + ...x +} = { + ...x, +}); +({ + ...x +} = { + ...x, + y, +}) +foo(...y,); + +function combined([a, ...arr], {b, ...obj}, regular,) {} + +function combined([a, ...arr], {b, ...obj}, regular,) {} diff --git a/test/rules/trailing-comma/spec-compliant/test.ts.lint b/test/rules/trailing-comma/spec-compliant/test.ts.lint new file mode 100644 index 00000000000..a2b896d2409 --- /dev/null +++ b/test/rules/trailing-comma/spec-compliant/test.ts.lint @@ -0,0 +1,83 @@ +let { + ...x, + ~ [Forbidden trailing comma] +} = {}; +let [ + ...y, + ~ [Forbidden trailing comma] +] = []; + +[ + ...y, + ~ [Forbidden trailing comma] +] = []; +({ + ...y, + ~ [Forbidden trailing comma] +} = {}) +function foo( + ...z, + ~ [Forbidden trailing comma] +) {} + + +let {...x,} = {}; + ~ [Forbidden trailing comma] +let [...y,] = []; + ~ [Forbidden trailing comma] +[...y,] = []; + ~ [Forbidden trailing comma] +({...y,} = {}) + ~ [Forbidden trailing comma] +function foo(...z,) {} + ~ [Forbidden trailing comma] + +let { + ...x +} = {}; +let [ + ...y +] = []; + +[ + ...y +] = []; +({ + ...y +} = {}) +function foo( + ...z +) {} + + +let {...x} = {}; +let [...y] = []; +[...y] = []; +({...y} = {}) +function foo(...z) {} + + +[...y] = [...y]; + ~nil [Missing trailing comma] +({ + ...x +} = { + ...x + ~nil [Missing trailing comma] +}); +({ + ...x +} = { + ...x, + y + ~nil [Missing trailing comma] +}) +foo(...y); + ~nil [Missing trailing comma] + +function combined([a, ...arr], {b, ...obj}, regular) {} + ~nil [Missing trailing comma] + +function combined([a, ...arr,], {b, ...obj,}, regular,) {} + ~ [Forbidden trailing comma] + ~ [Forbidden trailing comma] diff --git a/test/rules/trailing-comma/spec-compliant/tslint.json b/test/rules/trailing-comma/spec-compliant/tslint.json new file mode 100644 index 00000000000..3005eb3add4 --- /dev/null +++ b/test/rules/trailing-comma/spec-compliant/tslint.json @@ -0,0 +1,12 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "multiline": "always", + "singleline": "always", + "esSpecCompliant": true + } + ] + } +} diff --git a/test/rules/triple-equals/allow-null-check/test.ts.lint b/test/rules/triple-equals/allow-null-check/test.ts.lint new file mode 100644 index 00000000000..6fddcf97283 --- /dev/null +++ b/test/rules/triple-equals/allow-null-check/test.ts.lint @@ -0,0 +1,19 @@ +var testVariable = 123; + +function testFunction() { + if (x === testFunction && y == 4) { + ~~ [== should be ===] + console.log("called"); + } + + var z = (x + 3) != 5; + ~~ [!= should be !==] + return; +} + +// disallow double-equality undefined checks +var x = (y == undefined) ? 1 : 2; + ~~ [== should be ===] + +// allow double-equality null checks +var x = (y == null) ? 1 : 2; diff --git a/test/rules/triple-equals/allow-null-check/tslint.json b/test/rules/triple-equals/allow-null-check/tslint.json new file mode 100644 index 00000000000..b60bf169ef6 --- /dev/null +++ b/test/rules/triple-equals/allow-null-check/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "triple-equals": [true, "allow-null-check"] + } +} diff --git a/test/rules/triple-equals/allow-undefined-check/test.ts.lint b/test/rules/triple-equals/allow-undefined-check/test.ts.lint new file mode 100644 index 00000000000..a3e2136f538 --- /dev/null +++ b/test/rules/triple-equals/allow-undefined-check/test.ts.lint @@ -0,0 +1,19 @@ +var testVariable = 123; + +function testFunction() { + if (x === testFunction && y == 4) { + ~~ [== should be ===] + console.log("called"); + } + + var z = (x + 3) != 5; + ~~ [!= should be !==] + return; +} + +// allow double-equality undefined checks +var x = (y == undefined) ? 1 : 2; + +// disallow double-equality null checks +var x = (y == null) ? 1 : 2; + ~~ [== should be ===] diff --git a/test/rules/triple-equals/allow-undefined-check/tslint.json b/test/rules/triple-equals/allow-undefined-check/tslint.json new file mode 100644 index 00000000000..1ab9dce6344 --- /dev/null +++ b/test/rules/triple-equals/allow-undefined-check/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "triple-equals": [true, "allow-undefined-check"] + } +} diff --git a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix new file mode 100644 index 00000000000..75bb20c25af --- /dev/null +++ b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.fix @@ -0,0 +1,21 @@ +type T = { + x: number; + y: string; +}; + +type T = { + x: number; + y: string; +}; + +type T = { + x: number; + y: string; +}; + +type T = { x: number; y: string }; + +// Works even when there's extra whitespace +type T = { x: number ; y: number }; +type T = { x: number ; y: number }; + diff --git a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint new file mode 100644 index 00000000000..d5b99e77592 --- /dev/null +++ b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/test.ts.lint @@ -0,0 +1,30 @@ +type T = { + x: number, + ~ [COMMA] + y: string + ~ [MISSING] +}; + +type T = { + x: number + ~ [MISSING] + y: string, + ~ [COMMA] +}; + +type T = { + x: number; + y: string; +}; + +type T = { x: number; y: string }; + +// Works even when there's extra whitespace +type T = { x: number ; y: number }; +type T = { x: number , y: number ; }; + ~ [COMMA] + ~ [EXTRA] + +[MISSING]: Expected type literal to use ';' to separate members. +[COMMA]: Expected type literal to use ';' instead of ','. +[EXTRA]: Did not expect single-line type literal to have a trailing ';'. diff --git a/test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json new file mode 100644 index 00000000000..ba33191cc21 --- /dev/null +++ b/test/rules/type-literal-delimiter/one-liners-with-no-trailings/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "type-literal-delimiter": true + } +} diff --git a/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix b/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix new file mode 100644 index 00000000000..7d8243768e1 --- /dev/null +++ b/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.fix @@ -0,0 +1,21 @@ +type T = { + x: number; + y: string; +}; + +type T = { + x: number; + y: string; +}; + +type T = { + x: number; + y: string; +}; + +type T = { x: number; y: string; }; + +// Works even when there's extra whitespace +type T = { x: number ; y: number; }; +type T = { x: number ; y: number ; }; + diff --git a/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint b/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint new file mode 100644 index 00000000000..49c25a3699a --- /dev/null +++ b/test/rules/type-literal-delimiter/one-liners-with-trailings/test.ts.lint @@ -0,0 +1,31 @@ +type T = { + x: number, + ~ [COMMA] + y: string + ~ [MISSING] +}; + +type T = { + x: number + ~ [MISSING] + y: string, + ~ [COMMA] +}; + +type T = { + x: number; + y: string; +}; + +type T = { x: number; y: string }; + ~ [MISSING] + +// Works even when there's extra whitespace +type T = { x: number ; y: number }; + ~ [MISSING] +type T = { x: number , y: number ; }; + ~ [COMMA] + +[MISSING]: Expected type literal to use ';' to separate members. +[COMMA]: Expected type literal to use ';' instead of ','. +[EXTRA]: Did not expect single-line type literal to have a trailing ';'. diff --git a/test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json b/test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json new file mode 100644 index 00000000000..a7f4da3afc2 --- /dev/null +++ b/test/rules/type-literal-delimiter/one-liners-with-trailings/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "type-literal-delimiter": [ + true, + { + "singleLine": "always" + } + ] + } +} diff --git a/test/rules/typedef-whitespace/both/nospace/test.ts.lint b/test/rules/typedef-whitespace/both/nospace/test.ts.lint new file mode 100644 index 00000000000..23252dd10c3 --- /dev/null +++ b/test/rules/typedef-whitespace/both/nospace/test.ts.lint @@ -0,0 +1,905 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + ~ [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~ [before-call] + ~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~ [before-call] + ~~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~~~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~~~ [before-call] + ~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~~ [before-call] + ~~~ [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; + ~ [after-property] +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~~~ [after-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; + ~ [before-property] +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; + ~ [before-property] + ~ [after-property] +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; + ~ [before-property] + ~~~ [after-property] +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~~~ [before-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; + ~~~ [before-property] + ~ [after-property] +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; + ~~~ [before-property] + ~~~ [after-property] +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + ~ [after-parameter] + ~ [after-parameter] + ~ [after-call] + var c: number = a + b; + ~ [after-variable] + var d: number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~~~ [after-parameter] + ~~~ [after-parameter] + ~~~ [after-call] + var c: number = a + b; + ~~~ [after-variable] + var d: number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + ~ [before-parameter] + ~ [before-parameter] + ~ [before-call] + var c :number = a + b; + ~ [before-variable] + var d :number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + ~ [before-parameter] + ~ [after-parameter] + ~ [before-parameter] + ~ [after-parameter] + ~ [before-call] + ~ [after-call] + var c : number = a + b; + ~ [before-variable] + ~ [after-variable] + var d : number = a - b; + ~ [before-variable] + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + ~ [before-parameter] + ~~~ [after-parameter] + ~ [before-parameter] + ~~~ [after-parameter] + ~ [before-call] + ~~~ [after-call] + var c : number = a + b; + ~ [before-variable] + ~~~ [after-variable] + var d : number = a - b; + ~ [before-variable] + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~~~ [before-parameter] + ~~~ [before-parameter] + ~~~ [before-call] + var c :number = a + b; + ~~~ [before-variable] + var d :number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + ~~~ [before-parameter] + ~ [after-parameter] + ~~~ [before-parameter] + ~ [after-parameter] + ~~~ [before-call] + ~ [after-call] + var c : number = a + b; + ~~~ [before-variable] + ~ [after-variable] + var d : number = a - b; + ~~~ [before-variable] + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + ~~~ [before-parameter] + ~~~ [after-parameter] + ~~~ [before-parameter] + ~~~ [after-parameter] + ~~~ [before-call] + ~~~ [after-call] + var c : number = a + b; + ~~~ [before-variable] + ~~~ [after-variable] + var d : number = a - b; + ~~~ [before-variable] + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + ~~~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + number, b: + number): + number { + var c: + number = a + b; + var d + : number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex: + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + b:number +):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + ~ [after-parameter] + b: number + ~ [after-parameter] +): number { + ~ [after-call] + var c: number = a + b; + ~ [after-variable] + var d: number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~~~ [after-parameter] + b: number + ~~~ [after-parameter] +): number { + ~~~ [after-call] + var c: number = a + b; + ~~~ [after-variable] + var d: number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + ~ [before-parameter] + b :number + ~ [before-parameter] +) :number { + ~ [before-call] + var c :number = a + b; + ~ [before-variable] + var d :number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + ~ [before-parameter] + ~ [after-parameter] + b : number + ~ [before-parameter] + ~ [after-parameter] +) : number { + ~ [before-call] + ~ [after-call] + var c : number = a + b; + ~ [before-variable] + ~ [after-variable] + var d : number = a - b; + ~ [before-variable] + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + ~ [before-parameter] + ~~~ [after-parameter] + b : number + ~ [before-parameter] + ~~~ [after-parameter] +) : number { + ~ [before-call] + ~~~ [after-call] + var c : number = a + b; + ~ [before-variable] + ~~~ [after-variable] + var d : number = a - b; + ~ [before-variable] + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~~~ [before-parameter] + b :number + ~~~ [before-parameter] +) :number { + ~~~ [before-call] + var c :number = a + b; + ~~~ [before-variable] + var d :number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + ~~~ [before-parameter] + ~ [after-parameter] + b : number + ~~~ [before-parameter] + ~ [after-parameter] +) : number { + ~~~ [before-call] + ~ [after-call] + var c : number = a + b; + ~~~ [before-variable] + ~ [after-variable] + var d : number = a - b; + ~~~ [before-variable] + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + ~~~ [before-parameter] + ~~~ [after-parameter] + b : number + ~~~ [before-parameter] + ~~~ [after-parameter] +) : number { + ~~~ [before-call] + ~~~ [after-call] + var c : number = a + b; + ~~~ [before-variable] + ~~~ [after-variable] + var d : number = a - b; + ~~~ [before-variable] + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + ~~~ [after-variable] + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + ~ [after-call] + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~~~ [after-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + ~ [before-call] + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + ~ [before-call] + ~ [after-call] + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + ~ [before-call] + ~~~ [after-call] + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~~~ [before-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + ~~~ [before-call] + ~ [after-call] + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + ~~~ [before-call] + ~~~ [after-call] + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + + Prop:string = "some property"; + + public get name():string { + return "some name"; + } + + public set name(a:string):void {} + + public shemp( + a:number, + b:number + ):void {} +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + ~ [after-parameter] + ~ [after-index] + + Prop: string = "some property"; + ~ [after-property] + + public get name(): string { + ~ [after-call] + return "some name"; + } + + public set name(a: string): void {} + ~ [after-parameter] + ~ [after-call] + + public shemp( + a: number, + ~ [after-parameter] + b: number + ~ [after-parameter] + ): void {} + ~ [after-call] +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~~~ [after-parameter] + ~~~ [after-index] + + Prop: string = "some property"; + ~~~ [after-property] + + public get name(): string { + ~~~ [after-call] + return "some name"; + } + + public set name(a: string): void {} + ~~~ [after-parameter] + ~~~ [after-call] + + public shemp( + a: number, + ~~~ [after-parameter] + b: number + ~~~ [after-parameter] + ): void {} + ~~~ [after-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + ~ [before-parameter] + ~ [before-index] + + Prop :string = "some property"; + ~ [before-property] + + public get name() :string { + ~ [before-call] + return "some name"; + } + + public set name(a :string) :void {} + ~ [before-parameter] + ~ [before-call] + + public shemp( + a :number, + ~ [before-parameter] + b :number + ~ [before-parameter] + ) :void {} + ~ [before-call] +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + ~ [before-parameter] + ~ [after-parameter] + ~ [before-index] + ~ [after-index] + + Prop : string = "some property"; + ~ [before-property] + ~ [after-property] + + public get name() : string { + ~ [before-call] + ~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~ [before-parameter] + ~ [after-parameter] + ~ [before-call] + ~ [after-call] + + public shemp( + a : number, + ~ [before-parameter] + ~ [after-parameter] + b : number + ~ [before-parameter] + ~ [after-parameter] + ) : void {} + ~ [before-call] + ~ [after-call] +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + ~ [before-parameter] + ~~~ [after-parameter] + ~ [before-index] + ~~~ [after-index] + + Prop : string = "some property"; + ~ [before-property] + ~~~ [after-property] + + public get name() : string { + ~ [before-call] + ~~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~ [before-parameter] + ~~~ [after-parameter] + ~ [before-call] + ~~~ [after-call] + + public shemp( + a : number, + ~ [before-parameter] + ~~~ [after-parameter] + b : number + ~ [before-parameter] + ~~~ [after-parameter] + ) : void {} + ~ [before-call] + ~~~ [after-call] +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~~~ [before-parameter] + ~~~ [before-index] + + Prop :string = "some property"; + ~~~ [before-property] + + public get name() :string { + ~~~ [before-call] + return "some name"; + } + + public set name(a :string) :void {} + ~~~ [before-parameter] + ~~~ [before-call] + + public shemp( + a :number, + ~~~ [before-parameter] + b :number + ~~~ [before-parameter] + ) :void {} + ~~~ [before-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + ~~~ [before-parameter] + ~ [after-parameter] + ~~~ [before-index] + ~ [after-index] + + Prop : string = "some property"; + ~~~ [before-property] + ~ [after-property] + + public get name() : string { + ~~~ [before-call] + ~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~~ [before-parameter] + ~ [after-parameter] + ~~~ [before-call] + ~ [after-call] + + public shemp( + a : number, + ~~~ [before-parameter] + ~ [after-parameter] + b : number + ~~~ [before-parameter] + ~ [after-parameter] + ) : void {} + ~~~ [before-call] + ~ [after-call] +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + ~~~ [before-parameter] + ~~~ [after-parameter] + ~~~ [before-index] + ~~~ [after-index] + + Prop : string = "some property"; + ~~~ [before-property] + ~~~ [after-property] + + public get name() : string { + ~~~ [before-call] + ~~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~~ [before-parameter] + ~~~ [after-parameter] + ~~~ [before-call] + ~~~ [after-call] + + public shemp( + a : number, + ~~~ [before-parameter] + ~~~ [after-parameter] + b : number + ~~~ [before-parameter] + ~~~ [after-parameter] + ) : void {} + ~~~ [before-call] + ~~~ [after-call] +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + string + + Prop: + string = "some property"; + + public get name(): + string { + return "some name"; + } + + public set name(a: + string): + void {} + + public shemp( + a: + number, + b: + number + ): + void {} +} + +let foo = ():void => {}; +let foo = () : void => {}; + ~ [before-call] + ~ [after-call] +let foo = () : void => {}; + ~~~ [before-call] + ~~~ [after-call] + +interface Foo { + new() : Bar; + ~ [before-call] + ~ [after-call] + () : void; + ~ [before-call] + ~ [after-call] +} + +// endregion + +[_base]: expected nospace %s colon in %s +[before-call]: _base % ('before', 'call-signature') +[after-call]: _base % ('after', 'call-signature') +[before-parameter]: _base % ('before', 'parameter') +[after-parameter]: _base % ('after', 'parameter') +[before-index]: _base % ('before', 'index-signature') +[after-index]: _base % ('after', 'index-signature') +[before-variable]: _base % ('before', 'variable-declaration') +[after-variable]: _base % ('after', 'variable-declaration') +[before-property]: _base % ('before', 'property-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/both/nospace/tslint.json b/test/rules/typedef-whitespace/both/nospace/tslint.json new file mode 100644 index 00000000000..459b9de0890 --- /dev/null +++ b/test/rules/typedef-whitespace/both/nospace/tslint.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-trailing-whitespace": true, + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }] + } +} diff --git a/test/rules/typedef-whitespace/both/onespace/test.ts.lint b/test/rules/typedef-whitespace/both/onespace/test.ts.lint new file mode 100644 index 00000000000..b8759bcf8be --- /dev/null +++ b/test/rules/typedef-whitespace/both/onespace/test.ts.lint @@ -0,0 +1,913 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + ~nil [before-call] + ~nil [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + ~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~~ [before-call] + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [before-call] + ~~ [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + ~nil [before-call] + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; + ~nil [before-property] + ~nil [after-property] +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; + ~nil [before-property] +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~nil [before-property] + ~~ [after-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; + ~~ [after-property] +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~~ [before-property] + ~nil [after-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; + ~~ [before-property] +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; + ~~ [before-property] + ~~ [after-property] +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + ~nil [before-property] + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-call] + ~nil [after-call] + var c:number = a + b; + ~nil [before-variable] + ~nil [after-variable] + var d:number = a - b; + ~nil [before-variable] + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~nil [before-parameter] + ~~ [after-parameter] + ~nil [before-parameter] + ~~ [after-parameter] + ~nil [before-call] + ~~ [after-call] + var c: number = a + b; + ~nil [before-variable] + ~~ [after-variable] + var d: number = a - b; + ~nil [before-variable] + ~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + ~~ [after-parameter] + ~~ [after-parameter] + ~~ [after-call] + var c : number = a + b; + ~~ [after-variable] + var d : number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~~ [before-parameter] + ~nil [after-parameter] + ~~ [before-parameter] + ~nil [after-parameter] + ~~ [before-call] + ~nil [after-call] + var c :number = a + b; + ~~ [before-variable] + ~nil [after-variable] + var d :number = a - b; + ~~ [before-variable] + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~ [before-variable] + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + ~~ [before-parameter] + ~~ [before-parameter] + ~~ [before-call] + var c : number = a + b; + ~~ [before-variable] + var d : number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + ~~ [before-parameter] + ~~ [after-parameter] + ~~ [before-parameter] + ~~ [after-parameter] + ~~ [before-call] + ~~ [after-call] + var c : number = a + b; + ~~ [before-variable] + ~~ [after-variable] + var d : number = a - b; + ~~ [before-variable] + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + ~~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + ~nil [before-parameter] + number, b: + ~nil [before-parameter] + number): + ~nil [before-call] + number { + var c: + ~nil [before-variable] + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + ~nil [before-variable] + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + ~nil [before-parameter] + ~nil [after-parameter] + b:number + ~nil [before-parameter] + ~nil [after-parameter] +):number { + ~nil [before-call] + ~nil [after-call] + var c:number = a + b; + ~nil [before-variable] + ~nil [after-variable] + var d:number = a - b; + ~nil [before-variable] + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~nil [before-parameter] + ~~ [after-parameter] + b: number + ~nil [before-parameter] + ~~ [after-parameter] +): number { + ~nil [before-call] + ~~ [after-call] + var c: number = a + b; + ~nil [before-variable] + ~~ [after-variable] + var d: number = a - b; + ~nil [before-variable] + ~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + ~~ [after-parameter] + b : number + ~~ [after-parameter] +) : number { + ~~ [after-call] + var c : number = a + b; + ~~ [after-variable] + var d : number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~~ [before-parameter] + ~nil [after-parameter] + b :number + ~~ [before-parameter] + ~nil [after-parameter] +) :number { + ~~ [before-call] + ~nil [after-call] + var c :number = a + b; + ~~ [before-variable] + ~nil [after-variable] + var d :number = a - b; + ~~ [before-variable] + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~ [before-variable] + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + ~~ [before-parameter] + b : number + ~~ [before-parameter] +) : number { + ~~ [before-call] + var c : number = a + b; + ~~ [before-variable] + var d : number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + ~~ [before-parameter] + ~~ [after-parameter] + b : number + ~~ [before-parameter] + ~~ [after-parameter] +) : number { + ~~ [before-call] + ~~ [after-call] + var c : number = a + b; + ~~ [before-variable] + ~~ [after-variable] + var d : number = a - b; + ~~ [before-variable] + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + ~~ [after-variable] + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + ~nil [before-call] + ~nil [after-call] + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + ~nil [before-call] + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~nil [before-call] + ~~ [after-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + ~~ [after-call] + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~~ [before-call] + ~nil [after-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + ~~ [before-call] + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + ~~ [before-call] + ~~ [after-call] + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + ~nil [before-call] + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-index] + ~nil [after-index] + + Prop:string = "some property"; + ~nil [before-property] + ~nil [after-property] + + public get name():string { + ~nil [before-call] + ~nil [after-call] + return "some name"; + } + + public set name(a:string):void {} + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-call] + ~nil [after-call] + + public shemp( + a:number, + ~nil [before-parameter] + ~nil [after-parameter] + b:number + ~nil [before-parameter] + ~nil [after-parameter] + ):void {} + ~nil [before-call] + ~nil [after-call] +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~nil [before-parameter] + ~~ [after-parameter] + ~nil [before-index] + ~~ [after-index] + + Prop: string = "some property"; + ~nil [before-property] + ~~ [after-property] + + public get name(): string { + ~nil [before-call] + ~~ [after-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~~ [after-parameter] + ~nil [before-call] + ~~ [after-call] + + public shemp( + a: number, + ~nil [before-parameter] + ~~ [after-parameter] + b: number + ~nil [before-parameter] + ~~ [after-parameter] + ): void {} + ~nil [before-call] + ~~ [after-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + ~~ [after-parameter] + ~~ [after-index] + + Prop : string = "some property"; + ~~ [after-property] + + public get name() : string { + ~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [after-parameter] + ~~ [after-call] + + public shemp( + a : number, + ~~ [after-parameter] + b : number + ~~ [after-parameter] + ) : void {} + ~~ [after-call] +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~~ [before-parameter] + ~nil [after-parameter] + ~~ [before-index] + ~nil [after-index] + + Prop :string = "some property"; + ~~ [before-property] + ~nil [after-property] + + public get name() :string { + ~~ [before-call] + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~~ [before-parameter] + ~nil [after-parameter] + ~~ [before-call] + ~nil [after-call] + + public shemp( + a :number, + ~~ [before-parameter] + ~nil [after-parameter] + b :number + ~~ [before-parameter] + ~nil [after-parameter] + ) :void {} + ~~ [before-call] + ~nil [after-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + ~~ [before-parameter] + ~~ [before-index] + + Prop : string = "some property"; + ~~ [before-property] + + public get name() : string { + ~~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [before-parameter] + ~~ [before-call] + + public shemp( + a : number, + ~~ [before-parameter] + b : number + ~~ [before-parameter] + ) : void {} + ~~ [before-call] +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + ~~ [before-parameter] + ~~ [after-parameter] + ~~ [before-index] + ~~ [after-index] + + Prop : string = "some property"; + ~~ [before-property] + ~~ [after-property] + + public get name() : string { + ~~ [before-call] + ~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [before-parameter] + ~~ [after-parameter] + ~~ [before-call] + ~~ [after-call] + + public shemp( + a : number, + ~~ [before-parameter] + ~~ [after-parameter] + b : number + ~~ [before-parameter] + ~~ [after-parameter] + ) : void {} + ~~ [before-call] + ~~ [after-call] +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-index] + string + + Prop: + ~nil [before-property] + string = "some property"; + + public get name(): + ~nil [before-call] + string { + return "some name"; + } + + public set name(a: + ~nil [before-parameter] + string): + ~nil [before-call] + void {} + + public shemp( + a: + ~nil [before-parameter] + number, + b: + ~nil [before-parameter] + number + ): + ~nil [before-call] + void {} +} + +let foo = ():void => {}; + ~nil [before-call] + ~nil [after-call] +let foo = () : void => {}; +let foo = () : void => {}; + ~~ [before-call] + ~~ [after-call] + +// endregion + +[_base]: expected onespace %s colon in %s +[before-call]: _base % ('before', 'call-signature') +[after-call]: _base % ('after', 'call-signature') +[before-parameter]: _base % ('before', 'parameter') +[after-parameter]: _base % ('after', 'parameter') +[before-index]: _base % ('before', 'index-signature') +[after-index]: _base % ('after', 'index-signature') +[before-variable]: _base % ('before', 'variable-declaration') +[after-variable]: _base % ('after', 'variable-declaration') +[before-property]: _base % ('before', 'property-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/both/onespace/tslint.json b/test/rules/typedef-whitespace/both/onespace/tslint.json new file mode 100644 index 00000000000..fcf1d6674eb --- /dev/null +++ b/test/rules/typedef-whitespace/both/onespace/tslint.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-trailing-whitespace": true, + "typedef-whitespace": [true, { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + }, { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + }] + } +} diff --git a/test/rules/typedef-whitespace/both/space/test.ts.lint b/test/rules/typedef-whitespace/both/space/test.ts.lint new file mode 100644 index 00000000000..3ba0bcc341f --- /dev/null +++ b/test/rules/typedef-whitespace/both/space/test.ts.lint @@ -0,0 +1,767 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + ~nil [before-call] + ~nil [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + ~nil [before-call] + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; + ~nil [before-property] + ~nil [after-property] +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; + ~nil [before-property] +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~nil [before-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + ~nil [before-property] + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-call] + ~nil [after-call] + var c:number = a + b; + ~nil [before-variable] + ~nil [after-variable] + var d:number = a - b; + ~nil [before-variable] + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + ~nil [before-parameter] + number, b: + ~nil [before-parameter] + number): + ~nil [before-call] + number { + var c: + ~nil [before-variable] + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + ~nil [before-variable] + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + ~nil [before-parameter] + ~nil [after-parameter] + b:number + ~nil [before-parameter] + ~nil [after-parameter] +):number { + ~nil [before-call] + ~nil [after-call] + var c:number = a + b; + ~nil [before-variable] + ~nil [after-variable] + var d:number = a - b; + ~nil [before-variable] + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + ~nil [before-call] + ~nil [after-call] + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + ~nil [before-call] + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~nil [before-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + ~nil [before-call] + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-index] + ~nil [after-index] + + Prop:string = "some property"; + ~nil [before-property] + ~nil [after-property] + + public get name():string { + ~nil [before-call] + ~nil [after-call] + return "some name"; + } + + public set name(a:string):void {} + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-call] + ~nil [after-call] + + public shemp( + a:number, + ~nil [before-parameter] + ~nil [after-parameter] + b:number + ~nil [before-parameter] + ~nil [after-parameter] + ):void {} + ~nil [before-call] + ~nil [after-call] +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + ~nil [before-parameter] + ~nil [after-parameter] + ~nil [before-index] + string + + Prop: + ~nil [before-property] + string = "some property"; + + public get name(): + ~nil [before-call] + string { + return "some name"; + } + + public set name(a: + ~nil [before-parameter] + string): + ~nil [before-call] + void {} + + public shemp( + a: + ~nil [before-parameter] + number, + b: + ~nil [before-parameter] + number + ): + ~nil [before-call] + void {} +} + +let foo = ():void => {}; + ~nil [before-call] + ~nil [after-call] +let foo = () : void => {}; +let foo = () : void => {}; + +// endregion + +[_base]: expected space %s colon in %s +[before-call]: _base % ('before', 'call-signature') +[after-call]: _base % ('after', 'call-signature') +[before-parameter]: _base % ('before', 'parameter') +[after-parameter]: _base % ('after', 'parameter') +[before-index]: _base % ('before', 'index-signature') +[after-index]: _base % ('after', 'index-signature') +[before-variable]: _base % ('before', 'variable-declaration') +[after-variable]: _base % ('after', 'variable-declaration') +[before-property]: _base % ('before', 'property-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/both/space/tslint.json b/test/rules/typedef-whitespace/both/space/tslint.json new file mode 100644 index 00000000000..44bbc56c01f --- /dev/null +++ b/test/rules/typedef-whitespace/both/space/tslint.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-trailing-whitespace": true, + "typedef-whitespace": [true, { + "call-signature": "space", + "index-signature": "space", + "parameter": "space", + "property-declaration": "space", + "variable-declaration": "space" + }, { + "call-signature": "space", + "index-signature": "space", + "parameter": "space", + "property-declaration": "space", + "variable-declaration": "space" + }] + } +} diff --git a/test/rules/typedef-whitespace/left/nospace/test.ts.lint b/test/rules/typedef-whitespace/left/nospace/test.ts.lint new file mode 100644 index 00000000000..6ee93d35296 --- /dev/null +++ b/test/rules/typedef-whitespace/left/nospace/test.ts.lint @@ -0,0 +1,745 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~~~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~~~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~~ [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; + ~ [before-property] +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; + ~ [before-property] +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; + ~ [before-property] +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~~~ [before-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; + ~~~ [before-property] +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; + ~~~ [before-property] +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + ~ [before-parameter] + ~ [before-parameter] + ~ [before-call] + var c :number = a + b; + ~ [before-variable] + var d :number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + ~ [before-parameter] + ~ [before-parameter] + ~ [before-call] + var c : number = a + b; + ~ [before-variable] + var d : number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + ~ [before-parameter] + ~ [before-parameter] + ~ [before-call] + var c : number = a + b; + ~ [before-variable] + var d : number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~~~ [before-parameter] + ~~~ [before-parameter] + ~~~ [before-call] + var c :number = a + b; + ~~~ [before-variable] + var d :number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + ~~~ [before-parameter] + ~~~ [before-parameter] + ~~~ [before-call] + var c : number = a + b; + ~~~ [before-variable] + var d : number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + ~~~ [before-parameter] + ~~~ [before-parameter] + ~~~ [before-call] + var c : number = a + b; + ~~~ [before-variable] + var d : number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + number, b: + number): + number { + var c: + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + b:number +):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + ~ [before-parameter] + b :number + ~ [before-parameter] +) :number { + ~ [before-call] + var c :number = a + b; + ~ [before-variable] + var d :number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + ~ [before-parameter] + b : number + ~ [before-parameter] +) : number { + ~ [before-call] + var c : number = a + b; + ~ [before-variable] + var d : number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + ~ [before-parameter] + b : number + ~ [before-parameter] +) : number { + ~ [before-call] + var c : number = a + b; + ~ [before-variable] + var d : number = a - b; + ~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~~~ [before-parameter] + b :number + ~~~ [before-parameter] +) :number { + ~~~ [before-call] + var c :number = a + b; + ~~~ [before-variable] + var d :number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + ~~~ [before-parameter] + b : number + ~~~ [before-parameter] +) : number { + ~~~ [before-call] + var c : number = a + b; + ~~~ [before-variable] + var d : number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + ~~~ [before-parameter] + b : number + ~~~ [before-parameter] +) : number { + ~~~ [before-call] + var c : number = a + b; + ~~~ [before-variable] + var d : number = a - b; + ~~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [before-variable] + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + ~ [before-call] + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + ~ [before-call] + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + ~ [before-call] + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~~~ [before-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + ~~~ [before-call] + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + ~~~ [before-call] + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + + Prop:string = "some property"; + + public get name():string { + return "some name"; + } + + public set name(a:string):void {} + + public shemp( + a:number, + b:number + ):void {} +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + ~ [before-parameter] + ~ [before-index] + + Prop :string = "some property"; + ~ [before-property] + + public get name() :string { + ~ [before-call] + return "some name"; + } + + public set name(a :string) :void {} + ~ [before-parameter] + ~ [before-call] + + public shemp( + a :number, + ~ [before-parameter] + b :number + ~ [before-parameter] + ) :void {} + ~ [before-call] +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + ~ [before-parameter] + ~ [before-index] + + Prop : string = "some property"; + ~ [before-property] + + public get name() : string { + ~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~ [before-parameter] + ~ [before-call] + + public shemp( + a : number, + ~ [before-parameter] + b : number + ~ [before-parameter] + ) : void {} + ~ [before-call] +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + ~ [before-parameter] + ~ [before-index] + + Prop : string = "some property"; + ~ [before-property] + + public get name() : string { + ~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~ [before-parameter] + ~ [before-call] + + public shemp( + a : number, + ~ [before-parameter] + b : number + ~ [before-parameter] + ) : void {} + ~ [before-call] +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~~~ [before-parameter] + ~~~ [before-index] + + Prop :string = "some property"; + ~~~ [before-property] + + public get name() :string { + ~~~ [before-call] + return "some name"; + } + + public set name(a :string) :void {} + ~~~ [before-parameter] + ~~~ [before-call] + + public shemp( + a :number, + ~~~ [before-parameter] + b :number + ~~~ [before-parameter] + ) :void {} + ~~~ [before-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + ~~~ [before-parameter] + ~~~ [before-index] + + Prop : string = "some property"; + ~~~ [before-property] + + public get name() : string { + ~~~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~~ [before-parameter] + ~~~ [before-call] + + public shemp( + a : number, + ~~~ [before-parameter] + b : number + ~~~ [before-parameter] + ) : void {} + ~~~ [before-call] +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + ~~~ [before-parameter] + ~~~ [before-index] + + Prop : string = "some property"; + ~~~ [before-property] + + public get name() : string { + ~~~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~~ [before-parameter] + ~~~ [before-call] + + public shemp( + a : number, + ~~~ [before-parameter] + b : number + ~~~ [before-parameter] + ) : void {} + ~~~ [before-call] +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + string + + Prop: + string = "some property"; + + public get name(): + string { + return "some name"; + } + + public set name(a: + string): + void {} + + public shemp( + a: + number, + b: + number + ): + void {} +} + +let foo = ():void => {}; +let foo = () : void => {}; + ~ [before-call] +let foo = () : void => {}; + ~~~ [before-call] + +// endregion + +[_base]: expected nospace %s colon in %s +[before-call]: _base % ('before', 'call-signature') +[before-parameter]: _base % ('before', 'parameter') +[before-index]: _base % ('before', 'index-signature') +[before-variable]: _base % ('before', 'variable-declaration') +[before-property]: _base % ('before', 'property-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/left/nospace/tslint.json b/test/rules/typedef-whitespace/left/nospace/tslint.json new file mode 100644 index 00000000000..55e481c3176 --- /dev/null +++ b/test/rules/typedef-whitespace/left/nospace/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }] + } +} diff --git a/test/rules/typedef-whitespace/left/onespace/test.ts.lint b/test/rules/typedef-whitespace/left/onespace/test.ts.lint new file mode 100644 index 00000000000..cd2182c989a --- /dev/null +++ b/test/rules/typedef-whitespace/left/onespace/test.ts.lint @@ -0,0 +1,762 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + ~nil [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [before-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + ~nil [before-call] + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; + ~nil [before-property] +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; + ~nil [before-property] +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~nil [before-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~~ [before-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; + ~~ [before-property] +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; + ~~ [before-property] +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + ~nil [before-property] + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c:number = a + b; + ~nil [before-variable] + var d:number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~~ [before-parameter] + ~~ [before-parameter] + ~~ [before-call] + var c :number = a + b; + ~~ [before-variable] + var d :number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + ~~ [before-parameter] + ~~ [before-parameter] + ~~ [before-call] + var c : number = a + b; + ~~ [before-variable] + var d : number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + ~~ [before-parameter] + ~~ [before-parameter] + ~~ [before-call] + var c : number = a + b; + ~~ [before-variable] + var d : number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + ~nil [before-parameter] + number, b: + ~nil [before-parameter] + number): + ~nil [before-call] + number { + var c: + ~nil [before-variable] + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + ~nil [before-variable] + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + ~nil [before-parameter] + b:number + ~nil [before-parameter] +):number { + ~nil [before-call] + var c:number = a + b; + ~nil [before-variable] + var d:number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~~ [before-parameter] + b :number + ~~ [before-parameter] +) :number { + ~~ [before-call] + var c :number = a + b; + ~~ [before-variable] + var d :number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + ~~ [before-parameter] + b : number + ~~ [before-parameter] +) : number { + ~~ [before-call] + var c : number = a + b; + ~~ [before-variable] + var d : number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + ~~ [before-parameter] + b : number + ~~ [before-parameter] +) : number { + ~~ [before-call] + var c : number = a + b; + ~~ [before-variable] + var d : number = a - b; + ~~ [before-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [before-variable] + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + ~nil [before-call] + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + ~nil [before-call] + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~nil [before-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~~ [before-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + ~~ [before-call] + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + ~~ [before-call] + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + ~nil [before-call] + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + ~nil [before-parameter] + ~nil [before-index] + + Prop:string = "some property"; + ~nil [before-property] + + public get name():string { + ~nil [before-call] + return "some name"; + } + + public set name(a:string):void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a:number, + ~nil [before-parameter] + b:number + ~nil [before-parameter] + ):void {} + ~nil [before-call] +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~~ [before-parameter] + ~~ [before-index] + + Prop :string = "some property"; + ~~ [before-property] + + public get name() :string { + ~~ [before-call] + return "some name"; + } + + public set name(a :string) :void {} + ~~ [before-parameter] + ~~ [before-call] + + public shemp( + a :number, + ~~ [before-parameter] + b :number + ~~ [before-parameter] + ) :void {} + ~~ [before-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + ~~ [before-parameter] + ~~ [before-index] + + Prop : string = "some property"; + ~~ [before-property] + + public get name() : string { + ~~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [before-parameter] + ~~ [before-call] + + public shemp( + a : number, + ~~ [before-parameter] + b : number + ~~ [before-parameter] + ) : void {} + ~~ [before-call] +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + ~~ [before-parameter] + ~~ [before-index] + + Prop : string = "some property"; + ~~ [before-property] + + public get name() : string { + ~~ [before-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [before-parameter] + ~~ [before-call] + + public shemp( + a : number, + ~~ [before-parameter] + b : number + ~~ [before-parameter] + ) : void {} + ~~ [before-call] +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + ~nil [before-parameter] + ~nil [before-index] + string + + Prop: + ~nil [before-property] + string = "some property"; + + public get name(): + ~nil [before-call] + string { + return "some name"; + } + + public set name(a: + ~nil [before-parameter] + string): + ~nil [before-call] + void {} + + public shemp( + a: + ~nil [before-parameter] + number, + b: + ~nil [before-parameter] + number + ): + ~nil [before-call] + void {} +} + +let foo = ():void => {}; + ~nil [before-call] +let foo = () : void => {}; +let foo = () : void => {}; + ~~ [before-call] + +// endregion + +[_base]: expected onespace %s colon in %s +[before-call]: _base % ('before', 'call-signature') +[before-parameter]: _base % ('before', 'parameter') +[before-index]: _base % ('before', 'index-signature') +[before-variable]: _base % ('before', 'variable-declaration') +[before-property]: _base % ('before', 'property-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/left/onespace/tslint.json b/test/rules/typedef-whitespace/left/onespace/tslint.json new file mode 100644 index 00000000000..aff33c3aa84 --- /dev/null +++ b/test/rules/typedef-whitespace/left/onespace/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "typedef-whitespace": [true, { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + }] + } +} diff --git a/test/rules/typedef-whitespace/left/space/test.ts.lint b/test/rules/typedef-whitespace/left/space/test.ts.lint new file mode 100644 index 00000000000..b28c78ae7de --- /dev/null +++ b/test/rules/typedef-whitespace/left/space/test.ts.lint @@ -0,0 +1,689 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + ~nil [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~nil [before-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + ~nil [before-call] + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; + ~nil [before-property] +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; + ~nil [before-property] +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~nil [before-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + ~nil [before-property] + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c:number = a + b; + ~nil [before-variable] + var d:number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~nil [before-parameter] + ~nil [before-parameter] + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + ~nil [before-parameter] + number, b: + ~nil [before-parameter] + number): + ~nil [before-call] + number { + var c: + ~nil [before-variable] + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + ~nil [before-variable] + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + ~nil [before-parameter] + b:number + ~nil [before-parameter] +):number { + ~nil [before-call] + var c:number = a + b; + ~nil [before-variable] + var d:number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] +): number { + ~nil [before-call] + var c: number = a + b; + ~nil [before-variable] + var d: number = a - b; + ~nil [before-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~nil [before-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + ~nil [before-call] + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + ~nil [before-call] + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~nil [before-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + ~nil [before-call] + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + ~nil [before-parameter] + ~nil [before-index] + + Prop:string = "some property"; + ~nil [before-property] + + public get name():string { + ~nil [before-call] + return "some name"; + } + + public set name(a:string):void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a:number, + ~nil [before-parameter] + b:number + ~nil [before-parameter] + ):void {} + ~nil [before-call] +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~nil [before-parameter] + ~nil [before-index] + + Prop: string = "some property"; + ~nil [before-property] + + public get name(): string { + ~nil [before-call] + return "some name"; + } + + public set name(a: string): void {} + ~nil [before-parameter] + ~nil [before-call] + + public shemp( + a: number, + ~nil [before-parameter] + b: number + ~nil [before-parameter] + ): void {} + ~nil [before-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + ~nil [before-parameter] + ~nil [before-index] + string + + Prop: + ~nil [before-property] + string = "some property"; + + public get name(): + ~nil [before-call] + string { + return "some name"; + } + + public set name(a: + ~nil [before-parameter] + string): + ~nil [before-call] + void {} + + public shemp( + a: + ~nil [before-parameter] + number, + b: + ~nil [before-parameter] + number + ): + ~nil [before-call] + void {} +} + +let foo = ():void => {}; + ~nil [before-call] +let foo = () : void => {}; +let foo = () : void => {}; + +// endregion + +[_base]: expected space %s colon in %s +[before-call]: _base % ('before', 'call-signature') +[before-parameter]: _base % ('before', 'parameter') +[before-index]: _base % ('before', 'index-signature') +[before-variable]: _base % ('before', 'variable-declaration') +[before-property]: _base % ('before', 'property-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/left/space/tslint.json b/test/rules/typedef-whitespace/left/space/tslint.json new file mode 100644 index 00000000000..b4da3d889fa --- /dev/null +++ b/test/rules/typedef-whitespace/left/space/tslint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "typedef-whitespace": [true, { + "call-signature": "space", + "index-signature": "space", + "parameter": "space", + "property-declaration": "space", + "variable-declaration": "space" + }] + } +} diff --git a/test/rules/typedef-whitespace/none/test.ts.lint b/test/rules/typedef-whitespace/none/test.ts.lint new file mode 100644 index 00000000000..3815729540f --- /dev/null +++ b/test/rules/typedef-whitespace/none/test.ts.lint @@ -0,0 +1,527 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + b:number +):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + + Prop:string = "some property"; + + public get name():string { + return "some name"; + } + + public set name(a:string):void {} + + public shemp( + a:number, + b:number + ):void {} +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +// endregion diff --git a/test/rules/typedef-whitespace/none/tslint.json b/test/rules/typedef-whitespace/none/tslint.json new file mode 100644 index 00000000000..09c46892473 --- /dev/null +++ b/test/rules/typedef-whitespace/none/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "typedef-whitespace": true + } +} diff --git a/test/rules/typedef-whitespace/right/nospace/test.ts.lint b/test/rules/typedef-whitespace/right/nospace/test.ts.lint new file mode 100644 index 00000000000..736a420e3c6 --- /dev/null +++ b/test/rules/typedef-whitespace/right/nospace/test.ts.lint @@ -0,0 +1,745 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + ~ [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + ~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~~ [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; + ~ [after-property] +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~~~ [after-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; + ~ [after-property] +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; + ~~~ [after-property] +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; + ~ [after-property] +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; + ~~~ [after-property] +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + ~ [after-parameter] + ~ [after-parameter] + ~ [after-call] + var c: number = a + b; + ~ [after-variable] + var d: number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~~~ [after-parameter] + ~~~ [after-parameter] + ~~~ [after-call] + var c: number = a + b; + ~~~ [after-variable] + var d: number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + ~ [after-parameter] + ~ [after-parameter] + ~ [after-call] + var c : number = a + b; + ~ [after-variable] + var d : number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + ~~~ [after-parameter] + ~~~ [after-parameter] + ~~~ [after-call] + var c : number = a + b; + ~~~ [after-variable] + var d : number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + ~ [after-parameter] + ~ [after-parameter] + ~ [after-call] + var c : number = a + b; + ~ [after-variable] + var d : number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + ~~~ [after-parameter] + ~~~ [after-parameter] + ~~~ [after-call] + var c : number = a + b; + ~~~ [after-variable] + var d : number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + number, b: + number): + number { + var c: + number = a + b; + var d + : number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex: + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + b:number +):number { + var c:number = a + b; + var d:number = a - b; + + try { + return c / d; + } catch (ex:Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + ~ [after-parameter] + b: number + ~ [after-parameter] +): number { + ~ [after-call] + var c: number = a + b; + ~ [after-variable] + var d: number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~~~ [after-parameter] + b: number + ~~~ [after-parameter] +): number { + ~~~ [after-call] + var c: number = a + b; + ~~~ [after-variable] + var d: number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + ~ [after-parameter] + b : number + ~ [after-parameter] +) : number { + ~ [after-call] + var c : number = a + b; + ~ [after-variable] + var d : number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + ~~~ [after-parameter] + b : number + ~~~ [after-parameter] +) : number { + ~~~ [after-call] + var c : number = a + b; + ~~~ [after-variable] + var d : number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + b :number +) :number { + var c :number = a + b; + var d :number = a - b; + + try { + return c / d; + } catch (ex :Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + ~ [after-parameter] + b : number + ~ [after-parameter] +) : number { + ~ [after-call] + var c : number = a + b; + ~ [after-variable] + var d : number = a - b; + ~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + ~~~ [after-parameter] + b : number + ~~~ [after-parameter] +) : number { + ~~~ [after-call] + var c : number = a + b; + ~~~ [after-variable] + var d : number = a - b; + ~~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~~ [after-variable] + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + ~ [after-call] + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~~~ [after-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + ~ [after-call] + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + ~~~ [after-call] + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + ~ [after-call] + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + ~~~ [after-call] + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + + Prop:string = "some property"; + + public get name():string { + return "some name"; + } + + public set name(a:string):void {} + + public shemp( + a:number, + b:number + ):void {} +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + ~ [after-parameter] + ~ [after-index] + + Prop: string = "some property"; + ~ [after-property] + + public get name(): string { + ~ [after-call] + return "some name"; + } + + public set name(a: string): void {} + ~ [after-parameter] + ~ [after-call] + + public shemp( + a: number, + ~ [after-parameter] + b: number + ~ [after-parameter] + ): void {} + ~ [after-call] +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~~~ [after-parameter] + ~~~ [after-index] + + Prop: string = "some property"; + ~~~ [after-property] + + public get name(): string { + ~~~ [after-call] + return "some name"; + } + + public set name(a: string): void {} + ~~~ [after-parameter] + ~~~ [after-call] + + public shemp( + a: number, + ~~~ [after-parameter] + b: number + ~~~ [after-parameter] + ): void {} + ~~~ [after-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + ~ [after-parameter] + ~ [after-index] + + Prop : string = "some property"; + ~ [after-property] + + public get name() : string { + ~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~ [after-parameter] + ~ [after-call] + + public shemp( + a : number, + ~ [after-parameter] + b : number + ~ [after-parameter] + ) : void {} + ~ [after-call] +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + ~~~ [after-parameter] + ~~~ [after-index] + + Prop : string = "some property"; + ~~~ [after-property] + + public get name() : string { + ~~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~~ [after-parameter] + ~~~ [after-call] + + public shemp( + a : number, + ~~~ [after-parameter] + b : number + ~~~ [after-parameter] + ) : void {} + ~~~ [after-call] +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + + Prop :string = "some property"; + + public get name() :string { + return "some name"; + } + + public set name(a :string) :void {} + + public shemp( + a :number, + b :number + ) :void {} +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + ~ [after-parameter] + ~ [after-index] + + Prop : string = "some property"; + ~ [after-property] + + public get name() : string { + ~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~ [after-parameter] + ~ [after-call] + + public shemp( + a : number, + ~ [after-parameter] + b : number + ~ [after-parameter] + ) : void {} + ~ [after-call] +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + ~~~ [after-parameter] + ~~~ [after-index] + + Prop : string = "some property"; + ~~~ [after-property] + + public get name() : string { + ~~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~~ [after-parameter] + ~~~ [after-call] + + public shemp( + a : number, + ~~~ [after-parameter] + b : number + ~~~ [after-parameter] + ) : void {} + ~~~ [after-call] +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + string + + Prop: + string = "some property"; + + public get name(): + string { + return "some name"; + } + + public set name(a: + string): + void {} + + public shemp( + a: + number, + b: + number + ): + void {} +} + +let foo = ():void => {}; +let foo = () : void => {}; + ~ [after-call] +let foo = () : void => {}; + ~~~ [after-call] + +// endregion + +[_base]: expected nospace %s colon in %s +[after-call]: _base % ('after', 'call-signature') +[after-parameter]: _base % ('after', 'parameter') +[after-index]: _base % ('after', 'index-signature') +[after-variable]: _base % ('after', 'variable-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/right/nospace/tslint.json b/test/rules/typedef-whitespace/right/nospace/tslint.json new file mode 100644 index 00000000000..779f842dcc4 --- /dev/null +++ b/test/rules/typedef-whitespace/right/nospace/tslint.json @@ -0,0 +1,12 @@ +{ + "rules": { + "no-trailing-whitespace": true, + "typedef-whitespace": [true, {}, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }] + } +} diff --git a/test/rules/typedef-whitespace/right/onespace/test.ts.lint b/test/rules/typedef-whitespace/right/onespace/test.ts.lint new file mode 100644 index 00000000000..69d3d585fa9 --- /dev/null +++ b/test/rules/typedef-whitespace/right/onespace/test.ts.lint @@ -0,0 +1,745 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + ~nil [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + ~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + ~~ [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; + ~nil [after-property] +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; + ~~ [after-property] +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; + ~~ [after-property] +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; + ~~ [after-property] +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c:number = a + b; + ~nil [after-variable] + var d:number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + ~~ [after-parameter] + ~~ [after-parameter] + ~~ [after-call] + var c: number = a + b; + ~~ [after-variable] + var d: number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + ~~ [after-parameter] + ~~ [after-parameter] + ~~ [after-call] + var c : number = a + b; + ~~ [after-variable] + var d : number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + ~~ [after-parameter] + ~~ [after-parameter] + ~~ [after-call] + var c : number = a + b; + ~~ [after-variable] + var d : number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + number, b: + number): + number { + var c: + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + ~nil [after-parameter] + b:number + ~nil [after-parameter] +):number { + ~nil [after-call] + var c:number = a + b; + ~nil [after-variable] + var d:number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + ~~ [after-parameter] + b: number + ~~ [after-parameter] +): number { + ~~ [after-call] + var c: number = a + b; + ~~ [after-variable] + var d: number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex: Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + ~~ [after-parameter] + b : number + ~~ [after-parameter] +) : number { + ~~ [after-call] + var c : number = a + b; + ~~ [after-variable] + var d : number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + ~~ [after-parameter] + b : number + ~~ [after-parameter] +) : number { + ~~ [after-call] + var c : number = a + b; + ~~ [after-variable] + var d : number = a - b; + ~~ [after-variable] + + try { + return c / d; + } catch (ex : Exception) { + ~~ [after-variable] + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + ~nil [after-call] + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + ~~ [after-call] + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + ~~ [after-call] + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + ~~ [after-call] + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + ~nil [after-parameter] + ~nil [after-index] + + Prop:string = "some property"; + ~nil [after-property] + + public get name():string { + ~nil [after-call] + return "some name"; + } + + public set name(a:string):void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a:number, + ~nil [after-parameter] + b:number + ~nil [after-parameter] + ):void {} + ~nil [after-call] +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + ~~ [after-parameter] + ~~ [after-index] + + Prop: string = "some property"; + ~~ [after-property] + + public get name(): string { + ~~ [after-call] + return "some name"; + } + + public set name(a: string): void {} + ~~ [after-parameter] + ~~ [after-call] + + public shemp( + a: number, + ~~ [after-parameter] + b: number + ~~ [after-parameter] + ): void {} + ~~ [after-call] +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + ~~ [after-parameter] + ~~ [after-index] + + Prop : string = "some property"; + ~~ [after-property] + + public get name() : string { + ~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [after-parameter] + ~~ [after-call] + + public shemp( + a : number, + ~~ [after-parameter] + b : number + ~~ [after-parameter] + ) : void {} + ~~ [after-call] +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + ~~ [after-parameter] + ~~ [after-index] + + Prop : string = "some property"; + ~~ [after-property] + + public get name() : string { + ~~ [after-call] + return "some name"; + } + + public set name(a : string) : void {} + ~~ [after-parameter] + ~~ [after-call] + + public shemp( + a : number, + ~~ [after-parameter] + b : number + ~~ [after-parameter] + ) : void {} + ~~ [after-call] +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + ~nil [after-parameter] + string + + Prop: + string = "some property"; + + public get name(): + string { + return "some name"; + } + + public set name(a: + string): + void {} + + public shemp( + a: + number, + b: + number + ): + void {} +} + +let foo = ():void => {}; + ~nil [after-call] +let foo = () : void => {}; +let foo = () : void => {}; + ~~ [after-call] + +// endregion + +[_base]: expected onespace %s colon in %s +[after-call]: _base % ('after', 'call-signature') +[after-parameter]: _base % ('after', 'parameter') +[after-index]: _base % ('after', 'index-signature') +[after-variable]: _base % ('after', 'variable-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/right/onespace/tslint.json b/test/rules/typedef-whitespace/right/onespace/tslint.json new file mode 100644 index 00000000000..ec35766ca4d --- /dev/null +++ b/test/rules/typedef-whitespace/right/onespace/tslint.json @@ -0,0 +1,12 @@ +{ + "rules": { + "no-trailing-whitespace": true, + "typedef-whitespace": [true, {}, { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + }] + } +} diff --git a/test/rules/typedef-whitespace/right/space/test.ts.lint b/test/rules/typedef-whitespace/right/space/test.ts.lint new file mode 100644 index 00000000000..86a91e08702 --- /dev/null +++ b/test/rules/typedef-whitespace/right/space/test.ts.lint @@ -0,0 +1,672 @@ +// region ObjectLiteralWithPropertyGetter + +var noPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop():string { + ~nil [after-call] + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop(): string { + return this._Prop; + } +}; + +var withPreceedingSpaceNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpaceWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesNoSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() :string { + ~nil [after-call] + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpaceObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var withPreceedingSpacesWithSubsequentSpacesObject = { + _Prop: "some property", + + get Prop() : string { + return this._Prop; + } +}; + +var noPreceedingSpaceWithSubsequentNewLineObject = { + _Prop: + "some property", + + get Prop(): + string { + return this._Prop; + } +}; + +// endregion + +// region Interface + +interface NoPreceedingSpaceNoSubsequentSpaceInterface { + Prop:string; + ~nil [after-property] +} + +interface NoPreceedingSpaceWithSubsequentSpaceInterface { + Prop: string; +} + +interface NoPreceedingSpaceWithSubsequentSpacesInterface { + Prop: string; +} + +interface WithPreceedingSpaceNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpaceWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpaceWithSubsequentSpacesInterface { + Prop : string; +} + +interface WithPreceedingSpacesNoSubsequentSpaceInterface { + Prop :string; + ~nil [after-property] +} + +interface WithPreceedingSpacesWithSubsequentSpaceInterface { + Prop : string; +} + +interface WithPreceedingSpacesWithSubsequentSpacesInterface { + Prop : string; +} + +interface NoPreceedingSpaceNoSubsequentSpaceAndNewLineInterface { + Prop: + string; +} + +// endregion + +// region Function + +function noPreceedingSpaceNoSubsequentSpaceFn(a:number, b:number):number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c:number = a + b; + ~nil [after-variable] + var d:number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesFn(a: number, b: number): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceFn(a :number, b :number) :number { + ~nil [after-parameter] + ~nil [after-parameter] + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesFn(a : number, b : number) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineFn(a: + number, b: + number): + number { + var c: + number = a + b; + var d + : number = a - b; + + try { + return c / d; + } catch (ex: + Exception) { + console.log(ex); + } +} + +// endregion + +// region Function multi-line signature + +function noPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a:number, + ~nil [after-parameter] + b:number + ~nil [after-parameter] +):number { + ~nil [after-call] + var c:number = a + b; + ~nil [after-variable] + var d:number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex:Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function noPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a: number, + b: number +): number { + var c: number = a + b; + var d: number = a - b; + + try { + return c / d; + } catch (ex: Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpaceWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesNoSubsequentSpaceMultiLineFn( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] +) :number { + ~nil [after-call] + var c :number = a + b; + ~nil [after-variable] + var d :number = a - b; + ~nil [after-variable] + + try { + return c / d; + } catch (ex :Exception) { + ~nil [after-variable] + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpaceMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +function withPreceedingSpacesWithSubsequentSpacesMultiLineFn( + a : number, + b : number +) : number { + var c : number = a + b; + var d : number = a - b; + + try { + return c / d; + } catch (ex : Exception) { + console.log(ex); + } +} + +// endregion + +// region CallSignaturePaddedParams + +function noPreceedingSpaceNoSubsequentSpaceSignature( ):{}; + ~nil [after-call] + +function noPreceedingSpaceWithSubsequentSpaceSignature( ): {}; + +function noPreceedingSpaceWithSubsequentSpacesSignature( ): {}; + +function withPreceedingSpaceNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpaceWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpaceWithSubsequentSpacesSignature( ) : {}; + +function withPreceedingSpacesNoSubsequentSpaceSignature( ) :{}; + ~nil [after-call] + +function withPreceedingSpacesWithSubsequentSpaceSignature( ) : {}; + +function withPreceedingSpacesWithSubsequentSpacesSignature( ) : {}; + +function noPreceedingSpaceNoSubsequentSpaceAndNewLineSignature( ): + {}; + +// endregion + +// region Class + +class NoPreceedingSpaceNoSubsequentSpaceClass { + [index:number]:string + ~nil [after-parameter] + ~nil [after-index] + + Prop:string = "some property"; + ~nil [after-property] + + public get name():string { + ~nil [after-call] + return "some name"; + } + + public set name(a:string):void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a:number, + ~nil [after-parameter] + b:number + ~nil [after-parameter] + ):void {} + ~nil [after-call] +} + +class NoPreceedingSpaceWithSubsequentSpaceClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class NoPreceedingSpaceWithSubsequentSpacesClass { + [index: number]: string + + Prop: string = "some property"; + + public get name(): string { + return "some name"; + } + + public set name(a: string): void {} + + public shemp( + a: number, + b: number + ): void {} +} + +class WithPreceedingSpaceNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpaceWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpaceWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesNoSubsequentSpaceClass { + [index :number] :string + ~nil [after-parameter] + ~nil [after-index] + + Prop :string = "some property"; + ~nil [after-property] + + public get name() :string { + ~nil [after-call] + return "some name"; + } + + public set name(a :string) :void {} + ~nil [after-parameter] + ~nil [after-call] + + public shemp( + a :number, + ~nil [after-parameter] + b :number + ~nil [after-parameter] + ) :void {} + ~nil [after-call] +} + +class WithPreceedingSpacesWithSubsequentSpaceClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class WithPreceedingSpacesWithSubsequentSpacesClass { + [index : number] : string + + Prop : string = "some property"; + + public get name() : string { + return "some name"; + } + + public set name(a : string) : void {} + + public shemp( + a : number, + b : number + ) : void {} +} + +class NoPreceedingSpaceNoSubsequentSpaceAndNewLineClass { + [index:number]: + ~nil [after-parameter] + string + + Prop: + string = "some property"; + + public get name(): + string { + return "some name"; + } + + public set name(a: + string): + void {} + + public shemp( + a: + number, + b: + number + ): + void {} +} + +let foo = ():void => {}; + ~nil [after-call] +let foo = () : void => {}; +let foo = () : void => {}; + +// endregion + +[_base]: expected space %s colon in %s +[after-call]: _base % ('after', 'call-signature') +[after-parameter]: _base % ('after', 'parameter') +[after-index]: _base % ('after', 'index-signature') +[after-variable]: _base % ('after', 'variable-declaration') +[after-property]: _base % ('after', 'property-declaration') \ No newline at end of file diff --git a/test/rules/typedef-whitespace/right/space/tslint.json b/test/rules/typedef-whitespace/right/space/tslint.json new file mode 100644 index 00000000000..2a839372c24 --- /dev/null +++ b/test/rules/typedef-whitespace/right/space/tslint.json @@ -0,0 +1,12 @@ +{ + "rules": { + "no-trailing-whitespace": true, + "typedef-whitespace": [true, {}, { + "call-signature": "space", + "index-signature": "space", + "parameter": "space", + "property-declaration": "space", + "variable-declaration": "space" + }] + } +} diff --git a/test/rules/typedef/all/test.ts.lint b/test/rules/typedef/all/test.ts.lint new file mode 100644 index 00000000000..60256bce0f7 --- /dev/null +++ b/test/rules/typedef/all/test.ts.lint @@ -0,0 +1,107 @@ +// should not error with missing exception type +try { +} catch (e) { +} + +var NoTypeObjectLiteralWithPropertyGetter = { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [expected variable-declaration: 'NoTypeObjectLiteralWithPropertyGetter' to have a typedef] + Prop: "some property", + + get PropDef() { + ~~~~~~~ [expected call-signature: 'PropDef' to have a typedef] + return this.Prop; + }, + + methodDef() { + ~~~~~~~~~ [expected call-signature: 'methodDef' to have a typedef] + return 'untyped'; + }, + + anotherMethodDef: function() { + ~~ [expected call-signature to have a typedef] + return 'also untyped'; + }, + + arrowMethodDef: () => { + ~~ [expected arrow-call-signature to have a typedef] + return 'also untyped'; + } +}; + +interface NoTypeInterface { + Prop; + ~~~~ [expected property-declaration: 'Prop' to have a typedef] + PropWithType: string; +} + +var NoTypesFn = function (a, b) { + ~~~~~~~~~ [expected variable-declaration: 'NoTypesFn' to have a typedef] + ~ [expected parameter: 'a' to have a typedef] + ~ [expected parameter: 'b' to have a typedef] + ~~~~~~ [expected call-signature to have a typedef] + var c = a + b, + ~ [expected variable-declaration: 'c' to have a typedef] + d = a - b; + ~ [expected variable-declaration: 'd' to have a typedef] + +class TsLint { + helloWorld() { + ~~~~~~~~~~ [expected call-signature: 'helloWorld' to have a typedef] + return 'Hello World'; + }; + + regularMemberWithType: string = this.getValue(); + + regularMemberWithoutType = this.getValue(); + ~~~~~~~~~~~~~~~~~~~~~~~~ [expected member-variable-declaration: 'regularMemberWithoutType' to have a typedef] + + arrowHelloWorld = () => { + ~~ [expected arrow-call-signature to have a typedef] + return this.helloWorld(); + }; + + arrowHelloWorldWithArgsNoTypedef = (arg1) => { + ~~~~ [expected member-variable-declaration: 'arg1' to have a typedef] + ~~~~~~ [expected arrow-call-signature to have a typedef] + return this.helloWorld(); + }; + + arrowHelloWorldWithArgsTypedefProperty: (arg1: string) => string = (arg1) => { + return this.helloWorld(); + }; + + arrowHelloWorldWithArgsTypedefInline = (arg1: string): string => { + return this.helloWorld(); + }; +} + +setTimeout(() => {}, 1000); + ~~ [expected arrow-call-signature to have a typedef] +setTimeout(function() {}, 1000); + ~~ [expected call-signature to have a typedef] + +someFunc(n => n+1); + ~~~ [expected arrow-call-signature to have a typedef] + ~ [expected arrow-parameter: 'n' to have a typedef] +someFunc(n => {}); + ~~~ [expected arrow-call-signature to have a typedef] + ~ [expected arrow-parameter: 'n' to have a typedef] + +class A { + // property w/o an initializer + public foo; + ~~~ [expected member-variable-declaration: 'foo' to have a typedef] + private bar: number; +} + + +const { paramA, paramB } = { paramA: "test", paramB: 15 }; + ~~~~~~~~~~~~~~~~~~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] + +const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; + +const [ paramA, paramB ] = [15, 'test']; + ~~~~~~~~~~~~~~~~~~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] + +const [ paramA3, paramB3 ]: [ number, string ] = [15, 'test']; + diff --git a/test/rules/typedef/all/tslint.json b/test/rules/typedef/all/tslint.json new file mode 100644 index 00000000000..70ecde71823 --- /dev/null +++ b/test/rules/typedef/all/tslint.json @@ -0,0 +1,15 @@ +{ + "rules": { + "typedef": [true, + "call-signature", + "arrow-call-signature", + "parameter", + "arrow-parameter", + "variable-declaration", + "property-declaration", + "member-variable-declaration", + "object-destructuring", + "array-destructuring" + ] + } +} diff --git a/test/rules/typedef/array-destructuring/test.ts.lint b/test/rules/typedef/array-destructuring/test.ts.lint new file mode 100644 index 00000000000..2781fce8f6a --- /dev/null +++ b/test/rules/typedef/array-destructuring/test.ts.lint @@ -0,0 +1,4 @@ +const [ paramA, paramB ] = [15, 'test']; + ~~~~~~~~~~~~~~~~~~ [expected array-destructuring: '[ paramA, paramB ]' to have a typedef] + +const [ paramA3, paramB3 ]: { number: string, paramB1: string } = [15, 'test']; diff --git a/test/rules/typedef/array-destructuring/tslint.json b/test/rules/typedef/array-destructuring/tslint.json new file mode 100644 index 00000000000..fcc56d55361 --- /dev/null +++ b/test/rules/typedef/array-destructuring/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "array-destructuring" + ] + } +} diff --git a/test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint b/test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint new file mode 100644 index 00000000000..b2ebdc7a502 --- /dev/null +++ b/test/rules/typedef/arrow-call-signature-and-parameter/test.ts.lint @@ -0,0 +1,12 @@ +class AComponent { + private _test(): void { + this._foo.test({ + callback: () => { + // asd + }, + }); + } +} + +function foo(bar: any) :void {} +foo({bar: ()=>{}}); \ No newline at end of file diff --git a/test/rules/typedef/arrow-call-signature-and-parameter/tslint.json b/test/rules/typedef/arrow-call-signature-and-parameter/tslint.json new file mode 100644 index 00000000000..fd636ff1fa4 --- /dev/null +++ b/test/rules/typedef/arrow-call-signature-and-parameter/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "typedef": [true, + "parameter", + "call-signature" + ] + } +} diff --git a/test/rules/typedef/arrow-call-signature/test.ts.lint b/test/rules/typedef/arrow-call-signature/test.ts.lint new file mode 100644 index 00000000000..37ca4446442 --- /dev/null +++ b/test/rules/typedef/arrow-call-signature/test.ts.lint @@ -0,0 +1,30 @@ +function foge() {} + +class TsLint { + helloWorld() { + return 'Hello World'; + }; + + arrowHelloWorld = () => { + ~~ [expected arrow-call-signature to have a typedef] + return this.helloWorld(); + }; +} + +var obj = { + foge: function() {}, + bar: () => {} + ~~ [expected arrow-call-signature to have a typedef] +} + +setTimeout(() => {}, 1000); + ~~ [expected arrow-call-signature to have a typedef] +setTimeout(function() {}, 1000); + +const foo = n => n+1 + ~~~~ [expected arrow-call-signature to have a typedef] + +someFunc(n => n+1); + ~~~ [expected arrow-call-signature to have a typedef] +someFunc(n => {}); + ~~~ [expected arrow-call-signature to have a typedef] diff --git a/test/rules/typedef/arrow-call-signature/tslint.json b/test/rules/typedef/arrow-call-signature/tslint.json new file mode 100644 index 00000000000..fe8057f1088 --- /dev/null +++ b/test/rules/typedef/arrow-call-signature/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "arrow-call-signature" + ] + } +} diff --git a/test/rules/typedef/arrow-parameter/test.ts.lint b/test/rules/typedef/arrow-parameter/test.ts.lint new file mode 100644 index 00000000000..1a8a2180dc1 --- /dev/null +++ b/test/rules/typedef/arrow-parameter/test.ts.lint @@ -0,0 +1,13 @@ +var NoTypesFn = function (a, b) {} + +var NoTypesArrowFn = (a, b) => {} + ~ [expected arrow-parameter: 'a' to have a typedef] + ~ [expected arrow-parameter: 'b' to have a typedef] + +someFunc(n => n+1); + ~ [expected arrow-parameter: 'n' to have a typedef] +someFunc((n) => n+1); + ~ [expected arrow-parameter: 'n' to have a typedef] +someFunc((n,m) => n+m); + ~ [expected arrow-parameter: 'n' to have a typedef] + ~ [expected arrow-parameter: 'm' to have a typedef] diff --git a/test/rules/typedef/arrow-parameter/tslint.json b/test/rules/typedef/arrow-parameter/tslint.json new file mode 100644 index 00000000000..fe7a8c4e913 --- /dev/null +++ b/test/rules/typedef/arrow-parameter/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "arrow-parameter" + ] + } +} diff --git a/test/rules/typedef/call-signature/test.ts.lint b/test/rules/typedef/call-signature/test.ts.lint new file mode 100644 index 00000000000..fe695835056 --- /dev/null +++ b/test/rules/typedef/call-signature/test.ts.lint @@ -0,0 +1,39 @@ +function foge() {} + ~~~~ [expected call-signature: 'foge' to have a typedef] + +class TsLint { + helloWorld() { + ~~~~~~~~~~ [expected call-signature: 'helloWorld' to have a typedef] + return 'Hello World'; + }; + + arrowHelloWorld = () => { + return this.helloWorld(); + }; +} + +var obj = { + foge: function() {}, + ~~ [expected call-signature to have a typedef] + bar: () => {} +} + +setTimeout(() => {}, 1000); +setTimeout(function() {}, 1000); + ~~ [expected call-signature to have a typedef] + +someFunc(n => n+1); +someFunc(n => {}); + +class AComponent { + private _test(): void { + this._foo.test({ + callback: () => { + // asd + }, + }); + } +} + +function foo(bar: any) :void {} +foo({bar: ()=>{}}); diff --git a/test/rules/typedef/call-signature/tslint.json b/test/rules/typedef/call-signature/tslint.json new file mode 100644 index 00000000000..067259a15fe --- /dev/null +++ b/test/rules/typedef/call-signature/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "call-signature" + ] + } +} diff --git a/test/rules/typedef/member-variable-declaration/test.ts.lint b/test/rules/typedef/member-variable-declaration/test.ts.lint new file mode 100644 index 00000000000..a437c7b7d58 --- /dev/null +++ b/test/rules/typedef/member-variable-declaration/test.ts.lint @@ -0,0 +1,16 @@ +class TypesMemberArrowFn { + fn: (param: string) => void = (param) => {} +} + +class TypesInFunctionMemberArrowFn { + fn = (param: string) => {} +} + +class TypesInFunctionWithReturnMemberArrowFn { + fn = (param: string): void => {} +} + +class NoTypesMemberArrowFn { + fn = (param) => {} + ~~~~~ [expected member-variable-declaration: 'param' to have a typedef] +} diff --git a/test/rules/typedef/member-variable-declaration/tslint.json b/test/rules/typedef/member-variable-declaration/tslint.json new file mode 100644 index 00000000000..d6bef7c0dbe --- /dev/null +++ b/test/rules/typedef/member-variable-declaration/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "member-variable-declaration" + ] + } +} diff --git a/test/rules/typedef/none/test.ts.lint b/test/rules/typedef/none/test.ts.lint new file mode 100644 index 00000000000..3af21a467cb --- /dev/null +++ b/test/rules/typedef/none/test.ts.lint @@ -0,0 +1,87 @@ +var NoTypeObjectLiteralWithPropertyGetter = { + Prop: "some property", + + get PropDef() { + return this.Prop; + }, + + methodDef() { + return 'untyped'; + }, + + anotherMethodDef: function() { + return 'also untyped'; + }, + + arrowMethodDef: () => { + return 'also untyped'; + } +}; + +interface NoTypeInterface { + Prop; + PropWithType: string; +} + +var NoTypesFn = function ( + a, + b) { + var c = a + b, + d = a - b; +}; + +class NoTypesClass { + [index: number]: number; + + Member = "some property"; + + public get name() { + return "some name"; + } + + private unTyped() { + return null; + } +} + +class ConstructorUnTyped { + constructor(type) { + + } +} + +function anotherNoTypesFn(a, b) { + return b; +} + +function forInFn(): void { + for (var p in []) {} +} + +function spreadFunction(...n) : number { + return ns[0]; +} + +class NoReturnTypeForSetAccessor { + set name(value: string) { + } +} + +try { + return 123; +} catch (e) { // should not be a failure; catch clause can't have typedef + console.log(e); +} + +// should not fail, typedefs not allowed in for-of loops +for (let i of [1, 2, 3]) { + +} + +const [ paramA, paramB ] = [ 'test', 15 ]; + +const { paramA, paramB } = { paramA: "test", paramB: 15 }; + +const [ paramA3, paramB3 ]: [ number, string ] = [15, 'test']; + +const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; diff --git a/test/rules/typedef/none/tslint.json b/test/rules/typedef/none/tslint.json new file mode 100644 index 00000000000..08b740b4692 --- /dev/null +++ b/test/rules/typedef/none/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "typedef": true + } +} diff --git a/test/rules/typedef/object-destructuring/test.ts.lint b/test/rules/typedef/object-destructuring/test.ts.lint new file mode 100644 index 00000000000..8f222db7f6d --- /dev/null +++ b/test/rules/typedef/object-destructuring/test.ts.lint @@ -0,0 +1,4 @@ +const { paramA, paramB } = { paramA: "test", paramB: 15 }; + ~~~~~~~~~~~~~~~~~~ [expected object-destructuring: '{ paramA, paramB }' to have a typedef] + +const { paramA, paramB }: { paramA: string, paramB: number } = { paramA: "test", paramB: 15 }; diff --git a/test/rules/typedef/object-destructuring/tslint.json b/test/rules/typedef/object-destructuring/tslint.json new file mode 100644 index 00000000000..fec26c5acc2 --- /dev/null +++ b/test/rules/typedef/object-destructuring/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "object-destructuring" + ] + } +} diff --git a/test/rules/typedef/parameter/test.ts.lint b/test/rules/typedef/parameter/test.ts.lint new file mode 100644 index 00000000000..309c04fcc93 --- /dev/null +++ b/test/rules/typedef/parameter/test.ts.lint @@ -0,0 +1,19 @@ +var NoTypesFn = function (a, b) { + ~ [expected parameter: 'a' to have a typedef] + ~ [expected parameter: 'b' to have a typedef] +} + +var NoTypesArrowFn = (a, b) => {} + +class AComponent { + private _test(): void { + this._foo.test({ + callback: () => { + // asd + }, + }); + } +} + +function foo(bar: any) :void {} +foo({bar: ()=>{}}); diff --git a/test/rules/typedef/parameter/tslint.json b/test/rules/typedef/parameter/tslint.json new file mode 100644 index 00000000000..11d12816d90 --- /dev/null +++ b/test/rules/typedef/parameter/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "parameter" + ] + } +} diff --git a/test/rules/typedef/variable-declaration-ignore-function/test.ts.lint b/test/rules/typedef/variable-declaration-ignore-function/test.ts.lint new file mode 100644 index 00000000000..d9f013a93a0 --- /dev/null +++ b/test/rules/typedef/variable-declaration-ignore-function/test.ts.lint @@ -0,0 +1,23 @@ +var foo = function(): void {}; +let foo = function(): void {}; +const foo = function(): void {}; + +var foo = (): void => {}; +let foo = (): void => {}; +const foo = (): void => {}; + +class Foo { + foo = (): void => {}; + foo = function(): void {}; +} + +const foo: () => void = (): void => {}; +const foo: () => void = function(): void {}; + +var noTypeDef = 'Should still fail'; + ~~~~~~~~~ [expected variable-declaration: 'noTypeDef' to have a typedef] + +class NoTypeDef { + public noTypeDef = 'Should still fail'; + ~~~~~~~~~ [expected member-variable-declaration: 'noTypeDef' to have a typedef] +} diff --git a/test/rules/typedef/variable-declaration-ignore-function/tslint.json b/test/rules/typedef/variable-declaration-ignore-function/tslint.json new file mode 100644 index 00000000000..f815790c07b --- /dev/null +++ b/test/rules/typedef/variable-declaration-ignore-function/tslint.json @@ -0,0 +1,10 @@ +{ + "rules": { + "typedef": [ + true, + "variable-declaration", + "member-variable-declaration", + "variable-declaration-ignore-function" + ] + } +} diff --git a/test/rules/typedef/variable-declaration/test.ts.lint b/test/rules/typedef/variable-declaration/test.ts.lint new file mode 100644 index 00000000000..0547e0b2013 --- /dev/null +++ b/test/rules/typedef/variable-declaration/test.ts.lint @@ -0,0 +1,5 @@ +var v = { } + ~ [expected variable-declaration: 'v' to have a typedef] + +const { paramA, paramB } = { paramA: "test", paramB: 15 }; +const [ paramA, paramB ] = [15, 'test']; diff --git a/test/rules/typedef/variable-declaration/tslint.json b/test/rules/typedef/variable-declaration/tslint.json new file mode 100644 index 00000000000..15593c2829e --- /dev/null +++ b/test/rules/typedef/variable-declaration/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "typedef": [true, + "variable-declaration" + ] + } +} diff --git a/test/rules/typeof-compare/test.ts.lint b/test/rules/typeof-compare/test.ts.lint new file mode 100644 index 00000000000..788f0ea6c0a --- /dev/null +++ b/test/rules/typeof-compare/test.ts.lint @@ -0,0 +1,109 @@ +var testVariable = 123; + +function testFunction() { + if (typeof x === 'null') { + ~~~~~~~~~~~~~~~~~~~ [0] + console.log("called"); + } + const x = typeof foo === 'undefied' + ~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +console.log(typeof window == 'object ') + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] + +const string = "string"; +typeof bar === string +typeof bar === `${string}`; +typeof bar === `${"s"}tring`; + +var num = 123; +typeof num !== "number"; +typeof num !== "object"; +typeof num !== "string"; +typeof num !== "boolean"; +typeof num !== "function"; +typeof num !== "symbol"; +typeof num !== "undefined"; + +"number" !== typeof num; +"object" !== typeof num; +"string" !== typeof num; +"boolean" !== typeof num; +"function" !== typeof num; +"symbol" !== typeof num; +"undefined" !== typeof num; + +typeof num === "number"; +typeof num === "object"; +typeof num === "string"; +typeof num === "boolean"; +typeof num === "function"; +typeof num === "symbol"; +typeof num === "undefined"; + +"number" === typeof num; +"object" === typeof num; +"string" === typeof num; +"boolean" === typeof num; +"function" === typeof num; +"symbol" === typeof num; +"undefined" === typeof num; + +typeof num == "number"; +typeof num == "object"; +typeof num == "string"; +typeof num == "boolean"; +typeof num == "function"; +typeof num == "symbol"; +typeof num == "undefined"; + +"number" == typeof num; +"object" == typeof num; +"string" == typeof num; +"boolean" == typeof num; +"function" == typeof num; +"symbol" == typeof num; +"undefined" == typeof num; + +typeof num != "number"; +typeof num != "object"; +typeof num != "string"; +typeof num != "boolean"; +typeof num != "function"; +typeof num != "symbol"; +typeof num != "undefined"; + +"number" == typeof num; +"object" == typeof num; +"string" == typeof num; +"boolean" == typeof num; +"function" == typeof num; +"symbol" == typeof num; +"undefined" == typeof num; +"frizzle" == typeof num; +~~~~~~~~~~~~~~~~~~~~~~~ [0] + +typeof bar === 123 +~~~~~~~~~~~~~~~~~~ [0] +typeof bar === undefined +~~~~~~~~~~~~~~~~~~~~~~~~ [0] +typeof bar === null +~~~~~~~~~~~~~~~~~~~ [0] +typeof bar === true +~~~~~~~~~~~~~~~~~~~ [0] +typeof bar === false +~~~~~~~~~~~~~~~~~~~~ [0] + +123 === typeof bar +~~~~~~~~~~~~~~~~~~ [0] +undefined === typeof bar +~~~~~~~~~~~~~~~~~~~~~~~~ [0] +null === typeof bar +~~~~~~~~~~~~~~~~~~~ [0] +true === typeof bar +~~~~~~~~~~~~~~~~~~~ [0] +false === typeof bar +~~~~~~~~~~~~~~~~~~~~ [0] + +[0]: 'typeof' expression must be compared to one of: "undefined", "string", "boolean", "number", "function", "object", "symbol" diff --git a/test/rules/typeof-compare/tslint.json b/test/rules/typeof-compare/tslint.json new file mode 100644 index 00000000000..39fd5bded31 --- /dev/null +++ b/test/rules/typeof-compare/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "typeof-compare": true + } +} diff --git a/test/rules/unified-signatures/test.d.ts.lint b/test/rules/unified-signatures/test.d.ts.lint new file mode 100644 index 00000000000..ed4b0268b9f --- /dev/null +++ b/test/rules/unified-signatures/test.d.ts.lint @@ -0,0 +1,99 @@ +interface I { + // For 3 or more overloads, mentions the line. + a0(): void; + a0(x: string): string; + a0(x: number): void; + ~~~~~~~~~ [This overload and the one on line 3 can be combined into one signature with an optional parameter.] + + // Error for extra parameter. + a1(): void; + a1(x: number): void; + ~~~~~~~~~ [0] + + // No error for arity difference greater than 1. + a2(): void; + a2(x: number, y: number): void; + + // Error for arity difference greater than 1 if the additional parameters are all optional/rest. + a3(): void; + a3(x: number, y?: number, ...z: number[]): void; + ~~~~~~~~~~~~~~ [These overloads can be combined into one signature with a rest parameter.] + + // No error for different return types. + a4(): void; + a4(x: number): number; + + // No error if one takes a type parameter and the other doesn't. + a5(x: T): T; + a5(x: number): number; + + // Error if only one defines a rest parameter. + b(): void; + b(...x: number[]): void; + ~~~~~~~~~~~~~~ [1] + + // No error if one is a rest parameter and other isn't. + b2(x: string): void; + b2(...x: number[]): void; + + // No error if both are rest parameters. (https://github.com/Microsoft/TypeScript/issues/5077) + b3(...x: number[]): void; + b3(...x: string[]): void; + + // Error if only one defines an optional parameter. + c(): void; + c(x?: number): void; + ~~~~~~~~~~ [0] + + // Error if both are optional. + c2(x?: number): void; + c2(x?: string): void; + ~~~~~~~~~~ [These overloads can be combined into one signature taking `number | string`.] + + // No error if one is optional and the other isn't. + c3(x: number): void; + c3(x?: string): void; + + // Error for different types (could be a union) + d(x: string): void; + d(x: number): void; + ~~~~~~~~~ [These overloads can be combined into one signature taking `string | number`.] + + // No error if they differ by 2 or more parameters. + d2(x: string, y: number): void; + d2(x: number, y: string): void; +} + +// Works for type literal too. +type T = { + // Works for call signature too. + (): void; + (x: number): void; + ~~~~~~~~~ [0] +} + +declare class C { + // Works for constructor. + constructor(); + constructor(x: number); + ~~~~~~~~~ [0] +} + +declare class D { + // No conflict between static/non-static members. + static a(); + a(x: number); +} + +// Allow separate overloads if one is generic and the other isn't. +interface Generic { + x(): void; + x(x: T[]): void; + + y(x: T[]): void; + y(x: T): void; + ~~~~ [These overloads can be combined into one signature taking `T[] | T`.] +} + +[0]: These overloads can be combined into one signature with an optional parameter. +[1]: These overloads can be combined into one signature with a rest parameter. diff --git a/test/rules/unified-signatures/test.ts.lint b/test/rules/unified-signatures/test.ts.lint new file mode 100644 index 00000000000..a6843a4328a --- /dev/null +++ b/test/rules/unified-signatures/test.ts.lint @@ -0,0 +1,31 @@ +// Works in non-declaration file too. +function f(x: number): void; +function f(x: string): void; + ~~~~~~~~~ [These overloads can be combined into one signature taking `number | string`.] +function f(x: any): any { + return x; +} + +// Body does *not* count as a signature. +function g(): void; +function g(a: number, b: number): void; +function g(a?: number, b?: number): void {} + +class C { + constructor(); + constructor(a: number, b: number); + constructor(a?: number, b?: number) {} + + a(): void; + a(a: number, b: number): void; + a(a?: number, b?: number): void {} +} + +function rest(...xs: number[]): void; +function rest(xs: number[], y: string): void; +function rest(...args: any[]) {} + +function opt(xs?: number[]): void; +function opt(xs: number[], y: string): void; + ~~~~~~~~~ [These overloads can be combined into one signature with an optional parameter.] +function opt(...args: any[]) {} diff --git a/test/rules/unified-signatures/tslint.json b/test/rules/unified-signatures/tslint.json new file mode 100644 index 00000000000..a9d166dc010 --- /dev/null +++ b/test/rules/unified-signatures/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unified-signatures": true + } +} diff --git a/test/rules/unnecessary-bind/typed/test.ts.lint b/test/rules/unnecessary-bind/typed/test.ts.lint new file mode 100644 index 00000000000..1edebe3976f --- /dev/null +++ b/test/rules/unnecessary-bind/typed/test.ts.lint @@ -0,0 +1,73 @@ +const arrowLambda = () => {}; +const functionVar = function () {}; + +declare const stubDecorator: any; + +class Class { + public constructor() { } + + public bind() { } + + public method() { } + + public boundFunction = function () {}.bind(this) + ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] + + public boundAsyncFunction = (async function () {}).bind(this) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] + + @stubDecorator + public decorated = function () {}.bind(this) +} + +const instance = new Class(); + +arrowLambda.bind(this); +~~~~~~~~~~~~~~~~~~~~~~ [arrow] +arrowLambda.bind(arrowLambda); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] +arrowLambda.bind(undefined); +~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] +arrowLambda.bind(this, 1); +arrowLambda.bind(this, undefined); + +functionVar.bind(this); +functionVar.bind(functionVar); +functionVar.bind(undefined); +functionVar.bind(this, 1); +functionVar.bind(this, undefined); + +const immediatelyBoundFunction = function () {}.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionReturn = function (i: number): number { return i; }.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionWrapped = (function () {}).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionWrappedReturn = (function (i: number): number { return i; }).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionArgs = function (i: number): number {}.bind(this, 1); +const immediatelyBoundFunctionArgsReturn = function (i: number): number { return i; }.bind(this, 1); +const immediatelyBoundFunctionNameUnused = function foo() { functionVar(); }.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionNameUsed = function foo() { foo(); }.bind(this); + +const immediatelyBoundArrow = ((i: number) => i).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] +const immediatelyBoundArrowArgs = ((i: number) => i).bind(this, 1); +const immediatelyBoundArrowArgsReturn = function (i: number): number { return i; }.bind(this, 1); + +const asyncFunction = async function () {}.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const asyncFunctionReturn = async function (): number { return 1; }.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const asyncArrow = (async () => {}).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] +const asyncArrowReturn = (async (): number => { return 1; }).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [arrow] + +(function* generator() {}).bind(this); +instance.method.bind(this); +instance.bind(this); +Class.bind(this); +[arrow]: Don't bind scopes to arrow lambdas, as they already have a bound scope. +[function]: Don't bind `this` without arguments as a scope to a function. Use an arrow lambda instead. diff --git a/test/rules/unnecessary-bind/typed/tsconfig.json b/test/rules/unnecessary-bind/typed/tsconfig.json new file mode 100644 index 00000000000..744a66c893a --- /dev/null +++ b/test/rules/unnecessary-bind/typed/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/rules/unnecessary-bind/typed/tslint.json b/test/rules/unnecessary-bind/typed/tslint.json new file mode 100644 index 00000000000..3a5cc6c8d6f --- /dev/null +++ b/test/rules/unnecessary-bind/typed/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unnecessary-bind": true + } +} diff --git a/test/rules/unnecessary-bind/untyped/test.ts.lint b/test/rules/unnecessary-bind/untyped/test.ts.lint new file mode 100644 index 00000000000..48cbdff01d4 --- /dev/null +++ b/test/rules/unnecessary-bind/untyped/test.ts.lint @@ -0,0 +1,62 @@ +const arrowLambda = () => {}; +const functionVar = function () {}; + +class Class { + public constructor() { } + + public bind() { } + + public method() { } + + public boundFunction = function () {}.bind(this) + ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] + + public boundAsyncFunction = (async function () {}).bind(this) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +} + +const instance = new Class(); + +arrowLambda.bind(this); +arrowLambda.bind(arrowLambda); +arrowLambda.bind(undefined); +arrowLambda.bind(this, 1); +arrowLambda.bind(this, undefined); + +functionVar.bind(this); +functionVar.bind(functionVar); +functionVar.bind(undefined); +functionVar.bind(this, 1); +functionVar.bind(this, undefined); + +const immediatelyBoundFunction = function () {}.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionReturn = function (i: number): number { return i; }.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionWrapped = (function () {}).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionWrappedReturn = (function (i: number): number { return i; }).bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionArgs = function (i: number): number {}.bind(this, 1); +const immediatelyBoundFunctionArgsReturn = function (i: number): number { return i; }.bind(this, 1); +const immediatelyBoundFunctionNameUnused = function foo() { functionVar(); }.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const immediatelyBoundFunctionNameUsed = function foo() { foo(); }.bind(this); + +const immediatelyBoundArrow = ((i: number) => i).bind(this); +const immediatelyBoundArrowArgs = ((i: number) => i).bind(this, 1); +const immediatelyBoundArrowArgsReturn = function (i: number): number { return i; }.bind(this, 1); + +const asyncFunction = async function () {}.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const asyncFunctionReturn = async function (): number { return 1; }.bind(this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [function] +const asyncArrow = (async () => {}).bind(this); +const asyncArrowReturn = (async (): number => { return 1; }).bind(this); + +(function* generator() {}).bind(this); +instance.method.bind(this); +instance.bind(this); +Class.bind(this); +[arrow]: Don't bind scopes to arrow lambdas, as they already have a bound scope. +[function]: Don't bind `this` without arguments as a scope to a function. Use an arrow lambda instead. diff --git a/test/rules/unnecessary-bind/untyped/tslint.json b/test/rules/unnecessary-bind/untyped/tslint.json new file mode 100644 index 00000000000..3a5cc6c8d6f --- /dev/null +++ b/test/rules/unnecessary-bind/untyped/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unnecessary-bind": true + } +} diff --git a/test/rules/unnecessary-constructor/check-super-calls/test.ts.fix b/test/rules/unnecessary-constructor/check-super-calls/test.ts.fix new file mode 100644 index 00000000000..a5c97d4ba14 --- /dev/null +++ b/test/rules/unnecessary-constructor/check-super-calls/test.ts.fix @@ -0,0 +1,147 @@ +export class ExportedClass { +} + +class PublicConstructor { +} + +class ProtectedConstructor { + protected constructor() { } +} + +class PrivateConstructor { + private constructor() { } +} + +class SameLine { } + +class WithPrecedingMember { + public member: string; +} + +class WithFollowingMethod { + public method() {} +} + +const classExpression = class { +} + +class ContainsContents { + constructor() { + console.log("Hello!"); + } +} + +class CallsSuper extends PublicConstructor { +} + +class ContainsParameter { +} + +class PrivateContainsParameter { + private constructor(x: number) { } +} + +class ProtectedContainsParameter { + protected constructor(x: number) { } +} + +class ContainsParameterDeclaration { + constructor(public x: number) { } +} + +class ContainsParameterAndParameterDeclaration { + constructor(x: number, public y: number) { } +} + +class ConstructorOverload { +} + +interface IConstructorSignature { + new(): {}; +} + +class DecoratedParameters { + constructor(@Optional x: number) {} +} + +class X { + constructor(private param1: number, param2: number) {} +} + +export class Y extends X { + constructor(param1: number) { + super(param1, 2); + } +} + +class Base { + constructor(public param: number) {} +} + +class Super extends Base { + public param: number; + constructor(param1: number) { + super(param1); + this.param = param1; + } +} + +class Super extends Base { +} + +class Super extends Base { + constructor(param1: number, public param2: number) { + super(param1); + } +} + +class Super extends Base { +} + +class Super extends Base { + constructor(param1: number) { + super(param1 + 1); + } +} + +class Super extends Base { + constructor() { + super(1); + } +} + +class Super extends Base { + constructor(param1: number) { + super(1); + } +} + +const test = (param: number) => number; + +class Super extends Base { + constructor(param1: number) { + super(test(param1)); + } +} + +class Base2 { + constructor(public param1: number, param2: number) {} +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + super(test(param2), param1); + } +} + +class Super extends Base2 { +} + +class Super extends Base { + public param1: number; + constructor(public param2: number) { + super(param2); + this.param1 = param2; + } +} + diff --git a/test/rules/unnecessary-constructor/check-super-calls/test.ts.lint b/test/rules/unnecessary-constructor/check-super-calls/test.ts.lint new file mode 100644 index 00000000000..fe419035572 --- /dev/null +++ b/test/rules/unnecessary-constructor/check-super-calls/test.ts.lint @@ -0,0 +1,188 @@ +export class ExportedClass { + constructor() { } + ~~~~~~~~~~~~~~~~~ [0] +} + +class PublicConstructor { + public constructor() { } + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +class ProtectedConstructor { + protected constructor() { } +} + +class PrivateConstructor { + private constructor() { } +} + +class SameLine { constructor() { } } + ~~~~~~~~~~~~~~~~~ [0] + +class WithPrecedingMember { + public member: string; + constructor() {} + ~~~~~~~~~~~~~~~~ [0] +} + +class WithFollowingMethod { + constructor() {} + ~~~~~~~~~~~~~~~~ [0] + public method() {} +} + +const classExpression = class { + constructor() { } + ~~~~~~~~~~~~~~~~~ [0] +} + +class ContainsContents { + constructor() { + console.log("Hello!"); + } +} + +class CallsSuper extends PublicConstructor { + constructor() { + ~~~~~~~~~~~~~~~ + super(); +~~~~~~~~~~~~~~~~ + } +~~~~~ [0] +} + +class ContainsParameter { + constructor(x: number) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +class PrivateContainsParameter { + private constructor(x: number) { } +} + +class ProtectedContainsParameter { + protected constructor(x: number) { } +} + +class ContainsParameterDeclaration { + constructor(public x: number) { } +} + +class ContainsParameterAndParameterDeclaration { + constructor(x: number, public y: number) { } +} + +class ConstructorOverload { + constructor(x: number); + constructor(x: number, y?: number) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +interface IConstructorSignature { + new(): {}; +} + +class DecoratedParameters { + constructor(@Optional x: number) {} +} + +class X { + constructor(private param1: number, param2: number) {} +} + +export class Y extends X { + constructor(param1: number) { + super(param1, 2); + } +} + +class Base { + constructor(public param: number) {} +} + +class Super extends Base { + public param: number; + constructor(param1: number) { + super(param1); + this.param = param1; + } +} + +class Super extends Base { + constructor(param: number) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + super(param); +~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [0] +} + +class Super extends Base { + constructor(param1: number, public param2: number) { + super(param1); + } +} + +class Super extends Base { + constructor(param1: number, param2: number) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + super(param1); +~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [0] +} + +class Super extends Base { + constructor(param1: number) { + super(param1 + 1); + } +} + +class Super extends Base { + constructor() { + super(1); + } +} + +class Super extends Base { + constructor(param1: number) { + super(1); + } +} + +const test = (param: number) => number; + +class Super extends Base { + constructor(param1: number) { + super(test(param1)); + } +} + +class Base2 { + constructor(public param1: number, param2: number) {} +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + super(test(param2), param1); + } +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + super(param2, param1); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } +~~~~~ [0] +} + +class Super extends Base { + public param1: number; + constructor(public param2: number) { + super(param2); + this.param1 = param2; + } +} + +[0]: Remove unnecessary empty constructor. diff --git a/test/rules/unnecessary-constructor/check-super-calls/tslint.json b/test/rules/unnecessary-constructor/check-super-calls/tslint.json new file mode 100644 index 00000000000..387e6c2b68e --- /dev/null +++ b/test/rules/unnecessary-constructor/check-super-calls/tslint.json @@ -0,0 +1,8 @@ +{ + "rules": { + "unnecessary-constructor": [ + true, + { "check-super-calls": true } + ] + } +} diff --git a/test/rules/unnecessary-constructor/default/test.ts.fix b/test/rules/unnecessary-constructor/default/test.ts.fix new file mode 100644 index 00000000000..a274aa9f2f7 --- /dev/null +++ b/test/rules/unnecessary-constructor/default/test.ts.fix @@ -0,0 +1,159 @@ +export class ExportedClass { +} + +class PublicConstructor { +} + +class ProtectedConstructor { + protected constructor() { } +} + +class PrivateConstructor { + private constructor() { } +} + +class SameLine { } + +class WithPrecedingMember { + public member: string; +} + +class WithFollowingMethod { + public method() {} +} + +const classExpression = class { +} + +class ContainsContents { + constructor() { + console.log("Hello!"); + } +} + +class CallsSuper extends PublicConstructor { + constructor() { + super(); + } +} + +class ContainsParameter { +} + +class PrivateContainsParameter { + private constructor(x: number) { } +} + +class ProtectedContainsParameter { + protected constructor(x: number) { } +} + +class ContainsParameterDeclaration { + constructor(public x: number) { } +} + +class ContainsParameterAndParameterDeclaration { + constructor(x: number, public y: number) { } +} + +class ConstructorOverload { +} + +interface IConstructorSignature { + new(): {}; +} + +class DecoratedParameters { + constructor(@Optional x: number) {} +} + +class X { + constructor(private param1: number, param2: number) {} +} + +export class Y extends X { + constructor(param1: number) { + super(param1, 2); + } +} + +class Base { + constructor(public param: number) {} +} + +class Super extends Base { + public param: number; + constructor(param1: number) { + super(param1); + this.param = param1; + } +} + +class Super extends Base { + constructor(param: number) { + super(param); + } +} + +class Super extends Base { + constructor(param1: number, public param2: number) { + super(param1); + } +} + +class Super extends Base { + constructor(param1: number, param2: number) { + super(param1); + } +} + +class Super extends Base { + constructor(param1: number) { + super(param1 + 1); + } +} + +class Super extends Base { + constructor() { + super(1); + } +} + +class Super extends Base { + constructor(param1: number) { + super(1); + } +} + +const test = (param: number) => number; + +class Super extends Base { + constructor(param1: number) { + super(test(param1)); + } +} + +class Base2 { + constructor(public param1: number, param2: number) {} +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + super(test(param2), param1); + } +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + super(param2, param1); + } +} + +class Super extends Base { + public param1: number; + constructor(public param2: number) { + super(param2); + this.param1 = param2; + } +} + diff --git a/test/rules/unnecessary-constructor/default/test.ts.lint b/test/rules/unnecessary-constructor/default/test.ts.lint new file mode 100644 index 00000000000..0203b8cf994 --- /dev/null +++ b/test/rules/unnecessary-constructor/default/test.ts.lint @@ -0,0 +1,176 @@ +export class ExportedClass { + constructor() { } + ~~~~~~~~~~~~~~~~~ [0] +} + +class PublicConstructor { + public constructor() { } + ~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +class ProtectedConstructor { + protected constructor() { } +} + +class PrivateConstructor { + private constructor() { } +} + +class SameLine { constructor() { } } + ~~~~~~~~~~~~~~~~~ [0] + +class WithPrecedingMember { + public member: string; + constructor() {} + ~~~~~~~~~~~~~~~~ [0] +} + +class WithFollowingMethod { + constructor() {} + ~~~~~~~~~~~~~~~~ [0] + public method() {} +} + +const classExpression = class { + constructor() { } + ~~~~~~~~~~~~~~~~~ [0] +} + +class ContainsContents { + constructor() { + console.log("Hello!"); + } +} + +class CallsSuper extends PublicConstructor { + constructor() { + super(); + } +} + +class ContainsParameter { + constructor(x: number) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +class PrivateContainsParameter { + private constructor(x: number) { } +} + +class ProtectedContainsParameter { + protected constructor(x: number) { } +} + +class ContainsParameterDeclaration { + constructor(public x: number) { } +} + +class ContainsParameterAndParameterDeclaration { + constructor(x: number, public y: number) { } +} + +class ConstructorOverload { + constructor(x: number); + constructor(x: number, y?: number) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] +} + +interface IConstructorSignature { + new(): {}; +} + +class DecoratedParameters { + constructor(@Optional x: number) {} +} + +class X { + constructor(private param1: number, param2: number) {} +} + +export class Y extends X { + constructor(param1: number) { + super(param1, 2); + } +} + +class Base { + constructor(public param: number) {} +} + +class Super extends Base { + public param: number; + constructor(param1: number) { + super(param1); + this.param = param1; + } +} + +class Super extends Base { + constructor(param: number) { + super(param); + } +} + +class Super extends Base { + constructor(param1: number, public param2: number) { + super(param1); + } +} + +class Super extends Base { + constructor(param1: number, param2: number) { + super(param1); + } +} + +class Super extends Base { + constructor(param1: number) { + super(param1 + 1); + } +} + +class Super extends Base { + constructor() { + super(1); + } +} + +class Super extends Base { + constructor(param1: number) { + super(1); + } +} + +const test = (param: number) => number; + +class Super extends Base { + constructor(param1: number) { + super(test(param1)); + } +} + +class Base2 { + constructor(public param1: number, param2: number) {} +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + super(test(param2), param1); + } +} + +class Super extends Base2 { + constructor(param1: number, param2: number) { + super(param2, param1); + } +} + +class Super extends Base { + public param1: number; + constructor(public param2: number) { + super(param2); + this.param1 = param2; + } +} + +[0]: Remove unnecessary empty constructor. diff --git a/test/rules/unnecessary-constructor/default/tslint.json b/test/rules/unnecessary-constructor/default/tslint.json new file mode 100644 index 00000000000..53a2dfbba1b --- /dev/null +++ b/test/rules/unnecessary-constructor/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unnecessary-constructor": true + } +} diff --git a/test/rules/unnecessary-else/allow-else-if/test.ts.lint b/test/rules/unnecessary-else/allow-else-if/test.ts.lint new file mode 100644 index 00000000000..96d1fc50ab6 --- /dev/null +++ b/test/rules/unnecessary-else/allow-else-if/test.ts.lint @@ -0,0 +1,255 @@ +const testReturn = (a) => { + if (a===0) { + return 0; + } else { + ~~~~ [return] + return a; + } +} + +const testReturn = (a) => { + if (a===0) return 0; + else return a; + ~~~~ [return] +} + +const testReturn = (a) => { + if (a===0) + return 0; + else + ~~~~ [return] + return a; +} + +const testReturn = (a) => { + if (a>0) { + if (a%2 ===0) { + return "even" ; + } else { + ~~~~ [return] + return "odd"; + } + } + return "negative"; +} + +const testReturn = (a) => { + if (a===0) { + return 0; + } + return a; +} + +const testReturn = (a) => { + if (a<0) { + return; + } else if (a>0) { + if (a%2 === 0) { + return ; + } else if (a === 0) { + return ; + } + } + return; +} + +const testReturn = (a) => { + if (a<0) { + return; + } + if (a===1) { + return ; + } else { + ~~~~ [return] + return ; + } +} + +const testReturn = (a) => { + if (a>0) { + if (a%3===0) { + return; + } else { + ~~~~ [return] + console.log(a) + } + } + else { + console.log("negative"); + } +} + +const testThrow = (a) => { + if ( a===0 ) { + throw "error"; + } else { + ~~~~ [throw] + return 100/a; + } +} + +const testThrow = (a) => { + if (a===0) + throw "error; + else if (a < 0) + console.log(100/a); +} + +const testThrow = (a) => { + if (a===0) throw "error; + else console.log(100/a); + ~~~~ [throw] +} + +const testThrow = (a) => { + switch (a) { + case 1: + break; + case 2: + if (true) { + throw "error"; + } else { + ~~~~ [throw] + break; + } + default : + break; + } +} + +const testThrow = (a) => { + let i = 1; + do { + if (a-i === 0) { + throw "error; + } else { + ~~~~ [throw] + console.log(i/a-i); + } + ++i; + } +} + +const testThrow = (a) => { + if (a===0) { + throw "error"; + } + return 100/a; +} + +const testThrow = (a) => { + if (a===0) throw "error"; + return 100/a; +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===8) { + continue ; + } else { + ~~~~ [continue] + console.log(i); + } + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===8) continue ; + else console.log(i); + ~~~~ [continue] + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===8) + continue ; + else + ~~~~ [continue] + console.log(i); + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===4) { + continue ; + } + console.log(i); + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===4) + continue ; + console.log(i); + } +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) { + break ; + } else { + ~~~~ [break] + i++; + } + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) { + break ; + } + i++; + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) + break ; + i++; + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) break ; + i++; + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) break ; + else i++; + ~~~~ [break] + } + return i-1; +} + +const testNoJump = (a) => { + if (a % 2 === 0) { + console.log(a); + } else { + console.log(a * 2); + } +} + +[return]: The preceding `if` block ends with a `return` statement. This `else` is unnecessary. +[throw]: The preceding `if` block ends with a `throw` statement. This `else` is unnecessary. +[break]: The preceding `if` block ends with a `break` statement. This `else` is unnecessary. +[continue]: The preceding `if` block ends with a `continue` statement. This `else` is unnecessary. diff --git a/test/rules/unnecessary-else/allow-else-if/tslint.json b/test/rules/unnecessary-else/allow-else-if/tslint.json new file mode 100644 index 00000000000..8ae348723a7 --- /dev/null +++ b/test/rules/unnecessary-else/allow-else-if/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unnecessary-else": [true, { "allow-else-if": true }] + } +} diff --git a/test/rules/unnecessary-else/default/test.ts.lint b/test/rules/unnecessary-else/default/test.ts.lint new file mode 100644 index 00000000000..b36386fb80b --- /dev/null +++ b/test/rules/unnecessary-else/default/test.ts.lint @@ -0,0 +1,337 @@ +const testReturn = (a) => { + if (a===0) { + return 0; + } else { + ~~~~ [return] + return a; + } +} + +const testReturn = (a) => { + if (a===0) return 0; + else return a; + ~~~~ [return] +} + +const testReturn = (a) => { + if (a===0) + return 0; + else + ~~~~ [return] + return a; +} + +const testReturn = (a) => { + if (a>0) { + if (a%2 ===0) { + return "even" ; + } else { + ~~~~ [return] + return "odd"; + } + } + return "negative"; +} + +const testReturn = (a) => { + if (a===0) { + return 0; + } + return a; +} + +const testReturn = (a) => { + if (a<0) { + return; + } else if (a>0) { + ~~~~ [return] + if (a%2 === 0) { + return ; + } else { + ~~~~ [return] + return ; + } + } + return; +} + +const testReturn = (a) => { + if (a<0) { + return; + } + if (a===1) { + return ; + } else { + ~~~~ [return] + return ; + } +} + +const testReturn = (a) => { + if (a>0) { + if (a%3===0) { + return; + } else { + ~~~~ [return] + console.log(a) + } + } + else { + console.log("negative"); + } +} + +const testThrow = (a) => { + if ( a===0 ) { + throw "error"; + } else { + ~~~~ [throw] + return 100/a; + } +} + +const testThrow = (a) => { + if (a===0) + throw "error; + else + ~~~~ [throw] + console.log(100/a); +} + +const testThrow = (a) => { + if (a===0) throw "error; + else console.log(100/a); + ~~~~ [throw] +} + +const testThrow = (a) => { + switch (a) { + case 1: + break; + case 2: + if (true) { + throw "error"; + } else { + ~~~~ [throw] + break; + } + default : + break; + } +} + +const testThrow = (a) => { + let i = 1; + do { + if (a-i === 0) { + throw "error; + } else { + ~~~~ [throw] + console.log(i/a-i); + } + ++i; + } +} + +const testThrow = (a) => { + if (a===0) { + throw "error"; + } + return 100/a; +} + +const testThrow = (a) => { + if (a===0) throw "error"; + return 100/a; +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===8) { + continue ; + } else { + ~~~~ [continue] + console.log(i); + } + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===8) continue ; + else console.log(i); + ~~~~ [continue] + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===8) + continue ; + else + ~~~~ [continue] + console.log(i); + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===4) { + continue ; + } + console.log(i); + } +} + +const testContinue = () => { + for (let i = 1; i < 10; i++) { + if (i===4) + continue ; + console.log(i); + } +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) { + break ; + } else { + ~~~~ [break] + i++; + } + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) { + break ; + } + i++; + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) + break ; + i++; + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) break ; + i++; + } + return i-1; +} + +const testBreak = (a) => { + let i = 0; + while(i < 20) { + if (i === a) break ; + else i++; + ~~~~ [break] + } + return i-1; +} + +const testNoJump = (a) => { + if (a % 2 === 0) { + console.log(a); + } else { + console.log(a * 2); + } +} + +const testConsoleLogIf = (a) => { + if (a) { + // ... + } else if (!a) { + // ... + } +} + +const testNonJumpingElse = (a) => { + if (a === 1) { + console.log("a"); + } else if (a === 2) { + return; + } else { + console.log("b"); + } + + console.log("c"); +} + +const testNonJumpingIf = (a) => { + if (a === 1) { + console.log("a"); + } else if (a === 2) { + return; + } else if (a % 2 === 1) { + console.log("b"); + } + + console.log("c"); +} + +const testNonJumpingIfNestedJumping = (a) => { + if (a === 1) { + if (a) { + return; + } + else { } + ~~~~ [return] + } else if (a === 2) { + return; + } else if (a % 2 === 1) { + console.log("b"); + } + + console.log("c"); +} + +const testNonJumpingIfNestedNonJumping = (a) => { + if (a === 1) { + if (a) {} + else if (a) { + return; + } + else { } + } else if (a === 2) { + return; + } else if (a % 2 === 1) { + console.log("b"); + } + + console.log("c"); +} + +const testNonJumpingIfAndUnrelated = (a) => { + if (a === 1) { + console.log("a"); + if (a) {} + else if (a) { } + else { } + } else if (a === 2) { + return; + } else if (a % 2 === 1) { + console.log("b"); + } + + console.log("c"); +} + +[return]: The preceding `if` block ends with a `return` statement. This `else` is unnecessary. +[throw]: The preceding `if` block ends with a `throw` statement. This `else` is unnecessary. +[break]: The preceding `if` block ends with a `break` statement. This `else` is unnecessary. +[continue]: The preceding `if` block ends with a `continue` statement. This `else` is unnecessary. diff --git a/test/rules/unnecessary-else/default/tslint.json b/test/rules/unnecessary-else/default/tslint.json new file mode 100644 index 00000000000..5e3f2360d32 --- /dev/null +++ b/test/rules/unnecessary-else/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "unnecessary-else": true + } +} diff --git a/test/rules/use-default-type-parameter/test.ts.fix b/test/rules/use-default-type-parameter/test.ts.fix new file mode 100644 index 00000000000..8930a90507a --- /dev/null +++ b/test/rules/use-default-type-parameter/test.ts.fix @@ -0,0 +1,18 @@ + +function f() {} +f(); +f(); + +function g() {} +g(); +g(); // Must specify 1st type parameter if 2nd is different than default. + + +class C {} +function h(c: C) {} +new C(); +class D extends C {} + +interface I {} +class Impl implements I {} + diff --git a/test/rules/use-default-type-parameter/test.ts.lint b/test/rules/use-default-type-parameter/test.ts.lint new file mode 100644 index 00000000000..516caf71c5b --- /dev/null +++ b/test/rules/use-default-type-parameter/test.ts.lint @@ -0,0 +1,26 @@ +[typescript]: >= 2.3.0 + +function f() {} +f(); + ~~~~~~ [0] +f(); + +function g() {} +g(); + ~~~~~~ [0] +g(); // Must specify 1st type parameter if 2nd is different than default. + + +class C {} +function h(c: C) {} + ~~~~~~ [0] +new C(); + ~~~~~~ [0] +class D extends C {} + ~~~~~~ [0] + +interface I {} +class Impl implements I {} + ~~~~~~ [0] + +[0]: This is the default value for this type parameter, so it can be omitted. diff --git a/test/rules/use-default-type-parameter/tsconfig.json b/test/rules/use-default-type-parameter/tsconfig.json new file mode 100644 index 00000000000..9e26dfeeb6e --- /dev/null +++ b/test/rules/use-default-type-parameter/tsconfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/rules/use-default-type-parameter/tslint.json b/test/rules/use-default-type-parameter/tslint.json new file mode 100644 index 00000000000..d5a2fb118d1 --- /dev/null +++ b/test/rules/use-default-type-parameter/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "use-default-type-parameter": true + } +} diff --git a/test/rules/use-isnan/test.ts.lint b/test/rules/use-isnan/test.ts.lint new file mode 100644 index 00000000000..27119c9a3e9 --- /dev/null +++ b/test/rules/use-isnan/test.ts.lint @@ -0,0 +1,64 @@ + +// no violation for comparing NaN using isNaN +if (isNaN(NaN)) { +} + +// no violation for correctly checking for isNaN +if (isNaN(something)) { } + +// no violation for assignments +let x = 0; +x = NaN; +x += NaN; +x -= NaN; +x /= NaN; +x *= NaN; +x %= NaN; +x **= NaN; +x <<= NaN; +x >>= NaN; +x >>>= NaN; +x &= NaN; +x ^= NaN; +x |= NaN; + +// no violation for arithmetic operators +x = x + NaN; +x = NaN - x; +x = x / NaN; +x = NaN * x; +x = x % NaN; +x = NaN ** x; + +// no violation for bitwise operators +x = x & NaN; +x = NaN | x; +x = x ^ NaN; +x = NaN << x; +x = x >> NaN; +x = NaN >>> x; +x = x & NaN; + +// no violation for other operators +if (x instanceof NaN) { } +if (NaN in x) { } + +// do not use equality operators to compare for NaN +if (foo == NaN) { } + ~~~~~~~~~~ [Found an invalid comparison for NaN: foo == NaN] +if (NaN === foo) { } + ~~~~~~~~~~~ [Found an invalid comparison for NaN: NaN === foo] +if (foo != NaN) { } + ~~~~~~~~~~ [Found an invalid comparison for NaN: foo != NaN] +if (NaN !== foo) { } + ~~~~~~~~~~~ [Found an invalid comparison for NaN: NaN !== foo] + +// do not use any binary operators to compare for NaN +if (foo > NaN) { } + ~~~~~~~~~ [Found an invalid comparison for NaN: foo > NaN] +if (NaN >= foo) { } + ~~~~~~~~~~ [Found an invalid comparison for NaN: NaN >= foo] +if (foo < NaN) { } + ~~~~~~~~~ [Found an invalid comparison for NaN: foo < NaN] +if (NaN <= foo) { } + ~~~~~~~~~~ [Found an invalid comparison for NaN: NaN <= foo] diff --git a/test/rules/use-isnan/tslint.json b/test/rules/use-isnan/tslint.json new file mode 100644 index 00000000000..880adde9812 --- /dev/null +++ b/test/rules/use-isnan/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "use-isnan": true + } +} diff --git a/test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint b/test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint new file mode 100644 index 00000000000..a1cf5b656da --- /dev/null +++ b/test/rules/variable-name/allow-leading-trailing-underscore/test.ts.lint @@ -0,0 +1,47 @@ +var validName1 = "hi"; +var VALIDNAME2 = "there"; +var InvalidName1 = ","; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +var invalid_name2 = " "; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +class Test { + private Invalid_name3 = "how"; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + private _optionallyValid = "are"; // sometimes a failure +} + +function test() { + () => { + var InVaLiDnAmE4 = "you"; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + }; +} + +declare var DeclaresAreValid: any; + +export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures + ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let { foo, bar } = { foo: 1, bar: 2 }; +let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let optionallyValid_ = "bar"; +let _$httpBackend_ = "leading and trailing"; diff --git a/test/rules/variable-name/allow-leading-trailing-underscore/tslint.json b/test/rules/variable-name/allow-leading-trailing-underscore/tslint.json new file mode 100644 index 00000000000..c5d657add43 --- /dev/null +++ b/test/rules/variable-name/allow-leading-trailing-underscore/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "allow-leading-underscore", "allow-trailing-underscore"] + } +} diff --git a/test/rules/variable-name/allow-leading-underscore/test.ts.lint b/test/rules/variable-name/allow-leading-underscore/test.ts.lint new file mode 100644 index 00000000000..6f9150814df --- /dev/null +++ b/test/rules/variable-name/allow-leading-underscore/test.ts.lint @@ -0,0 +1,49 @@ +var validName1 = "hi"; +var VALIDNAME2 = "there"; +var InvalidName1 = ","; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +var invalid_name2 = " "; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +class Test { + private Invalid_name3 = "how"; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + private _optionallyValid = "are"; // sometimes a failure +} + +function test() { + () => { + var InVaLiDnAmE4 = "you"; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + }; +} + +declare var DeclaresAreValid: any; + +export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures + ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let { foo, bar } = { foo: 1, bar: 2 }; +let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let optionallyValid_ = "bar"; + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +let _$httpBackend_ = "leading and trailing"; + ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] diff --git a/test/rules/variable-name/allow-leading-underscore/tslint.json b/test/rules/variable-name/allow-leading-underscore/tslint.json new file mode 100644 index 00000000000..4f9cde74fec --- /dev/null +++ b/test/rules/variable-name/allow-leading-underscore/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "allow-leading-underscore"] + } +} diff --git a/test/rules/variable-name/allow-pascal-case/test.ts.lint b/test/rules/variable-name/allow-pascal-case/test.ts.lint new file mode 100644 index 00000000000..eec49b268f1 --- /dev/null +++ b/test/rules/variable-name/allow-pascal-case/test.ts.lint @@ -0,0 +1,50 @@ +var validName1 = "hi"; +var VALIDNAME2 = "there"; +var ValidName3 = ","; +var invalid_name1 = " "; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + +class Test { + private Invalid_name3 = "how"; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + private _optionallyValid = "are"; // sometimes a failure + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] +} + +function test() { + () => { + var InVaLiDnAmE4 = "you"; + }; +} + +declare var DeclaresAreValid: any; + +export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 1 failure + ~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + // +} + +let { foo, bar } = { foo: 1, bar: 2 }; +let [ invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures + ~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + +export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 1 failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + // +} + +export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure + ~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + // +} + +let optionallyValid_ = "bar"; + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] +let _$httpBackend_ = "leading and trailing"; + ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE] + +// don't crash on syntax errors + +class {} +let {bar:} = foo; diff --git a/test/rules/variable-name/allow-pascal-case/tslint.json b/test/rules/variable-name/allow-pascal-case/tslint.json new file mode 100644 index 00000000000..2552fcdc0d7 --- /dev/null +++ b/test/rules/variable-name/allow-pascal-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "allow-pascal-case"] + } +} diff --git a/test/rules/variable-name/allow-snake-case/test.ts.lint b/test/rules/variable-name/allow-snake-case/test.ts.lint new file mode 100644 index 00000000000..548e443fb0c --- /dev/null +++ b/test/rules/variable-name/allow-snake-case/test.ts.lint @@ -0,0 +1,64 @@ +var validName1 = "hi"; +var VALIDNAME2 = "there"; +var valid_name3 = "tslint"; +var Invalid_name1 = " "; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] +var InvalidName2 = " "; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + +class Test { + private valid_name = " "; + private Invalid_name1 = "how"; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + private _optionallyValid = "are"; // sometimes a failure + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] +} + +function test() { + () => { + var valid_name = " "; + var InVaLiDnAmE4 = "you"; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + }; +} + +declare var DeclaresAreValid: any; + +export function functionWithInvalidParamNames (ok_name, BadName) { // 1 failure + ~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] +} + +let { foo, bar } = { foo: 1, bar: 2 }; +let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 1 failure + ~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + +export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 1 failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + // +} + +export function functionWithInvalidSpread(InvalidArg: ...number) { // 1 failure + ~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + // +} + +let optionallyValid_ = "bar"; + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] +let _$httpBackend_ = "leading and trailing"; + ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + +// Aliases. +class X { + ValidAlias = ValidAlias; +} + +var ValidAlias = some.ValidAlias; +var ValidAlias = some.InValidAlias; + ~~~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] + +var someObject = {MoreValidAlias: 1}; +var {MoreValidAlias: localVar} = someObject; +var {MoreValidAlias: local_var} = someObject; +var {MoreValidAlias: LocalVar} = someObject; + ~~~~~~~~ [variable name must be in lowerCamelCase, snake_case or UPPER_CASE] +var {MoreValidAlias} = someObject; diff --git a/test/rules/variable-name/allow-snake-case/tslint.json b/test/rules/variable-name/allow-snake-case/tslint.json new file mode 100644 index 00000000000..16bbbfb2052 --- /dev/null +++ b/test/rules/variable-name/allow-snake-case/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "allow-snake-case"] + } +} diff --git a/test/rules/variable-name/allow-trailing-underscore/test.ts.lint b/test/rules/variable-name/allow-trailing-underscore/test.ts.lint new file mode 100644 index 00000000000..d635af62bc0 --- /dev/null +++ b/test/rules/variable-name/allow-trailing-underscore/test.ts.lint @@ -0,0 +1,49 @@ +var validName1 = "hi"; +var VALIDNAME2 = "there"; +var InvalidName1 = ","; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +var invalid_name2 = " "; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +class Test { + private Invalid_name3 = "how"; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + private _optionallyValid = "are"; // sometimes a failure + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +} + +function test() { + () => { + var InVaLiDnAmE4 = "you"; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + }; +} + +declare var DeclaresAreValid: any; + +export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures + ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let { foo, bar } = { foo: 1, bar: 2 }; +let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let optionallyValid_ = "bar"; +let _$httpBackend_ = "leading and trailing"; + ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] diff --git a/test/rules/variable-name/allow-trailing-underscore/tslint.json b/test/rules/variable-name/allow-trailing-underscore/tslint.json new file mode 100644 index 00000000000..86b02a3ad4f --- /dev/null +++ b/test/rules/variable-name/allow-trailing-underscore/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "allow-trailing-underscore"] + } +} diff --git a/test/rules/variable-name/ban-keywords/test.ts.lint b/test/rules/variable-name/ban-keywords/test.ts.lint new file mode 100644 index 00000000000..3bf0f62aa0e --- /dev/null +++ b/test/rules/variable-name/ban-keywords/test.ts.lint @@ -0,0 +1,21 @@ +let undefined = 8; + ~~~~~~~~~ [variable name clashes with keyword/type] +let boolean: boolean; + ~~~~~~~ [variable name clashes with keyword/type] +function bad(any: any) { } + ~~~ [variable name clashes with keyword/type] +let [number] = [3]; + ~~~~~~ [variable name clashes with keyword/type] +let {String} = {String: 1}; + ~~~~~~ [variable name clashes with keyword/type] + +// good: +let foo = 2; +let bar: any; +function good(baz: any) { } +let [faz] = [5]; +const {pom} = {pom: 5}; + +interface Wob { + number: string; +} diff --git a/test/rules/variable-name/ban-keywords/tslint.json b/test/rules/variable-name/ban-keywords/tslint.json new file mode 100644 index 00000000000..9b5db62cf01 --- /dev/null +++ b/test/rules/variable-name/ban-keywords/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "ban-keywords"] + } +} diff --git a/test/rules/variable-name/const-only-for-caps/test.ts.lint b/test/rules/variable-name/const-only-for-caps/test.ts.lint new file mode 100644 index 00000000000..8a092a64932 --- /dev/null +++ b/test/rules/variable-name/const-only-for-caps/test.ts.lint @@ -0,0 +1,38 @@ +var snake_case_var; + ~~~~~~~~~~~~~~ [regular-case] + +var camelCaseVar; + +var PascalCaseVar; + ~~~~~~~~~~~~~ [regular-case] + +var UPPER_CASE_VAR; + ~~~~~~~~~~~~~~ [const] + +let snake_case_let; + ~~~~~~~~~~~~~~ [regular-case] + +let camelCaseLet; + +let PascalCaseLet; + ~~~~~~~~~~~~~ [regular-case] + +let UPPER_CASE_LET; + ~~~~~~~~~~~~~~ [const] + +const snake_case_const; + ~~~~~~~~~~~~~~~~ [regular-case] + +const camelCaseConst; + +const PascalCaseConst; + ~~~~~~~~~~~~~~~ [regular-case] + +const UPPER_CASE_CONST; + +class Test { + public static readonly MY_FIELD = 10; +} + +[const]: Only `const` variables may be UPPER_CASE. +[regular-case]: variable name must be in lowerCamelCase or UPPER_CASE diff --git a/test/rules/variable-name/const-only-for-caps/tslint.json b/test/rules/variable-name/const-only-for-caps/tslint.json new file mode 100644 index 00000000000..991cbcb344e --- /dev/null +++ b/test/rules/variable-name/const-only-for-caps/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": [true, "require-const-for-all-caps"] + } +} diff --git a/test/rules/variable-name/default/test.ts.lint b/test/rules/variable-name/default/test.ts.lint new file mode 100644 index 00000000000..ade3be266b2 --- /dev/null +++ b/test/rules/variable-name/default/test.ts.lint @@ -0,0 +1,65 @@ +var validName1 = "hi"; +var VALIDNAME2 = "there"; +var InvalidName1 = ","; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +var invalid_name2 = " "; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +class Test { + private Invalid_name3 = "how"; // failure + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + private _optionallyValid = "are"; // sometimes a failure + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +} + +function test() { + () => { + var InVaLiDnAmE4 = "you"; // failure + ~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + }; +} + +declare var DeclaresAreValid: any; + +export function functionWithInvalidParamNames (bad_name, AnotherOne) { // 2 failures + ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let { foo, bar } = { foo: 1, bar: 2 }; +let [ InvalidFoo, invalid_bar, ...invalid_baz ] = [1, 2, 3, 4]; // 3 failures + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +export function anotherFunctionWithInvalidParamNames ([first_element, SecondElement]) { // 2 failures + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + ~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +export function functionWithInvalidSpread(invalid_arg: ...number) { // 1 failure + ~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + // +} + +let optionallyValid_ = "bar"; + ~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +let _$httpBackend_ = "leading and trailing"; + ~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +// Aliases. +class X { + ValidAlias = ValidAlias; +} + +var ValidAlias = some.ValidAlias; +var ValidAlias = some.InValidAlias; + ~~~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] + +var someObject = {MoreValidAlias: 1}; +var {MoreValidAlias: localVar} = someObject; +var {MoreValidAlias: LocalVar} = someObject; + ~~~~~~~~ [variable name must be in lowerCamelCase or UPPER_CASE] +var {MoreValidAlias} = someObject; diff --git a/test/rules/variable-name/default/tslint.json b/test/rules/variable-name/default/tslint.json new file mode 100644 index 00000000000..4c41fc82fc7 --- /dev/null +++ b/test/rules/variable-name/default/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "variable-name": true + } +} diff --git a/test/rules/whitespace/all/bom.ts.lint b/test/rules/whitespace/all/bom.ts.lint new file mode 100644 index 00000000000..4d075454a73 --- /dev/null +++ b/test/rules/whitespace/all/bom.ts.lint @@ -0,0 +1 @@ +import * as $t from 't'; diff --git a/test/rules/whitespace/all/import-type.lint b/test/rules/whitespace/all/import-type.lint new file mode 100644 index 00000000000..64ef7f5cb5f --- /dev/null +++ b/test/rules/whitespace/all/import-type.lint @@ -0,0 +1,32 @@ +[typescript]: >=2.9.0 + +const foo: import("bar"); +const foo: import ("bar"); + +function foo(a: import("bar")): import("baz") {} +function foo(a: import ("bar")): import ("baz") {} + +const foo = (a: import("bar")): import("baz") => {}; +const foo = (a: import ("bar")): import ("baz") => {}; + +type foo = { bar: import("baz") } & import("qux"); +type foo = { bar: import ("baz") } & import ("qux"); + +interface Foo { + bar: import("baz"); + qux: import ("quux"); +} + +class Foo { + bar: import("baz"); + qux: import ("quux"); +} + +/** + * @param bar { import("qux") } + * @param baz { import ("qux") } + */ +function foo(bar, baz) { } + +type foo = Bar; +type foo = Bar; diff --git a/test/rules/whitespace/all/import.ts.lint b/test/rules/whitespace/all/import.ts.lint new file mode 100644 index 00000000000..aaa73d65808 --- /dev/null +++ b/test/rules/whitespace/all/import.ts.lint @@ -0,0 +1,3 @@ +[typescript]: >=2.4.0 +import('./foo') +.then(foo => { foo.setup(); }); diff --git a/test/rules/whitespace/all/test.ts.fix b/test/rules/whitespace/all/test.ts.fix new file mode 100644 index 00000000000..d5cc53cab29 --- /dev/null +++ b/test/rules/whitespace/all/test.ts.fix @@ -0,0 +1,135 @@ +import ast = AST; +module M { + export var ast = AST; + + var x: number; + + var y = (x === 10) ? 1 : 2; + + var zz = (y === 4); + + var z = y; + + var a, b; + + switch (x) { + case 1: break; + default: break; + } + + for (x = 1; x < 2; ++x) { + goto: console.log("hi"); + } + + for (x = 2; x--;) {} + for (;;) {} + + while (i < 1) { + ++i; + } + + var q; + q.forEach(() => 3); + q.forEach(() => { + return 3; + }); + + var r: () => string; + var s: new () => string; + var a = "10"; + var a = "10"; +} + +var a; + +export = a; + +a.then(() => { + return 1; +}).if(() => { + return 1; +}); + +var name = "something"; +var test = ` + +
3); + ~ [missing whitespace] + ~ [missing whitespace] + q.forEach(()=>{ + ~ [missing whitespace] + ~ [missing whitespace] + return 3; + }); + + var r: ()=>string; + ~ [missing whitespace] + ~ [missing whitespace] + var s: new ()=>string; + ~ [missing whitespace] + ~ [missing whitespace] + var a = "10"; + ~ [missing whitespace] + var a = "10"; +} + +var a; + +export=a; + ~ [missing whitespace] + ~ [missing whitespace] + +a.then(() => { + return 1; +}).if(() => { + return 1; +}); + +var name = "something"; +var test = ` + +
3); + q.forEach(()=>{ + return 3; + }); + + var r: ()=>string; + var s: new ()=>string; + var a = "10"; + var a = "10"; +} + +var a; + +export=a; + +a.then(() => { + return 1; +}).if(() => { + return 1; +}); + +var name = "something"; +var test = ` + +
Date: Thu, 28 Nov 2019 13:26:42 -0500 Subject: [PATCH 6/7] captured case of this.contentTags being undefined --- src/rules/completed-docs/tagExclusion.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rules/completed-docs/tagExclusion.ts b/src/rules/completed-docs/tagExclusion.ts index f1a6affb0d7..4977d010d74 100644 --- a/src/rules/completed-docs/tagExclusion.ts +++ b/src/rules/completed-docs/tagExclusion.ts @@ -49,6 +49,10 @@ export class TagExclusion extends Exclusion { return true; } + if (this.contentTags === undefined) { + return false; + } + const matcherBody = this.contentTags[tagWithContent[0]]; if (matcherBody === undefined) { continue; From 924b8af038cf270b54d96796e1105d9eee52adf8 Mon Sep 17 00:00:00 2001 From: Jay Bhagat Date: Thu, 28 Nov 2019 13:44:38 -0500 Subject: [PATCH 7/7] added documentation to test --- test/rules/completed-docs/defaults/edge-case/test.ts.lint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rules/completed-docs/defaults/edge-case/test.ts.lint b/test/rules/completed-docs/defaults/edge-case/test.ts.lint index eeae338c31d..16d3985926b 100644 --- a/test/rules/completed-docs/defaults/edge-case/test.ts.lint +++ b/test/rules/completed-docs/defaults/edge-case/test.ts.lint @@ -1,5 +1,5 @@ /** - * + * Snippet where no error occurs (But completed-docs correctly gives an error on the lack of jsdoc). * @returns {Promise} */ export const handler = async () => { ... }