= $('')
`,
options: [2, { VariableDeclarator: { const: 3 } }],
},
+ // https://github.com/typescript-eslint/typescript-eslint/issues/441
+ `const;`,
],
invalid: [
...individualNodeTests.invalid,
diff --git a/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts b/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts
index cf596ffecbc3..b27cc8111bc0 100644
--- a/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts
+++ b/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts
@@ -1,5 +1,8 @@
-import rule from '../../src/rules/no-explicit-any';
+import rule, { MessageIds, Options } from '../../src/rules/no-explicit-any';
import { RuleTester } from '../RuleTester';
+import { TSESLint } from '@typescript-eslint/experimental-utils';
+
+type InvalidTestCase = TSESLint.InvalidTestCase;
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
@@ -187,7 +190,7 @@ type obj = {
options: [{ ignoreRestArgs: true }],
},
],
- invalid: [
+ invalid: ([
{
code: 'const number: any = 1',
errors: [
@@ -784,5 +787,23 @@ type obj = {
},
],
},
- ],
+ ] as InvalidTestCase[]).reduce((acc, testCase) => {
+ acc.push(testCase);
+ const options = testCase.options || [];
+ const code = `// fixToUnknown: true\n${testCase.code}`;
+ acc.push({
+ code,
+ output: code.replace(/any/g, 'unknown'),
+ options: [{ ...options[0], fixToUnknown: true }],
+ errors: testCase.errors.map(err => {
+ if (err.line === undefined) {
+ return err;
+ }
+
+ return { ...err, line: err.line + 1 };
+ }),
+ });
+
+ return acc;
+ }, []),
});
diff --git a/packages/eslint-plugin/tests/rules/no-triple-slash-reference.test.ts b/packages/eslint-plugin/tests/rules/no-triple-slash-reference.test.ts
index 5beaf104e52b..f120d5262432 100644
--- a/packages/eslint-plugin/tests/rules/no-triple-slash-reference.test.ts
+++ b/packages/eslint-plugin/tests/rules/no-triple-slash-reference.test.ts
@@ -22,7 +22,7 @@ let a
code: '/// ',
errors: [
{
- messageId: 'tripleSlashReference',
+ messageId: 'noTripleSlashReference',
line: 1,
column: 1,
},
@@ -36,7 +36,7 @@ let a
parser: '@typescript-eslint/parser',
errors: [
{
- messageId: 'tripleSlashReference',
+ messageId: 'noTripleSlashReference',
line: 2,
column: 1,
},
diff --git a/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts b/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts
new file mode 100644
index 000000000000..a5ff4734e1c5
--- /dev/null
+++ b/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts
@@ -0,0 +1,549 @@
+import rule from '../../src/rules/prefer-readonly';
+import { RuleTester, getFixturesRootDir } from '../RuleTester';
+
+const rootDir = getFixturesRootDir();
+const ruleTester = new RuleTester({
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ ecmaVersion: 2015,
+ tsconfigRootDir: rootDir,
+ project: './tsconfig.json',
+ },
+});
+
+ruleTester.run('prefer-readonly', rule, {
+ valid: [
+ `function ignore() { }`,
+ `const ignore = function () { }`,
+ `const ignore = () => { }`,
+ `const container = { member: true };
+ container.member;`,
+ `const container = { member: 1 };
+ +container.member;`,
+ `const container = { member: 1 };
+ ++container.member;`,
+ `const container = { member: 1 };
+ container.member++;`,
+ `const container = { member: 1 };
+ -container.member;`,
+ `const container = { member: 1 };
+ --container.member;`,
+ `const container = { member: 1 };
+ container.member--;`,
+ `class TestEmpty { }`,
+ `class TestReadonlyStatic {
+ private static readonly correctlyReadonlyStatic = 7;
+ }`,
+ `class TestModifiableStatic {
+ private static correctlyModifiableStatic = 7;
+
+ public constructor() {
+ TestModifiableStatic.correctlyModifiableStatic += 1;
+ }
+ }`,
+ `class TestModifiableByParameterProperty {
+ private static readonly correctlyModifiableByParameterProperty = 7;
+
+ public constructor(
+ public correctlyModifiablePublicParameter: number = (() => {
+ return TestModifiableStatic.correctlyModifiableByParameterProperty += 1;
+ })()
+ ) { }
+ }`,
+ `class TestReadonlyInline {
+ private readonly correctlyReadonlyInline = 7;
+ }`,
+ `class TestReadonlyDelayed {
+ private readonly correctlyReadonlyDelayed = 7;
+
+ public constructor() {
+ this.correctlyReadonlyDelayed += 1;
+ }
+ }`,
+ `class TestModifiableInline {
+ private correctlyModifiableInline = 7;
+
+ public mutate() {
+ this.correctlyModifiableInline += 1;
+
+ return class {
+ private correctlyModifiableInline = 7;
+
+ mutate() {
+ this.correctlyModifiableInline += 1;
+ }
+ };
+ }
+ }`,
+ `class TestModifiableDelayed {
+ private correctlyModifiableDelayed = 7;
+
+ public mutate() {
+ this.correctlyModifiableDelayed += 1;
+ }
+ }`,
+ `class TestModifiableDeleted {
+ private correctlyModifiableDeleted = 7;
+
+ public mutate() {
+ delete this.correctlyModifiableDeleted;
+ }
+ }`,
+ `class TestModifiableWithinConstructor {
+ private correctlyModifiableWithinConstructor = 7;
+
+ public constructor() {
+ (() => {
+ this.correctlyModifiableWithinConstructor += 1;
+ })();
+ }
+ }`,
+ `class TestModifiableWithinConstructorArrowFunction {
+ private correctlyModifiableWithinConstructorArrowFunction = 7;
+
+ public constructor() {
+ (() => {
+ this.correctlyModifiableWithinConstructorArrowFunction += 1;
+ })();
+ }
+ }`,
+ `class TestModifiableWithinConstructorInFunctionExpression {
+ private correctlyModifiableWithinConstructorInFunctionExpression = 7;
+
+ public constructor() {
+ const self = this;
+
+ (() => {
+ self.correctlyModifiableWithinConstructorInFunctionExpression += 1;
+ })();
+ }
+ }`,
+ `class TestModifiableWithinConstructorInGetAccessor {
+ private correctlyModifiableWithinConstructorInGetAccessor = 7;
+
+ public constructor() {
+ const self = this;
+
+ const confusingObject = {
+ get accessor() {
+ return self.correctlyModifiableWithinConstructorInGetAccessor += 1;
+ },
+ };
+ }
+ }`,
+ `class TestModifiableWithinConstructorInMethodDeclaration {
+ private correctlyModifiableWithinConstructorInMethodDeclaration = 7;
+
+ public constructor() {
+ const self = this;
+
+ const confusingObject = {
+ methodDeclaration() {
+ self.correctlyModifiableWithinConstructorInMethodDeclaration = 7;
+ }
+ };
+ }
+ }`,
+ `class TestModifiableWithinConstructorInSetAccessor {
+ private correctlyModifiableWithinConstructorInSetAccessor = 7;
+
+ public constructor() {
+ const self = this;
+
+ const confusingObject = {
+ set accessor(value: number) {
+ self.correctlyModifiableWithinConstructorInSetAccessor += value;
+ },
+ };
+ }
+ }`,
+ `class TestModifiablePostDecremented {
+ private correctlyModifiablePostDecremented = 7;
+
+ public mutate() {
+ this.correctlyModifiablePostDecremented -= 1;
+ }
+ }`,
+ `class TestyModifiablePostIncremented {
+ private correctlyModifiablePostIncremented = 7;
+
+ public mutate() {
+ this.correctlyModifiablePostIncremented += 1;
+ }
+ }`,
+ `class TestModifiablePreDecremented {
+ private correctlyModifiablePreDecremented = 7;
+
+ public mutate() {
+ --this.correctlyModifiablePreDecremented;
+ }
+ }`,
+ `class TestModifiablePreIncremented {
+ private correctlyModifiablePreIncremented = 7;
+
+ public mutate() {
+ ++this.correctlyModifiablePreIncremented;
+ }
+ }`,
+ `class TestProtectedModifiable {
+ protected protectedModifiable = 7;
+ }`,
+ `class TestPublicModifiable {
+ public publicModifiable = 7;
+ }`,
+ `class TestReadonlyParameter {
+ public constructor(
+ private readonly correctlyReadonlyParameter = 7,
+ ) { }
+ }`,
+ `class TestCorrectlyModifiableParameter {
+ public constructor(
+ private correctlyModifiableParameter = 7,
+ ) { }
+
+ public mutate() {
+ this.correctlyModifiableParameter += 1;
+ }
+ }`,
+ {
+ code: `class TestCorrectlyNonInlineLambdas {
+ private correctlyNonInlineLambda = 7;
+ }`,
+ options: [
+ {
+ onlyInlineLambdas: true,
+ },
+ ],
+ },
+ ],
+ invalid: [
+ {
+ code: `class TestIncorrectlyModifiableStatic {
+ private static incorrectlyModifiableStatic = 7;
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiableStatic',
+ },
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiableStatic {
+ private static readonly incorrectlyModifiableStatic = 7;
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiableStaticArrow {
+ private static incorrectlyModifiableStaticArrow = () => 7;
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiableStaticArrow',
+ },
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiableStaticArrow {
+ private static readonly incorrectlyModifiableStaticArrow = () => 7;
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiableInline {
+ private incorrectlyModifiableInline = 7;
+
+ public createConfusingChildClass() {
+ return class {
+ private incorrectlyModifiableInline = 7;
+ }
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiableInline',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ {
+ data: {
+ name: 'incorrectlyModifiableInline',
+ },
+ line: 6,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiableInline {
+ private readonly incorrectlyModifiableInline = 7;
+
+ public createConfusingChildClass() {
+ return class {
+ private readonly incorrectlyModifiableInline = 7;
+ }
+ }
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiableDelayed {
+ private incorrectlyModifiableDelayed = 7;
+
+ public constructor() {
+ this.incorrectlyModifiableDelayed = 7;
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiableDelayed',
+ },
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiableDelayed {
+ private readonly incorrectlyModifiableDelayed = 7;
+
+ public constructor() {
+ this.incorrectlyModifiableDelayed = 7;
+ }
+ }`,
+ },
+ {
+ code: `class TestChildClassExpressionModifiable {
+ private childClassExpressionModifiable = 7;
+
+ public createConfusingChildClass() {
+ return class {
+ private childClassExpressionModifiable = 7;
+
+ mutate() {
+ this.childClassExpressionModifiable += 1;
+ }
+ }
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'childClassExpressionModifiable',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestChildClassExpressionModifiable {
+ private readonly childClassExpressionModifiable = 7;
+
+ public createConfusingChildClass() {
+ return class {
+ private childClassExpressionModifiable = 7;
+
+ mutate() {
+ this.childClassExpressionModifiable += 1;
+ }
+ }
+ }
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiablePostMinus {
+ private incorrectlyModifiablePostMinus = 7;
+
+ public mutate() {
+ this.incorrectlyModifiablePostMinus - 1;
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiablePostMinus',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiablePostMinus {
+ private readonly incorrectlyModifiablePostMinus = 7;
+
+ public mutate() {
+ this.incorrectlyModifiablePostMinus - 1;
+ }
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiablePostPlus {
+ private incorrectlyModifiablePostPlus = 7;
+
+ public mutate() {
+ this.incorrectlyModifiablePostPlus + 1;
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiablePostPlus',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiablePostPlus {
+ private readonly incorrectlyModifiablePostPlus = 7;
+
+ public mutate() {
+ this.incorrectlyModifiablePostPlus + 1;
+ }
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiablePreMinus {
+ private incorrectlyModifiablePreMinus = 7;
+
+ public mutate() {
+ -this.incorrectlyModifiablePreMinus;
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiablePreMinus',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiablePreMinus {
+ private readonly incorrectlyModifiablePreMinus = 7;
+
+ public mutate() {
+ -this.incorrectlyModifiablePreMinus;
+ }
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiablePrePlus {
+ private incorrectlyModifiablePrePlus = 7;
+
+ public mutate() {
+ +this.incorrectlyModifiablePrePlus;
+ }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiablePrePlus',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiablePrePlus {
+ private readonly incorrectlyModifiablePrePlus = 7;
+
+ public mutate() {
+ +this.incorrectlyModifiablePrePlus;
+ }
+ }`,
+ },
+ {
+ code: `class TestOverlappingClassVariable {
+ private overlappingClassVariable = 7;
+
+ public workWithSimilarClass(other: SimilarClass) {
+ other.overlappingClassVariable = 7;
+ }
+ }
+
+ class SimilarClass {
+ public overlappingClassVariable = 7;
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'overlappingClassVariable',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestOverlappingClassVariable {
+ private readonly overlappingClassVariable = 7;
+
+ public workWithSimilarClass(other: SimilarClass) {
+ other.overlappingClassVariable = 7;
+ }
+ }
+
+ class SimilarClass {
+ public overlappingClassVariable = 7;
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiableParameter {
+ public constructor(
+ private incorrectlyModifiableParameter = 7,
+ ) { }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiableParameter',
+ },
+ line: 3,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiableParameter {
+ public constructor(
+ private readonly incorrectlyModifiableParameter = 7,
+ ) { }
+ }`,
+ },
+ {
+ code: `class TestIncorrectlyModifiableParameter {
+ public constructor(
+ public ignore: boolean,
+ private incorrectlyModifiableParameter = 7,
+ ) { }
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyModifiableParameter',
+ },
+ line: 4,
+ messageId: 'preferReadonly',
+ },
+ ],
+ output: `class TestIncorrectlyModifiableParameter {
+ public constructor(
+ public ignore: boolean,
+ private readonly incorrectlyModifiableParameter = 7,
+ ) { }
+ }`,
+ },
+ {
+ code: `class TestCorrectlyNonInlineLambdas {
+ private incorrectlyInlineLambda = () => 7;
+ }`,
+ errors: [
+ {
+ data: {
+ name: 'incorrectlyInlineLambda',
+ },
+ line: 2,
+ messageId: 'preferReadonly',
+ },
+ ],
+ options: [
+ {
+ onlyInlineLambdas: true,
+ },
+ ],
+ output: `class TestCorrectlyNonInlineLambdas {
+ private readonly incorrectlyInlineLambda = () => 7;
+ }`,
+ },
+ ],
+});
diff --git a/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts b/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts
new file mode 100644
index 000000000000..030bade0f480
--- /dev/null
+++ b/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts
@@ -0,0 +1,907 @@
+import path from 'path';
+import rule from '../../src/rules/strict-boolean-expressions';
+import { RuleTester } from '../RuleTester';
+
+const rootPath = path.join(process.cwd(), 'tests/fixtures/');
+
+const ruleTester = new RuleTester({
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ tsconfigRootDir: rootPath,
+ project: './tsconfig.json',
+ },
+});
+
+ruleTester.run('strict-boolean-expressions', rule, {
+ valid: [
+ `
+ let val = true;
+ let bool = !val;
+ let bool2 = true || val;
+ let bool3 = true && val;
+ `,
+ `
+ let a = 0;
+ let u1 = typeof a;
+ let u2 = -a;
+ let u3 = ~a;
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ if (true) {
+ return;
+ }
+
+ if (bool1) {
+ return;
+ }
+
+ if (bool1 && bool2) {
+ return;
+ }
+
+ if (bool1 || bool2) {
+ return;
+ }
+
+ if ((bool1 && bool2) || (bool1 || bool2)) {
+ return;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ const res1 = true ? true : false;
+ const res2 = bool1 && bool2 ? true : false;
+ const res3 = bool1 || bool2 ? true : false;
+ const res4 = (bool1 && bool2) || (bool1 || bool2) ? true : false;
+ `,
+ `
+ for (let i = 0; true; i++) {
+ break;
+ }
+ `,
+ `
+ const bool = true;
+ for (let i = 0; bool; i++) {
+ break;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ for (let i = 0; bool1 && bool2; i++) {
+ break;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ for (let i = 0; bool1 || bool2; i++) {
+ break;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ for (let i = 0; (bool1 && bool2) || (bool1 || bool2); i++) {
+ break;
+ }
+ `,
+ `
+ while (true) {
+ break;
+ }
+ `,
+ `
+ const bool = true;
+ while (bool) {
+ break;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ while (bool1 && bool2) {
+ break;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ while (bool1 || bool2) {
+ break;
+ }
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ while ((bool1 && bool2) || (bool1 || bool2)) {
+ break;
+ }
+ `,
+ `
+ do {
+ break;
+ } while (true);
+ `,
+ `
+ const bool = true;
+ do {
+ break;
+ } while (bool);
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ do {
+ break;
+ } while (bool1 && bool2);
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ do {
+ break;
+ } while (bool1 || bool2);
+ `,
+ `
+ const bool1 = true;
+ const bool2 = false;
+ do {
+ break;
+ } while ((bool1 && bool2) || (bool1 || bool2));
+ `,
+ `
+ function foo(arg: T) { return !arg; }
+ `,
+ ],
+
+ invalid: [
+ {
+ code: `
+ let val = 1;
+ let bool = !val;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 21,
+ },
+ ],
+ },
+ {
+ code: `
+ let val;
+ let bool = !val;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 21,
+ },
+ ],
+ },
+ {
+ code: `
+ let val = 1;
+ let bool = true && val;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 20,
+ },
+ ],
+ },
+ {
+ code: `
+ let val;
+ let bool = true && val;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 20,
+ },
+ ],
+ },
+ {
+ code: `
+ let val = 1;
+ let bool = true || val;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 20,
+ },
+ ],
+ },
+ {
+ code: `
+ let val;
+ let bool = true || val;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 20,
+ },
+ ],
+ },
+ {
+ code: `
+ if (1) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ if (undefined) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item = 1;
+ if (item) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item;
+ if (item) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = true;
+ let item2 = 1;
+ if (item1 && item2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = 1;
+ let item2 = true;
+ if (item1 && item2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1;
+ let item2 = true;
+ if (item1 && item2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = true;
+ let item2 = 1;
+ if (item1 || item2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = 1;
+ let item2 = true;
+ if (item1 || item2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1;
+ let item2 = true;
+ if (item1 || item2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 13,
+ },
+ ],
+ },
+ {
+ code: `
+ const bool = 1 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ const bool = undefined ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item = 1;
+ const bool = item ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item;
+ const bool = item ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = 1;
+ let item2 = false;
+ const bool = item1 && item2 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = true;
+ let item2 = 1;
+ const bool = item1 && item2 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = true;
+ let item2;
+ const bool = item1 && item2 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = 1;
+ let item2 = false;
+ const bool = item1 || item2 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = true;
+ let item2 = 1;
+ const bool = item1 || item2 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ let item1 = true;
+ let item2;
+ const bool = item1 || item2 ? true : false;
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 22,
+ },
+ ],
+ },
+ {
+ code: `
+ for (let i = 0; 1; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ for (let i = 0; undefined; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool = 1;
+ for (let i = 0; bool; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool;
+ for (let i = 0; bool; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1 = 1;
+ let bool2 = true;
+ for (let i = 0; bool1 && bool2; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1;
+ let bool2 = true;
+ for (let i = 0; bool1 && bool2; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1 = 1;
+ let bool2 = true;
+ for (let i = 0; bool1 || bool2; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1;
+ let bool2 = true;
+ for (let i = 0; bool1 || bool2; i++) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 25,
+ },
+ ],
+ },
+ {
+ code: `
+ while (1) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ while (undefined) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool = 1;
+ while (bool) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool;
+ while (bool) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 3,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1 = 1;
+ let bool2 = true;
+ while (bool1 && bool2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1;
+ let bool2 = true;
+ while (bool1 && bool2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1 = 1;
+ let bool2 = true;
+ while (bool1 || bool2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1;
+ let bool2 = true;
+ while (bool1 || bool2) {
+ return;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 16,
+ },
+ ],
+ },
+ {
+ code: `
+ do {
+ return;
+ } while (1);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ do {
+ return;
+ } while (undefined);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 4,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool = 1;
+ do {
+ return;
+ } while (bool);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 5,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool;
+ do {
+ return;
+ } while (bool);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 5,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1 = 1;
+ let bool2 = true;
+ do {
+ return;
+ } while (bool1 && bool2);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 6,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1;
+ let bool2 = true;
+ do {
+ return;
+ } while (bool1 && bool2);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 6,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1 = 1;
+ let bool2 = true;
+ do {
+ return;
+ } while (bool1 || bool2);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 6,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ let bool1;
+ let bool2 = true;
+ do {
+ return;
+ } while (bool1 || bool2);
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 6,
+ column: 18,
+ },
+ ],
+ },
+ {
+ code: `
+ function foo(arg: T) { return !arg; }
+ `,
+ errors: [
+ {
+ messageId: 'strictBooleanExpression',
+ line: 2,
+ column: 58,
+ },
+ ],
+ },
+ ],
+});
diff --git a/packages/eslint-plugin/tests/rules/triple-slash-reference.test.ts b/packages/eslint-plugin/tests/rules/triple-slash-reference.test.ts
new file mode 100644
index 000000000000..0785bf7a02ee
--- /dev/null
+++ b/packages/eslint-plugin/tests/rules/triple-slash-reference.test.ts
@@ -0,0 +1,128 @@
+import rule from '../../src/rules/triple-slash-reference';
+import { RuleTester } from '../RuleTester';
+
+const ruleTester = new RuleTester({
+ parserOptions: {
+ sourceType: 'module',
+ },
+ parser: '@typescript-eslint/parser',
+});
+
+ruleTester.run('triple-slash-reference', rule, {
+ valid: [
+ {
+ code: `
+ ///
+ ///
+ ///
+ import * as foo from "foo"
+ import * as bar from "bar"
+ import * as baz from "baz"
+ `,
+ options: [{ path: 'always', types: 'always', lib: 'always' }],
+ },
+ {
+ code: `
+ import * as foo from "foo"
+ `,
+ options: [{ path: 'never' }],
+ },
+ {
+ code: `
+ import * as foo from "foo"
+ `,
+ options: [{ types: 'never' }],
+ },
+ {
+ code: `
+ import * as foo from "foo"
+ `,
+ options: [{ lib: 'never' }],
+ },
+ {
+ code: `
+ import * as foo from "foo"
+ `,
+ options: [{ types: 'prefer-import' }],
+ },
+ {
+ code: `
+ ///
+ import * as bar from "bar"
+ `,
+ options: [{ types: 'prefer-import' }],
+ },
+ {
+ code: `
+ /*
+ ///
+ */
+ import * as foo from "foo"
+ `,
+ options: [{ path: 'never', types: 'never', lib: 'never' }],
+ },
+ ],
+ invalid: [
+ {
+ code: `
+///
+import * as foo from "foo"
+ `,
+ options: [{ types: 'prefer-import' }],
+ errors: [
+ {
+ messageId: 'tripleSlashReference',
+ line: 2,
+ column: 1,
+ },
+ ],
+ },
+ {
+ code: `
+///
+import foo = require("foo");
+ `,
+ options: [{ types: 'prefer-import' }],
+ errors: [
+ {
+ messageId: 'tripleSlashReference',
+ line: 2,
+ column: 1,
+ },
+ ],
+ },
+ {
+ code: `/// `,
+ options: [{ path: 'never' }],
+ errors: [
+ {
+ messageId: 'tripleSlashReference',
+ line: 1,
+ column: 1,
+ },
+ ],
+ },
+ {
+ code: `/// `,
+ options: [{ types: 'never' }],
+ errors: [
+ {
+ messageId: 'tripleSlashReference',
+ line: 1,
+ column: 1,
+ },
+ ],
+ },
+ {
+ code: `/// `,
+ options: [{ lib: 'never' }],
+ errors: [
+ {
+ messageId: 'tripleSlashReference',
+ line: 1,
+ column: 1,
+ },
+ ],
+ },
+ ],
+});
diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md
index 0726874992f2..40646cc4204d 100644
--- a/packages/experimental-utils/CHANGELOG.md
+++ b/packages/experimental-utils/CHANGELOG.md
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)
+
+**Note:** Version bump only for package @typescript-eslint/experimental-utils
+
+
+
+
+
# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)
diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json
index fa86431a8e02..d0a85ed8a905 100644
--- a/packages/experimental-utils/package.json
+++ b/packages/experimental-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/experimental-utils",
- "version": "1.11.0",
+ "version": "1.12.0",
"description": "(Experimental) Utilities for working with TypeScript + ESLint together",
"keywords": [
"eslint",
@@ -36,7 +36,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@typescript-eslint/typescript-estree": "1.11.0",
+ "@typescript-eslint/typescript-estree": "1.12.0",
"eslint-scope": "^4.0.0"
},
"peerDependencies": {
diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md
index 3ed7f17edcf1..78926d846a92 100644
--- a/packages/parser/CHANGELOG.md
+++ b/packages/parser/CHANGELOG.md
@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)
+
+
+### Bug Fixes
+
+* **typescript-estree:** fix `async` identifier token typed as `Keyword` ([#681](https://github.com/typescript-eslint/typescript-eslint/issues/681)) ([6de19d3](https://github.com/typescript-eslint/typescript-eslint/commit/6de19d3))
+
+
+
+
+
# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)
diff --git a/packages/parser/package.json b/packages/parser/package.json
index e683453843b1..cc6b85720b00 100644
--- a/packages/parser/package.json
+++ b/packages/parser/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/parser",
- "version": "1.11.0",
+ "version": "1.12.0",
"description": "An ESLint custom parser which leverages TypeScript ESTree",
"main": "dist/parser.js",
"files": [
@@ -42,11 +42,11 @@
},
"dependencies": {
"@types/eslint-visitor-keys": "^1.0.0",
- "@typescript-eslint/experimental-utils": "1.11.0",
- "@typescript-eslint/typescript-estree": "1.11.0",
+ "@typescript-eslint/experimental-utils": "1.12.0",
+ "@typescript-eslint/typescript-estree": "1.12.0",
"eslint-visitor-keys": "^1.0.0"
},
"devDependencies": {
- "@typescript-eslint/shared-fixtures": "1.11.0"
+ "@typescript-eslint/shared-fixtures": "1.12.0"
}
}
diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap
index aab288144990..2e00218b783a 100644
--- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap
+++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap
@@ -18534,6 +18534,614 @@ Object {
}
`;
+exports[`typescript fixtures/basics/keyword-variables.src 1`] = `
+Object {
+ "$id": 11,
+ "block": Object {
+ "range": Array [
+ 0,
+ 154,
+ ],
+ "type": "Program",
+ },
+ "childScopes": Array [
+ Object {
+ "$id": 10,
+ "block": Object {
+ "range": Array [
+ 0,
+ 154,
+ ],
+ "type": "Program",
+ },
+ "childScopes": Array [],
+ "functionExpressionScope": false,
+ "isStrict": true,
+ "references": Array [
+ Object {
+ "$id": 5,
+ "from": Object {
+ "$ref": 10,
+ },
+ "identifier": Object {
+ "name": "get",
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Identifier",
+ },
+ "kind": "w",
+ "resolved": Object {
+ "$ref": 0,
+ },
+ "writeExpr": Object {
+ "range": Array [
+ 12,
+ 13,
+ ],
+ "type": "Literal",
+ },
+ },
+ Object {
+ "$id": 6,
+ "from": Object {
+ "$ref": 10,
+ },
+ "identifier": Object {
+ "name": "set",
+ "range": Array [
+ 21,
+ 24,
+ ],
+ "type": "Identifier",
+ },
+ "kind": "w",
+ "resolved": Object {
+ "$ref": 1,
+ },
+ "writeExpr": Object {
+ "range": Array [
+ 27,
+ 28,
+ ],
+ "type": "Literal",
+ },
+ },
+ Object {
+ "$id": 7,
+ "from": Object {
+ "$ref": 10,
+ },
+ "identifier": Object {
+ "name": "module",
+ "range": Array [
+ 36,
+ 42,
+ ],
+ "type": "Identifier",
+ },
+ "kind": "w",
+ "resolved": Object {
+ "$ref": 2,
+ },
+ "writeExpr": Object {
+ "range": Array [
+ 45,
+ 46,
+ ],
+ "type": "Literal",
+ },
+ },
+ Object {
+ "$id": 8,
+ "from": Object {
+ "$ref": 10,
+ },
+ "identifier": Object {
+ "name": "type",
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "Identifier",
+ },
+ "kind": "w",
+ "resolved": Object {
+ "$ref": 3,
+ },
+ "writeExpr": Object {
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "type": "Literal",
+ },
+ },
+ Object {
+ "$id": 9,
+ "from": Object {
+ "$ref": 10,
+ },
+ "identifier": Object {
+ "name": "async",
+ "range": Array [
+ 70,
+ 75,
+ ],
+ "type": "Identifier",
+ },
+ "kind": "w",
+ "resolved": Object {
+ "$ref": 4,
+ },
+ "writeExpr": Object {
+ "range": Array [
+ 78,
+ 79,
+ ],
+ "type": "Literal",
+ },
+ },
+ ],
+ "throughReferences": Array [],
+ "type": "module",
+ "upperScope": Object {
+ "$ref": 11,
+ },
+ "variableMap": Object {
+ "async": Object {
+ "$ref": 4,
+ },
+ "get": Object {
+ "$ref": 0,
+ },
+ "module": Object {
+ "$ref": 2,
+ },
+ "set": Object {
+ "$ref": 1,
+ },
+ "type": Object {
+ "$ref": 3,
+ },
+ },
+ "variableScope": Object {
+ "$ref": 10,
+ },
+ "variables": Array [
+ Object {
+ "$id": 0,
+ "defs": Array [
+ Object {
+ "name": Object {
+ "name": "get",
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 6,
+ 13,
+ ],
+ "type": "VariableDeclarator",
+ },
+ "parent": Object {
+ "range": Array [
+ 0,
+ 14,
+ ],
+ "type": "VariableDeclaration",
+ },
+ "type": "Variable",
+ },
+ Object {
+ "name": Object {
+ "name": "get",
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "ImportSpecifier",
+ },
+ "parent": Object {
+ "range": Array [
+ 82,
+ 153,
+ ],
+ "type": "ImportDeclaration",
+ },
+ "type": "ImportBinding",
+ },
+ ],
+ "eslintUsed": undefined,
+ "identifiers": Array [
+ Object {
+ "name": "get",
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Identifier",
+ },
+ Object {
+ "name": "get",
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "Identifier",
+ },
+ ],
+ "name": "get",
+ "references": Array [
+ Object {
+ "$ref": 5,
+ },
+ ],
+ "scope": Object {
+ "$ref": 10,
+ },
+ },
+ Object {
+ "$id": 1,
+ "defs": Array [
+ Object {
+ "name": Object {
+ "name": "set",
+ "range": Array [
+ 21,
+ 24,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 21,
+ 28,
+ ],
+ "type": "VariableDeclarator",
+ },
+ "parent": Object {
+ "range": Array [
+ 15,
+ 29,
+ ],
+ "type": "VariableDeclaration",
+ },
+ "type": "Variable",
+ },
+ Object {
+ "name": Object {
+ "name": "set",
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "ImportSpecifier",
+ },
+ "parent": Object {
+ "range": Array [
+ 82,
+ 153,
+ ],
+ "type": "ImportDeclaration",
+ },
+ "type": "ImportBinding",
+ },
+ ],
+ "eslintUsed": undefined,
+ "identifiers": Array [
+ Object {
+ "name": "set",
+ "range": Array [
+ 21,
+ 24,
+ ],
+ "type": "Identifier",
+ },
+ Object {
+ "name": "set",
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "Identifier",
+ },
+ ],
+ "name": "set",
+ "references": Array [
+ Object {
+ "$ref": 6,
+ },
+ ],
+ "scope": Object {
+ "$ref": 10,
+ },
+ },
+ Object {
+ "$id": 2,
+ "defs": Array [
+ Object {
+ "name": Object {
+ "name": "module",
+ "range": Array [
+ 36,
+ 42,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 36,
+ 46,
+ ],
+ "type": "VariableDeclarator",
+ },
+ "parent": Object {
+ "range": Array [
+ 30,
+ 47,
+ ],
+ "type": "VariableDeclaration",
+ },
+ "type": "Variable",
+ },
+ Object {
+ "name": Object {
+ "name": "module",
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "ImportSpecifier",
+ },
+ "parent": Object {
+ "range": Array [
+ 82,
+ 153,
+ ],
+ "type": "ImportDeclaration",
+ },
+ "type": "ImportBinding",
+ },
+ ],
+ "eslintUsed": undefined,
+ "identifiers": Array [
+ Object {
+ "name": "module",
+ "range": Array [
+ 36,
+ 42,
+ ],
+ "type": "Identifier",
+ },
+ Object {
+ "name": "module",
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "Identifier",
+ },
+ ],
+ "name": "module",
+ "references": Array [
+ Object {
+ "$ref": 7,
+ },
+ ],
+ "scope": Object {
+ "$ref": 10,
+ },
+ },
+ Object {
+ "$id": 3,
+ "defs": Array [
+ Object {
+ "name": Object {
+ "name": "type",
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 54,
+ 62,
+ ],
+ "type": "VariableDeclarator",
+ },
+ "parent": Object {
+ "range": Array [
+ 48,
+ 63,
+ ],
+ "type": "VariableDeclaration",
+ },
+ "type": "Variable",
+ },
+ Object {
+ "name": Object {
+ "name": "type",
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "ImportSpecifier",
+ },
+ "parent": Object {
+ "range": Array [
+ 82,
+ 153,
+ ],
+ "type": "ImportDeclaration",
+ },
+ "type": "ImportBinding",
+ },
+ ],
+ "eslintUsed": undefined,
+ "identifiers": Array [
+ Object {
+ "name": "type",
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "Identifier",
+ },
+ Object {
+ "name": "type",
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "Identifier",
+ },
+ ],
+ "name": "type",
+ "references": Array [
+ Object {
+ "$ref": 8,
+ },
+ ],
+ "scope": Object {
+ "$ref": 10,
+ },
+ },
+ Object {
+ "$id": 4,
+ "defs": Array [
+ Object {
+ "name": Object {
+ "name": "async",
+ "range": Array [
+ 70,
+ 75,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 70,
+ 79,
+ ],
+ "type": "VariableDeclarator",
+ },
+ "parent": Object {
+ "range": Array [
+ 64,
+ 80,
+ ],
+ "type": "VariableDeclaration",
+ },
+ "type": "Variable",
+ },
+ Object {
+ "name": Object {
+ "name": "async",
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "Identifier",
+ },
+ "node": Object {
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "ImportSpecifier",
+ },
+ "parent": Object {
+ "range": Array [
+ 82,
+ 153,
+ ],
+ "type": "ImportDeclaration",
+ },
+ "type": "ImportBinding",
+ },
+ ],
+ "eslintUsed": undefined,
+ "identifiers": Array [
+ Object {
+ "name": "async",
+ "range": Array [
+ 70,
+ 75,
+ ],
+ "type": "Identifier",
+ },
+ Object {
+ "name": "async",
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "Identifier",
+ },
+ ],
+ "name": "async",
+ "references": Array [
+ Object {
+ "$ref": 9,
+ },
+ ],
+ "scope": Object {
+ "$ref": 10,
+ },
+ },
+ ],
+ },
+ ],
+ "functionExpressionScope": false,
+ "isStrict": false,
+ "references": Array [],
+ "throughReferences": Array [],
+ "type": "global",
+ "upperScope": null,
+ "variableMap": Object {},
+ "variableScope": Object {
+ "$ref": 11,
+ },
+ "variables": Array [],
+}
+`;
+
exports[`typescript fixtures/basics/nested-type-arguments.src 1`] = `
Object {
"$id": 2,
diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md
index 9cdeac709516..06c3ba92d001 100644
--- a/packages/shared-fixtures/CHANGELOG.md
+++ b/packages/shared-fixtures/CHANGELOG.md
@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)
+
+
+### Bug Fixes
+
+* **typescript-estree:** fix `async` identifier token typed as `Keyword` ([#681](https://github.com/typescript-eslint/typescript-eslint/issues/681)) ([6de19d3](https://github.com/typescript-eslint/typescript-eslint/commit/6de19d3))
+
+
+
+
+
# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)
diff --git a/packages/shared-fixtures/fixtures/typescript/basics/keyword-variables.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/keyword-variables.src.ts
new file mode 100644
index 000000000000..f4cbb3212bf1
--- /dev/null
+++ b/packages/shared-fixtures/fixtures/typescript/basics/keyword-variables.src.ts
@@ -0,0 +1,13 @@
+const get = 1;
+const set = 1;
+const module = 1;
+const type = 1;
+const async = 1;
+
+import {
+ get,
+ set,
+ module,
+ type,
+ async,
+} from 'fake-module';
diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json
index 28caabd65f4b..080975e7bb28 100644
--- a/packages/shared-fixtures/package.json
+++ b/packages/shared-fixtures/package.json
@@ -1,5 +1,5 @@
{
"name": "@typescript-eslint/shared-fixtures",
- "version": "1.11.0",
+ "version": "1.12.0",
"private": true
}
diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md
index 4f3c7cd49560..183ff3c672d4 100644
--- a/packages/typescript-estree/CHANGELOG.md
+++ b/packages/typescript-estree/CHANGELOG.md
@@ -3,6 +3,23 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)
+
+
+### Bug Fixes
+
+* **eslint-plugin:** handle `const;` ([#633](https://github.com/typescript-eslint/typescript-eslint/issues/633)) ([430d628](https://github.com/typescript-eslint/typescript-eslint/commit/430d628)), closes [#441](https://github.com/typescript-eslint/typescript-eslint/issues/441)
+* **typescript-estree:** fix `async` identifier token typed as `Keyword` ([#681](https://github.com/typescript-eslint/typescript-eslint/issues/681)) ([6de19d3](https://github.com/typescript-eslint/typescript-eslint/commit/6de19d3))
+
+
+### Features
+
+* **eslint-plugin:** added new rule prefer-readonly ([#555](https://github.com/typescript-eslint/typescript-eslint/issues/555)) ([76b89a5](https://github.com/typescript-eslint/typescript-eslint/commit/76b89a5))
+
+
+
+
+
# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)
diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json
index 61ccbddf8588..33079d27f036 100644
--- a/packages/typescript-estree/package.json
+++ b/packages/typescript-estree/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/typescript-estree",
- "version": "1.11.0",
+ "version": "1.12.0",
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
"main": "dist/parser.js",
"types": "dist/parser.d.ts",
@@ -46,6 +46,6 @@
},
"devDependencies": {
"@babel/types": "^7.3.2",
- "@typescript-eslint/shared-fixtures": "1.11.0"
+ "@typescript-eslint/shared-fixtures": "1.12.0"
}
}
diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts
index f8151e1b268c..cdf6b184150f 100644
--- a/packages/typescript-estree/src/convert.ts
+++ b/packages/typescript-estree/src/convert.ts
@@ -43,9 +43,9 @@ export function convertError(error: any) {
export class Converter {
private readonly ast: ts.SourceFile;
- private options: ConverterOptions;
- private esTreeNodeToTSNodeMap = new WeakMap();
- private tsNodeToESTreeNodeMap = new WeakMap();
+ private readonly options: ConverterOptions;
+ private readonly esTreeNodeToTSNodeMap = new WeakMap();
+ private readonly tsNodeToESTreeNodeMap = new WeakMap();
private allowPattern: boolean = false;
private inTypeMode: boolean = false;
diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts
index d682bb091b4e..a8d1b137d1c2 100644
--- a/packages/typescript-estree/src/node-utils.ts
+++ b/packages/typescript-estree/src/node-utils.ts
@@ -455,6 +455,7 @@ export function getTokenType(token: any): AST_TOKEN_TYPES {
case SyntaxKind.SetKeyword:
case SyntaxKind.TypeKeyword:
case SyntaxKind.ModuleKeyword:
+ case SyntaxKind.AsyncKeyword:
return AST_TOKEN_TYPES.Identifier;
default:
@@ -550,17 +551,17 @@ export function convertToken(
ast: ts.SourceFile,
): TSESTree.Token {
const start =
- token.kind === SyntaxKind.JsxText
- ? token.getFullStart()
- : token.getStart(ast),
- end = token.getEnd(),
- value = ast.text.slice(start, end),
- newToken: TSESTree.Token = {
- type: getTokenType(token),
- value,
- range: [start, end],
- loc: getLocFor(start, end, ast),
- };
+ token.kind === SyntaxKind.JsxText
+ ? token.getFullStart()
+ : token.getStart(ast);
+ const end = token.getEnd();
+ const value = ast.text.slice(start, end);
+ const newToken: TSESTree.Token = {
+ type: getTokenType(token),
+ value,
+ range: [start, end],
+ loc: getLocFor(start, end, ast),
+ };
if (newToken.type === 'RegularExpression') {
newToken.regex = {
diff --git a/packages/typescript-estree/src/ts-estree/ts-estree.ts b/packages/typescript-estree/src/ts-estree/ts-estree.ts
index e786e83e0dfb..8eed48390d0f 100644
--- a/packages/typescript-estree/src/ts-estree/ts-estree.ts
+++ b/packages/typescript-estree/src/ts-estree/ts-estree.ts
@@ -1387,6 +1387,7 @@ export interface UnaryExpression extends UnaryExpressionBase {
export interface VariableDeclaration extends BaseNode {
type: AST_NODE_TYPES.VariableDeclaration;
+ // NOTE - this is not guaranteed to have any elements in it. i.e. `const;`
declarations: VariableDeclarator[];
kind: 'let' | 'const' | 'var';
declare?: boolean;
diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
index 227932cd9360..7af41c0f3025 100644
--- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
+++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
@@ -1883,6 +1883,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/keyof-operator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
+exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/keyword-variables.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
+
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/nested-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/never-type-param.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap
index c8f0cf9e3649..0859b0362508 100644
--- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap
+++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap
@@ -58608,6 +58608,1442 @@ Object {
}
`;
+exports[`typescript fixtures/basics/keyword-variables.src 1`] = `
+Object {
+ "body": Array [
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "name": "get",
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 12,
+ 13,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 13,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 14,
+ ],
+ "type": "VariableDeclaration",
+ },
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ },
+ },
+ "name": "set",
+ "range": Array [
+ 21,
+ 24,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 27,
+ 28,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 21,
+ 28,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 15,
+ 29,
+ ],
+ "type": "VariableDeclaration",
+ },
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ },
+ },
+ "name": "module",
+ "range": Array [
+ 36,
+ 42,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 45,
+ 46,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 36,
+ 46,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 17,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 30,
+ 47,
+ ],
+ "type": "VariableDeclaration",
+ },
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ },
+ },
+ "name": "type",
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 54,
+ 62,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 48,
+ 63,
+ ],
+ "type": "VariableDeclaration",
+ },
+ Object {
+ "declarations": Array [
+ Object {
+ "id": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 5,
+ },
+ },
+ "name": "async",
+ "range": Array [
+ 70,
+ 75,
+ ],
+ "type": "Identifier",
+ },
+ "init": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 78,
+ 79,
+ ],
+ "raw": "1",
+ "type": "Literal",
+ "value": 1,
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 70,
+ 79,
+ ],
+ "type": "VariableDeclarator",
+ },
+ ],
+ "kind": "const",
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 64,
+ 80,
+ ],
+ "type": "VariableDeclaration",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 13,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 82,
+ 153,
+ ],
+ "source": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 13,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 13,
+ },
+ },
+ "range": Array [
+ 139,
+ 152,
+ ],
+ "raw": "'fake-module'",
+ "type": "Literal",
+ "value": "fake-module",
+ },
+ "specifiers": Array [
+ Object {
+ "imported": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ },
+ },
+ "name": "get",
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ },
+ },
+ "local": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ },
+ },
+ "name": "get",
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "Identifier",
+ },
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "ImportSpecifier",
+ },
+ Object {
+ "imported": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 9,
+ },
+ },
+ "name": "set",
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 9,
+ },
+ },
+ "local": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 9,
+ },
+ },
+ "name": "set",
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "Identifier",
+ },
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "ImportSpecifier",
+ },
+ Object {
+ "imported": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ },
+ },
+ "name": "module",
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ },
+ },
+ "local": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ },
+ },
+ "name": "module",
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "Identifier",
+ },
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "ImportSpecifier",
+ },
+ Object {
+ "imported": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 11,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ },
+ },
+ "name": "type",
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 11,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ },
+ },
+ "local": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 11,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ },
+ },
+ "name": "type",
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "Identifier",
+ },
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "ImportSpecifier",
+ },
+ Object {
+ "imported": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 12,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ },
+ },
+ "name": "async",
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "Identifier",
+ },
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 12,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ },
+ },
+ "local": Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 12,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ },
+ },
+ "name": "async",
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "Identifier",
+ },
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "ImportSpecifier",
+ },
+ ],
+ "type": "ImportDeclaration",
+ },
+ ],
+ "loc": Object {
+ "end": Object {
+ "column": 0,
+ "line": 14,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 154,
+ ],
+ "sourceType": "module",
+ "tokens": Array [
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 0,
+ 5,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 6,
+ 9,
+ ],
+ "type": "Identifier",
+ "value": "get",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 10,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 10,
+ 11,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 12,
+ 13,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 1,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 1,
+ },
+ },
+ "range": Array [
+ 13,
+ 14,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 15,
+ 20,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 21,
+ 24,
+ ],
+ "type": "Identifier",
+ "value": "set",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 10,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 25,
+ 26,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 27,
+ 28,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 2,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 2,
+ },
+ },
+ "range": Array [
+ 28,
+ 29,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 30,
+ 35,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 36,
+ 42,
+ ],
+ "type": "Identifier",
+ "value": "module",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 43,
+ 44,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 45,
+ 46,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 17,
+ "line": 3,
+ },
+ "start": Object {
+ "column": 16,
+ "line": 3,
+ },
+ },
+ "range": Array [
+ 46,
+ 47,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 48,
+ 53,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 10,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 54,
+ 58,
+ ],
+ "type": "Identifier",
+ "value": "type",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 12,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 11,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 59,
+ 60,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 14,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 13,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 61,
+ 62,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 4,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 4,
+ },
+ },
+ "range": Array [
+ 62,
+ 63,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 64,
+ 69,
+ ],
+ "type": "Keyword",
+ "value": "const",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 11,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 70,
+ 75,
+ ],
+ "type": "Identifier",
+ "value": "async",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 13,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 12,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 76,
+ 77,
+ ],
+ "type": "Punctuator",
+ "value": "=",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 15,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 14,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 78,
+ 79,
+ ],
+ "type": "Numeric",
+ "value": "1",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 16,
+ "line": 5,
+ },
+ "start": Object {
+ "column": 15,
+ "line": 5,
+ },
+ },
+ "range": Array [
+ 79,
+ 80,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 82,
+ 88,
+ ],
+ "type": "Keyword",
+ "value": "import",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 7,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 7,
+ },
+ },
+ "range": Array [
+ 89,
+ 90,
+ ],
+ "type": "Punctuator",
+ "value": "{",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 93,
+ 96,
+ ],
+ "type": "Identifier",
+ "value": "get",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 8,
+ },
+ "start": Object {
+ "column": 5,
+ "line": 8,
+ },
+ },
+ "range": Array [
+ 96,
+ 97,
+ ],
+ "type": "Punctuator",
+ "value": ",",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 5,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 100,
+ 103,
+ ],
+ "type": "Identifier",
+ "value": "set",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 9,
+ },
+ "start": Object {
+ "column": 5,
+ "line": 9,
+ },
+ },
+ "range": Array [
+ 103,
+ 104,
+ ],
+ "type": "Punctuator",
+ "value": ",",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 10,
+ },
+ },
+ "range": Array [
+ 107,
+ 113,
+ ],
+ "type": "Identifier",
+ "value": "module",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 9,
+ "line": 10,
+ },
+ "start": Object {
+ "column": 8,
+ "line": 10,
+ },
+ },
+ "range": Array [
+ 113,
+ 114,
+ ],
+ "type": "Punctuator",
+ "value": ",",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 11,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 11,
+ },
+ },
+ "range": Array [
+ 117,
+ 121,
+ ],
+ "type": "Identifier",
+ "value": "type",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 11,
+ },
+ "start": Object {
+ "column": 6,
+ "line": 11,
+ },
+ },
+ "range": Array [
+ 121,
+ 122,
+ ],
+ "type": "Punctuator",
+ "value": ",",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 7,
+ "line": 12,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 12,
+ },
+ },
+ "range": Array [
+ 125,
+ 130,
+ ],
+ "type": "Identifier",
+ "value": "async",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 8,
+ "line": 12,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 12,
+ },
+ },
+ "range": Array [
+ 130,
+ 131,
+ ],
+ "type": "Punctuator",
+ "value": ",",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 1,
+ "line": 13,
+ },
+ "start": Object {
+ "column": 0,
+ "line": 13,
+ },
+ },
+ "range": Array [
+ 132,
+ 133,
+ ],
+ "type": "Punctuator",
+ "value": "}",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 6,
+ "line": 13,
+ },
+ "start": Object {
+ "column": 2,
+ "line": 13,
+ },
+ },
+ "range": Array [
+ 134,
+ 138,
+ ],
+ "type": "Identifier",
+ "value": "from",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 20,
+ "line": 13,
+ },
+ "start": Object {
+ "column": 7,
+ "line": 13,
+ },
+ },
+ "range": Array [
+ 139,
+ 152,
+ ],
+ "type": "String",
+ "value": "'fake-module'",
+ },
+ Object {
+ "loc": Object {
+ "end": Object {
+ "column": 21,
+ "line": 13,
+ },
+ "start": Object {
+ "column": 20,
+ "line": 13,
+ },
+ },
+ "range": Array [
+ 152,
+ 153,
+ ],
+ "type": "Punctuator",
+ "value": ";",
+ },
+ ],
+ "type": "Program",
+}
+`;
+
exports[`typescript fixtures/basics/nested-type-arguments.src 1`] = `
Object {
"body": Array [
diff --git a/yarn.lock b/yarn.lock
index 53025c9063ac..c6bebb98da3a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4712,7 +4712,7 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"
-lodash._reinterpolate@~3.0.0:
+lodash._reinterpolate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
@@ -4758,19 +4758,19 @@ lodash.sortby@^4.7.0:
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash.template@^4.0.2:
- version "4.4.0"
- resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0"
- integrity sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=
+ version "4.5.0"
+ resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab"
+ integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==
dependencies:
- lodash._reinterpolate "~3.0.0"
+ lodash._reinterpolate "^3.0.0"
lodash.templatesettings "^4.0.0"
lodash.templatesettings@^4.0.0:
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316"
- integrity sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33"
+ integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==
dependencies:
- lodash._reinterpolate "~3.0.0"
+ lodash._reinterpolate "^3.0.0"
lodash.unescape@4.0.1:
version "4.0.1"