Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Breaking: No prefix on FnDec within namespace (fixes #127) #413

Merged
merged 1 commit into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,6 @@ module.exports = function convert(config) {
}
}

/**
* Prefix FunctionDeclarations within TypeScript namespaces with "TS"
*/
if (node.parent && node.parent.kind === SyntaxKind.ModuleBlock) {
functionDeclarationType = AST_NODE_TYPES.TSNamespaceFunctionDeclaration;
}

Object.assign(result, {
type: functionDeclarationType,
id: convertChild(node.name),
Expand Down
9 changes: 2 additions & 7 deletions tests/ast-alignment/fixtures-to-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let fixturesRequiringSourceTypeModule = [];
/**
* Utility to generate a FixturePatternConfig object containing the glob pattern for specific subsections of the fixtures/ directory,
* including the capability to ignore specific nested patterns.
*
*
* @param {string} fixturesSubPath the sub-path within the fixtures/ directory
* @param {Object?} config an optional configuration object with optional sub-paths to ignore and/or parse with sourceType: module
* @returns {FixturePatternConfig} an object containing the glob pattern and optional additional config
Expand Down Expand Up @@ -466,12 +466,7 @@ let fixturePatternConfigsToTest = [
* Babylon: TSDeclareFunction
* tsep: TSNamespaceFunctionDeclaration
*/
"declare-namespace-with-exported-function",
/**
* Babylon: FunctionDeclaration
* tsep: TSNamespaceFunctionDeclaration
*/
"module-with-default-exports"
"declare-namespace-with-exported-function"
]
})
];
Expand Down
34 changes: 17 additions & 17 deletions tests/integration/typescript.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ describe("TypeScript", () => {
);
});

it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
verifyAndAssertMessages(
unpad(`
export namespace foo {
export function bar() {
return;
}
}
export type Qux = true;
`),
{
"no-unreachable": 2
},
[]
);
});

// it("should not produce a false positive for no-restricted-globals rule (#350)", () => {
// verifyAndAssertMessages(
// unpad(`
Expand All @@ -171,23 +188,6 @@ describe("TypeScript", () => {
// );
// });

// it("should correctly apply no-unreachable on TS-constructs (#127)", () => {
// verifyAndAssertMessages(
// unpad(`
// export namespace foo {
// export function bar() {
// return;
// }
// }
// export type Qux = true;
// `),
// {
// "no-unreachable": 2
// },
// []
// );
// });

// it("should not throw a TypeError in the indent rule for invalid code (#309)", () => {
// verifyAndAssertMessages(
// unpad(`
Expand Down
18 changes: 9 additions & 9 deletions tests/lib/__snapshots__/typescript.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ Object {
},
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -2478,7 +2478,7 @@ Object {
},
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -12300,7 +12300,7 @@ Object {
18,
21,
],
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
Object {
Expand Down Expand Up @@ -12396,7 +12396,7 @@ Object {
"type": "TSStringKeyword",
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
Object {
Expand Down Expand Up @@ -12493,7 +12493,7 @@ Object {
"type": "TSStringKeyword",
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -19988,7 +19988,7 @@ Object {
"type": "TSAnyKeyword",
},
},
"type": "FunctionExpression",
"type": "TSEmptyBodyFunctionExpression",
},
},
],
Expand Down Expand Up @@ -20409,7 +20409,7 @@ Object {
"type": "TSStringKeyword",
},
},
"type": "DeclareFunction",
"type": "TSEmptyBodyDeclareFunction",
},
],
"loc": Object {
Expand Down Expand Up @@ -62800,7 +62800,7 @@ Object {
},
},
},
"type": "TSNamespaceFunctionDeclaration",
"type": "TSEmptyBodyFunctionDeclaration",
},
"loc": Object {
"end": Object {
Expand Down Expand Up @@ -63500,7 +63500,7 @@ Object {
93,
110,
],
"type": "TSNamespaceFunctionDeclaration",
"type": "FunctionDeclaration",
},
"loc": Object {
"end": Object {
Expand Down
2 changes: 1 addition & 1 deletion tools/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function createSnapshotTestBlock(code, config) {
* @returns {Object} the AST object
*/
function parse() {
const ast = parser.parse(code, config);
const ast = parser.parseForESLint(code, config).ast;
return getRaw(ast);
}

Expand Down